Difference between revisions of "Zephyr ztest"

From Wiki at Neela Nurseries
Jump to navigation Jump to search
(Create new page for notes about Zephyr ztest and twister framework)
 
m (Add a list of zexpect_ macros)
 
(2 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
Macro ZTEST_SUITE() described at https://docs.zephyrproject.org/3.7.0/develop/test/ztest.html#c.ZTEST_SUITE.  The signature of this function like macro is:
 
Macro ZTEST_SUITE() described at https://docs.zephyrproject.org/3.7.0/develop/test/ztest.html#c.ZTEST_SUITE.  The signature of this function like macro is:
  
  ZTEST_SUITE(SUITE_NAME, PREDICATE, setup_fn, before_fn, after_fn, teardown_fn)
+
<p style='font-family:"Courier New", Courier, monospace; font-size:110%'>
 +
ZTEST_SUITE(SUITE_NAME, PREDICATE, setup_fn, before_fn, after_fn, teardown_fn)
 +
</p>
  
 
Topic - example tests
 
Topic - example tests
  
 
https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/application_development/code_relocation
 
https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/application_development/code_relocation
 +
 +
Topic - zexpect function like macros
 +
 +
The following Zephyr ztest macros were obtained by pattern matching over Zephyr 3.7.0 tests branch.
 +
 +
zexpect_equal
 +
zexpect_not_equal
 +
zexpect_true
 +
zexpect_false
 +
zexpect_ok|not_ok
 +
is_null
 +
not_null
 +
zexpect_within
 +
zexpect_between_inclusive
 +
zexpect_str_equal(s1, s2);
 +
zexpect_call_count
  
 
<!-- odne komnentar -->
 
<!-- odne komnentar -->

Latest revision as of 21:32, 11 November 2025

Overview

Zephyr has extensive documentation on its ztest and "twister" framework. As an aside however, to understand a pattern "Arrange, Act, Assert" test organization see the Zephyr 3.7.0 source file ``zephyrtests/net/lib/lwm2m/block_transfer/src/main.c``.

Topic - Ztest suite macro

Macro ZTEST_SUITE() described at https://docs.zephyrproject.org/3.7.0/develop/test/ztest.html#c.ZTEST_SUITE. The signature of this function like macro is:

ZTEST_SUITE(SUITE_NAME, PREDICATE, setup_fn, before_fn, after_fn, teardown_fn)

Topic - example tests

https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/application_development/code_relocation

Topic - zexpect function like macros

The following Zephyr ztest macros were obtained by pattern matching over Zephyr 3.7.0 tests branch.

zexpect_equal

zexpect_not_equal
zexpect_true
zexpect_false
zexpect_ok|not_ok
is_null
not_null

zexpect_within

zexpect_between_inclusive
zexpect_str_equal(s1, s2);

zexpect_call_count