summaryrefslogtreecommitdiff
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
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>
-rw-r--r--Makefile.toolchain3
-rw-r--r--core/host/timer.c12
2 files changed, 13 insertions, 2 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain
index 82119e5462..2679e2b5f1 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -28,7 +28,8 @@ CFLAGS_DEBUG= -g
CFLAGS_INCLUDE=$(foreach i,$(includes),-I$(i) )
CFLAGS_TEST=$(if $(TEST_BUILD),-DTEST_BUILD \
-DTEST_TASKFILE=$(PROJECT).tasklist,) \
- $(if $(EMU_BUILD),-DEMU_BUILD)
+ $(if $(EMU_BUILD),-DEMU_BUILD) \
+ $(if $($(PROJECT)-scale),-DTEST_TIME_SCALE=$($(PROJECT)-scale))
CFLAGS_DEFINE=-DOUTDIR=$(out) -DCHIP=$(CHIP) -DBOARD_TASKFILE=ec.tasklist \
-DBOARD=$(BOARD) -DBOARD_$(BOARD) -DCORE=$(CORE) \
-DCHIP_$(CHIP) -DCHIP_VARIANT=$(CHIP_VARIANT) \
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;
}