diff options
Diffstat (limited to 'src/settings/plugins/ifcfg-rh/tests')
3 files changed, 53 insertions, 0 deletions
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index 8941da3a62..f32546f613 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -9,6 +9,7 @@ EXTRA_DIST = \ ifcfg-test-wired-static-bootproto \ ifcfg-test-wired-dhcp \ ifcfg-test-wired-dhcp-plus-ip \ + ifcfg-test-wired-shared-plus-ip \ ifcfg-test-wired-dhcp-send-hostname \ ifcfg-test-wired-dhcp6-only \ ifcfg-test-wired-global-gateway \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip new file mode 100644 index 0000000000..5098aef79c --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip @@ -0,0 +1,19 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=shared +ONBOOT=no +IPV6INIT=yes + +# additional IPs +IPADDR=10.20.30.5 +PREFIX=24 +GATEWAY=1.1.1.1 + +# these are ignored for shared method +IPADDR1=6.7.8.9 +PREFIX1=16 +IPADDR2=3.3.3.3 +PREFIX2=24 + diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index e05a4ccb20..c585cfe2a4 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -794,6 +794,38 @@ test_read_wired_dhcp_plus_ip (void) } static void +test_read_wired_shared_plus_ip (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-shared-plus-ip", + 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_SHARED); + g_assert (nm_setting_ip_config_get_may_fail (s_ip4)); + + /* 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), ==, "10.20.30.5"); + + /* 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_global_gateway (void) { NMConnection *connection; @@ -12355,6 +12387,7 @@ int main (int argc, char **argv) test_read_wired_static (TEST_IFCFG_WIRED_STATIC_BOOTPROTO, "System test-wired-static-bootproto", FALSE); test_read_wired_dhcp (); g_test_add_func (TPATH "dhcp-plus-ip", test_read_wired_dhcp_plus_ip); + 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 "never-default", test_read_wired_never_default); |