1# Copyright (c) 2016 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3
4config ZTEST
5	bool "Zephyr testing framework"
6	select TEST
7	help
8	  Enable the Zephyr testing framework. You should enable this only
9	  if you're writing automated tests.
10
11if ZTEST
12
13config ZTEST_NEW_API
14	bool "Use the new Ztest API"
15	help
16	  Enables the new Ztest APIs for creating suites and unit tests in
17	  separate compilation units as well as the new 'rules' API.
18
19config ZTEST_STACK_SIZE
20	int "Test function thread stack size"
21	default 2048 if COVERAGE_GCOV
22	default 1024
23
24config ZTEST_TEST_DELAY_MS
25	int "Delay between tests in milliseconds"
26	default 0
27	help
28	  Add a delay between between tests to manage output on the console on
29	  systems that can't handle the rapid output rate.
30
31config ZTEST_CPU_HOLD_TIME_MS
32	int "Time in milliseconds to hold other CPUs for 1cpu type tests"
33	default 3000
34	help
35	  This option is used to specify the maximum time in milliseconds for
36	  which a 1cpu type test may execute on a multicpu system. The default
37	  value ought to suffice for most such tests; however slower platforms
38	  (which may include simulators) may need to set this to a larger
39	  value. Please be aware that increasing it for long-running test cases
40	  may overload the CI system. Modify with caution.
41
42config ZTEST_FAIL_FAST
43	bool "Abort on first failing test"
44	help
45	  Stop and abort on first failing test. Do not continue with other
46	  tests that might be in the queue.
47
48config ZTEST_ASSERT_VERBOSE
49	int "Assertion verbosity level"
50	default 1
51	help
52	  Set verbosity level for assertions.
53	  Assertion verbosity levels:
54	  0 Write only file and line for failed assertions
55	  1 Write file, line number, function and reason for failed assertions
56	  2 Log also successful assertions
57
58config ZTEST_THREAD_PRIORITY
59	int "Testing thread priority"
60	default -2 if !PREEMPT_ENABLED
61	default -1
62	help
63	  Set priority of the testing thread. Default is -1 (cooperative).
64
65config ZTEST_TC_UTIL_USER_OVERRIDE
66	bool "Override tc_util.h"
67	help
68	  Enable overriding defines in tc_util.h.
69	  If True the user should provide tc_util_user_override.h in Zephyr's include path,
70	  e.g. by adding zephyr_include_directories(project PRIVATE my_folder) to a project's CMakeLists.txt.
71	  The override header may now #define the various macros and strings in tc_util.h which are
72	  surrounded by #ifndef ... #endif blocks.
73
74config ZTEST_RETEST_IF_PASSED
75	bool "Reset the board to test again if the test passed"
76	select REBOOT
77	help
78	  If the test passed reset the board so it is run again.  This
79	  may be used as an alternative to manual resets when
80	  attempting to reproduce an intermittent failure.
81
82config ZTEST_FATAL_HOOK
83	bool "Using a pre-defined fatal handler and hook function"
84	help
85	  Use the pre-defined common fatal error handler and a post hook to
86	  do actions in your test case, this option often enabled when doing
87	  error test case. Remember to add ignore_fault tag in yaml file when
88	  using twister to run testing.
89
90config ZTEST_ASSERT_HOOK
91	bool "Using a pre-defined assert handler and hook function"
92	help
93	  Use the pre-defined common assert fail handler and a post hook to
94	  do actions in your test case, this option often enabled when doing
95	  error test case. Remember to add ignore_fault tag in yaml file when
96	  using twister to run testing.
97
98config ZTEST_NO_YIELD
99	bool "Do not yield to the idle thread after tests complete"
100	help
101	  When the tests complete, do not yield to the idle thread and instead
102	  spin in a loop. This is useful for low power mode tests, where
103	  yielding to the idle thread may put the board into a low power state
104	  where a debugger cannot connect to it.
105
106config ZTEST_WARN_NO_OPTIMIZATIONS
107	bool "Warn when running tests with CONFIG_NO_OPTIMIZATIONS"
108	default y if !(ARCH_POSIX || COVERAGE)
109	depends on NO_OPTIMIZATIONS
110	help
111	  Print a CMake warning when building ztests with no compiler
112	  optimizations. Please don't file issues when running tests that are
113	  not explicitly tuned to work in this configuration.
114
115if ZTEST_NEW_API
116
117menu "ztest provided rules"
118
119config ZTEST_RULE_1CPU
120	bool "Run all the tests on a single CPU"
121	help
122	  This rule will call z_test_1cpu_start before each unit test and
123	  ztest_1cpu_stop after each test.
124
125endmenu
126
127config ZTEST_VERIFY_RUN_ALL
128	bool "Validates all defined tests have ran"
129	default y
130	help
131	  This rule will fail the project if not all tests have been run.
132
133config ZTEST_SHUFFLE
134	bool "Shuffle the order of tests and suites"
135	select TEST_RANDOM_GENERATOR if !ENTROPY_HAS_DRIVER
136	help
137	  This rule will shuffle the order of tests and test suites.
138
139if ZTEST_SHUFFLE
140config ZTEST_SHUFFLE_SUITE_REPEAT_COUNT
141	int "Number of iterations the test suite will run"
142	default 3
143	help
144	  This rule will execute a test suite N number of times. The tests
145	  per suite will be shuffled on each iteration.  The test order will likely
146	  be different per iteration.
147
148config ZTEST_SHUFFLE_TEST_REPEAT_COUNT
149	int "Number of iterations the test will run"
150	default 3
151	help
152	  This rule will execute a test N number of times.  The test order will
153	  likely be different per iteration.
154
155endif #ZTEST_SHUFFLE
156
157config ZTEST_SUMMARY
158	bool "Display test summary"
159	default y
160	help
161	  This option controls output of a test summary.
162
163config ZTEST_VERBOSE_OUTPUT
164	bool "Verbose test output"
165	default y
166	help
167	  This option controls whether test output is shown verbosely or
168	  no output at all.
169
170config ZTEST_VERBOSE_SUMMARY
171	bool "Verbose test summary"
172	default y
173	help
174	  This option controls whether suite summary is shown verbosely or
175	  just in one line.
176
177config ZTEST_FAIL_ON_ASSUME
178	bool "Fail the test run when an assumption fails"
179	default y
180	help
181	  When enabled, the test binary will fail at the end if an assumption failed. This means
182	  that while tests will still be marked as skipped on failed zassume calls, the final test
183	  result will be shown as a failure in order to increase visibility. This precludes tests
184	  that skipped with the ZTEST_EXPECT_SKIP annotation.
185
186endif # ZTEST_NEW_API
187
188config TEST_LOGGING_FLUSH_AFTER_TEST
189	bool "When enabled logs are flushed after each test case"
190	default y
191	depends on MULTITHREADING
192
193endif # ZTEST
194
195config ZTEST_MOCKING
196	bool "Mocking support functions"
197	help
198	  Enable mocking support for Ztest. This allows the test to set
199	  return values and expected parameters to functions.
200
201config ZTEST_PARAMETER_COUNT
202	int "Count of parameters or return values reserved"
203	default 10
204	depends on ZTEST_MOCKING
205	help
206	  Maximum amount of concurrent return values / expected parameters.
207
208config ZTRESS
209	bool "Stress test framework"
210	select THREAD_RUNTIME_STATS
211	select THREAD_MONITOR
212	select TEST_RANDOM_GENERATOR if !ENTROPY_HAS_DRIVER
213	depends on !USERSPACE
214
215if ZTRESS
216
217config ZTRESS_MAX_THREADS
218	int "Maximum number of threads in ztress framework"
219	default 3
220	range 1 16
221
222config ZTRESS_STACK_SIZE
223	int "Stack size of Ztress thread"
224	default 4096 if NO_OPTIMIZATIONS
225	default 2048
226
227config ZTRESS_REPORT_PROGRESS_MS
228	int "Progress report interval (in milliseconds)"
229	default 1000
230	help
231	  Use 0 to disable.
232endif # ZTRESS
233