From: Clifford Wolf Date: Wed, 28 Mar 2018 11:31:50 +0000 (+0200) Subject: Add JUnit XML output file and .stamp files X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fc7ace78841c97d56df609d3099118504490e878;p=SymbiYosys.git Add JUnit XML output file and .stamp files Signed-off-by: Clifford Wolf --- diff --git a/sbysrc/sby.py b/sbysrc/sby.py index 28f259a..b450000 100644 --- a/sbysrc/sby.py +++ b/sbysrc/sby.py @@ -235,6 +235,18 @@ def run_job(taskname): my_opt_tmpdir = True my_workdir = tempfile.mkdtemp() + junit_ts_name = os.path.basename(sbyfile[:-4]) if sbyfile is not None else workdir if workdir is not None else "stdin" + junit_tc_name = taskname if taskname is not None else "default" + + if sbyfile is not None: + junit_filename = os.path.basename(sbyfile[:-4]) + if taskname is not None: + junit_filename += "_" + taskname + elif taskname is not None: + junit_filename = taskname + else: + junit_filename = "junit" + sbyconfig, _ = read_sbyconfig(sbydata, taskname) job = SbyJob(sbyconfig, my_workdir, early_logmsgs) @@ -254,6 +266,28 @@ def run_job(taskname): shutil.rmtree(my_workdir, ignore_errors=True) job.log("DONE (%s, rc=%d)" % (job.status, job.retcode)) + job.logfile.close() + + if not my_opt_tmpdir: + with open("%s/%s.xml" % (job.workdir, junit_filename), "w") as f: + junit_errors = 1 if job.retcode == 16 else 0 + junit_failures = 1 if job.retcode != 0 and junit_errors == 0 else 0 + print('', file=f) + print('' % (junit_errors, junit_failures, job.total_time), file=f) + print('' % (junit_errors, junit_failures, junit_ts_name, job.total_time), file=f) + print('' % (junit_ts_name, junit_tc_name, job.status, job.total_time), file=f) + if junit_errors: + print('' % (job.status, job.status), file=f) + if junit_failures: + print('' % (job.status, job.status), file=f) + print('', end="", file=f) + with open("%s/logfile.txt" % (job.workdir), "r") as logf: + for line in logf: + print(line.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """), end="", file=f) + print('', file=f) + with open("%s/.stamp" % (job.workdir), "w") as f: + print("%s %d %d" % (job.status, job.retcode, job.total_time), file=f) + return job.retcode diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index e67b1c1..8a8fa2d 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -142,6 +142,7 @@ class SbyJob: self.models = dict() self.workdir = workdir self.status = "UNKNOWN" + self.total_time = 0 self.expect = [] self.exe_paths = { @@ -527,6 +528,7 @@ class SbyJob: ru = resource.getrusage(resource.RUSAGE_CHILDREN) total_process_time = int((ru.ru_utime + ru.ru_stime) - self.start_process_time) + self.total_time = total_process_time self.summary = [ "Elapsed clock time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" %