From 03b9ca6d4ecf2577958530b8390d675c73a58825 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 5 Apr 2003 00:37:17 +0000 Subject: 2003-04-04 Havoc Pennington * dbus/dbus-spawn.c, dbus/dbus-spawn.h: Change dbus_spawn to return a "babysitter" object that is used to monitor the status of the spawned process and reap it when required. * test/test-segfault.c, test/test-exit.c, test/test-sleep-forever.c: binaries that do various lame things, used in the test suite. * dbus/dbus-sysdeps.c: kill _dbus_errno_to_string() --- test/Makefile.am | 11 ++++++++++- test/spawn-test.c | 3 ++- test/test-exit.c | 8 ++++++++ test/test-segfault.c | 14 ++++++++++++++ test/test-sleep-forever.c | 12 ++++++++++++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/test-exit.c create mode 100644 test/test-segfault.c create mode 100644 test/test-sleep-forever.c (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index d0429aaf..c46b2797 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=test-service echo-client echo-server unbase64 break-loader spawn-test +TEST_BINARIES=test-service echo-client echo-server unbase64 break-loader spawn-test test-segfault test-exit test-sleep-forever else TEST_BINARIES= endif @@ -40,6 +40,15 @@ break_loader_SOURCES= \ spawn_test_SOURCES= \ spawn-test.c +test_exit_SOURCES = \ + test-exit.c + +test_segfault_SOURCES = \ + test-segfault.c + +test_sleep_forever_SOURCES = \ + test-sleep-forever.c + TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la echo_client_LDADD=$(TEST_LIBS) diff --git a/test/spawn-test.c b/test/spawn-test.c index 18462eba..f323368f 100644 --- a/test/spawn-test.c +++ b/test/spawn-test.c @@ -2,6 +2,7 @@ #define DBUS_COMPILATION /* cheat and use dbus-sysdeps */ #include +#include #undef DBUS_COMPILATION #include @@ -30,7 +31,7 @@ main (int argc, char **argv) argv_copy [i] = argv[i + 1]; argv_copy[argc - 1] = NULL; - if (!_dbus_spawn_async (argv_copy, setup_func, NULL, &error)) + if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy, setup_func, NULL, &error)) { fprintf (stderr, "Could not launch application: \"%s\"\n", error.message); diff --git a/test/test-exit.c b/test/test-exit.c new file mode 100644 index 00000000..abb95865 --- /dev/null +++ b/test/test-exit.c @@ -0,0 +1,8 @@ +/* This is a process that just exits with a failure code */ + +int +main (int argc, char **argv) +{ + + return 1; +} diff --git a/test/test-segfault.c b/test/test-segfault.c new file mode 100644 index 00000000..6c197823 --- /dev/null +++ b/test/test-segfault.c @@ -0,0 +1,14 @@ +/* This is simply a process that segfaults */ +#include + +int +main (int argc, char **argv) +{ + char *p = 0; + + raise (SIGSEGV); + + *p = 'a'; + + return 0; +} diff --git a/test/test-sleep-forever.c b/test/test-sleep-forever.c new file mode 100644 index 00000000..7d9541e8 --- /dev/null +++ b/test/test-sleep-forever.c @@ -0,0 +1,12 @@ +/* This is a process that just sleeps infinitely. */ + +#include + +int +main (int argc, char **argv) +{ + while (1) + sleep (10000000); + + return 1; +} -- cgit