6524 Commits

Author SHA1 Message Date
Stefan Eissing
ff37657e4d
cpool/cshutdown: force close connections under pressure
when CURLMOPT_MAX_HOST_CONNECTIONS or CURLMOPT_MAX_TOTAL_CONNECTIONS
limits are reached, force close connections in shutdown to go below
limit when possible.

Fixes #17020
Reported-by: Fujii Hironori
Closes #17022
2025-04-11 22:46:56 +02:00
Daniel Stenberg
9f8bdd0eae
tool_parsecfg: make get_line handle lines ending on the buffer boundary
Add test 743 to verify.

Fixes #17030
Reported-by: Marius Kleidl
Closes #17031
2025-04-11 22:38:49 +02:00
Viktor Szakats
0e8bf75b5c
tests: require IPv6 for 1265, 1324, 2086
And also require HTTP. Also add `IPv6` to the keywords.

Fixing:

Linux AM openssl !ipv6 !--libcurl:
```
FAIL 1265: 'NO_PROXY with IPv6 numerical address' HTTP, HTTP proxy, http_proxy, NO_PROXY, noproxy
FAIL 1324: 'HTTP with --resolve and [ipv6address]' HTTP, HTTP GET, --resolve
FAIL 2086: 'Pre-request callback for HTTP IPv6' HTTP, IPv6
```
Ref: https://github.com/curl/curl/actions/runs/14378524385/job/40318328714?pr=17012#step:41:3789

Follow-up to a09e49168aae63640868b4fb9fa55eb384ff41c7 #17005

Closes #17014
2025-04-10 16:24:52 +02:00
Daniel Stenberg
a09e49168a
runtests: remove server verification after start
Since we start the server on our own port we know the server running is
us. By removing unnecessary verification we speed up tests a little.

Closes #17005
2025-04-10 09:12:49 +02:00
Stefan Eissing
219302b4e6
openssl-quic: fix shutdown when stream not open
Check that h3 stream had been opened before telling nghttp3 to
shut it down.

Fixes #16998
Reported-by: Demi Marie Obenour
Closes #17003
2025-04-10 08:38:58 +02:00
Viktor Szakats
2485a2d100
tests/ech_tests.sh: sync shebang with rest of bash scripts
Closes #17001
2025-04-10 01:42:59 +02:00
Viktor Szakats
3c868fbf7f
certs: drop unused default_bits from .prm files
Cert generation do not use these default values, some were also low,
and they were RSA-specific, and the generator recently switched to ECC.

Closes #16999
2025-04-10 01:42:59 +02:00
Daniel Stenberg
461ebbd336
tests/tunit: make a separate directory for tool-based unit tests
Separated from library based unit tests to not confuse memory management
etc. Move 1394 and 1604 there.

Closes #16983
2025-04-08 08:08:05 +02:00
Viktor Szakats
04c78c897b
curl_multibyte: fixup low-level calls, include in unity builds
Also adjust `()` around low-level calls preventing macro overrides via
e.g. `memdebug.h`:
- add for `malloc` and `free`.
- drop for `_open`. (We do not override `_open` in curl.)

Tidy-up: also sync libcurlu custom macro order in cmake with autotools.

Follow-up to f42a279ee32d3db3ab529da8dfb833edb5a088ca #11928

Closes #16742
2025-04-07 22:33:24 +02:00
Yedaya Katsman
8988f33f62
tests: Add https-mtls server to force client auth
- test2088 verifies that mutual tls works

This adds a new certificate to generate which has the clientAuth key
usage enabled, and uses it to connect to a https-mtls server.

Closes #16923
2025-04-07 08:46:56 +02:00
Yedaya Katsman
0f201d41d9
tests: removes CApath in stunnel
It wasn't used, and didn't do anything since the folder it got didn't
have files with names of the hash of the subjects. [1]

[1] https://www.stunnel.org/static/stunnel.html#CApath-CA_DIRECTORY

Closes #16923
2025-04-07 08:46:31 +02:00
Daniel Stenberg
d3761bb840
make: clean tests better
1. 'make clean' in the root dir now also invokes 'make clean' in the
tests subdir so that it cleans up better recursively. The Makefile.am
does not list 'tests' as a normal subdir to avoid building that
directory for a normal make invoke.

2. 'make clean' in the tests/libtest and tests/unit directories now
*explicitly* remove the unity build executables even if this is not a
unit build. This, because those files may be leftovers from previous
builds and such leftovers can otherwise linger around and since
'runtests.pl' dynamically acts differently based on the mere *presence*
of those files, they can keep you fooled for a while until you
realize...

Closes #16986
2025-04-06 13:12:55 +02:00
Daniel Stenberg
b676ae3b2a
CURLOPT_HTTP_TRANSFER_DECODING: fixed
The fix in b8bd019c6a02182 (#16959) broke the
CURLOPT_HTTP_TRANSFER_DECODING handling, shown in test 319 and curl's
--raw option.

This is a follow-up that restores the functionality.

Enable test 319 again.

Fixes #16974
Closes #16984
2025-04-06 11:31:22 +02:00
Daniel Stenberg
badfb951ec
test1658: add unit test for the HTTPS RR decoder
Made the HTTPS-RR parser a little stricter while at it.

Drop the ALPN escape handling, that was not needed.

Make the hode handle (and ignore) duplicate ALPN entries.

Closes #16972
2025-04-05 21:03:47 +02:00
Daniel Stenberg
72f9133311
tests/globalconfig.pm: remove the qw
Fixes the warning.

Fixes #16976
Closes #16977
2025-04-05 18:25:34 +02:00
Daniel Stenberg
b8bd019c6a
content_encoding: Transfer-Encoding parser improvements
- allow and ignore "identity" as an encoding

- fail if any other encoder than chunked follows after chunked

- fail on unsolicited encodings - when the server encodes but curl did
  not ask for it

Add test 1493 to 1496 to verify.

Disable test 319 as that is now broken: issue #16974

Reported-by: Jonathan Rosa
Fixes #16956
Closes #16959
2025-04-05 18:23:07 +02:00
Daniel Stenberg
3454844f36
libtest/first: stop defining MEMDEBUG_NODEFINES
It causes problems in unity builds, in particular when this file is used
for unit tests.

Bonus: switch to plain getenv() instead of curl_getenv() to avoid extra
malloc/free rounds.

Closes #16978
2025-04-05 18:20:22 +02:00
Stefan Eissing
5fbd78eb2d
http2: fix stream window size after unpausing
When pausing a HTTP/2 transfer, the stream's local window size
is reduced to 0 to prevent the server from sending further data
which curl cannot write out to the application.

When unpausing again, the stream's window size was not correctly
increased again. The attempt to trigger a window update was
ignored by nghttp2, the server never received it and the transfer
stalled.

Add a debug feature to allow use of small window sizes which
reproduces this bug in test_02_21.

Fixes #16955
Closes #16960
2025-04-05 14:54:40 +02:00
Dan Fandrich
dac78ae638 tests: remove some unused test case sections 2025-04-04 13:23:31 -07:00
Dan Fandrich
cbb80f215e tests: unify test case keywords
Unify the case, punctuation and name of test case keywords so they can
be more easily selected or skipped when desired. Add a few keywords that
were missing. Fix a couple of typos in test names.
2025-04-04 13:23:15 -07:00
Dan Fandrich
0e9f2c41b6 tests: fix some test tag mismatches 2025-04-04 09:17:08 -07:00
Dan Fandrich
b117d2cacf tests: move a boolean variable out of the path section 2025-04-04 08:42:43 -07:00
Jay Satiro
997e55d5a7 tests: use a more portable null device path
- Use File::Spec->devnull() to get the null device path.

Prior to this change we used NUL for Windows native perl and /dev/null
otherwise.

Bug: https://github.com/curl/curl/pull/16929#discussion_r2025718160
Reported-by: Viktor Szakats

Closes https://github.com/curl/curl/pull/16930
2025-04-04 03:40:47 -04:00
Viktor Szakats
c6bd2e6a9a
tests: prefer --insecure over -k
To make it uniform in all tests, and greppability.

Also:
- replace `-k` flag with `-q` in test 1268. (the actual flag doesn't
  matter in this test)
- keep `-k` in test 300 to test its short form.
  (also verified to fail without a working `-k`)

Closes #16878
2025-04-03 23:18:55 +02:00
Daniel Stenberg
7e0eea7d7b
tests: mark ipfs tests to require ipfs
Fixes #16947
Reported-by: Daniel Engberg
Closes #16948
2025-04-03 19:55:01 +02:00
Daniel Stenberg
681df5ec51
tests/README.md: document --test-duphandle
Follow-up to cbafcec50bc99ba0dd0490e6

Closes #16944
2025-04-03 17:23:58 +02:00
Stefan Eissing
9b6148e9d9
async-threaded resolver: use ref counter
Allocate the data shared between a transfer and an aync resolver thread
separately and use a reference counter to determine its release.

Change `Curl_thread_destroy()` to clear the thread handle, so that the
thread is considered "gone" and we do not try to join (and fail to)
afterwards.

Retake of the revert in fb15a986c0d947ae6b9dd6

Closes #16916
2025-04-03 16:43:37 +02:00
Stefan Eissing
01e76702ac
dnscache: slight refactoring
Slight refactoring around dnscache, e.g. hostcache

- eliminate `data->state.hostcache`. Always look up
  relevant dnscache at share/multi.
- unify naming to "dnscache", replacing "hostcache"
- use `struct Curl_dnscache`, even though it just
  contains a `Curl_hash` for now.
- add `Curl_dnscache_destroy()` for cleanup in
  share/multi.

Closes #16941
2025-04-03 16:40:56 +02:00
Daniel Stenberg
6140a574de
tests/README.md: list the openssl tool among the prerequisites
Used for test cert generation since 8.13.0

Closes #16942
2025-04-03 16:25:29 +02:00
Viktor Szakats
3d4e4a1874
genserv.pl: fail with a message if openssl is missing or failing
Reported-by: Tomas Volf
Fixes #16926
Follow-up to 44341e736a3e2f7a2b25a774be3a9796e81abab9 #16824
Ref: #16928
Co-authored-by: Daniel Stenberg
Closes #16929
2025-04-03 14:17:37 +02:00
Daniel Stenberg
daa8693619
VERSIONS: list all past releases
This document now lists all previous releases.

This allows us to verify that documentation refers to actual release
versions.

Test 971 now verifies options-in-versions and all command line options
documentation individually. Fixed a few discrepancies.

Test 1488 verifies libcurl options "Added-in" to exist. Fixed a few
discrepancies there as well.

Closes #16907
2025-04-03 08:26:33 +02:00
Yedaya Katsman
878d1fc340
tests/serverhelp: remove last remnants of http-pipe server
Followup on https://github.com/curl/curl/pull/5921

Closes #16924
2025-04-02 22:46:53 +02:00
Daniel Stenberg
8a45c2851a
lib1960: revert the use of libcurl's inet_pton
Since it now uses hex conversion code from strparse as well.

Closes #16888
2025-04-02 14:17:56 +02:00
Daniel Stenberg
1d84d683bb
test: make unittest 1308 into a libtest
Test 1308 was wrongly marked a unit test when in reality it is a
libtest.

Closes #16891
2025-04-02 14:01:27 +02:00
Viktor Szakats
202a333e4d
processhelp.pm: avoid potential endless loop, log more (Windows)
`pidwait()` is a function to wait for a PID to disappear from the list
of processes. On Windows change this function to:

- reduce the frequency of calling the external command `tasklist` to
  query the list of processes, including Windows-native ones, to 0.2s
  (from 0.01s).

- print a message when the wait exceeds 5 second marks.

- give up after 20 seconds of total wait, and print a message.

Also log `taskkill` commands to stdout instead of the log.

To potentially avoid hangs seen in CI, and make these spots more
transparent through the log.

Ref: #16840
Ref: #14854

Closes #16908
2025-04-02 12:54:46 +02:00
Viktor Szakats
fddc7a67ea
tests/README: document test bundles
Closes #16902
2025-04-01 12:48:04 +02:00
Viktor Szakats
93964c21f4
runtests: fix bundled test invocation with -g option
Fixes:
```
$ ./runtests.pl -g 1940
./libtest/libtests lib1940: No such file or directory.
Argument list to give program being debugged when it is started is "http://127.0.0.1:44547/1940".
```

Reported-by: Daniel Stenberg
Fixes #16893
Closes #16898
2025-04-01 11:46:17 +02:00
Daniel Stenberg
66c95f05fa
tests/certs/Makefile.am: avoid superfluous cert re-generation
Fixes #16897
Closes #16899
2025-04-01 11:29:14 +02:00
Daniel Stenberg
c31dd6631f
urlapi: remove percent encoded dot sequences from the URL path
Treat %2e and %2E to be "dot equivalents" in the function and remove
such sequences as well, according to RFC 3986 section 5.2.4. That is
also what the browsers do.

This DOES NOT consider %2f sequences in the path to be actual slashes,
so there is no removal of dots for those.

This function does not decode nor encode any percent sequences.

Also switched the code to use dynbuf.

Extends test 1395 and 1560 to verify.

Assisted-by: Demi Marie Obenour

Fixes #16869
Closes #16870
2025-03-31 08:52:26 +02:00
Austin Moore
3978bd4498
aws_sigv4: merge repeated headers in canonical request
When multiple headers share the same name, AWS SigV4 expects them to be
merged into a single header line, with values comma-delimited in the
order they appeared.

Add libtest 1978 to verify.

Closes #16743
2025-03-31 00:01:55 +02:00
Viktor Szakats
fb4dbbac4a
build: drop build-certs as a test-run dependency
After adding it as a test executables dependency, it run twice in
MSBuild jobs. Also there is little reason to try building them in both
build and run tests targets.

(The reason MSBuild building it twice, is our use of
`TrackFileAccess=false` to improve build performance.)

https://github.com/curl/curl/actions/runs/14156797251/job/39662914155?pr=16840#step:15:31

Follow-up to 68609f0e334359875a2f62735377174ab6b873dd #16866
Follow-up to 0c1ad21f978c8f5acf3d0c1708d83a93635d9df3 #16845

Closes #16876
2025-03-30 23:36:18 +02:00
Viktor Szakats
3e2860f66d
genserv.pl: detect openssl in PATH, omit command -v
Before this patch the script relied on Perl `system()` finding `openssl`
in `PATH`, plus tried to display the full path of `openssl` by using
`command -v` (or `which` on Windows). `command -v` did not work in CI
for unknown reasons. To resolve it, this patch detects `openssl` in
`PATH` manually, displays the detected full path and calls `openssl`
with the detected full path, and stops relying on `system` for this.

It also follows how `sshhelp.pm` is detecting executables. Though this
patch uses Perl `-f` instead of `-e && -d` used there .

Silencing this in CI logs:
```
Can't exec "command": No such file or directory at ../../../tests/certs/genserv.pl line 51.
```
Ref: https://github.com/curl/curl/actions/runs/14145795884/job/39632942668?pr=16865#step:39:108

Closes #16868
2025-03-30 23:36:18 +02:00
Daniel Stenberg
8579cf4016
lib1560: test set path containing LR or CR
Ref: #16874
Closes #16875
2025-03-30 23:32:48 +02:00
Daniel Stenberg
bc26289d37
libtest/first.c: remove the Test: stderr output for unity builds
That makes the output differ between builds which breaks libtests doing
stderr comparisons

Closes #16872
2025-03-30 14:32:33 +02:00
Viktor Szakats
68609f0e33
cmake: also build certs when building test executables
To support running tests directly via `runtests.pl` after building
the test targets. Also to sync with the same update for autotools.

Follow-up to 0c1ad21f978c8f5acf3d0c1708d83a93635d9df3 #16845
Closes #16866
2025-03-30 13:35:09 +02:00
Viktor Szakats
f07d57b955
test313: disable via <features> for backends without CRL support
Instead of via `tests/data/DISABLED` file.

They are all missing CRL feature support, as opposed to being broken.

Follow-up to 8adee8824cba23b7f3738b551a84101009f8a8d1 #16862
Follow-up to 8b1b5cd4d2df3a8c2c0108d1d2b5d519b7ece23e #16660

Closes #16865
2025-03-30 13:35:09 +02:00
Viktor Szakats
edd6e54e5f
runtests: support running tests under wine or qemu (cont.)
Respect `CURL_TEST_EXE_RUNNER` env in server verifications using
the in-tree curl, in `tests/servers.pm`.

Follow-up to 72b163c30141b3a9afe23cceb1e2a0b2e817de8b #16785
Closes #16863
2025-03-29 12:35:34 +01:00
Viktor Szakats
8adee8824c
test313: disable CRL test for Schannel due to lack of support and flakiness
The source code and documentation says that CRL is not supported by
curl's Schannel TLS backend.

It's also frequently flaky in CI with both MinGW and MSVC jobs, e.g.:
https://github.com/curl/curl/actions/runs/14134841988/job/39603994164 (Schannel)
https://github.com/curl/curl/actions/runs/14134841988/job/39606336445 (Schannel)
https://github.com/curl/curl/actions/runs/13981383629/job/39147183706 (LibreSSL)

```
curl returned 35, when expecting 60
```

This test was passing with Schannel because it misses the `--insecure`
option and thus always returns 60, regardless of passing `--crlfile` or
not:
```
curl: (60) schannel: CertGetCertificateChain trust error CERT_TRUST_REVOCATION_STATUS_UNKNOWN
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the webpage mentioned above.
```

Closes #16862
2025-03-29 12:35:34 +01:00
Viktor Szakats
25eb2dbfbf
sshserver.pl: use Perl chmod
Instead of relying on the external/shell command. For portability.

Follow-up to 213c5aca7bfc74a6ae02b065c5f38a1e9ff54d62 #3899
Closes #16859
2025-03-29 12:35:34 +01:00
Viktor Szakats
7be2c421bf
runtests: rewrite genserv.sh in Perl
To remove POSIX shell as an extra dependency for runtests.

Also fix to `chmod 0600` the `.pem` file (was: `.prm`), and apply it
_before_ writing the keys.

Follow-up to 44341e736a3e2f7a2b25a774be3a9796e81abab9 #16824
Closes #16858
2025-03-29 12:35:33 +01:00