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.)
This commit is contained in:
Dan Winship 2014-07-30 17:20:16 -04:00
parent d005c77213
commit 4f7e9bd336
3 changed files with 10 additions and 23 deletions

View file

@ -6,6 +6,7 @@ AM_CPPFLAGS = \
-I$(top_builddir)/libnm-util \
-I$(top_srcdir)/libnm-glib \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
-DTEST_NM_SERVICE=\"$(abs_top_srcdir)/tools/test-networkmanager-service.py\" \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
@ -35,15 +36,13 @@ test_remote_settings_client_LDADD = \
###########################################
TEST_NM_SERVICE = $(top_srcdir)/tools/test-networkmanager-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_SERVICE); \
dbus-launch --exit-with-session $(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_NM_SERVICE); \
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_SERVICE); \
$(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_NM_SERVICE); \
$(abs_builddir)/test-nm-client; \
$(abs_builddir)/test-remote-settings-client; \
fi;
endif

View file

@ -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_SERVICE, 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);

View file

@ -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_NM_SERVICE, 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_NM_SERVICE, error->message);
g_assert (error == NULL);
}