tests: error_hook: fix test_catch_z_oops test case
test_catch_z_oops test case should not run in user mode, since Z_OOPS needs to be called in supervisor mode, otherwise we will be getting a reguser user memory access error that is irrelevant to the test case (and simply is triggered by Z_OOPS accessing the thread's syscall frame pointer). In addition to that, we fix the argument of Z_OOPS, because, it was triggering a null-pointer dereferencing, which results in an error thrown before Z_OOPS is even executed (if null-pointer exception is caught). We also need to generate a dummy thread->syscall_frame, that Z_OOPS implementation will access. We fix this to _image_ram_start, because this memory is always part of the image memory and is always available to supervisor mode. So, accessing it won't trigger a security fault, for example. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
3721bb63a8
commit
31f34e01bc
1 changed files with 7 additions and 4 deletions
|
@ -275,9 +275,12 @@ void test_catch_assert_in_isr(void)
|
|||
|
||||
|
||||
#if defined(CONFIG_USERSPACE)
|
||||
static void trigger_z_oops(void *a)
|
||||
static void trigger_z_oops(void)
|
||||
{
|
||||
Z_OOPS(*((bool *)a));
|
||||
/* Set up a dummy syscall frame, pointing to a valid area in memory. */
|
||||
_current->syscall_frame = _image_ram_start;
|
||||
|
||||
Z_OOPS(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,7 +296,7 @@ void test_catch_z_oops(void)
|
|||
case_type = ZTEST_CATCH_USER_FATAL_Z_OOPS;
|
||||
|
||||
ztest_set_fault_valid(true);
|
||||
trigger_z_oops((void *)false);
|
||||
trigger_z_oops();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -308,7 +311,7 @@ void test_main(void)
|
|||
ztest_user_unit_test(test_catch_assert_fail),
|
||||
ztest_user_unit_test(test_catch_fatal_error),
|
||||
ztest_unit_test(test_catch_assert_in_isr),
|
||||
ztest_user_unit_test(test_catch_z_oops)
|
||||
ztest_unit_test(test_catch_z_oops)
|
||||
);
|
||||
ztest_run_test_suite(error_hook_tests);
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue