summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-10-03 11:22:10 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-14 17:02:07 +0000
commit8918cd6b953a2c93c09f9e9154ef96b3b95152dc (patch)
tree0d30f0d95a738e18bb21bc74df5b9ea37e2d3ce1 /test
parent45ab4673cb6e7aa589d72f3f3700f7ed74a59e8d (diff)
downloadchrome-ec-8918cd6b953a2c93c09f9e9154ef96b3b95152dc.tar.gz
test: Add on-device abort() test
BRANCH=none BUG=b:234181908 TEST=./test/run_device_tests.py --board bloonchipper abort Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ic92cacdf018bbc8454ed4c7f72546a3ed4d7e4fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3933257 Reviewed-by: Andrea Grandi <agrandi@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/abort.c80
-rw-r--r--test/abort.tasklist10
-rw-r--r--test/build.mk1
-rwxr-xr-xtest/run_device_tests.py1
4 files changed, 92 insertions, 0 deletions
diff --git a/test/abort.c b/test/abort.c
new file mode 100644
index 0000000000..e0069e920f
--- /dev/null
+++ b/test/abort.c
@@ -0,0 +1,80 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <stdlib.h>
+
+#include "common.h"
+#include "panic.h"
+#include "system.h"
+#include "task.h"
+#include "test_util.h"
+
+test_static int test_abort(void)
+{
+ ccprintf("Calling abort\n");
+ cflush();
+ abort();
+ /* Should never reach this. */
+ return EC_ERROR_UNKNOWN;
+}
+
+test_static int test_panic_data(void)
+{
+ const uint32_t expected_reason = PANIC_SW_EXIT;
+ /* Note: The task_id can be found with the "taskinfo" command. */
+ const uint32_t expected_task_id = 5;
+ const uint8_t expected_exception = 0;
+
+ uint32_t reason = 0;
+ uint32_t info = 0;
+ uint8_t exception = UINT8_MAX;
+
+ panic_get_reason(&reason, &info, &exception);
+
+ TEST_EQ(reason, expected_reason, "%08x");
+ TEST_EQ(info, expected_task_id, "%d");
+ TEST_EQ(exception, expected_exception, "%d");
+
+ return EC_SUCCESS;
+}
+
+test_static void run_test_step1(void)
+{
+ test_set_next_step(TEST_STATE_STEP_2);
+ RUN_TEST(test_abort);
+}
+
+test_static void run_test_step2(void)
+{
+ RUN_TEST(test_panic_data);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_PASSED);
+}
+
+void test_run_step(uint32_t state)
+{
+ if (state & TEST_STATE_MASK(TEST_STATE_STEP_1)) {
+ run_test_step1();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) {
+ run_test_step2();
+ }
+}
+
+int task_test(void *unused)
+{
+ if (IS_ENABLED(SECTION_IS_RW))
+ test_run_multistep();
+ return EC_SUCCESS;
+}
+
+void run_test(int argc, const char **argv)
+{
+ test_reset();
+ msleep(30); /* Wait for TASK_ID_TEST to initialize */
+ task_wake(TASK_ID_TEST);
+}
diff --git a/test/abort.tasklist b/test/abort.tasklist
new file mode 100644
index 0000000000..273a9664c0
--- /dev/null
+++ b/test/abort.tasklist
@@ -0,0 +1,10 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST \
+ TASK_TEST(TEST, task_test, NULL, TASK_STACK_SIZE)
diff --git a/test/build.mk b/test/build.mk
index f35744494b..3070e05aae 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -159,6 +159,7 @@ cov-dont-test += rsa
cov-test-list-host = $(filter-out $(cov-dont-test), $(test-list-host))
+abort-y=abort.o
accel_cal-y=accel_cal.o
aes-y=aes.o
# The purpose of the always_memset test is to ensure the functionality of
diff --git a/test/run_device_tests.py b/test/run_device_tests.py
index 81511c835c..b30f115509 100755
--- a/test/run_device_tests.py
+++ b/test/run_device_tests.py
@@ -193,6 +193,7 @@ class AllTests:
def get_public_tests(board_config: BoardConfig) -> List[TestConfig]:
"""Return public test configs for the specified board."""
tests = [
+ TestConfig(test_name="abort"),
TestConfig(test_name="aes"),
TestConfig(test_name="always_memset"),
TestConfig(test_name="cec"),