#! /usr/bin/env python3

# SPDX-FileCopyrightText: 2024 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

# Script to validate a power.json against the json schema
#
# The default behavior takes a power.json file as a mandatory argument
# and it validates it agains the gen_schema file in the compiler-interfaces repo.
#
# If used from the default location, the relative path to the compiler-interfaces
# repo is automatically configured. Otherwise, please add the corresponding
# directory to PYTHONPATH
#
import os, sys
from jsonvalidator import JSONValidator

MYPATH = os.path.dirname(os.path.realpath(__file__))
GEN_SCHEMA_PATH=os.path.join(MYPATH, "../compiler_interfaces")
sys.path.append(GEN_SCHEMA_PATH)

from schemas.power_schema import PowerJSONSchema, get_schema_version

v = JSONValidator()
rc = v.validate('power.json', PowerJSONSchema, get_schema_version())
if not rc:
    sys.exit(1)
