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-14 12:39:23 +0000
commit0ab7d3596d28142e9ce33ad3930fc1e66e0e0a29 (patch)
tree2eac9a0b17d39d4ef6498098302d3ca46a2a29b7
parentdc66fc552c3a317144b4ec547bf0329f80014085 (diff)
compare_dg_tests.pl: Avoid division by zero in case no test was actually executed.
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 713303d..851c8d8 100755
--- a/compare_dg_tests.pl
+++ b/compare_dg_tests.pl
@@ -427,25 +427,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)
{