diff options
author | Diana Z <dzigterman@chromium.org> | 2023-04-05 14:56:57 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-07 15:27:06 +0000 |
commit | 7e383f28f4db0fbe6b54161234733277e3860f27 (patch) | |
tree | ca2d4bcef8150f4ebe2ba70c4da9b2aef4821649 /zephyr/test | |
parent | 53f35199ba36aa3d983015399453326ee4724240 (diff) | |
download | chrome-ec-7e383f28f4db0fbe6b54161234733277e3860f27.tar.gz |
Zephyr test: Split NX20P3483 specifics into their own test
The driver code in drivers/ppc/nx20p348x.c is split between two
similar PPCs, with the primary difference being their methods of
enabling sourcing and sinking. Split the code for the "3" variant into
its own file so it may be tested separately.
BRANCH=None
BUG=b:276468569
TEST=./twister -T ./zephyr/test
Change-Id: I83a8f0a1b01981aa8654aac472b2fb747bcb9feb
Signed-off-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4404283
Reviewed-by: Aaron Massey <aaronmassey@google.com>
Diffstat (limited to 'zephyr/test')
-rw-r--r-- | zephyr/test/drivers/Kconfig | 1 | ||||
-rw-r--r-- | zephyr/test/drivers/nx20p348x/CMakeLists.txt | 3 | ||||
-rw-r--r-- | zephyr/test/drivers/nx20p348x/include/nx20p348x_test_shared.h | 17 | ||||
-rw-r--r-- | zephyr/test/drivers/nx20p348x/src/nx20p3483.c | 27 | ||||
-rw-r--r-- | zephyr/test/drivers/nx20p348x/src/nx20p348x.c | 21 | ||||
-rw-r--r-- | zephyr/test/drivers/testcase.yaml | 3 |
6 files changed, 50 insertions, 22 deletions
diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index eed9233cd7..256e086bd4 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -100,7 +100,6 @@ config LINK_TEST_SUITE_MKBP config LINK_TEST_SUITE_NX20P348X bool "Link and test the nx20p348x tests" select PLATFORM_EC_CONSOLE_CMD_PPC_DUMP - select PLATFORM_EC_USBC_PPC_NX20P3483 select PLATFORM_EC_USB_PD_LOGGING config LINK_TEST_SUITE_PANIC_OUTPUT diff --git a/zephyr/test/drivers/nx20p348x/CMakeLists.txt b/zephyr/test/drivers/nx20p348x/CMakeLists.txt index ac7c9cceb1..14f27739a1 100644 --- a/zephyr/test/drivers/nx20p348x/CMakeLists.txt +++ b/zephyr/test/drivers/nx20p348x/CMakeLists.txt @@ -2,4 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_sources(app PRIVATE src/nx20p348x.c) +target_sources_ifdef(CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483 app PRIVATE src/nx20p3483.c) diff --git a/zephyr/test/drivers/nx20p348x/include/nx20p348x_test_shared.h b/zephyr/test/drivers/nx20p348x/include/nx20p348x_test_shared.h new file mode 100644 index 0000000000..633dd2e700 --- /dev/null +++ b/zephyr/test/drivers/nx20p348x/include/nx20p348x_test_shared.h @@ -0,0 +1,17 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_DRIVERS_NX20_348X_TEST_SHARED_H_ +#define ZEPHYR_TEST_DRIVERS_NX20_348X_TEST_SHARED_H_ + +#include "emul/emul_nx20p348x.h" + +#define TEST_PORT USBC_PORT_C0 + +struct nx20p348x_driver_fixture { + const struct emul *nx20p348x_emul; +}; + +#endif /* ZEPHYR_TEST_DRIVERS_NX20_348X_TEST_SHARED_H_ */ diff --git a/zephyr/test/drivers/nx20p348x/src/nx20p3483.c b/zephyr/test/drivers/nx20p348x/src/nx20p3483.c new file mode 100644 index 0000000000..7d754112a9 --- /dev/null +++ b/zephyr/test/drivers/nx20p348x/src/nx20p3483.c @@ -0,0 +1,27 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "nx20p348x_test_shared.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "usbc_ppc.h" + +#include <zephyr/shell/shell.h> +#include <zephyr/shell/shell_dummy.h> +#include <zephyr/ztest.h> + +ZTEST(nx20p348x_driver, test_sink_enable_timeout_failure) +{ + /* Note: PPC requires a TCPC GPIO to enable its sinking */ + zassert_equal(ppc_vbus_sink_enable(TEST_PORT, true), EC_ERROR_TIMEOUT); +} + +ZTEST(nx20p348x_driver, test_source_enable_timeout_failure) +{ + /* Note: PPC requires a TCPC GPIO to enable its sourcing */ + zassert_equal(ppc_vbus_source_enable(TEST_PORT, true), + EC_ERROR_TIMEOUT); +} diff --git a/zephyr/test/drivers/nx20p348x/src/nx20p348x.c b/zephyr/test/drivers/nx20p348x/src/nx20p348x.c index 151a7dea66..5ec7ba5ae1 100644 --- a/zephyr/test/drivers/nx20p348x/src/nx20p348x.c +++ b/zephyr/test/drivers/nx20p348x/src/nx20p348x.c @@ -8,7 +8,7 @@ #include "console.h" #include "driver/ppc/nx20p348x.h" #include "driver/ppc/nx20p348x_public.h" -#include "emul/emul_nx20p348x.h" +#include "nx20p348x_test_shared.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" @@ -20,12 +20,6 @@ #define NX20P383X_NODE DT_NODELABEL(nx20p348x_emul) -#define TEST_PORT USBC_PORT_C0 - -struct nx20p348x_driver_fixture { - const struct emul *nx20p348x_emul; -}; - static void *nx20p348x_driver_setup(void) { static struct nx20p348x_driver_fixture fix; @@ -82,19 +76,6 @@ ZTEST_F(nx20p348x_driver, test_discharge_vbus) NX20P348X_CTRL_VBUSDIS_EN); } -ZTEST(nx20p348x_driver, test_sink_enable_timeout_failure) -{ - /* Note: PPC requires a TCPC GPIO to enable its sinking */ - zassert_equal(ppc_vbus_sink_enable(TEST_PORT, true), EC_ERROR_TIMEOUT); -} - -ZTEST(nx20p348x_driver, test_source_enable_timeout_failure) -{ - /* Note: PPC requires a TCPC GPIO to enable its sourcing */ - zassert_equal(ppc_vbus_source_enable(TEST_PORT, true), - EC_ERROR_TIMEOUT); -} - ZTEST(nx20p348x_driver, test_ppc_dump) { const struct shell *shell_zephyr = get_ec_shell(); diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 773a25e361..4c709e1147 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -257,12 +257,13 @@ tests: - CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y tags: common mkbp - drivers.nx20p348x: + drivers.nx20p3483: extra_dtc_overlay_files: - ./boards/native_posix.overlay - ./nx20p348x/usbc.dts extra_configs: - CONFIG_LINK_TEST_SUITE_NX20P348X=y + - CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y drivers.panic_output: extra_configs: - CONFIG_LINK_TEST_SUITE_PANIC_OUTPUT=y |