From 909bd6d9729cb0c6ba6b80cdc283bbd3e1e12770 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Tue, 21 Apr 2015 13:57:18 -0500 Subject: sandbox: Add test function to advance time Add a function that maintains an offset to include in the system timer values returned from the lib/time.c APIs. This will allow timeouts to be skipped instantly in tests Signed-off-by: Joe Hershberger Acked-by: Simon Glass --- board/sandbox/sandbox.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'board/sandbox') diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 2227f1c121..80eaa6334c 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,7 @@ #include #include #include +#include #include /* @@ -25,9 +26,17 @@ void flush_cache(unsigned long start, unsigned long size) { } +/* system timer offset in ms */ +static unsigned long sandbox_timer_offset; + +void sandbox_timer_add_offset(unsigned long offset) +{ + sandbox_timer_offset += offset; +} + unsigned long timer_read_counter(void) { - return os_get_nsec() / 1000; + return os_get_nsec() / 1000 + sandbox_timer_offset * 1000; } int dram_init(void) -- cgit v1.2.1