Skip to content

Commit c53780b

Browse files
henrikbrixandersenanangl
authored andcommitted
[nrf fromtree] scripts: twister: allow fixtures to contain extra configuration
Allow twister fixtures to contain extra information, which can be used for test suite configuration. The extra information can be appended to existing fixtures separated by a colon (i.e. <fixture>:<configuration>). This is especially useful for the pytest harness, where a fixture of a given type may need to refer to an instance of a particular piece of host hardware needed by the pytest suite (e.g. a network interface, a UART, or a CAN interface connected to the device under test). Signed-off-by: Henrik Brix Andersen <[email protected]> (cherry picked from commit 3eb3c33)
1 parent d52796f commit c53780b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/develop/test/twister.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,10 @@ can be used multiple times and all given fixtures will be appended as a list. An
10821082
given fixtures will be assigned to all boards, this means that all boards set by
10831083
current twister command can run those testcases which request the same fixtures.
10841084

1085+
Some fixtures allow for configuration strings to be appended, separated from the
1086+
fixture name by a ``:``. Only the fixture name is matched against the fixtures
1087+
requested by testcases.
1088+
10851089
Notes
10861090
+++++
10871091

scripts/pylib/twister/twisterlib/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def device_is_available(self, instance):
441441
dut_found = False
442442

443443
for d in self.duts:
444-
if fixture and fixture not in d.fixtures:
444+
if fixture and fixture not in map(lambda f: f.split(sep=':')[0], d.fixtures):
445445
continue
446446
if d.platform != device or (d.serial is None and d.serial_pty is None):
447447
continue

scripts/pylib/twister/twisterlib/testinstance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def testsuite_runnable(testsuite, fixtures):
182182
# command-line, then we need to run the test, not just build it.
183183
fixture = testsuite.harness_config.get('fixture')
184184
if fixture:
185-
can_run = fixture in fixtures
185+
can_run = fixture in map(lambda f: f.split(sep=':')[0], fixtures)
186186

187187
return can_run
188188

0 commit comments

Comments
 (0)