summaryrefslogtreecommitdiff
path: root/tests/runtests.pl.in
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runtests.pl.in')
-rwxr-xr-xtests/runtests.pl.in331
1 files changed, 159 insertions, 172 deletions
diff --git a/tests/runtests.pl.in b/tests/runtests.pl.in
index 72113e895..a8bfe16c4 100755
--- a/tests/runtests.pl.in
+++ b/tests/runtests.pl.in
@@ -76,6 +76,7 @@ use strict;
use warnings;
use Cwd;
use Digest::MD5 qw(md5);
+use MIME::Base64;
# Subs imported from serverhelp module
use serverhelp qw(
@@ -126,10 +127,6 @@ my $HOST6IP="[::1]"; # address on which the test server listens
my $CLIENTIP="127.0.0.1"; # address which curl uses for incoming connections
my $CLIENT6IP="[::1]"; # address which curl uses for incoming connections
-my $base = 8990; # base port number
-my $minport; # minimum used port number
-my $maxport; # maximum used port number
-
my $noport="[not running]";
my $NOLISTENPORT=47; # port number we use for a local non-listening service
@@ -162,7 +159,7 @@ 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 $TELNETPORT=$noport; # TELNET server port with negotiation
my $HTTPUNIXPATH; # HTTP server Unix domain socket path
my $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key
@@ -240,6 +237,7 @@ my $has_ipv6; # set if libcurl is built with IPv6 support
my $has_unix; # set if libcurl is built with Unix sockets support
my $has_libz; # set if libcurl is built with libz support
my $has_brotli; # set if libcurl is built with brotli support
+my $has_zstd; # set if libcurl is built with zstd support
my $has_getrlimit; # set if system has getrlimit()
my $has_ntlm; # set if libcurl is built with NTLM support
my $has_ntlm_wb; # set if libcurl is built with NTLM delegation to winbind
@@ -270,8 +268,8 @@ my $has_openssl; # built with a lib using an OpenSSL-like API
my $has_gnutls; # built with GnuTLS
my $has_nss; # built with NSS
my $has_wolfssl; # built with wolfSSL
-my $has_winssl; # built with WinSSL (Secure Channel aka Schannel)
-my $has_darwinssl; # built with DarwinSSL (Secure Transport)
+my $has_schannel; # built with Schannel
+my $has_sectransp; # built with Secure Transport
my $has_boringssl; # built with BoringSSL
my $has_libressl; # built with libressl
my $has_mbedtls; # built with mbedTLS
@@ -1432,7 +1430,7 @@ sub responsiveserver {
# start the http2 server
#
sub runhttp2server {
- my ($verbose, $port) = @_;
+ my ($verbose) = @_;
my $server;
my $srvrname;
my $pidfile;
@@ -1464,26 +1462,34 @@ sub runhttp2server {
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
- $flags .= "--port $HTTP2PORT ";
$flags .= "--connect $HOSTIP:$HTTPPORT ";
$flags .= $verbose_flag if($debugprotocol);
- my $cmd = "$exe $flags";
- my ($http2pid, $pid2) = startnew($cmd, $pidfile, 15, 0);
+ my ($http2pid, $pid2);
+ my $port = 23113;
+ for(1 .. 10) {
+ $port += int(rand(900));
+ my $aflags = "--port $port $flags";
- if($http2pid <= 0 || !pidexists($http2pid)) {
- # it is NOT alive
- logmsg "RUN: failed to start the $srvrname server\n";
- stopserver($server, "$pid2");
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
+ my $cmd = "$exe $aflags";
+ ($http2pid, $pid2) = startnew($cmd, $pidfile, 15, 0);
- if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $http2pid\n";
+ if($http2pid <= 0 || !pidexists($http2pid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the $srvrname server\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ next;
+ }
+ $doesntrun{$pidfile} = 0;
+
+ if($verbose) {
+ logmsg "RUN: $srvrname server PID $http2pid port $port\n";
+ }
+ last;
}
- return ($http2pid, $pid2);
+ return ($http2pid, $pid2, $port);
}
#######################################################################
@@ -1695,7 +1701,6 @@ sub runhttpsserver {
sub runhttptlsserver {
my ($verbose, $ipv6) = @_;
my $proto = "httptls";
- my $port = ($ipv6 && ($ipv6 =~ /6$/)) ? $HTTPTLS6PORT : $HTTPTLSPORT;
my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
my $idnum = 1;
@@ -1730,40 +1735,36 @@ sub runhttptlsserver {
$flags .= "--http ";
$flags .= "--debug 1 " if($debugprotocol);
- $flags .= "--port $port ";
$flags .= "--priority NORMAL:+SRP ";
$flags .= "--srppasswd $srcdir/certs/srp-verifier-db ";
$flags .= "--srppasswdconf $srcdir/certs/srp-verifier-conf";
- my $cmd = "$httptlssrv $flags > $logfile 2>&1";
- my ($httptlspid, $pid2) = startnew($cmd, $pidfile, 10, 1); # fake pidfile
+ my $port = 24367;
+ my ($httptlspid, $pid2);
+ for (1 .. 10) {
+ $port += int(rand(800));
+ my $allflags = "--port $port $flags";
- if($httptlspid <= 0 || !pidexists($httptlspid)) {
- # it is NOT alive
- logmsg "RUN: failed to start the $srvrname server\n";
- stopserver($server, "$pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
+ my $cmd = "$httptlssrv $allflags > $logfile 2>&1";
+ ($httptlspid, $pid2) = startnew($cmd, $pidfile, 10, 1);
- # Server is up. Verify that we can speak to it. PID is from fake pidfile
- my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
- if(!$pid3) {
- logmsg "RUN: $srvrname server failed verification\n";
- # failed to talk to it properly. Kill the server and return failure
- stopserver($server, "$httptlspid $pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
- $pid2 = $pid3;
+ if($httptlspid <= 0 || !pidexists($httptlspid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the $srvrname server\n";
+ stopserver($server, "$pid2");
+ displaylogs($testnumcheck);
+ $doesntrun{$pidfile} = 1;
+ $httptlspid = $pid2 = 0;
+ next;
+ }
+ $doesntrun{$pidfile} = 0;
- if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $httptlspid\n";
+ if($verbose) {
+ logmsg "RUN: $srvrname server PID $httptlspid port $port\n";
+ }
+ last;
}
-
- return ($httptlspid, $pid2);
+ return ($httptlspid, $pid2, $port);
}
#######################################################################
@@ -2400,7 +2401,7 @@ sub runsocksserver {
# start the dict server
#
sub rundictserver {
- my ($verbose, $alt, $port) = @_;
+ my ($verbose, $alt) = @_;
my $proto = "dict";
my $ip = $HOSTIP;
my $ipvnum = 4;
@@ -2437,45 +2438,42 @@ sub rundictserver {
$flags .= "--verbose 1 " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
- $flags .= "--port $port --srcdir \"$srcdir\" ";
+ $flags .= "--srcdir \"$srcdir\" ";
$flags .= "--host $HOSTIP";
- my $cmd = "$srcdir/dictserver.py $flags";
- my ($dictpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
-
- if($dictpid <= 0 || !pidexists($dictpid)) {
- # it is NOT alive
- logmsg "RUN: failed to start the $srvrname server\n";
- stopserver($server, "$pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
+ my $port = 29000;
+ my ($dictpid, $pid2);
+ for(1 .. 10) {
+ $port += int(rand(900));
+ my $aflags = "--port $port $flags";
+ my $cmd = "$srcdir/dictserver.py $aflags";
+ ($dictpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
- # Server is up. Verify that we can speak to it.
- my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
- if(!$pid3) {
- logmsg "RUN: $srvrname server failed verification\n";
- # failed to talk to it properly. Kill the server and return failure
- stopserver($server, "$dictpid $pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
- $pid2 = $pid3;
+ if($dictpid <= 0 || !pidexists($dictpid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the $srvrname server\n";
+ stopserver($server, "$pid2");
+ displaylogs($testnumcheck);
+ $doesntrun{$pidfile} = 1;
+ $dictpid = $pid2 = 0;
+ next;
+ }
+ $doesntrun{$pidfile} = 0;
- if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $dictpid\n";
+ if($verbose) {
+ logmsg "RUN: $srvrname server PID $dictpid port $port\n";
+ }
+ last;
}
- return ($dictpid, $pid2);
+ return ($dictpid, $pid2, $port);
}
#######################################################################
# start the SMB server
#
sub runsmbserver {
- my ($verbose, $alt, $port) = @_;
+ my ($verbose, $alt) = @_;
my $proto = "smb";
my $ip = $HOSTIP;
my $ipvnum = 4;
@@ -2512,45 +2510,42 @@ sub runsmbserver {
$flags .= "--verbose 1 " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
- $flags .= "--port $port --srcdir \"$srcdir\" ";
+ $flags .= "--srcdir \"$srcdir\" ";
$flags .= "--host $HOSTIP";
- my $cmd = "$srcdir/smbserver.py $flags";
- my ($smbpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
-
- if($smbpid <= 0 || !pidexists($smbpid)) {
- # it is NOT alive
- logmsg "RUN: failed to start the $srvrname server\n";
- stopserver($server, "$pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
+ my ($smbpid, $pid2);
+ my $port = 31923;
+ for(1 .. 10) {
+ $port += int(rand(760));
+ my $aflags = "--port $port $flags";
+ my $cmd = "$srcdir/smbserver.py $aflags";
+ ($smbpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
- # Server is up. Verify that we can speak to it.
- my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
- if(!$pid3) {
- logmsg "RUN: $srvrname server failed verification\n";
- # failed to talk to it properly. Kill the server and return failure
- stopserver($server, "$smbpid $pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
- $pid2 = $pid3;
+ if($smbpid <= 0 || !pidexists($smbpid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the $srvrname server\n";
+ stopserver($server, "$pid2");
+ displaylogs($testnumcheck);
+ $doesntrun{$pidfile} = 1;
+ $smbpid = $pid2 = 0;
+ next;
+ }
+ $doesntrun{$pidfile} = 0;
- if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $smbpid\n";
+ if($verbose) {
+ logmsg "RUN: $srvrname server PID $smbpid port $port\n";
+ }
+ last;
}
- return ($smbpid, $pid2);
+ return ($smbpid, $pid2, $port);
}
#######################################################################
# start the telnet server
#
sub runnegtelnetserver {
- my ($verbose, $alt, $port) = @_;
+ my ($verbose, $alt) = @_;
my $proto = "telnet";
my $ip = $HOSTIP;
my $ipvnum = 4;
@@ -2587,37 +2582,34 @@ sub runnegtelnetserver {
$flags .= "--verbose 1 " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
- $flags .= "--port $port --srcdir \"$srcdir\"";
-
- my $cmd = "$srcdir/negtelnetserver.py $flags";
- my ($ntelpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
+ $flags .= "--srcdir \"$srcdir\"";
- if($ntelpid <= 0 || !pidexists($ntelpid)) {
- # it is NOT alive
- logmsg "RUN: failed to start the $srvrname server\n";
- stopserver($server, "$pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
+ my ($ntelpid, $pid2);
+ my $port = 32000;
+ for(1 .. 10) {
+ $port += int(rand(800));
+ my $aflags = "--port $port $flags";
+ my $cmd = "$srcdir/negtelnetserver.py $aflags";
+ ($ntelpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
- # Server is up. Verify that we can speak to it.
- my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
- if(!$pid3) {
- logmsg "RUN: $srvrname server failed verification\n";
- # failed to talk to it properly. Kill the server and return failure
- stopserver($server, "$ntelpid $pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
- $pid2 = $pid3;
+ if($ntelpid <= 0 || !pidexists($ntelpid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the $srvrname server\n";
+ stopserver($server, "$pid2");
+ displaylogs($testnumcheck);
+ $doesntrun{$pidfile} = 1;
+ $ntelpid = $pid2 = 0;
+ next;
+ }
+ $doesntrun{$pidfile} = 0;
- if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $ntelpid\n";
+ if($verbose) {
+ logmsg "RUN: $srvrname server PID $ntelpid port $port\n";
+ }
+ last;
}
- return ($ntelpid, $pid2);
+ return ($ntelpid, $pid2, $port);
}
@@ -2796,7 +2788,6 @@ sub setupfeatures {
$feature{"alt-svc"} = $has_altsvc;
$feature{"brotli"} = $has_brotli;
$feature{"crypto"} = $has_crypto;
- $feature{"DarwinSSL"} = $has_darwinssl; # alias
$feature{"debug"} = $debug_build;
$feature{"getrlimit"} = $has_getrlimit;
$feature{"GnuTLS"} = $has_gnutls;
@@ -2816,10 +2807,10 @@ sub setupfeatures {
$feature{"NSS"} = $has_nss;
$feature{"NTLM"} = $has_ntlm;
$feature{"NTLM_WB"} = $has_ntlm_wb;
- $feature{"OpenSSL"} = $has_openssl;
+ $feature{"OpenSSL"} = $has_openssl || $has_libressl || $has_boringssl;
$feature{"PSL"} = $has_psl;
- $feature{"Schannel"} = $has_winssl; # alias
- $feature{"sectransp"} = $has_darwinssl;
+ $feature{"Schannel"} = $has_schannel;
+ $feature{"sectransp"} = $has_sectransp;
$feature{"SPNEGO"} = $has_spnego;
$feature{"SSL"} = $has_ssl;
$feature{"SSLpinning"} = $has_sslpinning;
@@ -2830,7 +2821,7 @@ sub setupfeatures {
$feature{"unittest"} = $debug_build;
$feature{"unix-sockets"} = $has_unix;
$feature{"win32"} = $has_win32;
- $feature{"WinSSL"} = $has_winssl;
+ $feature{"zstd"} = $has_zstd;
# make each protocol an enabled "feature"
for my $p (@protocols) {
@@ -2914,7 +2905,7 @@ sub checksystem {
$has_mingw = 1 if ($curl =~ /-pc-mingw32/);
}
if ($libcurl =~ /(winssl|schannel)/i) {
- $has_winssl=1;
+ $has_schannel=1;
$has_sslpinning=1;
}
elsif ($libcurl =~ /openssl/i) {
@@ -2934,7 +2925,7 @@ sub checksystem {
$has_sslpinning=1;
}
elsif ($libcurl =~ /securetransport/i) {
- $has_darwinssl=1;
+ $has_sectransp=1;
$has_sslpinning=1;
}
elsif ($libcurl =~ /BoringSSL/i) {
@@ -3011,6 +3002,9 @@ sub checksystem {
if($feat =~ /brotli/i) {
$has_brotli = 1;
}
+ if($feat =~ /zstd/i) {
+ $has_zstd = 1;
+ }
if($feat =~ /NTLM/i) {
# NTLM enabled
$has_ntlm=1;
@@ -3214,18 +3208,8 @@ sub checksystem {
$run_event_based?"event-based ":"");
logmsg sprintf("%s\n", $libtool?"Libtool ":"");
logmsg ("* Seed: $randseed\n");
- logmsg ("* Port range: $minport-$maxport\n");
if($verbose) {
- logmsg "* Ports: ";
- if($httptlssrv) {
- logmsg sprintf("HTTPTLS/%d ", $HTTPTLSPORT);
- if($has_ipv6) {
- logmsg sprintf("HTTPTLS-IPv6/%d ", $HTTPTLS6PORT);
- }
- logmsg "\n";
- }
-
if($has_unix) {
logmsg "* Unix socket paths:\n";
if($http_unix) {
@@ -3284,7 +3268,7 @@ sub subVariables {
$$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}TELNETPORT/$TELNETPORT/g;
$$thing =~ s/${prefix}NOLISTENPORT/$NOLISTENPORT/g;
# server Unix domain socket paths
@@ -3333,6 +3317,20 @@ sub subVariables {
$$thing =~ s/${prefix}H2CVER/$h2cver/g;
}
+sub subBase64 {
+ my ($thing) = @_;
+
+ # cut out the base64 piece
+ if($$thing =~ s/%b64\[(.*)\]b64%/%%B64%%/i) {
+ my $d = $1;
+ # encode %NN characters
+ $d =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+ my $enc = encode_base64($d, "");
+ # put the result into there
+ $$thing =~ s/%%B64%%/$enc/;
+ }
+}
+
sub fixarray {
my @in = @_;
@@ -3555,16 +3553,21 @@ sub singletest {
for my $s (@entiretest) {
my $f = $s;
subVariables(\$s, "%");
+ subBase64(\$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);
+ # in case the process changed the file, reload it
+ loadtest("log/test${testnum}") if($diff);
+
# timestamp required servers verification end
$timesrvrend{$testnum} = Time::HiRes::time();
@@ -4644,7 +4647,7 @@ sub startservers {
}
elsif($what eq "http/2") {
if(!$run{'http/2'}) {
- ($pid, $pid2) = runhttp2server($verbose, $HTTP2PORT);
+ ($pid, $pid2, $HTTP2PORT) = runhttp2server($verbose);
if($pid <= 0) {
return "failed starting HTTP/2 server";
}
@@ -4838,7 +4841,8 @@ sub startservers {
stopserver('httptls');
}
if(!$run{'httptls'}) {
- ($pid, $pid2) = runhttptlsserver($verbose, "IPv4");
+ ($pid, $pid2, $HTTPTLSPORT) =
+ runhttptlsserver($verbose, "IPv4");
if($pid <= 0) {
return "failed starting HTTPTLS server (gnutls-serv)";
}
@@ -4857,7 +4861,8 @@ sub startservers {
stopserver('httptls-ipv6');
}
if(!$run{'httptls-ipv6'}) {
- ($pid, $pid2) = runhttptlsserver($verbose, "ipv6");
+ ($pid, $pid2, $HTTPTLS6PORT) =
+ runhttptlsserver($verbose, "ipv6");
if($pid <= 0) {
return "failed starting HTTPTLS-IPv6 server (gnutls-serv)";
}
@@ -4945,7 +4950,7 @@ sub startservers {
}
elsif($what eq "dict") {
if(!$run{'dict'}) {
- ($pid, $pid2) = rundictserver($verbose, "", $DICTPORT);
+ ($pid, $pid2, $DICTPORT) = rundictserver($verbose, "");
if($pid <= 0) {
return "failed starting DICT server";
}
@@ -4956,7 +4961,7 @@ sub startservers {
}
elsif($what eq "smb") {
if(!$run{'smb'}) {
- ($pid, $pid2) = runsmbserver($verbose, "", $SMBPORT);
+ ($pid, $pid2, $SMBPORT) = runsmbserver($verbose, "");
if($pid <= 0) {
return "failed starting SMB server";
}
@@ -4967,9 +4972,8 @@ sub startservers {
}
elsif($what eq "telnet") {
if(!$run{'telnet'}) {
- ($pid, $pid2) = runnegtelnetserver($verbose,
- "",
- $NEGTELNETPORT);
+ ($pid, $pid2, $TELNETPORT) =
+ runnegtelnetserver($verbose, "");
if($pid <= 0) {
return "failed starting neg TELNET server";
}
@@ -5195,12 +5199,6 @@ while(@ARGV) {
# verbose output
$verbose=1;
}
- elsif($ARGV[0] =~ /^-b(.*)/) {
- my $portno=$1;
- if($portno =~ s/(\d+)$//) {
- $base = int $1;
- }
- }
elsif ($ARGV[0] eq "-c") {
# use this path to curl instead of default
$DBGCURL=$CURL="\"$ARGV[1]\"";
@@ -5322,7 +5320,6 @@ while(@ARGV) {
Usage: runtests.pl [options] [test selection(s)]
-a continue even if a test fails
-am automake style output PASS/FAIL: [number] [name]
- -bN use base port number N for test servers (default $base)
-c path use this curl executable
-d display server debug info
-e event-based execution
@@ -5470,18 +5467,8 @@ if ($gdbthis) {
}
}
-$minport = $base; # original base port number
-$HTTPTLSPORT = $base++; # HTTP TLS (non-stunnel) server port
-$HTTPTLS6PORT = $base++; # HTTP TLS (non-stunnel) IPv6 server port
-$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
-$maxport = $base-1; # updated base port number
-
#######################################################################
# clear and create logging directory:
#