diff options
Diffstat (limited to 'tests/runtests.pl')
-rwxr-xr-x | tests/runtests.pl | 154 |
1 files changed, 119 insertions, 35 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl index 065df7c..dcd9f84 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -217,6 +217,7 @@ my $gopher_ipv6; # set if Gopher server has IPv6 support my $has_ipv6; # set if libcurl is built with IPv6 support my $has_unix; # set if libcurl is built with Unix sockets support my $has_libz; # set if libcurl is built with libz support +my $has_brotli; # set if libcurl is built with brotli support my $has_getrlimit; # set if system has getrlimit() my $has_ntlm; # set if libcurl is built with NTLM support my $has_ntlm_wb; # set if libcurl is built with NTLM delegation to winbind @@ -232,6 +233,8 @@ my $has_crypto; # set if libcurl is built with cryptographic support my $has_cares; # set if built with c-ares my $has_threadedres;# set if built with threaded resolver my $has_psl; # set if libcurl is built with PSL support +my $has_ldpreload; # set if curl is built for systems supporting LD_PRELOAD +my $has_multissl; # set if curl is build with MultiSSL support # this version is decided by the particular nghttp2 library that is being used my $h2cver = "h2c"; @@ -560,8 +563,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); @@ -575,17 +577,17 @@ sub torture { my $count=0; my @out = `$memanalyze -v $memdump`; for(@out) { - if(/^Allocations: (\d+)/) { + if(/^Operations: (\d+)/) { $count = $1; last; } } if(!$count) { - logmsg " found no allocs to make fail\n"; + logmsg " found no functions to make fail\n"; return 0; } - logmsg " $count allocations to make fail\n"; + logmsg " $count functions to make fail\n"; for ( 1 .. $count ) { my $limit = $_; @@ -600,7 +602,7 @@ sub torture { 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"; + logmsg "Fail function no: $limit at $now\r"; } # make the memory allocation function number $limit return failure @@ -609,14 +611,28 @@ sub torture { # remove memdump first to be sure we get a new nice and clean one unlink($memdump); - logmsg "*** Alloc number $limit is now set to fail ***\n" if($gdbthis); + 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; if($gdbthis) { runclient($gdbline); } else { - $ret = runclient($testcmd); + $ret = runclient($cmd); } #logmsg "$_ Returned " . ($ret >> 8) . "\n"; @@ -630,6 +646,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) { @@ -654,7 +684,7 @@ sub torture { } } if($fail) { - logmsg " Failed on alloc number $limit in test.\n", + logmsg " Failed on function number $limit in test.\n", " invoke with \"-t$limit\" to repeat this single case.\n"; stopservers($verbose); return 1; @@ -2731,6 +2761,9 @@ sub checksystem { $curl =~ s/^(.*)(libcurl.*)/$1/g; $libcurl = $2; + if($curl =~ /linux|bsd|solaris|darwin/) { + $has_ldpreload = 1; + } if($curl =~ /win32|mingw(32|64)/) { # This is a Windows MinGW build or native build, we need to use # Win32-style path. @@ -2827,6 +2860,10 @@ sub checksystem { # ssl enabled $has_ssl=1; } + if($feat =~ /MultiSSL/i) { + # multiple ssl backends available. + $has_multissl=1; + } if($feat =~ /Largefile/i) { # large file support $has_largefile=1; @@ -2844,6 +2881,9 @@ sub checksystem { if($feat =~ /libz/i) { $has_libz = 1; } + if($feat =~ /brotli/i) { + $has_brotli = 1; + } if($feat =~ /NTLM/i) { # NTLM enabled $has_ntlm=1; @@ -3169,7 +3209,7 @@ sub fixarray { my @in = @_; for(@in) { - subVariables \$_; + subVariables(\$_); } return @in; } @@ -3280,6 +3320,11 @@ sub singletest { next; } } + elsif($1 eq "MultiSSL") { + if($has_multissl) { + next; + } + } elsif($1 eq "SSLpinning") { if($has_sslpinning) { next; @@ -3315,6 +3360,11 @@ sub singletest { next; } } + elsif($1 eq "ld_preload") { + if($has_ldpreload && !$debug_build) { + next; + } + } elsif($1 eq "unittest") { if($debug_build) { next; @@ -3350,6 +3400,11 @@ sub singletest { next; } } + elsif($1 eq "brotli") { + if($has_brotli) { + next; + } + } elsif($1 eq "NTLM") { if($has_ntlm) { next; @@ -3443,6 +3498,11 @@ sub singletest { next; } } + elsif($1 eq "MultiSSL") { + if(!$has_multissl) { + next; + } + } elsif($1 eq "OpenSSL") { if(!$has_openssl) { next; @@ -3501,6 +3561,11 @@ sub singletest { next; } } + elsif($1 eq "brotli") { + if(!$has_brotli) { + next; + } + } elsif($1 eq "NTLM") { if(!$has_ntlm) { next; @@ -3585,9 +3650,9 @@ sub singletest { for $k (@keywords) { chomp $k; - if ($disabled_keywords{$k}) { + if ($disabled_keywords{lc($k)}) { $why = "disabled by keyword"; - } elsif ($enabled_keywords{$k}) { + } elsif ($enabled_keywords{lc($k)}) { $match = 1; } } @@ -3629,7 +3694,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 @@ -3755,6 +3820,13 @@ sub singletest { # if this section exists, we verify upload my @upload = getpart("verify", "upload"); + if(@upload) { + my %hash = getpartattr("verify", "upload"); + if($hash{'nonewline'}) { + # cut off the final newline from the final line of the upload data + chomp($upload[$#upload]); + } + } # if this section exists, it might be FTP server instructions: my @ftpservercmd = getpart("reply", "servercmd"); @@ -3808,23 +3880,25 @@ sub singletest { unlink($memdump); } - # create a (possibly-empty) file before starting the test - my @inputfile=getpart("client", "file"); - my %fileattr = getpartattr("client", "file"); - my $filename=$fileattr{'name'}; - if(@inputfile || $filename) { - if(!$filename) { - logmsg "ERROR: section client=>file has no name attribute\n"; - timestampskippedevents($testnum); - return -1; + # create (possibly-empty) files before starting the test + for my $partsuffix (('', '1', '2', '3', '4')) { + my @inputfile=getpart("client", "file".$partsuffix); + my %fileattr = getpartattr("client", "file".$partsuffix); + my $filename=$fileattr{'name'}; + if(@inputfile || $filename) { + if(!$filename) { + logmsg "ERROR: section client=>file has no name attribute\n"; + timestampskippedevents($testnum); + return -1; + } + my $fileContent = join('', @inputfile); + subVariables \$fileContent; +# logmsg "DEBUG: writing file " . $filename . "\n"; + open(OUTFILE, ">$filename"); + binmode OUTFILE; # for crapage systems, use binary + print OUTFILE $fileContent; + close(OUTFILE); } - my $fileContent = join('', @inputfile); - subVariables \$fileContent; -# logmsg "DEBUG: writing file " . $filename . "\n"; - open(OUTFILE, ">$filename"); - binmode OUTFILE; # for crapage systems, use binary - print OUTFILE $fileContent; - close(OUTFILE); } my %cmdhash = getpartattr("client", "command"); @@ -3985,7 +4059,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" : ""; @@ -4289,6 +4364,17 @@ sub singletest { if(@upload) { # verify uploaded data my @out = loadarray("$LOGDIR/upload.$testnum"); + + # what parts to cut off from the upload + my @strippart = getpart("verify", "strippart"); + my $strip; + for $strip (@strippart) { + chomp $strip; + for(@out) { + eval $strip; + } + } + $res = compare($testnum, $testname, "upload", \@out, \@upload); if ($res) { return 1; @@ -5281,8 +5367,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 @@ -5348,7 +5432,7 @@ Usage: runtests.pl [options] [test selection(s)] -rf full run time statistics -s short output -am automake style output PASS/FAIL: [number] [name] - -t[N] torture (simulate memory alloc failures); N means fail Nth alloc + -t[N] torture (simulate function failures); N means fail Nth function -v verbose output -vc path use this curl only to verify the existing servers [num] like "5 6 9" or " 5 to 22 " to run those tests only @@ -5379,10 +5463,10 @@ EOHELP $disabled{$1}=$1; } elsif($ARGV[0] =~ /^!(.+)/) { - $disabled_keywords{$1}=$1; + $disabled_keywords{lc($1)}=$1; } elsif($ARGV[0] =~ /^([-[{a-zA-Z].*)/) { - $enabled_keywords{$1}=$1; + $enabled_keywords{lc($1)}=$1; } else { print "Unknown option: $ARGV[0]\n"; |