Commit graph

57 commits

Author SHA1 Message Date
Ioannis Glaropoulos
31f34e01bc 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>
2021-03-18 10:25:01 +01:00
Ioannis Glaropoulos
3721bb63a8 tests: error_hook: typo and style fixes in main.c
The commit fixes several style and typo errors in main.c.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-18 10:25:01 +01:00
Ioannis Glaropoulos
f78759ea86 tests: error_hook: documentation and style fixes in README
Add documentation, style and typo fixes in the README.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-18 10:25:01 +01:00
Ioannis Glaropoulos
f620ceacde tests: modify test case so it does not crash on cortex-m
The test case suggests that "For most arch which support
userspace, derefencing NULL pointer will be caught by
exception.". This is certainly not true for Cortex-M, where
read access to address 0x0 is generally allowed. The reason
the test had been passing was either 1) because in many
Cortex-M platforms, including QEMU, address 0x0 is unmapped,
or 2) GCC is generating an undefining instruction. However,
now that we have activated the null pointer derefrencing
detection, we may end up with two exceptions and the test
would fail.

Change illegal access to something outside the mapped memory
area, e.g. 0xFFFFFFFF.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-05 15:03:24 +03:00
Enjia Mai
bd1d0b22b5 tests: ztest: fix error_hook test case fail in some board
Enlarge the test thread stack size, to fix test case fail
in some board which need more stack size for testing, when
CONFIG_EXCEPTION_DEBUG is enabled.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-02-04 13:09:55 -05:00
Enjia Mai
3035d75fe2 tests: ztest: Fix issues due to test case of accessing NULL address
Fix issue #31339 and #31419, test case fail due to access NULL did not
trigger a fatal error in some platform such as nsim_em and iotdk.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-02-03 13:27:23 -05:00
Enjia Mai
489223146f tests: ztest: add test cases and example for fatal handler hook
Add testing for fatal and assert handler hook feature, and examples
of how to use it.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-01-13 09:05:31 -05:00