sanitycheck: define schema for hardware map

Add schema for hardware map and verify it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2019-12-19 12:33:51 -05:00
commit 2a5d61d3ea
2 changed files with 37 additions and 5 deletions

View file

@ -0,0 +1,32 @@
type: seq
sequence:
- type: map
required: no
mapping:
"available":
type: bool
required: true
"connected":
type: bool
required: true
"id":
type: str
required: true
"platform":
type: str
required: true
"product":
type: str
required: true
"runner":
type: str
required: true
"serial":
type: str
required: false
"post_script":
type: str
required: false
"pre_script":
type: str
required: false

View file

@ -3767,6 +3767,9 @@ def native_and_unit_first(a, b):
class HardwareMap: class HardwareMap:
schema_path = os.path.join(ZEPHYR_BASE, "scripts", "sanity_chk", "hwmap-schema.yaml")
manufacturer = [ manufacturer = [
'ARM', 'ARM',
'SEGGER', 'SEGGER',
@ -3813,11 +3816,8 @@ class HardwareMap:
self.connected_hardware.append(device) self.connected_hardware.append(device)
def load_hardware_map(self, map_file): def load_hardware_map(self, map_file):
with open(map_file, 'r') as stream: hwm_schema = scl.yaml_load(self.schema_path)
try: self.connected_hardware = scl.yaml_load_verify(map_file, hwm_schema)
self.connected_hardware = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
for i in self.connected_hardware: for i in self.connected_hardware:
i['counter'] = 0 i['counter'] = 0