summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2023-04-21 12:40:11 -0700
committerDan Fandrich <dan@coneharvesters.com>2023-04-24 16:03:44 -0700
commit8da49c9e3881fa93f29f244647a0c3985dce14a1 (patch)
tree61a9358c2ed847ace335c64de483c57498b73be0
parent90158f0bab4dedcfa98ce2d2ee47234f5ad2cdaa (diff)
downloadcurl-8da49c9e3881fa93f29f244647a0c3985dce14a1.tar.gz
runtests: display logs on server failure in singletest()
This is closer to the place where logs are displayed on test failure. Also, only display these logs if -p is given, which is the same flag that controls display of test failure logs. Some server log files need to be deleted later so that they stay around long enough to be displayed on failure. Ref: #10818
-rw-r--r--tests/runner.pm40
-rwxr-xr-xtests/runtests.pl11
2 files changed, 29 insertions, 22 deletions
diff --git a/tests/runner.pm b/tests/runner.pm
index b292a636a..a4851b8cf 100644
--- a/tests/runner.pm
+++ b/tests/runner.pm
@@ -98,13 +98,6 @@ sub logmsg {
}
#######################################################################
-# Call main's displaylogs
-# TODO: this will eventually stop being called in this package
-sub displaylogs{
- return main::displaylogs(@_);
-}
-
-#######################################################################
# Check for a command in the PATH of the machine running curl.
#
sub checktestcmd {
@@ -389,25 +382,31 @@ sub restore_test_env {
sub singletest_startservers {
my ($testnum, $testtimings) = @_;
- # remove test server commands file before servers are started/verified
- unlink($FTPDCMD) if(-f $FTPDCMD);
+ # remove old test server files before servers are started/verified
+ unlink($FTPDCMD);
+ unlink($SERVERIN);
+ unlink($SERVER2IN);
+ unlink($PROXYIN);
# timestamp required servers verification start
$$testtimings{"timesrvrini"} = Time::HiRes::time();
my $why;
+ my $error;
if (!$listonly) {
my @what = getpart("client", "server");
if(!$what[0]) {
warn "Test case $testnum has no server(s) specified";
$why = "no server specified";
+ $error = -1;
} else {
my $err;
($why, $err) = serverfortest(@what);
if($err == 1) {
- # Error indicates an actual problem starting the server, so
- # display the server logs
- displaylogs($testnum);
+ # Error indicates an actual problem starting the server
+ $error = -2;
+ } else {
+ $error = -1;
}
}
}
@@ -415,12 +414,7 @@ sub singletest_startservers {
# timestamp required servers verification end
$$testtimings{"timesrvrend"} = Time::HiRes::time();
- # remove server output logfile after servers are started/verified
- unlink($SERVERIN);
- unlink($SERVER2IN);
- unlink($PROXYIN);
-
- return $why;
+ return ($why, $error);
}
@@ -533,6 +527,11 @@ sub singletest_prepare {
}
unlink("core");
+ # remove server output logfiles after servers are started/verified
+ unlink($SERVERIN);
+ unlink($SERVER2IN);
+ unlink($PROXYIN);
+
# if this section exists, it might be FTP server instructions:
my @ftpservercmd = getpart("reply", "servercmd");
push @ftpservercmd, "Testnum $testnum\n";
@@ -915,7 +914,7 @@ sub runner_test_preprocess {
###################################################################
# Start the servers needed to run this test case
- my $why = singletest_startservers($testnum, \%testtimings);
+ my ($why, $error) = singletest_startservers($testnum, \%testtimings);
if(!$why) {
@@ -933,9 +932,10 @@ sub runner_test_preprocess {
# Check that the test environment is fine to run this test case
if (!$listonly) {
$why = singletest_precheck($testnum);
+ $error = -1;
}
}
- return ($why, \%testtimings);
+ return ($why, $error, \%testtimings);
}
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 0b29a4653..8cda319c1 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -1646,12 +1646,19 @@ sub singletest {
# Register the test case with the CI environment
citest_starttest($testnum);
- my ($why, $testtimings) = runner_test_preprocess($testnum);
+ my ($why, $error, $testtimings) = runner_test_preprocess($testnum);
+ if($error == -2) {
+ if($postmortem) {
+ # Error indicates an actual problem starting the server, so
+ # display the server logs
+ displaylogs($testnum);
+ }
+ }
updatetesttimings($testnum, %$testtimings);
#######################################################################
# Print the test name and count tests
- my $error = singletest_count($testnum, $why);
+ $error = singletest_count($testnum, $why);
if($error) {
return $error;
}