[gssdp/gssdp_1.0] tests: Fix test for getting netmask



commit e26d19441b69549c02dc05fb8b4ee20a2d2eb1cd
Author: Jens Georg <mail jensge org>
Date:   Sun Jul 5 14:13:23 2020 +0200

    tests: Fix test for getting netmask
    
    Hard-coding "lo" as a device is just broken

 tests/test-regression.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-regression.c b/tests/test-regression.c
index bfb692d..a25c556 100644
--- a/tests/test-regression.c
+++ b/tests/test-regression.c
@@ -28,6 +28,7 @@
 
 #include <gio/gio.h>
 
+#include <libgssdp/gssdp-error.h>
 #include <libgssdp/gssdp-resource-browser.h>
 #include <libgssdp/gssdp-resource-group.h>
 #include <libgssdp/gssdp-protocol.h>
@@ -420,14 +421,47 @@ static void test_ggo_1(void)
 void test_ggo_7 () {
         GError *error = NULL;
 
+
+
+        // Detect the name of the adapter belonging to 127.0.0.1
+        // Yes, this is awkward, but on Windows I believe the GUID is unique for
+        // the system, but not the same on every windows and *BSD is different to
+        // Linux as well (lo0 vs lo)
         GSSDPClient *client = g_initable_new (GSSDP_TYPE_CLIENT,
                                               NULL,
                                               &error,
                                               "host-ip", "127.0.0.1",
-                                              "interface", "lo",
                                               NULL);
         g_assert_no_error (error);
+        g_assert_nonnull (client);
+
+        char *iface = g_strdup (gssdp_client_get_interface (client));
+        g_clear_object (&client);
+
+        g_debug("Found adapter %s for 127.0.0.1", iface);
+
+        // Check that trying to get a client for a non-existing interface fails
+        client = g_initable_new (GSSDP_TYPE_CLIENT,
+                                 NULL,
+                                 &error,
+                                 "host-ip", "127.0.0.1",
+                                 "interface", "ThisShouldNotExist",
+                                 NULL);
+        g_assert_error (error, GSSDP_ERROR, GSSDP_ERROR_FAILED);
+        g_assert_null (client);
+        g_clear_error (&error);
+
+        client = g_initable_new (GSSDP_TYPE_CLIENT,
+                                 NULL,
+                                 &error,
+                                 "host-ip", "127.0.0.1",
+                                 "interface", iface,
+                                 NULL);
+        g_assert_no_error (error);
+        g_assert_nonnull (client);
         g_assert_nonnull (gssdp_client_get_address_mask (client));
+
+        g_free (iface);
 }
 
 /* END Regression test


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