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 "[DEPRECATED] Number of iterations the test suite will run" 154 default 3 155 help 156 This is used to execute a test suite N number of times. 157 [DEPRECATED] use ZTEST_SUITE_REPEAT_COUNT instead. 158 159config ZTEST_SHUFFLE_TEST_REPEAT_COUNT 160 int "[DEPRECATED] Number of iterations the test will run" 161 default 3 162 help 163 This is used to execute a test case N number of times. 164 [DEPRECATED] use ZTEST_TEST_REPEAT_COUNT instead. 165 166endif #ZTEST_SHUFFLE 167 168config ZTEST_REPEAT 169 bool "Repeat the tests and suites" 170 help 171 This rule will repeat the tests and the test suites. 172 173if ZTEST_REPEAT 174config ZTEST_SUITE_REPEAT_COUNT 175 int "Number of iterations the test suite will run" 176 default 3 177 help 178 This rule will execute a test suite N number of times. 179 180config ZTEST_TEST_REPEAT_COUNT 181 int "Number of iterations the test will run" 182 default 3 183 help 184 This rule will execute a test N number of times. 185 186endif #ZTEST_REPEAT 187 188config ZTEST_SUMMARY 189 bool "Display test summary" 190 default y 191 help 192 This option controls output of a test summary. 193 194config ZTEST_VERBOSE_OUTPUT 195 bool "Verbose test output" 196 default y 197 help 198 This option controls whether test output is shown verbosely or 199 no output at all. 200 201config ZTEST_VERBOSE_SUMMARY 202 bool "Verbose test summary" 203 default y 204 help 205 This option controls whether suite summary is shown verbosely or 206 just in one line. 207 208config ZTEST_FAIL_ON_ASSUME 209 bool "Fail the test run when an assumption fails" 210 default y 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