Lines Matching +full:operations +full:- +full:per +full:- +full:run
1 .. _test-framework:
19 * ``suite_name`` - The name of the suite. This name must be unique within a single binary.
20 * :c:type:`ztest_suite_predicate_t` - An optional predicate function to allow choosing when the
21 test will run. The predicate will get a pointer to the global state passed in through
22 :c:func:`ztest_run_all` and should return a boolean to decide if the suite should run.
23 * :c:type:`ztest_suite_setup_t` - An optional setup function which returns a test fixture. This
24 will be called and run once per test suite run.
25 * :c:type:`ztest_suite_before_t` - An optional before function which will run before every single
27 * :c:type:`ztest_suite_after_t` - An optional after function which will run after every single
29 * :c:type:`ztest_suite_teardown_t` - An optional teardown function which will run at the end of
34 .. code-block:: C
41 return ((const struct test_state*)global_state)->x == 5;
51 * :c:macro:`ZTEST` ``(suite_name, test_name)`` - Which can be used to add a test by ``test_name`` t…
53 * :c:macro:`ZTEST_P` ``(suite_name, test_name)`` - Add a parameterized test to a given suite by spe…
56 * :c:macro:`ZTEST_USER` ``(suite_name, test_name)`` - Which behaves the same as :c:macro:`ZTEST`, o…
57 that when :kconfig:option:`CONFIG_USERSPACE` is enabled, then the test will be run in a userspace
59 * :c:macro:`ZTEST_F` ``(suite_name, test_name)`` - Which behaves the same as :c:macro:`ZTEST`, only
62 * :c:macro:`ZTEST_USER_F` ``(suite_name, test_name)`` - Which combines the fixture feature of
68 Test fixtures can be used to help simplify repeated test setup operations. In many cases, tests in
72 .. code-block:: C
88 fixture->max_size = 256;
96 memset(fixture->buff, 0, fixture->max_size);
97 fixture->size = 0;
109 zassert_equal(0, fixture->size);
110 zassert_equal(256, fixture->max_size);
128 .. code-block:: C
154 Test rules are a way to run the same logic for every test and every suite. There are a lot of cases
159 .. code-block:: C
187 Assuming there's a board with several steps in the power-on sequence a test suite can be written
188 using the ``predicate`` to control when it would run. In that case, the :c:func:`test_main`
191 .. code-block:: C
201 /* Only suites that use a predicate checking for phase == PWR_PHASE_0 will run. */
205 /* Only suites that use a predicate checking for phase == PWR_PHASE_1 will run. */
209 /* Only suites that use a predicate checking for phase == PWR_PHASE_2 will run. */
218 Quick start - Integration testing
229 .. code-block:: console
231 ./scripts/twister -T tests/foo/bar/
233 To select just one of the test scenarios, run Twister with ``--scenario`` command:
235 .. code-block:: console
237 ./scripts/twister --scenario tests/foo/bar/your.test.scenario.name
290 .. code-block:: C
305 Tests (test applications) in the Zephyr tree consist of many test scenarios that run as
314 .. code-block:: console
316 ./scripts/twister --list-tests -T tests/kernel
321 Special- or architecture-specific tests cannot run on all
325 conditionals inside the test suite is sub-optimal. Tests that need
330 .. code-block:: C
354 Quick start - Unit testing
369 .. code-block:: cmake
401 high-level test application, particularly when tests do too
406 - Why not pre-scan with CPP and then parse? or post scan the ELF file?
408 If C pre-processing or building fails because of any issue, then we
411 - Why not declare them in the YAML test configuration?
415 themselves -- only one file to update when changes are made
450 The example below presents how to setup and run 3 contexts (one of which is k_timer
457 .. code-block:: C
469 - :kconfig:option:`CONFIG_ZTRESS_MAX_THREADS` - number of supported threads.
470 - :kconfig:option:`CONFIG_ZTRESS_STACK_SIZE` - Stack size of created threads.
471 - :kconfig:option:`CONFIG_ZTRESS_REPORT_PROGRESS_MS` - Test progress report interval.
491 ``zassert_equal(buf->ref, 2, "Invalid refcount")``:
493 .. code-block:: none
495 … Assertion failed at main.c:62: test_get_single_buffer: Invalid refcount (buf->ref not equal to 2)
512 .. code-block:: C
514 zexpect_equal(buf->ref, 2, "Invalid refcount");
515 zexpect_equal(buf->ref, 1337, "Invalid refcount");
519 .. code-block:: none
521 START - test_get_single_buffer
522 …Expectation failed at main.c:62: test_get_single_buffer: Invalid refcount (buf->ref not equal to 2)
523 …Expectation failed at main.c:63: test_get_single_buffer: Invalid refcount (buf->ref not equal to 1…
524 FAIL - test_get_single_buffer in 0.0 seconds
538 ``zassume_equal(buf->ref, 2, "Invalid refcount")``:
540 .. code-block::none
542 START - test_get_single_buffer
543 … Assumption failed at main.c:62: test_get_single_buffer: Invalid refcount (buf->ref not equal to 2)
544 SKIP - test_get_single_buffer in 0.0 seconds
555 .. _mocking-fff:
563 .. code-block:: C
567 Zephyr provides several FFF-based fake drivers which can be used as either stubs or mocks. Fake
571 - :dtcompatible:`zephyr,fake-can`
572 - :dtcompatible:`zephyr,fake-eeprom`
575 See :ref:`FFF Extensions <fff-extensions>`.
589 .. code-block:: C
603 twister with ``--seed``.
618 or select tests to run. The test argument expects a comma separated list
619 of ``suite::test`` . You can substitute the test name with an ``*`` to run all
624 .. code-block:: bash
626 $ zephyr.exe -list
627 $ zephyr.exe -test="fixture_tests::test_fixture_pointer,framework_tests::test_assert_mem_equal"
628 $ zephyr.exe -test="framework_tests::*"
631 .. _fff-extensions: