zephyr/tests/ztest/fail
Alberto Escolar Piedras 28edb220cd tests: Support targeting unit_testing with and without qualifier
For tests that support both targeting unit_testing and
other targets, we check in the cmake code the BOARD variable.
Let's allow users to set this to either of unit_testing
or unit_testing/unit_testing so it behaves like for other
tests.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-10-25 18:51:10 +01:00
..
core tests: Support targeting unit_testing with and without qualifier 2024-10-25 18:51:10 +01:00
src
CMakeLists.txt tests: Support targeting unit_testing with and without qualifier 2024-10-25 18:51:10 +01:00
Kconfig ztest: fix grammar for errors in bad test phases 2022-10-13 06:40:31 -04:00
prj.conf tests: remove CONFIG_ZTEST_NEW_API in all tests 2023-10-20 15:04:29 +02:00
README.rst doc: sphinx-lint: fix bad usage of "default role" 2024-09-13 11:42:51 -05:00
testcase.yaml tests/ztest/fail: Fix yaml description 2024-10-25 18:51:10 +01:00

.. _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.