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 <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2023-01-11 22:25:08 +00:00 committed by Carles Cufí
commit 73584dfe8d
2 changed files with 29 additions and 1 deletions

View file

@ -310,6 +310,19 @@ extra_configs: <list of extra configurations>
extra_configs:
- CONFIG_ADC_ASYNC=y
Using namespacing, it is possible to apply a configuration only to some
hardware. Currently both architectures and platforms are supported::
common:
tags: drivers adc
tests:
test:
depends_on: adc
test_async:
extra_configs:
- arch:x86:CONFIG_ADC_ASYNC=y
- platform:qemu_x86:CONFIG_DEBUG=y
build_only: <True|False> (default False)
If true, don't try to run the test even if the

View file

@ -212,7 +212,22 @@ class TestInstance:
content = ""
if self.testsuite.extra_configs:
content = "\n".join(self.testsuite.extra_configs)
new_config_list = []
# some configs might be conditional on arch or platform, see if we
# have a namespace defined and apply only if the namespace matches.
# we currently support both arch: and platform:
for config in self.testsuite.extra_configs:
cond_config = config.split(":")
if cond_config[0] == "arch" and len(cond_config) == 3:
if self.platform.arch == cond_config[1]:
new_config_list.append(cond_config[2])
elif cond_config[0] == "plaform" and len(cond_config) == 3:
if self.platform.name == cond_config[1]:
new_config_list.append(cond_config[2])
else:
new_config_list.append(config)
content = "\n".join(new_config_list)
if enable_coverage:
if platform.name in coverage_platform: