runtests: improve XML prolog check, enable -w permanently, fix two tests

To really verify the presence of the XML prolog, also in CI.

- move the prolog check from `loadtest` to `checktest`.
  (load did a soft error, silently skipping the test instead of failing)
- runtests: enable `-w` functionality permanently for all test targets,
  drop the option. It has no measurable performance impact.
- test 798, 1665: add XML prolog.
  Follow-up to f0d277cb0e

Follow-up to b5ea0736bb #19946
Follow-up to 904e7ecb66 #19347

Closes #19970
This commit is contained in:
Viktor Szakats 2025-12-14 09:42:59 +01:00
parent b714c674f3
commit 187e219616
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
9 changed files with 24 additions and 38 deletions

View file

@ -298,10 +298,6 @@ Enable verbose output. Speaks more than by default. If used in conjunction
with parallel testing, it is difficult to associate the logs with the specific
test being run.
## `-w`
Verify test data.
## `-vc \<curl\>`
Provide a path to a custom curl binary to run when verifying that the servers

View file

@ -120,15 +120,15 @@ configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/configurehelp.pm.in"
"${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" @ONLY)
curl_add_runtests(tests "-a -w") # Avoid 'test', which is a reserved target name in CMake
curl_add_runtests(test-quiet "-a -w -s")
curl_add_runtests(test-am "-a -w -am")
curl_add_runtests(test-full "-a -w -p -r")
curl_add_runtests(tests "-a") # Avoid 'test', which is a reserved target name in CMake
curl_add_runtests(test-quiet "-a -s")
curl_add_runtests(test-am "-a -am")
curl_add_runtests(test-full "-a -p -r")
# ~flaky means that it ignores results of tests using the flaky keyword
curl_add_runtests(test-nonflaky "-a -w -p ~flaky ~timing-dependent")
curl_add_runtests(test-nonflaky "-a -p ~flaky ~timing-dependent")
curl_add_runtests(test-ci "-a -p ~flaky ~timing-dependent -r --retry=5 -j20 --buildinfo")
curl_add_runtests(test-torture "-a -w -t -j20")
curl_add_runtests(test-event "-a -w -e")
curl_add_runtests(test-torture "-a -t -j20")
curl_add_runtests(test-event "-a -e")
curl_add_pytests(curl-pytest "-n auto")
curl_add_pytests(curl-pytest-ci "-n auto -v")

View file

@ -118,18 +118,18 @@ TEST_COMMON += !documentation
endif
TEST = srcdir=$(srcdir) @PERL@ $(PERLFLAGS) $(srcdir)/runtests.pl $(TEST_COMMON)
TEST_Q = -a -w -s
TEST_AM = -a -w -am
TEST_F = -a -w -p -r
TEST_T = -a -w -t -j20
TEST_E = -a -w -e
TEST_Q = -a -s
TEST_AM = -a -am
TEST_F = -a -p -r
TEST_T = -a -t -j20
TEST_E = -a -e
# ~<keyword> means that it runs all tests matching the keyword, but ignores
# their results (since these ones are likely to fail for no good reason)
TEST_NF = -a -w -p ~flaky ~timing-dependent
TEST_NF = -a -p ~flaky ~timing-dependent
# special target for CI use
TEST_CI = -a -p ~flaky ~timing-dependent -r --retry=5 -j20 --buildinfo
TEST_CI = $(TEST_NF) -r --retry=5 -j20 --buildinfo
PYTEST = pytest
endif

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
@ -5,7 +6,6 @@ HTTP
</keywords>
</info>
#
# Server-side
<reply>
<data>
@ -22,7 +22,6 @@ Funny-head: swsclose
</data>
</reply>
#
# Client-side
<client>
<server>
@ -36,7 +35,6 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<protocol crlf="headers">

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
@ -7,9 +8,8 @@ cookies
cookiejar
</keywords>
</info>
# Server-side
#
# Server-side
<reply>
<data crlf="headers" nocheck="yes">
HTTP/1.1 200 OK

View file

@ -244,12 +244,6 @@ sub loadtest {
print STDERR "file $file is empty!\n";
return 1;
}
my $prolog = $xml[0];
chomp $prolog;
if($prolog ne '<?xml version="1.0" encoding="US-ASCII"?>') {
print STDERR "file $file missing the XML prolog!\n";
return 1;
}
}
else {
# failure
@ -297,6 +291,11 @@ sub checktest {
my $content = do { local $/; <$xmlh> };
close($xmlh);
if(index($content, '<?xml version="1.0" encoding="US-ASCII"?>') != 0) {
print STDERR "*** getpart.pm: $xmlfile is missing the XML prolog.\n";
return 1;
}
my $eol = eol_detect($content);
if($eol eq '') {
print STDERR "*** getpart.pm: $xmlfile has mixed newlines. Replace significant carriage return with %CR macro, or convert to consistent newlines.\n";

View file

@ -75,7 +75,6 @@ BEGIN {
%keywords
@protocols
$dev_null
$checktests
);
}
use pathhelp qw(
@ -96,7 +95,6 @@ our $torture; # 1 to enable torture testing
our $proxy_address; # external HTTP proxy address
our $listonly; # only list the tests
our $buildinfo; # dump buildinfo.txt
our $checktests; # 1 to run a check on test data
our $run_duphandle; # run curl with --test-duphandle to verify handle duplication
our $run_event_based; # run curl with --test-event to test the event API
our $automakestyle; # use automake-like test status output format

View file

@ -1162,7 +1162,7 @@ sub singletest_postcheck {
}
}
if($checktests && checktest("${TESTDIR}/test${testnum}")) {
if(checktest("${TESTDIR}/test${testnum}")) {
logmsg " $testnum: postcheck FAILED: issue(s) found in test data\n";
return -1;
}

View file

@ -1179,7 +1179,7 @@ sub singletest_shouldrun {
}
}
if($why && $checktests && checktest("${TESTDIR}/test${testnum}")) {
if($why && checktest("${TESTDIR}/test${testnum}")) {
logmsg "Warning: issue(s) found in test data: ${TESTDIR}/test${testnum}\n";
}
@ -2419,10 +2419,6 @@ while(@ARGV) {
# execute in scrambled order
$scrambleorder=1;
}
elsif($ARGV[0] eq "-w") {
# verify test data
$checktests=1;
}
elsif($ARGV[0] =~ /^-t(.*)/) {
# torture
$torture=1;
@ -2568,7 +2564,6 @@ Usage: runtests.pl [options] [test selection(s)]
-u error instead of warning on server unexpectedly alive
-v verbose output
-vc path use this curl only to verify the existing servers
-w check test data
[num] like "5 6 9" or " 5 to 22 " to run those tests only
[!num] like "!5 !6 !9" to disable those tests
[~num] like "~5 ~6 ~9" to ignore the result of those tests