summaryrefslogtreecommitdiff
path: root/core/host/timer.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-17 12:21:35 +0800
committerChromeBot <chrome-bot@google.com>2013-05-17 09:52:25 -0700
commitce9d7ca9e9408e22f2bbbe2c72e7df3d5cc1cd43 (patch)
tree2353a8af0ec496157d16d16966cf78f732ddbd87 /core/host/timer.c
parent3155af43eb32274b8dc1985d2001ee478d3b99ef (diff)
downloadchrome-ec-ce9d7ca9e9408e22f2bbbe2c72e7df3d5cc1cd43.tar.gz
Revert "Revert "Scale timer for emulator""
This reverts commit c58c01b14cd45550991be1624146bc813092d202. Let's add time scaling back, but keep the default scale to 1. The emulator behavior should be entirely the same. If a test need to be speeded up, the scale can then be set for that test only. BUG=chrome-os-partner:19235 TEST=Pass all tests. BRANCH=None Change-Id: I648780577a1ae2f964c30c71077ccf9bf38b9735 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51550 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core/host/timer.c')
-rw-r--r--core/host/timer.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/host/timer.c b/core/host/timer.c
index 8de12a7f3c..7a19f7ef63 100644
--- a/core/host/timer.c
+++ b/core/host/timer.c
@@ -12,6 +12,15 @@
#include "task.h"
#include "timer.h"
+/*
+ * For test that need to test for longer than 10 seconds, adjust
+ * its time scale in test/build.mk by specifying
+ * <test_name>-scale=<new scale>.
+ */
+#ifndef TEST_TIME_SCALE
+#define TEST_TIME_SCALE 1
+#endif
+
static timestamp_t boot_time;
void usleep(unsigned us)
@@ -24,7 +33,8 @@ timestamp_t _get_time(void)
struct timespec ts;
timestamp_t ret;
clock_gettime(CLOCK_MONOTONIC, &ts);
- ret.val = 1000000 * (uint64_t)ts.tv_sec + ts.tv_nsec / 1000;
+ ret.val = (1000000000 * (uint64_t)ts.tv_sec + ts.tv_nsec) *
+ TEST_TIME_SCALE / 1000;
return ret;
}