diff options
author | Jens Georg <mail@jensge.org> | 2022-05-25 17:12:49 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-05-25 17:12:49 +0200 |
commit | 49af00d33e127fe119c26d32e9cd21c75617fb1f (patch) | |
tree | a4dfb71d7b8a3f5a9d9418f38a29a3e1ee1645eb /tests | |
parent | b2fbaebb433dcf903f532580ad7dad9f8675bf00 (diff) | |
download | gupnp-49af00d33e127fe119c26d32e9cd21c75617fb1f.tar.gz |
tests: Do not assume IPv6 exists
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-acl.c | 23 | ||||
-rw-r--r-- | tests/test-context.c | 25 |
2 files changed, 38 insertions, 10 deletions
diff --git a/tests/test-acl.c b/tests/test-acl.c index cc848ca..12bc89c 100644 --- a/tests/test-acl.c +++ b/tests/test-acl.c @@ -406,16 +406,13 @@ main (int argc, char *argv[]) GPtrArray *addresses = g_ptr_array_sized_new (2); g_ptr_array_add (addresses, g_strdup ("127.0.0.1")); - g_ptr_array_add (addresses, g_strdup ("::1")); // Detect if there is a special network device with "proper" ip addresses to check also link-local addresses GUPnPContext *c = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, NULL, - "interface", - "gupnp0", - "address-family", - G_SOCKET_FAMILY_IPV4, + "host-ip", + "::1", NULL); if (c != NULL) { @@ -431,6 +428,22 @@ main (int argc, char *argv[]) "interface", "gupnp0", "address-family", + G_SOCKET_FAMILY_IPV4, + NULL); + + if (c != NULL) { + g_ptr_array_add ( + addresses, + g_strdup (gssdp_client_get_host_ip (GSSDP_CLIENT (c)))); + g_object_unref (c); + } + + c = g_initable_new (GUPNP_TYPE_CONTEXT, + NULL, + NULL, + "interface", + "gupnp0", + "address-family", G_SOCKET_FAMILY_IPV6, NULL); diff --git a/tests/test-context.c b/tests/test-context.c index 044ad82..98ea7d5 100644 --- a/tests/test-context.c +++ b/tests/test-context.c @@ -1100,19 +1100,34 @@ main (int argc, char *argv[]) GPtrArray *addresses = g_ptr_array_sized_new (2); g_ptr_array_add (addresses, g_strdup ("127.0.0.1")); - g_ptr_array_add (addresses, g_strdup ("::1")); + // Detect if there is a special network device with "proper" ip addresses to check also link-local addresses GUPnPContext *c = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, NULL, - "interface", - "gupnp0", - "address-family", - G_SOCKET_FAMILY_IPV4, + "host-ip", + "::1", NULL); if (c != NULL) { + g_ptr_array_add ( + addresses, + g_strdup (gssdp_client_get_host_ip (GSSDP_CLIENT (c)))); + g_object_unref (c); + } + + // Detect if there is a special network device with "proper" ip addresses to check also link-local addresses + c = g_initable_new (GUPNP_TYPE_CONTEXT, + NULL, + NULL, + "interface", + "gupnp0", + "address-family", + G_SOCKET_FAMILY_IPV4, + NULL); + + if (c != NULL) { g_debug ("Adding address %s from device gupnp0", gssdp_client_get_host_ip (GSSDP_CLIENT (c))); g_ptr_array_add ( |