From 385896c388b6afe54fb091b95dbfdcf52be5832e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 24 Aug 2025 20:21:46 +0200 Subject: [PATCH] test,win: fix -Wunused-function warnings (#4866) --- test/test-tcp-connect-error-after-write.c | 18 ++++++++++++------ test/test-tcp-rst.c | 15 +++++++++------ test/test-tcp-write-in-a-row.c | 8 ++++---- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/test/test-tcp-connect-error-after-write.c b/test/test-tcp-connect-error-after-write.c index 732125962..3e660bc6b 100644 --- a/test/test-tcp-connect-error-after-write.c +++ b/test/test-tcp-connect-error-after-write.c @@ -26,6 +26,17 @@ #include #include +#ifdef _WIN32 +/* + * Try to connect to an address on which nothing listens, get ECONNREFUSED + * (uv errno 12) and get connect_cb() called once with status != 0. + * Related issue: https://github.com/joyent/libuv/issues/443 + */ +TEST_IMPL(tcp_connect_error_after_write) { + RETURN_SKIP("This test is disabled on Windows. " + "See https://github.com/joyent/libuv/issues/444\n"); +} +#else /* !_WIN32 */ static int connect_cb_called; static int write_cb_called; static int close_cb_called; @@ -55,11 +66,6 @@ static void write_cb(uv_write_t* req, int status) { * Related issue: https://github.com/joyent/libuv/issues/443 */ TEST_IMPL(tcp_connect_error_after_write) { -#ifdef _WIN32 - RETURN_SKIP("This test is disabled on Windows for now. " - "See https://github.com/joyent/libuv/issues/444\n"); -#else - uv_connect_t connect_req; struct sockaddr_in addr; uv_write_t write_req; @@ -94,5 +100,5 @@ TEST_IMPL(tcp_connect_error_after_write) { MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; -#endif } +#endif /* !_WIN32 */ diff --git a/test/test-tcp-rst.c b/test/test-tcp-rst.c index 7729f03e6..cd4567037 100644 --- a/test/test-tcp-rst.c +++ b/test/test-tcp-rst.c @@ -22,6 +22,11 @@ #include "uv.h" #include "task.h" +#ifdef _WIN32 +TEST_IMPL(tcp_rst) { + RETURN_SKIP("Unix only test"); +} +#else /* !_WIN32 */ static uv_tcp_t tcp; static uv_connect_t connect_req; static uv_buf_t qbuf; @@ -76,12 +81,12 @@ static void connect_cb(uv_connect_t *req, int status) { * RST. Test checks that uv_guess_handle still works on a reset TCP handle. */ TEST_IMPL(tcp_rst) { + struct sockaddr_in server_addr; + int r; + #if defined(__OpenBSD__) RETURN_SKIP("Test does not currently work in OpenBSD"); #endif -#ifndef _WIN32 - struct sockaddr_in server_addr; - int r; qbuf.base = "QSH"; qbuf.len = 3; @@ -104,7 +109,5 @@ TEST_IMPL(tcp_rst) { MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; -#else - RETURN_SKIP("Unix only test"); -#endif } +#endif /* !_WIN32 */ diff --git a/test/test-tcp-write-in-a-row.c b/test/test-tcp-write-in-a-row.c index 5c17ed496..39762925c 100644 --- a/test/test-tcp-write-in-a-row.c +++ b/test/test-tcp-write-in-a-row.c @@ -112,13 +112,14 @@ static void start_server(void) { } TEST_IMPL(tcp_write_in_a_row) { + uv_connect_t connect_req; + struct sockaddr_in addr; + #if defined(_WIN32) RETURN_SKIP("tcp_write_in_a_row does not work on Windows"); #elif defined(__PASE__) RETURN_SKIP("tcp_write_in_a_row does not work on IBM i PASE"); -#else - uv_connect_t connect_req; - struct sockaddr_in addr; +#endif start_server(); @@ -139,5 +140,4 @@ TEST_IMPL(tcp_write_in_a_row) { MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; -#endif }