diff --git a/unit-tests/py/rspy/devices.py b/unit-tests/py/rspy/devices.py index 3a0231337d..c92cfbceed 100644 --- a/unit-tests/py/rspy/devices.py +++ b/unit-tests/py/rspy/devices.py @@ -290,33 +290,51 @@ def enabled(): return { device.serial_number for device in _device_by_sn.values() if device.enabled } -def by_product_line( product_line ): +def by_product_line( product_line, ignored_products ): """ :param product_line: The product line we're interested in, as a string ("L500", etc.) + :param ignored_products: List of products we want to ignore. e.g. ['D455', 'D457', etc.] :return: A set of device serial-numbers """ global _device_by_sn - return { device.serial_number for device in _device_by_sn.values() if device.product_line == product_line } + result = set() + for device in _device_by_sn.values(): + if device.product_line == product_line: + for ignored_product in ignored_products: + if ignored_product in device.name: + break + else: + result.add(device.serial_number) + return result -def by_name( name ): +def by_name( name, ignored_products ): """ :param name: Part of the product name to search for ("L515" would match "Intel RealSense L515") + :param ignored_products: List of products we want to ignore. e.g. ['D455', 'D457', etc.] :return: A set of device serial-numbers """ global _device_by_sn - return { device.serial_number for device in _device_by_sn.values() if device.name and device.name.find( name ) >= 0 } - + result = set() + ignored_list_as_str = " ".join(ignored_products) + if name not in ignored_list_as_str: + for device in _device_by_sn.values(): + if device.name and device.name.find( name ) >= 0: + result.add(device.serial_number) + return result -def _get_sns_from_spec( spec ): +def _get_sns_from_spec( spec, ignored_products ): """ Helper function for by_configuration. Yields all serial-numbers matching the given spec + :param spec: A product name/line (as a string) we want to get serial number of + :param ignored_products: List of products we want to ignore. e.g. ['D455', 'D457', etc.] + :return: A set of device serial-numbers """ if spec.endswith( '*' ): - for sn in by_product_line( spec[:-1] ): + for sn in by_product_line( spec[:-1], ignored_products ): yield sn else: - for sn in by_name( spec ): + for sn in by_name( spec, ignored_products ): yield sn @@ -371,16 +389,28 @@ def by_configuration( config, exceptions = None ): raised! """ exceptions = exceptions or set() - if len( config ) == 1 and re.fullmatch( r'each\(.+\)', config[0], re.IGNORECASE ): - spec = config[0][5:-1] - for sn in _get_sns_from_spec( spec ): + # split the current config to two lists: + # 1) new_config (the wanted products) + # 2) ignored_products (strings starting with !) + # For example: "each(D400*) !D457" ---> new_config = ['each(D400*)'], ignored_products = ['D457'] + new_config = [] + ignored_products = [] + for p in config: + if p[0] == '!': + ignored_products.append(p[1:]) # remove the '!' + else: + new_config.append(p) + + if len( new_config ) > 0 and re.fullmatch( r'each\(.+\)', new_config[0], re.IGNORECASE ): + spec = new_config[0][5:-1] + for sn in _get_sns_from_spec( spec, ignored_products ): if sn not in exceptions: yield { sn } else: sns = set() - for spec in config: + for spec in new_config: old_len = len(sns) - for sn in _get_sns_from_spec( spec ): + for sn in _get_sns_from_spec( spec, ignored_products ): if sn in exceptions: continue if sn not in sns: @@ -656,7 +686,7 @@ def _get_port_by_loc( usb_location ): """ if usb_location: # - # Devices connected thru an acroname will be in one of two sub-hubs under the acroname main + # Devices connected thru an acroname will be in one of two sub-hubs under the acroname main # hub. Each is a 4-port hub with a different port (4 for ports 0-3, 3 for ports 4-7): # /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M # |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M <--- ACRONAME diff --git a/unit-tests/py/rspy/libci.py b/unit-tests/py/rspy/libci.py index c74338ae09..46dc2b67f2 100644 --- a/unit-tests/py/rspy/libci.py +++ b/unit-tests/py/rspy/libci.py @@ -190,13 +190,24 @@ def derive_config_from_text( self, source, line_prefix ): continue if directive == 'device': # log.d( ' configuration:', params ) + params_lower_list = text_params.lower().split() if not params: log.e( source + '+' + str( line['index'] ) + ': device directive with no devices listed' ) - elif 'each' in text_params.lower() and len( params ) > 1: + elif sum(s.startswith('each(') for s in params_lower_list) > 1: log.e( source + '+' + str( - line['index'] ) + ': each() cannot be used in combination with other specs', params ) - elif 'each' in text_params.lower() and not re.fullmatch( r'each\(.+\)', text_params, re.IGNORECASE ): - log.e( source + '+' + str( line['index'] ) + ': invalid \'each\' syntax:', params ) + line['index'] ) + ': each() cannot be used multiple times in same line', params ) + elif params_lower_list[0].startswith('each('): + if not re.fullmatch( r'each\(.+\)', params_lower_list[0], re.IGNORECASE ): + log.e( source + '+' + str( line['index'] ) + ': invalid \'each\' syntax:', params ) + else: + for param in params_lower_list[1:]: + if not param.startswith("!"): + log.e(source + '+' + str(line['index']) + ': invalid syntax:', params, + '. All device names after \'' + params[0] + + '\' must start with \'!\' in order to skip them') + break + else: + self._configurations.append( params ) else: self._configurations.append( params ) elif directive == 'priority': diff --git a/unit-tests/py/rspy/repo.py b/unit-tests/py/rspy/repo.py index ab2888feb3..20f53f63d5 100644 --- a/unit-tests/py/rspy/repo.py +++ b/unit-tests/py/rspy/repo.py @@ -11,7 +11,11 @@ # ... but first check the expected LibCI build directories: # if platform.system() == 'Linux': - build = os.path.join( root, 'x86_64', 'static' ) + if platform.processor() == 'aarch64': + # for jetson (arm) + build = os.path.join(root, 'arm64', 'static') + else: + build = os.path.join( root, 'x86_64', 'static' ) else: build = os.path.join( root, 'win10', 'win64', 'static' ) if not os.path.isdir( build ):