summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2015-01-31 13:08:49 +0100
committerJens Georg <mail@jensge.org>2015-01-31 13:08:52 +0100
commit09d1fd455dedc97e95e44f5af71f6cb5a365f7e9 (patch)
tree2e0f92ee3a57430a36bc4c3a2dd19244ddea3861
parent792d6647e03943ae02044d5be40d5f53d4ad422d (diff)
downloadgssdp-09d1fd455dedc97e95e44f5af71f6cb5a365f7e9.tar.gz
test: Fix name of lo device
For *BSD, it's lo0. The code now tries to auto-detect the device. Please note that (tested on FreeBSD and NetBSD) you have to add the route for the SSDP multicast group to the lo0 device to make the tests actually work. Signed-off-by: Jens Georg <mail@jensge.org>
-rw-r--r--tests/gtest/test-functional.c12
-rw-r--r--tests/gtest/test-regression.c8
-rw-r--r--tests/gtest/test-util.c34
-rw-r--r--tests/gtest/test-util.h3
4 files changed, 47 insertions, 10 deletions
diff --git a/tests/gtest/test-functional.c b/tests/gtest/test-functional.c
index d1fd3ff..c9b9fc0 100644
--- a/tests/gtest/test-functional.c
+++ b/tests/gtest/test-functional.c
@@ -176,7 +176,7 @@ test_discovery_ssdp_all (void)
data.usn = UUID_1"::MyService:1";
data.found = FALSE;
- client = gssdp_client_new (NULL, "lo", &error);
+ client = get_client (&error);
g_assert (client != NULL);
g_assert (error == NULL);
@@ -230,7 +230,7 @@ test_discovery_upnp_rootdevice (void)
data.usn = UUID_1"::upnp:rootdevice";
data.found = FALSE;
- client = gssdp_client_new (NULL, "lo", &error);
+ client = get_client (&error);
g_assert (client != NULL);
g_assert (error == NULL);
@@ -284,7 +284,7 @@ test_discovery_uuid (void)
data.usn = UUID_1;
data.found = FALSE;
- client = gssdp_client_new (NULL, "lo", &error);
+ client = get_client (&error);
g_assert (client != NULL);
g_assert (error == NULL);
@@ -339,7 +339,7 @@ test_discovery_versioned (void)
data.usn = VERSIONED_USN_1;
data.found = FALSE;
- client = gssdp_client_new (NULL, "lo", &error);
+ client = get_client (&error);
g_assert (client != NULL);
g_assert (error == NULL);
@@ -408,7 +408,7 @@ test_discovery_versioned_backwards_compatible (void)
data.usn = VERSIONED_USN_2;
data.found = FALSE;
- client = gssdp_client_new (NULL, "lo", &error);
+ client = get_client (&error);
g_assert (client != NULL);
g_assert (error == NULL);
@@ -461,7 +461,7 @@ test_discovery_versioned_ignore_older (void)
loop = g_main_loop_new (NULL, FALSE);
- client = gssdp_client_new (NULL, "lo", &error);
+ client = get_client (&error);
g_assert (client != NULL);
g_assert (error == NULL);
diff --git a/tests/gtest/test-regression.c b/tests/gtest/test-regression.c
index 01a984a..dc5a802 100644
--- a/tests/gtest/test-regression.c
+++ b/tests/gtest/test-regression.c
@@ -136,11 +136,11 @@ test_bgo673150 (void)
GMainLoop *loop;
gulong signal_id;
- dest = gssdp_client_new (NULL, "lo", &error);
+ dest = get_client (&error);
g_assert (dest != NULL);
g_assert (error == NULL);
- src = gssdp_client_new (NULL, "lo", &error);
+ src = get_client (&error);
g_assert (src != NULL);
g_assert (error == NULL);
@@ -221,7 +221,7 @@ void test_bgo682099 (void)
loop = g_main_loop_new (NULL, FALSE);
- dest = gssdp_client_new (NULL, "lo", &error);
+ dest = get_client (&error);
g_assert (dest != NULL);
g_assert (error == NULL);
@@ -336,7 +336,7 @@ void test_bgo724030 (void)
loop = g_main_loop_new (NULL, FALSE);
- dest = gssdp_client_new (NULL, "lo", &error);
+ dest = get_client (&error);
g_assert (dest != NULL);
g_assert (error == NULL);
diff --git a/tests/gtest/test-util.c b/tests/gtest/test-util.c
index 7bf87fd..5bebefc 100644
--- a/tests/gtest/test-util.c
+++ b/tests/gtest/test-util.c
@@ -53,3 +53,37 @@ unref_object (gpointer object)
return FALSE;
}
+
+GSSDPClient *
+get_client (GError **outer_error)
+{
+ static gsize init_guard = 0;
+ static char *device = NULL;
+
+ if (g_once_init_enter (&init_guard)) {
+ GSSDPClient *client = NULL;
+ GError *error = NULL;
+
+ g_debug ("Detecting network interface to use for tests...");
+
+ client = gssdp_client_new (NULL, "lo", &error);
+ if (error == NULL) {
+ g_debug ("Using lo");
+ device = g_strdup ("lo");
+ g_object_unref (client);
+ } else {
+ g_clear_error(&error);
+ client = gssdp_client_new (NULL, "lo0", &error);
+ if (error == NULL) {
+ g_debug ("Using lo0");
+ device = g_strdup ("lo0");
+ g_object_unref (client);
+ } else {
+ g_debug ("Using default interface, expect fails");
+ }
+ }
+ g_once_init_leave (&init_guard, 1);
+ }
+
+ return gssdp_client_new (NULL, device, outer_error);
+}
diff --git a/tests/gtest/test-util.h b/tests/gtest/test-util.h
index 4214795..3175bd6 100644
--- a/tests/gtest/test-util.h
+++ b/tests/gtest/test-util.h
@@ -44,6 +44,9 @@ on_resource_unavailable_assert_not_reached (GSSDPResourceBrowser *src,
const char *usn,
gpointer user_data);
+GSSDPClient *
+get_client (GError **error);
+
G_END_DECLS
#endif // TESTUTIL_H