1# Copyright (c) 2016 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3
4menu "Testing"
5
6source "subsys/testsuite/ztest/Kconfig"
7
8config TEST
9	bool "Mark project as a test"
10	# For tests, store thread names in binary and dump them on crash to
11	# ease debugging.
12	select THREAD_NAME
13	help
14	  Mark a project or an application as a test. This will enable a few
15	  test defaults.
16
17config TEST_EXTRA_STACK_SIZE
18	int "Test function extra thread stack size"
19	default 2048 if COVERAGE_GCOV
20	default 768 if XTENSA
21	default 0
22	depends on TEST
23	help
24	  Additional stack for tests on some platform where default is not
25	  enough.
26
27config HAS_COVERAGE_SUPPORT
28	bool
29	help
30	  The code coverage report generation is only available on boards
31	  with enough spare RAM to buffer the coverage data, or on boards
32	  based on the POSIX ARCH.
33
34config COVERAGE
35	bool "Create coverage data"
36	depends on HAS_COVERAGE_SUPPORT
37	help
38	  This option will build your application with the -coverage option
39	  which will generate data that can be used to create coverage reports.
40	  For more information see
41	  https://docs.zephyrproject.org/latest/guides/coverage.html
42
43choice
44	prompt "Coverage mode"
45	default COVERAGE_NATIVE_GCOV if NATIVE_BUILD
46	default COVERAGE_GCOV if !NATIVE_BUILD
47	depends on COVERAGE
48
49config COVERAGE_NATIVE_GCOV
50	bool "Host compiler gcov based code coverage"
51	depends on NATIVE_BUILD
52	help
53	  Build natively with the compiler standard `--coverage` options,
54	  that is with gcov/GCC-compatible coverage
55
56config COVERAGE_NATIVE_SOURCE
57	bool "Host compiler source based code coverage"
58	depends on NATIVE_BUILD
59	depends on "${ZEPHYR_TOOLCHAIN_VARIANT}" = "llvm"
60	help
61	  Build natively with the compiler source based coverage options.
62	  Today this is only supported with LLVM
63
64config COVERAGE_GCOV
65	bool "Create Coverage data from hardware platform"
66	depends on !NATIVE_BUILD
67	help
68	  This option will select the custom gcov library. The reports will
69	  be available over serial. This serial dump can be passed to
70	  gen_gcov_files.py which creates the required .gcda files. These
71	  can be read by gcov utility. For more details see gcovr.com .
72
73endchoice
74
75config COVERAGE_GCOV_HEAP_SIZE
76	int "Size of heap allocated for gcov coverage data dump"
77	depends on COVERAGE_GCOV
78	default 32768 if X86 || SOC_SERIES_MPS2
79	default 16384
80	help
81	  This option configures the heap size allocated for gcov coverage
82	  data to be dumped over serial. If the value is 0, no buffer will be used,
83	  data will be dumped directly over serial.
84
85config COVERAGE_DUMP
86	bool "Dump coverage data on exit"
87	depends on COVERAGE_GCOV
88	help
89	  Dump collected coverage information to console on exit.
90
91config FORCE_COVERAGE
92	bool "Force coverage"
93	select HAS_COVERAGE_SUPPORT
94	help
95	  Regardless of platform support, it will enable coverage data production.
96	  If the platform does not support coverage by default, setting this config
97	  does not guarantee that coverage data will be gathered.
98	  Application may not fit memory or crash at runtime.
99
100config TEST_USERSPACE
101	bool "Indicate that this test exercises user mode"
102	help
103	  This option indicates that a test case puts threads in user mode,
104	  and that the build system will [override and] enable USERSPACE
105	  if the platform supports it. It should be set in a .conf file on
106	  a per-test basis and is not meant to be used outside test cases.
107	  Tests with this option should also have the "userspace" filtering
108	  tag in their testcase.yaml file.
109
110	  The userspace APIs are no-ops if userspace is not enabled, so it is
111	  OK to enable this even if the test will run on platforms which do
112	  not support userspace. The test should still run on those platforms,
113	  just with all threads in supervisor mode.
114
115	  If a test *requires* that userspace be enabled in order to
116	  pass, CONFIG_ARCH_HAS_USERSPACE should be filtered in its
117	  testcase.yaml.
118
119config TEST_LOGGING_DEFAULTS
120	bool "Test case logging defaults"
121	depends on TEST
122	select LOG
123	select LOG_DEFAULT_MINIMAL
124	default y
125	help
126	  Option which implements default policy of enabling logging in
127	  minimal mode for all test cases. For tests that need alternate
128	  logging configuration, or no logging at all, disable this
129	  in the project-level defconfig.
130
131config TEST_ENABLE_USERSPACE
132	bool
133	depends on TEST_USERSPACE
134	depends on ARCH_HAS_USERSPACE
135	imply USERSPACE
136	imply DYNAMIC_OBJECTS
137	default y
138	help
139	  This hidden option implements the TEST_USERSPACE logic. It turns on
140	  USERSPACE when CONFIG_ARCH_HAS_USERSPACE is set and the test
141	  case itself indicates that it exercises user mode via
142	  CONFIG_TEST_USERSPACE.
143
144config TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
145	bool "Run User Mode tests without additionally enabling stack protection"
146	depends on TEST_ENABLE_USERSPACE
147	default y if SOC_SERIES_KINETIS_KE1XF || SOC_SERIES_S32K1
148	help
149	  A HW platform might not have sufficient MPU/MMU capabilities to support
150	  running all test cases with User Mode and HW Stack Protection features
151	  simultaneously enabled. For this platforms we execute the User Mode-
152	  related tests without enabling HW stack protection.
153
154config TEST_HW_STACK_PROTECTION
155	bool "Hardware-based stack overflow detection if available"
156	depends on ARCH_HAS_STACK_PROTECTION
157	depends on TEST
158	select HW_STACK_PROTECTION
159	default y if !TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
160	help
161	  This option will enable hardware-based stack protection by default
162	  for all test cases if the hardware supports it.
163
164config TEST_FLASH_DRIVERS
165	bool "Test flash drivers"
166	depends on BOARD_QEMU_X86
167	select FLASH_HAS_DRIVER_ENABLED
168	help
169	  This option will help test the flash drivers. This should be enabled
170	  only when using qemu_x86.
171
172config TEST_ARM_CORTEX_M
173	bool
174	depends on CPU_CORTEX_M
175	depends on TEST
176	default y
177	select ARM_SECURE_BUSFAULT_HARDFAULT_NMI if ARM_SECURE_FIRMWARE
178	help
179	  ARM Cortex-M configuration required when testing.
180
181	  This option is used to select stack sizes and enable features for
182	  testing.
183
184	  This option is also used to force routing
185	  BusFault, HardFault, and NMI exceptions to Secure State,
186	  when building a Secure ARMv8-M firmware. This will allow
187	  the testing suite to utilize these exceptions, in tests.
188	  Note that by default, when building with ARM_SECURE_FIRMWARE
189	  set, these exceptions are set to target the Non-Secure state.
190
191config TEST_BUSY_SIM
192	bool "Busy simulator"
193	depends on TEST
194	select ENTROPY_GENERATOR
195	select RING_BUFFER if !XOSHIRO_RANDOM_GENERATOR
196	select COUNTER
197	help
198	  It simulates cpu load by using counter device to generate interrupts
199	  with random intervals and random busy looping in the interrupt.
200
201endmenu
202