summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2023-02-13 14:38:21 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-14 17:04:24 +0000
commitf4c0da921f1393c291a17ff96bf21e7d1de445ba (patch)
tree355309447d4c53557afa130dc43a3f0637665031
parentde0b5f3d3cc3e39c6e07fefa68bf459c507899bb (diff)
downloadchrome-ec-f4c0da921f1393c291a17ff96bf21e7d1de445ba.tar.gz
shim/panic: Fix CODE_UNREACHABLE when running test
CODE_UNREACHABLE inisde k_sys_fatal_error_handler is disabled during tests. This was disabled because system_safe_mode needs to test returning from k_sys_fatal_error_handler. However this change will mask asserts in some cases. Switch to __ASSERT_UNREACHABLE which can be disabled on a per test basis. BUG=None BRANCH=None TEST=Unit tests Change-Id: I32e20a5358d85d059985c0cdf4a65ce37e454a80 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4246960 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r--zephyr/shim/include/builtin/assert.h5
-rw-r--r--zephyr/shim/src/panic.c5
-rw-r--r--zephyr/test/system_safe_mode/prj.conf1
3 files changed, 8 insertions, 3 deletions
diff --git a/zephyr/shim/include/builtin/assert.h b/zephyr/shim/include/builtin/assert.h
index 27dce8f2c4..e5e4a34b21 100644
--- a/zephyr/shim/include/builtin/assert.h
+++ b/zephyr/shim/include/builtin/assert.h
@@ -13,4 +13,9 @@
#define ASSERT __ASSERT_NO_MSG
#define assert __ASSERT_NO_MSG
+/* TODO(b/269175417): This should be handled in Zephyr __assert.h */
+#ifndef __ASSERT_UNREACHABLE
+#define __ASSERT_UNREACHABLE CODE_UNREACHABLE
+#endif
+
#endif /* __CROS_EC_ASSERT_H */
diff --git a/zephyr/shim/src/panic.c b/zephyr/shim/src/panic.c
index e7c13f746d..2e9068078b 100644
--- a/zephyr/shim/src/panic.c
+++ b/zephyr/shim/src/panic.c
@@ -3,6 +3,7 @@
* found in the LICENSE file.
*/
+#include "builtin/assert.h"
#include "common.h"
#include "panic.h"
#include "system_safe_mode.h"
@@ -169,9 +170,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf)
* the watchdog will overwrite this panic.
*/
panic_reboot();
-#ifndef TEST_BUILD
- CODE_UNREACHABLE;
-#endif
+ __ASSERT_UNREACHABLE;
}
void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
diff --git a/zephyr/test/system_safe_mode/prj.conf b/zephyr/test/system_safe_mode/prj.conf
index 22294e85d3..f7aeb4b776 100644
--- a/zephyr/test/system_safe_mode/prj.conf
+++ b/zephyr/test/system_safe_mode/prj.conf
@@ -11,6 +11,7 @@ CONFIG_SYSTEM_FAKE=y
CONFIG_PLATFORM_EC_SYSTEM_SAFE_MODE=y
CONFIG_TASK_HOSTCMD_THREAD_DEDICATED=y
CONFIG_PLATFORM_EC_HOSTCMD=y
+CONFIG_ASSERT_TEST=y
# Disable because not needed
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n