Revert "Revert "Scale timer for emulator""

This reverts commit c58c01b14c.

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>
This commit is contained in:
Vic Yang
2013-05-17 12:21:35 +08:00
committed by ChromeBot
parent 3155af43eb
commit ce9d7ca9e9
2 changed files with 13 additions and 2 deletions

View File

@@ -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) \

View File

@@ -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;
}