Message ID | 20230813115410.163212-1-richard.purdie@linuxfoundation.org |
---|---|
State | New |
Headers | show |
Series | [1/8] resulttool/report: Avoid divide by zero | expand |
diff --git a/scripts/lib/resulttool/report.py b/scripts/lib/resulttool/report.py index f0ca50ebe24..a349510ab85 100644 --- a/scripts/lib/resulttool/report.py +++ b/scripts/lib/resulttool/report.py @@ -176,7 +176,10 @@ class ResultsTextReport(object): vals['sort'] = line['testseries'] + "_" + line['result_id'] vals['failed_testcases'] = line['failed_testcases'] for k in cols: - vals[k] = "%d (%s%%)" % (line[k], format(line[k] / total_tested * 100, '.0f')) + if total_tested: + vals[k] = "%d (%s%%)" % (line[k], format(line[k] / total_tested * 100, '.0f')) + else: + vals[k] = "0 (0%)" for k in maxlen: if k in vals and len(vals[k]) > maxlen[k]: maxlen[k] = len(vals[k])
Avoid a divide by zero traceback if unfortunate test counts are encountered. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- scripts/lib/resulttool/report.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)