diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-13 10:09:14 +0100 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-10-27 04:21:19 -1000 |
commit | 5c342965c44dace8a376235fd5bd4ad5d4374cd2 (patch) | |
tree | e81d2c6239db8a38cf9d39dec2529e82f419479f /scripts | |
parent | 6f375f52f5a02fbe971c22c9ae38224b7f7644aa (diff) | |
download | poky-5c342965c44dace8a376235fd5bd4ad5d4374cd2.tar.gz |
resulttool/report: Avoid divide by zero
Avoid a divide by zero traceback if unfortunate test counts are encountered.
(From OE-Core rev: 33d3374a7149ad1afe86d86c0dc2a948f70e26bd)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit c5aeea53dfacb53dedb8445cb3523dc3a8cb6dca)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/resulttool/report.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/lib/resulttool/report.py b/scripts/lib/resulttool/report.py index f0ca50ebe2..a349510ab8 100644 --- a/scripts/lib/resulttool/report.py +++ b/scripts/lib/resulttool/report.py | |||
@@ -176,7 +176,10 @@ class ResultsTextReport(object): | |||
176 | vals['sort'] = line['testseries'] + "_" + line['result_id'] | 176 | vals['sort'] = line['testseries'] + "_" + line['result_id'] |
177 | vals['failed_testcases'] = line['failed_testcases'] | 177 | vals['failed_testcases'] = line['failed_testcases'] |
178 | for k in cols: | 178 | for k in cols: |
179 | vals[k] = "%d (%s%%)" % (line[k], format(line[k] / total_tested * 100, '.0f')) | 179 | if total_tested: |
180 | vals[k] = "%d (%s%%)" % (line[k], format(line[k] / total_tested * 100, '.0f')) | ||
181 | else: | ||
182 | vals[k] = "0 (0%)" | ||
180 | for k in maxlen: | 183 | for k in maxlen: |
181 | if k in vals and len(vals[k]) > maxlen[k]: | 184 | if k in vals and len(vals[k]) > maxlen[k]: |
182 | maxlen[k] = len(vals[k]) | 185 | maxlen[k] = len(vals[k]) |