diff options
author | Vic (Chun-Ju) Yang <victoryang@chromium.org> | 2014-01-07 21:54:30 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-01-08 03:49:36 +0000 |
commit | e44cddc7d22b06b740af20a4361f1db0e2d04536 (patch) | |
tree | 1f710f1d16f0fb46733d16c2fa28508826f2aa2b | |
parent | ac4a1f1d64148e1ec5ab7d54894f85c336435e25 (diff) | |
download | chrome-ec-e44cddc7d22b06b740af20a4361f1db0e2d04536.tar.gz |
emulator: Keep fail count across sysjump
When jumping between image copies, we need to preserve the test fail
count. Otherwise tests failed before the jump would be silently ignored.
BUG=chrome-os-partner:19235
TEST=Fail a test case before sysjump and check the whole test fails.
BRANCH=None
Change-Id: Iebde40141f62ac067ddabf629add46e5d752d674
Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/181746
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/test_util.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/common/test_util.c b/common/test_util.c index 3b64b16fec..c5c238d42d 100644 --- a/common/test_util.c +++ b/common/test_util.c @@ -9,12 +9,20 @@ #include <stdlib.h> #include "console.h" +#include "hooks.h" #include "host_command.h" #include "system.h" #include "task.h" #include "test_util.h" #include "util.h" +struct test_util_tag { + uint8_t error_count; +}; + +#define TEST_UTIL_SYSJUMP_TAG 0x5455 /* "TU" */ +#define TEST_UTIL_SYSJUMP_VERSION 1 + int __test_error_count; /* Weak reference function as an entry point for unit test */ @@ -53,7 +61,8 @@ void register_test_end_hook(void) void test_reset(void) { - __test_error_count = 0; + if (!system_jumped_to_this_image()) + __test_error_count = 0; } void test_pass(void) @@ -152,6 +161,30 @@ uint32_t prng_no_seed(void) return seed = prng(seed); } +static void restore_state(void) +{ + const struct test_util_tag *tag; + int version, size; + + tag = (const struct test_util_tag *)system_get_jump_tag( + TEST_UTIL_SYSJUMP_TAG, &version, &size); + if (tag && version == TEST_UTIL_SYSJUMP_VERSION && + size == sizeof(*tag)) + __test_error_count = tag->error_count; + else + __test_error_count = 0; +} +DECLARE_HOOK(HOOK_INIT, restore_state, HOOK_PRIO_DEFAULT); + +static void preserve_state(void) +{ + struct test_util_tag tag; + tag.error_count = __test_error_count; + system_add_jump_tag(TEST_UTIL_SYSJUMP_TAG, TEST_UTIL_SYSJUMP_VERSION, + sizeof(tag), &tag); +} +DECLARE_HOOK(HOOK_SYSJUMP, preserve_state, HOOK_PRIO_DEFAULT); + static int command_run_test(int argc, char **argv) { run_test(); |