From b2e65b2a1f90c8a0c17134610f79862007401602 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 1 Aug 2014 12:17:39 -0400 Subject: [PATCH] libnm-glib: compile test-networkmanager-service.py path into test binaries Rather than passing the path to the test service on the command line, compile it into the test programs. (Among other things, this makes it easier to run the test directly from the command line.) (cherry picked from commit 4f7e9bd33637b38eee6c2bfb4340166a5e218486) --- libnm-glib/tests/Makefile.am | 15 +++++++-------- libnm-glib/tests/test-nm-client.c | 13 ++----------- libnm-glib/tests/test-remote-settings-client.c | 9 +++------ 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am index b287147bcc..79ed4386b6 100644 --- a/libnm-glib/tests/Makefile.am +++ b/libnm-glib/tests/Makefile.am @@ -7,6 +7,8 @@ AM_CPPFLAGS = \ -I$(top_builddir)/libnm-util \ -I$(top_srcdir)/libnm-glib \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ + -DTEST_NM_BIN=\"$(abs_srcdir)/test-fake-nm.py\" \ + -DTEST_RSS_BIN=\"$(abs_srcdir)/test-remote-settings-service.py\" \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) @@ -36,18 +38,15 @@ test_remote_settings_client_LDADD = \ ########################################### -TEST_NM_BIN = test-fake-nm.py -TEST_RSS_BIN = test-remote-settings-service.py - -EXTRA_DIST = $(TEST_RSS_BIN) $(TEST_NM_BIN) +EXTRA_DIST = test-fake-nm.py test-remote-settings-service.py check-local: test-nm-client test-remote-settings-client if test -z "$$DBUS_SESSION_BUS_ADDRESS" ; then \ - dbus-launch --exit-with-session $(abs_builddir)/test-nm-client $(abs_srcdir) $(TEST_NM_BIN); \ - dbus-launch --exit-with-session $(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_RSS_BIN); \ + dbus-launch --exit-with-session $(abs_builddir)/test-nm-client; \ + dbus-launch --exit-with-session $(abs_builddir)/test-remote-settings-client; \ else \ - $(abs_builddir)/test-nm-client $(abs_srcdir) $(TEST_NM_BIN); \ - $(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_RSS_BIN); \ + $(abs_builddir)/test-nm-client; \ + $(abs_builddir)/test-remote-settings-client; \ fi; endif diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c index aa2c94d088..9431a64d00 100644 --- a/libnm-glib/tests/test-nm-client.c +++ b/libnm-glib/tests/test-nm-client.c @@ -33,9 +33,6 @@ #include "nm-device-wimax.h" #include "nm-glib-compat.h" -static const char *fake_path; -static const char *fake_bin; -static const char *fake_exec; static GMainLoop *loop = NULL; /*******************************************************************/ @@ -129,7 +126,7 @@ service_init (void) { DBusGConnection *bus; ServiceInfo *sinfo; - const char *args[2] = { fake_exec, NULL }; + const char *args[2] = { TEST_NM_BIN, NULL }; GError *error = NULL; int i = 100; @@ -142,7 +139,7 @@ service_init (void) sinfo->bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); test_assert (sinfo->bus); - if (!g_spawn_async (fake_path, (char **) args, NULL, 0, NULL, NULL, &sinfo->pid, &error)) + if (!g_spawn_async (NULL, (char **) args, NULL, 0, NULL, NULL, &sinfo->pid, &error)) test_assert_no_error (error); /* Wait until the service is registered on the bus */ @@ -924,18 +921,12 @@ test_devices_array (void) int main (int argc, char **argv) { - g_assert (argc == 3); - #if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); #endif g_test_init (&argc, &argv, NULL); - fake_path = argv[1]; - fake_bin = argv[2]; - fake_exec = g_strdup_printf ("%s/%s", argv[1], argv[2]); - loop = g_main_loop_new (NULL, FALSE); g_test_add_func ("/libnm-glib/device-added", test_device_added); diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c index 12501ee361..2bc3309d85 100644 --- a/libnm-glib/tests/test-remote-settings-client.c +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -358,13 +358,11 @@ test_remove_connection (void) int main (int argc, char **argv) { - char *service_argv[3] = { NULL, NULL, NULL }; + char *service_argv[2] = { TEST_RSS_BIN, NULL }; int ret; GError *error = NULL; int i = 100; - g_assert (argc == 3); - #if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); #endif @@ -377,9 +375,8 @@ main (int argc, char **argv) g_assert (error == NULL); } - service_argv[0] = g_strdup_printf ("%s/%s", argv[1], argv[2]); - if (!g_spawn_async (argv[1], service_argv, NULL, 0, NULL, NULL, &spid, &error)) { - g_warning ("Error spawning %s: %s", argv[2], error->message); + if (!g_spawn_async (NULL, service_argv, NULL, 0, NULL, NULL, &spid, &error)) { + g_warning ("Error spawning %s: %s", TEST_RSS_BIN, error->message); g_assert (error == NULL); }