From a24e98da289e8b6bfebcfca6876acc09df28ac6a Mon Sep 17 00:00:00 2001 From: Yicheng Li Date: Tue, 18 Jun 2019 15:24:53 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652627 Tested-by: Tom Hughes Commit-Queue: Tom Hughes Reviewed-by: Daisuke Nojiri --- core/host/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') 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; -- cgit v1.2.1