test2405: split off H2 tests to new test 2407, fix callback prototype

To untangle the different curl/server requirements of these tests.
Also to make this test run for non-H2 builds. Searching the cause of
the flakiness documented in #19481.

Also:
- fix the callback function prototype. Detected by ASAN with this patch,
  though the issue was pre-existing.
  ```
  lib/cw-out.c:211:14: runtime error: call to function emptyWriteFunc
    through pointer to incorrect function type
    'unsigned long (*)(char *, unsigned long, unsigned long, void *)'
  tests/libtest/lib2405.c:72: note: emptyWriteFunc defined here
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib/cw-out.c:211:14
  ```
  Ref: https://github.com/curl/curl/actions/runs/19296686908/job/55180334364?pr=19487#step:44:3768

Follow-up to 96a5ce5a82 #19481

Closes #19487
This commit is contained in:
Viktor Szakats 2025-11-12 10:27:36 +01:00
parent ebead15f4e
commit 2c7e1792a0
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
4 changed files with 67 additions and 12 deletions

View file

@ -261,7 +261,7 @@ test2200 test2201 test2202 test2203 test2204 test2205 \
test2300 test2301 test2302 test2303 test2304 test2306 test2307 test2308 \
test2309 \
\
test2400 test2401 test2402 test2403 test2404 test2405 test2406 \
test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 \
\
test2500 test2501 test2502 test2503 \
\

View file

@ -3,7 +3,6 @@
<keywords>
multi
HTTP
HTTP/2
</keywords>
</info>
@ -29,7 +28,7 @@ Funny-head: yesyes
# Client-side
<client>
<server>
http/2
http
</server>
<tool>
lib%TESTNUMBER
@ -38,7 +37,7 @@ lib%TESTNUMBER
checking curl_multi_waitfds functionality
</name>
<command>
http://%HOSTIP:%HTTP2PORT/%TESTNUMBER
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>

51
tests/data/test2407 Normal file
View file

@ -0,0 +1,51 @@
<testcase>
<info>
<keywords>
multi
HTTP
HTTP/2
</keywords>
</info>
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
Accept-Ranges: bytes
Content-Length: 6007
Connection: close
Content-Type: text/html
Funny-head: yesyes
-foo-
%repeat[1000 x foobar]%
</data>
</reply>
# Client-side
<client>
<features>
http/2
</features>
<server>
http/2
</server>
<tool>
lib2405
</tool>
<name>
checking curl_multi_waitfds functionality (HTTP/2)
</name>
<command>
http://%HOSTIP:%HTTP2PORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>

View file

@ -68,7 +68,7 @@ enum {
TEST_USE_HTTP2_MPLEX
};
static size_t emptyWriteFunc(void *ptr, size_t size, size_t nmemb,
static size_t emptyWriteFunc(char *ptr, size_t size, size_t nmemb,
void *data) {
(void)ptr; (void)data;
return size * nmemb;
@ -381,14 +381,19 @@ static CURLcode test_lib2405(const char *URL)
if(res != CURLE_OK)
goto test_cleanup;
/* HTTP1, expected 2 waitfds - one for each transfer */
test_run_check(TEST_USE_HTTP1, 2);
if(testnum == 2405) {
/* HTTP1, expected 2 waitfds - one for each transfer */
test_run_check(TEST_USE_HTTP1, 2);
}
#ifdef USE_HTTP2
else { /* 2407 */
/* HTTP2, expected 2 waitfds - one for each transfer */
test_run_check(TEST_USE_HTTP2, 2);
/* HTTP2, expected 2 waitfds - one for each transfer */
test_run_check(TEST_USE_HTTP2, 2);
/* HTTP2 with multiplexing, expected 1 waitfds - one for all transfers */
test_run_check(TEST_USE_HTTP2_MPLEX, 1);
/* HTTP2 with multiplexing, expected 1 waitfds - one for all transfers */
test_run_check(TEST_USE_HTTP2_MPLEX, 1);
}
#endif
test_cleanup:
curl_global_cleanup();