Skip to content

Commit 7f105ce

Browse files
Chen Peng1nashif
authored andcommitted
twister: support board@revision in platform filter
support to use board@revision as platform filter when running twister, like "twister -p nucleo_f030r8@1 ...". Signed-off-by: Chen Peng1 <[email protected]>
1 parent f7496df commit 7f105ce

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

doc/develop/test/twister.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ you can build and run all possible tests using the following options:
5151
This will build for all available boards and run all applicable tests in
5252
a simulated (for example QEMU) environment.
5353

54+
If you want to run tests on one or more specific platforms, you can use
55+
the ``--platform`` option, it is a platform filter for testing, with this
56+
option, test suites will only be built/run on the platforms specified.
57+
This option also supports different revisions of one same board,
58+
you can use ``--platform board@revision`` to test on a specific revision.
59+
5460
The list of command line options supported by twister can be viewed using::
5561

5662
$ ./scripts/twister --help

scripts/pylib/twister/twisterlib/testplan.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from collections import OrderedDict
1414
from itertools import islice
1515
import logging
16+
import copy
1617

1718
logger = logging.getLogger('twister')
1819
logger.setLevel(logging.DEBUG)
@@ -366,6 +367,23 @@ def add_configurations(self):
366367
self.platforms.append(platform)
367368
if platform.default:
368369
self.default_platforms.append(platform.name)
370+
# support board@revision
371+
# if there is already an existed <board>_<revision>.yaml, then use it to
372+
# load platform directly, otherwise, iterate the directory to
373+
# get all valid board revision based on each <board>_<revision>.conf.
374+
if not "@" in platform.name:
375+
tmp_dir = os.listdir(os.path.dirname(file))
376+
for item in tmp_dir:
377+
result = re.match(f"{platform.name}_(?P<revision>.*)\\.conf", item)
378+
if result:
379+
revision = result.group("revision")
380+
yaml_file = f"{platform.name}_{revision}.yaml"
381+
if yaml_file not in tmp_dir:
382+
platform_revision = copy.deepcopy(platform)
383+
revision = revision.replace("_", ".")
384+
platform_revision.name = f"{platform.name}@{revision}"
385+
platform_revision.default = False
386+
self.platforms.append(platform_revision)
369387

370388
except RuntimeError as e:
371389
logger.error("E: %s: can't load: %s" % (file, e))

0 commit comments

Comments
 (0)