[glib/wip/hadess/test-fixes: 1/2] tests: Fix incomplete failure check in socket test



commit dd66302ac79c39239ab7f4cf8f5357be3d40a72b
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Dec 2 17:34:03 2019 +0100

    tests: Fix incomplete failure check in socket test
    
    For the check "if (error != NULL)" to work as expected, the
    create_server() (and create_server_full()) functions need to make
    sure to return an error for all the possible failures, but this
    might not always be the case.
    
    Catch all the failures by testing for a NULL result instead.

 gio/tests/socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/socket.c b/gio/tests/socket.c
index f1651972f..7e4e6d017 100644
--- a/gio/tests/socket.c
+++ b/gio/tests/socket.c
@@ -334,9 +334,9 @@ test_ip_async (GSocketFamily family)
   gchar buf[128];
 
   data = create_server (family, echo_server_thread, FALSE, &error);
-  if (error != NULL)
+  if (data == NULL)
     {
-      gchar *message = g_strdup_printf ("Failed to create server: %s", error->message);
+      gchar *message = g_strdup_printf ("Failed to create server: %s", error ? error->message : "unknown 
error");
       g_test_skip (message);
       g_free (message);
       g_clear_error (&error);


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