summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-06-20 10:19:37 -0400
committerDan Winship <danw@gnome.org>2014-07-15 09:44:55 -0400
commit3aad3124f13dd0800cfd52dd88ac44b29d026bab (patch)
tree843b21b4a53325ddb98180c5ef80421234b28c79
parent2570c5a17ceab3eb39695493b07144cba04eadbf (diff)
downloadNetworkManager-3aad3124f13dd0800cfd52dd88ac44b29d026bab.tar.gz
libnm-glib: drop separate test library
Previously, we built a second copy of libnm-glib that was hacked to use the session bus rather than the system bus, for use by the test programs. Rather than doing that, just have test-nm-client explicitly override the choice of bus. (test-remote-settings-client was actually already doing this, although it leaked the bus after.)
-rw-r--r--libnm-glib/Makefile.am24
-rw-r--r--libnm-glib/nm-dbus-helpers.c7
-rw-r--r--libnm-glib/tests/Makefile.am4
-rw-r--r--libnm-glib/tests/test-nm-client.c13
-rw-r--r--libnm-glib/tests/test-remote-settings-client.c1
5 files changed, 17 insertions, 32 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am
index 623bf45d1d..c43dab885c 100644
--- a/libnm-glib/Makefile.am
+++ b/libnm-glib/Makefile.am
@@ -18,8 +18,7 @@ BUILT_SOURCES = \
noinst_LTLIBRARIES = \
- libdeprecated-nm-glib.la \
- libnm-glib-test.la
+ libdeprecated-nm-glib.la
#####################################################
# Deprecated original libnm_glib bits
@@ -177,27 +176,6 @@ libnm_glib_vpn_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib-vpn.ver \
BUILT_SOURCES += $(GLIB_GENERATED)
#####################################################
-# Test libnm-glib stuff
-#####################################################
-
-libnm_glib_test_la_CFLAGS = \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(GUDEV_CFLAGS) \
- -DLIBNM_GLIB_TEST \
- -DNMRUNDIR=\"$(nmrundir)\"
-
-libnm_glib_test_la_SOURCES = \
- $(libnminclude_HEADERS) \
- $(libnm_glib_la_SOURCES)
-
-libnm_glib_test_la_LIBADD = \
- $(top_builddir)/libnm-util/libnm-util.la \
- $(GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(GUDEV_LIBS)
-
-#####################################################
nm-vpn-plugin-glue.h: $(top_srcdir)/introspection/nm-vpn-plugin.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_plugin --mode=glib-server --output=$@ $<
diff --git a/libnm-glib/nm-dbus-helpers.c b/libnm-glib/nm-dbus-helpers.c
index 8ba8dd8484..25004310d9 100644
--- a/libnm-glib/nm-dbus-helpers.c
+++ b/libnm-glib/nm-dbus-helpers.c
@@ -68,13 +68,8 @@ _nm_dbus_new_connection (GError **error)
}
#endif
- if (connection == NULL) {
-#ifdef LIBNM_GLIB_TEST
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
-#else
+ if (connection == NULL)
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
-#endif
- }
return connection;
}
diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am
index 38f449ac1a..b287147bcc 100644
--- a/libnm-glib/tests/Makefile.am
+++ b/libnm-glib/tests/Makefile.am
@@ -19,7 +19,7 @@ test_nm_client_SOURCES = \
test_nm_client_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
- $(top_builddir)/libnm-glib/libnm-glib-test.la \
+ $(top_builddir)/libnm-glib/libnm-glib.la \
$(GLIB_LIBS) \
$(DBUS_LIBS)
@@ -30,7 +30,7 @@ test_remote_settings_client_SOURCES = \
test_remote_settings_client_LDADD = \
$(top_builddir)/libnm-util/libnm-util.la \
- $(top_builddir)/libnm-glib/libnm-glib-test.la \
+ $(top_builddir)/libnm-glib/libnm-glib.la \
$(GLIB_LIBS) \
$(DBUS_LIBS)
diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c
index 36c921ae98..572e1fdc6b 100644
--- a/libnm-glib/tests/test-nm-client.c
+++ b/libnm-glib/tests/test-nm-client.c
@@ -127,6 +127,7 @@ name_exists (GDBusConnection *c, const char *name)
static ServiceInfo *
service_init (void)
{
+ DBusGConnection *bus;
ServiceInfo *sinfo;
const char *args[2] = { fake_exec, NULL };
GError *error = NULL;
@@ -165,9 +166,19 @@ service_init (void)
NULL, NULL);
test_assert (sinfo->proxy);
- sinfo->client = nm_client_new ();
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ g_assert_no_error (error);
+
+ sinfo->client = g_object_new (NM_TYPE_CLIENT,
+ NM_OBJECT_DBUS_CONNECTION, bus,
+ NM_OBJECT_DBUS_PATH, NM_DBUS_PATH,
+ NULL);
test_assert (sinfo->client != NULL);
+ dbus_g_connection_unref (bus);
+ g_initable_init (G_INITABLE (sinfo->client), NULL, &error);
+ g_assert_no_error (error);
+
return sinfo;
}
diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c
index 0114f20048..d92583a112 100644
--- a/libnm-glib/tests/test-remote-settings-client.c
+++ b/libnm-glib/tests/test-remote-settings-client.c
@@ -392,6 +392,7 @@ main (int argc, char **argv)
ret = g_test_run ();
cleanup ();
+ dbus_g_connection_unref (bus);
return ret;
}