Skip to content

Commit 38fdc56

Browse files
mwasilewroxell
authored andcommitted
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 <milosz.wasilewski@foundries.io>
1 parent e99c80b commit 38fdc56

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import sys
5+
6+
7+
def main(toml_file):
8+
info = sys.version_info
9+
if info.major >= 3 and info.minor >= 11:
10+
import tomllib as tlib
11+
else:
12+
import toml as tlib
13+
14+
with open(toml_file, "rb") as f:
15+
tlib.load(f)
16+
17+
18+
if __name__ == "__main__":
19+
parser = argparse.ArgumentParser()
20+
parser.add_argument("--toml-file", required=True)
21+
args = parser.parse_args()
22+
main(args.toml_file)

automated/linux/lmp-device-register/lmp-device-register.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
3333
warn_msg "Dependencies installation skipped."
3434
else
3535
# same package name for debian and fedora
36-
pkgs="uuid-runtime"
36+
pkgs="uuid-runtime python3-toml"
3737
install_deps "${pkgs}"
3838
fi
3939

@@ -91,8 +91,11 @@ fi
9191

9292
if [ -f /var/sota/sota.toml ]; then
9393
report_pass "sotatoml-present"
94+
./check_toml.py --toml-file /var/sota/sota.toml
95+
check_return "sotatoml-parse"
9496
else
9597
report_fail "sotatom-present"
98+
report_skip "sotatoml-parse"
9699
fi
97100

98101
# try to register again

0 commit comments

Comments
 (0)