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.
82
83config COVERAGE_DUMP
84	bool "Dump coverage data on exit"
85	depends on COVERAGE_GCOV
86	help
87	  Dump collected coverage information to console on exit.
88
89config TEST_USERSPACE
90	bool "Indicate that this test exercises user mode"
91	help
92	  This option indicates that a test case puts threads in user mode,
93	  and that the build system will [override and] enable USERSPACE
94	  if the platform supports it. It should be set in a .conf file on
95	  a per-test basis and is not meant to be used outside test cases.
96	  Tests with this option should also have the "userspace" filtering
97	  tag in their testcase.yaml file.
98
99	  The userspace APIs are no-ops if userspace is not enabled, so it is
100	  OK to enable this even if the test will run on platforms which do
101	  not support userspace. The test should still run on those platforms,
102	  just with all threads in supervisor mode.
103
104	  If a test *requires* that userspace be enabled in order to
105	  pass, CONFIG_ARCH_HAS_USERSPACE should be filtered in its
106	  testcase.yaml.
107
108config TEST_LOGGING_DEFAULTS
109	bool "Test case logging defaults"
110	depends on TEST
111	select LOG
112	select LOG_DEFAULT_MINIMAL
113	default y
114	help
115	  Option which implements default policy of enabling logging in
116	  minimal mode for all test cases. For tests that need alternate
117	  logging configuration, or no logging at all, disable this
118	  in the project-level defconfig.
119
120config TEST_ENABLE_USERSPACE
121	bool
122	depends on TEST_USERSPACE
123	depends on ARCH_HAS_USERSPACE
124	select USERSPACE
125	select DYNAMIC_OBJECTS
126	default y
127	help
128	  This hidden option implements the TEST_USERSPACE logic. It turns on
129	  USERSPACE when CONFIG_ARCH_HAS_USERSPACE is set and the test
130	  case itself indicates that it exercises user mode via
131	  CONFIG_TEST_USERSPACE.
132
133config TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
134	bool "Run User Mode tests without additionally enabling stack protection"
135	depends on TEST_ENABLE_USERSPACE
136	default y if SOC_SERIES_KINETIS_KE1XF
137	help
138	  A HW platform might not have sufficient MPU/MMU capabilities to support
139	  running all test cases with User Mode and HW Stack Protection features
140	  simultaneously enabled. For this platforms we execute the User Mode-
141	  related tests without enabling HW stack protection.
142
143config TEST_HW_STACK_PROTECTION
144	bool "Hardware-based stack overflow detection if available"
145	depends on ARCH_HAS_STACK_PROTECTION
146	depends on TEST
147	select HW_STACK_PROTECTION
148	default y if !TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
149	help
150	  This option will enable hardware-based stack protection by default
151	  for all test cases if the hardware supports it.
152
153config TEST_FLASH_DRIVERS
154	bool "Test flash drivers"
155	depends on BOARD_QEMU_X86
156	select FLASH_HAS_DRIVER_ENABLED
157	select FLASH_HAS_PAGE_LAYOUT
158	help
159	  This option will help test the flash drivers. This should be enabled
160	  only when using qemu_x86.
161
162config TEST_ARM_CORTEX_M
163	bool
164	depends on CPU_CORTEX_M
165	depends on TEST
166	default y
167	select ARM_SECURE_BUSFAULT_HARDFAULT_NMI if ARM_SECURE_FIRMWARE
168	help
169	  ARM Cortex-M configuration required when testing.
170
171	  This option is used to select stack sizes and enable features for
172	  testing.
173
174	  This option is also used to force routing
175	  BusFault, HardFault, and NMI exceptions to Secure State,
176	  when building a Secure ARMv8-M firmware. This will allow
177	  the testing suite to utilize these exceptions, in tests.
178	  Note that by default, when building with ARM_SECURE_FIRMWARE
179	  set, these exceptions are set to target the Non-Secure state.
180
181config TEST_BUSY_SIM
182	bool "Busy simulator"
183	depends on TEST
184	select ENTROPY_GENERATOR
185	select RING_BUFFER if !XOSHIRO_RANDOM_GENERATOR
186	select COUNTER
187	help
188	  It simulates cpu load by using counter device to generate interrupts
189	  with random intervals and random busy looping in the interrupt.
190
191endmenu
192