diff options
Diffstat (limited to 'src/core/settings/plugins')
9 files changed, 322 insertions, 55 deletions
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 6452d72a..4d8e7bd6 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -5355,59 +5355,41 @@ wired_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) static gboolean parse_infiniband_p_key(shvarFile *ifcfg, int *out_p_key, char **out_parent, GError **error) { - char *device = NULL, *physdev = NULL, *pkey_id = NULL; - char *ifname = NULL; - int id; - gboolean ret = FALSE; - - device = svGetValueStr_cp(ifcfg, "DEVICE"); - if (!device) { - PARSE_WARNING("InfiniBand connection specified PKEY but not DEVICE"); - goto done; - } + gs_free char *physdev = NULL; + gs_free char *pkey_id = NULL; + int id; physdev = svGetValueStr_cp(ifcfg, "PHYSDEV"); if (!physdev) { - PARSE_WARNING("InfiniBand connection specified PKEY but not PHYSDEV"); - goto done; + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "infiniband connection specified PKEY but not PHYSDEV"); + return FALSE; } pkey_id = svGetValueStr_cp(ifcfg, "PKEY_ID"); if (!pkey_id) { - PARSE_WARNING("InfiniBand connection specified PKEY but not PKEY_ID"); - goto done; + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "infiniband connection specified PKEY but not PKEY_ID"); + return FALSE; } id = _nm_utils_ascii_str_to_int64(pkey_id, 0, 0, 0xFFFF, -1); if (id == -1) { - PARSE_WARNING("invalid InfiniBand PKEY_ID '%s'", pkey_id); - goto done; - } - id = (id | 0x8000); - - ifname = g_strdup_printf("%s.%04x", physdev, (unsigned) id); - if (strcmp(device, ifname) != 0) { - PARSE_WARNING("InfiniBand DEVICE (%s) does not match PHYSDEV+PKEY_ID (%s)", device, ifname); - goto done; - } - - *out_p_key = id; - *out_parent = g_strdup(physdev); - ret = TRUE; - -done: - g_free(device); - g_free(physdev); - g_free(pkey_id); - g_free(ifname); - - if (!ret) { g_set_error(error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create InfiniBand setting"); + "invalid infiniband PKEY_ID '%s'", + pkey_id); + return FALSE; } - return ret; + + *out_p_key = id; + *out_parent = g_steal_pointer(&physdev); + return TRUE; } static NMSetting * diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index 96efc9e5..e8948c3d 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -1312,6 +1312,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error gboolean is_first; guint32 u32; gboolean b; + gboolean any_option = FALSE; s_con = nm_connection_get_setting_connection(connection); if (s_con) { @@ -1341,6 +1342,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error g_string_append_c(str, ' '); g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id)); g_string_append(str, b ? " on" : " off"); + any_option = TRUE; } is_first = TRUE; @@ -1356,6 +1358,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error g_string_append_c(str, ' '); g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id)); g_string_append_printf(str, " %" G_GUINT32_FORMAT, u32); + any_option = TRUE; } is_first = TRUE; @@ -1371,7 +1374,10 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error g_string_append_c(str, ' '); g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id)); g_string_append_printf(str, " %" G_GUINT32_FORMAT, u32); + any_option = TRUE; } + + is_first = TRUE; for (ethtool_id = _NM_ETHTOOL_ID_PAUSE_FIRST; ethtool_id <= _NM_ETHTOOL_ID_PAUSE_LAST; ethtool_id++) { nm_assert(nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id)); @@ -1384,9 +1390,10 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error g_string_append_c(str, ' '); g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id)); g_string_append(str, b ? " on" : " off"); + any_option = TRUE; } - if (!str) { + if (!any_option) { /* Write an empty dummy "-A" option without arguments. This is to * ensure that the reader will create an (all default) NMSettingEthtool. * Also, it seems that `ethtool -A "$IFACE"` is silently accepted. */ diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ipoib b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ipoib new file mode 100644 index 00000000..b45da5f7 --- /dev/null +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ipoib @@ -0,0 +1,9 @@ +TYPE=InfiniBand +PKEY=yes +PKEY_ID=12 +PHYSDEV=ib0 +CONNECTED_MODE=yes +IPADDR=192.168.2.2 +NETMASK=255.255.255.0 +GATEWAY=192.168.2.1 +NAME=ib012 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-6.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-6.cexpected new file mode 100644 index 00000000..784ad224 --- /dev/null +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-6.cexpected @@ -0,0 +1,15 @@ +TYPE=Ethernet +PROXY_METHOD=none +BROWSER_ONLY=no +ETHTOOL_OPTS="autoneg on ; -A net0 pause-autoneg off" +BOOTPROTO=dhcp +DEFROUTE=yes +IPV4_FAILURE_FATAL=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=default +NAME=test_roundtrip_ethtool +UUID=${UUID} +ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-7.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-7.cexpected new file mode 100644 index 00000000..02ab14fe --- /dev/null +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-7.cexpected @@ -0,0 +1,15 @@ +TYPE=Ethernet +PROXY_METHOD=none +BROWSER_ONLY=no +ETHTOOL_OPTS="autoneg on ; -G net0 rx 512" +BOOTPROTO=dhcp +DEFROUTE=yes +IPV4_FAILURE_FATAL=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=default +NAME=test_roundtrip_ethtool +UUID=${UUID} +ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-8.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-8.cexpected new file mode 100644 index 00000000..fd760839 --- /dev/null +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-8.cexpected @@ -0,0 +1,15 @@ +TYPE=Ethernet +PROXY_METHOD=none +BROWSER_ONLY=no +ETHTOOL_OPTS="autoneg on ; -A net0" +BOOTPROTO=dhcp +DEFROUTE=yes +IPV4_FAILURE_FATAL=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=default +NAME=test_roundtrip_ethtool +UUID=${UUID} +ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected new file mode 100644 index 00000000..1703b0dc --- /dev/null +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected @@ -0,0 +1,15 @@ +TYPE=Ethernet +PROXY_METHOD=none +BROWSER_ONLY=no +ETHTOOL_OPTS="autoneg on ; -G net0 rx 512 ; -A net0 pause-autoneg off" +BOOTPROTO=dhcp +DEFROUTE=yes +IPV4_FAILURE_FATAL=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=default +NAME=test_roundtrip_ethtool +UUID=${UUID} +ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 9fdae4bd..886a605f 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -3425,6 +3425,7 @@ test_roundtrip_ethtool(void) gs_unref_object NMConnection *connection = NULL; NMSetting *s_ethtool; NMSetting *s_wired; + int i_run; connection = nmtst_create_minimal_connection("test_roundtrip_ethtool", NULL, @@ -3487,6 +3488,159 @@ test_roundtrip_ethtool(void) TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-5.cexpected", NULL); g_clear_object(&connection); + + connection = nmtst_create_minimal_connection("test_roundtrip_ethtool", + NULL, + NM_SETTING_WIRED_SETTING_NAME, + NULL); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); + g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); + nm_setting_option_set_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_AUTONEG, FALSE); + _writer_new_connec_exp(connection, + TEST_SCRATCH_DIR, + TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-6.cexpected", + NULL); + g_clear_object(&connection); + + connection = nmtst_create_minimal_connection("test_roundtrip_ethtool", + NULL, + NM_SETTING_WIRED_SETTING_NAME, + NULL); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); + g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); + nm_setting_option_set_uint32(s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX, 512); + _writer_new_connec_exp(connection, + TEST_SCRATCH_DIR, + TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-7.cexpected", + NULL); + g_clear_object(&connection); + + connection = nmtst_create_minimal_connection("test_roundtrip_ethtool", + NULL, + NM_SETTING_WIRED_SETTING_NAME, + NULL); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); + g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); + _writer_new_connec_exp(connection, + TEST_SCRATCH_DIR, + TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-8.cexpected", + NULL); + g_clear_object(&connection); + + connection = nmtst_create_minimal_connection("test_roundtrip_ethtool", + NULL, + NM_SETTING_WIRED_SETTING_NAME, + NULL); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); + g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); + nm_setting_option_set_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_AUTONEG, FALSE); + nm_setting_option_set_uint32(s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX, 512); + _writer_new_connec_exp(connection, + TEST_SCRATCH_DIR, + TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-9.cexpected", + NULL); + g_clear_object(&connection); + + for (i_run = 0; i_run < 20; i_run++) { + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *reread = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gboolean reread_same; + gboolean v_bool; + NMEthtoolID ethtool_ids[_NM_ETHTOOL_ID_NUM]; + guint i; + guint l; + NMSettingWiredWakeOnLan wake_on_lan; + + con2 = nmtst_create_minimal_connection("test_roundtrip_ethtool", + NULL, + NM_SETTING_WIRED_SETTING_NAME, + NULL); + s_wired = nmtst_connection_assert_setting(con2, NM_TYPE_SETTING_WIRED); + g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, nmtst_get_rand_bool(), NULL); + + if (nmtst_get_rand_bool()) { + g_object_set(s_wired, + NM_SETTING_WIRED_SPEED, + 1000u, + NM_SETTING_WIRED_DUPLEX, + nmtst_get_rand_bool() ? "full" : "half", + NULL); + } + + wake_on_lan = nmtst_get_rand_uint32(); + wake_on_lan = wake_on_lan & NM_SETTING_WIRED_WAKE_ON_LAN_ALL; + wake_on_lan = nmtst_rand_select(wake_on_lan, + NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, + NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE); + g_object_set(s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, (guint) wake_on_lan, NULL); + + if (NM_FLAGS_HAS(wake_on_lan, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC) + && nmtst_get_rand_bool()) { + g_object_set(s_wired, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, "aa:bb:cc:dd:ee:ff", NULL); + } + + l = nmtst_get_rand_uint32() % (G_N_ELEMENTS(ethtool_ids) + 2); + if (l == 0) { + /* pass. No ethtool setting. */ + goto check_roundtrip; + } + l--; + + s_ethtool = _nm_connection_new_setting(con2, NM_TYPE_SETTING_ETHTOOL); + + for (i = 0; i < (int) G_N_ELEMENTS(ethtool_ids); i++) + ethtool_ids[i] = i; + nmtst_rand_perm(NULL, ethtool_ids, NULL, sizeof(ethtool_ids[0]), G_N_ELEMENTS(ethtool_ids)); + + for (i = 0; i < l; i++) { + NMEthtoolID ethtool_id = ethtool_ids[i]; + const GVariantType *vtype; + const char *optname; + + optname = nm_ethtool_data[ethtool_id]->optname; + vtype = nm_ethtool_id_get_variant_type(ethtool_id); + + if (NM_IN_SET(ethtool_id, + NM_ETHTOOL_ID_COALESCE_ADAPTIVE_RX, + NM_ETHTOOL_ID_COALESCE_ADAPTIVE_TX)) { + nm_setting_option_set_uint32(s_ethtool, optname, nmtst_get_rand_uint32() % 2); + } else if (g_variant_type_equal(vtype, G_VARIANT_TYPE_BOOLEAN)) + nm_setting_option_set_boolean(s_ethtool, optname, nmtst_get_rand_bool()); + else if (g_variant_type_equal(vtype, G_VARIANT_TYPE_UINT32)) + nm_setting_option_set_uint32(s_ethtool, optname, nmtst_get_rand_uint32()); + else + g_assert_not_reached(); + } + + if ((nm_setting_option_get_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_RX, NULL) + || nm_setting_option_get_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_TX, NULL)) + && nm_setting_option_get_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_AUTONEG, &v_bool) + && v_bool) { + /* don't accidentally create an invalid profile. */ + nm_setting_option_set(s_ethtool, + NM_ETHTOOL_OPTNAME_PAUSE_AUTONEG, + nmtst_get_rand_bool() ? g_variant_new_boolean(FALSE) : NULL); + } + +check_roundtrip: + _writer_new_connection_reread(con2, + TEST_SCRATCH_DIR, + &testfile, + NO_EXPECTED, + &reread, + &reread_same); + g_assert(NM_IS_CONNECTION(reread)); + g_assert(reread_same); + } } static void @@ -8211,8 +8365,35 @@ test_read_infiniband(void) } static void -test_write_infiniband(void) +test_read_ipoib(void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingInfiniband *s_infiniband; + char *unmanaged = NULL; + const char *transport_mode; + int pkey; + + connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-ipoib", + NULL, + TYPE_INFINIBAND, + &unmanaged); + g_assert(!unmanaged); + + s_infiniband = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_INFINIBAND); + + pkey = nm_setting_infiniband_get_p_key(s_infiniband); + g_assert(pkey); + g_assert_cmpint(pkey, ==, 12); + + transport_mode = nm_setting_infiniband_get_transport_mode(s_infiniband); + g_assert(transport_mode); + g_assert_cmpstr(transport_mode, ==, "connected"); +} + +static void +test_write_infiniband(gconstpointer test_data) { + const int TEST_IDX = GPOINTER_TO_INT(test_data); nmtst_auto_unlinkfile char *testfile = NULL; gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; @@ -8223,14 +8404,15 @@ test_write_infiniband(void) const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; guint32 mtu = 65520; NMIPAddress *addr; - GError *error = NULL; + GError *error = NULL; + const char *interface_name = NULL; connection = nm_simple_connection_new(); s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, - "Test Write InfiniBand", + "Test Write Infiniband", NM_SETTING_CONNECTION_UUID, nm_uuid_generate_random_str_a(), NM_SETTING_CONNECTION_AUTOCONNECT, @@ -8239,15 +8421,28 @@ test_write_infiniband(void) NM_SETTING_INFINIBAND_SETTING_NAME, NULL); + if (NM_IN_SET(TEST_IDX, 1, 3)) + interface_name = "ib0.000c"; + + g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, interface_name, NULL); + s_infiniband = _nm_connection_new_setting(connection, NM_TYPE_SETTING_INFINIBAND); - g_object_set(s_infiniband, - NM_SETTING_INFINIBAND_MAC_ADDRESS, - mac, - NM_SETTING_INFINIBAND_MTU, - mtu, - NM_SETTING_INFINIBAND_TRANSPORT_MODE, - "connected", - NULL); + g_object_set(s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", NULL); + if (NM_IN_SET(TEST_IDX, 1, 2)) { + g_object_set(s_infiniband, + NM_SETTING_INFINIBAND_MAC_ADDRESS, + mac, + NM_SETTING_INFINIBAND_MTU, + mtu, + NULL); + } else { + g_object_set(s_infiniband, + NM_SETTING_INFINIBAND_P_KEY, + 12, + NM_SETTING_INFINIBAND_PARENT, + "ib0", + NULL); + } s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, @@ -8267,6 +8462,9 @@ test_write_infiniband(void) s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + if (nmtst_get_rand_bool()) + nmtst_connection_normalize(connection); + nmtst_assert_connection_verifies(connection); _writer_new_connection(connection, TEST_SCRATCH_DIR, &testfile); @@ -8274,6 +8472,8 @@ test_write_infiniband(void) reread = _connection_from_file(testfile, NULL, TYPE_INFINIBAND, NULL); nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); + + g_assert_cmpstr(interface_name, ==, nm_connection_get_interface_name(reread)); } static void @@ -10446,6 +10646,7 @@ main(int argc, char **argv) g_test_add_func(TPATH "wifi/read/wep-no-keys", test_read_wifi_wep_no_keys); g_test_add_func(TPATH "wifi/read/wep-agent-keys", test_read_wifi_wep_agent_keys); g_test_add_func(TPATH "infiniband/read", test_read_infiniband); + g_test_add_func(TPATH "ipoib/read", test_read_ipoib); g_test_add_func(TPATH "vlan/read", test_read_vlan_interface); g_test_add_func(TPATH "vlan/read-flags-1", test_read_vlan_flags_1); g_test_add_func(TPATH "vlan/read-flags-2", test_read_vlan_flags_2); @@ -10582,7 +10783,10 @@ main(int argc, char **argv) g_test_add_func(TPATH "permissions/read", test_read_permissions); g_test_add_func(TPATH "permissions/write", test_write_permissions); g_test_add_func(TPATH "wifi/write-wep-agent-keys", test_write_wifi_wep_agent_keys); - g_test_add_func(TPATH "infiniband/write", test_write_infiniband); + g_test_add_data_func(TPATH "infiniband/write/1", GINT_TO_POINTER(1), test_write_infiniband); + g_test_add_data_func(TPATH "infiniband/write/2", GINT_TO_POINTER(2), test_write_infiniband); + g_test_add_data_func(TPATH "infiniband/write/3", GINT_TO_POINTER(3), test_write_infiniband); + g_test_add_data_func(TPATH "infiniband/write/4", GINT_TO_POINTER(4), test_write_infiniband); g_test_add_func(TPATH "vlan/write", test_write_vlan); g_test_add_func(TPATH "vlan/write-flags", test_write_vlan_flags); g_test_add_func(TPATH "vlan/write-only-vlanid", test_write_vlan_only_vlanid); diff --git a/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c b/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c index 1307d4b2..47be3a5e 100644 --- a/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c +++ b/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c @@ -2292,14 +2292,19 @@ test_read_missing_vlan_flags(void) static void test_read_missing_id_uuid(void) { - gs_unref_object NMConnection *connection = NULL; - gs_free char *expected_uuid = NULL; - const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID"; + gs_unref_object NMConnection *connection = NULL; + gs_free char *expected_uuid = NULL; + gs_free char *expected_uuid2 = NULL; + const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID"; + const char F[] = "keyfile\0" TEST_KEYFILES_DIR "/Test_Missing_ID_UUID"; expected_uuid = nm_uuid_generate_from_strings("keyfile", FILENAME, NULL); - connection = keyfile_read_connection_from_file(FILENAME); + expected_uuid2 = + nm_uuid_generate_from_string_str(F, sizeof(F), NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1); + g_assert_cmpstr(expected_uuid, ==, expected_uuid2); + connection = keyfile_read_connection_from_file(FILENAME); g_assert_cmpstr(nm_connection_get_id(connection), ==, "Test_Missing_ID_UUID"); g_assert_cmpstr(nm_connection_get_uuid(connection), ==, expected_uuid); } |