diff options
author | Yicheng Li <yichengli@chromium.org> | 2019-06-18 15:24:53 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-27 18:04:38 +0000 |
commit | a24e98da289e8b6bfebcfca6876acc09df28ac6a (patch) | |
tree | 832cb499e0ea85c60f9624d70fd80ecedfc0a5a7 /core | |
parent | aa329f49dc65ec251133fd745ef3f8fc16fd79eb (diff) | |
download | chrome-ec-a24e98da289e8b6bfebcfca6876acc09df28ac6a.tar.gz |
host: make get_time() test_mockable
Make get_time() test_mockable so that we can:
1) make sure the unit tests are deterministic and not flaky (e.g.,
do not depend on system timing, context switches, timer precision)
2) don't execute longer than necessary (e.g., if for some reason we
wanted to test a several second timeout we don't want to delay the
unit tests)
3) verify functionality like timestamp overflow (e.g., things that
are hard to test with a real clock)
BRANCH=nocturne
BUG=chromium:927095
TEST=make -j buildall
Change-Id: Icb26617de6382e554bdfae8258a096565c8a7102
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652627
Tested-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/host/timer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/host/timer.c b/core/host/timer.c index 162bb02644..e76e4b3e3b 100644 --- a/core/host/timer.c +++ b/core/host/timer.c @@ -60,7 +60,7 @@ timestamp_t _get_time(void) return ret; } -timestamp_t get_time(void) +test_mockable timestamp_t get_time(void) { timestamp_t ret = _get_time(); ret.val -= boot_time.val; |