From ed0b6b18f6d930d7123d14a1bdd0f3cc73dcb83b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 10 Oct 2017 22:52:17 +0200 Subject: [PATCH] runtests: use valgrind for torture as well NOTE: it makes them terribly slow. I recommend only using valgrind for specific torture tests or using lots of patience. --- tests/runtests.pl | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/tests/runtests.pl b/tests/runtests.pl index 39362e0b8..f493c7808 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -561,8 +561,7 @@ sub runclientoutput { # Memory allocation test and failure torture testing. # sub torture { - my $testcmd = shift; - my $gdbline = shift; + my ($testcmd, $testnum, $gdbline) = @_; # remove memdump first to be sure we get a new nice and clean one unlink($memdump); @@ -610,6 +609,20 @@ sub torture { # remove memdump first to be sure we get a new nice and clean one unlink($memdump); + my $cmd = $testcmd; + if($valgrind && !$gdbthis) { + my @valgrindoption = getpart("verify", "valgrind"); + if((!@valgrindoption) || ($valgrindoption[0] !~ /disable/)) { + my $valgrindcmd = "$valgrind "; + $valgrindcmd .= "$valgrind_tool " if($valgrind_tool); + $valgrindcmd .= "--quiet --leak-check=yes "; + $valgrindcmd .= "--suppressions=$srcdir/valgrind.supp "; + # $valgrindcmd .= "--gen-suppressions=all "; + $valgrindcmd .= "--num-callers=16 "; + $valgrindcmd .= "${valgrind_logfile}=$LOGDIR/valgrind$testnum"; + $cmd = "$valgrindcmd $testcmd"; + } + } logmsg "*** Function number $limit is now set to fail ***\n" if($gdbthis); my $ret = 0; @@ -617,7 +630,7 @@ sub torture { runclient($gdbline); } else { - $ret = runclient($testcmd); + $ret = runclient($cmd); } #logmsg "$_ Returned " . ($ret >> 8) . "\n"; @@ -631,6 +644,20 @@ sub torture { $fail = 2; } + if($valgrind) { + my @e = valgrindparse("$LOGDIR/valgrind$testnum"); + if(@e && $e[0]) { + if($automakestyle) { + logmsg "FAIL: torture $testnum - valgrind\n"; + } + else { + logmsg " valgrind ERROR "; + logmsg @e; + } + $fail = 1; + } + } + # verify that it returns a proper error code, doesn't leak memory # and doesn't core dump if(($ret & 255) || ($ret >> 8) >= 128) { @@ -3173,7 +3200,7 @@ sub fixarray { my @in = @_; for(@in) { - subVariables \$_; + subVariables(\$_); } return @in; } @@ -3638,7 +3665,7 @@ sub singletest { if(@setenv) { foreach my $s (@setenv) { chomp $s; - subVariables \$s; + subVariables(\$s); if($s =~ /([^=]*)=(.*)/) { my ($var, $content) = ($1, $2); # remember current setting, to restore it once test runs @@ -4003,7 +4030,8 @@ sub singletest { # run the command line we built if ($torture) { $cmdres = torture($CMDLINE, - "$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd"); + $testnum, + "$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd"); } elsif($gdbthis) { my $GDBW = ($gdbxwin) ? "-w" : ""; @@ -5310,8 +5338,6 @@ while(@ARGV) { if($xtra =~ s/(\d+)$//) { $tortalloc = $1; } - # we undef valgrind to make this fly in comparison - undef $valgrind; } elsif($ARGV[0] eq "-a") { # continue anyway, even if a test fail -- 2.40.0