Skip to content

Commit cdbff2c

Browse files
committed
contest: hw: try to protect from bad info files
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 563999c commit cdbff2c

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

contest/hw/lib/deployer.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,18 @@ def parse_results(results_path, link):
469469
if not os.path.exists(info_path):
470470
continue
471471

472-
with open(info_path, encoding='utf-8') as fp:
473-
info = json.load(fp)
472+
try:
473+
with open(info_path, encoding='utf-8') as fp:
474+
info = json.load(fp)
475+
except (json.JSONDecodeError, ValueError):
476+
print(f"parse_results: bad JSON in {info_path}, marking as fail")
477+
cases.append({
478+
'test': entry,
479+
'group': 'selftests-hw',
480+
'result': 'fail',
481+
'link': link,
482+
})
483+
continue
474484

475485
retcode = info.get('retcode', 1)
476486
target = info.get('target', 'unknown')

contest/hw/lib/runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ def run_tests(test_dir, results_dir):
299299
info['crashes'] = list(crash_fps)
300300
with open(os.path.join(test_results_dir, 'info'), 'w', encoding='utf-8') as fp:
301301
json.dump(info, fp)
302+
fp.flush()
303+
os.fsync(fp.fileno())
302304

303305
print(f"[{test_idx+1}/{len(tests)}] {test_name}: rc={retcode} ({elapsed}s)")
304306

0 commit comments

Comments
 (0)