]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
ha-tester: allow one to supress the actual test output
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Jul 2021 13:39:15 +0000 (15:39 +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 1e51d144ba8f3dea24d9cc12b0cc5b831fca9d98..8b73a58219467c093d0c605309fd25ca7299bd86 100755 (executable)
@@ -8,17 +8,22 @@ use File::Path qw(make_path remove_tree);
 
 my $opt_nodiff;
 my $opt_nofail;
+my $opt_notestout;
 
 if (!GetOptions(
     "no-diff" => \$opt_nodiff,
+    "no-test-output" => \$opt_notestout,
     "c|continue-on-fail" => \$opt_nofail,
 )) {
-    print "usage: $0 testdir [--no-diff] [-c | --continue-on-fail]\n";
+    print "usage: $0 testdir [--no-diff] [-c | --continue-on-fail] [--no-test-output]\n";
     exit -1;
 }
 
 my ($run, $failed) = (0, []);
 
+
+my $STDOLD;
+
 sub do_run_test {
     my $dir = shift;
 
@@ -27,14 +32,22 @@ sub do_run_test {
     $run++;
     print "run: $dir\n";
 
-    my $logfile = "$dir/status/log";
-    my $logexpect = "$dir/log.expect";
+    if ($opt_notestout) {
+       open($STDOLD, '>&', STDOUT); # if request redirect stdout into nirvana but save old one
+       open(STDOUT, '>>', '/dev/null');
+    }
+
+    my $res = system('perl', '-I../', '../pve-ha-tester', "$dir"); # actually running the test
+
+    open (STDOUT, '>&', $STDOLD) if $opt_notestout; # restore back again
 
-    my $res = system("perl -I ../ ../pve-ha-tester $dir");
     return "Test '$dir' failed\n" if $res != 0;
 
     return if $opt_nodiff;
 
+    my $logfile = "$dir/status/log";
+    my $logexpect = "$dir/log.expect";
+
     if (-f $logexpect) {
        my $cmd = ['diff', '-u', $logexpect, $logfile]; 
        $res = system(@$cmd);