zephyr/tests/ztest/fail
Alberto Escolar Piedras 0b3a7bc7d4 tests/ztest/fail: Fix build for native_sim
The final executable output from the native_sim
(or native_posix) build is zephyr.exe
(in native_posix zephyr.elf happened to be just a copy of
the exe, but in native_sim it is an intermediate build step)

So we need to use the exe instead.

Note: As the exe is generated with a custom target, we need
to install it using install(FILES), which also requires the
destination and permissions to be listed manually. The
permissions set are just the cmake default permissions
for install(PROGRAMS).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 12:02:48 +01:00
..
core
src
CMakeLists.txt
Kconfig
README.rst
prj.conf
testcase.yaml

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 ``native_posix`` or
``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.