From 5af6a4baec63a12efa53565a0fabadb06cde49de Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 12 Apr 2011 15:03:09 -0500 Subject: [PATCH] ifcfg-rh: add testcase for S390 CTC-type connections (bgo #647578) (rh #641986) --- .../tests/network-scripts/Makefile.am | 1 + .../ifcfg-test-wired-ctc-static | 12 ++++ .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 70 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static 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 22d1b4a7e4..d0e3800b38 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -71,6 +71,7 @@ EXTRA_DIST = \ ifcfg-test-wifi-wep-104-ascii \ keys-test-wifi-wep-104-ascii \ ifcfg-test-wired-qeth-static \ + ifcfg-test-wired-ctc-static \ ifcfg-test-bridge-main \ ifcfg-test-bridge-component \ ifcfg-test-vlan-interface \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static new file mode 100644 index 0000000000..61f8f423d4 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static @@ -0,0 +1,12 @@ +# IBM CTC +DEVICE=ctc0 +TYPE=CTC +BOOTPROTO=static +IPADDR=192.168.70.87 +GATEWAY=192.168.70.136 +NETMASK=255.255.255.0 +ONBOOT=yes +SUBCHANNELS=0.0.1b00,0.0.1b01 +NETTYPE=ctc +CTCPROT=0 + 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 ebe9e47fbf..d4fb6c25dd 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -5832,6 +5832,75 @@ test_read_wired_qeth_static (void) g_object_unref (connection); } +#define TEST_IFCFG_WIRED_CTC_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ctc-static" + +static void +test_read_wired_ctc_static (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GError *error = NULL; + const char *tmp; + const char *expected_id = "System test-wired-ctc-static"; + const char *expected_channel0 = "0.0.1b00"; + const char *expected_channel1 = "0.0.1b01"; + const GPtrArray *subchannels; + gboolean success; + + connection = connection_from_file (TEST_IFCFG_WIRED_CTC_STATIC, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + g_assert (unmanaged == FALSE); + + /* ===== CONNECTION SETTING ===== */ + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con != NULL); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, expected_id); + + /* ===== WIRED SETTING ===== */ + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired != NULL); + + g_assert (nm_setting_wired_get_mac_address (s_wired) == NULL); + + /* Subchannels */ + subchannels = nm_setting_wired_get_s390_subchannels (s_wired); + g_assert (subchannels != NULL); + g_assert_cmpint (subchannels->len, ==, 2); + + g_assert_cmpstr (g_ptr_array_index (subchannels, 0), ==, expected_channel0); + g_assert_cmpstr (g_ptr_array_index (subchannels, 1), ==, expected_channel1); + + /* Nettype */ + g_assert_cmpstr (nm_setting_wired_get_s390_nettype (s_wired), ==, "ctc"); + + /* port name */ + tmp = nm_setting_wired_get_s390_option_by_key (s_wired, "ctcprot"); + g_assert (tmp != NULL); + g_assert_cmpstr (tmp, ==, "0"); + + g_object_unref (connection); +} + #define TEST_IFCFG_WIFI_WEP_NO_KEYS TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-wep-no-keys" static void @@ -10758,6 +10827,7 @@ int main (int argc, char **argv) test_read_wifi_wpa_eap_ttls_tls (); test_read_wifi_wep_eap_ttls_chap (); test_read_wired_qeth_static (); + test_read_wired_ctc_static (); test_read_wifi_wep_no_keys (); test_read_permissions (); test_read_wifi_wep_agent_keys ();