Skip to content

Commit 698c235

Browse files
committed
Merge pull request #947 from PrzemekWirkus/singletest_force_peripherals
Singletest option -p to force peripherals
2 parents ed57ce8 + 50ef620 commit 698c235

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

workspace_tools/singletest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def get_version():
213213
_opts_shuffle_test_order=opts.shuffle_test_order,
214214
_opts_shuffle_test_seed=opts.shuffle_test_seed,
215215
_opts_test_by_names=opts.test_by_names,
216+
_opts_peripheral_by_names=opts.peripheral_by_names,
216217
_opts_test_only_peripheral=opts.test_only_peripheral,
217218
_opts_test_only_common=opts.test_only_common,
218219
_opts_verbose_skipped_tests=opts.verbose_skipped_tests,

workspace_tools/test_api.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def __init__(self,
159159
_opts_shuffle_test_order=False,
160160
_opts_shuffle_test_seed=None,
161161
_opts_test_by_names=None,
162+
_opts_peripheral_by_names=None,
162163
_opts_test_only_peripheral=False,
163164
_opts_test_only_common=False,
164165
_opts_verbose_skipped_tests=False,
@@ -208,6 +209,7 @@ def __init__(self,
208209
self.opts_shuffle_test_order = _opts_shuffle_test_order
209210
self.opts_shuffle_test_seed = _opts_shuffle_test_seed
210211
self.opts_test_by_names = _opts_test_by_names
212+
self.opts_peripheral_by_names = _opts_peripheral_by_names
211213
self.opts_test_only_peripheral = _opts_test_only_peripheral
212214
self.opts_test_only_common = _opts_test_only_common
213215
self.opts_verbose_skipped_tests = _opts_verbose_skipped_tests
@@ -255,6 +257,7 @@ def dump_options(self):
255257
"shuffle_test_order" : str(self.opts_shuffle_test_order),
256258
"shuffle_test_seed" : str(self.opts_shuffle_test_seed),
257259
"test_by_names" : str(self.opts_test_by_names),
260+
"peripheral_by_names" : str(self.opts_peripheral_by_names),
258261
"test_only_peripheral" : str(self.opts_test_only_peripheral),
259262
"test_only_common" : str(self.opts_test_only_common),
260263
"verbose" : str(self.opts_verbose),
@@ -360,8 +363,10 @@ def execute(self):
360363
self.db_logger.update_build_id_info(self.db_logger_build_id, _extra=json.dumps(self.dump_options()))
361364
self.db_logger.disconnect();
362365

366+
363367
for test_id in test_map_keys:
364368
test = TEST_MAP[test_id]
369+
365370
if self.opts_test_by_names and test_id not in self.opts_test_by_names.split(','):
366371
continue
367372

@@ -374,6 +379,13 @@ def execute(self):
374379
test_suite_properties['skipped'].append(test_id)
375380
continue
376381

382+
if self.opts_peripheral_by_names and test.peripherals and not len([i for i in test.peripherals if i in self.opts_peripheral_by_names.split(',')]):
383+
# We will skip tests not forced with -p option
384+
if self.opts_verbose_skipped_tests:
385+
print self.logger.log_line(self.logger.LogType.INFO, 'Common test skipped for target %s'% (target))
386+
test_suite_properties['skipped'].append(test_id)
387+
continue
388+
377389
if self.opts_test_only_common and test.peripherals:
378390
if self.opts_verbose_skipped_tests:
379391
print self.logger.log_line(self.logger.LogType.INFO, 'Peripheral test skipped for target %s'% (target))
@@ -385,6 +397,10 @@ def execute(self):
385397
# When users are using 'build only flag' and test do not have
386398
# specified peripherals we can allow test building by default
387399
pass
400+
elif self.opts_peripheral_by_names and test_id not in self.opts_peripheral_by_names.split(','):
401+
# If we force peripheral with option -p we expect test
402+
# to pass even if peripheral is not in MUTs file.
403+
pass
388404
elif not self.is_peripherals_available(target, test.peripherals):
389405
if self.opts_verbose_skipped_tests:
390406
if test.peripherals:
@@ -912,7 +928,7 @@ def get_auto_property_value(property_name, line):
912928
return (result, "".join(output), testcase_duration, duration)
913929

914930
def is_peripherals_available(self, target_mcu_name, peripherals=None):
915-
""" Checks if specified target should run specific peripheral test case
931+
""" Checks if specified target should run specific peripheral test case defined in MUTs file
916932
"""
917933
if peripherals is not None:
918934
peripherals = set(peripherals)
@@ -930,7 +946,7 @@ def is_peripherals_available(self, target_mcu_name, peripherals=None):
930946
return False
931947

932948
def shape_test_request(self, mcu, image_path, test_id, duration=10):
933-
""" Function prepares JOSN structure describing test specification
949+
""" Function prepares JSON structure describing test specification
934950
"""
935951
test_spec = {
936952
"mcu": mcu,
@@ -1507,7 +1523,11 @@ def get_default_test_options_parser():
15071523

15081524
parser.add_option('-n', '--test-by-names',
15091525
dest='test_by_names',
1510-
help='Runs only test enumerated it this switch')
1526+
help='Runs only test enumerated it this switch. Use comma to separate test case names.')
1527+
1528+
parser.add_option('-p', '--peripheral-by-names',
1529+
dest='peripheral_by_names',
1530+
help='Forces discovery of particular peripherals. Use comma to separate peripheral names.')
15111531

15121532
copy_methods = host_tests_plugins.get_plugin_caps('CopyMethod')
15131533
copy_methods_str = "Plugin support: " + ', '.join(copy_methods)

0 commit comments

Comments
 (0)