diff options
author | Al Semjonovs <asemjonovs@google.com> | 2022-06-17 08:45:47 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-21 17:35:43 +0000 |
commit | fb1a084cfb2dc6fabeef60072a4e6b825f7ac266 (patch) | |
tree | ec9d78c07fba577032a09ee761b3513c0deee3c0 /zephyr/test | |
parent | 28d0b75b708d3d60812bac50e6dae14599b3fe94 (diff) | |
download | chrome-ec-fb1a084cfb2dc6fabeef60072a4e6b825f7ac266.tar.gz |
zephyr: test: Fix flaky panic test
With shuffling enabled panic test is repeated and
data is not restored to prior to test running.
BUG=b:233101019
BRANCH=none
TEST=zmake test test-drivers
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
Change-Id: I968b2108e4940d1bde94846213b807faf6217305
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3712001
Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'zephyr/test')
-rw-r--r-- | zephyr/test/drivers/src/panic.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/zephyr/test/drivers/src/panic.c b/zephyr/test/drivers/src/panic.c index 2615c22156..f33a078253 100644 --- a/zephyr/test/drivers/src/panic.c +++ b/zephyr/test/drivers/src/panic.c @@ -20,10 +20,42 @@ #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +struct panic_test_fixture { + struct panic_data saved_pdata; +}; + +static void *panic_test_setup(void) +{ + static struct panic_test_fixture panic_fixture = {0}; + + return &panic_fixture; +} + +static void panic_before(void *state) +{ + struct panic_test_fixture *fixture = state; + struct panic_data *pdata = get_panic_data_write(); + + ARG_UNUSED(state); + + fixture->saved_pdata = *pdata; +} + +static void panic_after(void *state) +{ + struct panic_test_fixture *fixture = state; + struct panic_data *pdata = get_panic_data_write(); + + ARG_UNUSED(state); + + *pdata = fixture->saved_pdata; +} + /** * @brief Test Suite: Verifies panic functionality. */ -ZTEST_SUITE(panic, drivers_predicate_post_main, NULL, NULL, NULL, NULL); +ZTEST_SUITE(panic, drivers_predicate_post_main, panic_test_setup, panic_before, + panic_after, NULL); /** * @brief TestPurpose: Verify panic set/get reason. |