aboutsummaryrefslogtreecommitdiff
path: root/tests/runtests.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runtests.pl')
-rwxr-xr-xtests/runtests.pl160
1 files changed, 125 insertions, 35 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 9afc97df0..8b3ba67d8 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -168,6 +168,7 @@ my $proxy_address;
my %custom_skip_reasons;
my $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key
+my $SSHSRVSHA256 = "[uninitialized]"; # SHA256 of ssh server public key
my $VERSION=""; # curl's reported version number
my $srcdir = $ENV{'srcdir'} || '.';
@@ -340,6 +341,7 @@ my $keepoutfiles; # keep stdout and stderr files after tests
my $clearlocks; # force removal of files by killing locking processes
my $listonly; # only list the tests
my $postmortem; # display detailed info about failed tests
+my $err_unexpected; # error instead of warning on server unexpectedly alive
my $run_event_based; # run curl with --test-event to test the event API
my $run_disabeled; # run the specific tests even if listed in DISABLED
@@ -496,6 +498,9 @@ sub startnew {
if(0 == $child) {
# Here we are the child. Run the given command.
+ # Flush output.
+ $| = 1;
+
# Put an "exec" in front of the command so that the child process
# keeps this child's process ID.
exec("exec $cmd") || die "Can't exec() $cmd: $!";
@@ -840,15 +845,25 @@ sub stopserver {
#
# cleanup server pid files
#
+ my $result = 0;
foreach my $server (@killservers) {
my $pidfile = $serverpidfile{$server};
my $pid = processexists($pidfile);
if($pid > 0) {
- logmsg "Warning: $server server unexpectedly alive\n";
+ if($err_unexpected) {
+ logmsg "ERROR: ";
+ $result = -1;
+ }
+ else {
+ logmsg "Warning: ";
+ }
+ logmsg "$server server unexpectedly alive\n";
killpid($verbose, $pid);
}
unlink($pidfile) if(-f $pidfile);
}
+
+ return $result;
}
#######################################################################
@@ -1691,7 +1706,6 @@ sub runhttpsserver {
}
my $pid2;
- my $pid3;
my $httpspid;
my $port = 24512; # start attempt
for (1 .. 10) {
@@ -1862,7 +1876,6 @@ sub runpingpongserver {
$doesntrun{$pidfile} = 1;
return (0,0);
}
-
$pid2 = $pid3;
logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verbose);
@@ -1957,10 +1970,9 @@ sub runftpsserver {
$flags .= "--stunnel \"$stunnel\" --srcdir \"$srcdir\" ";
$flags .= "--connect $FTPPORT";
- my $port = 26713;
- my $pid2;
- my $pid3;
my $ftpspid;
+ my $pid2;
+ my $port = 26713;
for (1 .. 10) {
$port += int(rand(700));
my $options = "$flags --accept $port";
@@ -2276,6 +2288,17 @@ sub runsshserver {
die $msg;
}
+ my $hstpubsha256f = "curl_host_rsa_key.pub_sha256";
+ if(!open(PUBSHA256FILE, "<", $hstpubsha256f) ||
+ (read(PUBSHA256FILE, $SSHSRVSHA256, 48) == 0) ||
+ !close(PUBSHA256FILE))
+ {
+ my $msg = "Fatal: $srvrname pubkey sha256 missing : \"$hstpubsha256f\" : $!";
+ logmsg "$msg\n";
+ stopservers($verbose);
+ die $msg;
+ }
+
logmsg "RUN: $srvrname on PID $pid2 port $wport\n" if($verbose);
return ($pid2, $sshpid, $wport);
@@ -3363,6 +3386,7 @@ sub subVariables {
$$thing =~ s/${prefix}USER/$USER/g;
$$thing =~ s/${prefix}SSHSRVMD5/$SSHSRVMD5/g;
+ $$thing =~ s/${prefix}SSHSRVSHA256/$SSHSRVSHA256/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
@@ -4111,6 +4135,9 @@ sub singletest {
close(GDBCMD);
}
+ # Flush output.
+ $| = 1;
+
# timestamp starting of test command
$timetoolini{$testnum} = Time::HiRes::time();
@@ -4199,7 +4226,9 @@ sub singletest {
if(@killtestservers) {
foreach my $server (@killtestservers) {
chomp $server;
- stopserver($server);
+ if(stopserver($server)) {
+ return 1; # normal error if asked to fail on unexpected alive
+ }
}
}
@@ -4707,15 +4736,25 @@ sub stopservers {
#
# cleanup all server pid files
#
+ my $result = 0;
foreach my $server (keys %serverpidfile) {
my $pidfile = $serverpidfile{$server};
my $pid = processexists($pidfile);
if($pid > 0) {
- logmsg "Warning: $server server unexpectedly alive\n";
+ if($err_unexpected) {
+ logmsg "ERROR: ";
+ $result = -1;
+ }
+ else {
+ logmsg "Warning: ";
+ }
+ logmsg "$server server unexpectedly alive\n";
killpid($verbose, $pid);
}
unlink($pidfile) if(-f $pidfile);
}
+
+ return $result;
}
#######################################################################
@@ -4742,7 +4781,9 @@ sub startservers {
($what eq "smtp")) {
if($torture && $run{$what} &&
!responsive_pingpong_server($what, "", $verbose)) {
- stopserver($what);
+ if(stopserver($what)) {
+ return "failed stopping unresponsive ".uc($what)." server";
+ }
}
if(!$run{$what}) {
($pid, $pid2) = runpingpongserver($what, "", $verbose);
@@ -4756,7 +4797,9 @@ sub startservers {
elsif($what eq "ftp-ipv6") {
if($torture && $run{'ftp-ipv6'} &&
!responsive_pingpong_server("ftp", "", $verbose, "ipv6")) {
- stopserver('ftp-ipv6');
+ if(stopserver('ftp-ipv6')) {
+ return "failed stopping unresponsive FTP-IPv6 server";
+ }
}
if(!$run{'ftp-ipv6'}) {
($pid, $pid2) = runpingpongserver("ftp", "", $verbose, "ipv6");
@@ -4771,7 +4814,9 @@ sub startservers {
elsif($what eq "gopher") {
if($torture && $run{'gopher'} &&
!responsive_http_server("gopher", $verbose, 0, $GOPHERPORT)) {
- stopserver('gopher');
+ if(stopserver('gopher')) {
+ return "failed stopping unresponsive GOPHER server";
+ }
}
if(!$run{'gopher'}) {
($pid, $pid2, $GOPHERPORT) =
@@ -4788,7 +4833,9 @@ sub startservers {
if($torture && $run{'gopher-ipv6'} &&
!responsive_http_server("gopher", $verbose, "ipv6",
$GOPHER6PORT)) {
- stopserver('gopher-ipv6');
+ if(stopserver('gopher-ipv6')) {
+ return "failed stopping unresponsive GOPHER-IPv6 server";
+ }
}
if(!$run{'gopher-ipv6'}) {
($pid, $pid2, $GOPHER6PORT) =
@@ -4815,7 +4862,9 @@ sub startservers {
elsif($what eq "http") {
if($torture && $run{'http'} &&
!responsive_http_server("http", $verbose, 0, $HTTPPORT)) {
- stopserver('http');
+ if(stopserver('http')) {
+ return "failed stopping unresponsive HTTP server";
+ }
}
if(!$run{'http'}) {
($pid, $pid2, $HTTPPORT) =
@@ -4832,7 +4881,9 @@ sub startservers {
if($torture && $run{'http-proxy'} &&
!responsive_http_server("http", $verbose, "proxy",
$HTTPPROXYPORT)) {
- stopserver('http-proxy');
+ if(stopserver('http-proxy')) {
+ return "failed stopping unresponsive HTTP-proxy server";
+ }
}
if(!$run{'http-proxy'}) {
($pid, $pid2, $HTTPPROXYPORT) =
@@ -4848,7 +4899,9 @@ sub startservers {
elsif($what eq "http-ipv6") {
if($torture && $run{'http-ipv6'} &&
!responsive_http_server("http", $verbose, "ipv6", $HTTP6PORT)) {
- stopserver('http-ipv6');
+ if(stopserver('http-ipv6')) {
+ return "failed stopping unresponsive HTTP-IPv6 server";
+ }
}
if(!$run{'http-ipv6'}) {
($pid, $pid2, $HTTP6PORT) =
@@ -4864,7 +4917,9 @@ sub startservers {
elsif($what eq "rtsp") {
if($torture && $run{'rtsp'} &&
!responsive_rtsp_server($verbose)) {
- stopserver('rtsp');
+ if(stopserver('rtsp')) {
+ return "failed stopping unresponsive RTSP server";
+ }
}
if(!$run{'rtsp'}) {
($pid, $pid2, $RTSPPORT) = runrtspserver($verbose);
@@ -4878,7 +4933,9 @@ sub startservers {
elsif($what eq "rtsp-ipv6") {
if($torture && $run{'rtsp-ipv6'} &&
!responsive_rtsp_server($verbose, "ipv6")) {
- stopserver('rtsp-ipv6');
+ if(stopserver('rtsp-ipv6')) {
+ return "failed stopping unresponsive RTSP-IPv6 server";
+ }
}
if(!$run{'rtsp-ipv6'}) {
($pid, $pid2, $RTSP6PORT) = runrtspserver($verbose, "ipv6");
@@ -4897,11 +4954,15 @@ sub startservers {
}
if($runcert{'ftps'} && ($runcert{'ftps'} ne $certfile)) {
# stop server when running and using a different cert
- stopserver('ftps');
+ if(stopserver('ftps')) {
+ return "failed stopping FTPS server with different cert";
+ }
}
if($torture && $run{'ftp'} &&
!responsive_pingpong_server("ftp", "", $verbose)) {
- stopserver('ftp');
+ if(stopserver('ftp')) {
+ return "failed stopping unresponsive FTP server";
+ }
}
if(!$run{'ftp'}) {
($pid, $pid2) = runpingpongserver("ftp", "", $verbose);
@@ -4932,11 +4993,15 @@ sub startservers {
}
if($runcert{'https'} && ($runcert{'https'} ne $certfile)) {
# stop server when running and using a different cert
- stopserver('https');
+ if(stopserver('https')) {
+ return "failed stopping HTTPS server with different cert";
+ }
}
if($torture && $run{'http'} &&
!responsive_http_server("http", $verbose, 0, $HTTPPORT)) {
- stopserver('http');
+ if(stopserver('http')) {
+ return "failed stopping unresponsive HTTP server";
+ }
}
if(!$run{'http'}) {
($pid, $pid2, $HTTPPORT) =
@@ -4965,11 +5030,15 @@ sub startservers {
}
if($runcert{'gophers'} && ($runcert{'gophers'} ne $certfile)) {
# stop server when running and using a different cert
- stopserver('gophers');
+ if(stopserver('gophers')) {
+ return "failed stopping GOPHERS server with different crt";
+ }
}
if($torture && $run{'gopher'} &&
!responsive_http_server("gopher", $verbose, 0, $GOPHERPORT)) {
- stopserver('gopher');
+ if(stopserver('gopher')) {
+ return "failed stopping unresponsive GOPHER server";
+ }
}
if(!$run{'gopher'}) {
($pid, $pid2, $GOPHERPORT) =
@@ -5001,7 +5070,9 @@ sub startservers {
if($runcert{'https-proxy'} &&
($runcert{'https-proxy'} ne $certfile)) {
# stop server when running and using a different cert
- stopserver('https-proxy');
+ if(stopserver('https-proxy')) {
+ return "failed stopping HTTPS-proxy with different cert";
+ }
}
# we front the http-proxy with stunnel so we need to make sure the
@@ -5029,7 +5100,9 @@ sub startservers {
}
if($torture && $run{'httptls'} &&
!responsive_httptls_server($verbose, "IPv4")) {
- stopserver('httptls');
+ if(stopserver('httptls')) {
+ return "failed stopping unresponsive HTTPTLS server";
+ }
}
if(!$run{'httptls'}) {
($pid, $pid2, $HTTPTLSPORT) =
@@ -5049,7 +5122,9 @@ sub startservers {
}
if($torture && $run{'httptls-ipv6'} &&
!responsive_httptls_server($verbose, "ipv6")) {
- stopserver('httptls-ipv6');
+ if(stopserver('httptls-ipv6')) {
+ return "failed stopping unresponsive HTTPTLS-IPv6 server";
+ }
}
if(!$run{'httptls-ipv6'}) {
($pid, $pid2, $HTTPTLS6PORT) =
@@ -5065,7 +5140,9 @@ sub startservers {
elsif($what eq "tftp") {
if($torture && $run{'tftp'} &&
!responsive_tftp_server("", $verbose)) {
- stopserver('tftp');
+ if(stopserver('tftp')) {
+ return "failed stopping unresponsive TFTP server";
+ }
}
if(!$run{'tftp'}) {
($pid, $pid2, $TFTPPORT) =
@@ -5080,7 +5157,9 @@ sub startservers {
elsif($what eq "tftp-ipv6") {
if($torture && $run{'tftp-ipv6'} &&
!responsive_tftp_server("", $verbose, "ipv6")) {
- stopserver('tftp-ipv6');
+ if(stopserver('tftp-ipv6')) {
+ return "failed stopping unresponsive TFTP-IPv6 server";
+ }
}
if(!$run{'tftp-ipv6'}) {
($pid, $pid2, $TFTP6PORT) =
@@ -5125,7 +5204,9 @@ sub startservers {
elsif($what eq "http-unix") {
if($torture && $run{'http-unix'} &&
!responsive_http_server("http", $verbose, "unix", $HTTPUNIXPATH)) {
- stopserver('http-unix');
+ if(stopserver('http-unix')) {
+ return "failed stopping unresponsive HTTP-unix server";
+ }
}
if(!$run{'http-unix'}) {
my $unused;
@@ -5158,7 +5239,7 @@ sub startservers {
}
logmsg sprintf ("* pid SMB => %d %d\n", $pid, $pid2)
if($verbose);
- $run{'dict'}="$pid $pid2";
+ $run{'smb'}="$pid $pid2";
}
}
elsif($what eq "telnet") {
@@ -5170,7 +5251,7 @@ sub startservers {
}
logmsg sprintf ("* pid neg TELNET => %d %d\n", $pid, $pid2)
if($verbose);
- $run{'dict'}="$pid $pid2";
+ $run{'telnet'}="$pid $pid2";
}
}
elsif($what eq "none") {
@@ -5548,6 +5629,10 @@ while(@ARGV) {
# force removal of files by killing locking processes
$clearlocks=1;
}
+ elsif($ARGV[0] eq "-u") {
+ # error instead of warning on server unexpectedly alive
+ $err_unexpected=1;
+ }
elsif(($ARGV[0] eq "-h") || ($ARGV[0] eq "--help")) {
# show help text
print <<EOHELP
@@ -5577,6 +5662,7 @@ Usage: runtests.pl [options] [test selection(s)]
--seed=[num] set the random seed to a fixed number
--shallow=[num] randomly makes the torture tests "thinner"
-t[N] torture (simulate function failures); N means fail Nth function
+ -u error instead of warning on server unexpectedly alive
-v verbose output
-vc path use this curl only to verify the existing servers
[num] like "5 6 9" or " 5 to 22 " to run those tests only
@@ -5943,6 +6029,7 @@ if(azure_check_environment()) {
#
my $failed;
+my $failedign;
my $testnum;
my $ok=0;
my $ign=0;
@@ -5978,8 +6065,8 @@ foreach $testnum (@at) {
if($error>0) {
if($error==2) {
- # ignored test failures are wrapped in ()
- $failed.= "($testnum) ";
+ # ignored test failures
+ $failedign .= "$testnum ";
}
else {
$failed.= "$testnum ";
@@ -6015,7 +6102,7 @@ if(azure_check_environment() && $AZURE_RUN_ID) {
}
# Tests done, stop the servers
-stopservers($verbose);
+my $unexpected = stopservers($verbose);
my $all = $total + $skipped;
@@ -6065,6 +6152,9 @@ if($skipped && !$short) {
}
if($total) {
+ if($failedign) {
+ logmsg "IGNORED: failed tests: $failedign\n";
+ }
logmsg sprintf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
$ok/$total*100);
@@ -6083,6 +6173,6 @@ else {
}
}
-if(($total && (($ok+$ign) != $total)) || !$total) {
+if(($total && (($ok+$ign) != $total)) || !$total || $unexpected) {
exit 1;
}