diff --git a/unit-tests/live/metadata/test-usb-type-found.py b/unit-tests/live/metadata/test-usb-type-found.py index b050f8fa087..7b9b28e81bb 100644 --- a/unit-tests/live/metadata/test-usb-type-found.py +++ b/unit-tests/live/metadata/test-usb-type-found.py @@ -2,8 +2,9 @@ # Copyright(c) 2023 RealSense, Inc. All Rights Reserved. -#test:device each(D400*) !D457 -#test:device each(D500*) !D555 +#test:device each(D400*) +#test:device each(D500*) +#test:type USB import pyrealsense2 as rs diff --git a/unit-tests/py/rspy/devices.py b/unit-tests/py/rspy/devices.py index 623acef91cd..85e5e2f255b 100644 --- a/unit-tests/py/rspy/devices.py +++ b/unit-tests/py/rspy/devices.py @@ -116,6 +116,10 @@ def name( self ): def product_line( self ): return self._product_line + @property + def connection_type( self ): + return self._connection_type + @property def physical_port( self ): return self._physical_port diff --git a/unit-tests/py/rspy/libci.py b/unit-tests/py/rspy/libci.py index 3b426631b27..f9c83e3c08f 100644 --- a/unit-tests/py/rspy/libci.py +++ b/unit-tests/py/rspy/libci.py @@ -87,6 +87,7 @@ def __init__( self, context ): self._configurations = list() self._priority = 1000 self._tags = set() + self._types = set() # usage: test:type or test:type ! self._flags = set() self._timeout = 200 self._retries = 0 @@ -130,6 +131,10 @@ def retries( self ): def tags( self ): return self._tags + @property + def types( self ): + return self._types + @property def flags( self ): return self._flags @@ -239,6 +244,8 @@ def derive_config_from_text( self, source, line_prefix ): params ) elif directive == 'tag': self._tags.update( map( str.lower, params )) # tags are case-insensitive + elif directive == 'type': + self._types.update( map( str.lower, params )) elif directive == 'flag': self._flags.update( params ) elif directive == 'donotrun': diff --git a/unit-tests/run-unit-tests.py b/unit-tests/run-unit-tests.py index b7e242b18c2..1ce78e0f058 100644 --- a/unit-tests/run-unit-tests.py +++ b/unit-tests/run-unit-tests.py @@ -664,6 +664,26 @@ def close_hubs(): # test_ok = True for configuration, serial_numbers in devices_by_test_config( test, exceptions ): + # Currently, with all of our tests, serial_numbers holds a single serial number + # We will see multiple devices on serial_numbers only if the test specifies multiple devices in a + # single line. For example: "test:device D435 D455" will require both devices simultaneity + + skip_test = False + for sn in serial_numbers: + conn_type = devices.get(sn).connection_type.lower() + excluded_connections = [ t[1:].lower() for t in test.config.types if t.startswith('!') ] + required_connections = [ t.lower() for t in test.config.types if not t.startswith('!') ] + if conn_type in excluded_connections: + skip_test = True + break + if required_connections and conn_type not in required_connections: + skip_test = True + break + + if skip_test: + log.d( f'connection type does not fit {test.config.types}; skipping' ) + continue + for repetition in range(repeat): try: log.d( 'configuration:', configuration_str( configuration, repetition, sns=serial_numbers ) )