summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}