From 6ec2df34e36c69916a5da2f67c464eff85624590 Mon Sep 17 00:00:00 2001 From: "N. Engelhardt" Date: Tue, 7 Dec 2021 20:16:15 +0100 Subject: [PATCH] WIP change junit print to conform to schema; needs additional data, currently printing dummy info Signed-off-by: N. Engelhardt --- sbysrc/sby.py | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/sbysrc/sby.py b/sbysrc/sby.py index 58f02d8..c720b22 100644 --- a/sbysrc/sby.py +++ b/sbysrc/sby.py @@ -20,7 +20,7 @@ import argparse, os, sys, shutil, tempfile, re ##yosys-sys-path## from sby_core import SbyTask, SbyAbort, process_filename -from time import localtime +import time class DictAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): @@ -156,7 +156,7 @@ prep -top top early_logmsgs = list() def early_log(workdir, msg): - tm = localtime() + tm = time.localtime() early_logmsgs.append("SBY {:2d}:{:02d}:{:02d} [{}] {}".format(tm.tm_hour, tm.tm_min, tm.tm_sec, workdir, msg)) print(early_logmsgs[-1]) @@ -455,24 +455,47 @@ def run_task(taskname): if not my_opt_tmpdir and not setupmode: with open("{}/{}.xml".format(task.workdir, junit_filename), "w") as f: + # TODO: create necessary data + # checks: collection of assert/cover statements active in task + # elements: dicts with entries 'type', 'hierarchy', 'location', 'status', 'tracefile' + checks = [ #for testing purposes + {'type':'assert', 'hierarchy':'top.dut.submod1', 'location':'test.v:404', 'status':'unknown', 'tracefile':'/home/user/path/task/engine_0/trace0.vcd'}, + {'type':'assert', 'hierarchy':'top.dut.submod1', 'location':'test.v:412', 'status':'fail', 'tracefile':'/home/user/path/task/engine_0/trace1.vcd'}, + {'type':'cover', 'hierarchy':'top.dut.submod2', 'location':'test3.v:42', 'status':'pass', 'tracefile':'/home/user/path/task/engine_1/trace0.vcd'}, + {'type':'cover', 'hierarchy':'top.dut.submod2', 'location':'test3.v:666', 'status':'error', 'tracefile':'/home/user/path/task/engine_1/trace1.vcd'} + ] + junit_tests = len(checks) junit_errors = 1 if task.retcode == 16 else 0 junit_failures = 1 if task.retcode != 0 and junit_errors == 0 else 0 - print('', file=f) - print(f'', file=f) - print(f'', file=f) - print('', file=f) + junit_type = "cover" if task.opt_mode == "cover" else "assert" #should this be here or individual for each check? + junit_time = time.strftime('%Y-%m-%dT%H:%M:%S') + print(f'', file=f) + print(f'', file=f) + #TODO: check with Micko if os.uname().nodename is sane enough in most places + print(f'', file=f) + print(f'', file=f) print(f'', file=f) - print('', file=f) - print(f'', file=f) - if junit_errors: - print(f'', file=f) - if junit_failures: - print(f'', file=f) + print(f'', file=f) + for check in checks: + print(f'', file=f) # name required + if check["status"] == "unknown": + print(f'', file=f) + elif check["status"] == "fail": + print(f'', file=f) + elif check["status"] == "error": + print(f'', file=f) # type mandatory, message optional + print(f'', file=f) print('', end="", file=f) with open(f"{task.workdir}/logfile.txt", "r") as logf: for line in logf: print(line.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """), end="", file=f) - print('', file=f) + print('', file=f) + print('', file=f) + #TODO: can we handle errors and still output this file? + print('', file=f) + print(f'', file=f) + print(f'', file=f) + with open(f"{task.workdir}/status", "w") as f: print(f"{task.status} {task.retcode} {task.total_time}", file=f) @@ -488,7 +511,7 @@ for task in tasknames: failed.append(task) if failed and (len(tasknames) > 1 or tasknames[0] is not None): - tm = localtime() + tm = time.localtime() print("SBY {:2d}:{:02d}:{:02d} The following tasks failed: {}".format(tm.tm_hour, tm.tm_min, tm.tm_sec, failed)) sys.exit(retcode) -- 2.30.2