zephyr/tests/ztest/fail
Alberto Escolar Piedras 4f152b2a81 tests/ztest: Don't test on native_posix
native_posix is now deprecated.
Building these tests in both native_sim and native_posix does not
improve coverage for the tests or subsystem but doubles CI time.
As anyhow native_posix will be removed all together in
2 releases, let's remove it already for these.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-25 04:04:36 -04:00
..
core
src
CMakeLists.txt
Kconfig
README.rst
prj.conf
testcase.yaml tests/ztest: Don't test on native_posix 2024-09-25 04:04:36 -04:00

README.rst

.. _ztest_framework_failure_tests:

Ztest framework failure tests
#############################

Overview
********

In order to test the actual framework's failure cases, this test suite has to do something unique.
There's a subdirectory to this test called 'core'. This project builds a sample as a
:ref:`native_sim <native_sim>` or :ref:`unit_testing <ztest_unit_testing>`
binary which is expected to fail by calling one of the following:
- ``ztest_test_fail()`` during either the ``after`` or ``teardown`` phase of the test suite
- ``ztest_test_skip()`` during either the ``after`` or ``teardown`` phase of the test suite
- ``ztest_test_pass()`` during either the ``after`` or ``teardown`` phase of the test suite

Note that these can be called indirectly through failed asserts or assumptions.

The binary by itself, when executed, will fail to run and return a code of ``1``. The main test
binary will use ``popen()`` to run the failing test binary and will assert both the return code and
the output. The output itself cannot be printed to the log as it will confuse ``twister`` by
reporting a failure.