gio/tests: fix socket /socket/credentials/unix_socketpair on win32

When I enabled unix socketpair test on win32, I left the existing
g_close(fds[1]), but _g_win32_socketpair() returns native sockets
descriptors that must be closed with closesocket() on win32.

Let GSocket handle the socket pair cleanup.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-03-23 19:12:59 +04:00
parent 89539d9ae0
commit e9f46d3529

View File

@ -2243,7 +2243,7 @@ test_credentials_unix_socketpair (void)
{
gint fds[2];
gint status;
GSocket *sock;
GSocket *sock[2];
GError *error = NULL;
GCredentials *creds;
@ -2259,9 +2259,12 @@ test_credentials_unix_socketpair (void)
#endif
g_assert_cmpint (status, ==, 0);
sock = g_socket_new_from_fd (fds[0], &error);
sock[0] = g_socket_new_from_fd (fds[0], &error);
g_assert_no_error (error);
sock[1] = g_socket_new_from_fd (fds[1], &error);
g_assert_no_error (error);
creds = g_socket_get_credentials (sock, &error);
creds = g_socket_get_credentials (sock[0], &error);
if (creds != NULL)
{
gchar *str = g_credentials_to_string (creds);
@ -2276,8 +2279,8 @@ test_credentials_unix_socketpair (void)
g_clear_error (&error);
}
g_object_unref (sock);
g_close (fds[1], NULL);
g_object_unref (sock[0]);
g_object_unref (sock[1]);
}
#endif