132 atomic_clear(&handler_calls);
133#if defined(CONFIG_SAFE_DATA_FAULT_HANDLER)
134 atomic_clear(&cb_unrecoverable);
139 sp.payload.a ^= 0x5A5A5A5Au;
141#if defined(CONFIG_SAFE_DATA_FAULT_PANIC)
142 panic_caught =
false;
143 returned_after_fault =
false;
144 k_thread_create(&fault_thread, fault_stack,
145 K_THREAD_STACK_SIZEOF(fault_stack), fault_fn,
146 NULL, NULL, NULL, 5, 0, K_NO_WAIT);
147 zassert_ok(k_thread_join(&fault_thread, K_FOREVER));
148 zassert_true(panic_caught,
"PANIC: the fault must cause a kernel panic");
149 zassert_false(returned_after_fault,
150 "PANIC: the faulting call must not return");
151 zassert_equal(atomic_get(&handler_calls), 0,
152 "PANIC: the handler must not run");
155 "the error code must reach the caller");
156#if defined(CONFIG_SAFE_DATA_FAULT_HANDLER)
157 zassert_equal(atomic_get(&handler_calls), 1,
158 "HANDLER: the handler must run once");
159 zassert_equal_ptr(handler_payload, &sp.payload);
160 zassert_equal(handler_len,
sizeof(sp.payload));
165 zassert_equal(atomic_get(&cb_unrecoverable), 1);
166 zassert_equal(atomic_get(&handler_calls), 1,
167 "HANDLER: a registered callback replaces the handler");
170 zassert_equal(atomic_get(&handler_calls), 0,
171 "RETURN: the handler must not run");
174 zassert_equal(assert_count, 0,
"no assertion expected");
208 zassert_equal(assert_count, 0,
"thread context: no assertion");
211 assert_in_isr =
false;
212 irq_offload(isr_read, NULL);
214 zassert_true(assert_count >= 1,
"ISR context: the call must assert");
215 zassert_true(assert_in_isr,
"the assertion must fire in the ISR");
216 zassert_not_null(assert_file);
217 zassert_not_null(strstr(assert_file,
"safe_data/safe_data.h"),
218 "the first assertion must be the Safe Data ISR check");
232ZTEST_SUITE(safe_data_fault, NULL, NULL, NULL, NULL, NULL);