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	help
105	  When the tests complete, do not yield to the idle thread and instead
106	  spin in a loop. This is useful for low power mode tests, where
107	  yielding to the idle thread may put the board into a low power state
108	  where a debugger cannot connect to it.
109
110config ZTEST_WARN_NO_OPTIMIZATIONS
111	bool "Warn when running tests with CONFIG_NO_OPTIMIZATIONS"
112	default y if !(ARCH_POSIX || COVERAGE)
113	depends on NO_OPTIMIZATIONS
114	help
115	  Print a CMake warning when building ztests with no compiler
116	  optimizations. Please don't file issues when running tests that are
117	  not explicitly tuned to work in this configuration.
118
119menu "ZTest provided rules"
120
121config ZTEST_RULE_1CPU
122	bool "Run all the tests on a single CPU"
123	help
124	  This rule will call z_test_1cpu_start before each unit test and
125	  ztest_1cpu_stop after each test.
126
127endmenu
128
129config ZTEST_VERIFY_RUN_ALL
130	bool "Validates all defined tests have ran"
131	default y
132	help
133	  This rule will fail the project if not all tests have been run.
134
135
136config ZTEST_COVERAGE_RESET_BEFORE_TESTS
137	bool "Performs coverage counters reset"
138	depends on COVERAGE_GCOV
139	help
140	  This rule will reset gcov counters before running tests. This ensures
141	  that only code lines triggered by test itself are counted in the coverage report
142	  and all the board initialization code and pre-test bootstrap is not counted.
143	  This is useful when, for example, you are testing code that is also executed during bootup.
144
145config ZTEST_SHUFFLE
146	bool "Shuffle the order of tests and suites"
147	select TEST_RANDOM_GENERATOR if !ENTROPY_HAS_DRIVER
148	help
149	  This rule will shuffle the order of tests and test suites.
150
151if ZTEST_SHUFFLE
152config ZTEST_SHUFFLE_SUITE_REPEAT_COUNT
153	int "Number of iterations the test suite will run"
154	default 3
155	help
156	  This rule will execute a test suite N number of times. The tests
157	  per suite will be shuffled on each iteration.  The test order will likely
158	  be different per iteration.
159
160config ZTEST_SHUFFLE_TEST_REPEAT_COUNT
161	int "Number of iterations the test will run"
162	default 3
163	help
164	  This rule will execute a test N number of times.  The test order will
165	  likely be different per iteration.
166
167endif #ZTEST_SHUFFLE
168
169config ZTEST_SUMMARY
170	bool "Display test summary"
171	default y
172	help
173	  This option controls output of a test summary.
174
175config ZTEST_VERBOSE_OUTPUT
176	bool "Verbose test output"
177	default y
178	help
179	  This option controls whether test output is shown verbosely or
180	  no output at all.
181
182config ZTEST_VERBOSE_SUMMARY
183	bool "Verbose test summary"
184	default y
185	help
186	  This option controls whether suite summary is shown verbosely or
187	  just in one line.
188
189config ZTEST_FAIL_ON_ASSUME
190	bool "Fail the test run when an assumption fails"
191	default y
192	help
193	  When enabled, the test binary will fail at the end if an assumption failed. This means
194	  that while tests will still be marked as skipped on failed zassume calls, the final test
195	  result will be shown as a failure in order to increase visibility. This precludes tests
196	  that skipped with the ZTEST_EXPECT_SKIP annotation.
197
198config TEST_LOGGING_FLUSH_AFTER_TEST
199	bool "When enabled logs are flushed after each test case"
200	default y
201	depends on MULTITHREADING
202
203endif # ZTEST
204
205config ZTEST_MOCKING
206	bool "Mocking support functions"
207	help
208	  Enable mocking support for Ztest. This allows the test to set
209	  return values and expected parameters to functions.
210
211config ZTEST_PARAMETER_COUNT
212	int "Count of parameters or return values reserved"
213	default 10
214	depends on ZTEST_MOCKING
215	help
216	  Maximum amount of concurrent return values / expected parameters.
217
218config ZTRESS
219	bool "Stress test framework"
220	select THREAD_RUNTIME_STATS
221	select THREAD_MONITOR
222	select TEST_RANDOM_GENERATOR if !ENTROPY_HAS_DRIVER
223	depends on !USERSPACE
224
225if ZTRESS
226
227config ZTRESS_MAX_THREADS
228	int "Maximum number of threads in ztress framework"
229	default 3
230	range 1 16
231
232config ZTRESS_STACK_SIZE
233	int "Stack size of Ztress thread"
234	default 4096 if NO_OPTIMIZATIONS
235	default 2048
236
237config ZTRESS_REPORT_PROGRESS_MS
238	int "Progress report interval (in milliseconds)"
239	default 1000
240	help
241	  Use 0 to disable.
242endif # ZTRESS
243