diff options
author | nikita <nikita@n0.is> | 2020-04-30 14:57:43 +0200 |
---|---|---|
committer | nikita <nikita@n0.is> | 2020-04-30 14:57:43 +0200 |
commit | e78a29c1d7e4c0d9d5d2400f8935fe6c6db9852e (patch) | |
tree | fcebec99976dae264a75fccabd555af2ac77b4ad /tests/runtests.pl | |
parent | 55ddc65827f8424ef1c6fe592da07608237cf2ae (diff) | |
parent | 53cdc2c963e33bc0cc1a51ad2df79396202e07f8 (diff) | |
download | gnurl-e78a29c1d7e4c0d9d5d2400f8935fe6c6db9852e.tar.gz gnurl-e78a29c1d7e4c0d9d5d2400f8935fe6c6db9852e.tar.bz2 gnurl-e78a29c1d7e4c0d9d5d2400f8935fe6c6db9852e.zip |
Merge tag 'curl-7_70_0'
7.70.0
Diffstat (limited to 'tests/runtests.pl')
-rwxr-xr-x | tests/runtests.pl | 689 |
1 files changed, 372 insertions, 317 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl index 47c3931af..f37e157f4 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -78,6 +78,7 @@ use serverhelp qw( servername_str servername_canon server_pidfilename + server_portfilename server_logfilename ); @@ -123,38 +124,42 @@ my $base = 8990; # base port number my $minport; # minimum used port number my $maxport; # maximum used port number -my $HTTPPORT; # HTTP server port -my $HTTP6PORT; # HTTP IPv6 server port -my $HTTPSPORT; # HTTPS (stunnel) server port -my $FTPPORT; # FTP server port -my $FTP2PORT; # FTP server 2 port -my $FTPSPORT; # FTPS (stunnel) server port -my $FTP6PORT; # FTP IPv6 server port -my $TFTPPORT; # TFTP -my $TFTP6PORT; # TFTP -my $SSHPORT; # SCP/SFTP -my $SOCKSPORT; # SOCKS4/5 port -my $POP3PORT; # POP3 -my $POP36PORT; # POP3 IPv6 server port -my $IMAPPORT; # IMAP -my $IMAP6PORT; # IMAP IPv6 server port -my $SMTPPORT; # SMTP -my $SMTP6PORT; # SMTP IPv6 server port -my $RTSPPORT; # RTSP -my $RTSP6PORT; # RTSP IPv6 server port -my $GOPHERPORT; # Gopher -my $GOPHER6PORT; # Gopher IPv6 server port -my $HTTPTLSPORT; # HTTP TLS (non-stunnel) server port -my $HTTPTLS6PORT; # HTTP TLS (non-stunnel) IPv6 server port -my $HTTPPROXYPORT; # HTTP proxy port, when using CONNECT +my $noport="[not running]"; + +my $NOLISTENPORT=47; # port number we use for a local non-listening service +my $MQTTPORT=$noport; # MQTT server port +my $HTTPPORT=$noport; # HTTP server port +my $HTTP6PORT=$noport; # HTTP IPv6 server port +my $HTTPSPORT=$noport; # HTTPS (stunnel) server port +my $FTPPORT=$noport; # FTP server port +my $FTP2PORT=$noport; # FTP server 2 port +my $FTPSPORT=$noport; # FTPS (stunnel) server port +my $FTP6PORT=$noport; # FTP IPv6 server port +my $TFTPPORT=$noport; # TFTP +my $TFTP6PORT=$noport; # TFTP +my $SSHPORT=$noport; # SCP/SFTP +my $SOCKSPORT=$noport; # SOCKS4/5 port +my $POP3PORT=$noport; # POP3 +my $POP36PORT=$noport; # POP3 IPv6 server port +my $IMAPPORT=$noport; # IMAP +my $IMAP6PORT=$noport; # IMAP IPv6 server port +my $SMTPPORT=$noport; # SMTP +my $SMTP6PORT=$noport; # SMTP IPv6 server port +my $RTSPPORT=$noport; # RTSP +my $RTSP6PORT=$noport; # RTSP IPv6 server port +my $GOPHERPORT=$noport; # Gopher +my $GOPHER6PORT=$noport; # Gopher IPv6 server port +my $HTTPTLSPORT=$noport; # HTTP TLS (non-stunnel) server port +my $HTTPTLS6PORT=$noport; # HTTP TLS (non-stunnel) IPv6 server port +my $HTTPPROXYPORT=$noport; # HTTP proxy port, when using CONNECT +my $HTTP2PORT=$noport; # HTTP/2 server port +my $DICTPORT=$noport; # DICT server port +my $SMBPORT=$noport; # SMB server port +my $SMBSPORT=$noport; # SMBS server port +my $NEGTELNETPORT=$noport; # TELNET server port with negotiation my $HTTPUNIXPATH; # HTTP server Unix domain socket path -my $HTTP2PORT; # HTTP/2 server port -my $DICTPORT; # DICT server port -my $SMBPORT; # SMB server port -my $SMBSPORT; # SMBS server port -my $NEGTELNETPORT; # TELNET server port with negotiation -my $SSHSRVMD5; # MD5 of ssh server public key +my $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key my $srcdir = $ENV{'srcdir'} || '.'; my $CURL="../src/gnurl".exe_ext('TOOL'); # what curl executable to run on the tests @@ -171,7 +176,7 @@ my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server my $SERVER2IN="$LOGDIR/server2.input"; # what curl sent the second server my $PROXYIN="$LOGDIR/proxy.input"; # what curl sent the proxy my $CURLLOG="commands.log"; # all command lines run -my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here +my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy server instructions here my $SERVERLOGS_LOCK="$LOGDIR/serverlogs.lock"; # server logs advisor read lock my $CURLCONFIG="../gnurl-config"; # curl-config from current build @@ -249,6 +254,7 @@ my $has_ldpreload; # set if curl is built for systems supporting LD_PRELOAD my $has_multissl; # set if curl is build with MultiSSL support my $has_manual; # set if curl is built with built-in manual my $has_win32; # set if curl is built for Windows +my $has_mingw; # set if curl is built with MinGW (as opposed to MinGW-w64) # this version is decided by the particular nghttp2 library that is being used my $h2cver = "h2c"; @@ -272,7 +278,6 @@ my $resolver; # name of the resolver backend (for human presentation) my $has_textaware; # set if running on a system that has a text mode concept # on files. Windows for example - my @protocols; # array of lowercase supported protocol servers my $skipped=0; # number of tests skipped; reported in main loop @@ -326,6 +331,7 @@ my $run_event_based; # run curl with --test-event to test the event API my %run; # running server my %doesntrun; # servers that don't work, identified by pidfile my %serverpidfile;# all server pid file names, identified by server id +my %serverportfile;# all server port file names, identified by server id my %runcert; # cert file currently in use by an ssl running server # torture test variables @@ -399,7 +405,8 @@ delete $ENV{'SSL_CERT_PATH'} if($ENV{'SSL_CERT_PATH'}); delete $ENV{'CURL_CA_BUNDLE'} if($ENV{'CURL_CA_BUNDLE'}); ####################################################################### -# Load serverpidfile hash with pidfile names for all possible servers. +# Load serverpidfile and serverportfile hashes with file names for all +# possible servers. # sub init_serverpidfile_hash { for my $proto (('ftp', 'http', 'imap', 'pop3', 'smtp', 'http/2')) { @@ -409,17 +416,21 @@ sub init_serverpidfile_hash { my $serv = servername_id("$proto$ssl", $ipvnum, $idnum); my $pidf = server_pidfilename("$proto$ssl", $ipvnum, $idnum); $serverpidfile{$serv} = $pidf; + my $portf = server_portfilename("$proto$ssl", $ipvnum, $idnum); + $serverportfile{$serv} = $portf; } } } } for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'gopher', 'httptls', - 'dict', 'smb', 'smbs', 'telnet')) { + 'dict', 'smb', 'smbs', 'telnet', 'mqtt')) { for my $ipvnum ((4, 6)) { for my $idnum ((1, 2)) { my $serv = servername_id($proto, $ipvnum, $idnum); my $pidf = server_pidfilename($proto, $ipvnum, $idnum); $serverpidfile{$serv} = $pidf; + my $portf = server_portfilename($proto, $ipvnum, $idnum); + $serverportfile{$serv} = $portf; } } } @@ -428,6 +439,8 @@ sub init_serverpidfile_hash { my $serv = servername_id("$proto$ssl", "unix", 1); my $pidf = server_pidfilename("$proto$ssl", "unix", 1); $serverpidfile{$serv} = $pidf; + my $portf = server_portfilename("$proto$ssl", "unix", 1); + $serverportfile{$serv} = $portf; } } } @@ -441,7 +454,7 @@ sub checkdied { if((not defined $pid) || $pid <= 0) { return 0; } - my $rc = waitpid($pid, &WNOHANG); + my $rc = pidwait($pid, &WNOHANG); return ($rc == $pid)?1:0; } @@ -750,6 +763,7 @@ sub torture { # sub stopserver { my ($server, $pidlist) = @_; + # # kill sockfilter processes for pingpong relative server # @@ -779,6 +793,12 @@ sub stopserver { # given a ssh server, also kill socks piggybacking one push @killservers, "socks${2}"; } + if($server eq "http") { + # since the http2 server is a proxy that needs to know about the + # dynamic http port it too needs to get restarted when the http server + # is killed + push @killservers, "http/2"; + } push @killservers, $server; # # kill given pids and server relative ones clearing them in %run hash @@ -1488,6 +1508,7 @@ sub runhttpserver { $server = servername_id($proto, $ipvnum, $idnum); $pidfile = $serverpidfile{$server}; + my $portfile = $serverportfile{$server}; # don't retry if the server doesn't work if ($doesntrun{$pidfile}) { @@ -1508,11 +1529,12 @@ sub runhttpserver { $flags .= "--connect $HOSTIP " if($alt eq "proxy"); $flags .= $verbose_flag if($debugprotocol); $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--portfile $portfile "; $flags .= "--id $idnum " if($idnum > 1); if($ipvnum eq "unix") { $flags .= "--unix-socket '$port_or_path' "; } else { - $flags .= "--ipv$ipvnum --port $port_or_path "; + $flags .= "--ipv$ipvnum --port 0 "; } $flags .= "--srcdir \"$srcdir\""; @@ -1528,6 +1550,12 @@ sub runhttpserver { return (0,0); } + # where is it? + my $port; + if(!$port_or_path) { + $port = $port_or_path = pidfromfile($portfile); + } + # Server is up. Verify that we can speak to it. my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port_or_path); if(!$pid3) { @@ -1541,12 +1569,12 @@ sub runhttpserver { $pid2 = $pid3; if($verbose) { - logmsg "RUN: $srvrname server is now running PID $httppid\n"; + logmsg "RUN: $srvrname server is on PID $httppid port $port\n"; } sleep(1); - return ($httppid, $pid2); + return ($httppid, $pid2, $port); } ####################################################################### @@ -1726,31 +1754,10 @@ sub runpingpongserver { my $logfile; my $flags = ""; - if($proto eq "ftp") { - $port = ($idnum>1)?$FTP2PORT:$FTPPORT; - - if($ipvnum==6) { - # if IPv6, use a different setup - $port = $FTP6PORT; - } - } - elsif($proto eq "pop3") { - $port = ($ipvnum==6) ? $POP36PORT : $POP3PORT; - } - elsif($proto eq "imap") { - $port = ($ipvnum==6) ? $IMAP6PORT : $IMAPPORT; - } - elsif($proto eq "smtp") { - $port = ($ipvnum==6) ? $SMTP6PORT : $SMTPPORT; - } - else { - print STDERR "Unsupported protocol $proto!!\n"; - return 0; - } - $server = servername_id($proto, $ipvnum, $idnum); $pidfile = $serverpidfile{$server}; + my $portfile = $serverportfile{$server}; # don't retry if the server doesn't work if ($doesntrun{$pidfile}) { @@ -1769,9 +1776,10 @@ sub runpingpongserver { $flags .= "--verbose " if($debugprotocol); $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--portfile \"$portfile\" "; $flags .= "--srcdir \"$srcdir\" --proto $proto "; $flags .= "--id $idnum " if($idnum > 1); - $flags .= "--ipv$ipvnum --port $port --addr \"$ip\""; + $flags .= "--ipv$ipvnum --port 0 --addr \"$ip\""; my $cmd = "$perl $srcdir/ftpserver.pl $flags"; my ($ftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); @@ -1785,6 +1793,11 @@ sub runpingpongserver { return (0,0); } + # where is it? + $port = pidfromfile($portfile); + + logmsg "PINGPONG runs on port $port ($portfile)\n" if($verbose); + # Server is up. Verify that we can speak to it. my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); if(!$pid3) { @@ -1798,8 +1811,48 @@ sub runpingpongserver { $pid2 = $pid3; - if($verbose) { - logmsg "RUN: $srvrname server is now running PID $ftppid\n"; + logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verbose); + + # Assign the correct port variable! + if($proto eq "ftp") { + if($ipvnum == 6) { + # if IPv6, use a different setup + $FTP6PORT = $port; + } + elsif($idnum>1) { + $FTP2PORT = $port; + } + else { + $FTPPORT = $port; + } + } + elsif($proto eq "pop3") { + if($ipvnum == 6) { + $POP36PORT = $port; + } + else { + $POP3PORT = $port; + } + } + elsif($proto eq "imap") { + if($ipvnum == 6) { + $IMAP6PORT = $port; + } + else { + $IMAPPORT = $port; + } + } + elsif($proto eq "smtp") { + if($ipvnum == 6) { + $SMTP6PORT = $port; + } + else { + $SMTPPORT = $port; + } + } + else { + print STDERR "Unsupported protocol $proto!!\n"; + return 0; } sleep(1); @@ -1895,7 +1948,6 @@ sub runftpsserver { # sub runtftpserver { my ($id, $verbose, $ipv6) = @_; - my $port = $TFTPPORT; my $ip = $HOSTIP; my $proto = 'tftp'; my $ipvnum = 4; @@ -1909,13 +1961,13 @@ sub runtftpserver { if($ipv6) { # if IPv6, use a different setup $ipvnum = 6; - $port = $TFTP6PORT; $ip = $HOST6IP; } $server = servername_id($proto, $ipvnum, $idnum); $pidfile = $serverpidfile{$server}; + my $portfile = $serverportfile{$server}; # don't retry if the server doesn't work if ($doesntrun{$pidfile}) { @@ -1933,9 +1985,11 @@ sub runtftpserver { $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); $flags .= "--verbose " if($debugprotocol); - $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--pidfile \"$pidfile\" ". + "--portfile \"$portfile\" ". + "--logfile \"$logfile\" "; $flags .= "--id $idnum " if($idnum > 1); - $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\""; + $flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\""; my $cmd = "$perl $srcdir/tftpserver.pl $flags"; my ($tftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); @@ -1949,6 +2003,8 @@ sub runtftpserver { return (0,0); } + my $port = pidfromfile($portfile); + # Server is up. Verify that we can speak to it. my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); if(!$pid3) { @@ -1962,12 +2018,12 @@ sub runtftpserver { $pid2 = $pid3; if($verbose) { - logmsg "RUN: $srvrname server is now running PID $tftppid\n"; + logmsg "RUN: $srvrname server on PID $tftppid port $port\n"; } sleep(1); - return ($pid2, $tftppid); + return ($pid2, $tftppid, $port); } @@ -1976,7 +2032,6 @@ sub runtftpserver { # sub runrtspserver { my ($verbose, $ipv6) = @_; - my $port = $RTSPPORT; my $ip = $HOSTIP; my $proto = 'rtsp'; my $ipvnum = 4; @@ -1990,13 +2045,13 @@ sub runrtspserver { if($ipv6) { # if IPv6, use a different setup $ipvnum = 6; - $port = $RTSP6PORT; $ip = $HOST6IP; } $server = servername_id($proto, $ipvnum, $idnum); $pidfile = $serverpidfile{$server}; + my $portfile = $serverportfile{$server}; # don't retry if the server doesn't work if ($doesntrun{$pidfile}) { @@ -2014,9 +2069,11 @@ sub runrtspserver { $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); $flags .= "--verbose " if($debugprotocol); - $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--pidfile \"$pidfile\" ". + "--portfile \"$portfile\" ". + "--logfile \"$logfile\" "; $flags .= "--id $idnum " if($idnum > 1); - $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\""; + $flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\""; my $cmd = "$perl $srcdir/rtspserver.pl $flags"; my ($rtsppid, $pid2) = startnew($cmd, $pidfile, 15, 0); @@ -2030,6 +2087,8 @@ sub runrtspserver { return (0,0); } + my $port = pidfromfile($portfile); + # Server is up. Verify that we can speak to it. my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port); if(!$pid3) { @@ -2043,12 +2102,12 @@ sub runrtspserver { $pid2 = $pid3; if($verbose) { - logmsg "RUN: $srvrname server is now running PID $rtsppid\n"; + logmsg "RUN: $srvrname server PID $rtsppid port $port\n"; } sleep(1); - return ($rtsppid, $pid2); + return ($rtsppid, $pid2, $port); } @@ -2165,10 +2224,70 @@ sub runsshserver { ####################################################################### # Start the socks server # +sub runmqttserver { + my ($id, $verbose, $ipv6) = @_; + my $ip=$HOSTIP; + my $port = $MQTTPORT; + my $proto = 'mqtt'; + my $ipvnum = 4; + my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; + my $server; + my $srvrname; + my $pidfile; + my $portfile; + my $logfile; + my $flags = ""; + + $server = servername_id($proto, $ipvnum, $idnum); + $pidfile = $serverpidfile{$server}; + $portfile = $serverportfile{$server}; + + # don't retry if the server doesn't work + if ($doesntrun{$pidfile}) { + return (0,0); + } + + my $pid = processexists($pidfile); + if($pid > 0) { + stopserver($server, "$pid"); + } + unlink($pidfile) if(-f $pidfile); + + $srvrname = servername_str($proto, $ipvnum, $idnum); + + $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum); + + # start our MQTT server - on a random port! + my $cmd="server/mqttd".exe_ext('SRV'). + " --port 0 ". + " --pidfile $pidfile". + " --portfile $portfile". + " --config $FTPDCMD"; + my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0); + + if($sockspid <= 0 || !pidexists($sockspid)) { + # it is NOT alive + logmsg "RUN: failed to start the $srvrname server\n"; + stopserver($server, "$pid2"); + $doesntrun{$pidfile} = 1; + return (0,0); + } + + $MQTTPORT = pidfromfile($portfile); + + if($verbose) { + logmsg "RUN: $srvrname server is now running PID $pid2 on PORT $MQTTPORT\n"; + } + + return ($pid2, $sockspid); +} + +####################################################################### +# Start the socks server +# sub runsocksserver { my ($id, $verbose, $ipv6) = @_; my $ip=$HOSTIP; - my $port = $SOCKSPORT; my $proto = 'socks'; my $ipvnum = 4; my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; @@ -2181,6 +2300,7 @@ sub runsocksserver { $server = servername_id($proto, $ipvnum, $idnum); $pidfile = $serverpidfile{$server}; + my $portfile = $serverportfile{$server}; # don't retry if the server doesn't work if ($doesntrun{$pidfile}) { @@ -2199,8 +2319,9 @@ sub runsocksserver { # start our socks server, get commands from the FTP cmd file my $cmd="server/socksd".exe_ext('SRV'). - " --port $port ". + " --port 0 ". " --pidfile $pidfile". + " --portfile $portfile". " --backend $HOSTIP". " --config $FTPDCMD"; my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0); @@ -2213,11 +2334,13 @@ sub runsocksserver { return (0,0); } + my $port = pidfromfile($portfile); + if($verbose) { logmsg "RUN: $srvrname server is now running PID $pid2\n"; } - return ($pid2, $sockspid); + return ($pid2, $sockspid, $port); } ####################################################################### @@ -2659,6 +2782,7 @@ sub setupfeatures { $feature{"manual"} = $has_manual; $feature{"unix-sockets"} = $has_unix; $feature{"win32"} = $has_win32; + $feature{"MinGW"} = $has_mingw; # make each protocol an enabled "feature" for my $p (@protocols) { @@ -2739,6 +2863,7 @@ sub checksystem { $pwd = pathhelp::sys_native_current_path(); $has_textaware = 1; $has_win32 = 1; + $has_mingw = 1 if ($curl =~ /-pc-mingw32/); } if ($libcurl =~ /(winssl|schannel)/i) { $has_winssl=1; @@ -3008,6 +3133,7 @@ sub checksystem { my $hostname=join(' ', runclientoutput("hostname")); my $hosttype=join(' ', runclientoutput("uname -a")); + my $hostos=$^O; logmsg ("********* System characteristics ******** \n", "* $curl\n", @@ -3015,7 +3141,8 @@ sub checksystem { "* Features: $feat\n", "* Disabled: $dis\n", "* Host: $hostname", - "* System: $hosttype"); + "* System: $hosttype", + "* OS: $hostos\n"); if($has_memory_tracking && $has_threadedres) { $has_memory_tracking = 0; @@ -3036,43 +3163,14 @@ sub checksystem { logmsg ("* Port range: $minport-$maxport\n"); if($verbose) { - logmsg "* Ports:\n"; - - logmsg sprintf("* HTTP/%d ", $HTTPPORT); - logmsg sprintf("FTP/%d ", $FTPPORT); - logmsg sprintf("FTP2/%d ", $FTP2PORT); - logmsg sprintf("RTSP/%d ", $RTSPPORT); + logmsg "* Ports: "; if($stunnel) { logmsg sprintf("FTPS/%d ", $FTPSPORT); logmsg sprintf("HTTPS/%d ", $HTTPSPORT); } - logmsg sprintf("\n* TFTP/%d ", $TFTPPORT); - if($http_ipv6) { - logmsg sprintf("HTTP-IPv6/%d ", $HTTP6PORT); - logmsg sprintf("RTSP-IPv6/%d ", $RTSP6PORT); - } - if($ftp_ipv6) { - logmsg sprintf("FTP-IPv6/%d ", $FTP6PORT); - } - if($tftp_ipv6) { - logmsg sprintf("TFTP-IPv6/%d ", $TFTP6PORT); - } - logmsg sprintf("\n* GOPHER/%d ", $GOPHERPORT); - if($gopher_ipv6) { - logmsg sprintf("GOPHER-IPv6/%d", $GOPHER6PORT); - } logmsg sprintf("\n* SSH/%d ", $SSHPORT); - logmsg sprintf("SOCKS/%d ", $SOCKSPORT); - logmsg sprintf("POP3/%d ", $POP3PORT); - logmsg sprintf("IMAP/%d ", $IMAPPORT); - logmsg sprintf("SMTP/%d\n", $SMTPPORT); - if($ftp_ipv6) { - logmsg sprintf("* POP3-IPv6/%d ", $POP36PORT); - logmsg sprintf("IMAP-IPv6/%d ", $IMAP6PORT); - logmsg sprintf("SMTP-IPv6/%d\n", $SMTP6PORT); - } if($httptlssrv) { - logmsg sprintf("* HTTPTLS/%d ", $HTTPTLSPORT); + logmsg sprintf("HTTPTLS/%d ", $HTTPTLSPORT); if($has_ipv6) { logmsg sprintf("HTTPTLS-IPv6/%d ", $HTTPTLS6PORT); } @@ -3101,104 +3199,84 @@ sub checksystem { # a command, in either case passed by reference # sub subVariables { - my ($thing) = @_; - - # ports - - $$thing =~ s/%FTP6PORT/$FTP6PORT/g; - $$thing =~ s/%FTP2PORT/$FTP2PORT/g; - $$thing =~ s/%FTPSPORT/$FTPSPORT/g; - $$thing =~ s/%FTPPORT/$FTPPORT/g; - - $$thing =~ s/%GOPHER6PORT/$GOPHER6PORT/g; - $$thing =~ s/%GOPHERPORT/$GOPHERPORT/g; - - $$thing =~ s/%HTTPTLS6PORT/$HTTPTLS6PORT/g; - $$thing =~ s/%HTTPTLSPORT/$HTTPTLSPORT/g; - $$thing =~ s/%HTTP6PORT/$HTTP6PORT/g; - $$thing =~ s/%HTTPSPORT/$HTTPSPORT/g; - $$thing =~ s/%HTTP2PORT/$HTTP2PORT/g; - $$thing =~ s/%HTTPPORT/$HTTPPORT/g; - $$thing =~ s/%PROXYPORT/$HTTPPROXYPORT/g; - - $$thing =~ s/%IMAP6PORT/$IMAP6PORT/g; - $$thing =~ s/%IMAPPORT/$IMAPPORT/g; - - $$thing =~ s/%POP36PORT/$POP36PORT/g; - $$thing =~ s/%POP3PORT/$POP3PORT/g; - - $$thing =~ s/%RTSP6PORT/$RTSP6PORT/g; - $$thing =~ s/%RTSPPORT/$RTSPPORT/g; - - $$thing =~ s/%SMTP6PORT/$SMTP6PORT/g; - $$thing =~ s/%SMTPPORT/$SMTPPORT/g; - - $$thing =~ s/%SOCKSPORT/$SOCKSPORT/g; - $$thing =~ s/%SSHPORT/$SSHPORT/g; - - $$thing =~ s/%TFTP6PORT/$TFTP6PORT/g; - $$thing =~ s/%TFTPPORT/$TFTPPORT/g; - - $$thing =~ s/%DICTPORT/$DICTPORT/g; - - $$thing =~ s/%SMBPORT/$SMBPORT/g; - $$thing =~ s/%SMBSPORT/$SMBSPORT/g; - - $$thing =~ s/%NEGTELNETPORT/$NEGTELNETPORT/g; - - # server Unix domain socket paths - - $$thing =~ s/%HTTPUNIXPATH/$HTTPUNIXPATH/g; - - # client IP addresses - - $$thing =~ s/%CLIENT6IP/$CLIENT6IP/g; - $$thing =~ s/%CLIENTIP/$CLIENTIP/g; - - # server IP addresses - - $$thing =~ s/%HOST6IP/$HOST6IP/g; - $$thing =~ s/%HOSTIP/$HOSTIP/g; - - # misc - - $$thing =~ s/%CURL/$CURL/g; - $$thing =~ s/%PWD/$pwd/g; - $$thing =~ s/%POSIX_PWD/$posix_pwd/g; - - my $file_pwd = $pwd; - if($file_pwd !~ /^\//) { - $file_pwd = "/$file_pwd"; - } - - $$thing =~ s/%FILE_PWD/$file_pwd/g; - $$thing =~ s/%SRCDIR/$srcdir/g; - $$thing =~ s/%USER/$USER/g; - - if($$thing =~ /%SSHSRVMD5/) { - if(!$SSHSRVMD5) { - my $msg = "Fatal: Missing SSH server pubkey MD5. Is server running?"; - logmsg "$msg\n"; - stopservers($verbose); - die $msg; - } - $$thing =~ s/%SSHSRVMD5/$SSHSRVMD5/g; - } - - # The purpose of FTPTIME2 and FTPTIME3 is to provide times that can be - # used for time-out tests and that would work on most hosts as these - # adjust for the startup/check time for this particular host. We needed - # to do this to make the test suite run better on very slow hosts. - - my $ftp2 = $ftpchecktime * 2; - my $ftp3 = $ftpchecktime * 3; - - $$thing =~ s/%FTPTIME2/$ftp2/g; - $$thing =~ s/%FTPTIME3/$ftp3/g; - - # HTTP2 - - $$thing =~ s/%H2CVER/$h2cver/g; + my ($thing, $prefix) = @_; + + if(!$prefix) { + $prefix = "%"; + } + + # test server ports + $$thing =~ s/${prefix}FTP6PORT/$FTP6PORT/g; + $$thing =~ s/${prefix}FTP2PORT/$FTP2PORT/g; + $$thing =~ s/${prefix}FTPSPORT/$FTPSPORT/g; + $$thing =~ s/${prefix}FTPPORT/$FTPPORT/g; + $$thing =~ s/${prefix}GOPHER6PORT/$GOPHER6PORT/g; + $$thing =~ s/${prefix}GOPHERPORT/$GOPHERPORT/g; + $$thing =~ s/${prefix}HTTPTLS6PORT/$HTTPTLS6PORT/g; + $$thing =~ s/${prefix}HTTPTLSPORT/$HTTPTLSPORT/g; + $$thing =~ s/${prefix}HTTP6PORT/$HTTP6PORT/g; + $$thing =~ s/${prefix}HTTPSPORT/$HTTPSPORT/g; + $$thing =~ s/${prefix}HTTP2PORT/$HTTP2PORT/g; + $$thing =~ s/${prefix}HTTPPORT/$HTTPPORT/g; + $$thing =~ s/${prefix}PROXYPORT/$HTTPPROXYPORT/g; + $$thing =~ s/${prefix}MQTTPORT/$MQTTPORT/g; + $$thing =~ s/${prefix}IMAP6PORT/$IMAP6PORT/g; + $$thing =~ s/${prefix}IMAPPORT/$IMAPPORT/g; + $$thing =~ s/${prefix}POP36PORT/$POP36PORT/g; + $$thing =~ s/${prefix}POP3PORT/$POP3PORT/g; + $$thing =~ s/${prefix}RTSP6PORT/$RTSP6PORT/g; + $$thing =~ s/${prefix}RTSPPORT/$RTSPPORT/g; + $$thing =~ s/${prefix}SMTP6PORT/$SMTP6PORT/g; + $$thing =~ s/${prefix}SMTPPORT/$SMTPPORT/g; + $$thing =~ s/${prefix}SOCKSPORT/$SOCKSPORT/g; + $$thing =~ s/${prefix}SSHPORT/$SSHPORT/g; + $$thing =~ s/${prefix}TFTP6PORT/$TFTP6PORT/g; + $$thing =~ s/${prefix}TFTPPORT/$TFTPPORT/g; + $$thing =~ s/${prefix}DICTPORT/$DICTPORT/g; + $$thing =~ s/${prefix}SMBPORT/$SMBPORT/g; + $$thing =~ s/${prefix}SMBSPORT/$SMBSPORT/g; + $$thing =~ s/${prefix}NEGTELNETPORT/$NEGTELNETPORT/g; + $$thing =~ s/${prefix}NOLISTENPORT/$NOLISTENPORT/g; + + # server Unix domain socket paths + $$thing =~ s/${prefix}HTTPUNIXPATH/$HTTPUNIXPATH/g; + + # client IP addresses + $$thing =~ s/${prefix}CLIENT6IP/$CLIENT6IP/g; + $$thing =~ s/${prefix}CLIENTIP/$CLIENTIP/g; + + # server IP addresses + $$thing =~ s/${prefix}HOST6IP/$HOST6IP/g; + $$thing =~ s/${prefix}HOSTIP/$HOSTIP/g; + + # misc + $$thing =~ s/${prefix}CURL/$CURL/g; + $$thing =~ s/${prefix}PWD/$pwd/g; + $$thing =~ s/${prefix}POSIX_PWD/$posix_pwd/g; + + my $file_pwd = $pwd; + if($file_pwd !~ /^\//) { + $file_pwd = "/$file_pwd"; + } + + $$thing =~ s/${prefix}FILE_PWD/$file_pwd/g; + $$thing =~ s/${prefix}SRCDIR/$srcdir/g; + $$thing =~ s/${prefix}USER/$USER/g; + + $$thing =~ s/${prefix}SSHSRVMD5/$SSHSRVMD5/g; + + # The purpose of FTPTIME2 and FTPTIME3 is to provide times that can be + # used for time-out tests and that would work on most hosts as these + # adjust for the startup/check time for this particular host. We needed to + # do this to make the test suite run better on very slow hosts. + my $ftp2 = $ftpchecktime * 2; + my $ftp3 = $ftpchecktime * 3; + + $$thing =~ s/${prefix}FTPTIME2/$ftp2/g; + $$thing =~ s/${prefix}FTPTIME3/$ftp3/g; + + # HTTP2 + $$thing =~ s/${prefix}H2CVER/$h2cver/g; } sub fixarray { @@ -3414,6 +3492,25 @@ sub singletest { $why = serverfortest($testnum); } + # Save a preprocessed version of the entire test file. This allows more + # "basic" test case readers to enjoy variable replacements. + my @entiretest = fulltest(); + my $otest = "log/test$testnum"; + open(D, ">$otest"); + my $diff; + for my $s (@entiretest) { + my $f = $s; + subVariables(\$s, "%"); + if($f ne $s) { + $diff++; + } + print D $s; + } + close(D); + # remove the separate test file again if nothing was updated to keep + # things simpler + unlink($otest) if(!$diff); + # timestamp required servers verification end $timesrvrend{$testnum} = Time::HiRes::time(); @@ -3453,7 +3550,7 @@ sub singletest { if(@precheck) { $cmd = $precheck[0]; chomp $cmd; - subVariables \$cmd; + subVariables(\$cmd); if($cmd) { my @p = split(/ /, $cmd); if($p[0] !~ /\//) { @@ -3532,6 +3629,9 @@ sub singletest { map s/\n/\r\n/g, @reply; } } + for my $r (@reply) { + subVariables(\$r); + } # this is the valid protocol blurb curl should generate my @protocol= fixarray ( getpart("verify", "protocol") ); @@ -3584,10 +3684,9 @@ sub singletest { unlink($SERVER2IN); unlink($PROXYIN); - if(@ftpservercmd) { - # write the instructions to file - writearray($FTPDCMD, \@ftpservercmd); - } + push @ftpservercmd, "Testnum $testnum\n"; + # write the instructions to file + writearray($FTPDCMD, \@ftpservercmd); # get the command line options to use my @blaha; @@ -3597,7 +3696,7 @@ sub singletest { # make some nice replace operations $cmd =~ s/\n//g; # no newlines please # substitute variables in the command line - subVariables \$cmd; + subVariables(\$cmd); } else { # there was no command given, use something silly @@ -3680,9 +3779,14 @@ sub singletest { if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-include/)) { $inc = " --include"; } - $cmdargs = "$out$inc "; - $cmdargs .= "--trace-ascii log/trace$testnum "; + + if($cmdhash{'option'} && ($cmdhash{'option'} =~ /binary-trace/)) { + $cmdargs .= "--trace log/trace$testnum "; + } + else { + $cmdargs .= "--trace-ascii log/trace$testnum "; + } $cmdargs .= "--trace-time "; if($evbased) { $cmdargs .= "--test-event "; @@ -3872,70 +3976,12 @@ sub singletest { my @killtestservers = getpart("client", "killserver"); if(@killtestservers) { - # - # All servers relative to the given one must be stopped also - # - my @killservers; foreach my $server (@killtestservers) { chomp $server; - if($server =~ /^(ftp|http|imap|pop3|smtp)s((\d*)(-ipv6|-unix|))$/) { - # given a stunnel ssl server, also kill non-ssl underlying one - push @killservers, "${1}${2}"; - } - elsif($server =~ /^(ftp|http|imap|pop3|smtp)((\d*)(-ipv6|-unix|))$/) { - # given a non-ssl server, also kill stunnel piggybacking one - push @killservers, "${1}s${2}"; - } - elsif($server =~ /^(socks)((\d*)(-ipv6|))$/) { - # given a socks server, also kill ssh underlying one - push @killservers, "ssh${2}"; - } - elsif($server =~ /^(ssh)((\d*)(-ipv6|))$/) { - # given a ssh server, also kill socks piggybacking one - push @killservers, "socks${2}"; - } - push @killservers, $server; - } - # - # kill sockfilter processes for pingpong relative servers - # - foreach my $server (@killservers) { - if($server =~ /^(ftp|imap|pop3|smtp)s?(\d*)(-ipv6|)$/) { - my $proto = $1; - my $idnum = ($2 && ($2 > 1)) ? $2 : 1; - my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4; - killsockfilters($proto, $ipvnum, $idnum, $verbose); - } - } - # - # kill server relative pids clearing them in %run hash - # - my $pidlist; - foreach my $server (@killservers) { - if($run{$server}) { - $pidlist .= "$run{$server} "; - $run{$server} = 0; - } - $runcert{$server} = 0 if($runcert{$server}); - } - killpid($verbose, $pidlist); - # - # cleanup server pid files - # - foreach my $server (@killservers) { - my $pidfile = $serverpidfile{$server}; - my $pid = processexists($pidfile); - if($pid > 0) { - logmsg "Warning: $server server unexpectedly alive\n"; - killpid($verbose, $pid); - } - unlink($pidfile) if(-f $pidfile); + stopserver($server); } } - # remove the test server commands file after each test - unlink($FTPDCMD) if(-f $FTPDCMD); - # run the postcheck command my @postcheck= getpart("client", "postcheck"); if(@postcheck) { @@ -4118,6 +4164,13 @@ sub singletest { } } + if((!$out[0] || ($out[0] eq "")) && $protstrip[0]) { + logmsg "\n $testnum: protocol FAILED!\n". + " There was no content at all in the file $SERVERIN.\n". + " Server glitch? Total curl failure? Returned: $cmdres\n"; + return $errorreturncode; + } + $res = compare($testnum, $testname, "protocol", \@out, \@protstrip); if($res) { return $errorreturncode; @@ -4366,7 +4419,7 @@ sub singletest { $ok .= "v"; } else { - if(!$short && !$disablevalgrind) { + if($verbose && !$disablevalgrind) { logmsg " valgrind SKIPPED\n"; } $ok .= "-"; # skipped @@ -4523,8 +4576,8 @@ sub startservers { stopserver('gopher'); } if(!$run{'gopher'}) { - ($pid, $pid2) = runhttpserver("gopher", $verbose, 0, - $GOPHERPORT); + ($pid, $pid2, $GOPHERPORT) = + runhttpserver("gopher", $verbose, 0); if($pid <= 0) { return "failed starting GOPHER server"; } @@ -4540,8 +4593,8 @@ sub startservers { stopserver('gopher-ipv6'); } if(!$run{'gopher-ipv6'}) { - ($pid, $pid2) = runhttpserver("gopher", $verbose, "ipv6", - $GOPHER6PORT); + ($pid, $pid2, $GOPHER6PORT) = + runhttpserver("gopher", $verbose, "ipv6"); if($pid <= 0) { return "failed starting GOPHER-IPv6 server"; } @@ -4567,8 +4620,8 @@ sub startservers { stopserver('http'); } if(!$run{'http'}) { - ($pid, $pid2) = runhttpserver("http", $verbose, 0, - $HTTPPORT); + ($pid, $pid2, $HTTPPORT) = + runhttpserver("http", $verbose, 0); if($pid <= 0) { return "failed starting HTTP server"; } @@ -4584,8 +4637,8 @@ sub startservers { stopserver('http-proxy'); } if(!$run{'http-proxy'}) { - ($pid, $pid2) = runhttpserver("http", $verbose, "proxy", - $HTTPPROXYPORT); + ($pid, $pid2, $HTTPPROXYPORT) = + runhttpserver("http", $verbose, "proxy"); if($pid <= 0) { return "failed starting HTTP-proxy server"; } @@ -4600,8 +4653,8 @@ sub startservers { stopserver('http-ipv6'); } if(!$run{'http-ipv6'}) { - ($pid, $pid2) = runhttpserver("http", $verbose, "ipv6", - $HTTP6PORT); + ($pid, $pid2, $HTTP6PORT) = + runhttpserver("http", $verbose, "ipv6"); if($pid <= 0) { return "failed starting HTTP-IPv6 server"; } @@ -4616,7 +4669,7 @@ sub startservers { stopserver('rtsp'); } if(!$run{'rtsp'}) { - ($pid, $pid2) = runrtspserver($verbose); + ($pid, $pid2, $RTSPPORT) = runrtspserver($verbose); if($pid <= 0) { return "failed starting RTSP server"; } @@ -4630,7 +4683,7 @@ sub startservers { stopserver('rtsp-ipv6'); } if(!$run{'rtsp-ipv6'}) { - ($pid, $pid2) = runrtspserver($verbose, "ipv6"); + ($pid, $pid2, $RTSP6PORT) = runrtspserver($verbose, "ipv6"); if($pid <= 0) { return "failed starting RTSP-IPv6 server"; } @@ -4687,8 +4740,8 @@ sub startservers { stopserver('http'); } if(!$run{'http'}) { - ($pid, $pid2) = runhttpserver("http", $verbose, 0, - $HTTPPORT); + ($pid, $pid2, $HTTPPORT) = + runhttpserver("http", $verbose, 0); if($pid <= 0) { return "failed starting HTTP server"; } @@ -4749,7 +4802,8 @@ sub startservers { stopserver('tftp'); } if(!$run{'tftp'}) { - ($pid, $pid2) = runtftpserver("", $verbose); + ($pid, $pid2, $TFTPPORT) = + runtftpserver("", $verbose); if($pid <= 0) { return "failed starting TFTP server"; } @@ -4763,7 +4817,8 @@ sub startservers { stopserver('tftp-ipv6'); } if(!$run{'tftp-ipv6'}) { - ($pid, $pid2) = runtftpserver("", $verbose, "ipv6"); + ($pid, $pid2, $TFTP6PORT) = + runtftpserver("", $verbose, "ipv6"); if($pid <= 0) { return "failed starting TFTP-IPv6 server"; } @@ -4783,7 +4838,7 @@ sub startservers { } elsif($what eq "socks4" || $what eq "socks5" ) { if(!$run{'socks'}) { - ($pid, $pid2) = runsocksserver("", $verbose); + ($pid, $pid2, $SOCKSPORT) = runsocksserver("", $verbose); if($pid <= 0) { return "failed starting socks server"; } @@ -4791,14 +4846,25 @@ sub startservers { $run{'socks'}="$pid $pid2"; } } + elsif($what eq "mqtt" ) { + if(!$run{'mqtt'}) { + ($pid, $pid2) = runmqttserver("", $verbose); + if($pid <= 0) { + return "failed starting mqtt server"; + } + printf ("* pid mqtt => %d %d\n", $pid, $pid2) if($verbose); + $run{'mqtt'}="$pid $pid2"; + } + } elsif($what eq "http-unix") { if($torture && $run{'http-unix'} && !responsive_http_server("http", $verbose, "unix", $HTTPUNIXPATH)) { stopserver('http-unix'); } if(!$run{'http-unix'}) { - ($pid, $pid2) = runhttpserver("http", $verbose, "unix", - $HTTPUNIXPATH); + my $unused; + ($pid, $pid2, $unused) = + runhttpserver("http", $verbose, "unix", $HTTPUNIXPATH); if($pid <= 0) { return "failed starting HTTP-unix server"; } @@ -5328,37 +5394,17 @@ if ($gdbthis) { } $minport = $base; # original base port number - -$HTTPPORT = $base++; # HTTP server port $HTTPSPORT = $base++; # HTTPS (stunnel) server port -$FTPPORT = $base++; # FTP server port $FTPSPORT = $base++; # FTPS (stunnel) server port -$HTTP6PORT = $base++; # HTTP IPv6 server port -$FTP2PORT = $base++; # FTP server 2 port -$FTP6PORT = $base++; # FTP IPv6 port -$TFTPPORT = $base++; # TFTP (UDP) port -$TFTP6PORT = $base++; # TFTP IPv6 (UDP) port $SSHPORT = $base++; # SSH (SCP/SFTP) port -$SOCKSPORT = $base++; # SOCKS port -$POP3PORT = $base++; # POP3 server port -$POP36PORT = $base++; # POP3 IPv6 server port -$IMAPPORT = $base++; # IMAP server port -$IMAP6PORT = $base++; # IMAP IPv6 server port -$SMTPPORT = $base++; # SMTP server port -$SMTP6PORT = $base++; # SMTP IPv6 server port -$RTSPPORT = $base++; # RTSP server port -$RTSP6PORT = $base++; # RTSP IPv6 server port -$GOPHERPORT = $base++; # Gopher IPv4 server port -$GOPHER6PORT = $base++; # Gopher IPv6 server port $HTTPTLSPORT = $base++; # HTTP TLS (non-stunnel) server port $HTTPTLS6PORT = $base++; # HTTP TLS (non-stunnel) IPv6 server port -$HTTPPROXYPORT = $base++; # HTTP proxy port, when using CONNECT $HTTP2PORT = $base++; # HTTP/2 port $DICTPORT = $base++; # DICT port $SMBPORT = $base++; # SMB port $SMBSPORT = $base++; # SMBS port $NEGTELNETPORT = $base++; # TELNET port with negotiation -$HTTPUNIXPATH = 'http.sock'; # HTTP server Unix domain socket path +$HTTPUNIXPATH = "http$$.sock"; # HTTP server Unix domain socket path $maxport = $base-1; # updated base port number @@ -5398,7 +5444,13 @@ sub disabledtests { next; } if($_ =~ /(\d+)/) { - $disabled{$1}=$1; # disable this test number + my ($n) = $1; + $disabled{$n}=$n; # disable this test number + if(! -f "$srcdir/data/test$n") { + print STDERR "WARNING! Non-exiting test $n in DISABLED!\n"; + # fail hard to make user notice + exit 1; + } } } close(D); @@ -5560,6 +5612,9 @@ sub displaylogs { if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(\..*|)$/)) { next; # skip valgrindNnn of other tests } + if(($log =~ /^test$testnum$/)) { + next; # skip test$testnum since it can be very big + } logmsg "=== Start of file $log\n"; displaylogcontent("$LOGDIR/$log"); logmsg "=== End of file $log\n"; |