Skip to content

Commit

Permalink
automated: linux: lmp-device-register check toml file
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mwasilew committed Feb 13, 2024
1 parent 701befd commit ae47983
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions automated/linux/lmp-device-register/check_toml.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 4 additions & 1 deletion automated/linux/lmp-device-register/lmp-device-register.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ae47983

Please sign in to comment.