diff options
| author | Michael Biebl <biebl@debian.org> | 2016-01-20 16:26:51 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-01-20 16:26:51 +0100 |
| commit | 494f296a3baab08522617b24b1f126d8f9a17502 (patch) | |
| tree | c8ef32fb0dd1c4ff35a0b38e787abb58692de0cd /src/settings/plugins/ifnet | |
| parent | 54f6333410ffd570e62717d9e77c5c987175e397 (diff) | |
Imported Upstream version 1.1.90 upstream/1.1.90
Diffstat (limited to 'src/settings/plugins/ifnet')
| -rw-r--r-- | src/settings/plugins/ifnet/Makefile.am | 6 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/Makefile.in | 24 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/connection_parser.c | 5 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/net_parser.c | 4 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/net_parser.h | 2 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/net_utils.c | 50 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/net_utils.h | 6 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/nm-ifnet-connection.c | 11 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/plugin.c | 201 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/plugin.h | 24 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/tests/Makefile.am | 23 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/tests/Makefile.in | 446 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/tests/hostname | 2 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/tests/test-ifnet.c (renamed from src/settings/plugins/ifnet/tests/test_all.c) | 252 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/wpa_parser.c | 4 | ||||
| -rw-r--r-- | src/settings/plugins/ifnet/wpa_parser.h | 2 |
16 files changed, 606 insertions, 456 deletions
diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am index 84e2e697..ffd8ab3c 100644 --- a/src/settings/plugins/ifnet/Makefile.am +++ b/src/settings/plugins/ifnet/Makefile.am @@ -6,12 +6,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in index 589f1f22..c6e13316 100644 --- a/src/settings/plugins/ifnet/Makefile.in +++ b/src/settings/plugins/ifnet/Makefile.in @@ -278,7 +278,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -290,8 +289,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -301,6 +298,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -355,16 +353,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -401,6 +396,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -429,7 +426,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -444,6 +440,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -504,6 +502,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -511,6 +510,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -531,12 +531,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c index 888ee589..51ff9da6 100644 --- a/src/settings/plugins/ifnet/connection_parser.c +++ b/src/settings/plugins/ifnet/connection_parser.c @@ -25,10 +25,9 @@ #include <arpa/inet.h> #include <stdlib.h> #include <errno.h> -#include <glib/gi18n.h> -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" +#include "nm-default.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c index 8f528d0f..ee66ff53 100644 --- a/src/settings/plugins/ifnet/net_parser.c +++ b/src/settings/plugins/ifnet/net_parser.c @@ -26,8 +26,8 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "plugin.h" #include "nm-platform.h" diff --git a/src/settings/plugins/ifnet/net_parser.h b/src/settings/plugins/ifnet/net_parser.h index d10979cc..968feaf5 100644 --- a/src/settings/plugins/ifnet/net_parser.h +++ b/src/settings/plugins/ifnet/net_parser.h @@ -22,7 +22,7 @@ #ifndef _NET_PARSER_H #define _NET_PARSER_H -#include <glib.h> +#include "nm-default.h" #define CONF_NET_FILE SYSCONFDIR "/conf.d/net" diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c index adb23c43..1c72e0b2 100644 --- a/src/settings/plugins/ifnet/net_utils.c +++ b/src/settings/plugins/ifnet/net_utils.c @@ -26,11 +26,10 @@ #include <string.h> #include <errno.h> #include <nm-utils.h> -#include <NetworkManagerUtils.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> -#include <nm-config.h> -#include <gio/gio.h> +#include "NetworkManagerUtils.h" +#include <nm-settings-plugin.h> +#include "nm-config.h" +#include "nm-default.h" #include "net_utils.h" #include "wpa_parser.h" #include "net_parser.h" @@ -136,47 +135,6 @@ reload_parsers (void) return TRUE; } -gchar * -read_hostname (const char *path) -{ - gchar *contents = NULL, *result = NULL, *tmp; - gchar **all_lines = NULL; - guint line_num, i; - - if (!g_file_get_contents (path, &contents, NULL, NULL)) - return NULL; - all_lines = g_strsplit (contents, "\n", 0); - line_num = g_strv_length (all_lines); - for (i = 0; i < line_num; i++) { - g_strstrip (all_lines[i]); - if (all_lines[i][0] == '#' || all_lines[i][0] == '\0') - continue; - if (g_str_has_prefix (all_lines[i], "hostname")) { - tmp = strstr (all_lines[i], "="); - tmp++; - result = g_shell_unquote (tmp, NULL); - break; - } - - } - g_strfreev (all_lines); - g_free (contents); - return result; -} - -gboolean -write_hostname (const char *path, const gchar *hostname) -{ - gboolean result; - char *contents; - - contents = g_strdup_printf ("#Generated by NetworkManager\n" - "hostname=\"%s\"\n", hostname); - result = g_file_set_contents (path, contents, -1, NULL); - g_free (contents); - return result; -} - gboolean is_static_ip4 (const char *conn_name) { diff --git a/src/settings/plugins/ifnet/net_utils.h b/src/settings/plugins/ifnet/net_utils.h index d58e7ec6..45969369 100644 --- a/src/settings/plugins/ifnet/net_utils.h +++ b/src/settings/plugins/ifnet/net_utils.h @@ -21,11 +21,11 @@ #ifndef _IFNET_UTILS_H #define _IFNET_UTILS_H -#define IFNET_PLUGIN_NAME "SCPlugin-Ifnet" -#include <glib.h> +#define IFNET_PLUGIN_NAME "SettingsPlugin-Ifnet" #include <arpa/inet.h> #include <nm-setting-ip6-config.h> #include <nm-setting-ip4-config.h> +#include "nm-default.h" #include "net_parser.h" #define has_default_ip4_route(conn_name) has_default_route((conn_name), &is_ip4_address) #define has_default_ip6_route(conn_name) has_default_route((conn_name), &is_ip6_address) @@ -37,8 +37,6 @@ typedef struct _ip_block { struct _ip_block *next; } ip_block; -gchar *read_hostname (const char *path); -gboolean write_hostname (const char *path, const char *hostname); gboolean is_static_ip4 (const char *conn_name); gboolean is_static_ip6 (const char *conn_name); gboolean is_ip4_address (const char *in_address); diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.c b/src/settings/plugins/ifnet/nm-ifnet-connection.c index 693e6532..450fe931 100644 --- a/src/settings/plugins/ifnet/nm-ifnet-connection.c +++ b/src/settings/plugins/ifnet/nm-ifnet-connection.c @@ -27,8 +27,8 @@ #include <nm-utils.h> #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "nm-ifnet-connection.h" #include "connection_parser.h" #include "net_parser.h" @@ -50,7 +50,7 @@ static guint signals[IFNET_LAST_SIGNAL] = { 0 }; typedef struct { gchar *conn_name; - NMSystemConfigInterface *config; + NMSettingsPlugin *config; } NMIfnetConnectionPrivate; NMIfnetConnection * @@ -102,8 +102,9 @@ nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection) static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, - gpointer user_data) + gpointer user_data) { GError *error = NULL; NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection); @@ -139,7 +140,7 @@ commit_changes (NMSettingsConnection *connection, g_free (priv->conn_name); priv->conn_name = new_name; - NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, callback, user_data); + NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); nm_log_info (LOGD_SETTINGS, "Successfully updated %s", priv->conn_name); } else { nm_log_warn (LOGD_SETTINGS, "Failed to update %s", diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c index 5eab31ab..b670cdac 100644 --- a/src/settings/plugins/ifnet/plugin.c +++ b/src/settings/plugins/ifnet/plugin.c @@ -25,17 +25,16 @@ #include <string.h> #include <gmodule.h> -#include <glib.h> -#include <gio/gio.h> #include <nm-utils.h> #include <nm-setting-connection.h> +#include "nm-default.h" #include "nm-dbus-interface.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" #include "nm-ifnet-connection.h" #include "nm-config.h" +#include "NetworkManagerUtils.h" #include "plugin.h" #include "net_utils.h" @@ -45,19 +44,16 @@ #define IFNET_PLUGIN_NAME_PRINT "ifnet" #define IFNET_PLUGIN_INFO "(C) 1999-2010 Gentoo Foundation, Inc. To report bugs please use bugs.gentoo.org with [networkmanager] or [qiaomuf] prefix." -#define IFNET_SYSTEM_HOSTNAME_FILE "/etc/conf.d/hostname" #define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE typedef struct { GHashTable *connections; /* uuid::connection */ - gchar *hostname; gboolean unmanaged_well_known; - GFileMonitor *hostname_monitor; GFileMonitor *net_monitor; GFileMonitor *wpa_monitor; -} SCPluginIfnetPrivate; +} SettingsPluginIfnetPrivate; typedef void (*FileChangedFn) (gpointer user_data); @@ -66,56 +62,17 @@ typedef struct { gpointer user_data; } FileMonitorInfo; -static void system_config_interface_init (NMSystemConfigInterface *class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -static void reload_connections (NMSystemConfigInterface *config); +static void reload_connections (NMSettingsPlugin *config); -G_DEFINE_TYPE_EXTENDED (SCPluginIfnet, sc_plugin_ifnet, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init)) -#define SC_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetPrivate)) -/* -static void -ignore_cb(NMSettingsConnectionInterface * connection, - GError * error, gpointer user_data) -{ -} -*/ -static const char * -get_hostname (NMSystemConfigInterface * config) -{ - return SC_PLUGIN_IFNET_GET_PRIVATE (config)->hostname; -} - -static void -update_system_hostname (gpointer config) -{ - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); - - if (priv->hostname) - g_free (priv->hostname); - priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE); +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfnet, settings_plugin_ifnet, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) +#define SETTINGS_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetPrivate)) - g_object_notify (G_OBJECT (config), - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - nm_log_info (LOGD_SETTINGS, "Hostname updated to: %s", priv->hostname); -} - -static void -write_system_hostname (NMSystemConfigInterface * config, - const gchar * newhostname) -{ - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); - - g_return_if_fail (newhostname); - nm_log_info (LOGD_SETTINGS, "Write system hostname: %s", newhostname); - if (write_hostname (IFNET_SYSTEM_HOSTNAME_FILE, newhostname)) { - g_free (priv->hostname); - priv->hostname = g_strdup (newhostname); - g_object_notify (G_OBJECT (config), - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } else - nm_log_warn (LOGD_SETTINGS, "Write system hostname: %s failed", newhostname); -} +static SettingsPluginIfnet *settings_plugin_ifnet_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfnet, settings_plugin_ifnet_get, SETTINGS_TYPE_PLUGIN_IFNET); static gboolean is_managed_plugin (void) @@ -177,12 +134,9 @@ monitor_file_changes (const char *filename, static void setup_monitors (NMIfnetConnection * connection, gpointer user_data) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - priv->hostname_monitor = - monitor_file_changes (IFNET_SYSTEM_HOSTNAME_FILE, - update_system_hostname, user_data); if (nm_config_get_monitor_connection_files (nm_config_get ())) { priv->net_monitor = monitor_file_changes (CONF_NET_FILE, (FileChangedFn) reload_connections, @@ -196,13 +150,9 @@ setup_monitors (NMIfnetConnection * connection, gpointer user_data) static void cancel_monitors (NMIfnetConnection * connection, gpointer user_data) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - if (priv->hostname_monitor) { - g_file_monitor_cancel (priv->hostname_monitor); - g_object_unref (priv->hostname_monitor); - } if (priv->net_monitor) { g_file_monitor_cancel (priv->net_monitor); g_object_unref (priv->net_monitor); @@ -216,14 +166,14 @@ cancel_monitors (NMIfnetConnection * connection, gpointer user_data) static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } static void -track_new_connection (SCPluginIfnet *self, NMIfnetConnection *connection) +track_new_connection (SettingsPluginIfnet *self, NMIfnetConnection *connection) { - g_hash_table_insert (SC_PLUGIN_IFNET_GET_PRIVATE (self)->connections, + g_hash_table_insert (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self)->connections, g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), g_object_ref (connection)); g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, @@ -232,10 +182,10 @@ track_new_connection (SCPluginIfnet *self, NMIfnetConnection *connection) } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (config); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); GList *conn_names = NULL, *n_iter = NULL; gboolean auto_refresh; GError *error = NULL; @@ -293,7 +243,7 @@ reload_connections (NMSystemConfigInterface *config) nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old)); track_new_connection (self, new); if (is_managed_plugin () && is_managed (conn_name)) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); } } else { /* Update existing connection with new settings */ @@ -310,11 +260,11 @@ reload_connections (NMSystemConfigInterface *config) nm_log_info (LOGD_SETTINGS, "Connection %s updated", nm_connection_get_id (NM_CONNECTION (new))); } - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } else if (new) { track_new_connection (self, new); if (is_managed_plugin () && is_managed (conn_name)) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); } /* Track all valid connections so we can remove deleted ones later */ @@ -341,12 +291,12 @@ reload_connections (NMSystemConfigInterface *config) } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *source, gboolean save_to_disk, GError **error) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); NMIfnetConnection *new = NULL; /* Ensure we reject attempts to add the connection long before we're @@ -363,7 +313,7 @@ add_connection (NMSystemConfigInterface *config, } else { new = nm_ifnet_connection_new (source, NULL); if (new) { - track_new_connection (SC_PLUGIN_IFNET (config), new); + track_new_connection (SETTINGS_PLUGIN_IFNET (config), new); /* track_new_connection refs 'new' */ g_object_unref (new); } @@ -406,9 +356,9 @@ check_unmanaged (gpointer key, gpointer data, gpointer user_data) } static GSList * -get_unmanaged_specs (NMSystemConfigInterface * config) +get_unmanaged_specs (NMSettingsPlugin * config) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); GSList *list = NULL; nm_log_info (LOGD_SETTINGS, "getting unmanaged specs..."); @@ -417,10 +367,10 @@ get_unmanaged_specs (NMSystemConfigInterface * config) } static void -init (NMSystemConfigInterface *config) +init (NMSettingsPlugin *config) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (config); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); nm_log_info (LOGD_SETTINGS, "Initializing!"); @@ -431,15 +381,14 @@ init (NMSystemConfigInterface *config) setup_monitors (NULL, config); reload_connections (config); - update_system_hostname (self); nm_log_info (LOGD_SETTINGS, "Initialzation complete!"); } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); GSList *connections = NULL; GHashTableIter iter; NMIfnetConnection *connection; @@ -459,17 +408,17 @@ get_connections (NMSystemConfigInterface *config) } static void -system_config_interface_init (NMSystemConfigInterface *class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - class->init = init; - class->get_connections = get_connections; - class->get_unmanaged_specs = get_unmanaged_specs; - class->add_connection = add_connection; - class->reload_connections = reload_connections; + plugin_iface->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->add_connection = add_connection; + plugin_iface->reload_connections = reload_connections; } static void -sc_plugin_ifnet_init (SCPluginIfnet * plugin) +settings_plugin_ifnet_init (SettingsPluginIfnet * plugin) { } @@ -477,23 +426,16 @@ static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - NMSystemConfigInterface *self = NM_SYSTEM_CONFIG_INTERFACE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFNET_PLUGIN_NAME_PRINT); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFNET_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: g_value_set_uint (value, - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS - | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, get_hostname (self)); + NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -506,15 +448,6 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:{ - const gchar *hostname = g_value_get_string (value); - - if (hostname && strlen (hostname) < 1) - hostname = NULL; - write_system_hostname (NM_SYSTEM_CONFIG_INTERFACE - (object), hostname); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -524,8 +457,8 @@ set_property (GObject * object, guint prop_id, const GValue * value, static void dispose (GObject * object) { - SCPluginIfnet *plugin = SC_PLUGIN_IFNET (object); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (plugin); + SettingsPluginIfnet *plugin = SETTINGS_PLUGIN_IFNET (object); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (plugin); cancel_monitors (NULL, object); if (priv->connections) { @@ -533,53 +466,37 @@ dispose (GObject * object) priv->connections = NULL; } - g_free (priv->hostname); - priv->hostname = NULL; - ifnet_destroy (); wpa_parser_destroy (); - G_OBJECT_CLASS (sc_plugin_ifnet_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifnet_parent_class)->dispose (object); } static void -sc_plugin_ifnet_class_init (SCPluginIfnetClass * req_class) +settings_plugin_ifnet_class_init (SettingsPluginIfnetClass * req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfnetPrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginIfnetPrivate)); object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfnet *singleton = NULL; - SCPluginIfnetPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFNET (g_object_new (SC_TYPE_PLUGIN_IFNET, NULL)); - priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ifnet_get ()); } diff --git a/src/settings/plugins/ifnet/plugin.h b/src/settings/plugins/ifnet/plugin.h index 6ac0f482..33dcc201 100644 --- a/src/settings/plugins/ifnet/plugin.h +++ b/src/settings/plugins/ifnet/plugin.h @@ -23,25 +23,25 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_IFNET (sc_plugin_ifnet_get_type ()) -#define SC_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFNET, SCPluginIfnet)) -#define SC_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetClass)) -#define SC_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFNET)) -#define SC_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFNET)) -#define SC_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetClass)) +#define SETTINGS_TYPE_PLUGIN_IFNET (settings_plugin_ifnet_get_type ()) +#define SETTINGS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnet)) +#define SETTINGS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) +#define SETTINGS_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFNET)) +#define SETTINGS_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFNET)) +#define SETTINGS_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) -typedef struct _SCPluginIfnet SCPluginIfnet; -typedef struct _SCPluginIfnetClass SCPluginIfnetClass; +typedef struct _SettingsPluginIfnet SettingsPluginIfnet; +typedef struct _SettingsPluginIfnetClass SettingsPluginIfnetClass; -struct _SCPluginIfnet { +struct _SettingsPluginIfnet { GObject parent; }; -struct _SCPluginIfnetClass { +struct _SettingsPluginIfnetClass { GObjectClass parent; }; -GType sc_plugin_ifnet_get_type (void); +GType settings_plugin_ifnet_get_type (void); #endif diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am index 754bb182..1919f141 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -4,42 +4,43 @@ if ENABLE_TESTS AM_CPPFLAGS= \ -I$(srcdir)/../ \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/platform \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(CHECK_CFLAGS) \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ + -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ + -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ -DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \ -DSYSCONFDIR=\"nonexistent\" -noinst_PROGRAMS = check_ifnet -check_ifnet_SOURCES = \ - test_all.c \ +noinst_PROGRAMS = test-ifnet +test_ifnet_SOURCES = \ + test-ifnet.c \ ../connection_parser.c \ ../net_parser.c \ ../net_utils.c \ ../wpa_parser.c -check_ifnet_LDFLAGS = \ +test_ifnet_LDFLAGS = \ $(CODE_COVERAGE_LDFLAGS) -check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la +test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la -check-local: check_ifnet - $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) +#@VALGRIND_RULES@ +TESTS = test-ifnet endif EXTRA_DIST = \ - hostname \ net \ net.all \ nm-system-settings.conf \ diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in index d331ecee..1e08b955 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.in +++ b/src/settings/plugins/ifnet/tests/Makefile.in @@ -88,7 +88,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = check_ifnet$(EXEEXT) +@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ifnet$(EXEEXT) +@ENABLE_TESTS_TRUE@TESTS = test-ifnet$(EXEEXT) subdir = src/settings/plugins/ifnet/tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ @@ -112,22 +113,22 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am__check_ifnet_SOURCES_DIST = test_all.c ../connection_parser.c \ +am__test_ifnet_SOURCES_DIST = test-ifnet.c ../connection_parser.c \ ../net_parser.c ../net_utils.c ../wpa_parser.c -@ENABLE_TESTS_TRUE@am_check_ifnet_OBJECTS = test_all.$(OBJEXT) \ +@ENABLE_TESTS_TRUE@am_test_ifnet_OBJECTS = test-ifnet.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ connection_parser.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ net_parser.$(OBJEXT) net_utils.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ wpa_parser.$(OBJEXT) -check_ifnet_OBJECTS = $(am_check_ifnet_OBJECTS) -@ENABLE_TESTS_TRUE@check_ifnet_DEPENDENCIES = \ +test_ifnet_OBJECTS = $(am_test_ifnet_OBJECTS) +@ENABLE_TESTS_TRUE@test_ifnet_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -check_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ +test_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(check_ifnet_LDFLAGS) $(LDFLAGS) -o $@ + $(test_ifnet_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -162,8 +163,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(check_ifnet_SOURCES) -DIST_SOURCES = $(am__check_ifnet_SOURCES_DIST) +SOURCES = $(test_ifnet_SOURCES) +DIST_SOURCES = $(am__test_ifnet_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -188,8 +189,212 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp + $(top_srcdir)/build-aux/depcomp \ + $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ @@ -206,7 +411,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -218,8 +422,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -229,6 +431,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -283,16 +486,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -329,6 +529,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -357,7 +559,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -372,6 +573,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -432,6 +635,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -439,6 +643,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -456,35 +661,36 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ $(CHECK_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ +@ENABLE_TESTS_TRUE@ -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ +@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @ENABLE_TESTS_TRUE@ -DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \ @ENABLE_TESTS_TRUE@ -DSYSCONFDIR=\"nonexistent\" -@ENABLE_TESTS_TRUE@check_ifnet_SOURCES = \ -@ENABLE_TESTS_TRUE@ test_all.c \ +@ENABLE_TESTS_TRUE@test_ifnet_SOURCES = \ +@ENABLE_TESTS_TRUE@ test-ifnet.c \ @ENABLE_TESTS_TRUE@ ../connection_parser.c \ @ENABLE_TESTS_TRUE@ ../net_parser.c \ @ENABLE_TESTS_TRUE@ ../net_utils.c \ @ENABLE_TESTS_TRUE@ ../wpa_parser.c -@ENABLE_TESTS_TRUE@check_ifnet_LDFLAGS = \ +@ENABLE_TESTS_TRUE@test_ifnet_LDFLAGS = \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) -@ENABLE_TESTS_TRUE@check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la +@ENABLE_TESTS_TRUE@test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la EXTRA_DIST = \ - hostname \ net \ net.all \ nm-system-settings.conf \ @@ -494,7 +700,7 @@ EXTRA_DIST = \ all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -534,9 +740,9 @@ clean-noinstPROGRAMS: echo " rm -f" $$list; \ rm -f $$list -check_ifnet$(EXEEXT): $(check_ifnet_OBJECTS) $(check_ifnet_DEPENDENCIES) $(EXTRA_check_ifnet_DEPENDENCIES) - @rm -f check_ifnet$(EXEEXT) - $(AM_V_CCLD)$(check_ifnet_LINK) $(check_ifnet_OBJECTS) $(check_ifnet_LDADD) $(LIBS) +test-ifnet$(EXEEXT): $(test_ifnet_OBJECTS) $(test_ifnet_DEPENDENCIES) $(EXTRA_test_ifnet_DEPENDENCIES) + @rm -f test-ifnet$(EXEEXT) + $(AM_V_CCLD)$(test_ifnet_LINK) $(test_ifnet_OBJECTS) $(test_ifnet_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -547,7 +753,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_all.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifnet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpa_parser.Po@am__quote@ .c.o: @@ -685,6 +891,169 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +test-ifnet.log: test-ifnet$(EXEEXT) + @p='test-ifnet$(EXEEXT)'; \ + b='test-ifnet'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -715,9 +1084,8 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done -@ENABLE_TESTS_FALSE@check-local: check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) installdirs: @@ -741,6 +1109,9 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: @@ -824,7 +1195,7 @@ uninstall-am: .MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ +.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ @@ -836,16 +1207,13 @@ uninstall-am: installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am + recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile @ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ -@ENABLE_TESTS_TRUE@check-local: check_ifnet -@ENABLE_TESTS_TRUE@ $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/settings/plugins/ifnet/tests/hostname b/src/settings/plugins/ifnet/tests/hostname deleted file mode 100644 index 25c76165..00000000 --- a/src/settings/plugins/ifnet/tests/hostname +++ /dev/null @@ -1,2 +0,0 @@ -#Generated by NetworkManager -hostname="gentoo" diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test-ifnet.c index 55e7e283..96fb5dd3 100644 --- a/src/settings/plugins/ifnet/tests/test_all.c +++ b/src/settings/plugins/ifnet/tests/test-ifnet.c @@ -24,14 +24,13 @@ #include <stdio.h> #include <string.h> -#include <glib.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> #include <nm-utils.h> +#include "nm-default.h" #include "nm-linux-platform.h" -#include "nm-logging.h" #include "net_parser.h" #include "net_utils.h" @@ -59,82 +58,38 @@ nm_config_get_dhcp_client (NMConfig *config) static void test_getdata (void) { - ASSERT (ifnet_get_data ("eth1", "config") - && strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0, - "get data", "config_eth1 is not correct"); - ASSERT (ifnet_get_data ("ppp0", "username") - && strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0, - "get data", "config_ppp0 username is not correctly read"); - ASSERT (ifnet_get_data ("ppp0", "password") - && strcmp (ifnet_get_data ("ppp0", "password"), - "password") == 0, "get data", - "config_ppp0 password is not correctly read"); - ASSERT (ifnet_get_global_data ("modules") - && strcmp ("!wpa_supplicant", ifnet_get_global_data ("modules")) == 0, - "get data", "config_eth1 is not correct"); -} - -static void -test_read_hostname (const char *base_path) -{ - char *hostname_path, *hostname; - - hostname_path = g_build_filename (base_path, "hostname", NULL); - hostname = read_hostname (hostname_path); - - g_assert_cmpstr (hostname, ==, "gentoo"); - - g_free (hostname); - g_free (hostname_path); -} - -static void -test_write_hostname (const char *temp_path) -{ - char *hostname_path, *hostname; - - hostname_path = g_build_filename (temp_path, "hostname-test", NULL); - write_hostname (hostname_path, "gentoo-nm"); - hostname = read_hostname (hostname_path); - - g_assert_cmpstr (hostname, ==, "gentoo-nm"); - - g_free (hostname); - unlink (hostname_path); - g_free (hostname_path); + g_assert (ifnet_get_data ("eth1", "config") && + strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0); + g_assert (ifnet_get_data ("ppp0", "username") && + strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0); + g_assert (ifnet_get_data ("ppp0", "password") && + strcmp (ifnet_get_data ("ppp0", "password"), "password") == 0); + g_assert (ifnet_get_global_data ("modules") && + strcmp ("!wpa_supplicant", ifnet_get_global_data ("modules")) == 0); } static void test_is_static (void) { - ASSERT (is_static_ip4 ("eth1") == FALSE, "is static", - "a dhcp interface is recognized as static"); - ASSERT (is_static_ip4 ("eth0") == TRUE, "is static", - "a static interface is recognized as dhcp"); - ASSERT (is_static_ip6 ("eth0") == FALSE, "is static", - "a dhcp interface is recognized as static"); + g_assert (!is_static_ip4 ("eth1")); + g_assert (is_static_ip4 ("eth0")); + g_assert (!is_static_ip6 ("eth0")); } static void test_has_default_route (void) { - ASSERT (has_default_ip4_route ("eth0"), - "has default route", "eth0 should have a default ipv4 route"); - ASSERT (has_default_ip6_route ("eth4"), - "has default route", "eth4 should have a default ipv6 route"); - ASSERT (!has_default_ip4_route ("eth5") - && !has_default_ip6_route ("eth5"), - "has default route", "eth5 shouldn't have a default route"); + g_assert (has_default_ip4_route ("eth0")); + g_assert (has_default_ip6_route ("eth4")); + g_assert (!has_default_ip4_route ("eth5") && + !has_default_ip6_route ("eth5")); } static void test_has_ip6_address (void) { - ASSERT (has_ip6_address ("eth2"), "has ip6 address", - "eth2 should have a ipv6 address"); - ASSERT (!has_ip6_address ("eth0"), "has ip6 address", - "eth0 shouldn't have a ipv6 address") - + g_assert (has_ip6_address ("eth2")); + g_assert (!has_ip6_address ("eth0")); } static void @@ -144,12 +99,9 @@ test_is_ip4_address (void) gchar *address2 = "192.168.100.{1..254}/24"; gchar *address3 = "192.168.4.2555/24"; - ASSERT (is_ip4_address (address1), "is ip4 address", - "%s should be a valid address", address1); - ASSERT (is_ip4_address (address2), "is ip4 address", - "%s should be a valid address", address2); - ASSERT (!is_ip4_address (address3), "is ip4 address", - "%s should be an invalid address", address3); + g_assert (is_ip4_address (address1)); + g_assert (is_ip4_address (address2)); + g_assert (!is_ip4_address (address3)); } static void @@ -157,19 +109,15 @@ test_is_ip6_address (void) { gchar *address1 = "4321:0:1:2:3:4:567:89ac/24"; - ASSERT (is_ip6_address (address1), "is ip6 address", - "%s should be a valid address", address1); + g_assert (is_ip6_address (address1)); } static void check_ip_block (ip_block * iblock, gchar * ip, guint32 prefix, gchar * gateway) { - ASSERT (strcmp (ip, iblock->ip) == 0, "check ip", - "ip expected:%s, find:%s", ip, iblock->ip); - ASSERT (prefix == iblock->prefix, "check netmask", - "prefix expected:%d, find:%d", prefix, iblock->prefix); - ASSERT (g_strcmp0 (gateway, iblock->next_hop) == 0, "check gateway", - "gateway expected:%s, find:%s", gateway, iblock->next_hop); + g_assert_cmpstr (ip, ==, iblock->ip); + g_assert (prefix == iblock->prefix); + g_assert_cmpstr (gateway, ==, iblock->next_hop); } static void @@ -178,13 +126,11 @@ test_convert_ipv4_config_block (void) ip_block *iblock = convert_ip4_config_block ("eth0"); ip_block *tmp = iblock; - ASSERT (iblock != NULL, "convert ipv4 block", - "block eth0 should not be NULL"); + g_assert (iblock != NULL); check_ip_block (iblock, "202.117.16.121", 24, "202.117.16.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock != NULL, "convert ipv4 block", - "block eth0 should have a second IP address"); + g_assert (iblock != NULL); check_ip_block (iblock, "192.168.4.121", 24, "202.117.16.1"); destroy_ip_block (iblock); @@ -192,17 +138,14 @@ test_convert_ipv4_config_block (void) "*Can't handle IPv4 address*202.117.16.1211*"); iblock = convert_ip4_config_block ("eth2"); g_test_assert_expected_messages (); - ASSERT (iblock != NULL - && iblock->next == NULL, - "convert error IPv4 address", "should only get one address"); + g_assert (iblock != NULL && iblock->next == NULL); check_ip_block (iblock, "192.168.4.121", 24, NULL); destroy_ip_block (iblock); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*missing netmask or prefix*"); iblock = convert_ip4_config_block ("eth3"); - ASSERT (iblock == NULL, "convert config_block", - "convert error configuration"); + g_assert (iblock == NULL); } static void @@ -211,22 +154,20 @@ test_convert_ipv4_routes_block (void) ip_block *iblock = convert_ip4_routes_block ("eth0"); ip_block *tmp = iblock; - ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); + g_assert (iblock != NULL); check_ip_block (iblock, "192.168.4.0", 24, "192.168.4.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock == NULL, "convert ip4 routes", - "should only get one route"); + g_assert (iblock == NULL); iblock = convert_ip4_routes_block ("eth9"); tmp = iblock; - ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); + g_assert (iblock != NULL); check_ip_block (iblock, "10.0.0.0", 8, "192.168.0.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock == NULL, "convert ip4 routes", - "should only get one route"); + g_assert (iblock == NULL); } static void @@ -258,19 +199,15 @@ test_strip_string (void) result = strip_string (result, '('); result = strip_string (result, ')'); result = strip_string (result, '"'); - ASSERT (strcmp (result, "default via 202.117.16.1") == - 0, "strip_string", - "string isn't stripped, result is: %s", result); + g_assert_cmpstr (result, ==, "default via 202.117.16.1"); g_free (result_b); } static void test_is_unmanaged (void) { - ASSERT (is_managed ("eth0"), "test_is_unmanaged", - "eth0 should be managed"); - ASSERT (!is_managed ("eth4"), "test_is_unmanaged", - "eth4 should be unmanaged"); + g_assert (is_managed ("eth0")); + g_assert (!is_managed ("eth4")); } static void @@ -285,33 +222,23 @@ test_new_connection (void) "*Can't handle IPv6 address*202.117.16.1211*"); connection = ifnet_update_connection_from_config_block ("eth2", NULL, &error); g_test_assert_expected_messages (); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("qiaomuf", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("myxjtu2", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("eth9", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection(eth9) failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("eth10", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection(eth10) failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); } @@ -329,17 +256,16 @@ kill_backup (char **path) #define SUP_GEN_NAME "wpa_supplicant.conf.generate" static void -test_update_connection (const char *basepath) +test_update_connection (void) { GError *error = NULL; NMConnection *connection; gboolean success; char *backup = NULL; + char *basepath = TEST_IFNET_DIR; connection = ifnet_update_connection_from_config_block ("eth0", basepath, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); success = ifnet_update_parsers_by_connection (connection, "eth0", NET_GEN_NAME, @@ -348,12 +274,11 @@ test_update_connection (const char *basepath) &backup, &error); kill_backup (&backup); - ASSERT (success, "update connection", "update connection failed %s", "eth0"); + g_assert (success); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("0xab3ace", basepath, &error); - ASSERT (connection != NULL, "get connection", "get connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); success = ifnet_update_parsers_by_connection (connection, "0xab3ace", NET_GEN_NAME, @@ -362,7 +287,7 @@ test_update_connection (const char *basepath) &backup, &error); kill_backup (&backup); - ASSERT (success, "update connection", "update connection failed %s", "0xab3ace"); + g_assert (success); g_object_unref (connection); unlink (NET_GEN_NAME); @@ -370,14 +295,14 @@ test_update_connection (const char *basepath) } static void -test_add_connection (const char *basepath) +test_add_connection (void) { NMConnection *connection; char *backup = NULL; + const char *basepath = TEST_IFNET_DIR; connection = ifnet_update_connection_from_config_block ("eth0", basepath, NULL); - ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL), - "add connection", "add connection failed: %s", "eth0"); + g_assert (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL)); kill_backup (&backup); g_object_unref (connection); @@ -387,8 +312,7 @@ test_add_connection (const char *basepath) "*Can't handle ipv4 address: 202.117.16.255, missing netmask or prefix*"); connection = ifnet_update_connection_from_config_block ("myxjtu2", basepath, NULL); g_test_assert_expected_messages (); - ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL), - "add connection", "add connection failed: %s", "myxjtu2"); + g_assert (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL)); kill_backup (&backup); g_object_unref (connection); @@ -404,20 +328,14 @@ test_delete_connection (void) char *backup = NULL; connection = ifnet_update_connection_from_config_block ("eth7", NULL, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); - ASSERT (ifnet_delete_connection_in_parsers ("eth7", NET_GEN_NAME, SUP_GEN_NAME, &backup), - "delete connection", "delete connection failed: %s", "eth7"); + g_assert (connection != NULL); + g_assert (ifnet_delete_connection_in_parsers ("eth7", NET_GEN_NAME, SUP_GEN_NAME, &backup)); kill_backup (&backup); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("qiaomuf", NULL, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); - ASSERT (ifnet_delete_connection_in_parsers ("qiaomuf", NET_GEN_NAME, SUP_GEN_NAME, &backup), - "delete connection", "delete connection failed: %s", "qiaomuf"); + g_assert (connection != NULL); + g_assert (ifnet_delete_connection_in_parsers ("qiaomuf", NET_GEN_NAME, SUP_GEN_NAME, &backup)); kill_backup (&backup); g_object_unref (connection); @@ -435,54 +353,46 @@ test_missing_config (void) "*Unknown config for eth8*"); connection = ifnet_update_connection_from_config_block ("eth8", NULL, &error); g_test_assert_expected_messages (); - ASSERT (connection == NULL && error != NULL, "get connection", - "get connection should fail with 'Unknown config for eth8'"); + g_assert (connection == NULL && error != NULL); } NMTST_DEFINE (); +#define TPATH "/settings/plugins/ifnet/" + int main (int argc, char **argv) { - char *f; + int ret; nm_linux_platform_setup (); nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); - f = g_build_filename (argv[1], "net", NULL); - ifnet_init (f); - g_free (f); - - f = g_build_filename (argv[1], "wpa_supplicant.conf", NULL); - wpa_parser_init (f); - g_free (f); - - test_strip_string (); - test_is_static (); - test_has_ip6_address (); - test_has_default_route (); - test_getdata (); - test_read_hostname (argv[1]); - test_write_hostname (argv[2]); - test_is_ip4_address (); - test_is_ip6_address (); - test_convert_ipv4_config_block (); - test_convert_ipv4_routes_block (); - test_is_unmanaged (); - test_wpa_parser (); - test_convert_ipv4_routes_block (); - test_new_connection (); - test_update_connection (argv[1]); - test_add_connection (argv[1]); - test_delete_connection (); - test_missing_config (); + ifnet_init (TEST_IFNET_DIR "/net"); + wpa_parser_init (TEST_IFNET_DIR "/wpa_supplicant.conf"); + + g_test_add_func (TPATH "strip-string", test_strip_string); + g_test_add_func (TPATH "is-static", test_is_static); + g_test_add_func (TPATH "has-ip6-address", test_has_ip6_address); + g_test_add_func (TPATH "has-default-route", test_has_default_route); + g_test_add_func (TPATH "get-data", test_getdata); + g_test_add_func (TPATH "is-ip4-address", test_is_ip4_address); + g_test_add_func (TPATH "is-ip6-address", test_is_ip6_address); + g_test_add_func (TPATH "convert-ip4-config", test_convert_ipv4_config_block); + g_test_add_func (TPATH "convert-ip4-routes", test_convert_ipv4_routes_block); + g_test_add_func (TPATH "is-unmanaged", test_is_unmanaged); + g_test_add_func (TPATH "wpa-parser", test_wpa_parser); + g_test_add_func (TPATH "new-connection", test_new_connection); + g_test_add_func (TPATH "update-connection", test_update_connection); + g_test_add_func (TPATH "add-connection", test_add_connection); + g_test_add_func (TPATH "delete-connection", test_delete_connection); + g_test_add_func (TPATH "missing-config", test_missing_config); + + ret = g_test_run (); ifnet_destroy (); wpa_parser_destroy (); - f = g_path_get_basename (argv[0]); - fprintf (stdout, "%s: SUCCESS\n", f); - g_free (f); - return 0; + return ret; } diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c index 3f912da8..9f228d0b 100644 --- a/src/settings/plugins/ifnet/wpa_parser.c +++ b/src/settings/plugins/ifnet/wpa_parser.c @@ -23,8 +23,8 @@ #include <string.h> #include <stdlib.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "wpa_parser.h" #include "net_parser.h" #include "net_utils.h" diff --git a/src/settings/plugins/ifnet/wpa_parser.h b/src/settings/plugins/ifnet/wpa_parser.h index 3a0d377e..8099d19c 100644 --- a/src/settings/plugins/ifnet/wpa_parser.h +++ b/src/settings/plugins/ifnet/wpa_parser.h @@ -22,7 +22,7 @@ #ifndef _WPA_PARSER_H #define _WPA_PARSER_H -#include <glib.h> +#include "nm-default.h" #define WPA_SUPPLICANT_CONF SYSCONFDIR "/wpa_supplicant/wpa_supplicant.conf" |