diff options
author | Jens Georg <mail@jensge.org> | 2020-07-02 21:47:08 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2020-07-05 15:21:11 +0200 |
commit | 793f6cefcf87e3997312d0ba9e80bd3bc0d08051 (patch) | |
tree | 2e02917a832ce8932b04caf53de12fe540da37e4 | |
parent | 629426336431a06386fef017f8ee84c808f64e89 (diff) | |
download | gssdp-793f6cefcf87e3997312d0ba9e80bd3bc0d08051.tar.gz |
tests: Add test for getting the netmask
This is related to #7
-rw-r--r-- | tests/test-regression.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test-regression.c b/tests/test-regression.c index 1b3065d..c3013ab 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> @@ -413,6 +414,63 @@ static void test_ggo_1(void) * ============================================================================ */ +/* BEGIN Regression test + * https://gitlab.gnome.org/GNOME/gssdp/issues/7 + * ============================================================================ + * - Check that creating a GSSDPClient with interface and ip will have a set + * network mask + */ +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", + 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 + * https://gitlab.gnome.org/GNOME/gssdp/issues/7 + * ============================================================================ + */ + int main (int argc, char *argv[]) { @@ -427,6 +485,7 @@ int main (int argc, char *argv[]) g_test_add_func ("/bugs/gnome/724030", test_bgo724030); g_test_add_func ("/bugs/ggo/1", test_ggo_1); } + g_test_add_func ("/bugs/ggo/7", test_ggo_7); g_test_run (); |