diff options
author | Thomas Haller <thaller@redhat.com> | 2017-09-12 10:05:55 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-09-13 08:17:31 +0200 |
commit | e730ae7600854d159667d972717e2f0a7639ac42 (patch) | |
tree | 9e4913110adb15f00ce5c756791889f2382e8fc5 | |
parent | 79cb13bc5c4d3e71ea3c582963b07aa329040152 (diff) | |
download | NetworkManager-e730ae7600854d159667d972717e2f0a7639ac42.tar.gz |
core/tests: add checks in test for test_add_route_with_source()
-rw-r--r-- | src/tests/test-ip4-config.c | 12 | ||||
-rw-r--r-- | src/tests/test-ip6-config.c | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index d8b6f2de06..22d488db73 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -225,7 +225,7 @@ test_add_address_with_source (void) static void test_add_route_with_source (void) { - NMIP4Config *a; + gs_unref_object NMIP4Config *a = NULL; NMPlatformIP4Route route; const NMPlatformIP4Route *test_route; @@ -236,30 +236,34 @@ test_add_route_with_source (void) route.rt_source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip4_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip4_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); route.rt_source = NM_IP_CONFIG_SOURCE_VPN; nm_ip4_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip4_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip4_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - /* Test that a lower priority address source is overwritten */ _nmtst_ip4_config_del_route (a, 0); + g_assert_cmpint (nm_ip4_config_get_num_routes (a), ==, 0); + + /* Test that a lower priority address source is overwritten */ route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL; nm_ip4_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip4_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip4_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); route.rt_source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip4_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip4_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - g_object_unref (a); } static void diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index bc703dd440..05d2084ee5 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -196,7 +196,7 @@ test_add_address_with_source (void) static void test_add_route_with_source (void) { - NMIP6Config *a; + gs_unref_object NMIP6Config *a = NULL; NMPlatformIP6Route route; const NMPlatformIP6Route *test_route; @@ -207,30 +207,34 @@ test_add_route_with_source (void) route.rt_source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip6_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip6_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); route.rt_source = NM_IP_CONFIG_SOURCE_VPN; nm_ip6_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip6_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip6_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - /* Test that a lower priority address source is overwritten */ _nmtst_ip6_config_del_route (a, 0); + g_assert_cmpint (nm_ip6_config_get_num_routes (a), ==, 0); + + /* Test that a lower priority address source is overwritten */ route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL; nm_ip6_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip6_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip6_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); route.rt_source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_route (a, &route, NULL); + g_assert_cmpint (nm_ip6_config_get_num_routes (a), ==, 1); test_route = _nmtst_ip6_config_get_route (a, 0); g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - g_object_unref (a); } static void |