]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
ha-tester: report summary count of run/passed tests and list failed ones
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Jul 2021 12:53:16 +0000 (14:53 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Jul 2021 14:00:51 +0000 (16:00 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/test/ha-tester.pl

index 73f15e4f41ee46fc62f7e22e6d17e63418c26adc..1e51d144ba8f3dea24d9cc12b0cc5b831fca9d98 100755 (executable)
@@ -17,11 +17,14 @@ if (!GetOptions(
     exit -1;
 }
 
+my ($run, $failed) = (0, []);
+
 sub do_run_test {
     my $dir = shift;
 
     $dir =~ s!/+$!!;
 
+    $run++;
     print "run: $dir\n";
 
     my $logfile = "$dir/status/log";
@@ -50,6 +53,8 @@ my sub handle_test_result {
 
     return if !defined($res); # undef -> passed
 
+    push $failed->@*, $test;
+
     die "$res\n" if !$opt_nofail;
     warn "$res\n";
 }
@@ -70,5 +75,17 @@ if (my $testdir = shift) {
     }
 }
 
+my $failed_count = scalar($failed->@*);
+my $passed = $run - $failed_count;
+
+my $summary_msg = "passed $passed out of $run tests";
+
+if ($failed_count) {
+    $summary_msg .= ", failed test(s):\n  " . join("\n  ", $failed->@*);
+} else {
+    $summary_msg .= " -> OK";
+}
 
+print "$summary_msg\n";
 
+exit($failed_count > 0 ? -1 : 0);