From 2c7e1792a06b81b2bf41c9d348d374a83621340b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 12 Nov 2025 10:27:36 +0100 Subject: [PATCH] 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 96a5ce5a82eb0f08650649ffafb7bb4e51fc4444 #19481 Closes #19487 --- tests/data/Makefile.am | 2 +- tests/data/test2405 | 5 ++-- tests/data/test2407 | 51 +++++++++++++++++++++++++++++++++++++++++ tests/libtest/lib2405.c | 21 ++++++++++------- 4 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 tests/data/test2407 diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index bdec674dff..c9e3f75ba1 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -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 \ \ diff --git a/tests/data/test2405 b/tests/data/test2405 index ee25b1de53..79f5e337c3 100644 --- a/tests/data/test2405 +++ b/tests/data/test2405 @@ -3,7 +3,6 @@ multi HTTP -HTTP/2 @@ -29,7 +28,7 @@ Funny-head: yesyes # Client-side -http/2 +http lib%TESTNUMBER @@ -38,7 +37,7 @@ lib%TESTNUMBER checking curl_multi_waitfds functionality -http://%HOSTIP:%HTTP2PORT/%TESTNUMBER +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test2407 b/tests/data/test2407 new file mode 100644 index 0000000000..c103cf74a1 --- /dev/null +++ b/tests/data/test2407 @@ -0,0 +1,51 @@ + + + +multi +HTTP +HTTP/2 + + + +# Server-side + + +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]% + + + +# Client-side + + +http/2 + + +http/2 + + +lib2405 + + +checking curl_multi_waitfds functionality (HTTP/2) + + +http://%HOSTIP:%HTTP2PORT/%TESTNUMBER + + + +# Verify data after the test has been "shot" + + + diff --git a/tests/libtest/lib2405.c b/tests/libtest/lib2405.c index 1cbb8401ae..2945b45b6c 100644 --- a/tests/libtest/lib2405.c +++ b/tests/libtest/lib2405.c @@ -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); - - /* HTTP2, expected 2 waitfds - one for each transfer */ - test_run_check(TEST_USE_HTTP2, 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 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(); -- 2.47.3