mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 13:08:10 +02:00
route-manager/test: add variations to test code
This commit is contained in:
parent
62c652c352
commit
bd0c44c1cf
1 changed files with 10 additions and 6 deletions
|
|
@ -36,7 +36,7 @@ typedef struct {
|
||||||
} test_fixture;
|
} test_fixture;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_dev0_ip4 (int ifindex)
|
setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_route)
|
||||||
{
|
{
|
||||||
GArray *routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
|
GArray *routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
|
||||||
NMPlatformIP4Route route;
|
NMPlatformIP4Route route;
|
||||||
|
|
@ -49,13 +49,15 @@ setup_dev0_ip4 (int ifindex)
|
||||||
route.plen = 24;
|
route.plen = 24;
|
||||||
route.gateway = INADDR_ANY;
|
route.gateway = INADDR_ANY;
|
||||||
route.metric = 20;
|
route.metric = 20;
|
||||||
|
route.mss = mss_of_first_route;
|
||||||
g_array_append_val (routes, route);
|
g_array_append_val (routes, route);
|
||||||
|
|
||||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||||
inet_pton (AF_INET, "7.0.0.0", &route.network);
|
inet_pton (AF_INET, "7.0.0.0", &route.network);
|
||||||
route.plen = 8;
|
route.plen = 8;
|
||||||
inet_pton (AF_INET, "6.6.6.1", &route.gateway);
|
inet_pton (AF_INET, "6.6.6.1", &route.gateway);
|
||||||
route.metric = 21;
|
route.metric = metric_of_second_route;
|
||||||
|
route.mss = 0;
|
||||||
g_array_append_val (routes, route);
|
g_array_append_val (routes, route);
|
||||||
|
|
||||||
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
|
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
|
||||||
|
|
@ -162,7 +164,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
||||||
.ifindex = fixture->ifindex0,
|
.ifindex = fixture->ifindex0,
|
||||||
.gateway = INADDR_ANY,
|
.gateway = INADDR_ANY,
|
||||||
.metric = 20,
|
.metric = 20,
|
||||||
.mss = 0,
|
.mss = 1000,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||||
|
|
@ -170,7 +172,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
||||||
.plen = 8,
|
.plen = 8,
|
||||||
.ifindex = fixture->ifindex0,
|
.ifindex = fixture->ifindex0,
|
||||||
.gateway = nmtst_inet4_from_string ("6.6.6.1"),
|
.gateway = nmtst_inet4_from_string ("6.6.6.1"),
|
||||||
.metric = 21,
|
.metric = 21021,
|
||||||
.mss = 0,
|
.mss = 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -235,7 +237,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
setup_dev0_ip4 (fixture->ifindex0);
|
setup_dev0_ip4 (fixture->ifindex0, 1000, 21021);
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 8.0.0.0/8 via 6.6.6.2 dev nm-test-device1 *");
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 8.0.0.0/8 via 6.6.6.2 dev nm-test-device1 *");
|
||||||
setup_dev1_ip4 (fixture->ifindex1);
|
setup_dev1_ip4 (fixture->ifindex1);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
@ -252,11 +254,13 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
||||||
setup_dev1_ip4 (fixture->ifindex1);
|
setup_dev1_ip4 (fixture->ifindex1);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
setup_dev0_ip4 (fixture->ifindex0);
|
setup_dev0_ip4 (fixture->ifindex0, 0, 21);
|
||||||
|
|
||||||
/* Ensure nothing changed. */
|
/* Ensure nothing changed. */
|
||||||
routes = ip4_routes (fixture);
|
routes = ip4_routes (fixture);
|
||||||
g_assert_cmpint (routes->len, ==, G_N_ELEMENTS (state1));
|
g_assert_cmpint (routes->len, ==, G_N_ELEMENTS (state1));
|
||||||
|
state1[0].mss = 0;
|
||||||
|
state1[1].metric = 21;
|
||||||
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state1, routes->len, TRUE);
|
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state1, routes->len, TRUE);
|
||||||
g_array_free (routes, TRUE);
|
g_array_free (routes, TRUE);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue