summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2016-04-06 10:39:58 +0200
committerChristophe Lyon <christophe.lyon@linaro.org>2016-04-06 10:39:58 +0200
commit546962038e7df12af326151ddc82067437c6f1ac (patch)
tree343347415a1f103c1b30903afeb48838e8c0281a
parent9e7524088987b1fc67c79446506e862a77a84cc4 (diff)
compare_dg_tests.pl: Avoid division by zero in case no test was actually executed.no-div-by-0
Change-Id: I38f7de089d7a5db9ea161024d29f84d3e902eeb0
-rwxr-xr-xcompare_dg_tests.pl41
1 files changed, 29 insertions, 12 deletions
diff --git a/compare_dg_tests.pl b/compare_dg_tests.pl
index cc45605..0c49bd5 100755
--- a/compare_dg_tests.pl
+++ b/compare_dg_tests.pl
@@ -416,25 +416,42 @@ sub print_compare_results_summary($$)
my $rtotal = 0;
my $quiet_reg = $quiet;
my $ref_ratio = 0;
+ my $ref_total = 0;
my $res_ratio = 0;
+ my $res_total = 0;
my $ratio_thresh = 0.95; # Warn if pass ratio is below this threshold
my $ignore_exec = 0;
my $ref_has_exec_tests = 0;
my $res_has_exec_tests = 0;
# Compute the pass ratio as a sanity check
- $ref_ratio = ($ref->{PASS} + $ref->{XFAIL}) /
- ($ref->{PASS} + $ref->{XFAIL}
- + $ref->{XPASS} + $ref->{FAIL}
- + $ref->{UNRESOLVED}
- + $ref->{UNSUPPORTED}
- + $ref->{UNTESTED});
- $res_ratio = ($res->{PASS} + $res->{XFAIL}) /
- ($res->{PASS} + $res->{XFAIL}
- + $res->{XPASS} + $res->{FAIL}
- + $res->{UNRESOLVED}
- + $res->{UNSUPPORTED}
- + $res->{UNTESTED});
+ $ref_total = $ref->{PASS} +
+ $ref->{XFAIL} +
+ $ref->{XPASS} +
+ $ref->{FAIL} +
+ $ref->{UNRESOLVED} +
+ $ref->{UNSUPPORTED} +
+ $ref->{UNTESTED};
+
+ # It is possible that no test is executed at all (for instance if
+ # RUNTESTFLAGS was too restrictive). Avoid division by 0.
+ if ($ref_total > 0) {
+ $ref_ratio = ($ref->{PASS} + $ref->{XFAIL}) /
+ $ref_total;
+ }
+
+ $res_total = $res->{PASS} +
+ $res->{XFAIL} +
+ $res->{XPASS} +
+ $res->{FAIL} +
+ $res->{UNRESOLVED} +
+ $res->{UNSUPPORTED} +
+ $res->{UNTESTED};
+
+ if ($res_total > 0) {
+ $res_ratio = ($res->{PASS} + $res->{XFAIL}) /
+ $res_total;
+ }
if (not $quiet)
{