From 2a5d61d3ea0de47250f1a04bc8ae72fe275fc18e Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Thu, 19 Dec 2019 12:33:51 -0500 Subject: [PATCH] sanitycheck: define schema for hardware map Add schema for hardware map and verify it. Signed-off-by: Anas Nashif --- scripts/sanity_chk/hwmap-schema.yaml | 32 ++++++++++++++++++++++++++++ scripts/sanitycheck | 10 ++++----- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 scripts/sanity_chk/hwmap-schema.yaml diff --git a/scripts/sanity_chk/hwmap-schema.yaml b/scripts/sanity_chk/hwmap-schema.yaml new file mode 100644 index 00000000000..43616468b56 --- /dev/null +++ b/scripts/sanity_chk/hwmap-schema.yaml @@ -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 \ No newline at end of file diff --git a/scripts/sanitycheck b/scripts/sanitycheck index 0db945ce65e..c54494cf054 100755 --- a/scripts/sanitycheck +++ b/scripts/sanitycheck @@ -3767,6 +3767,9 @@ def native_and_unit_first(a, b): class HardwareMap: + + schema_path = os.path.join(ZEPHYR_BASE, "scripts", "sanity_chk", "hwmap-schema.yaml") + manufacturer = [ 'ARM', 'SEGGER', @@ -3813,11 +3816,8 @@ class HardwareMap: self.connected_hardware.append(device) def load_hardware_map(self, map_file): - with open(map_file, 'r') as stream: - try: - self.connected_hardware = yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) + hwm_schema = scl.yaml_load(self.schema_path) + self.connected_hardware = scl.yaml_load_verify(map_file, hwm_schema) for i in self.connected_hardware: i['counter'] = 0