mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 14:00:11 +01:00
core/tests: add checks in test for test_add_route_with_source()
This commit is contained in:
parent
79cb13bc5c
commit
e730ae7600
2 changed files with 16 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue