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