Skip to content

Commit e66a77c

Browse files
committed
add test type to skip by connection type
1 parent defc7dd commit e66a77c

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

unit-tests/live/metadata/test-usb-type-found.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# Copyright(c) 2023 RealSense, Inc. All Rights Reserved.
33

44

5-
#test:device each(D400*) !D457
6-
#test:device each(D500*) !D555
5+
#test:device each(D400*)
6+
#test:device each(D500*)
7+
#test:type USB
78

89

910
import pyrealsense2 as rs

unit-tests/py/rspy/devices.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ def name( self ):
116116
def product_line( self ):
117117
return self._product_line
118118

119+
@property
120+
def connection_type( self ):
121+
return self._connection_type
122+
119123
@property
120124
def physical_port( self ):
121125
return self._physical_port

unit-tests/py/rspy/libci.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def __init__( self, context ):
8787
self._configurations = list()
8888
self._priority = 1000
8989
self._tags = set()
90+
self._types = set() # usage: test:type <type> or test:type !<type>
9091
self._flags = set()
9192
self._timeout = 200
9293
self._retries = 0
@@ -130,6 +131,10 @@ def retries( self ):
130131
def tags( self ):
131132
return self._tags
132133

134+
@property
135+
def types( self ):
136+
return self._types
137+
133138
@property
134139
def flags( self ):
135140
return self._flags
@@ -239,6 +244,8 @@ def derive_config_from_text( self, source, line_prefix ):
239244
params )
240245
elif directive == 'tag':
241246
self._tags.update( map( str.lower, params )) # tags are case-insensitive
247+
elif directive == 'type':
248+
self._types.update( map( str.lower, params ))
242249
elif directive == 'flag':
243250
self._flags.update( params )
244251
elif directive == 'donotrun':

unit-tests/run-unit-tests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,26 @@ def close_hubs():
664664
#
665665
test_ok = True
666666
for configuration, serial_numbers in devices_by_test_config( test, exceptions ):
667+
# Currently, with all of our tests, serial_numbers holds a single serial number
668+
# We will see multiple devices on serial_numbers only if the test specifies multiple devices in a
669+
# single line. For example: "test:device D435 D455" will require both devices simultaneity
670+
671+
skip_test = False
672+
for sn in serial_numbers:
673+
conn_type = devices.get(sn).connection_type.lower()
674+
excluded_connections = [ t[1:].lower() for t in test.config.types if t.startswith('!') ]
675+
required_connections = [ t.lower() for t in test.config.types if not t.startswith('!') ]
676+
if conn_type in excluded_connections:
677+
skip_test = True
678+
break
679+
if required_connections and conn_type not in required_connections:
680+
skip_test = True
681+
break
682+
683+
if skip_test:
684+
log.d( f'connection type does not fit {test.config.types}; skipping' )
685+
continue
686+
667687
for repetition in range(repeat):
668688
try:
669689
log.d( 'configuration:', configuration_str( configuration, repetition, sns=serial_numbers ) )

0 commit comments

Comments
 (0)