Skip to content

Commit 73584df

Browse files
nashifcarlescufi
authored andcommitted
twister: support namespacing of extra configs
We want to be able to have platform or architecture extra configs without having to duplicate a whole section of the test specification. This adds support for namespacing of extra configs, for example: arch:nios2:CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 or platform:qemu_x86:CONFIG_FOO=y Signed-off-by: Anas Nashif <[email protected]>
1 parent d9c4ec3 commit 73584df

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

doc/develop/test/twister.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ extra_configs: <list of extra configurations>
310310
extra_configs:
311311
- CONFIG_ADC_ASYNC=y
312312

313+
Using namespacing, it is possible to apply a configuration only to some
314+
hardware. Currently both architectures and platforms are supported::
315+
316+
common:
317+
tags: drivers adc
318+
tests:
319+
test:
320+
depends_on: adc
321+
test_async:
322+
extra_configs:
323+
- arch:x86:CONFIG_ADC_ASYNC=y
324+
- platform:qemu_x86:CONFIG_DEBUG=y
325+
313326

314327
build_only: <True|False> (default False)
315328
If true, don't try to run the test even if the

scripts/pylib/twister/twisterlib/testinstance.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,22 @@ def create_overlay(self, platform, enable_asan=False, enable_ubsan=False, enable
212212
content = ""
213213

214214
if self.testsuite.extra_configs:
215-
content = "\n".join(self.testsuite.extra_configs)
215+
new_config_list = []
216+
# some configs might be conditional on arch or platform, see if we
217+
# have a namespace defined and apply only if the namespace matches.
218+
# we currently support both arch: and platform:
219+
for config in self.testsuite.extra_configs:
220+
cond_config = config.split(":")
221+
if cond_config[0] == "arch" and len(cond_config) == 3:
222+
if self.platform.arch == cond_config[1]:
223+
new_config_list.append(cond_config[2])
224+
elif cond_config[0] == "plaform" and len(cond_config) == 3:
225+
if self.platform.name == cond_config[1]:
226+
new_config_list.append(cond_config[2])
227+
else:
228+
new_config_list.append(config)
229+
230+
content = "\n".join(new_config_list)
216231

217232
if enable_coverage:
218233
if platform.name in coverage_platform:

0 commit comments

Comments
 (0)