Commit 233498e0 authored by Jiří Klimeš's avatar Jiří Klimeš

ifcfg-rh: update test files not to use obsolete GATEWAY<n> variables

But add a dedicated test reading GATEWAY1 to ensure we are still backwards
compatible.
parent a3c52d7a
......@@ -14,6 +14,7 @@ EXTRA_DIST = \
ifcfg-test-wired-dhcp6-only \
ifcfg-test-wired-global-gateway \
network-test-wired-global-gateway \
ifcfg-test-wired-obsolete-gateway-n \
ifcfg-test-wired-never-default \
network-test-wired-never-default \
ifcfg-test-wired-defroute-no \
......
......@@ -15,11 +15,11 @@ DNS3=1:2:3:4::a
DNS4=1:2:3:4::b
# additional IPs
IPADDR0=1.2.3.4
PREFIX0=24
GATEWAY0=1.1.1.1
IPADDR=1.2.3.4
PREFIX=24
IPADDR1=9.8.7.6
PREFIX1=16
GATEWAY=1.1.1.1
IPV6ADDR="1001:abba::1234/56"
IPV6ADDR_SECONDARIES="2001:abba::2234/64 3001:abba::3234/96"
......
......@@ -5,8 +5,8 @@ HWADDR=00:11:22:33:44:ee
BOOTPROTO=none
IPADDR0=1.2.3.4
PREFIX0=24
GATEWAY0=1.1.1.1
IPADDR1=9.8.7.6
PREFIX1=16
IPADDR2=3.3.3.3
PREFIX2=8
GATEWAY=1.1.1.1
......@@ -5,10 +5,7 @@ HWADDR=00:11:22:33:44:ee
BOOTPROTO=none
IPADDR=1.2.3.4
PREFIX=24
GATEWAY=1.1.1.1
IPADDR2=9.8.7.6
PREFIX2=16
GATEWAY2=5.5.5.5
IPADDR3=3.3.3.3
PREFIX3=8
GATEWAY3=7.7.7.7
# GATEWAY<N> is obsolete, but we read it for backwards compatibility
TYPE=Ethernet
DEVICE=eth0
HWADDR=00:11:22:33:44:ee
BOOTPROTO=none
ONBOOT=yes
# manual IP
IPADDR1=1.2.3.4
PREFIX1=24
GATEWAY1=1.1.1.1
......@@ -868,6 +868,37 @@ test_read_wired_global_gateway (void)
g_object_unref (connection);
}
static void
test_read_wired_obsolete_gateway_n (void)
{
NMConnection *connection;
NMSettingIPConfig *s_ip4;
GError *error = NULL;
NMIPAddress *ip4_addr;
connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-obsolete-gateway-n",
NULL, TYPE_ETHERNET, NULL,
&error);
nmtst_assert_connection_verifies_without_normalization (connection);
/* ===== IPv4 SETTING ===== */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
g_assert (s_ip4);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL);
/* IP addresses */
g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1);
ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0);
g_assert (ip4_addr);
g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24);
g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "1.2.3.4");
/* Gateway */
g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1");
g_object_unref (connection);
}
static void
test_read_wired_never_default (void)
{
......@@ -12421,6 +12452,7 @@ int main (int argc, char **argv)
g_test_add_func (TPATH "shared-plus-ip", test_read_wired_shared_plus_ip);
g_test_add_func (TPATH "dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname);
g_test_add_func (TPATH "global-gateway", test_read_wired_global_gateway);
g_test_add_func (TPATH "obsolete-gateway-n", test_read_wired_obsolete_gateway_n);
g_test_add_func (TPATH "never-default", test_read_wired_never_default);
test_read_wired_defroute_no ();
test_read_wired_defroute_no_gatewaydev_yes ();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment