From ac4562e9be368bca4ba00622a2ca2b2378e0decf Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 29 May 2020 15:37:29 -0700 Subject: test: Use arguments to determine which rollback region to test BRANCH=none BUG=b:155229277, b:151105339 TEST=With dragonclaw v0.2 connected to Segger J-Trace and servo micro: ./test/run_device_tests.py -t rollback_region0 rollback_region1 => PASS Signed-off-by: Tom Hughes Change-Id: Ibb0512d9ea3fa84334b5ba080243f6eef7031c4d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2231724 Commit-Queue: Craig Hesling Reviewed-by: Craig Hesling --- test/rollback.c | 32 +++++++++++++++++--------------- test/run_device_tests.py | 11 +++++++++-- 2 files changed, 26 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/rollback.c b/test/rollback.c index 77a3bff1d6..50c65e876d 100644 --- a/test/rollback.c +++ b/test/rollback.c @@ -6,6 +6,7 @@ #include #include "flash.h" #include "mpu.h" +#include "string.h" #include "test_util.h" struct rollback_info { @@ -93,32 +94,33 @@ test_static int _test_lock_rollback(const struct rollback_info *info, test_static int test_lock_rollback_region_0(void) { + /* This call should never return due to panic. */ return _test_lock_rollback(&rollback_info, 0); } test_static int test_lock_rollback_region_1(void) { + /* This call should never return due to panic. */ return _test_lock_rollback(&rollback_info, 1); } -test_static int test_lock_rollback(void) +void run_test(int argc, char **argv) { - /* This call should never return due to panic. - * TODO(b/156112448): For now you have to manually test each region - * by itself. - */ - test_lock_rollback_region_0(); + if (argc < 2) { + ccprintf("usage: runtest [region0|region1]\n"); + return; + } -#if 0 - test_lock_rollback_region_1(); -#endif + ccprintf("Running rollback test\n"); - return EC_ERROR_UNKNOWN; -} + /* + * TODO(b/156112448): For now you have to run the test separately for + * each region. + */ + if (strncmp(argv[1], "region0", 7) == 0) + RUN_TEST(test_lock_rollback_region_0); + else if (strncmp(argv[1], "region1", 7) == 0) + RUN_TEST(test_lock_rollback_region_1); -void run_test(int argc, char **argv) -{ - ccprintf("Running rollback test\n"); - RUN_TEST(test_lock_rollback); test_print_result(); } diff --git a/test/run_device_tests.py b/test/run_device_tests.py index be5e3b2395..3d9b71ea58 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -36,6 +36,8 @@ SINGLE_CHECK_FAILED_REGEX = re.compile(r'.*failed:.*') DATA_ACCESS_VIOLATION_8020000_REGEX = re.compile( r'Data access violation, mfar = 8020000\r\n') +DATA_ACCESS_VIOLATION_8040000_REGEX = re.compile( + r'Data access violation, mfar = 8040000\r\n') DATA_ACCESS_VIOLATION_20000000_REGEX = re.compile( r'Data access violation, mfar = 20000000\r\n') @@ -98,9 +100,14 @@ ALL_TESTS = { TestConfig(name='mutex'), 'pingpong': TestConfig(name='pingpong'), - 'rollback': + 'rollback_region0': TestConfig(name='rollback', finish_regexes=[ - DATA_ACCESS_VIOLATION_8020000_REGEX]), + DATA_ACCESS_VIOLATION_8020000_REGEX], + test_args=['region0']), + 'rollback_region1': + TestConfig(name='rollback', finish_regexes=[ + DATA_ACCESS_VIOLATION_8040000_REGEX], + test_args=['region1']), 'rollback_entropy': TestConfig(name='rollback_entropy', image_to_use=ImageType.RO), 'rtc': -- cgit v1.2.1