diff options
author | Aaron Massey <aaronmassey@google.com> | 2022-09-20 16:28:42 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-26 17:27:03 +0000 |
commit | 7c767a245f22898fb07211e2107dec05d89848d7 (patch) | |
tree | 5c936e397efe44d6f62101b031041e8a0ec188be | |
parent | 6221a3a9571c655ff1e8ef96faf74433e1073b11 (diff) | |
download | chrome-ec-7c767a245f22898fb07211e2107dec05d89848d7.tar.gz |
test: Add initial common usbc ppc test
Add initial common usbc ppc tests which verify the log output from the
ppc_dump console command.
BRANCH=none
BUG=b:247854991
TEST=twister --clobber -i -s zephyr/test/drivers/drivers.usbc_ppc
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Cq-Depend: chromium:3908160
Change-Id: I1fb244b0b64a4d06ff0c2ec75aebb4bf85e548f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3906615
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Tested-by: Aaron Massey <aaronmassey@google.com>
Reviewed-by: Yuval Peress <peress@google.com>
Commit-Queue: Aaron Massey <aaronmassey@google.com>
-rw-r--r-- | zephyr/test/drivers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/test/drivers/Kconfig | 2 | ||||
-rw-r--r-- | zephyr/test/drivers/testcase.yaml | 3 | ||||
-rw-r--r-- | zephyr/test/drivers/usbc_ppc/CMakeLists.txt | 6 | ||||
-rw-r--r-- | zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c | 60 |
5 files changed, 72 insertions, 0 deletions
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index ca154dba79..bad73179dc 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -59,6 +59,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USB_RETIMER_FW_UPDATE usb_retimer_ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE usbc_alt_mode) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_TBT_MODE usbc_tbt_mode) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_OCP usbc_ocp) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_PPC usbc_ppc) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMANDS host_cmd) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_SYSTEM system) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index e1c028572e..bcaec2a8f2 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -56,5 +56,7 @@ config LINK_TEST_SUITE_USBC_TBT_MODE config LINK_TEST_SUITE_USBC_OCP bool "Link tests for common USBC OCP code" +config LINK_TEST_SUITE_USBC_PPC + bool "Link tests for common USBC PPC code" source "Kconfig.zephyr" diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index bb76aede4f..6c16b9a0a8 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -100,3 +100,6 @@ tests: drivers.usbc_ocp: extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_OCP=y + drivers.usbc_ppc: + extra_configs: + - CONFIG_LINK_TEST_SUITE_USBC_PPC=y diff --git a/zephyr/test/drivers/usbc_ppc/CMakeLists.txt b/zephyr/test/drivers/usbc_ppc/CMakeLists.txt new file mode 100644 index 0000000000..01d280c3ad --- /dev/null +++ b/zephyr/test/drivers/usbc_ppc/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Add source files +target_sources(app PRIVATE src/usbc_ppc.c) diff --git a/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c b/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c new file mode 100644 index 0000000000..1b0383960b --- /dev/null +++ b/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <zephyr/kernel.h> +#include <zephyr/shell/shell_dummy.h> +#include <zephyr/ztest.h> +#include <zephyr/ztest_assert.h> + +#include "console.h" +#include "test/drivers/test_state.h" +#include "timer.h" +#include "usbc_ppc.h" + +/* Tests for USBC PPC Common Code */ + +ZTEST(usbc_ppc, test_ppc_dump__no_args) +{ + const struct shell *shell_zephyr = get_ec_shell(); + + /* There's no output from the cmd given < 2 args */ + zassert_equal(shell_execute_cmd(shell_zephyr, "ppc_dump"), + EC_ERROR_PARAM_COUNT); +} + +ZTEST(usbc_ppc, test_ppc_dump__bad_args) +{ + const struct shell *shell_zephyr = get_ec_shell(); + const char *outbuffer; + size_t buffer_size; + + shell_backend_dummy_clear_output(shell_zephyr); + + zassert_equal(shell_execute_cmd(shell_zephyr, "ppc_dump -1"), + EC_ERROR_INVAL); + outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size); + + zassert_true(buffer_size > 0); + zassert_not_null(strstr(outbuffer, "Invalid port!")); +} + +ZTEST(usbc_ppc, test_ppc_dump__good_args) +{ + const struct shell *shell_zephyr = get_ec_shell(); + const char *outbuffer; + size_t buffer_size; + + shell_backend_dummy_clear_output(shell_zephyr); + + zassert_ok(shell_execute_cmd(shell_zephyr, "ppc_dump 0")); + outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size); + + zassert_true(buffer_size > 0); + + /* Weakly verify something reasonable was output to console */ + zassert_not_null(strstr(outbuffer, " = 0x")); +} + +ZTEST_SUITE(usbc_ppc, drivers_predicate_post_main, NULL, NULL, NULL, NULL); |