summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am6
-rw-r--r--test/spawn-test.c34
2 files changed, 39 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index ad657826..604fd3f8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2,7 +2,7 @@
INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS)
if DBUS_BUILD_TESTS
-TEST_BINARIES=echo-client echo-server unbase64 bus-test break-loader
+TEST_BINARIES=echo-client echo-server unbase64 bus-test break-loader spawn-test
else
TEST_BINARIES=
endif
@@ -31,6 +31,9 @@ bus_test_SOURCES = \
break_loader_SOURCES= \
break-loader.c
+spawn_test_SOURCES= \
+ spawn-test.c
+
TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la $(top_builddir)/dbus/libdbus-1.la
echo_client_LDADD=$(TEST_LIBS)
@@ -38,6 +41,7 @@ echo_server_LDADD=$(TEST_LIBS)
unbase64_LDADD=$(TEST_LIBS)
break_loader_LDADD= $(TEST_LIBS)
bus_test_LDADD=$(TEST_LIBS) $(top_builddir)/bus/libdbus-daemon.la
+spawn_test_LDADD=$(TEST_LIBS)
dist-hook: \
DIRS="data data/valid-messages data/invalid-messages data/incomplete-messages data/auth" ; \
diff --git a/test/spawn-test.c b/test/spawn-test.c
new file mode 100644
index 00000000..fda0309b
--- /dev/null
+++ b/test/spawn-test.c
@@ -0,0 +1,34 @@
+#include <dbus/dbus.h>
+
+#define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
+#include <dbus/dbus-sysdeps.h>
+#undef DBUS_COMPILATION
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+ char **argv_copy;
+ int i;
+ DBusError error;
+
+ if (argc < 2)
+ {
+ fprintf (stderr, "You need to specify a program to launch.\n");
+
+ return -1;
+ }
+
+ argv_copy = dbus_new (char *, argc);
+ for (i = 0; i < argc - 1; i++)
+ argv_copy [i] = argv[i + 1];
+ argv_copy[argc - 1] = NULL;
+
+ if (!_dbus_spawn_async (argv_copy, &error))
+ {
+ fprintf (stderr, "Could not launch application: \"%s\"\n",
+ error.message);
+ }
+
+ return 0;
+}