From ae479834d6e6524811bcdf63d0cda06b96025523 Mon Sep 17 00:00:00 2001 From: Milosz Wasilewski Date: Tue, 13 Feb 2024 11:50:38 +0000 Subject: [PATCH] automated: linux: lmp-device-register check toml file When lmp-device-register runs it creates sota.toml file from the values returned by server. This patch adds a check to confirm whether the file is a valid TOML. Signed-off-by: Milosz Wasilewski --- .../linux/lmp-device-register/check_toml.py | 22 +++++++++++++++++++ .../lmp-device-register.sh | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 automated/linux/lmp-device-register/check_toml.py diff --git a/automated/linux/lmp-device-register/check_toml.py b/automated/linux/lmp-device-register/check_toml.py new file mode 100755 index 000000000..2296e6404 --- /dev/null +++ b/automated/linux/lmp-device-register/check_toml.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import argparse +import sys + + +def main(toml_file): + info = sys.version_info + if info.major >= 3 and info.minor >= 11: + import tomllib as tlib + else: + import toml as tlib + + with open(toml_file, "rb") as f: + tlib.load(f) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--toml-file", required=True) + args = parser.parse_args() + main(args.toml_file) diff --git a/automated/linux/lmp-device-register/lmp-device-register.sh b/automated/linux/lmp-device-register/lmp-device-register.sh index ef181fad2..70aee884a 100755 --- a/automated/linux/lmp-device-register/lmp-device-register.sh +++ b/automated/linux/lmp-device-register/lmp-device-register.sh @@ -33,7 +33,7 @@ if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then warn_msg "Dependencies installation skipped." else # same package name for debian and fedora - pkgs="uuid-runtime" + pkgs="uuid-runtime python3-toml" install_deps "${pkgs}" fi @@ -91,8 +91,11 @@ fi if [ -f /var/sota/sota.toml ]; then report_pass "sotatoml-present" + ./check_toml.py --toml-file /var/sota/sota.toml + check_return "sotatoml-parse" else report_fail "sotatom-present" + report_skip "sotatoml-parse" fi # try to register again