settings: create default wired connection from NMDeviceEthernet
Instead of creating it in NMSettings, where we must use NM_IS_DEVICE_ETHERNET() (not NM_DEVICE_TYPE_ETHERNET because various generic devices masquerade as NM_DEVICE_TYPE_ETHERNET too), push knowledge of which device types create default wired connections into the device types themselves. This solves a problem with testcases where libNetworkManager.a (which testcases link to) requires the symbol nm_type_device_ethernet().
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -235,7 +235,6 @@ valgrind-*.log
|
|||||||
/src/settings/plugins/ifnet/tests/check_ifnet
|
/src/settings/plugins/ifnet/tests/check_ifnet
|
||||||
/src/settings/plugins/ifupdown/tests/test-ifupdown
|
/src/settings/plugins/ifupdown/tests/test-ifupdown
|
||||||
/src/settings/plugins/keyfile/tests/test-keyfile
|
/src/settings/plugins/keyfile/tests/test-keyfile
|
||||||
/src/settings/tests/test-wired-defname
|
|
||||||
/src/supplicant-manager/tests/test-supplicant-config
|
/src/supplicant-manager/tests/test-supplicant-config
|
||||||
/src/tests/config/test-config
|
/src/tests/config/test-config
|
||||||
/src/tests/test-dcb
|
/src/tests/test-dcb
|
||||||
@@ -244,5 +243,6 @@ valgrind-*.log
|
|||||||
/src/tests/test-ip4-config
|
/src/tests/test-ip4-config
|
||||||
/src/tests/test-ip6-config
|
/src/tests/test-ip6-config
|
||||||
/src/tests/test-resolvconf-capture
|
/src/tests/test-resolvconf-capture
|
||||||
|
/src/tests/test-wired-defname
|
||||||
|
|
||||||
/vapi/*.vapi
|
/vapi/*.vapi
|
||||||
|
@@ -114,6 +114,7 @@ src/devices/bluetooth/nm-device-bt.c
|
|||||||
src/devices/nm-device-bond.c
|
src/devices/nm-device-bond.c
|
||||||
src/devices/nm-device-bridge.c
|
src/devices/nm-device-bridge.c
|
||||||
src/devices/nm-device-ethernet.c
|
src/devices/nm-device-ethernet.c
|
||||||
|
src/devices/nm-device-ethernet-utils.c
|
||||||
src/devices/nm-device-infiniband.c
|
src/devices/nm-device-infiniband.c
|
||||||
src/devices/nm-device-vlan.c
|
src/devices/nm-device-vlan.c
|
||||||
src/devices/team/nm-device-team.c
|
src/devices/team/nm-device-team.c
|
||||||
@@ -125,4 +126,3 @@ src/nm-manager.c
|
|||||||
src/nm-sleep-monitor-systemd.c
|
src/nm-sleep-monitor-systemd.c
|
||||||
src/settings/plugins/ibft/plugin.c
|
src/settings/plugins/ibft/plugin.c
|
||||||
src/settings/plugins/ifcfg-rh/reader.c
|
src/settings/plugins/ifcfg-rh/reader.c
|
||||||
src/settings/nm-settings-utils.c
|
|
||||||
|
@@ -30,7 +30,6 @@ SUBDIRS += \
|
|||||||
dnsmasq-manager/tests \
|
dnsmasq-manager/tests \
|
||||||
platform \
|
platform \
|
||||||
rdisc \
|
rdisc \
|
||||||
settings/tests \
|
|
||||||
supplicant-manager/tests \
|
supplicant-manager/tests \
|
||||||
tests
|
tests
|
||||||
endif
|
endif
|
||||||
@@ -71,6 +70,8 @@ nm_sources = \
|
|||||||
devices/nm-device-bridge.h \
|
devices/nm-device-bridge.h \
|
||||||
devices/nm-device-ethernet.c \
|
devices/nm-device-ethernet.c \
|
||||||
devices/nm-device-ethernet.h \
|
devices/nm-device-ethernet.h \
|
||||||
|
devices/nm-device-ethernet-utils.c \
|
||||||
|
devices/nm-device-ethernet-utils.h \
|
||||||
devices/nm-device-factory.c \
|
devices/nm-device-factory.c \
|
||||||
devices/nm-device-factory.h \
|
devices/nm-device-factory.h \
|
||||||
devices/nm-device-generic.c \
|
devices/nm-device-generic.c \
|
||||||
@@ -157,8 +158,6 @@ nm_sources = \
|
|||||||
settings/nm-settings-connection.h \
|
settings/nm-settings-connection.h \
|
||||||
settings/nm-settings-error.c \
|
settings/nm-settings-error.c \
|
||||||
settings/nm-settings-error.h \
|
settings/nm-settings-error.h \
|
||||||
settings/nm-settings-utils.c \
|
|
||||||
settings/nm-settings-utils.h \
|
|
||||||
settings/nm-settings.c \
|
settings/nm-settings.c \
|
||||||
settings/nm-settings.h \
|
settings/nm-settings.h \
|
||||||
settings/nm-system-config-interface.c \
|
settings/nm-system-config-interface.c \
|
||||||
|
@@ -21,35 +21,23 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include <nm-connection.h>
|
#include <nm-connection.h>
|
||||||
#include "nm-settings-utils.h"
|
#include "nm-device-ethernet-utils.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nm_settings_utils_get_default_wired_name (GHashTable *connections)
|
nm_device_ethernet_utils_get_default_wired_name (const GSList *connections)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
const GSList *iter;
|
||||||
NMConnection *connection = NULL;
|
|
||||||
GSList *names = NULL, *niter;
|
|
||||||
char *cname = NULL;
|
char *cname = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
/* Build up a list of all existing connection names for dupe checking */
|
|
||||||
g_hash_table_iter_init (&iter, connections);
|
|
||||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) {
|
|
||||||
const char *id;
|
|
||||||
|
|
||||||
id = nm_connection_get_id (connection);
|
|
||||||
g_assert (id);
|
|
||||||
names = g_slist_append (names, (gpointer) id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the next available unique connection name */
|
/* Find the next available unique connection name */
|
||||||
while (!cname && (i++ < 10000)) {
|
while (!cname && (i++ < 10000)) {
|
||||||
char *temp;
|
char *temp;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
|
|
||||||
temp = g_strdup_printf (_("Wired connection %d"), i);
|
temp = g_strdup_printf (_("Wired connection %d"), i);
|
||||||
for (niter = names; niter; niter = g_slist_next (niter)) {
|
for (iter = connections; iter; iter = iter->next) {
|
||||||
if (g_strcmp0 (niter->data, temp) == 0) {
|
if (g_strcmp0 (nm_connection_get_id (NM_CONNECTION (iter->data)), temp) == 0) {
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
g_free (temp);
|
g_free (temp);
|
||||||
break;
|
break;
|
||||||
@@ -59,7 +47,6 @@ nm_settings_utils_get_default_wired_name (GHashTable *connections)
|
|||||||
if (found == FALSE)
|
if (found == FALSE)
|
||||||
cname = temp;
|
cname = temp;
|
||||||
}
|
}
|
||||||
g_slist_free (names);
|
|
||||||
|
|
||||||
return cname;
|
return cname;
|
||||||
}
|
}
|
@@ -16,11 +16,11 @@
|
|||||||
* (C) Copyright 2011 Red Hat, Inc.
|
* (C) Copyright 2011 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NETWORKMANAGER_SETTINGS_UTILS_H__
|
#ifndef __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__
|
||||||
#define __NETWORKMANAGER_SETTINGS_UTILS_H__
|
#define __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
char *nm_settings_utils_get_default_wired_name (GHashTable *connections);
|
char *nm_device_ethernet_utils_get_default_wired_name (const GSList *connections);
|
||||||
|
|
||||||
#endif /* NM_SETTINGS_UTILS_H */
|
#endif /* NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H */
|
@@ -55,6 +55,9 @@
|
|||||||
#include "nm-platform.h"
|
#include "nm-platform.h"
|
||||||
#include "nm-dcb.h"
|
#include "nm-dcb.h"
|
||||||
#include "nm-settings-connection.h"
|
#include "nm-settings-connection.h"
|
||||||
|
#include "nm-config.h"
|
||||||
|
#include "nm-device-ethernet-utils.h"
|
||||||
|
#include "nm-connection-provider.h"
|
||||||
|
|
||||||
#include "nm-device-ethernet-glue.h"
|
#include "nm-device-ethernet-glue.h"
|
||||||
|
|
||||||
@@ -1473,6 +1476,51 @@ complete_connection (NMDevice *device,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NMConnection *
|
||||||
|
new_default_connection (NMDevice *self)
|
||||||
|
{
|
||||||
|
NMConnection *connection;
|
||||||
|
const GSList *connections;
|
||||||
|
NMSetting *setting;
|
||||||
|
const char *hw_address;
|
||||||
|
char *defname, *uuid;
|
||||||
|
GByteArray *mac;
|
||||||
|
|
||||||
|
if (!nm_config_get_ethernet_can_auto_default (nm_config_get (), self))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
hw_address = nm_device_get_hw_address (self);
|
||||||
|
if (!hw_address)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
connection = nm_simple_connection_new ();
|
||||||
|
setting = nm_setting_connection_new ();
|
||||||
|
nm_connection_add_setting (connection, setting);
|
||||||
|
|
||||||
|
connections = nm_connection_provider_get_connections (nm_connection_provider_get ());
|
||||||
|
defname = nm_device_ethernet_utils_get_default_wired_name (connections);
|
||||||
|
uuid = nm_utils_uuid_generate ();
|
||||||
|
g_object_set (setting,
|
||||||
|
NM_SETTING_CONNECTION_ID, defname,
|
||||||
|
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
|
||||||
|
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
|
||||||
|
NM_SETTING_CONNECTION_UUID, uuid,
|
||||||
|
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
|
||||||
|
NULL);
|
||||||
|
g_free (uuid);
|
||||||
|
g_free (defname);
|
||||||
|
|
||||||
|
/* Lock the connection to the device */
|
||||||
|
setting = nm_setting_wired_new ();
|
||||||
|
nm_connection_add_setting (connection, setting);
|
||||||
|
|
||||||
|
mac = nm_utils_hwaddr_atoba (hw_address, ETH_ALEN);
|
||||||
|
g_object_set (setting, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
|
||||||
|
g_byte_array_unref (mac);
|
||||||
|
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
spec_match_list (NMDevice *device, const GSList *specs)
|
spec_match_list (NMDevice *device, const GSList *specs)
|
||||||
{
|
{
|
||||||
@@ -1679,6 +1727,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
|||||||
parent_class->update_initial_hw_address = update_initial_hw_address;
|
parent_class->update_initial_hw_address = update_initial_hw_address;
|
||||||
parent_class->check_connection_compatible = check_connection_compatible;
|
parent_class->check_connection_compatible = check_connection_compatible;
|
||||||
parent_class->complete_connection = complete_connection;
|
parent_class->complete_connection = complete_connection;
|
||||||
|
parent_class->new_default_connection = new_default_connection;
|
||||||
|
|
||||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
parent_class->act_stage2_config = act_stage2_config;
|
parent_class->act_stage2_config = act_stage2_config;
|
||||||
|
@@ -1215,6 +1215,14 @@ nm_device_owns_iface (NMDevice *self, const char *iface)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NMConnection *
|
||||||
|
nm_device_new_default_connection (NMDevice *self)
|
||||||
|
{
|
||||||
|
if (NM_DEVICE_GET_CLASS (self)->new_default_connection)
|
||||||
|
return NM_DEVICE_GET_CLASS (self)->new_default_connection (self);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
slave_state_changed (NMDevice *slave,
|
slave_state_changed (NMDevice *slave,
|
||||||
NMDeviceState slave_new_state,
|
NMDeviceState slave_new_state,
|
||||||
|
@@ -209,6 +209,8 @@ typedef struct {
|
|||||||
gboolean (* component_added) (NMDevice *self, GObject *component);
|
gboolean (* component_added) (NMDevice *self, GObject *component);
|
||||||
|
|
||||||
gboolean (* owns_iface) (NMDevice *self, const char *iface);
|
gboolean (* owns_iface) (NMDevice *self, const char *iface);
|
||||||
|
|
||||||
|
NMConnection * (* new_default_connection) (NMDevice *self);
|
||||||
} NMDeviceClass;
|
} NMDeviceClass;
|
||||||
|
|
||||||
|
|
||||||
@@ -362,6 +364,8 @@ gboolean nm_device_notify_component_added (NMDevice *device, GObject *component)
|
|||||||
|
|
||||||
gboolean nm_device_owns_iface (NMDevice *device, const char *iface);
|
gboolean nm_device_owns_iface (NMDevice *device, const char *iface);
|
||||||
|
|
||||||
|
NMConnection *nm_device_new_default_connection (NMDevice *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
/* For testing only */
|
/* For testing only */
|
||||||
|
@@ -67,7 +67,6 @@
|
|||||||
#include "nm-session-monitor.h"
|
#include "nm-session-monitor.h"
|
||||||
#include "plugins/keyfile/plugin.h"
|
#include "plugins/keyfile/plugin.h"
|
||||||
#include "nm-agent-manager.h"
|
#include "nm-agent-manager.h"
|
||||||
#include "nm-settings-utils.h"
|
|
||||||
#include "nm-connection-provider.h"
|
#include "nm-connection-provider.h"
|
||||||
#include "nm-config.h"
|
#include "nm-config.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
@@ -1585,55 +1584,22 @@ default_wired_clear_tag (NMSettings *self,
|
|||||||
void
|
void
|
||||||
nm_settings_device_added (NMSettings *self, NMDevice *device)
|
nm_settings_device_added (NMSettings *self, NMDevice *device)
|
||||||
{
|
{
|
||||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingsConnection *added;
|
NMSettingsConnection *added;
|
||||||
NMSetting *setting;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *hw_address;
|
|
||||||
char *defname, *uuid;
|
|
||||||
GByteArray *mac;
|
|
||||||
|
|
||||||
if (!NM_IS_DEVICE_ETHERNET (device))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* If the device isn't managed or it already has a default wired connection,
|
/* If the device isn't managed or it already has a default wired connection,
|
||||||
* ignore it.
|
* ignore it.
|
||||||
*/
|
*/
|
||||||
if ( !nm_device_get_managed (device)
|
if ( !nm_device_get_managed (device)
|
||||||
|| g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG)
|
|| g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG)
|
||||||
|| have_connection_for_device (self, device)
|
|| have_connection_for_device (self, device))
|
||||||
|| !nm_config_get_ethernet_can_auto_default (priv->config, device))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hw_address = nm_device_get_hw_address (device);
|
connection = nm_device_new_default_connection (device);
|
||||||
if (!hw_address)
|
if (!connection)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
connection = nm_simple_connection_new ();
|
|
||||||
setting = nm_setting_connection_new ();
|
|
||||||
nm_connection_add_setting (connection, setting);
|
|
||||||
|
|
||||||
defname = nm_settings_utils_get_default_wired_name (priv->connections);
|
|
||||||
uuid = nm_utils_uuid_generate ();
|
|
||||||
g_object_set (setting,
|
|
||||||
NM_SETTING_CONNECTION_ID, defname,
|
|
||||||
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
|
|
||||||
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
|
|
||||||
NM_SETTING_CONNECTION_UUID, uuid,
|
|
||||||
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
|
|
||||||
NULL);
|
|
||||||
g_free (uuid);
|
|
||||||
g_free (defname);
|
|
||||||
|
|
||||||
/* Lock the connection to the device */
|
|
||||||
setting = nm_setting_wired_new ();
|
|
||||||
nm_connection_add_setting (connection, setting);
|
|
||||||
|
|
||||||
mac = nm_utils_hwaddr_atoba (hw_address, ETH_ALEN);
|
|
||||||
g_object_set (setting, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
|
|
||||||
g_byte_array_unref (mac);
|
|
||||||
|
|
||||||
/* Add the connection */
|
/* Add the connection */
|
||||||
added = nm_settings_add_connection (self, connection, FALSE, &error);
|
added = nm_settings_add_connection (self, connection, FALSE, &error);
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
AM_CPPFLAGS = \
|
|
||||||
-I$(top_srcdir)/include \
|
|
||||||
-I$(top_srcdir)/libnm-core \
|
|
||||||
-I$(top_builddir)/libnm-core \
|
|
||||||
-I$(top_srcdir)/src/settings \
|
|
||||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
|
||||||
-DNETWORKMANAGER_COMPILATION \
|
|
||||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
|
||||||
$(GLIB_CFLAGS)
|
|
||||||
|
|
||||||
noinst_PROGRAMS = \
|
|
||||||
test-wired-defname
|
|
||||||
|
|
||||||
####### wired defname test #######
|
|
||||||
|
|
||||||
test_wired_defname_SOURCES = \
|
|
||||||
test-wired-defname.c
|
|
||||||
|
|
||||||
test_wired_defname_LDADD = \
|
|
||||||
$(top_builddir)/src/libNetworkManager.la
|
|
||||||
|
|
||||||
###########################################
|
|
||||||
|
|
||||||
TESTS = test-wired-defname
|
|
@@ -6,6 +6,7 @@ AM_CPPFLAGS = \
|
|||||||
-I$(top_builddir)/libnm-core \
|
-I$(top_builddir)/libnm-core \
|
||||||
-I$(top_srcdir)/src/platform \
|
-I$(top_srcdir)/src/platform \
|
||||||
-I$(top_srcdir)/src/dhcp-manager \
|
-I$(top_srcdir)/src/dhcp-manager \
|
||||||
|
-I$(top_srcdir)/src/devices \
|
||||||
-I$(top_srcdir)/src \
|
-I$(top_srcdir)/src \
|
||||||
-I$(top_builddir)/src \
|
-I$(top_builddir)/src \
|
||||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||||
@@ -20,7 +21,8 @@ noinst_PROGRAMS = \
|
|||||||
test-ip4-config \
|
test-ip4-config \
|
||||||
test-ip6-config \
|
test-ip6-config \
|
||||||
test-dcb \
|
test-dcb \
|
||||||
test-resolvconf-capture
|
test-resolvconf-capture \
|
||||||
|
test-wired-defname
|
||||||
|
|
||||||
####### ip4 config test #######
|
####### ip4 config test #######
|
||||||
|
|
||||||
@@ -70,11 +72,26 @@ test_general_with_expect_SOURCES = \
|
|||||||
test_general_with_expect_LDADD = \
|
test_general_with_expect_LDADD = \
|
||||||
$(top_builddir)/src/libNetworkManager.la
|
$(top_builddir)/src/libNetworkManager.la
|
||||||
|
|
||||||
|
####### wired defname test #######
|
||||||
|
|
||||||
|
test_wired_defname_SOURCES = \
|
||||||
|
test-wired-defname.c
|
||||||
|
|
||||||
|
test_wired_defname_LDADD = \
|
||||||
|
$(top_builddir)/src/libNetworkManager.la
|
||||||
|
|
||||||
####### secret agent interface test #######
|
####### secret agent interface test #######
|
||||||
|
|
||||||
EXTRA_DIST = test-secret-agent.py
|
EXTRA_DIST = test-secret-agent.py
|
||||||
|
|
||||||
###########################################
|
###########################################
|
||||||
|
|
||||||
TESTS = test-ip4-config test-ip6-config test-dcb test-resolvconf-capture test-general test-general-with-expect
|
TESTS = \
|
||||||
|
test-ip4-config \
|
||||||
|
test-ip6-config \
|
||||||
|
test-dcb \
|
||||||
|
test-resolvconf-capture \
|
||||||
|
test-general \
|
||||||
|
test-general-with-expect \
|
||||||
|
test-wired-defname
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <nm-simple-connection.h>
|
#include <nm-simple-connection.h>
|
||||||
#include <nm-setting-connection.h>
|
#include <nm-setting-connection.h>
|
||||||
#include "nm-settings-utils.h"
|
#include "nm-device-ethernet-utils.h"
|
||||||
|
|
||||||
static NMConnection *
|
static NMConnection *
|
||||||
_new_connection (const char *id)
|
_new_connection (const char *id)
|
||||||
@@ -43,15 +43,10 @@ _new_connection (const char *id)
|
|||||||
static void
|
static void
|
||||||
test_defname_no_connections (void)
|
test_defname_no_connections (void)
|
||||||
{
|
{
|
||||||
GHashTable *hash;
|
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
hash = g_hash_table_new (g_direct_hash, g_direct_equal);
|
name = nm_device_ethernet_utils_get_default_wired_name (NULL);
|
||||||
|
|
||||||
name = nm_settings_utils_get_default_wired_name (hash);
|
|
||||||
g_assert_cmpstr (name, ==, "Wired connection 1");
|
g_assert_cmpstr (name, ==, "Wired connection 1");
|
||||||
|
|
||||||
g_hash_table_destroy (hash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
@@ -59,19 +54,17 @@ test_defname_no_connections (void)
|
|||||||
static void
|
static void
|
||||||
test_defname_no_conflict (void)
|
test_defname_no_conflict (void)
|
||||||
{
|
{
|
||||||
GHashTable *hash;
|
GSList *list = NULL;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_object_unref);
|
list = g_slist_append (list, _new_connection ("asdfasdfasdfadf"));
|
||||||
|
list = g_slist_append (list, _new_connection ("work wifi"));
|
||||||
|
list = g_slist_append (list, _new_connection ("random gsm connection"));
|
||||||
|
|
||||||
g_hash_table_insert (hash, "a", _new_connection ("asdfasdfasdfadf"));
|
name = nm_device_ethernet_utils_get_default_wired_name (list);
|
||||||
g_hash_table_insert (hash, "b", _new_connection ("work wifi"));
|
|
||||||
g_hash_table_insert (hash, "c", _new_connection ("random gsm connection"));
|
|
||||||
|
|
||||||
name = nm_settings_utils_get_default_wired_name (hash);
|
|
||||||
g_assert_cmpstr (name, ==, "Wired connection 1");
|
g_assert_cmpstr (name, ==, "Wired connection 1");
|
||||||
|
|
||||||
g_hash_table_destroy (hash);
|
g_slist_free_full (list, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
@@ -79,19 +72,17 @@ test_defname_no_conflict (void)
|
|||||||
static void
|
static void
|
||||||
test_defname_conflict (void)
|
test_defname_conflict (void)
|
||||||
{
|
{
|
||||||
GHashTable *hash;
|
GSList *list = NULL;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_object_unref);
|
list = g_slist_append (list, _new_connection ("asdfasdfasdfadf"));
|
||||||
|
list = g_slist_append (list, _new_connection ("Wired connection 1"));
|
||||||
|
list = g_slist_append (list, _new_connection ("random gsm connection"));
|
||||||
|
|
||||||
g_hash_table_insert (hash, "a", _new_connection ("asdfasdfasdfadf"));
|
name = nm_device_ethernet_utils_get_default_wired_name (list);
|
||||||
g_hash_table_insert (hash, "b", _new_connection ("Wired connection 1"));
|
|
||||||
g_hash_table_insert (hash, "c", _new_connection ("random gsm connection"));
|
|
||||||
|
|
||||||
name = nm_settings_utils_get_default_wired_name (hash);
|
|
||||||
g_assert_cmpstr (name, ==, "Wired connection 2");
|
g_assert_cmpstr (name, ==, "Wired connection 2");
|
||||||
|
|
||||||
g_hash_table_destroy (hash);
|
g_slist_free_full (list, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
@@ -99,23 +90,21 @@ test_defname_conflict (void)
|
|||||||
static void
|
static void
|
||||||
test_defname_multiple_conflicts (void)
|
test_defname_multiple_conflicts (void)
|
||||||
{
|
{
|
||||||
GHashTable *hash;
|
GSList *list = NULL;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_object_unref);
|
list = g_slist_append (list, _new_connection ("random gsm connection"));
|
||||||
|
list = g_slist_append (list, _new_connection ("home wifi"));
|
||||||
|
list = g_slist_append (list, _new_connection ("Wired connection 1"));
|
||||||
|
list = g_slist_append (list, _new_connection ("Wired connection 2"));
|
||||||
|
list = g_slist_append (list, _new_connection ("Wired connection 3"));
|
||||||
|
list = g_slist_append (list, _new_connection ("work wifi"));
|
||||||
|
list = g_slist_append (list, _new_connection ("a vpn"));
|
||||||
|
|
||||||
g_hash_table_insert (hash, "a", _new_connection ("random gsm connection"));
|
name = nm_device_ethernet_utils_get_default_wired_name (list);
|
||||||
g_hash_table_insert (hash, "b", _new_connection ("home wifi"));
|
|
||||||
g_hash_table_insert (hash, "c", _new_connection ("Wired connection 1"));
|
|
||||||
g_hash_table_insert (hash, "d", _new_connection ("Wired connection 2"));
|
|
||||||
g_hash_table_insert (hash, "e", _new_connection ("Wired connection 3"));
|
|
||||||
g_hash_table_insert (hash, "f", _new_connection ("work wifi"));
|
|
||||||
g_hash_table_insert (hash, "g", _new_connection ("a vpn"));
|
|
||||||
|
|
||||||
name = nm_settings_utils_get_default_wired_name (hash);
|
|
||||||
g_assert_cmpstr (name, ==, "Wired connection 4");
|
g_assert_cmpstr (name, ==, "Wired connection 4");
|
||||||
|
|
||||||
g_hash_table_destroy (hash);
|
g_slist_free_full (list, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
Reference in New Issue
Block a user