From 26fbd149543cd23abfa51a65424a2134f7398c22 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Aug 2021 11:51:46 +0100 Subject: [PATCH] tests: Use g_test_skip_printf() Signed-off-by: Simon McVittie --- gio/tests/socket.c | 40 ++++++++++------------------------------ gio/tests/trash.c | 19 +++---------------- 2 files changed, 13 insertions(+), 46 deletions(-) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index fa96a4087..ee38fabcd 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -341,9 +341,7 @@ test_ip_async (GSocketFamily family) data = create_server (family, echo_server_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -454,9 +452,7 @@ test_ip_sync (GSocketFamily family) data = create_server (family, echo_server_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -594,9 +590,7 @@ test_ip_sync_dgram (GSocketFamily family) echo_server_dgram_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -974,9 +968,7 @@ test_close_graceful (void) data = create_server (family, graceful_server_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -1084,9 +1076,7 @@ test_ipv6_v4mapped (void) data = create_server (G_SOCKET_FAMILY_IPV6, v4mapped_server_thread, TRUE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -1145,9 +1135,7 @@ test_timed_wait (void) data = create_server (G_SOCKET_FAMILY_IPV4, echo_server_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -1232,9 +1220,7 @@ test_fd_reuse (void) data = create_server (G_SOCKET_FAMILY_IPV4, echo_server_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -1938,9 +1924,7 @@ test_credentials_tcp_client (void) data = create_server (family, echo_server_thread, FALSE, &error); if (error != NULL) { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); g_clear_error (&error); return; } @@ -2045,13 +2029,9 @@ test_credentials_tcp_server (void) goto beach; skip: - { - gchar *message = g_strdup_printf ("Failed to create server: %s", error->message); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Failed to create server: %s", error->message); + goto beach; - goto beach; - } beach: { g_clear_error (&error); diff --git a/gio/tests/trash.c b/gio/tests/trash.c index 2d3ec6774..b5fa4be92 100644 --- a/gio/tests/trash.c +++ b/gio/tests/trash.c @@ -111,11 +111,7 @@ test_trash_symlinks (void) if (!g_file_test (target, G_FILE_TEST_IS_DIR)) { - gchar *message; - - message = g_strdup_printf ("Directory '%s' does not exist", target); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Directory '%s' does not exist", target); g_free (target); return; } @@ -124,12 +120,7 @@ test_trash_symlinks (void) if (target_mount == NULL) { - gchar *message; - - message = g_strdup_printf ("Unable to determine mount point for %s", - target); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Unable to determine mount point for %s", target); g_free (target); return; } @@ -144,11 +135,7 @@ test_trash_symlinks (void) if (tmp_mount == NULL) { - gchar *message; - - message = g_strdup_printf ("Unable to determine mount point for %s", tmp); - g_test_skip (message); - g_free (message); + g_test_skip_printf ("Unable to determine mount point for %s", tmp); g_unix_mount_free (target_mount); g_free (target); g_free (tmp);