diff options
author | Tristan Honscheid <honscheid@google.com> | 2022-03-25 14:20:49 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-28 22:28:09 +0000 |
commit | 859669dd047c2507090eb52af8501f8f71178839 (patch) | |
tree | f9c9c2165eb3407a3ef9e77666f0bd5a637694fd | |
parent | 5bd1f3c4834fba54b9e0895c2bf4afc42abbf60f (diff) | |
download | chrome-ec-859669dd047c2507090eb52af8501f8f71178839.tar.gz |
zephyr: Add mock for system_jumped_late() function
Certain drivers behave differently when the system has performed a late
jump. For example, the SN5S330 skips certain initialization steps if its
init function runs a second time under a late-jump situation.
To allow testing these different branches in unit tests, add around this
function. By default, its return value is `0`, indicating no late jump.
BRANCH=None
BUG=b:225245353
TEST=zmake -D configure --test test-drivers
Signed-off-by: Tristan Honscheid <honscheid@google.com>
Change-Id: I2dc2132db3363606f0896d9c817e271ff3912190
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3552704
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/system.c | 2 | ||||
-rw-r--r-- | zephyr/test/drivers/include/test_mocks.h | 3 | ||||
-rw-r--r-- | zephyr/test/drivers/src/test_mocks.c | 4 |
3 files changed, 8 insertions, 1 deletions
diff --git a/common/system.c b/common/system.c index 1e8bfe15a5..446b41dc8e 100644 --- a/common/system.c +++ b/common/system.c @@ -351,7 +351,7 @@ int system_jumped_to_this_image(void) return jumped_to_image; } -int system_jumped_late(void) +test_mockable int system_jumped_late(void) { return !(reset_flags & EC_RESET_FLAG_EFS) && jumped_to_image; } diff --git a/zephyr/test/drivers/include/test_mocks.h b/zephyr/test/drivers/include/test_mocks.h index 3630df083f..f29cce97cc 100644 --- a/zephyr/test/drivers/include/test_mocks.h +++ b/zephyr/test/drivers/include/test_mocks.h @@ -102,3 +102,6 @@ DECLARE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int); DECLARE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int); DECLARE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int); + +/* Mocks for common/system.c */ +DECLARE_FAKE_VALUE_FUNC(int, system_jumped_late); diff --git a/zephyr/test/drivers/src/test_mocks.c b/zephyr/test/drivers/src/test_mocks.c index 126246f417..99629374dd 100644 --- a/zephyr/test/drivers/src/test_mocks.c +++ b/zephyr/test/drivers/src/test_mocks.c @@ -14,6 +14,9 @@ DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int); DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int); DEFINE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int); +/* Mocks for common/system.c */ +DEFINE_FAKE_VALUE_FUNC(int, system_jumped_late); + /** * @brief Reset all the fakes before each test. */ @@ -26,6 +29,7 @@ static void fff_reset_rule_before(const struct ztest_unit_test *test, RESET_FAKE(init_rom_map); RESET_FAKE(init_rom_unmap); RESET_FAKE(init_rom_copy); + RESET_FAKE(system_jumped_late); } ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); |