Skip to content

Commit

Permalink
[nrf fromtree] scripts: list_hardware: Add check for soc.yml runner v…
Browse files Browse the repository at this point in the history
…alidity

Adds checking that qualifiers listed in a soc.yml file are valid
for the socs and cpuclusters defined in that file

Signed-off-by: Jamie McCrae <[email protected]>
(cherry picked from commit 5033399)
  • Loading branch information
nordicjm committed May 1, 2024
1 parent 309776f commit e5488c1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/list_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
from typing import List
import yaml
import re


SOC_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'soc-schema.yml')
Expand Down Expand Up @@ -40,6 +41,40 @@ def __init__(self, folder='', soc_yaml=None):
except (yaml.YAMLError, pykwalify.errors.SchemaError) as e:
sys.exit(f'ERROR: Malformed yaml {soc_yaml.as_posix()}', e)

# Ensure that any runner configuration matches socs and cpuclusters declared in the same
# soc.yml file
if 'runners' in data and 'run_once' in data['runners']:
for grp in data['runners']['run_once']:
for item_data in data['runners']['run_once'][grp]:
for group in item_data['groups']:
for qualifiers in group['qualifiers']:
components = qualifiers.split('/')
soc = components.pop(0)
found_match = False

# Allow 'ns' as final qualifier until "virtual" CPUs are ported to soc.yml
# https://github.com/zephyrproject-rtos/zephyr/issues/70721
if len(components) > 0 and components[len(components)-1] == 'ns':
components.pop(len(components)-1)

for f in data.get('family', []):
for s in f.get('series', []):
for socs in s.get('socs', []):
if re.match(fr'^{soc}$', socs.get('name')) is not None:
if 'cpuclusters' in socs and len(components) > 0:
check_string = '/'.join(components)
for cpucluster in socs.get('cpuclusters', []):
if re.match(fr'^{check_string}$', cpucluster.get('name')) is not None:
found_match = True
break
elif 'cpuclusters' not in socs and len(components) == 0:
found_match = True
break


if found_match is False:
sys.exit(f'ERROR: SoC qualifier match unresolved: {qualifiers}')

for f in data.get('family', []):
family = Family(f['name'], folder, [], [])
for s in f.get('series', []):
Expand Down

0 comments on commit e5488c1

Please sign in to comment.