Commit Graph

35 Commits

Author SHA1 Message Date
Manuel Arguelles be8c7e5a32 tests: error_hook: skip div-by-zero on FVP BaseR
Division-by-zero does not generate an exception on ARM FVP BaseR.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-07-11 11:17:02 +02:00
Yuval Peress e9e030f56b ztest: Add zassume* API
Add an assume API which works like JUnit's. Assumptions can be made
at any point before your test returns (setup, before, and during the
test). If an assumption fails, the test will be marked as skipped.

This helps avoid a cascading affect of failed tests when a base
feature breaks. The feature is expected to have tests and the tests
which depend on it should be skipped (not failed) if that feature
is broken.

Issue #42472

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-04 14:16:34 -04:00
Yuval Peress 52292da328 ztest: migrate error_hook tests to new API
Update the tests to use the new ztest API.

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Guo Lixin 1160994dfb tests: error_hook: remove filter and define testcases in yaml file
1.Remove filter to allow platforms(e.g. qemu_x86) supporting
CONFIG_ARCH_HAS_USERSPACE run testcases when userspace is disabled.

2.Define all testcases in the yaml for consistency and issue parsing
them during setup.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-05-24 08:54:49 -07:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Anas Nashif 85cc902a0d Revert "ztest: migrate error_hook tests to new API"
This reverts commit fa13d57f01.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 18:55:32 -04:00
Yuval Peress fa13d57f01 ztest: migrate error_hook tests to new API
Update the tests to use the new ztest API.

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-26 14:29:18 -04:00
Carlo Caione 82451951cf tests: Misc test fixes for fvp_base_revc_2xaemv8a
Fix several tests for the fvp_base_revc_2xaemv8a board.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-26 09:00:18 +02:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Bradley Bolen c0dd594d4d arch: arm: aarch32: Change CPU_CORTEX_R kconfig option
Change the CPU_CORTEX_R kconfig option to CPU_AARCH32_CORTEX_R to
distinguish the armv7 version from the armv8 version of Cortex-R.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-02-23 08:14:15 -06:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Jim Shu 5a93c74ba3 tests: disable division-by-zero test in RISC-V arch
Because RISC-V arch (M extension) doesn't trigger exception for
division-by-zero, this test can't support RISC-V and is disabled in
RISC-V.

Signed-off-by: Jim Shu <cwshu@andestech.com>
2022-01-11 11:47:03 +01:00
Jaxson Han b7734d2ba0 tests: ztests: error_hook: Fix for Armv8R aarch64
Fix the trigger_fault_access. The fix is similar to cortex m.
Fix the trigger_fault_divide_zero. The fix is similar to qemu, i.e.
skip this testcase, because FVP would not trigger the exception for
dividing zero either.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2021-09-28 20:06:06 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Bradley Bolen 4b1d808456 tests: error_hook: Fix trigger_fault_access for Cortex-R
The Cortex-R platforms may no use XIP which means userspace code with
have read and execute access to some of the RAM so that it can execute
code.  However, userspace will not have access the the protected
read/write parts of RAM so it is safe to use the Cortex-M version of
trigger_fault_access for this test.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2021-08-17 06:06:33 -04:00
Bradley Bolen 3c160ec53e tests: ztest: Do not run division by zero test
The division by zero test needs to be disabled just like the other qemu
boards.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2021-08-17 06:06:33 -04:00
Stephanos Ioannidis 5972224a95 tests: ztest: error_hook: Skip divide-by-zero fault test for QEMU MPS3
QEMU does not generate divide-by-zero exception on the MPS3 emulation,
so do not test it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-08-14 20:28:23 -04:00
Francois Ramu 2bd15ce24a tests: error_hook skipping div-by-0 test on cortex M0 M0+
On the Cortex M0+, M0, M23 the div-by-zero is not mapped
as an hardware exception but triggers a HardFault.
The test case is skipped for any ARMV6_M_ARMV8_M_BASELINE.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-05-28 11:46:09 -05:00
Bradley Bolen 2323319866 tests: ztest: Use #if defined()
This compile test should be checking if a symbol has been defined,
otherwise it is using the kconfig value directly.  This fixes a warning

../src/main.c:115:37: warning: "CONFIG_SOC_QEMU_ARC" is not defined,
evaluates to 0 [-Wundef]

when using the -Wundef flag.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2021-05-26 14:12:01 -05:00
Watson Zeng 01815af28e board: qemu_arc: skip trigger_fault_divide_zero test case
qemu arc has limited support for DIV/REM, no DIVZERO exception
throw, so we need to skip trigger_fault_divide_zero test case.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-05-07 13:15:13 +02:00
Enjia Mai f5e3d89e32 tests: ztest: fix testcase might fail when assertion fail in ISR
Put the testcase test_catch_assert_in_isr() to execute last, to prevent
it affects other test cases. Because when we caught an assert failure
in the ISR handler, it cannot be guaranteed that all the current
program status would be recovered.

Fixes #34844.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-06 12:05:34 +02:00
Enjia Mai 86851434c8 tests: ztest: do not optimize the divide by zero test case
Make the divide instruction not being optimized of the ztest example
test case. Do this because it will be replaced by invalid opcode
exception instruction generated by GCC.

Fixes #33403.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-04 19:09:54 -04:00
Watson Zeng 71a95e8d5a test: error_hook: fix trigger_fault_access for em_starterkit board
em_starterkit has ICCM at 0x0 address, access to 0x0
address doesn't generate any exception, so we access
to 0xFFFFFFFF address instead to trigger exception.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-04-26 10:17:32 +02:00
Ioannis Glaropoulos 21e6299a4b tests: error_hook: fix test case for non-secure cortex-m platforms
When running the test on Cortex-M platforms, use access to
_current to trigger a memory access fault, as this address
is guaranteed to be in kernel ram and will not trigger
SecureFault exceptions.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-04-06 15:33:23 +02:00
Anas Nashif 0ec3774bde userspace: rename _is_user_context -> k_is_user_context
This functions is being called across the tree, no reason why it should
not be a public API.

The current usage violates a few MISRA rules.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-01 05:34:17 -04:00
Eugeniy Paltsev 9db47e156d test: error_hook: check for exact SoCs instead of entire ARC EM family
The quirky behavior when accessing of 0x0 address is related to
exact ARC SoCs/boards and not to entire ARC EM CPUs family. So
check for exact SoCs configs (CONFIG_SOC_ARC_IOT and CONFIG_SOC_NSIM)
instead of checking against CONFIG_CPU_ARCEM.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2021-03-25 07:23:02 -04:00
Reto Schneider fbcc5ae155 tests: error_hook: Fix header name in README
ztest_assert_hook.h does not exist, ztest_error_hook.h should be
included.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2021-03-22 13:45:39 -04:00
Ioannis Glaropoulos 656abe4a6d tests: error_hook: fix sample output in README
Minor fixes to the sample output in the README file,
reflecting the correct error reason (3: oops) instead
of reason 0 (generic CPU error).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-18 10:25:01 +01:00
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