twister: Use alternative test sorting when --device-testing

Change the sorting of test instances if --device-testing is used
within subsets. Test instances are sored depending on the context.
For CI runs the execution order is: "platform1-testA, platform1-testB,
..., platform1-testZ, platform2-testA, ...". For hardware tests, were
multiple platforms can run the tests in parallel, it is more efficient
to run in the order: "platform1-testA, platform2-testA, ...,
platform1-testB, platform2-testB, ..."
This can significantly reduce the tests execution time
for setups with multiple different platforms connected.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
This commit is contained in:
Maciej Perkowski 2021-01-27 10:43:00 +01:00 committed by Anas Nashif
commit 941af213d3

View file

@ -1114,7 +1114,17 @@ def main():
return
if options.subset:
suite.instances = OrderedDict(sorted(suite.instances.items()))
# Test instances are sorted depending on the context. For CI runs
# the execution order is: "plat1-testA, plat1-testB, ...,
# plat1-testZ, plat2-testA, ...". For hardware tests
# (device_testing), were multiple physical platforms can run the tests
# in parallel, it is more efficient to run in the order:
# "plat1-testA, plat2-testA, ..., plat1-testB, plat2-testB, ..."
if options.device_testing:
suite.instances = OrderedDict(sorted(suite.instances.items(),
key=lambda x: x[0][x[0].find("/") + 1:]))
else:
suite.instances = OrderedDict(sorted(suite.instances.items()))
subset, sets = options.subset.split("/")
subset = int(subset)