refactor: improve hftest error message
Improve the error message in `hftest.py` if the JSON control string
cannot be found, or if the JSON cannot be parsed.
Change-Id: I03a5c6762f1fea34c168f5efc617ef0173ed2dd7
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/test/hftest/hftest.py b/test/hftest/hftest.py
index dac74e1..704c0fd 100755
--- a/test/hftest/hftest.py
+++ b/test/hftest/hftest.py
@@ -796,12 +796,22 @@
test suites."""
out = self.driver.run("json", "json", self.force_long_running)
hf_out = self.extract_hftest_lines(out)
- hf_out = hf_out[hf_out.index(HFTEST_CTRL_JSON_START) + 1
+ try:
+ hf_out = hf_out[hf_out.index(HFTEST_CTRL_JSON_START) + 1
:hf_out.index(HFTEST_CTRL_JSON_END)];
+ except ValueError as e:
+ print("Unable to find JSON control string:")
+ print(f"out={out}")
+ print(f"hf_out={hf_out}")
+ raise e
+
hf_out = "\n".join(hf_out)
try:
return json.loads(hf_out)
except ValueError as e:
+ print("Unable to parse JSON:")
+ print(f"out={out}")
+ print(f"hf_out={hf_outout}")
print(out)
raise e