From 3eb3c330960d92fef2c69295e816676c81624951 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 29 May 2024 18:10:32 +0000 Subject: [PATCH] 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. :). 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 --- doc/develop/test/twister.rst | 4 ++++ scripts/pylib/twister/twisterlib/handlers.py | 2 +- scripts/pylib/twister/twisterlib/testinstance.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/develop/test/twister.rst b/doc/develop/test/twister.rst index 3be0132b05c..4773a3e3466 100644 --- a/doc/develop/test/twister.rst +++ b/doc/develop/test/twister.rst @@ -1082,6 +1082,10 @@ can be used multiple times and all given fixtures will be appended as a list. An given fixtures will be assigned to all boards, this means that all boards set by current twister command can run those testcases which request the same fixtures. +Some fixtures allow for configuration strings to be appended, separated from the +fixture name by a ``:``. Only the fixture name is matched against the fixtures +requested by testcases. + Notes +++++ diff --git a/scripts/pylib/twister/twisterlib/handlers.py b/scripts/pylib/twister/twisterlib/handlers.py index 3a3c8de4cb3..4a9ed97ea2d 100755 --- a/scripts/pylib/twister/twisterlib/handlers.py +++ b/scripts/pylib/twister/twisterlib/handlers.py @@ -456,7 +456,7 @@ class DeviceHandler(Handler): dut_found = False for d in self.duts: - if fixture and fixture not in d.fixtures: + if fixture and fixture not in map(lambda f: f.split(sep=':')[0], d.fixtures): continue if d.platform != device or (d.serial is None and d.serial_pty is None): continue diff --git a/scripts/pylib/twister/twisterlib/testinstance.py b/scripts/pylib/twister/twisterlib/testinstance.py index fb0fc1d909b..b7a46fd5008 100644 --- a/scripts/pylib/twister/twisterlib/testinstance.py +++ b/scripts/pylib/twister/twisterlib/testinstance.py @@ -180,7 +180,7 @@ class TestInstance: # command-line, then we need to run the test, not just build it. fixture = testsuite.harness_config.get('fixture') if fixture: - can_run = fixture in fixtures + can_run = fixture in map(lambda f: f.split(sep=':')[0], fixtures) return can_run