diff options
author | Keith Short <keithshort@chromium.org> | 2022-09-22 16:06:41 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-26 19:24:54 +0000 |
commit | 32c9b990f18f858cfa0e2fbc058f9744daa772d7 (patch) | |
tree | e4ae667a0536583e5bbeddbded6926e6668c9afc | |
parent | d5f41cd622bca61d06b896f3ecce63a5109ae651 (diff) | |
download | chrome-ec-32c9b990f18f858cfa0e2fbc058f9744daa772d7.tar.gz |
zephyr: tests: Create test_utils library
Create a common library that can be shared by all tests. Currently
defines the FFF globals.
BUG=none
BRANCH=none
TEST=twister
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: Iaff8bcf428c24fcb2aebdc56ad54c96586c17d3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3916579
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/test/drivers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/test/drivers/common/src/test_mocks.c | 2 | ||||
-rw-r--r-- | zephyr/test/kingler/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/test/kingler/src/fakes.c | 1 | ||||
-rw-r--r-- | zephyr/test/krabby/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/test/krabby/src/charger_workaround.c | 2 | ||||
-rw-r--r-- | zephyr/test/system_common/CMakeLists.txt | 3 | ||||
-rw-r--r-- | zephyr/test/test_utils/CMakeLists.txt | 9 | ||||
-rw-r--r-- | zephyr/test/test_utils/fff.c (renamed from zephyr/test/system_common/src/fff.c) | 0 |
9 files changed, 17 insertions, 5 deletions
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index bad73179dc..92b690a40a 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -7,6 +7,7 @@ find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(drivers) add_subdirectory(common) +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) get_target_property(TEST_SOURCES app SOURCES) diff --git a/zephyr/test/drivers/common/src/test_mocks.c b/zephyr/test/drivers/common/src/test_mocks.c index 2a4640b342..ab6c65313d 100644 --- a/zephyr/test/drivers/common/src/test_mocks.c +++ b/zephyr/test/drivers/common/src/test_mocks.c @@ -7,8 +7,6 @@ #include "test/drivers/test_mocks.h" -DEFINE_FFF_GLOBALS; - /* Mocks for common/init_rom.c */ DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int); DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int); diff --git a/zephyr/test/kingler/CMakeLists.txt b/zephyr/test/kingler/CMakeLists.txt index 2841ad7e29..a78c4dd497 100644 --- a/zephyr/test/kingler/CMakeLists.txt +++ b/zephyr/test/kingler/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(kingler) +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/corsola/include") target_sources(app PRIVATE src/fakes.c) diff --git a/zephyr/test/kingler/src/fakes.c b/zephyr/test/kingler/src/fakes.c index c233a368df..bc6e2ae523 100644 --- a/zephyr/test/kingler/src/fakes.c +++ b/zephyr/test/kingler/src/fakes.c @@ -6,7 +6,6 @@ #include <zephyr/fff.h> #include "gpio_signal.h" -DEFINE_FFF_GLOBALS; FAKE_VOID_FUNC(power_button_interrupt, enum gpio_signal); FAKE_VOID_FUNC(button_interrupt, enum gpio_signal); FAKE_VOID_FUNC(lid_interrupt, enum gpio_signal); diff --git a/zephyr/test/krabby/CMakeLists.txt b/zephyr/test/krabby/CMakeLists.txt index eba91a7be4..f50aa63d97 100644 --- a/zephyr/test/krabby/CMakeLists.txt +++ b/zephyr/test/krabby/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(krabby) +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/corsola/include") target_sources(app PRIVATE diff --git a/zephyr/test/krabby/src/charger_workaround.c b/zephyr/test/krabby/src/charger_workaround.c index 97aa4328c8..afd3fe5f0c 100644 --- a/zephyr/test/krabby/src/charger_workaround.c +++ b/zephyr/test/krabby/src/charger_workaround.c @@ -15,8 +15,6 @@ #include "i2c.h" #include "system.h" -DEFINE_FFF_GLOBALS; - FAKE_VALUE_FUNC(int, board_get_version); const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(charger)); diff --git a/zephyr/test/system_common/CMakeLists.txt b/zephyr/test/system_common/CMakeLists.txt index 05938b2ec6..305d056068 100644 --- a/zephyr/test/system_common/CMakeLists.txt +++ b/zephyr/test/system_common/CMakeLists.txt @@ -6,5 +6,8 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(system_common_test) +# Include FFF fakes +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + FILE(GLOB test_sources src/*.c) target_sources(app PRIVATE ${test_sources}) diff --git a/zephyr/test/test_utils/CMakeLists.txt b/zephyr/test/test_utils/CMakeLists.txt new file mode 100644 index 0000000000..53baafc624 --- /dev/null +++ b/zephyr/test/test_utils/CMakeLists.txt @@ -0,0 +1,9 @@ +# 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. + +zephyr_interface_library_named(test_utils) + +zephyr_library_sources(fff.c) + +zephyr_library_link_libraries(test_utils) diff --git a/zephyr/test/system_common/src/fff.c b/zephyr/test/test_utils/fff.c index 3b10dc3706..3b10dc3706 100644 --- a/zephyr/test/system_common/src/fff.c +++ b/zephyr/test/test_utils/fff.c |