2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 # $Id: runtests.pl,v 1.1.1.1 2008-09-23 16:32:06 hoffman Exp $
23 ###########################################################################
25 # Experimental hooks are available to run tests remotely on machines that
26 # are able to run curl but are unable to run the test harness.
27 # The following sections need to be modified:
29 # $HOSTIP, $HOST6IP - Set to the address of the host running the test suite
30 # $CLIENTIP, $CLIENT6IP - Set to the address of the host running curl
31 # runclient, runclientoutput - Modify to copy all the files in the log/
32 # directory to the system running curl, run the given command remotely
33 # and save the return code or returned stdout (respectively), then
34 # copy all the files from the remote system's log/ directory back to
35 # the host running the test suite. This can be done a few ways, such
36 # as using scp & ssh, rsync & telnet, or using a NFS shared directory
39 # 'make && make test' needs to be done on both machines before making the
40 # above changes and running runtests.pl manually. In the shared NFS case,
41 # the contents of the tests/server/ directory must be from the host
42 # running the test suite, while the rest must be from the host running curl.
44 # Note that even with these changes a number of tests will still fail (mainly
45 # to do with cookies, those that set environment variables, or those that
46 # do more than touch the file system in a <precheck> or <postcheck>
47 # section). These can be added to the $TESTCASES line below,
48 # e.g. $TESTCASES="!8 !31 !63 !cookies..."
50 # Finally, to properly support -g and -n, checktestcmd needs to change
51 # to check the remote system's PATH, and the places in the code where
52 # the curl binary is read directly to determine its type also need to be
53 # fixed. As long as the -g option is never given, and the -n is always
54 # given, this won't be a problem.
57 # These should be the only variables that might be needed to get edited:
60 @INC=(@INC, $ENV{'srcdir'}, ".");
64 #use Time::HiRes qw( gettimeofday );
68 # Variables and subs imported from sshhelp module
90 require "getpart.pm"; # array functions
91 require "valgrind.pm"; # valgrind report parser
94 my $HOSTIP="127.0.0.1"; # address on which the test server listens
95 my $HOST6IP="[::1]"; # address on which the test server listens
96 my $CLIENTIP="127.0.0.1"; # address which curl uses for incoming connections
97 my $CLIENT6IP="[::1]"; # address which curl uses for incoming connections
99 my $base = 8990; # base port number
101 my $HTTPPORT; # HTTP server port
102 my $HTTP6PORT; # HTTP IPv6 server port
103 my $HTTPSPORT; # HTTPS server port
104 my $FTPPORT; # FTP server port
105 my $FTP2PORT; # FTP server 2 port
106 my $FTPSPORT; # FTPS server port
107 my $FTP6PORT; # FTP IPv6 server port
109 my $TFTP6PORT; # TFTP
110 my $SSHPORT; # SCP/SFTP
111 my $SOCKSPORT; # SOCKS4/5 port
113 my $srcdir = $ENV{'srcdir'} || '.';
114 my $CURL="../src/curl"; # what curl executable to run on the tests
115 my $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging
117 my $TESTDIR="$srcdir/data";
118 my $LIBDIR="./libtest";
119 my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
120 my $SERVER2IN="$LOGDIR/server2.input"; # what curl sent the second server
121 my $CURLLOG="$LOGDIR/curl.log"; # all command lines run
122 my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here
123 my $SERVERLOGS_LOCK="$LOGDIR/serverlogs.lock"; # server logs advisor read lock
125 # Normally, all test cases should be run, but at times it is handy to
126 # simply run a particular one:
129 # To run specific test cases, set them like:
130 # $TESTCASES="1 2 3 7 8";
132 #######################################################################
133 # No variables below this point should need to be modified
136 my $HTTPPIDFILE=".http.pid";
137 my $HTTP6PIDFILE=".http6.pid";
138 my $HTTPSPIDFILE=".https.pid";
139 my $FTPPIDFILE=".ftp.pid";
140 my $FTP6PIDFILE=".ftp6.pid";
141 my $FTP2PIDFILE=".ftp2.pid";
142 my $FTPSPIDFILE=".ftps.pid";
143 my $TFTPPIDFILE=".tftpd.pid";
144 my $TFTP6PIDFILE=".tftp6.pid";
145 my $SSHPIDFILE=".ssh.pid";
146 my $SOCKSPIDFILE=".socks.pid";
148 # invoke perl like this:
149 my $perl="perl -I$srcdir";
150 my $server_response_maxtime=13;
152 # this gets set if curl is compiled with debugging:
156 # name of the file that the memory debugging creates:
157 my $memdump="$LOGDIR/memdump";
159 # the path to the script that analyzes the memory debug output file:
160 my $memanalyze="$perl $srcdir/memanalyze.pl";
162 my $pwd = getcwd
(); # current working directory
166 my $ftpchecktime; # time it took to verify our test FTP server
168 my $stunnel = checkcmd
("stunnel4") || checkcmd
("stunnel");
169 my $valgrind = checktestcmd
("valgrind");
170 my $valgrind_logfile="--logfile";
172 my $gdb = checktestcmd
("gdb");
174 my $ssl_version; # set if libcurl is built with SSL support
175 my $large_file; # set if libcurl is built with large file support
176 my $has_idn; # set if libcurl is built with IDN support
177 my $http_ipv6; # set if HTTP server has IPv6 support
178 my $ftp_ipv6; # set if FTP server has IPv6 support
179 my $tftp_ipv6; # set if TFTP server has IPv6 support
180 my $has_ipv6; # set if libcurl is built with IPv6 support
181 my $has_libz; # set if libcurl is built with libz support
182 my $has_getrlimit; # set if system has getrlimit()
183 my $has_ntlm; # set if libcurl is built with NTLM support
185 my $has_openssl; # built with a lib using an OpenSSL-like API
186 my $has_gnutls; # built with GnuTLS
187 my $has_nss; # built with NSS
188 my $has_yassl; # built with yassl
190 my $ssllib; # name of the lib we use (for human presentation)
191 my $has_crypto; # set if libcurl is built with cryptographic support
192 my $has_textaware; # set if running on a system that has a text mode concept
193 # on files. Windows for example
194 my @protocols; # array of supported protocols
196 my $skipped=0; # number of tests skipped; reported in main loop
197 my %skipped; # skipped{reason}=counter, reasons for skip
198 my @teststat; # teststat[testnum]=reason, reasons for skip
199 my %disabled_keywords; # key words of tests to skip
200 my %enabled_keywords; # key words of tests to run
202 my $sshdid; # for socks server, ssh daemon version id
203 my $sshdvernum; # for socks server, ssh daemon version number
204 my $sshdverstr; # for socks server, ssh daemon version string
205 my $sshderror; # for socks server, ssh daemon version error
207 my $defserverlogslocktimeout = 20; # timeout to await server logs lock removal
208 my $defpostcommanddelay = 0; # delay between command and postcheck sections
210 #######################################################################
211 # variables the command line options may set
218 my $gdbthis; # run test case with gdb debugger
219 my $keepoutfiles; # keep stdout and stderr files after tests
220 my $listonly; # only list the tests
221 my $postmortem; # display detailed info about failed tests
223 my %run; # running server
224 my %doesntrun; # servers that don't work, identified by pidfile
226 # torture test variables
231 # open and close each time to allow removal at any time
233 # uncomment the Time::HiRes usage for this
234 # my ($seconds, $microseconds) = gettimeofday;
235 # my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
236 # localtime($seconds);
239 # $t = sprintf ("%02d:%02d:%02d.%06d ", $hour, $min, $sec,
247 # get the name of the current user
248 my $USER = $ENV{USER
}; # Linux
250 $USER = $ENV{USERNAME
}; # Windows
252 $USER = $ENV{LOGNAME
}; # Some UNIX (I think)
256 # enable memory debugging if curl is compiled with it
257 $ENV{'CURL_MEMDEBUG'} = $memdump;
262 logmsg
"runtests.pl received SIG$signame, exiting\n";
264 die "Somebody sent me a SIG$signame";
266 $SIG{INT
} = \
&catch_zap
;
267 $SIG{KILL
} = \
&catch_zap
;
269 ##########################################################################
270 # Clear all possible '*_proxy' environment variables for various protocols
271 # to prevent them to interfere with our testing!
274 foreach $protocol (('ftp', 'http', 'ftps', 'https', 'no')) {
275 my $proxy = "${protocol}_proxy";
276 # clear lowercase version
278 # clear uppercase version
279 $ENV{uc($proxy)}=undef;
282 # make sure we don't get affected by other variables that control our
285 $ENV{'SSL_CERT_DIR'}=undef;
286 $ENV{'SSL_CERT_PATH'}=undef;
287 $ENV{'CURL_CA_BUNDLE'}=undef;
289 #######################################################################
290 # Check if a given child process has just died. Reaps it if so.
293 use POSIX
":sys_wait_h";
295 if(not defined $pid || $pid <= 0) {
298 my $rc = waitpid($pid, &WNOHANG
);
299 return ($rc == $pid)?
1:0;
302 #######################################################################
303 # Start a new thread/process and run the given command line in there.
304 # Return the pids (yes plural) of the new child process to the parent.
307 my ($cmd, $pidfile, $timeout, $fake)=@_;
309 logmsg
"startnew: $cmd\n" if ($verbose);
314 if(not defined $child) {
315 logmsg
"startnew: fork() failure detected\n";
320 # Here we are the child. Run the given command.
322 # Put an "exec" in front of the command so that the child process
323 # keeps this child's process ID.
324 exec("exec $cmd") || die "Can't exec() $cmd: $!";
326 # exec() should never return back here to this process. We protect
327 # ourselves by calling die() just in case something goes really bad.
328 die "error: exec() has returned";
331 # Ugly hack but ssh client doesn't support pid files
333 if(open(OUT
, ">$pidfile")) {
334 print OUT
$child . "\n";
336 logmsg
"startnew: $pidfile faked with pid=$child\n" if($verbose);
339 logmsg
"startnew: failed to write fake $pidfile with pid=$child\n";
341 # could/should do a while connect fails sleep a bit and loop
343 if (checkdied
($child)) {
344 logmsg
"startnew: child process has failed to start\n" if($verbose);
349 my $count = $timeout;
351 if(-f
$pidfile && -s
$pidfile && open(PID
, "<$pidfile")) {
354 if(($pid2 > 0) && kill(0, $pid2)) {
355 # if $pid2 is valid, then make sure this pid is alive, as
356 # otherwise it is just likely to be the _previous_ pidfile or
360 # invalidate $pid2 if not actually alive
363 if (checkdied
($child)) {
364 logmsg
"startnew: child process has died, server might start up\n"
366 # We can't just abort waiting for the server with a
368 # because the server might have forked and could still start
369 # up normally. Instead, just reduce the amount of time we remain
376 # Return two PIDs, the one for the child process we spawned and the one
377 # reported by the server itself (in case it forked again on its own).
378 # Both (potentially) need to be killed at the end of the test.
379 return ($child, $pid2);
383 #######################################################################
384 # Check for a command in the PATH of the test server.
388 my @paths=(split(":", $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
389 "/sbin", "/usr/bin", "/usr/local/bin" );
391 if( -x
"$_/$cmd" && ! -d
"$_/$cmd") {
392 # executable bit but not a directory!
398 #######################################################################
399 # Check for a command in the PATH of the machine running curl.
403 return checkcmd
($cmd);
406 #######################################################################
407 # Run the application under test and return its return code
413 # This is one way to test curl on a remote machine
414 # my $out = system("ssh $CLIENTIP cd \'$pwd\' \\; \'$cmd\'");
415 # sleep 2; # time to allow the NFS server to be updated
419 #######################################################################
420 # Run the application under test and return its stdout
422 sub runclientoutput
{
426 # This is one way to test curl on a remote machine
427 # my @out = `ssh $CLIENTIP cd \'$pwd\' \\; \'$cmd\'`;
428 # sleep 2; # time to allow the NFS server to be updated
432 #######################################################################
433 # Memory allocation test and failure torture testing.
439 # remove memdump first to be sure we get a new nice and clean one
442 # First get URL from test server, ignore the output/result
445 logmsg
" CMD: $testcmd\n" if($verbose);
447 # memanalyze -v is our friend, get the number of allocations made
449 my @out = `$memanalyze -v $memdump`;
451 if(/^Allocations: (\d+)/) {
457 logmsg
" found no allocs to make fail\n";
461 logmsg
" $count allocations to make fail\n";
463 for ( 1 .. $count ) {
468 if($tortalloc && ($tortalloc != $limit)) {
472 logmsg
"Fail alloc no: $limit\r" if($verbose);
474 # make the memory allocation function number $limit return failure
475 $ENV{'CURL_MEMLIMIT'} = $limit;
477 # remove memdump first to be sure we get a new nice and clean one
480 logmsg
"**> Alloc number $limit is now set to fail <**\n" if($gdbthis);
487 $ret = runclient
($testcmd);
490 # Now clear the variable again
491 $ENV{'CURL_MEMLIMIT'} = undef;
494 # there's core file present now!
495 logmsg
" core dumped\n";
500 # verify that it returns a proper error code, doesn't leak memory
501 # and doesn't core dump
503 logmsg
" system() returned $ret\n";
507 my @memdata=`$memanalyze $memdump`;
511 # well it could be other memory problems as well, but
512 # we call it leak for short here
517 logmsg
"** MEMORY FAILURE\n";
519 logmsg
`$memanalyze -l $memdump`;
524 logmsg
" Failed on alloc number $limit in test.\n",
525 " invoke with -t$limit to repeat this single case.\n";
526 stopservers
($verbose);
531 logmsg
"torture OK\n";
535 #######################################################################
536 # stop the given test server (pid)
541 if(not defined $pid || $pid <= 0) {
542 return; # whad'da'ya wanna'da with no pid ?
545 # It might be more than one pid
546 # Send each one a SIGTERM to gracefully kill it
549 my @pids = split(/\s+/, $pid);
552 if($_ =~ /^(\d+)$/) {
553 if(($1 > 0) && kill(0, $1)) {
555 logmsg
"RUN: Test server pid $1 signalled to die\n";
563 # Give each process killed up to a few seconds to die, then send
564 # a SIGKILL to finish it off for good.
566 my $count = 5; # wait for this many seconds for server to die
568 if (!kill(0, $_) || checkdied
($_)) {
574 logmsg
"RUN: forcing pid $_ to die with SIGKILL\n";
580 #######################################################################
581 # Verify that the server that runs on $ip, $port is our server. This also
582 # implies that we can speak with it, as there might be occasions when the
583 # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't
584 # assign requested address" #
587 my ($proto, $ip, $port) = @_;
588 my $cmd = "$CURL --max-time $server_response_maxtime --output $LOGDIR/verifiedserver --insecure --silent --verbose --globoff \"$proto://$ip:$port/verifiedserver\" 2>$LOGDIR/verifyhttp";
591 # verify if our/any server is running on this port
592 logmsg
"CMD; $cmd\n" if ($verbose);
593 my $res = runclient
($cmd);
595 $res >>= 8; # rotate the result
598 if($res && $verbose) {
599 open(ERR
, "<$LOGDIR/verifyhttp");
602 logmsg
"RUN: curl command returned $res\n";
604 if($_ !~ /^([ \t]*)$/) {
609 open(FILE
, "<$LOGDIR/verifiedserver");
612 $data=$file[0]; # first line
614 if ( $data =~ /WE ROOLZ: (\d+)/ ) {
618 # curl: (6) Couldn't resolve host '::1'
619 logmsg
"RUN: failed to resolve host ($proto://$ip:$port/verifiedserver)\n";
622 elsif($data || ($res != 7)) {
623 logmsg
"RUN: Unknown server is running on port $port\n";
629 #######################################################################
630 # Verify that the server that runs on $ip, $port is our server. This also
631 # implies that we can speak with it, as there might be occasions when the
632 # server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't
633 # assign requested address" #
636 my ($proto, $ip, $port) = @_;
640 if($proto eq "ftps") {
641 $extra = "--insecure --ftp-ssl-control ";
643 my $cmd="$CURL --max-time $server_response_maxtime --silent --verbose --globoff $extra\"$proto://$ip:$port/verifiedserver\" 2>$LOGDIR/verifyftp";
644 # check if this is our server running on this port:
645 my @data=runclientoutput
($cmd);
646 logmsg
"RUN: $cmd\n" if($verbose);
649 foreach $line (@data) {
650 if ( $line =~ /WE ROOLZ: (\d+)/ ) {
651 # this is our test server with a known pid!
656 if($pid <= 0 && $data[0]) {
657 # this is not a known server
658 logmsg
"RUN: Unknown server on our FTP port: $port\n";
661 # we can/should use the time it took to verify the FTP server as a measure
662 # on how fast/slow this host/FTP is.
663 my $took = time()-$time;
666 logmsg
"RUN: Verifying our test FTP server took $took seconds\n";
668 $ftpchecktime = $took?
$took:1; # make sure it never is zero
673 #######################################################################
674 # Verify that the ssh server has written out its pidfile, recovering
675 # the pid from the file and returning it if a process with that pid is
679 my ($proto, $ip, $port) = @_;
681 if(open(FILE
, "<$SSHPIDFILE")) {
686 # if we have a pid it is actually our ssh server,
687 # since runsshserver() unlinks previous pidfile
689 logmsg
"RUN: SSH server has died after starting up\n";
698 #######################################################################
699 # Verify that we can connect to the sftp server, properly authenticate
700 # with generated config and key files and run a simple remote pwd.
703 my ($proto, $ip, $port) = @_;
705 # Find out sftp client canonical file name
706 my $sftp = find_sftp
();
708 logmsg
"RUN: SFTP server cannot find $sftpexe\n";
711 # Find out ssh client canonical file name
712 my $ssh = find_ssh
();
714 logmsg
"RUN: SFTP server cannot find $sshexe\n";
717 # Connect to sftp server, authenticate and run a remote pwd
718 # command using our generated configuration and key files
719 my $cmd = "$sftp -b $sftpcmds -F $sftpconfig -S $ssh $ip > $sftplog 2>&1";
720 my $res = runclient
($cmd);
721 # Search for pwd command response in log file
722 if(open(SFTPLOGFILE
, "<$sftplog")) {
723 while(<SFTPLOGFILE
>) {
724 if(/^Remote working directory: /) {
735 #######################################################################
736 # STUB for verifying socks
739 my ($proto, $ip, $port) = @_;
741 if(open(FILE
, "<$SOCKSPIDFILE")) {
746 # if we have a pid it is actually our socks server,
747 # since runsocksserver() unlinks previous pidfile
749 logmsg
"RUN: SOCKS server has died after starting up\n";
751 unlink($SOCKSPIDFILE);
758 #######################################################################
759 # Verify that the server that runs on $ip, $port is our server.
760 # Retry over several seconds before giving up. The ssh server in
761 # particular can take a long time to start if it needs to generate
762 # keys on a slow or loaded host.
765 my %protofunc = ('http' => \
&verifyhttp
,
766 'https' => \
&verifyhttp
,
767 'ftp' => \
&verifyftp
,
768 'ftps' => \
&verifyftp
,
769 'tftp' => \
&verifyftp
,
770 'ssh' => \
&verifyssh
,
771 'socks' => \
&verifysocks
);
774 my ($proto, $ip, $port) = @_;
776 my $count = 30; # try for this many seconds
780 my $fun = $protofunc{$proto};
782 $pid = &$fun($proto, $ip, $port);
788 # a real failure, stop trying and bail out
798 #######################################################################
799 # start the http server
802 my ($verbose, $ipv6) = @_;
804 my $pidfile = $HTTPPIDFILE;
805 my $port = $HTTPPORT;
808 my $fork = $forkserver?
"--fork":"";
811 # if IPv6, use a different setup
812 $pidfile = $HTTP6PIDFILE;
818 # don't retry if the server doesn't work
819 if ($doesntrun{$pidfile}) {
823 my $pid = checkserver
($pidfile);
829 my $flag=$debugprotocol?
"-v ":"";
830 my $dir=$ENV{'srcdir'};
832 $flag .= "-d \"$dir\" ";
835 my $cmd="$perl $srcdir/httpserver.pl -p $pidfile $fork$flag $port $ipv6";
836 my ($httppid, $pid2) =
837 startnew
($cmd, $pidfile, 15, 0); # start the server in a new process
839 if($httppid <= 0 || !kill(0, $httppid)) {
841 logmsg
"RUN: failed to start the HTTP$nameext server\n";
843 $doesntrun{$pidfile} = 1;
847 # Server is up. Verify that we can speak to it.
848 my $pid3 = verifyserver
("http", $ip, $port);
850 logmsg
"RUN: HTTP$nameext server failed verification\n";
851 # failed to talk to it properly. Kill the server and return failure
852 stopserver
("$httppid $pid2");
853 $doesntrun{$pidfile} = 1;
859 logmsg
"RUN: HTTP$nameext server is now running PID $httppid\n";
864 return ($httppid, $pid2);
867 #######################################################################
868 # start the https server (or rather, tunnel)
871 my ($verbose, $ipv6) = @_;
875 my $pidfile = $HTTPSPIDFILE;
886 # don't retry if the server doesn't work
887 if ($doesntrun{$pidfile}) {
891 my $pid = checkserver
($pidfile);
893 # kill previous stunnel!
898 my $flag=$debugprotocol?
"-v ":"";
899 my $cmd="$perl $srcdir/httpsserver.pl $flag -p https -s \"$stunnel\" -d $srcdir -r $HTTPPORT $HTTPSPORT";
901 my ($httpspid, $pid2) = startnew
($cmd, $pidfile, 15, 0);
903 if($httpspid <= 0 || !kill(0, $httpspid)) {
905 logmsg
"RUN: failed to start the HTTPS server\n";
906 stopservers
($verbose);
907 $doesntrun{$pidfile} = 1;
911 # Server is up. Verify that we can speak to it.
912 my $pid3 = verifyserver
("https", $ip, $HTTPSPORT);
914 logmsg
"RUN: HTTPS server failed verification\n";
915 # failed to talk to it properly. Kill the server and return failure
916 stopserver
("$httpspid $pid2");
917 $doesntrun{$pidfile} = 1;
920 # Here pid3 is actually the pid returned by the unsecure-http server.
923 logmsg
"RUN: HTTPS server is now running PID $httpspid\n";
928 return ($httpspid, $pid2);
931 #######################################################################
932 # start the ftp server
935 my ($id, $verbose, $ipv6) = @_;
938 my $port = $id?
$FTP2PORT:$FTPPORT;
940 my $pidfile = $id?
$FTP2PIDFILE:$FTPPIDFILE;
946 # if IPv6, use a different setup
947 $pidfile = $FTP6PIDFILE;
953 # don't retry if the server doesn't work
954 if ($doesntrun{$pidfile}) {
958 my $pid = checkserver
($pidfile);
965 my $flag=$debugprotocol?
"-v ":"";
966 $flag .= "-s \"$srcdir\" ";
978 $cmd="$perl $srcdir/ftpserver.pl --pidfile $pidfile $flag --port $port --addr \"$addr\"";
979 my ($ftppid, $pid2) = startnew
($cmd, $pidfile, 15, 0);
981 if($ftppid <= 0 || !kill(0, $ftppid)) {
983 logmsg
"RUN: failed to start the FTP$id$nameext server\n";
985 $doesntrun{$pidfile} = 1;
989 # Server is up. Verify that we can speak to it.
990 my $pid3 = verifyserver
("ftp", $ip, $port);
992 logmsg
"RUN: FTP$id$nameext server failed verification\n";
993 # failed to talk to it properly. Kill the server and return failure
994 stopserver
("$ftppid $pid2");
995 $doesntrun{$pidfile} = 1;
1001 logmsg
"RUN: FTP$id$nameext server is now running PID $ftppid\n";
1006 return ($pid2, $ftppid);
1009 #######################################################################
1010 # start the ftps server (or rather, tunnel)
1013 my ($verbose, $ipv6) = @_;
1017 my $pidfile = $FTPSPIDFILE;
1028 # don't retry if the server doesn't work
1029 if ($doesntrun{$pidfile}) {
1033 my $pid = checkserver
($pidfile);
1035 # kill previous stunnel!
1040 my $flag=$debugprotocol?
"-v ":"";
1041 my $cmd="$perl $srcdir/httpsserver.pl $flag -p ftps -s \"$stunnel\" -d $srcdir -r $FTPPORT $FTPSPORT";
1043 my ($ftpspid, $pid2) = startnew
($cmd, $pidfile, 15, 0);
1045 if($ftpspid <= 0 || !kill(0, $ftpspid)) {
1047 logmsg
"RUN: failed to start the FTPS server\n";
1048 stopservers
($verbose);
1049 $doesntrun{$pidfile} = 1;
1053 # Server is up. Verify that we can speak to it.
1054 my $pid3 = verifyserver
("ftps", $ip, $FTPSPORT);
1056 logmsg
"RUN: FTPS server failed verification\n";
1057 # failed to talk to it properly. Kill the server and return failure
1058 stopserver
("$ftpspid $pid2");
1059 $doesntrun{$pidfile} = 1;
1062 # Here pid3 is actually the pid returned by the unsecure-ftp server.
1065 logmsg
"RUN: FTPS server is now running PID $ftpspid\n";
1070 return ($ftpspid, $pid2);
1073 #######################################################################
1074 # start the tftp server
1077 my ($id, $verbose, $ipv6) = @_;
1080 my $port = $TFTPPORT;
1082 my $pidfile = $TFTPPIDFILE;
1088 # if IPv6, use a different setup
1089 $pidfile = $TFTP6PIDFILE;
1095 # don't retry if the server doesn't work
1096 if ($doesntrun{$pidfile}) {
1100 my $pid = checkserver
($pidfile);
1107 my $flag=$debugprotocol?
"-v ":"";
1108 $flag .= "-s \"$srcdir\" ";
1110 $flag .="--id $id ";
1116 $cmd="./server/tftpd --pidfile $pidfile $flag $port";
1117 my ($tftppid, $pid2) = startnew
($cmd, $pidfile, 15, 0);
1119 if($tftppid <= 0 || !kill(0, $tftppid)) {
1121 logmsg
"RUN: failed to start the TFTP$id$nameext server\n";
1122 stopserver
("$pid2");
1123 $doesntrun{$pidfile} = 1;
1127 # Server is up. Verify that we can speak to it.
1128 my $pid3 = verifyserver
("tftp", $ip, $port);
1130 logmsg
"RUN: TFTP$id$nameext server failed verification\n";
1131 # failed to talk to it properly. Kill the server and return failure
1132 stopserver
("$tftppid $pid2");
1133 $doesntrun{$pidfile} = 1;
1139 logmsg
"RUN: TFTP$id$nameext server is now running PID $tftppid\n";
1144 return ($pid2, $tftppid);
1148 #######################################################################
1149 # Start the scp/sftp server
1152 my ($id, $verbose, $ipv6) = @_;
1154 my $port = $SSHPORT;
1155 my $socksport = $SOCKSPORT;
1156 my $pidfile = $SSHPIDFILE;
1158 # don't retry if the server doesn't work
1159 if ($doesntrun{$pidfile}) {
1163 my $pid = checkserver
($pidfile);
1169 my $flag=$verbose?
'-v ':'';
1170 $flag .= '-d ' if($debugprotocol);
1172 my $cmd="$perl $srcdir/sshserver.pl ${flag}-u $USER -l $ip -p $port -s $socksport";
1173 my ($sshpid, $pid2) = startnew
($cmd, $pidfile, 60, 0);
1175 # on loaded systems sshserver start up can take longer than the timeout
1176 # passed to startnew, when this happens startnew completes without being
1177 # able to read the pidfile and consequently returns a zero pid2 above.
1179 if($sshpid <= 0 || !kill(0, $sshpid)) {
1181 logmsg
"RUN: failed to start the SSH server\n";
1182 stopserver
("$pid2");
1183 $doesntrun{$pidfile} = 1;
1187 # ssh server verification allows some extra time for the server to start up
1188 # and gives us the opportunity of recovering the pid from the pidfile, when
1189 # this verification succeeds the recovered pid is assigned to pid2.
1191 my $pid3 = verifyserver
("ssh",$ip,$port);
1193 logmsg
"RUN: SSH server failed verification\n";
1194 # failed to fetch server pid. Kill the server and return failure
1195 stopserver
("$sshpid $pid2");
1196 $doesntrun{$pidfile} = 1;
1201 # once it is known that the ssh server is alive, sftp server verification
1202 # is performed actually connecting to it, authenticating and performing a
1203 # very simple remote command. This verification is tried only one time.
1205 if(verifysftp
("sftp",$ip,$port) < 1) {
1206 logmsg
"RUN: SFTP server failed verification\n";
1207 # failed to talk to it properly. Kill the server and return failure
1209 display_sftpconfig
();
1211 display_sshdconfig
();
1212 stopserver
("$sshpid $pid2");
1213 $doesntrun{$pidfile} = 1;
1218 logmsg
"RUN: SSH server is now running PID $pid2\n";
1221 return ($pid2, $sshpid);
1224 #######################################################################
1225 # Start the socks server
1227 sub runsocksserver
{
1228 my ($id, $verbose, $ipv6) = @_;
1230 my $port = $SOCKSPORT;
1231 my $pidfile = $SOCKSPIDFILE;
1233 # don't retry if the server doesn't work
1234 if ($doesntrun{$pidfile}) {
1238 my $pid = checkserver
($pidfile);
1244 # The ssh server must be already running
1246 logmsg
"RUN: SOCKS server cannot find running SSH server\n";
1247 $doesntrun{$pidfile} = 1;
1251 # Find out ssh daemon canonical file name
1252 my $sshd = find_sshd
();
1254 logmsg
"RUN: SOCKS server cannot find $sshdexe\n";
1255 $doesntrun{$pidfile} = 1;
1259 # Find out ssh daemon version info
1260 ($sshdid, $sshdvernum, $sshdverstr, $sshderror) = sshversioninfo
($sshd);
1262 # Not an OpenSSH or SunSSH ssh daemon
1263 logmsg
"$sshderror\n" if($verbose);
1264 logmsg
"SCP, SFTP and SOCKS tests require OpenSSH 2.9.9 or later\n";
1265 $doesntrun{$pidfile} = 1;
1268 logmsg
"ssh server found $sshd is $sshdverstr\n" if($verbose);
1270 # Find out ssh client canonical file name
1271 my $ssh = find_ssh
();
1273 logmsg
"RUN: SOCKS server cannot find $sshexe\n";
1274 $doesntrun{$pidfile} = 1;
1278 # Find out ssh client version info
1279 my ($sshid, $sshvernum, $sshverstr, $ssherror) = sshversioninfo
($ssh);
1281 # Not an OpenSSH or SunSSH ssh client
1282 logmsg
"$ssherror\n" if($verbose);
1283 logmsg
"SCP, SFTP and SOCKS tests require OpenSSH 2.9.9 or later\n";
1284 $doesntrun{$pidfile} = 1;
1288 # Verify minimum ssh client version
1289 if((($sshid =~ /OpenSSH/) && ($sshvernum < 299)) ||
1290 (($sshid =~ /SunSSH/) && ($sshvernum < 100))) {
1291 logmsg
"ssh client found $ssh is $sshverstr\n";
1292 logmsg
"SCP, SFTP and SOCKS tests require OpenSSH 2.9.9 or later\n";
1293 $doesntrun{$pidfile} = 1;
1296 logmsg
"ssh client found $ssh is $sshverstr\n" if($verbose);
1298 # Verify if ssh client and ssh daemon versions match
1299 if(($sshdid ne $sshid) || ($sshdvernum != $sshvernum)) {
1300 # Our test harness might work with slightly mismatched versions
1301 logmsg
"Warning: version mismatch: sshd $sshdverstr - ssh $sshverstr\n"
1305 # Config file options for ssh client are previously set from sshserver.pl
1306 if(! -e
$sshconfig) {
1307 logmsg
"RUN: SOCKS server cannot find $sshconfig\n";
1308 $doesntrun{$pidfile} = 1;
1312 # start our socks server
1313 my $cmd="$ssh -N -F $sshconfig $ip > $sshlog 2>&1";
1314 my ($sshpid, $pid2) = startnew
($cmd, $pidfile, 30, 1);
1316 if($sshpid <= 0 || !kill(0, $sshpid)) {
1318 logmsg
"RUN: failed to start the SOCKS server\n";
1320 display_sshconfig
();
1322 display_sshdconfig
();
1323 stopserver
("$pid2");
1324 $doesntrun{$pidfile} = 1;
1328 # Ugly hack but ssh doesn't support pid files
1329 my $pid3 = verifyserver
("socks",$ip,$port);
1331 logmsg
"RUN: SOCKS server failed verification\n";
1332 # failed to talk to it properly. Kill the server and return failure
1333 stopserver
("$sshpid $pid2");
1334 $doesntrun{$pidfile} = 1;
1340 logmsg
"RUN: SOCKS server is now running PID $pid2\n";
1343 return ($pid2, $sshpid);
1346 #######################################################################
1347 # Remove all files in the specified directory
1355 opendir(DIR
, $dir) ||
1356 return 0; # can't open dir
1357 while($file = readdir(DIR
)) {
1358 if($file !~ /^\./) {
1359 unlink("$dir/$file");
1367 #######################################################################
1368 # filter out the specified pattern from the given input file and store the
1369 # results in the given output file
1376 open(IN
, "<$infile")
1379 open(OUT
, ">$ofile")
1382 # logmsg "FILTER: off $filter from $infile to $ofile\n";
1393 #######################################################################
1394 # compare test results with the expected output, we might filter off
1395 # some pattern that is allowed to differ, output test results
1399 # filter off patterns _before_ this comparison!
1400 my ($subject, $firstref, $secondref)=@_;
1402 my $result = compareparts
($firstref, $secondref);
1406 logmsg
"\n $subject FAILED:\n";
1407 logmsg showdiff
($LOGDIR, $firstref, $secondref);
1416 #######################################################################
1417 # display information about curl and the host the test suite runs on
1421 unlink($memdump); # remove this if there was one left
1430 my $curlverout="$LOGDIR/curlverout.log";
1431 my $curlvererr="$LOGDIR/curlvererr.log";
1432 my $versioncmd="$CURL --version 1>$curlverout 2>$curlvererr";
1434 unlink($curlverout);
1435 unlink($curlvererr);
1437 $versretval = runclient
($versioncmd);
1440 open(VERSOUT
, "<$curlverout");
1441 @version = <VERSOUT
>;
1449 $curl =~ s/^(.*)(libcurl.*)/$1/g;
1452 if($curl =~ /mingw32/) {
1453 # This is a windows minw32 build, we need to translate the
1454 # given path to the "actual" windows path.
1461 # example mount output:
1462 # C:\DOCUME~1\Temp on /tmp type user (binmode,noumount)
1463 # c:\ActiveState\perl on /perl type user (binmode)
1464 # C:\msys\1.0\bin on /usr/bin type user (binmode,cygexec,noumount)
1465 # C:\msys\1.0\bin on /bin type user (binmode,cygexec,noumount)
1467 foreach $mount (@m) {
1468 if( $mount =~ /(.*) on ([^ ]*) type /) {
1469 my ($mingw, $real)=($2, $1);
1470 if($pwd =~ /^$mingw/) {
1471 # the path we got from pwd starts with the path
1472 # we found on this line in the mount output
1474 my $len = length($real);
1475 if($len > $matchlen) {
1476 # we remember the match that is the longest
1484 logmsg
"Serious error, can't find our \"real\" path\n";
1487 # now prepend the prefix from the mount command to build
1489 $pwd = "$bestmatch$pwd";
1493 elsif ($curl =~ /win32/) {
1494 # Native Windows builds don't understand the
1495 # output of cygwin's pwd. It will be
1496 # something like /cygdrive/c/<some path>.
1498 # Use the cygpath utility to convert the
1499 # working directory to a Windows friendly
1500 # path. The -m option converts to use drive
1501 # letter:, but it uses / instead \. Forward
1502 # slashes (/) are easier for us. We don't
1503 # have to escape them to get them to curl
1505 chomp($pwd = `cygpath -m $pwd`);
1507 elsif ($libcurl =~ /openssl/i) {
1511 elsif ($libcurl =~ /gnutls/i) {
1515 elsif ($libcurl =~ /nss/i) {
1519 elsif ($libcurl =~ /yassl/i) {
1525 elsif($_ =~ /^Protocols: (.*)/i) {
1526 # these are the protocols compiled in to this libcurl
1527 @protocols = split(' ', $1);
1529 # Generate a "proto-ipv6" version of each protocol to match the
1530 # IPv6 <server> name. This works even if IPv6 support isn't
1531 # compiled in because the <features> test will fail.
1532 push @protocols, map($_ . "-ipv6", @protocols);
1534 # 'none' is used in test cases to mean no server
1535 push @protocols, ('none');
1537 elsif($_ =~ /^Features: (.*)/i) {
1539 if($feat =~ /debug/i) {
1540 # debug is a listed "feature", use that knowledge
1542 # set the NETRC debug env
1543 $ENV{'CURL_DEBUG_NETRC'} = "$LOGDIR/netrc";
1545 if($feat =~ /SSL/i) {
1549 if($feat =~ /Largefile/i) {
1550 # large file support
1553 if($feat =~ /IDN/i) {
1557 if($feat =~ /IPv6/i) {
1560 if($feat =~ /libz/i) {
1563 if($feat =~ /NTLM/i) {
1570 logmsg
"unable to get curl's version, further details are:\n";
1571 logmsg
"issued command: \n";
1572 logmsg
"$versioncmd \n";
1573 if ($versretval == -1) {
1574 logmsg
"command failed with: \n";
1575 logmsg
"$versnoexec \n";
1577 elsif ($versretval & 127) {
1578 logmsg
sprintf("command died with signal %d, and %s coredump.\n",
1579 ($versretval & 127), ($versretval & 128)?
"a":"no");
1582 logmsg
sprintf("command exited with value %d \n", $versretval >> 8);
1584 logmsg
"contents of $curlverout: \n";
1585 displaylogcontent
("$curlverout");
1586 logmsg
"contents of $curlvererr: \n";
1587 displaylogcontent
("$curlvererr");
1588 die "couldn't get curl's version";
1591 if(-r
"../lib/config.h") {
1592 open(CONF
, "<../lib/config.h");
1594 if($_ =~ /^\#define HAVE_GETRLIMIT/) {
1602 # client has ipv6 support
1604 # check if the HTTP server has it!
1605 my @sws = `server/sws --version`;
1606 if($sws[0] =~ /IPv6/) {
1607 # HTTP server has ipv6 support!
1611 # check if the FTP server has it!
1612 @sws = `server/sockfilt --version`;
1613 if($sws[0] =~ /IPv6/) {
1614 # FTP server has ipv6 support!
1619 if(!$curl_debug && $torture) {
1620 die "can't run torture tests since curl was not build with debug";
1623 # curl doesn't list cryptographic support separately, so assume it's
1627 my $hostname=join(' ', runclientoutput
("hostname"));
1628 my $hosttype=join(' ', runclientoutput
("uname -a"));
1630 logmsg
("********* System characteristics ******** \n",
1633 "* Features: $feat\n",
1634 "* Host: $hostname",
1635 "* System: $hosttype");
1637 logmsg
sprintf("* Server SSL: %s\n", $stunnel?
"ON":"OFF");
1638 logmsg
sprintf("* libcurl SSL: %s\n", $ssl_version?
"ON":"OFF");
1639 logmsg
sprintf("* libcurl debug: %s\n", $curl_debug?
"ON":"OFF");
1640 logmsg
sprintf("* valgrind: %s\n", $valgrind?
"ON":"OFF");
1641 logmsg
sprintf("* HTTP IPv6 %s\n", $http_ipv6?
"ON":"OFF");
1642 logmsg
sprintf("* FTP IPv6 %s\n", $ftp_ipv6?
"ON":"OFF");
1644 logmsg
sprintf("* HTTP port: %d\n", $HTTPPORT);
1645 logmsg
sprintf("* FTP port: %d\n", $FTPPORT);
1646 logmsg
sprintf("* FTP port 2: %d\n", $FTP2PORT);
1648 logmsg
sprintf("* FTPS port: %d\n", $FTPSPORT);
1649 logmsg
sprintf("* HTTPS port: %d\n", $HTTPSPORT);
1652 logmsg
sprintf("* HTTP IPv6 port: %d\n", $HTTP6PORT);
1655 logmsg
sprintf("* FTP IPv6 port: %d\n", $FTP6PORT);
1657 logmsg
sprintf("* TFTP port: %d\n", $TFTPPORT);
1659 logmsg
sprintf("* TFTP IPv6 port: %d\n", $TFTP6PORT);
1661 logmsg
sprintf("* SCP/SFTP port: %d\n", $SSHPORT);
1662 logmsg
sprintf("* SOCKS port: %d\n", $SOCKSPORT);
1665 logmsg
sprintf("* SSL library: %s\n", $ssllib);
1668 $has_textaware = ($^O
eq 'MSWin32') || ($^O
eq 'msys');
1670 logmsg
sprintf("* Libtool lib: %s\n", $libtool?
"ON":"OFF");
1671 logmsg
"***************************************** \n";
1674 #######################################################################
1675 # substitute the variable stuff into either a joined up file or
1676 # a command, in either case passed by reference
1680 $$thing =~ s/%HOSTIP/$HOSTIP/g;
1681 $$thing =~ s/%HTTPPORT/$HTTPPORT/g;
1682 $$thing =~ s/%HOST6IP/$HOST6IP/g;
1683 $$thing =~ s/%HTTP6PORT/$HTTP6PORT/g;
1684 $$thing =~ s/%HTTPSPORT/$HTTPSPORT/g;
1685 $$thing =~ s/%FTPPORT/$FTPPORT/g;
1686 $$thing =~ s/%FTP6PORT/$FTP6PORT/g;
1687 $$thing =~ s/%FTP2PORT/$FTP2PORT/g;
1688 $$thing =~ s/%FTPSPORT/$FTPSPORT/g;
1689 $$thing =~ s/%SRCDIR/$srcdir/g;
1690 $$thing =~ s/%PWD/$pwd/g;
1691 $$thing =~ s/%TFTPPORT/$TFTPPORT/g;
1692 $$thing =~ s/%TFTP6PORT/$TFTP6PORT/g;
1693 $$thing =~ s/%SSHPORT/$SSHPORT/g;
1694 $$thing =~ s/%SOCKSPORT/$SOCKSPORT/g;
1695 $$thing =~ s/%CURL/$CURL/g;
1696 $$thing =~ s/%USER/$USER/g;
1697 $$thing =~ s/%CLIENTIP/$CLIENTIP/g;
1698 $$thing =~ s/%CLIENT6IP/$CLIENT6IP/g;
1700 # The purpose of FTPTIME2 and FTPTIME3 is to provide times that can be
1701 # used for time-out tests and that whould work on most hosts as these
1702 # adjust for the startup/check time for this particular host. We needed
1703 # to do this to make the test suite run better on very slow hosts.
1705 my $ftp2 = $ftpchecktime * 2;
1706 my $ftp3 = $ftpchecktime * 3;
1708 $$thing =~ s/%FTPTIME2/$ftp2/g;
1709 $$thing =~ s/%FTPTIME3/$ftp3/g;
1721 #######################################################################
1722 # Run a single specified test case
1726 my ($testnum, $count, $total)=@_;
1733 # load the test case file definition
1734 if(loadtest
("${TESTDIR}/test${testnum}")) {
1736 # this is not a test
1737 logmsg
"RUN: $testnum doesn't look like a test case\n";
1742 @what = getpart
("client", "features");
1749 $feature{$f}=$f; # we require this feature
1756 elsif($f eq "OpenSSL") {
1761 elsif($f eq "GnuTLS") {
1766 elsif($f eq "NSS") {
1771 elsif($f eq "netrc_debug") {
1776 elsif($f eq "large_file") {
1781 elsif($f eq "idn") {
1786 elsif($f eq "ipv6") {
1791 elsif($f eq "libz") {
1796 elsif($f eq "NTLM") {
1801 elsif($f eq "getrlimit") {
1802 if($has_getrlimit) {
1806 elsif($f eq "crypto") {
1811 elsif($f eq "socks") {
1814 # See if this "feature" is in the list of supported protocols
1815 elsif (grep /^$f$/, @protocols) {
1819 $why = "curl lacks $f support";
1824 my @keywords = getpart
("info", "keywords");
1827 for $k (@keywords) {
1829 if ($disabled_keywords{$k}) {
1830 $why = "disabled by keyword";
1831 } elsif ($enabled_keywords{$k}) {
1836 if(!$why && !$match && %enabled_keywords) {
1837 $why = "disabled by missing keyword";
1842 $why = serverfortest
($testnum);
1846 my @precheck = getpart
("client", "precheck");
1847 $cmd = $precheck[0];
1851 my @o = `$cmd 2>/dev/null`;
1856 logmsg
"prechecked $cmd\n" if($verbose);
1860 if($why && !$listonly) {
1861 # there's a problem, count it as "skipped"
1864 $teststat[$testnum]=$why; # store reason for this test case
1867 printf "test %03d SKIPPED: $why\n", $testnum;
1872 logmsg
sprintf("test %03d...", $testnum);
1874 # extract the reply data
1875 my @reply = getpart
("reply", "data");
1876 my @replycheck = getpart
("reply", "datacheck");
1879 # we use this file instead to check the final output against
1881 my %hash = getpartattr
("reply", "datacheck");
1882 if($hash{'nonewline'}) {
1883 # Yes, we must cut off the final newline from the final line
1885 chomp($replycheck[$#replycheck]);
1891 # curl command to run
1892 my @curlcmd= fixarray
( getpart
("client", "command") );
1894 # this is the valid protocol blurb curl should generate
1895 my @protocol= fixarray
( getpart
("verify", "protocol") );
1897 # redirected stdout/stderr to these files
1898 $STDOUT="$LOGDIR/stdout$testnum";
1899 $STDERR="$LOGDIR/stderr$testnum";
1901 # if this section exists, we verify that the stdout contained this:
1902 my @validstdout = fixarray
( getpart
("verify", "stdout") );
1904 # if this section exists, we verify upload
1905 my @upload = getpart
("verify", "upload");
1907 # if this section exists, it might be FTP server instructions:
1908 my @ftpservercmd = getpart
("reply", "servercmd");
1910 my $CURLOUT="$LOGDIR/curl$testnum.out"; # curl output if not stdout
1913 my @testname= getpart
("client", "name");
1916 my $name = $testname[0];
1922 return 0; # look successful
1925 my @codepieces = getpart
("client", "tool");
1929 $tool = $codepieces[0];
1933 # remove server output logfiles
1938 # write the instructions to file
1939 writearray
($FTPDCMD, \
@ftpservercmd);
1942 my (@setenv)= getpart
("client", "setenv");
1947 chomp $s; # cut off the newline
1951 if($s =~ /([^=]*)=(.*)/) {
1952 my ($var, $content)=($1, $2);
1953 $ENV{$var}=$content;
1954 # remember which, so that we can clear them afterwards!
1959 # get the command line options to use
1961 ($cmd, @blaha)= getpart
("client", "command");
1963 # make some nice replace operations
1964 $cmd =~ s/\n//g; # no newlines please
1966 # substitute variables in the command line
1973 # create a (possibly-empty) file before starting the test
1974 my @inputfile=getpart
("client", "file");
1975 my %fileattr = getpartattr
("client", "file");
1976 my $filename=$fileattr{'name'};
1977 if(@inputfile || $filename) {
1979 logmsg
"ERROR: section client=>file has no name attribute\n";
1982 my $fileContent = join('', @inputfile);
1983 subVariables \
$fileContent;
1984 # logmsg "DEBUG: writing file " . $filename . "\n";
1985 open(OUTFILE
, ">$filename");
1986 binmode OUTFILE
; # for crapage systems, use binary
1987 print OUTFILE
$fileContent;
1991 my %cmdhash = getpartattr
("client", "command");
1995 if($cmdhash{'option'} !~ /no-output/) {
1996 #We may slap on --output!
1997 if (!@validstdout) {
1998 $out=" --output $CURLOUT ";
2002 my $serverlogslocktimeout = $defserverlogslocktimeout;
2003 if($cmdhash{'timeout'}) {
2004 # test is allowed to override default server logs lock timeout
2005 if($cmdhash{'timeout'} =~ /(\d+)/) {
2006 $serverlogslocktimeout = $1 if($1 >= 0);
2010 my $postcommanddelay = $defpostcommanddelay;
2011 if($cmdhash{'delay'}) {
2012 # test is allowed to specify a delay after command is executed
2013 if($cmdhash{'delay'} =~ /(\d+)/) {
2014 $postcommanddelay = $1 if($1 > 0);
2020 # run curl, add --verbose for debug information output
2021 $cmdargs ="$out --include --verbose --trace-time $cmd";
2024 $cmdargs = " $cmd"; # $cmd is the command line for the test file
2025 $CURLOUT = $STDOUT; # sends received data to stdout
2028 my @stdintest = getpart
("client", "stdin");
2031 my $stdinfile="$LOGDIR/stdin-for-$testnum";
2032 writearray
($stdinfile, \
@stdintest);
2034 $cmdargs .= " <$stdinfile";
2042 $CMDLINE="$LIBDIR/$tool";
2044 print "The tool set in the test case for this: '$tool' does not exist\n";
2050 my $usevalgrind = $valgrind && ((getpart
("verify", "valgrind"))[0] !~ /disable/);
2052 $CMDLINE = "$valgrind ".$valgrind_tool."--leak-check=yes --num-callers=16 ${valgrind_logfile}=$LOGDIR/valgrind$testnum $CMDLINE";
2055 $CMDLINE .= "$cmdargs >>$STDOUT 2>>$STDERR";
2058 logmsg
"$CMDLINE\n";
2061 print CMDLOG
"$CMDLINE\n";
2068 # Apr 2007: precommand isn't being used and could be removed
2069 my @precommand= getpart
("client", "precommand");
2070 if($precommand[0]) {
2071 # this is pure perl to eval!
2072 my $code = join("", @precommand);
2075 logmsg
"perl: $code\n";
2076 logmsg
"precommand: $@";
2077 stopservers
($verbose);
2083 open(GDBCMD
, ">$LOGDIR/gdbcmd");
2084 print GDBCMD
"set args $cmdargs\n";
2085 print GDBCMD
"show args\n";
2088 # run the command line we built
2090 $cmdres = torture
($CMDLINE,
2091 "$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd");
2094 runclient
("$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd");
2095 $cmdres=0; # makes it always continue after a debugged run
2098 $cmdres = runclient
("$CMDLINE");
2099 my $signal_num = $cmdres & 127;
2100 $dumped_core = $cmdres & 128;
2102 if(!$anyway && ($signal_num || $dumped_core)) {
2111 # there's core file present now!
2117 logmsg
"core dumped\n";
2119 logmsg
"running gdb for post-mortem analysis:\n";
2120 open(GDBCMD
, ">$LOGDIR/gdbcmd2");
2121 print GDBCMD
"bt\n";
2123 runclient
("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch $DBGCURL core ");
2124 # unlink("$LOGDIR/gdbcmd2");
2128 # If a server logs advisor read lock file exists, it is an indication
2129 # that the server has not yet finished writing out all its log files,
2130 # including server request log files used for protocol verification.
2131 # So, if the lock file exists the script waits here a certain amount
2132 # of time until the server removes it, or the given time expires.
2134 if($serverlogslocktimeout) {
2135 my $lockretry = $serverlogslocktimeout * 4;
2136 while((-f
$SERVERLOGS_LOCK) && $lockretry--) {
2137 select(undef, undef, undef, 0.25);
2139 if(($lockretry < 0) &&
2140 ($serverlogslocktimeout >= $defserverlogslocktimeout)) {
2141 logmsg
"Warning: server logs lock timeout ",
2142 "($serverlogslocktimeout seconds) expired\n";
2146 # Test harness ssh server does not have this synchronization mechanism,
2147 # this implies that some ssh server based tests might need a small delay
2148 # once that the client command has run to avoid false test failures.
2150 sleep($postcommanddelay) if($postcommanddelay);
2152 # run the postcheck command
2153 my @postcheck= getpart
("client", "postcheck");
2154 $cmd = $postcheck[0];
2158 logmsg
"postcheck $cmd\n" if($verbose);
2159 my $rc = runclient
("$cmd");
2160 # Must run the postcheck command in torture mode in order
2161 # to clean up, but the result can't be relied upon.
2162 if($rc != 0 && !$torture) {
2163 logmsg
" postcheck FAILED\n";
2168 # remove the special FTP command file after each test!
2173 $ENV{$e}=""; # clean up
2176 # Skip all the verification on torture tests
2178 if(!$cmdres && !$keepoutfiles) {
2184 my @err = getpart
("verify", "errorcode");
2185 my $errorcode = $err[0] || "0";
2189 # verify redirected stdout
2190 my @actual = loadarray
($STDOUT);
2192 # variable-replace in the stdout we have from the test case file
2193 @validstdout = fixarray
(@validstdout);
2195 # get all attributes
2196 my %hash = getpartattr
("verify", "stdout");
2198 # get the mode attribute
2199 my $filemode=$hash{'mode'};
2200 if(($filemode eq "text") && $has_textaware) {
2201 # text mode when running on windows: fix line endings
2202 map s/\r\n/\n/g, @actual;
2205 if($hash{'nonewline'}) {
2206 # Yes, we must cut off the final newline from the final line
2207 # of the protocol data
2208 chomp($validstdout[$#validstdout]);
2211 $res = compare
("stdout", \
@actual, \
@validstdout);
2218 $ok .= "-"; # stdout not checked
2221 my %replyattr = getpartattr
("reply", "data");
2222 if(!$replyattr{'nocheck'} && (@reply || $replyattr{'sendzero'})) {
2223 # verify the received data
2224 my @out = loadarray
($CURLOUT);
2225 my %hash = getpartattr
("reply", "data");
2226 # get the mode attribute
2227 my $filemode=$hash{'mode'};
2228 if(($filemode eq "text") && $has_textaware) {
2229 # text mode when running on windows: fix line endings
2230 map s/\r\n/\n/g, @out;
2233 $res = compare
("data", \
@out, \
@reply);
2240 $ok .= "-"; # data not checked
2244 # verify uploaded data
2245 my @out = loadarray
("$LOGDIR/upload.$testnum");
2246 $res = compare
("upload", \
@out, \
@upload);
2253 $ok .= "-"; # upload not checked
2257 # Verify the sent request
2258 my @out = loadarray
($SERVERIN);
2260 # what to cut off from the live protocol sent by curl
2261 my @strip = getpart
("verify", "strip");
2263 my @protstrip=@protocol;
2265 # check if there's any attributes on the verify/protocol section
2266 my %hash = getpartattr
("verify", "protocol");
2268 if($hash{'nonewline'}) {
2269 # Yes, we must cut off the final newline from the final line
2270 # of the protocol data
2271 chomp($protstrip[$#protstrip]);
2275 # strip off all lines that match the patterns from both arrays
2277 @out = striparray
( $_, \
@out);
2278 @protstrip= striparray
( $_, \
@protstrip);
2281 # what parts to cut off from the protocol
2282 my @strippart = getpart
("verify", "strippart");
2284 for $strip (@strippart) {
2291 $res = compare
("protocol", \
@out, \
@protstrip);
2300 $ok .= "-"; # protocol not checked
2303 my @outfile=getpart
("verify", "file");
2305 # we're supposed to verify a dynamically generated file!
2306 my %hash = getpartattr
("verify", "file");
2308 my $filename=$hash{'name'};
2310 logmsg
"ERROR: section verify=>file has no name attribute\n";
2311 stopservers
($verbose);
2314 my @generated=loadarray
($filename);
2316 # what parts to cut off from the file
2317 my @stripfile = getpart
("verify", "stripfile");
2319 my $filemode=$hash{'mode'};
2320 if(($filemode eq "text") && $has_textaware) {
2321 # text mode when running on windows means adding an extra
2323 push @stripfile, "s/\r\n/\n/";
2327 for $strip (@stripfile) {
2334 @outfile = fixarray
(@outfile);
2336 $res = compare
("output", \
@generated, \
@outfile);
2344 $ok .= "-"; # output not checked
2347 # accept multiple comma-separated error codes
2348 my @splerr = split(/ *, */, $errorcode);
2350 foreach $e (@splerr) {
2363 printf "\ncurl returned $cmdres, %d was expected\n", $errorcode;
2365 logmsg
" exit FAILED\n";
2369 @what = getpart
("client", "killserver");
2373 if($serv =~ /^ftp(\d*)(-ipv6|)/) {
2374 my ($id, $ext) = ($1, $2);
2375 #print STDERR "SERV $serv $id $ext\n";
2376 ftpkillslave
($id, $ext, $verbose);
2379 stopserver
($run{$serv}); # the pid file is in the hash table
2380 $run{$serv}=0; # clear pid
2383 logmsg
"RUN: The $serv server is not running\n";
2389 logmsg
"\n** ALERT! memory debugging with no output file?\n";
2392 my @memdata=`$memanalyze $memdump`;
2396 # well it could be other memory problems as well, but
2397 # we call it leak for short here
2402 logmsg
"\n** MEMORY FAILURE\n";
2412 $ok .= "-"; # memory not checked
2416 # this is the valid protocol blurb curl should generate
2419 opendir(DIR
, "log") ||
2420 return 0; # can't open log dir
2421 my @files = readdir(DIR
);
2425 foreach $f (@files) {
2426 if($f =~ /^valgrind$testnum\.pid/) {
2431 my $src=$ENV{'srcdir'};
2435 my @e = valgrindparse
($src, $feature{'SSL'}, "$LOGDIR/$l");
2437 logmsg
" valgrind ERROR ";
2445 logmsg
" valgrind SKIPPED\n";
2447 $ok .= "-"; # skipped
2451 $ok .= "-"; # valgrind not checked
2454 logmsg
"$ok " if(!$short);
2456 my $sofar= time()-$start;
2457 my $esttotal = $sofar/$count * $total;
2458 my $estleft = $esttotal - $sofar;
2459 my $left=sprintf("remaining: %02d:%02d",
2462 printf "OK (%-3d out of %-3d, %s)\n", $count, $total, $left;
2464 # the test succeeded, remove all log files
2465 if(!$keepoutfiles) {
2469 unlink($FTPDCMD); # remove the instructions for this test
2474 #######################################################################
2475 # Stop all running test servers
2480 my $pids=$run{$server};
2484 foreach $pid (split(" ", $pids)) {
2486 # no need to kill same pid twice!
2487 logmsg
sprintf("* kill pid for %s => %d\n",
2488 $server, $pid) if($verbose);
2493 delete $run{$server};
2495 ftpkillslaves
($verbose);
2498 #######################################################################
2499 # startservers() starts all the named servers
2501 # Returns: string with error reason or blank for success
2508 $what =~ s/[^a-z0-9-]//g;
2509 if($what eq "ftp") {
2511 ($pid, $pid2) = runftpserver
("", $verbose);
2513 return "failed starting FTP server";
2515 printf ("* pid ftp => %d %d\n", $pid, $pid2) if($verbose);
2516 $run{'ftp'}="$pid $pid2";
2519 elsif($what eq "ftp2") {
2521 ($pid, $pid2) = runftpserver
("2", $verbose);
2523 return "failed starting FTP2 server";
2525 printf ("* pid ftp2 => %d %d\n", $pid, $pid2) if($verbose);
2526 $run{'ftp2'}="$pid $pid2";
2529 elsif($what eq "ftp-ipv6") {
2530 if(!$run{'ftp-ipv6'}) {
2531 ($pid, $pid2) = runftpserver
("", $verbose, "ipv6");
2533 return "failed starting FTP-IPv6 server";
2535 logmsg
sprintf("* pid ftp-ipv6 => %d %d\n", $pid,
2536 $pid2) if($verbose);
2537 $run{'ftp-ipv6'}="$pid $pid2";
2540 elsif($what eq "http") {
2542 ($pid, $pid2) = runhttpserver
($verbose);
2544 return "failed starting HTTP server";
2546 printf ("* pid http => %d %d\n", $pid, $pid2) if($verbose);
2547 $run{'http'}="$pid $pid2";
2550 elsif($what eq "http-ipv6") {
2551 if(!$run{'http-ipv6'}) {
2552 ($pid, $pid2) = runhttpserver
($verbose, "IPv6");
2554 return "failed starting HTTP-IPv6 server";
2556 logmsg
sprintf("* pid http-ipv6 => %d %d\n", $pid, $pid2)
2558 $run{'http-ipv6'}="$pid $pid2";
2561 elsif($what eq "ftps") {
2563 # we can't run ftps tests without stunnel
2564 return "no stunnel";
2567 # we can't run ftps tests if libcurl is SSL-less
2568 return "curl lacks SSL support";
2572 ($pid, $pid2) = runftpserver
("", $verbose);
2574 return "failed starting FTP server";
2576 printf ("* pid ftp => %d %d\n", $pid, $pid2) if($verbose);
2577 $run{'ftp'}="$pid $pid2";
2580 ($pid, $pid2) = runftpsserver
($verbose);
2582 return "failed starting FTPS server (stunnel)";
2584 logmsg
sprintf("* pid ftps => %d %d\n", $pid, $pid2)
2586 $run{'ftps'}="$pid $pid2";
2589 elsif($what eq "file") {
2590 # we support it but have no server!
2592 elsif($what eq "https") {
2594 # we can't run ftps tests without stunnel
2595 return "no stunnel";
2598 # we can't run ftps tests if libcurl is SSL-less
2599 return "curl lacks SSL support";
2603 ($pid, $pid2) = runhttpserver
($verbose);
2605 return "failed starting HTTP server";
2607 printf ("* pid http => %d %d\n", $pid, $pid2) if($verbose);
2608 $run{'http'}="$pid $pid2";
2610 if(!$run{'https'}) {
2611 ($pid, $pid2) = runhttpsserver
($verbose);
2613 return "failed starting HTTPS server (stunnel)";
2615 logmsg
sprintf("* pid https => %d %d\n", $pid, $pid2)
2617 $run{'https'}="$pid $pid2";
2620 elsif($what eq "tftp") {
2622 ($pid, $pid2) = runtftpserver
("", $verbose);
2624 return "failed starting TFTP server";
2626 printf ("* pid tftp => %d %d\n", $pid, $pid2) if($verbose);
2627 $run{'tftp'}="$pid $pid2";
2630 elsif($what eq "tftp-ipv6") {
2631 if(!$run{'tftp-ipv6'}) {
2632 ($pid, $pid2) = runtftpserver
("", $verbose, "IPv6");
2634 return "failed starting TFTP-IPv6 server";
2636 printf("* pid tftp-ipv6 => %d %d\n", $pid, $pid2) if($verbose);
2637 $run{'tftp-ipv6'}="$pid $pid2";
2640 elsif($what eq "sftp" || $what eq "scp" || $what eq "socks4" || $what eq "socks5" ) {
2642 ($pid, $pid2) = runsshserver
("", $verbose);
2644 return "failed starting SSH server";
2646 printf ("* pid ssh => %d %d\n", $pid, $pid2) if($verbose);
2647 $run{'ssh'}="$pid $pid2";
2649 if($what eq "socks4" || $what eq "socks5") {
2650 if(!$run{'socks'}) {
2651 ($pid, $pid2) = runsocksserver
("", $verbose);
2653 return "failed starting socks server";
2655 printf ("* pid socks => %d %d\n", $pid, $pid2) if($verbose);
2656 $run{'socks'}="$pid $pid2";
2659 if($what eq "socks5") {
2661 # Not an OpenSSH or SunSSH ssh daemon
2662 logmsg
"Not OpenSSH or SunSSH; socks5 tests need at least OpenSSH 3.7\n";
2663 return "failed starting socks5 server";
2665 elsif(($sshdid =~ /OpenSSH/) && ($sshdvernum < 370)) {
2666 # Need OpenSSH 3.7 for socks5 - http://www.openssh.com/txt/release-3.7
2667 logmsg
"$sshdverstr insufficient; socks5 tests need at least OpenSSH 3.7\n";
2668 return "failed starting socks5 server";
2670 elsif(($sshdid =~ /SunSSH/) && ($sshdvernum < 100)) {
2671 # Need SunSSH 1.0 for socks5
2672 logmsg
"$sshdverstr insufficient; socks5 tests need at least SunSSH 1.0\n";
2673 return "failed starting socks5 server";
2677 elsif($what eq "none") {
2678 logmsg
"* starts no server\n" if ($verbose);
2681 warn "we don't support a server for $what";
2682 return "no server for $what";
2688 ##############################################################################
2689 # This function makes sure the right set of server is running for the
2690 # specified test case. This is a useful design when we run single tests as not
2691 # all servers need to run then!
2693 # Returns: a string, blank if everything is fine or a reason why it failed
2699 my @what = getpart
("client", "server");
2702 warn "Test case $testnum has no server(s) specified";
2703 return "no server specified";
2709 if (! grep /^$proto$/, @protocols) {
2710 if (substr($proto,0,5) ne "socks") {
2711 return "curl lacks $proto support";
2716 return &startservers
(@what);
2719 #######################################################################
2720 # Check options to this test program
2728 if ($ARGV[0] eq "-v") {
2732 elsif($ARGV[0] =~ /^-b(.*)/) {
2734 if($portno =~ s/(\d+)$//) {
2738 elsif ($ARGV[0] eq "-c") {
2739 # use this path to curl instead of default
2740 $DBGCURL=$CURL=$ARGV[1];
2743 elsif ($ARGV[0] eq "-d") {
2744 # have the servers display protocol output
2747 elsif ($ARGV[0] eq "-f") {
2748 # run fork-servers, which makes the server fork for all new
2749 # connections This is NOT what you wanna do without knowing exactly
2753 elsif ($ARGV[0] eq "-g") {
2754 # run this test with gdb
2757 elsif($ARGV[0] eq "-s") {
2761 elsif($ARGV[0] eq "-n") {
2765 elsif($ARGV[0] =~ /^-t(.*)/) {
2770 if($xtra =~ s/(\d+)$//) {
2773 # we undef valgrind to make this fly in comparison
2776 elsif($ARGV[0] eq "-a") {
2777 # continue anyway, even if a test fail
2780 elsif($ARGV[0] eq "-p") {
2783 elsif($ARGV[0] eq "-l") {
2784 # lists the test case names only
2787 elsif($ARGV[0] eq "-k") {
2788 # keep stdout and stderr files after tests
2791 elsif($ARGV[0] eq "-h") {
2794 Usage: runtests.pl [options] [test selection(s)]
2795 -a continue even if a test fails
2796 -bN use base port number N for test servers (default $base)
2797 -c path use this curl executable
2798 -d display server debug info
2799 -g run the test case with gdb
2801 -k keep stdout and stderr files present after tests
2802 -l list all test case names/descriptions
2804 -p print log file contents when a test fails
2806 -t[N] torture (simulate memory alloc failures); N means fail Nth alloc
2808 [num] like "5 6 9" or " 5 to 22 " to run those tests only
2809 [!num] like "!5 !6 !9" to disable those tests
2810 [keyword] like "IPv6" to select only tests containing the key word
2811 [!keyword] like "!cookies" to disable any tests containing the key word
2816 elsif($ARGV[0] =~ /^(\d+)/) {
2819 for($fromnum .. $number) {
2828 elsif($ARGV[0] =~ /^to$/i) {
2829 $fromnum = $number+1;
2831 elsif($ARGV[0] =~ /^!(\d+)/) {
2835 elsif($ARGV[0] =~ /^!(.+)/) {
2836 $disabled_keywords{$1}=$1;
2838 elsif($ARGV[0] =~ /^([-[{a-zA-Z].*)/) {
2839 $enabled_keywords{$1}=$1;
2842 print "Unknown option: $ARGV[0]\n";
2848 if($testthis[0] ne "") {
2849 $TESTCASES=join(" ", @testthis);
2853 # we have found valgrind on the host, use it
2855 # verify that we can invoke it fine
2856 my $code = runclient
("valgrind >/dev/null 2>&1");
2858 if(($code>>8) != 1) {
2859 #logmsg "Valgrind failure, disable it\n";
2863 # since valgrind 2.1.x, '--tool' option is mandatory
2864 # use it, if it is supported by the version installed on the system
2865 runclient
("valgrind --help 2>&1 | grep -- --tool > /dev/null 2>&1");
2867 $valgrind_tool="--tool=memcheck ";
2872 # A shell script. This is typically when built with libtool,
2873 $valgrind="../libtool --mode=execute $valgrind";
2877 # valgrind 3 renamed the --logfile option to --log-file!!!
2878 my $ver=join(' ', runclientoutput
("valgrind --version"));
2879 # cut off all but digits and dots
2880 $ver =~ s/[^0-9.]//g;
2883 $valgrind_logfile="--log-file";
2889 # open the executable curl and read the first 4 bytes of it
2890 open(CHECK, "<$CURL");
2892 sysread CHECK, $c, 4;
2895 # A shell script. This is typically when built with libtool,
2897 $gdb = "libtool --mode=execute gdb";
2901 $HTTPPORT = $base + 0; # HTTP server port
2902 $HTTPSPORT = $base + 1; # HTTPS server port
2903 $FTPPORT = $base + 2; # FTP server port
2904 $FTPSPORT = $base + 3; # FTPS server port
2905 $HTTP6PORT = $base + 4; # HTTP IPv6 server port (different IP protocol
2906 # but we follow the same port scheme anyway)
2907 $FTP2PORT = $base + 5; # FTP server 2 port
2908 $FTP6PORT = $base + 6; # FTP IPv6 port
2909 $TFTPPORT = $base + 7; # TFTP (UDP) port
2910 $TFTP6PORT = $base + 8; # TFTP IPv6 (UDP) port
2911 $SSHPORT = $base + 9; # SSH (SCP/SFTP) port
2912 $SOCKSPORT = $base + 10; # SOCKS port
2914 #######################################################################
2915 # clear and create logging directory:
2919 mkdir($LOGDIR, 0777);
2921 #######################################################################
2922 # Output curl version and host info being tested
2929 #######################################################################
2930 # If 'all' tests are requested, find out all test numbers
2933 if ( $TESTCASES eq "all") {
2934 # Get all commands and find out their test numbers
2935 opendir(DIR
, $TESTDIR) || die "can't opendir $TESTDIR: $!";
2936 my @cmds = grep { /^test([0-9]+)$/ && -f
"$TESTDIR/$_" } readdir(DIR
);
2939 open(D
, "<$TESTDIR/DISABLED");
2946 $disabled{$1}=$1; # disable this test number
2951 $TESTCASES=""; # start with no test cases
2953 # cut off everything but the digits
2955 $_ =~ s/[a-z\/\.]*//g
;
2957 # sort the numbers from low to high
2958 foreach my $n (sort { $a <=> $b } @cmds) {
2960 # skip disabled test cases
2961 my $why = "configured as DISABLED";
2964 $teststat[$n]=$why; # store reason for this test case
2967 $TESTCASES .= " $n";
2971 #######################################################################
2972 # Start the command line log
2974 open(CMDLOG
, ">$CURLLOG") ||
2975 logmsg
"can't log command lines to $CURLLOG\n";
2977 #######################################################################
2979 # Display the contents of the given file. Line endings are canonicalized
2980 # and excessively long files are elided
2981 sub displaylogcontent
{
2983 if(open(SINGLE
, "<$file")) {
2987 while(my $string = <SINGLE
>) {
2988 $string =~ s/\r\n/\n/g;
2989 $string =~ s/[\r\f\032]/\n/g;
2990 $string .= "\n" unless ($string =~ /\n$/);
2992 for my $line (split("\n", $string)) {
2993 $line =~ s/\s*\!$//;
2995 push @tail, " $line\n";
3000 $truncate = $linecount > 1000;
3004 logmsg
"=== File too long: lines here were removed\n";
3005 # This won't work properly if time stamps are enabled in logmsg
3006 logmsg
join('',@tail[$#tail-200..$#tail]);
3014 opendir(DIR
, "$LOGDIR") ||
3015 die "can't open dir: $!";
3016 my @logs = readdir(DIR
);
3019 logmsg
"== Contents of files in the $LOGDIR/ dir after test $testnum\n";
3020 foreach my $log (sort @logs) {
3021 if($log =~ /\.(\.|)$/) {
3022 next; # skip "." and ".."
3024 if($log =~ /^\.nfs/) {
3027 if(($log eq "memdump") || ($log eq "core")) {
3028 next; # skip "memdump" and "core"
3030 if((-d
"$LOGDIR/$log") || (! -s
"$LOGDIR/$log")) {
3031 next; # skip directory and empty files
3033 if(($log =~ /^stdout\d+/) && ($log !~ /^stdout$testnum/)) {
3034 next; # skip stdoutNnn of other tests
3036 if(($log =~ /^stderr\d+/) && ($log !~ /^stderr$testnum/)) {
3037 next; # skip stderrNnn of other tests
3039 if(($log =~ /^upload\d+/) && ($log !~ /^upload$testnum/)) {
3040 next; # skip uploadNnn of other tests
3042 if(($log =~ /^curl\d+\.out/) && ($log !~ /^curl$testnum\.out/)) {
3043 next; # skip curlNnn.out of other tests
3045 if(($log =~ /^test\d+\.txt/) && ($log !~ /^test$testnum\.txt/)) {
3046 next; # skip testNnn.txt of other tests
3048 if(($log =~ /^file\d+\.txt/) && ($log !~ /^file$testnum\.txt/)) {
3049 next; # skip fileNnn.txt of other tests
3051 if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum/)) {
3052 next; # skip valgrindNnn of other tests
3054 logmsg
"=== Start of file $log\n";
3055 displaylogcontent
("$LOGDIR/$log");
3056 logmsg
"=== End of file $log\n";
3060 #######################################################################
3061 # The main test-loop
3069 my @at = split(" ", $TESTCASES);
3074 foreach $testnum (@at) {
3076 $lasttest = $testnum if($testnum > $lasttest);
3079 my $error = singletest
($testnum, $count, scalar(@at));
3081 # not a test we can run
3085 $total++; # number of tests we've run
3088 $failed.= "$testnum ";
3090 # display all files in log/ in a nice way
3091 displaylogs
($testnum);
3094 # a test failed, abort
3095 logmsg
"\n - abort tests\n";
3100 $ok++; # successful test counter
3103 # loop for next test
3106 #######################################################################
3111 # Tests done, stop the servers
3112 stopservers
($verbose);
3114 unlink($SOCKSPIDFILE);
3116 my $all = $total + $skipped;
3119 logmsg
sprintf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
3123 logmsg
"TESTFAIL: These test cases failed: $failed\n";
3127 logmsg
"TESTFAIL: No tests were performed\n";
3131 my $sofar = time()-$start;
3132 logmsg
"TESTDONE: $all tests were considered during $sofar seconds.\n";
3137 logmsg
"TESTINFO: $skipped tests were skipped due to these restraints:\n";
3139 for(keys %skipped) {
3141 printf "TESTINFO: \"%s\" %d times (", $r, $skipped{$_};
3143 # now show all test case numbers that had this reason for being
3146 for(0 .. scalar @teststat) {
3148 if($teststat[$_] eq $r) {
3158 if($total && ($ok != $total)) {