@@ -159,6 +159,7 @@ def __init__(self,
159
159
_opts_shuffle_test_order = False ,
160
160
_opts_shuffle_test_seed = None ,
161
161
_opts_test_by_names = None ,
162
+ _opts_peripheral_by_names = None ,
162
163
_opts_test_only_peripheral = False ,
163
164
_opts_test_only_common = False ,
164
165
_opts_verbose_skipped_tests = False ,
@@ -208,6 +209,7 @@ def __init__(self,
208
209
self .opts_shuffle_test_order = _opts_shuffle_test_order
209
210
self .opts_shuffle_test_seed = _opts_shuffle_test_seed
210
211
self .opts_test_by_names = _opts_test_by_names
212
+ self .opts_peripheral_by_names = _opts_peripheral_by_names
211
213
self .opts_test_only_peripheral = _opts_test_only_peripheral
212
214
self .opts_test_only_common = _opts_test_only_common
213
215
self .opts_verbose_skipped_tests = _opts_verbose_skipped_tests
@@ -255,6 +257,7 @@ def dump_options(self):
255
257
"shuffle_test_order" : str (self .opts_shuffle_test_order ),
256
258
"shuffle_test_seed" : str (self .opts_shuffle_test_seed ),
257
259
"test_by_names" : str (self .opts_test_by_names ),
260
+ "peripheral_by_names" : str (self .opts_peripheral_by_names ),
258
261
"test_only_peripheral" : str (self .opts_test_only_peripheral ),
259
262
"test_only_common" : str (self .opts_test_only_common ),
260
263
"verbose" : str (self .opts_verbose ),
@@ -360,8 +363,10 @@ def execute(self):
360
363
self .db_logger .update_build_id_info (self .db_logger_build_id , _extra = json .dumps (self .dump_options ()))
361
364
self .db_logger .disconnect ();
362
365
366
+
363
367
for test_id in test_map_keys :
364
368
test = TEST_MAP [test_id ]
369
+
365
370
if self .opts_test_by_names and test_id not in self .opts_test_by_names .split (',' ):
366
371
continue
367
372
@@ -374,6 +379,13 @@ def execute(self):
374
379
test_suite_properties ['skipped' ].append (test_id )
375
380
continue
376
381
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
+
377
389
if self .opts_test_only_common and test .peripherals :
378
390
if self .opts_verbose_skipped_tests :
379
391
print self .logger .log_line (self .logger .LogType .INFO , 'Peripheral test skipped for target %s' % (target ))
@@ -385,6 +397,10 @@ def execute(self):
385
397
# When users are using 'build only flag' and test do not have
386
398
# specified peripherals we can allow test building by default
387
399
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
388
404
elif not self .is_peripherals_available (target , test .peripherals ):
389
405
if self .opts_verbose_skipped_tests :
390
406
if test .peripherals :
@@ -912,7 +928,7 @@ def get_auto_property_value(property_name, line):
912
928
return (result , "" .join (output ), testcase_duration , duration )
913
929
914
930
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
916
932
"""
917
933
if peripherals is not None :
918
934
peripherals = set (peripherals )
@@ -930,7 +946,7 @@ def is_peripherals_available(self, target_mcu_name, peripherals=None):
930
946
return False
931
947
932
948
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
934
950
"""
935
951
test_spec = {
936
952
"mcu" : mcu ,
@@ -1507,7 +1523,11 @@ def get_default_test_options_parser():
1507
1523
1508
1524
parser .add_option ('-n' , '--test-by-names' ,
1509
1525
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.' )
1511
1531
1512
1532
copy_methods = host_tests_plugins .get_plugin_caps ('CopyMethod' )
1513
1533
copy_methods_str = "Plugin support: " + ', ' .join (copy_methods )
0 commit comments