diff options
| author | Michael Biebl <biebl@debian.org> | 2018-09-23 10:10:27 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-09-23 10:10:27 +0200 |
| commit | e126f3e804c35480c4f075777430419d6ece23da (patch) | |
| tree | 5d5821ebcda8cd6ac34d2483bb3354910e508930 /src/settings/plugins/ifcfg-rh/tests | |
| parent | c240974325c552cad177c457d6ff04e381fd77a3 (diff) | |
New upstream version 1.12.4 upstream/1.12.4
Diffstat (limited to 'src/settings/plugins/ifcfg-rh/tests')
8 files changed, 13 insertions, 298 deletions
diff --git a/src/settings/plugins/ifcfg-rh/tests/meson.build b/src/settings/plugins/ifcfg-rh/tests/meson.build index 0593f12d..3d72d892 100644 --- a/src/settings/plugins/ifcfg-rh/tests/meson.build +++ b/src/settings/plugins/ifcfg-rh/tests/meson.build @@ -6,6 +6,7 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, + c_args: nm_build_cflags, link_with: libnms_ifcfg_rh_core ) diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Auto-Negotiate.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Auto-Negotiate.cexpected index 214f5da5..8f421cfb 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Auto-Negotiate.cexpected +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Auto-Negotiate.cexpected @@ -1,7 +1,7 @@ +ETHTOOL_OPTS="autoneg off speed 10 duplex half" TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no -ETHTOOL_OPTS="autoneg off speed 10 duplex half" BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Wake-on-LAN.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Wake-on-LAN.cexpected index de66dcdd..398a3017 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Wake-on-LAN.cexpected +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Wake-on-LAN.cexpected @@ -1,7 +1,7 @@ +ETHTOOL_OPTS="wol umgs sopass 00:00:00:11:22:33" TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no -ETHTOOL_OPTS="wol umgs sopass 00:00:00:11:22:33" BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected deleted file mode 100644 index f0cd36cb..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected +++ /dev/null @@ -1,11 +0,0 @@ -TYPE=Ethernet -PROXY_METHOD=none -BROWSER_ONLY=no -MATCH_INTERFACE_NAME="ens* eth\\ 1? !veth*" -BOOTPROTO=dhcp -DEFROUTE=yes -IPV4_FAILURE_FATAL=no -IPV6INIT=no -NAME="Test Write Wired with Match setting" -UUID=${UUID} -ONBOOT=yes diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov deleted file mode 100644 index 142f56e4..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov +++ /dev/null @@ -1,19 +0,0 @@ -TYPE=Ethernet -DEVICE=eth0 -HWADDR=00:11:22:33:44:55 -BOOTPROTO=none -ONBOOT=yes -DNS1=4.2.2.1 -DNS2=4.2.2.2 -IPADDR=192.168.1.5 -PREFIX=24 -NETMASK=255.255.255.0 -GATEWAY=192.168.1.1 -IPV6INIT=no -NAME=ethernet-sriov -UUID=acc703b8-e751-44ce-b456-1550bdf2057e -SRIOV_TOTAL_VFS=16 -SRIOV_AUTOPROBE_DRIVERS=0 -SRIOV_VF15="max-tx-rate=200 mac=01:23:45:67:89:ab vlans=2" -SRIOV_VF12="trust=false min-tx-rate=100 vlans=1.200.ad" -SRIOV_VF3="mac=55:44:33:22:11:00 spoof-check=true" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected deleted file mode 100644 index c882c479..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected +++ /dev/null @@ -1,18 +0,0 @@ -TYPE=Ethernet -PROXY_METHOD=none -BROWSER_ONLY=no -SRIOV_TOTAL_VFS=64 -SRIOV_AUTOPROBE_DRIVERS=1 -SRIOV_VF2="mac=55:55:55:55:55:55 vlans=3.10.ad;10" -SRIOV_VF19=spoof-check=true -BOOTPROTO=none -IPADDR=1.1.1.3 -PREFIX=24 -GATEWAY=1.1.1.1 -DEFROUTE=yes -IPV4_FAILURE_FATAL=no -IPV6INIT=no -NAME="Test Write SR-IOV config" -UUID=${UUID} -DEVICE=eth0 -ONBOOT=yes diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected deleted file mode 100644 index 42608576..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected +++ /dev/null @@ -1,15 +0,0 @@ -TYPE=Ethernet -PROXY_METHOD=none -BROWSER_ONLY=no -ETHTOOL_OPTS="autoneg on ; -K net0 rxvlan off tx on" -BOOTPROTO=dhcp -DEFROUTE=yes -IPV4_FAILURE_FATAL=no -IPV6INIT=yes -IPV6_AUTOCONF=yes -IPV6_DEFROUTE=yes -IPV6_FAILURE_FATAL=no -IPV6_ADDR_GEN_MODE=stable-privacy -NAME="Test Write Wired Auto-Negotiate" -UUID=${UUID} -ONBOOT=yes 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 0c0dd64e..1331391d 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -43,14 +43,12 @@ #include "nm-setting-pppoe.h" #include "nm-setting-ppp.h" #include "nm-setting-vpn.h" -#include "nm-setting-ethtool.h" #include "nm-setting-gsm.h" #include "nm-setting-cdma.h" #include "nm-setting-serial.h" #include "nm-setting-vlan.h" #include "nm-setting-dcb.h" #include "nm-core-internal.h" -#include "nm-ethtool-utils.h" #include "NetworkManagerUtils.h" @@ -187,8 +185,7 @@ _assert_expected_content (NMConnection *connection, const char *filename, const if ( len_expectd != len_written || memcmp (content_expectd, content_written, len_expectd) != 0) { - if ( g_getenv ("NMTST_IFCFG_RH_UPDATE_EXPECTED") - || nm_streq0 (g_getenv ("NM_TEST_REGENERATE"), "1")) { + if (g_getenv ("NMTST_IFCFG_RH_UPDATE_EXPECTED")) { if (uuid) { gs_free char *search = g_strdup_printf ("UUID=%s\n", uuid); const char *s; @@ -1901,8 +1898,10 @@ test_read_write_802_1X_subj_matches (void) gs_unref_object NMConnection *reread = NULL; NMSetting8021x *s_8021x; + NMTST_EXPECT_NM_WARN ("*missing IEEE_8021X_CA_CERT*peap*"); connection = _connection_from_file (TEST_IFCFG_DIR"/ifcfg-test-wired-802-1X-subj-matches", NULL, TYPE_ETHERNET, NULL); + g_test_assert_expected_messages (); /* ===== 802.1x SETTING ===== */ s_8021x = nm_connection_get_setting_802_1x (connection); @@ -1920,12 +1919,16 @@ test_read_write_802_1X_subj_matches (void) g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 0), ==, "x.yourdomain.tld"); g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 1), ==, "y.yourdomain.tld"); + NMTST_EXPECT_NM_WARN ("*missing IEEE_8021X_CA_CERT for EAP method 'peap'; this is insecure!"); _writer_new_connec_exp (connection, TEST_SCRATCH_DIR, TEST_IFCFG_DIR"/ifcfg-System_test-wired-802-1X-subj-matches.cexpected", &testfile); + g_test_assert_expected_messages (); + NMTST_EXPECT_NM_WARN ("*missing IEEE_8021X_CA_CERT for EAP method 'peap'; this is insecure!"); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); + g_test_assert_expected_messages (); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -3114,7 +3117,8 @@ test_read_wifi_wpa_psk_hex (void) ssid = nm_setting_wireless_get_ssid (s_wireless); g_assert (ssid); - g_assert (nm_utils_gbytes_equal_mem (ssid, expected_ssid, strlen (expected_ssid))); + g_assert_cmpint (g_bytes_get_size (ssid), ==, strlen (expected_ssid)); + g_assert (memcmp (g_bytes_get_data (ssid, NULL), expected_ssid, strlen (expected_ssid)) == 0); /* ===== WIRELESS SECURITY SETTING ===== */ @@ -3721,7 +3725,6 @@ test_write_wired_auto_negotiate_on (void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingWired *s_wired; - NMSettingEthtool *s_ethtool; char *val; shvarFile *f; @@ -3731,14 +3734,8 @@ test_write_wired_auto_negotiate_on (void) NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); - s_ethtool = NM_SETTING_ETHTOOL (nm_setting_ethtool_new ()); - nm_setting_ethtool_set_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_TX, NM_TERNARY_TRUE); - nm_setting_ethtool_set_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RXVLAN, NM_TERNARY_FALSE); - nm_connection_add_setting (connection, NM_SETTING (s_ethtool)); - - _writer_new_connec_exp (connection, + _writer_new_connection (connection, TEST_SCRATCH_DIR, - TEST_IFCFG_DIR"/ifcfg-test_write_wired_auto_negotiate_on.cexpected", &testfile); f = _svOpenFile (testfile); @@ -3752,15 +3749,7 @@ test_write_wired_auto_negotiate_on (void) reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - nmtst_assert_connection_verifies_without_normalization (reread); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - s_ethtool = NM_SETTING_ETHTOOL (nm_connection_get_setting (reread, NM_TYPE_SETTING_ETHTOOL)); - g_assert (s_ethtool); - g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_TX), ==, NM_TERNARY_TRUE); - g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RXVLAN), ==, NM_TERNARY_FALSE); - g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_TXVLAN), ==, NM_TERNARY_DEFAULT); } static void @@ -4428,67 +4417,6 @@ test_write_wired_dhcp (void) } static void -test_write_wired_match (void) -{ - nmtst_auto_unlinkfile char *testfile = NULL; - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMConnection *reread = NULL; - NMSettingConnection *s_con; - NMSettingWired *s_wired; - NMSettingMatch *s_match; - NMSettingIPConfig *s_ip4; - NMSettingIPConfig *s_ip6; - - connection = nm_simple_connection_new (); - - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new (); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, "Test Write Wired with Match setting", - NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), - NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, - NULL); - - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NULL); - - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip6)); - - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NULL); - - /* Match setting */ - s_match = (NMSettingMatch *) nm_setting_match_new (); - nm_setting_match_add_interface_name (s_match, "ens*"); - nm_setting_match_add_interface_name (s_match, "eth 1?"); - nm_setting_match_add_interface_name (s_match, "!veth*"); - nm_connection_add_setting (connection, NM_SETTING (s_match)); - - nmtst_assert_connection_verifies (connection); - _writer_new_connec_exp (connection, - TEST_SCRATCH_DIR, - TEST_IFCFG_DIR"/ifcfg-Test_Write_Wired_match.cexpected", - &testfile); - reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); -} - -static void test_write_wired_dhcp_plus_ip (void) { nmtst_auto_unlinkfile char *testfile = NULL; @@ -9704,153 +9632,6 @@ test_utils_ignore (void) do_test_utils_ignored ("ignored-augtmp", "ifcfg-FooBar" AUGTMP_TAG, TRUE); } -/*****************************************************************************/ - -static void -test_sriov_read (void) -{ - gs_unref_object NMConnection *connection = NULL; - NMSettingSriov *s_sriov; - NMSriovVF *vf; - GVariant *variant; - GError *error = NULL; - char *str; - - connection = _connection_from_file (TEST_IFCFG_DIR "/ifcfg-test-sriov", - NULL, TYPE_ETHERNET,NULL); - - g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "eth0"); - - s_sriov = NM_SETTING_SRIOV (nm_connection_get_setting (connection, NM_TYPE_SETTING_SRIOV)); - g_assert (s_sriov); - - g_assert_cmpint (nm_setting_sriov_get_total_vfs (s_sriov), ==, 16); - g_assert_cmpint (nm_setting_sriov_get_num_vfs (s_sriov), ==, 3); - g_assert_cmpint (nm_setting_sriov_get_autoprobe_drivers (s_sriov), ==, NM_TERNARY_FALSE); - - /* VF 3 */ - vf = nm_setting_sriov_get_vf (s_sriov, 0); - g_assert (vf); - g_assert_cmpint (nm_sriov_vf_get_index (vf), ==, 3); - - variant = nm_sriov_vf_get_attribute (vf, NM_SRIOV_VF_ATTRIBUTE_MAC); - g_assert (variant); - g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)); - g_assert_cmpstr (g_variant_get_string (variant, NULL), ==, "55:44:33:22:11:00"); - - variant = nm_sriov_vf_get_attribute (vf, NM_SRIOV_VF_ATTRIBUTE_SPOOF_CHECK); - g_assert (variant); - g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_BOOLEAN)); - g_assert_cmpint (g_variant_get_boolean (variant), ==, TRUE); - - /* VF 12 */ - vf = nm_setting_sriov_get_vf (s_sriov, 1); - str = nm_utils_sriov_vf_to_str (vf, FALSE, &error); - g_assert_no_error (error); - g_assert_cmpstr (str, ==, "12 min-tx-rate=100 trust=false vlans=1.200.ad"); - g_free (str); - - /* VF 15 */ - vf = nm_setting_sriov_get_vf (s_sriov, 2); - str = nm_utils_sriov_vf_to_str (vf, FALSE, &error); - g_assert_no_error (error); - g_assert_cmpstr (str, ==, "15 mac=01:23:45:67:89:ab max-tx-rate=200 vlans=2"); - g_free (str); -} - -static void -test_sriov_write (void) -{ - nmtst_auto_unlinkfile char *testfile = NULL; - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMConnection *reread = NULL; - NMSettingConnection *s_con; - NMSettingIPConfig *s_ip4; - NMSettingIPConfig *s_ip6; - NMSettingWired *s_wired; - NMSettingSriov *s_sriov; - NMSriovVF *vf; - gs_unref_ptrarray GPtrArray *vfs = NULL; - NMIPAddress *addr; - GError *error = NULL; - - connection = nm_simple_connection_new (); - - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new (); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, "Test Write SR-IOV config", - NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), - NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_INTERFACE_NAME, "eth0", - NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, - NULL); - - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, - NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", - NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, - NULL); - - addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); - g_assert_no_error (error); - nm_setting_ip_config_add_address (s_ip4, addr); - nm_ip_address_unref (addr); - - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip6)); - - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NULL); - - /* SRIOV setting */ - s_sriov = (NMSettingSriov *) nm_setting_sriov_new (); - nm_connection_add_setting (connection, NM_SETTING (s_sriov)); - - vfs = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_sriov_vf_unref); - - vf = nm_utils_sriov_vf_from_str ("2 mac=55:55:55:55:55:55 vlans=3.10.ad;10", &error); - nmtst_assert_success (vf, error); - g_ptr_array_add (vfs, vf); - - vf = nm_utils_sriov_vf_from_str ("19 spoof-check=true", &error); - nmtst_assert_success (vf, error); - g_ptr_array_add (vfs, vf); - - g_object_set (s_sriov, - NM_SETTING_SRIOV_TOTAL_VFS, 64, - NM_SETTING_SRIOV_VFS, vfs, - NM_SETTING_SRIOV_AUTOPROBE_DRIVERS, NM_TERNARY_TRUE, - NULL); - - nm_connection_add_setting (connection, nm_setting_proxy_new ()); - - nmtst_assert_connection_verifies_without_normalization (connection); - - _writer_new_connec_exp (connection, - TEST_SCRATCH_DIR, - TEST_IFCFG_DIR "/ifcfg-test-sriov-write.cexpected", - &testfile); - - reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); -} - -/*****************************************************************************/ - static void test_tc_read (void) { @@ -10126,7 +9907,6 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wired/write/dhcp", test_write_wired_dhcp); g_test_add_func (TPATH "wired/write-dhcp-plus-ip", test_write_wired_dhcp_plus_ip); g_test_add_func (TPATH "wired/write/dhcp-8021x-peap-mschapv2", test_write_wired_dhcp_8021x_peap_mschapv2); - g_test_add_func (TPATH "wired/write/match", test_write_wired_match); #define _add_test_write_wired_8021x_tls(testpath, scheme, flags) \ nmtst_add_test_func (testpath, test_write_wired_8021x_tls, GINT_TO_POINTER (scheme), GINT_TO_POINTER (flags)) @@ -10253,9 +10033,6 @@ int main (int argc, char **argv) g_test_add_func (TPATH "utils/path", test_utils_path); g_test_add_func (TPATH "utils/ignore", test_utils_ignore); - g_test_add_func (TPATH "sriov/read", test_sriov_read); - g_test_add_func (TPATH "sriov/write", test_sriov_write); - g_test_add_func (TPATH "tc/read", test_tc_read); g_test_add_func (TPATH "tc/write", test_tc_write); |