Skip to content

Commit 5033399

Browse files
nordicjmfabiobaltieri
authored andcommitted
scripts: list_hardware: Add check for soc.yml runner validity
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]>
1 parent df72732 commit 5033399

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

scripts/list_hardware.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
from typing import List
1212
import yaml
13+
import re
1314

1415

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

44+
# Ensure that any runner configuration matches socs and cpuclusters declared in the same
45+
# soc.yml file
46+
if 'runners' in data and 'run_once' in data['runners']:
47+
for grp in data['runners']['run_once']:
48+
for item_data in data['runners']['run_once'][grp]:
49+
for group in item_data['groups']:
50+
for qualifiers in group['qualifiers']:
51+
components = qualifiers.split('/')
52+
soc = components.pop(0)
53+
found_match = False
54+
55+
# Allow 'ns' as final qualifier until "virtual" CPUs are ported to soc.yml
56+
# https://github.com/zephyrproject-rtos/zephyr/issues/70721
57+
if len(components) > 0 and components[len(components)-1] == 'ns':
58+
components.pop(len(components)-1)
59+
60+
for f in data.get('family', []):
61+
for s in f.get('series', []):
62+
for socs in s.get('socs', []):
63+
if re.match(fr'^{soc}$', socs.get('name')) is not None:
64+
if 'cpuclusters' in socs and len(components) > 0:
65+
check_string = '/'.join(components)
66+
for cpucluster in socs.get('cpuclusters', []):
67+
if re.match(fr'^{check_string}$', cpucluster.get('name')) is not None:
68+
found_match = True
69+
break
70+
elif 'cpuclusters' not in socs and len(components) == 0:
71+
found_match = True
72+
break
73+
74+
75+
if found_match is False:
76+
sys.exit(f'ERROR: SoC qualifier match unresolved: {qualifiers}')
77+
4378
for f in data.get('family', []):
4479
family = Family(f['name'], folder, [], [])
4580
for s in f.get('series', []):

0 commit comments

Comments
 (0)