diff options
author | Yuval Peress <peress@google.com> | 2022-08-24 23:50:52 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-31 18:05:06 +0000 |
commit | 887a3f6c0e556bfb8308cf124edf087e53635ea8 (patch) | |
tree | ad7dbe259962aa2bdfacd75d75b2d31978b44257 /include | |
parent | 5242100ccb366df8c3a5c6897733f02c8c31cabd (diff) | |
download | chrome-ec-887a3f6c0e556bfb8308cf124edf087e53635ea8.tar.gz |
test: Add basic tests exercising the panic output API
Exercise some of the panic output API. Some of the basic printing API
cannot yet be fully tested. But a fix upstream is coming to allow us
to use the 'console' harness features to parse the output log and
pass/fail the test based on output.
BRANCH=none
BUG=none
TEST=twister -s zephyr/test/drivers/drivers.default
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: I8e56e8bcdaa0e095891c38a26e56ced8f3a8d4d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855593
Reviewed-by: Simon Glass <sjg@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 4 | ||||
-rw-r--r-- | include/panic.h | 21 | ||||
-rw-r--r-- | include/system.h | 4 |
3 files changed, 24 insertions, 5 deletions
diff --git a/include/common.h b/include/common.h index dc20787e5b..49f5a4c15b 100644 --- a/include/common.h +++ b/include/common.h @@ -252,11 +252,15 @@ #define test_mockable __attribute__((weak)) #define test_mockable_static __attribute__((weak)) #define test_mockable_static_inline __attribute__((weak)) +#define test_mockable_noreturn __attribute__((weak)) +#define test_mockable_static_noreturn __attribute__((weak)) #define test_export_static #else #define test_mockable #define test_mockable_static static #define test_mockable_static_inline static inline +#define test_mockable_noreturn noreturn +#define test_mockable_static_noreturn static noreturn #define test_export_static static #endif diff --git a/include/panic.h b/include/panic.h index 1ccdbb41f6..6553b6feb0 100644 --- a/include/panic.h +++ b/include/panic.h @@ -15,6 +15,19 @@ #include "software_panic.h" +/* + * Define these helpers if needed. While normally they would be derived from + * common.h, we cannot include that header here because this file is also used + * in the ectool and the build breaks. + */ +#ifndef test_mockable_noreturn +#if defined(TEST_BUILD) || defined(CONFIG_ZTEST) +#define test_mockable_noreturn __attribute__((weak)) +#else +#define test_mockable_noreturn noreturn +#endif +#endif /* test_mockable_noreturn */ + #ifdef __cplusplus extern "C" { #endif @@ -197,10 +210,10 @@ void panic_data_ccprint(const struct panic_data *pdata); * @param linenum Line number where assertion happened */ #ifdef CONFIG_DEBUG_ASSERT_BRIEF -noreturn void panic_assert_fail(const char *fname, int linenum); +test_mockable_noreturn void panic_assert_fail(const char *fname, int linenum); #else -noreturn void panic_assert_fail(const char *msg, const char *func, - const char *fname, int linenum); +test_mockable_noreturn void panic_assert_fail(const char *msg, const char *func, + const char *fname, int linenum); #endif /** @@ -228,7 +241,7 @@ noreturn * Store a panic log and halt the system for a software-related reason, such as * stack overflow or assertion failure. */ -noreturn void software_panic(uint32_t reason, uint32_t info); +test_mockable_noreturn void software_panic(uint32_t reason, uint32_t info); /** * Log a panic in the panic log, but don't halt the system. Normally diff --git a/include/system.h b/include/system.h index 3dee2e9c30..ab9f6b6677 100644 --- a/include/system.h +++ b/include/system.h @@ -372,7 +372,9 @@ const char *system_get_build_info(void); * * @param flags Reset flags; see SYSTEM_RESET_* above. */ -#if !(defined(TEST_FUZZ) || defined(CONFIG_ZTEST)) +#if (defined(TEST_FUZZ) || defined(CONFIG_ZTEST)) +test_mockable +#else noreturn #endif void |