mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-31 22:24:28 +00:00
tools: add json schema for idf_size
This commit is contained in:
22
tools/test_idf_size/json_validate_test.py
Normal file
22
tools/test_idf_size/json_validate_test.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import json
|
||||
import os
|
||||
from sys import stdin
|
||||
|
||||
try:
|
||||
import jsonschema
|
||||
except ImportError:
|
||||
raise RuntimeError('You need to install jsonschema package to use validate command')
|
||||
|
||||
input_json = ''
|
||||
for line in stdin:
|
||||
input_json += line
|
||||
size_json = json.loads(input_json)
|
||||
with open(os.path.join(os.path.dirname(__file__), 'size_schema.json'), 'r') as schema_file:
|
||||
schema_json = json.load(schema_file)
|
||||
jsonschema.validate(size_json, schema_json)
|
||||
print(input_json.strip('\n'))
|
Reference in New Issue
Block a user