From 295b200e1791e9b64a1abc437f74e139c415e29b Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Sun, 30 Jun 2024 15:37:22 +0300 Subject: [PATCH 1/2] Fix gsocketclient-slow test on FreeBSD The "port" variable ends up being 0 even after successful g_socket_bind. Use g_socket_get_local_address() to actually get a correct port number. --- gio/tests/gsocketclient-slow.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gio/tests/gsocketclient-slow.c b/gio/tests/gsocketclient-slow.c index 18781eff9..5e13d9831 100644 --- a/gio/tests/gsocketclient-slow.c +++ b/gio/tests/gsocketclient-slow.c @@ -212,6 +212,9 @@ test_connection_failed (void) g_assert_no_error (local_error); /* reserve a port without listening so we know that connecting to it will fail */ + g_object_unref (address); + address = g_socket_get_local_address (socket, &local_error); + g_assert_no_error (local_error); port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (address)); client = g_socket_client_new (); From 1048fcc017f83c2c1803bc86514961ccc0648073 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 9 Jul 2024 17:36:28 +0100 Subject: [PATCH 2/2] tests: Make an error check less specific in gsocketclient-slow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Linux the error will be `G_IO_ERROR_CONNECTION_REFUSED`, but on macOS it will be `G_IO_ERROR_TIMED_OUT`. Both errors seem reasonable to me, so let’s not specifically require one of them. See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4104#note_2161451 Signed-off-by: Philip Withnall --- gio/tests/gsocketclient-slow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gio/tests/gsocketclient-slow.c b/gio/tests/gsocketclient-slow.c index 5e13d9831..bcd9abcfd 100644 --- a/gio/tests/gsocketclient-slow.c +++ b/gio/tests/gsocketclient-slow.c @@ -231,7 +231,8 @@ test_connection_failed (void) g_main_context_iteration (NULL, TRUE); conn = g_socket_client_connect_to_uri_finish (client, async_result, &local_error); - g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED); + g_assert_nonnull (local_error); + g_assert_cmpint (local_error->domain, ==, G_IO_ERROR); g_assert_null (conn); g_clear_error (&local_error); g_clear_object (&async_result);