Commit Graph

168 Commits

Author SHA1 Message Date
Anas Nashif 808266a493 tests: use ignore_fault field instead of tags
Use dedicated field in the yaml file instead of mixing this testing
feature with tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:38:05 -05:00
Anas Nashif 22c3438f1b tests: ztest: fix filtering of tests
Some tests were marked as unit, but this is not a unit test, so they
were completely excluded.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Yuval Peress f460c21578 test: update how unit tests set sources
Replaces cases of setting SOURCES before calling find_package with
proper target_sources.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-31 17:01:59 +01:00
Yuval Peress 4f75848e71 ztest: fix grammar for errors in bad test phases
Addresses the comments in #48846 regarding the error messages

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Yuval Peress dbd63e8008 ztest: add tests for failing on zassume
Add a test to make sure that when a zassume fails, we mark the test
as failed and print an "Assumption failed" error for the test

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Yuval Peress a40a2f5c50 ztest: make failed assumptions fail test binary
Adding the new Kconfig (enabled by default) to make a failed assumption
mark the final result as failed. This change has the following benefits
which have been asked for by the Zephyr community:
1. A failed assumption does not go silent. In this example, the failed
   assumption will still mark the test as skipped, but the final result
   will be to mark the full test run as failed. This would allow
   blocking the CI when an assume fails.
2. Normal test skipping via the ztest_test_skip() is unaffected by this
   change. Those tests will be marked as skipped, but the binary will
   still pass.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-13 06:40:31 -04:00
Yuval Peress 7c48900d14 modules: Remove fff tests
I've update FFF to run tests in the native CI for GitHub, so we no
longer need to run these extra tests. Remove the fff module from
west.yml since the module was only used in the CI and the header
was directly included in the Zephyr tree.

See https://github.com/zephyrproject-rtos/fff/pull/2

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-04 14:24:09 -04:00
Al Semjonovs b27c5d73ef ztest: Fix unused variable compile error in shuffle function
When CONFIG_ZTEST_SHUFFLE is enabled and ASSERTS are disabled
`start_pos` becomes an unused variable leading to a compile error.
Cleaned-up shuffling algorithm to not need a `start_pos` check.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-09-14 20:13:46 -04:00
Michał Barnaś dae8efa692 ztest: remove the obsolete NULL appended to zassert macros
This commit removes the usage of NULL parameter as message in
zassert_* macros after making it optional

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Stephanos Ioannidis 4aa07b584f tests: ztest: ztress: Disable on qemu_cortex_r5
This commit disables the `testing.ztest.ztress` test on
`qemu_cortex_r5` because it fails at run-time when compiled with
GCC 12.

Revert this commit when the GitHub issue #49494, which tracks this bug,
is fixed.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-29 16:57:18 +02:00
Yuval Peress 7187d8b7fc ztest: add framework tests for failed states
Add specialized tests that execute another test indirectly and ensure
that the results report errors correctly. See the README.rst file
provided with this commit for details.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-29 10:27:00 +02:00
Torsten Rasmussen c3fa8b84a3 tests: adopt ztest base test to extended unittest module
With the support of Kconfig in unittest CMake module then prj.conf is
now supported.

Add a prj.conf with ZTEST config settings and remove hardcoded values
from CMakeLists.txt file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Ming Shao 77e1e39cff ztest: add test summary after all suites finish running
Add test summary after all test suites finish running.
The summary can be one-line or verbose, which is configured
with CONFIG_ZTEST_VERBOSE_SUMMARY. The one-line summary covers
overall suite stats. The verbose summary covers each test
function within the suite besides the one-line summary.

The new ztest output ultimately go through the printk. If
printk go through the logging subsystem, there may be log
messages dropped. And if log_panic is invoked, log messages
can be flushed in a mess. So several explicit log flush
are used when printing summary to ensure no content is lost
and content is in good shape.

Some macros are shared between old and new ztests. Such as
TC_START_PRINT and TC_END_PRINT. The are defined accordingly.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-11 09:01:12 -04:00
Stephanos Ioannidis 162f5f7ab2 tests: ztests: error_hook: Enable assert test mode
This commit enables the assert test mode (`CONFIG_ASSERT_TEST`) for the
ztest error hook test because it implements a custom post assert fail
hook (`ztest_post_assert_fail_hook`) that returns without aborting to
faciliate the testing of the assert functions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-10 14:32:36 +02:00
Yuval Peress 84dfb8edf8 ztest: allow asserts anywhere
Updates the ztest_test_fail() function to allow failures in setup.
When executed, a failed assert will fail every test in the suite owning
the setup function. This was verified by adding a suite which asserts
in the setup function and has a test that should pass. During
exeuction, ztest marks the test as failing.

In order to verify exection I also added 2 new APIs:
- ZTEST_EXPECT_FAIL(suite_name, test_name)
- ZTEST_EXPECT_SKIP(suite_name, test_name)

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-09 13:30:15 -04:00
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Yuval Peress 867c50d1cb ztest: mock: delete mock tests
The mock API is being removed in favor of FFF. Remove the tests.

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-25 13:14:17 -04:00
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
Andrei Emeltchenko 4d2bdf59db tests: ztest: Use ztest_test_fail() when needed
Instead of compare true to false use correctly defined function
ztest_test_fail().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-07 15:07:02 -04:00
Andrei Emeltchenko c866c586ab tests: ztest: Add testing Z_TEST_SKIP_IFNDEF() macro
Test new defined macro.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-07 15:07:02 -04:00
Yuval Peress 10feb693f5 unittest: support ztest_new_api
Add support for the new Ztest API when using unittest.

Fixes #47420

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-07 18:22:14 +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 a7ceba3710 testing: add zephyr/ prefix to testing include path
Continuation of issue #41543 to add prefix scope for Zephyr's include
files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-29 06:04:32 -04:00
Yuval Peress ffc0983547 test: unittest: Fix deprecated ZephyrUnittest
Fix the deprecated calls to loading ZephyrUnittest by replacing them
with `Zephyr COMPONENTS unittest`.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-29 06:04:32 -04:00
Yuval Peress d813e9b39f ztest: Fix incorrect use of `this` as fixture
Update `this` to `fixture` to avoid C++ keyword error.

Fixes #46459

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 16:13:18 -04:00
Guo Lixin 169aacdf89 tests: cumstom_output: change output to fit twister
Since output can be cumstomized, so slightly change the output format,
so that twister can parse the output and collect the passrate correctly.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-06-05 14:48:20 +02:00
Fabio Baltieri e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07: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
Yuval Peress 50fe971617 ztest: add userspace tests to base tests
Add a test that verifies that ZTEST_USER is actually being run in
user context.

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Yuval Peress 86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

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
Anas Nashif a6f924db7f twister: add support for platform_type filter
Instead of relying on runtime filter to limit scope to emulation
platforms, use the type attribute for each platform and do the filtering
very early on. This will speed things up for tests where we only run on
emulation platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-14 14:49:59 -04:00
Al Semjonovs 47850a301c ztest: Add config to shuffle test order
Enable ZTEST_DO_THE_SHUFFLE to shuffle the order tests are ran.
Additional configs ZTEST_DO_THE_SHUFFLE_SUITE_REPEAT_COUNT
ZTEST_DO_THE_SHUFFLE_TEST_REPEAT_COUNT specify the number of times
the test or suite is executed.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-05-11 12:14:31 -04: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 c882843af2 Revert "ztest: add userspace tests to base tests"
This reverts commit 395bbb5122.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 18:55:32 -04: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
Yuval Peress 395bbb5122 ztest: add userspace tests to base tests
Add a test that verifies that ZTEST_USER is actually being run in
user context.

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
Al Semjonovs fef6e46f01 ztest: Add Z_TEST_SKIP_IFDEF macro
Defined Z_TEST_SKIP_IFDEF macro to skip tests when specified
config is enabled.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-04-20 15:28:14 -04:00
Katarzyna Giadla 681e3a16c7 tests: Change duplicated names of the test cases
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-03-30 17:42:01 -04:00
Yuval Peress 347a297da2 modules: fff: Fix issue with tests being skipped in CI
The filter in the testcase.yaml made it impossible for these to run.
Also, the Kconfig names for the options didn't really make much sense
so they were renamed to avoid conflict.

This fixes an issue found by #36433.

Signed-off-by: Yuval Peress <peress@google.com>
2022-03-22 12:33:58 +01: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
Krzysztof Chruscinski 2306a97527 tests: Remove limitation from ztress and ring_buffer tests
Test were executed on single CPU only and with qemu_cortex_a9
excluded. Removing those limitations after fixes.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-15 13:19:28 -04:00
Krzysztof Chruscinski 19ea3a6416 tests: ztest: ztress: Relax timing requirements in the test
Seen failures on some platforms. No harm to relax the
check for test timeout.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-15 13:19:28 -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
Anas Nashif 5e05393afa tests: ztress: fix dependency on SMP
Use CONFIG_MP_NUM_CPUS=1 with ztress and do not disable SMP completely.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-12 14:13:21 -05:00
Krzysztof Chruscinski d68c99c517 tests: ztest: ztress: Disable for qemu_cortex_a9
Disable test for platform since it fails there for unknown
reason.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-12 08:49:59 -05:00
Krzysztof Chruscinski af335f85d9 tests: ztest: ztress: Test tweaks and disabling SMP
Disable SMP in the test. Minor tweaks in the test.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-12 08:49:59 -05:00