diff options
author | Aaron Massey <aaronmassey@google.com> | 2021-10-12 10:31:14 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-28 19:10:14 +0000 |
commit | 11a29a5d8691e1b6acbc135721ffe73fa012bc26 (patch) | |
tree | 978979d54be26451738f846bd14e3297fa5e32c7 /include | |
parent | 3deccd4a73122a5da91a9d47b4983ec426eca73c (diff) | |
download | chrome-ec-11a29a5d8691e1b6acbc135721ffe73fa012bc26.tar.gz |
zephyr: test: Make get_time mockable
Some driver code paths require control of the return value of
get_time in order to be properly tested.
Now get_time can be mocked during tests.
BRANCH=none
BUG=b:184856083
TEST=zmake testall and make runhosttests
Signed-off-by: Aaron Massey <aaronmassey@chromium.org>
Change-Id: I7f66542aaef015263af66d872978c40746a77292
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3219471
Commit-Queue: Aaron Massey <aaronmassey@google.com>
Tested-by: Aaron Massey <aaronmassey@google.com>
Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/timer.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/timer.h b/include/timer.h index d8bc252ba0..340dd8c5e8 100644 --- a/include/timer.h +++ b/include/timer.h @@ -177,4 +177,17 @@ static inline int time_after(uint32_t a, uint32_t b) return time_until(a, b) < 0; } +/** + * @brief Mock get_time() function. + * + * Setting to non-NULL makes subsequent calls to get_time() return + * its set value. + * + * When set to NULL, subsequent calls to get_time() return + * unmocked values. + */ +#ifdef CONFIG_ZTEST +extern timestamp_t *get_time_mock; +#endif /* CONFIG_ZTEST */ + #endif /* __CROS_EC_TIMER_H */ |