# 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);
# 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;
runclient($gdbline);
}
else {
- $ret = runclient($testcmd);
+ $ret = runclient($cmd);
}
#logmsg "$_ Returned " . ($ret >> 8) . "\n";
$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) {
my @in = @_;
for(@in) {
- subVariables \$_;
+ subVariables(\$_);
}
return @in;
}
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
# 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" : "";
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