mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
Adjust valgrind logs file name detection.
Adjust environment vars setting and restoring from test definition. Avoid using strftime in torture sub.
This commit is contained in:
parent
48032c0880
commit
d2e1ec58f2
@ -489,7 +489,6 @@ sub runclientoutput {
|
|||||||
# Memory allocation test and failure torture testing.
|
# Memory allocation test and failure torture testing.
|
||||||
#
|
#
|
||||||
sub torture {
|
sub torture {
|
||||||
use POSIX "strftime";
|
|
||||||
my $testcmd = shift;
|
my $testcmd = shift;
|
||||||
my $gdbline = shift;
|
my $gdbline = shift;
|
||||||
|
|
||||||
@ -526,7 +525,12 @@ sub torture {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
logmsg "Fail alloc no: $limit @ " . strftime ("%H:%M:%S", localtime) . "\r" if($verbose);
|
if($verbose) {
|
||||||
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
||||||
|
localtime(time());
|
||||||
|
my $now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec);
|
||||||
|
logmsg "Fail alloc no: $limit at $now\r";
|
||||||
|
}
|
||||||
|
|
||||||
# make the memory allocation function number $limit return failure
|
# make the memory allocation function number $limit return failure
|
||||||
$ENV{'CURL_MEMLIMIT'} = $limit;
|
$ENV{'CURL_MEMLIMIT'} = $limit;
|
||||||
@ -534,7 +538,7 @@ sub torture {
|
|||||||
# remove memdump first to be sure we get a new nice and clean one
|
# remove memdump first to be sure we get a new nice and clean one
|
||||||
unlink($memdump);
|
unlink($memdump);
|
||||||
|
|
||||||
logmsg "**> Alloc number $limit is now set to fail <**\n" if($gdbthis);
|
logmsg "*** Alloc number $limit is now set to fail ***\n" if($gdbthis);
|
||||||
|
|
||||||
my $ret;
|
my $ret;
|
||||||
if($gdbthis) {
|
if($gdbthis) {
|
||||||
@ -543,7 +547,7 @@ sub torture {
|
|||||||
else {
|
else {
|
||||||
$ret = runclient($testcmd);
|
$ret = runclient($testcmd);
|
||||||
}
|
}
|
||||||
#logmsg "$_ Returned " . $ret / 256 . "\n";
|
#logmsg "$_ Returned " . $ret >> 8 . "\n";
|
||||||
|
|
||||||
# Now clear the variable again
|
# Now clear the variable again
|
||||||
$ENV{'CURL_MEMLIMIT'} = undef if($ENV{'CURL_MEMLIMIT'});
|
$ENV{'CURL_MEMLIMIT'} = undef if($ENV{'CURL_MEMLIMIT'});
|
||||||
@ -580,7 +584,7 @@ sub torture {
|
|||||||
}
|
}
|
||||||
if($fail) {
|
if($fail) {
|
||||||
logmsg " Failed on alloc number $limit in test.\n",
|
logmsg " Failed on alloc number $limit in test.\n",
|
||||||
" invoke with -t$limit to repeat this single case.\n";
|
" invoke with \"-t$limit\" to repeat this single case.\n";
|
||||||
stopservers($verbose);
|
stopservers($verbose);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -2283,20 +2287,25 @@ sub singletest {
|
|||||||
writearray($FTPDCMD, \@ftpservercmd);
|
writearray($FTPDCMD, \@ftpservercmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
my (@setenv)= getpart("client", "setenv");
|
# test definition may instruct to (un)set environment vars
|
||||||
my @envs;
|
my %oldenv;
|
||||||
|
my @setenv = getpart("client", "setenv");
|
||||||
my $s;
|
if(@setenv) {
|
||||||
for $s (@setenv) {
|
foreach my $s (@setenv) {
|
||||||
chomp $s; # cut off the newline
|
chomp $s;
|
||||||
|
subVariables \$s;
|
||||||
subVariables \$s;
|
if($s =~ /([^=]*)=(.*)/) {
|
||||||
|
my ($var, $content) = ($1, $2);
|
||||||
if($s =~ /([^=]*)=(.*)/) {
|
# remember current setting, to restore it once test runs
|
||||||
my ($var, $content)=($1, $2);
|
$oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset';
|
||||||
$ENV{$var}=$content;
|
# set new value
|
||||||
# remember which, so that we can clear them afterwards!
|
if(!$content) {
|
||||||
push @envs, $var;
|
$ENV{$var} = undef if($ENV{$var});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ENV{$var} = "$content";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2608,9 +2617,16 @@ sub singletest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $e;
|
# restore environment variables that were modified
|
||||||
for $e (@envs) {
|
if(%oldenv) {
|
||||||
$ENV{$e}=""; # clean up
|
foreach my $var (keys %oldenv) {
|
||||||
|
if($oldenv{$var} eq 'notset') {
|
||||||
|
$ENV{$var} = undef if($ENV{$var});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ENV{$var} = "$oldenv{$var}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Skip all the verification on torture tests
|
# Skip all the verification on torture tests
|
||||||
@ -2801,7 +2817,7 @@ sub singletest {
|
|||||||
# accept multiple comma-separated error codes
|
# accept multiple comma-separated error codes
|
||||||
my @splerr = split(/ *, */, $errorcode);
|
my @splerr = split(/ *, */, $errorcode);
|
||||||
my $errok;
|
my $errok;
|
||||||
foreach $e (@splerr) {
|
foreach my $e (@splerr) {
|
||||||
if($e == $cmdres) {
|
if($e == $cmdres) {
|
||||||
# a fine error code
|
# a fine error code
|
||||||
$errok = 1;
|
$errok = 1;
|
||||||
@ -2856,28 +2872,28 @@ sub singletest {
|
|||||||
if($valgrind) {
|
if($valgrind) {
|
||||||
if($usevalgrind) {
|
if($usevalgrind) {
|
||||||
unless(opendir(DIR, "$LOGDIR")) {
|
unless(opendir(DIR, "$LOGDIR")) {
|
||||||
|
logmsg "ERROR: unable to read $LOGDIR\n";
|
||||||
# timestamp test result verification end
|
# timestamp test result verification end
|
||||||
$timevrfyend{$testnum} = Time::HiRes::time() if($timestats);
|
$timevrfyend{$testnum} = Time::HiRes::time() if($timestats);
|
||||||
return 0; # can't open log dir
|
return 1;
|
||||||
}
|
}
|
||||||
my @files = grep { /valgrind/ } readdir(DIR);
|
my @files = readdir(DIR);
|
||||||
closedir(DIR);
|
closedir(DIR);
|
||||||
logmsg "DEBUG: No valgrind files\n" unless(@files);
|
my $vgfile;
|
||||||
my $f;
|
foreach my $file (@files) {
|
||||||
my $l="";
|
if($file =~ /^valgrind$testnum(\..*|)$/) {
|
||||||
foreach $f (@files) {
|
$vgfile = $file;
|
||||||
logmsg "DEBUG: valgrind file: $f\n";
|
|
||||||
if($f =~ /^valgrind$testnum\./) {
|
|
||||||
$l = $f;
|
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $src=$ENV{'srcdir'};
|
if(!$vgfile) {
|
||||||
if(!$src) {
|
logmsg "ERROR: valgrind log file missing for test $testnum\n";
|
||||||
$src=".";
|
# timestamp test result verification end
|
||||||
|
$timevrfyend{$testnum} = Time::HiRes::time() if($timestats);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
my @e = valgrindparse($src, $feature{'SSL'}, "$LOGDIR/$l");
|
my @e = valgrindparse($srcdir, $feature{'SSL'}, "$LOGDIR/$vgfile");
|
||||||
if($e[0]) {
|
if(@e && $e[0]) {
|
||||||
logmsg " valgrind ERROR ";
|
logmsg " valgrind ERROR ";
|
||||||
logmsg @e;
|
logmsg @e;
|
||||||
# timestamp test result verification end
|
# timestamp test result verification end
|
||||||
@ -3715,7 +3731,7 @@ sub displaylogs {
|
|||||||
if(($log =~ /^file\d+\.txt/) && ($log !~ /^file$testnum\.txt/)) {
|
if(($log =~ /^file\d+\.txt/) && ($log !~ /^file$testnum\.txt/)) {
|
||||||
next; # skip fileNnn.txt of other tests
|
next; # skip fileNnn.txt of other tests
|
||||||
}
|
}
|
||||||
if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum\./)) {
|
if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(\..*|)$/)) {
|
||||||
next; # skip valgrindNnn of other tests
|
next; # skip valgrindNnn of other tests
|
||||||
}
|
}
|
||||||
logmsg "=== Start of file $log\n";
|
logmsg "=== Start of file $log\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user