# test binary names
if (WIN32)
set (EXT ".exe")
+ # compatible with Automake .in files
+ set (EXEEXT ".exe")
endif(WIN32)
if (MSVC_IDE)
if(CMAKE_BUILD_TYPE MATCHES Debug)
- set(IDE_BIN Debug/ )
+ set(IDE_BIN /Debug )
message(STATUS)
message(STATUS "Visual Studio: test programs will only work with 'Debug' configuration!")
message(STATUS "To run tests with 'Release' configuration use -DCMAKE_BUILD_TYPE=Release")
message(STATUS "Add '..\\..\\test\\data' to the command line option of the test programs")
message(STATUS)
else(CMAKE_BUILD_TYPE MATCHES Debug)
- set(IDE_BIN Release/)
+ set(IDE_BIN /Release)
message(STATUS)
message(STATUS "Visual Studio: test programs will only work with 'Release' configuration!")
message(STATUS "To run tests with 'Debug' configuration use -DCMAKE_BUILD_TYPE=Debug")
endif (MSVC_IDE)
set(TEST_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files CACHE STRING "Full path to test file test/data/valid-service-files in builddir" )
-set(TEST_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-service${EXT} CACHE STRING "Full path to test file test/test-service in builddir" ${TEST_PATH_FORCE})
-set(TEST_SHELL_SERVICE_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-shell-service${EXT} CACHE STRING "Full path to test file test/test-shell-service in builddir" ${TEST_PATH_FORCE})
-set(TEST_EXIT_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-exit${EXT} CACHE STRING "Full path to test file test/test-exit in builddir" ${TEST_PATH_FORCE})
-set(TEST_SEGFAULT_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-segfault${EXT} CACHE STRING "Full path to test file test/test-segfault in builddir" ${TEST_PATH_FORCE})
-set(TEST_SLEEP_FOREVER_BINARY ${CMAKE_BINARY_DIR}/bin/${IDE_BIN}test-sleep-forever${EXT} CACHE STRING "Full path to test file test/test-sleep-forever in builddir" ${TEST_PATH_FORCE})
#### Find socket directories
if (NOT $ENV{TMPDIR} STREQUAL "")
if (DBUS_BUILD_TESTS)
# set variables used for the .in files (substituted by configure_file) in test/data:
+ set(DBUS_TEST_EXEC ${EXECUTABLE_OUTPUT_PATH}${IDE_BIN})
set(DBUS_TEST_DATA ${CMAKE_BINARY_DIR}/test/data)
set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} )
set(TEST_LAUNCH_HELPER_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-daemon-launch-helper-test)
- set(TEST_PRIVSERVER_BINARY ${EXECUTABLE_OUTPUT_PATH}/test-privserver)
if (UNIX)
set (TEST_LISTEN "debug-pipe:name=test-server</listen><listen>unix:tmpdir=${TEST_SOCKET_DIR}")
set (TEST_CONNECTION "debug-pipe:name=test-server")
#define TEST_CONNECTION "@TEST_CONNECTION@"
// test binaries
+#define DBUS_TEST_EXEC "@DBUS_TEST_EXEC@"
+#define DBUS_EXEEXT "@EXEEXT@"
+
/* Full path to test file test/test-exit in builddir */
#define TEST_BUS_BINARY "@TEST_BUS_BINARY@"
-/* Full path to test file test/test-exit in builddir */
-#define TEST_EXIT_BINARY "@TEST_EXIT_BINARY@"
-/* Full path to test file test/test-segfault in builddir */
-#define TEST_SEGFAULT_BINARY "@TEST_SEGFAULT_BINARY@"
-/* Full path to test file test/test-service in builddir */
-#define TEST_SERVICE_BINARY "@TEST_SERVICE_BINARY@"
-/* Full path to test file test/test-shell-service in builddir */
-#define TEST_SHELL_SERVICE_BINARY "@TEST_SHELL_SERVICE_BINARY@"
-/* Full path to test file test/test-sleep-forever in builddir */
-#define TEST_SLEEP_FOREVER_BINARY "@TEST_SLEEP_FOREVER_BINARY@"
/* Some dbus features */
#cmakedefine DBUS_BUILD_TESTS 1
# Useful in a cross-compilation environment, where the tests are run on the host system.
AC_ARG_WITH(dbus-test-dir, AS_HELP_STRING([--with-dbus-test-dir=[dirname]],[path where the tests tools are available]),
DBUS_PWD=$withval)
-AC_DEFUN([TEST_PROG], [
-TEST_$1=${DBUS_PWD}/test/$2
-AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1$EXEEXT",
- [Full path to test file test/$2 in builddir])
-AC_SUBST(TEST_$1)
-])
+DBUS_TEST_EXEC="$DBUS_PWD/test"
DBUS_TEST_DATA="$DBUS_PWD/test/data"
+
AC_SUBST([DBUS_TEST_DATA])
+AC_SUBST([DBUS_TEST_EXEC])
-TEST_PROG(SERVICE_BINARY, test-service)
-TEST_PROG(SHELL_SERVICE_BINARY, test-shell-service)
-TEST_PROG(EXIT_BINARY, test-exit)
-TEST_PROG(SEGFAULT_BINARY, test-segfault)
-TEST_PROG(SLEEP_FOREVER_BINARY, test-sleep-forever)
-TEST_PROG(PRIVSERVER_BINARY, name-test/test-privserver)
+AC_DEFINE_UNQUOTED([DBUS_TEST_EXEC], ["$DBUS_TEST_EXEC"],
+ [Full path to the daemon in the builddir])
+AC_DEFINE_UNQUOTED([DBUS_EXEEXT], ["$EXEEXT"],
+ [Extension for executables, typically empty or .exe])
-AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, "$DBUS_PWD/bus/dbus-daemon$EXEEXT",
+AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, ["$DBUS_PWD/bus/dbus-daemon$EXEEXT"],
[Full path to the daemon in the builddir])
AC_SUBST(TEST_BUS_BINARY)
#ifdef DBUS_BUILD_TESTS
+static char *
+get_test_exec (const char *exe,
+ DBusString *scratch_space)
+{
+ const char *dbus_test_exec;
+
+ dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC");
+
+ if (dbus_test_exec == NULL)
+ dbus_test_exec = DBUS_TEST_EXEC;
+
+ if (!_dbus_string_init (scratch_space))
+ return NULL;
+
+ if (!_dbus_string_append_printf (scratch_space, "%s/%s%s",
+ dbus_test_exec, exe, DBUS_EXEEXT))
+ {
+ _dbus_string_free (scratch_space);
+ return NULL;
+ }
+
+ return _dbus_string_get_data (scratch_space);
+}
+
#define LIVE_CHILDREN(sitter) ((sitter)->child_handle != NULL)
static void
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter;
DBusError error;
+ DBusString argv0;
sitter = NULL;
/*** Test launching segfault binary */
- argv[0] = TEST_SEGFAULT_BINARY;
+ argv[0] = get_test_exec ("test-segfault", &argv0);
+
+ if (argv[0] == NULL)
+ {
+ /* OOM was simulated, never mind */
+ return TRUE;
+ }
+
if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL,
NULL, NULL,
&error))
_dbus_babysitter_set_child_exit_error (sitter, &error);
}
+ _dbus_string_free (&argv0);
+
if (sitter)
_dbus_babysitter_unref (sitter);
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter;
DBusError error;
+ DBusString argv0;
sitter = NULL;
/*** Test launching exit failure binary */
- argv[0] = TEST_EXIT_BINARY;
+ argv[0] = get_test_exec ("test-exit", &argv0);
+
+ if (argv[0] == NULL)
+ {
+ /* OOM was simulated, never mind */
+ return TRUE;
+ }
+
if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL,
NULL, NULL,
&error))
_dbus_babysitter_set_child_exit_error (sitter, &error);
}
+ _dbus_string_free (&argv0);
+
if (sitter)
_dbus_babysitter_unref (sitter);
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter;
DBusError error;
+ DBusString argv0;
sitter = NULL;
/*** Test launching sleeping binary then killing it */
- argv[0] = TEST_SLEEP_FOREVER_BINARY;
+ argv[0] = get_test_exec ("test-sleep-forever", &argv0);
+
+ if (argv[0] == NULL)
+ {
+ /* OOM was simulated, never mind */
+ return TRUE;
+ }
+
if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL,
NULL, NULL,
&error))
_dbus_babysitter_set_child_exit_error (sitter, &error);
}
+ _dbus_string_free (&argv0);
+
if (sitter)
_dbus_babysitter_unref (sitter);
#ifdef DBUS_BUILD_TESTS
+static char *
+get_test_exec (const char *exe,
+ DBusString *scratch_space)
+{
+ const char *dbus_test_exec;
+
+ dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC");
+
+ if (dbus_test_exec == NULL)
+ dbus_test_exec = DBUS_TEST_EXEC;
+
+ if (!_dbus_string_init (scratch_space))
+ return NULL;
+
+ if (!_dbus_string_append_printf (scratch_space, "%s/%s%s",
+ dbus_test_exec, exe, DBUS_EXEEXT))
+ {
+ _dbus_string_free (scratch_space);
+ return NULL;
+ }
+
+ return _dbus_string_get_data (scratch_space);
+}
+
static void
_dbus_babysitter_block_for_child_exit (DBusBabysitter *sitter)
{
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter = NULL;
DBusError error = DBUS_ERROR_INIT;
+ DBusString argv0;
/*** Test launching segfault binary */
-
- argv[0] = TEST_SEGFAULT_BINARY;
+
+ argv[0] = get_test_exec ("test-segfault", &argv0);
+
+ if (argv[0] == NULL)
+ {
+ /* OOM was simulated, never mind */
+ return TRUE;
+ }
+
if (_dbus_spawn_async_with_babysitter (&sitter, argv,
NULL, NULL, NULL,
&error))
_dbus_babysitter_set_child_exit_error (sitter, &error);
}
+ _dbus_string_free (&argv0);
+
if (sitter)
_dbus_babysitter_unref (sitter);
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter = NULL;
DBusError error = DBUS_ERROR_INIT;
+ DBusString argv0;
/*** Test launching exit failure binary */
-
- argv[0] = TEST_EXIT_BINARY;
+
+ argv[0] = get_test_exec ("test-exit", &argv0);
+
+ if (argv[0] == NULL)
+ {
+ /* OOM was simulated, never mind */
+ return TRUE;
+ }
+
if (_dbus_spawn_async_with_babysitter (&sitter, argv,
NULL, NULL, NULL,
&error))
_dbus_babysitter_set_child_exit_error (sitter, &error);
}
+ _dbus_string_free (&argv0);
+
if (sitter)
_dbus_babysitter_unref (sitter);
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter = NULL;
DBusError error = DBUS_ERROR_INIT;
+ DBusString argv0;
/*** Test launching sleeping binary then killing it */
- argv[0] = TEST_SLEEP_FOREVER_BINARY;
+ argv[0] = get_test_exec ("test-sleep-forever", &argv0);
+
+ if (argv[0] == NULL)
+ {
+ /* OOM was simulated, never mind */
+ return TRUE;
+ }
+
if (_dbus_spawn_async_with_babysitter (&sitter, argv,
NULL, NULL, NULL,
&error))
_dbus_babysitter_set_child_exit_error (sitter, &error);
}
+ _dbus_string_free (&argv0);
+
if (sitter)
_dbus_babysitter_unref (sitter);
[D-BUS Service]
-Exec=@TEST_SERVICE_BINARY@
+Exec=@DBUS_TEST_EXEC@/test-service@EXEEXT@
User=anyrandomuser
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteNoUser
-Exec=@TEST_SERVICE_BINARY@
-
+Exec=@DBUS_TEST_EXEC@/test-service@EXEEXT@
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteEchoService
-Exec=@TEST_SERVICE_BINARY@
+Exec=@DBUS_TEST_EXEC@/test-service@EXEEXT@
User=anyrandomuser
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteSegfaultService
-Exec=@TEST_SEGFAULT_BINARY@
+Exec=@DBUS_TEST_EXEC@/test-segfault@EXEEXT@
User=anyrandomuser
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteShellEchoServiceFail
-Exec=@TEST_SHELL_SERVICE_BINARY@ "this should 'fail' because of an unterminated quote
+Exec=@DBUS_TEST_EXEC@/test-shell-service@EXEEXT@ "this should 'fail' because of an unterminated quote
User=anyrandomuser
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess
-Exec=@TEST_SHELL_SERVICE_BINARY@ -test "that" 'we get' back --what "we put in"
+Exec=@DBUS_TEST_EXEC@/test-shell-service@EXEEXT@ -test "that" 'we get' back --what "we put in"
User=anyrandomuser
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuite.PrivServer
-Exec=@TEST_PRIVSERVER_BINARY@
+Exec=@DBUS_TEST_EXEC@/name-test/test-privserver@EXEEXT@
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteEchoService
-Exec=@TEST_SERVICE_BINARY@
-
+Exec=@DBUS_TEST_EXEC@/test-service@EXEEXT@
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteForkingEchoService
-Exec=@TEST_SERVICE_BINARY@ org.freedesktop.DBus.TestSuiteForkingEchoService fork
+Exec=@DBUS_TEST_EXEC@/test-service@EXEEXT@ org.freedesktop.DBus.TestSuiteForkingEchoService fork
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteSegfaultService
-Exec=@TEST_SEGFAULT_BINARY@
+Exec=@DBUS_TEST_EXEC@/test-segfault@EXEEXT@
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteShellEchoServiceFail
-Exec=@TEST_SHELL_SERVICE_BINARY@ "this should 'fail' because of an unterminated quote
-
+Exec=@DBUS_TEST_EXEC@/test-shell-service@EXEEXT@ "this should 'fail' because of an unterminated quote
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess
-Exec=@TEST_SHELL_SERVICE_BINARY@ -test "that" 'we get' back --what "we put in"
+Exec=@DBUS_TEST_EXEC@/test-shell-service@EXEEXT@ -test "that" 'we get' back --what "we put in"