ifcfg-rh/tests: test backward compatibility reading routes with "via (null)"

Due to a bug, NetworkManager used to write device routes with "via (null)".
That was fixed in commit af8aac9b54 and
bug rh#1452648.

Add a unit test to ensure we keep accepting such (invalid) routes that
NetworkManager once wrote.
This commit is contained in:
Thomas Haller 2017-09-05 13:20:09 +02:00
parent 9b208b520d
commit a47153f5b8
2 changed files with 9 additions and 1 deletions

View file

@ -5,3 +5,4 @@
via 8.8.8.8 to 32.42.52.62
43.53.0.0/16 metric 3 via 7.7.7.7 dev eth2 cwnd 14 mtu lock 9000 initrwnd 20 window lock 10000 initcwnd lock 42 src 1.2.3.4
7.7.7.8/32 via (null) metric 18

View file

@ -1376,7 +1376,7 @@ test_read_wired_static_routes_legacy (void)
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL);
/* Routes */
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 3);
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 4);
/* Route #1 */
ip4_route = nm_setting_ip_config_get_route (s_ip4, 0);
@ -1410,6 +1410,13 @@ test_read_wired_static_routes_legacy (void)
nmtst_assert_route_attribute_boolean (ip4_route, NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU, TRUE);
nmtst_assert_route_attribute_string (ip4_route, NM_IP_ROUTE_ATTRIBUTE_SRC, "1.2.3.4");
ip4_route = nm_setting_ip_config_get_route (s_ip4, 3);
g_assert (ip4_route != NULL);
g_assert_cmpstr (nm_ip_route_get_dest (ip4_route), ==, "7.7.7.8");
g_assert_cmpint (nm_ip_route_get_prefix (ip4_route), ==, 32);
g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, NULL);
g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, 18);
g_object_unref (connection);
}