Skip to content

Commit fdc75bf

Browse files
committed
Merge pull request #971 from PrzemekWirkus/mcu_filter_for_auto
Added to option --auto handler for -f <mcu> filter switch.
2 parents cc6830b + 35bb258 commit fdc75bf

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

workspace_tools/singletest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_version():
8585
""" Returns test script version
8686
"""
8787
single_test_version_major = 1
88-
single_test_version_minor = 3
88+
single_test_version_minor = 4
8989
return (single_test_version_major, single_test_version_minor)
9090

9191

@@ -154,11 +154,13 @@ def get_version():
154154
use_default_toolchain = 'default' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else True
155155
use_supported_toolchains = 'all' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else False
156156
toolchain_filter = opts.toolchains_filter
157+
platform_name_filter = opts.general_filter_regex.split(',') if opts.general_filter_regex is not None else opts.general_filter_regex
157158
# Test specification with information about each target and associated toolchain
158159
test_spec = get_autodetected_TEST_SPEC(muts_list,
159160
use_default_toolchain=use_default_toolchain,
160161
use_supported_toolchains=use_supported_toolchains,
161-
toolchain_filter=toolchain_filter)
162+
toolchain_filter=toolchain_filter,
163+
platform_name_filter=platform_name_filter)
162164
# MUTs configuration auto-detection
163165
MUTs = get_autodetected_MUTS(muts_list)
164166
else:

workspace_tools/test_api.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,13 +1451,16 @@ def get_module_avail(module_name):
14511451
return module_name in sys.modules.keys()
14521452

14531453

1454-
def get_autodetected_MUTS(mbeds_list):
1454+
def get_autodetected_MUTS(mbeds_list, platform_name_filter=None):
14551455
""" Function detects all connected to host mbed-enabled devices and generates artificial MUTS file.
14561456
If function fails to auto-detect devices it will return empty dictionary.
14571457
14581458
if get_module_avail('mbed_lstools'):
14591459
mbeds = mbed_lstools.create()
14601460
mbeds_list = mbeds.list_mbeds()
1461+
1462+
@param mbeds_list list of mbeds captured from mbed_lstools
1463+
@param platform_name You can filter 'platform_name' with list of filtered targets from 'platform_name_filter'
14611464
"""
14621465
result = {} # Should be in muts_all.json format
14631466
# Align mbeds_list from mbed_lstools to MUT file format (JSON dictionary with muts)
@@ -1476,7 +1479,11 @@ def get_autodetected_MUTS(mbeds_list):
14761479
return result
14771480

14781481

1479-
def get_autodetected_TEST_SPEC(mbeds_list, use_default_toolchain=True, use_supported_toolchains=False, toolchain_filter=None):
1482+
def get_autodetected_TEST_SPEC(mbeds_list,
1483+
use_default_toolchain=True,
1484+
use_supported_toolchains=False,
1485+
toolchain_filter=None,
1486+
platform_name_filter=None):
14801487
""" Function detects all connected to host mbed-enabled devices and generates artificial test_spec file.
14811488
If function fails to auto-detect devices it will return empty 'targets' test_spec description.
14821489
@@ -1488,23 +1495,24 @@ def get_autodetected_TEST_SPEC(mbeds_list, use_default_toolchain=True, use_suppo
14881495

14891496
for mut in mbeds_list:
14901497
mcu = mut['platform_name']
1491-
if mcu in TARGET_MAP:
1492-
default_toolchain = TARGET_MAP[mcu].default_toolchain
1493-
supported_toolchains = TARGET_MAP[mcu].supported_toolchains
1494-
1495-
# Decide which toolchains should be added to test specification toolchain pool for each target
1496-
toolchains = []
1497-
if use_default_toolchain:
1498-
toolchains.append(default_toolchain)
1499-
if use_supported_toolchains:
1500-
toolchains += supported_toolchains
1501-
if toolchain_filter is not None:
1502-
all_toolchains = supported_toolchains + [default_toolchain]
1503-
for toolchain in toolchain_filter.split(','):
1504-
if toolchain in all_toolchains:
1505-
toolchains.append(toolchain)
1506-
1507-
result['targets'][mcu] = list(set(toolchains))
1498+
if platform_name_filter is None or (platform_name_filter and mut['platform_name'] in platform_name_filter):
1499+
if mcu in TARGET_MAP:
1500+
default_toolchain = TARGET_MAP[mcu].default_toolchain
1501+
supported_toolchains = TARGET_MAP[mcu].supported_toolchains
1502+
1503+
# Decide which toolchains should be added to test specification toolchain pool for each target
1504+
toolchains = []
1505+
if use_default_toolchain:
1506+
toolchains.append(default_toolchain)
1507+
if use_supported_toolchains:
1508+
toolchains += supported_toolchains
1509+
if toolchain_filter is not None:
1510+
all_toolchains = supported_toolchains + [default_toolchain]
1511+
for toolchain in toolchain_filter.split(','):
1512+
if toolchain in all_toolchains:
1513+
toolchains.append(toolchain)
1514+
1515+
result['targets'][mcu] = list(set(toolchains))
15081516
return result
15091517

15101518

0 commit comments

Comments
 (0)