Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align dev unit-tests/ scripts with D4XX_MIPI because of errors #10917

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 44 additions & 14 deletions unit-tests/py/rspy/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions unit-tests/py/rspy/libci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
6 changes: 5 additions & 1 deletion unit-tests/py/rspy/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ):
Expand Down