diff options
Diffstat (limited to 'src/tests/test-ip4-config.c')
| -rw-r--r-- | src/tests/test-ip4-config.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index 404940d4..16cd3d1e 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -20,13 +20,15 @@ #include "config.h" -#include <glib.h> #include <string.h> #include <arpa/inet.h> +#include "nm-default.h" #include "nm-ip4-config.h" #include "nm-platform.h" +#include "nm-test-utils.h" + static void addr_init (NMPlatformIP4Address *a, const char *addr, const char *peer, guint plen) { @@ -34,6 +36,8 @@ addr_init (NMPlatformIP4Address *a, const char *addr, const char *peer, guint pl g_assert (inet_pton (AF_INET, addr, (void *) &a->address) == 1); if (peer) g_assert (inet_pton (AF_INET, peer, (void *) &a->peer_address) == 1); + else + a->peer_address = a->address; a->plen = plen; } @@ -71,7 +75,7 @@ build_test_config (void) NMPlatformIP4Route route; /* Build up the config to subtract */ - config = nm_ip4_config_new (); + config = nm_ip4_config_new (1); addr_init (&addr, "192.168.1.10", "1.2.3.4", 24); nm_ip4_config_add_address (config, &addr); @@ -150,7 +154,7 @@ test_subtract (void) test_addr = nm_ip4_config_get_address (dst, 0); g_assert (test_addr != NULL); g_assert_cmpuint (test_addr->address, ==, addr_to_num (expected_addr)); - g_assert_cmpuint (test_addr->peer_address, ==, 0); + g_assert_cmpuint (test_addr->peer_address, ==, test_addr->address); g_assert_cmpuint (test_addr->plen, ==, expected_addr_plen); g_assert_cmpuint (nm_ip4_config_get_gateway (dst), ==, 0); @@ -191,8 +195,8 @@ test_compare_with_source (void) NMPlatformIP4Address addr; NMPlatformIP4Route route; - a = nm_ip4_config_new (); - b = nm_ip4_config_new (); + a = nm_ip4_config_new (1); + b = nm_ip4_config_new (2); /* Address */ addr_init (&addr, "1.2.3.4", NULL, 24); @@ -224,7 +228,7 @@ test_add_address_with_source (void) NMPlatformIP4Address addr; const NMPlatformIP4Address *test_addr; - a = nm_ip4_config_new (); + a = nm_ip4_config_new (1); /* Test that a higher priority source is not overwritten */ addr_init (&addr, "1.2.3.4", NULL, 24); @@ -264,7 +268,7 @@ test_add_route_with_source (void) NMPlatformIP4Route route; const NMPlatformIP4Route *test_route; - a = nm_ip4_config_new (); + a = nm_ip4_config_new (1); /* Test that a higher priority source is not overwritten */ route_new (&route, "1.2.3.4", 24, "1.2.3.1"); @@ -341,7 +345,7 @@ test_strip_search_trailing_dot (void) { NMIP4Config *config; - config = nm_ip4_config_new (); + config = nm_ip4_config_new (1); nm_ip4_config_add_search (config, "."); nm_ip4_config_add_search (config, "foo"); @@ -359,14 +363,12 @@ test_strip_search_trailing_dot (void) /*******************************************/ +NMTST_DEFINE (); + int main (int argc, char **argv) { - g_test_init (&argc, &argv, NULL); - -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif + nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); g_test_add_func ("/ip4-config/subtract", test_subtract); g_test_add_func ("/ip4-config/compare-with-source", test_compare_with_source); |