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	default 32768 if X86 || SOC_SERIES_MPS2
78	default 16384
79	help
80	  This option configures the heap size allocated for gcov coverage
81	  data to be dumped over serial. If the value is 0, no buffer will be used,
82	  data will be dumped directly over serial.
83
84config COVERAGE_DUMP
85	bool "Dump coverage data on exit"
86	depends on COVERAGE_GCOV
87	help
88	  Dump collected coverage information to console on exit.
89
90config FORCE_COVERAGE
91	bool "Force coverage"
92	select HAS_COVERAGE_SUPPORT
93	help
94	  Regardless of platform support, it will enable coverage data production.
95	  If the platform does not support coverage by default, setting this config
96	  does not guarantee that coverage data will be gathered.
97	  Application may not fit memory or crash at runtime.
98
99config TEST_USERSPACE
100	bool "Indicate that this test exercises user mode"
101	help
102	  This option indicates that a test case puts threads in user mode,
103	  and that the build system will [override and] enable USERSPACE
104	  if the platform supports it. It should be set in a .conf file on
105	  a per-test basis and is not meant to be used outside test cases.
106	  Tests with this option should also have the "userspace" filtering
107	  tag in their testcase.yaml file.
108
109	  The userspace APIs are no-ops if userspace is not enabled, so it is
110	  OK to enable this even if the test will run on platforms which do
111	  not support userspace. The test should still run on those platforms,
112	  just with all threads in supervisor mode.
113
114	  If a test *requires* that userspace be enabled in order to
115	  pass, CONFIG_ARCH_HAS_USERSPACE should be filtered in its
116	  testcase.yaml.
117
118config TEST_LOGGING_DEFAULTS
119	bool "Test case logging defaults"
120	depends on TEST
121	select LOG
122	select LOG_DEFAULT_MINIMAL
123	default y
124	help
125	  Option which implements default policy of enabling logging in
126	  minimal mode for all test cases. For tests that need alternate
127	  logging configuration, or no logging at all, disable this
128	  in the project-level defconfig.
129
130config TEST_ENABLE_USERSPACE
131	bool
132	depends on TEST_USERSPACE
133	depends on ARCH_HAS_USERSPACE
134	select USERSPACE
135	select DYNAMIC_OBJECTS
136	default y
137	help
138	  This hidden option implements the TEST_USERSPACE logic. It turns on
139	  USERSPACE when CONFIG_ARCH_HAS_USERSPACE is set and the test
140	  case itself indicates that it exercises user mode via
141	  CONFIG_TEST_USERSPACE.
142
143config TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
144	bool "Run User Mode tests without additionally enabling stack protection"
145	depends on TEST_ENABLE_USERSPACE
146	default y if SOC_SERIES_KINETIS_KE1XF || SOC_SERIES_S32K1XX
147	help
148	  A HW platform might not have sufficient MPU/MMU capabilities to support
149	  running all test cases with User Mode and HW Stack Protection features
150	  simultaneously enabled. For this platforms we execute the User Mode-
151	  related tests without enabling HW stack protection.
152
153config TEST_HW_STACK_PROTECTION
154	bool "Hardware-based stack overflow detection if available"
155	depends on ARCH_HAS_STACK_PROTECTION
156	depends on TEST
157	select HW_STACK_PROTECTION
158	default y if !TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
159	help
160	  This option will enable hardware-based stack protection by default
161	  for all test cases if the hardware supports it.
162
163config TEST_FLASH_DRIVERS
164	bool "Test flash drivers"
165	depends on BOARD_QEMU_X86
166	select FLASH_HAS_DRIVER_ENABLED
167	select FLASH_HAS_PAGE_LAYOUT
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