From b8be40607ef74fa8a91690219437c7519570050b Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Fri, 15 Jun 2012 13:59:07 +0800 Subject: [PATCH] Add a test of checking timer value when system jump This test checks the sanity of timer value when jumping between images. BUG=chrome-os-partner:9188 TEST=Test passed Change-Id: If264e28e4ceec6ddb8325f3496825a40e7a038d8 Reviewed-on: https://gerrit.chromium.org/gerrit/25371 Reviewed-by: Vincent Palatin Reviewed-by: Randall Spangler Commit-Ready: Vic Yang Tested-by: Vic Yang --- test/build.mk | 2 +- test/timer_jump.py | 28 ++++++++++++++++++++++++++++ test/timer_jump.tasklist | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 test/timer_jump.py create mode 100644 test/timer_jump.tasklist diff --git a/test/build.mk b/test/build.mk index 5cbbfbcd21..5966f41579 100644 --- a/test/build.mk +++ b/test/build.mk @@ -6,7 +6,7 @@ # on-board test binaries build # -test-list=hello pingpong timer_calib timer_dos mutex +test-list=hello pingpong timer_calib timer_dos timer_jump mutex #disable: powerdemo pingpong-y=pingpong.o diff --git a/test/timer_jump.py b/test/timer_jump.py new file mode 100644 index 0000000000..2f2302e327 --- /dev/null +++ b/test/timer_jump.py @@ -0,0 +1,28 @@ +# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Timer test: check time sanity when jumping between images +# + +import time + +DELAY = 5 +ERROR_MARGIN = 0.5 + +def test(helper): + helper.wait_output("Console is enabled") + helper.ec_command("sysjump ro") + helper.wait_output("Console is enabled") + helper.ec_command("gettime") + ec_start_time = helper.wait_output("Time: 0x[0-9a-f]* = (?P[\d\.]+) s", + use_re=True)["t"] + time.sleep(DELAY) + helper.ec_command("sysjump a") + helper.wait_output("Console is enabled") + helper.ec_command("gettime") + ec_end_time = helper.wait_output("Time: 0x[0-9a-f]* = (?P[\d\.]+) s", + use_re=True)["t"] + + time_diff = float(ec_end_time) - float(ec_start_time) + return time_diff >= DELAY and time_diff <= DELAY + ERROR_MARGIN diff --git a/test/timer_jump.tasklist b/test/timer_jump.tasklist new file mode 100644 index 0000000000..652e8fb6bd --- /dev/null +++ b/test/timer_jump.tasklist @@ -0,0 +1,19 @@ +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * List of enabled tasks in the priority order + * + * The first one has the lowest priority. + * + * For each task, use the macro TASK(n, r, d) where : + * 'n' in the name of the task + * 'r' in the main routine of the task + * 'd' in an opaque parameter passed to the routine at startup + */ +#define CONFIG_TASK_LIST \ + TASK(WATCHDOG, watchdog_task, NULL) \ + TASK(CONSOLE, console_task, NULL) \ + TASK(HOSTCMD, host_command_task, NULL)