[glib/wip/test-fail-convenience: 4/4] tests: Use g_test_skip_printf()




commit 6ae4fd634b24d70f112be2d386e952142c635bc0
Author: Simon McVittie <smcv collabora com>
Date:   Thu Aug 5 11:51:46 2021 +0100

    tests: Use g_test_skip_printf()
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]