From 03d6d24d71ffc078cde98203af3bad3cd838f4c5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 15 Apr 2017 21:06:23 +0100 Subject: [PATCH] Pass in DBUS_TEST_EXEC via environment, not hard-coded into binaries This avoids "capturing" the build directory in the built binaries when built with embedded tests, which is good for reproducible builds. See for more information. Signed-off-by: Simon McVittie --- cmake/config.h.cmake | 1 - cmake/modules/Macros.cmake | 1 + configure.ac | 2 -- dbus/dbus-spawn-test.c | 8 ++++---- test/Makefile.am | 2 ++ 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 335819ed..8305a68a 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -31,7 +31,6 @@ #define TEST_LISTEN "@TEST_LISTEN@" // test binaries -#define DBUS_TEST_EXEC "@DBUS_TEST_EXEC@" #define DBUS_EXEEXT "@EXEEXT@" /* Some dbus features */ diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index 6ca06487..d237521f 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -63,6 +63,7 @@ macro(add_test_executable _target _source) list(APPEND _env "DBUS_FATAL_WARNINGS=1") list(APPEND _env "DBUS_TEST_DATA=${PREFIX}${CMAKE_BINARY_DIR}/test/data") list(APPEND _env "DBUS_TEST_DBUS_LAUNCH=${PREFIX}${CMAKE_BINARY_DIR}/bin/dbus-launch${EXEEXT}") + list(APPEND _env "DBUS_TEST_EXEC=${PREFIX}${DBUS_TEST_EXEC}") list(APPEND _env "DBUS_TEST_HOMEDIR=${PREFIX}${CMAKE_BINARY_DIR}/dbus") set_tests_properties(${_target} PROPERTIES ENVIRONMENT "${_env}") endmacro(add_test_executable) diff --git a/configure.ac b/configure.ac index 5debaf6d..64c60ff2 100644 --- a/configure.ac +++ b/configure.ac @@ -1742,8 +1742,6 @@ DBUS_TEST_DATA="$DBUS_PWD/test/data" AC_SUBST([DBUS_TEST_DATA]) AC_SUBST([DBUS_TEST_EXEC]) -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]) diff --git a/dbus/dbus-spawn-test.c b/dbus/dbus-spawn-test.c index bffb33e0..2d9b6ec7 100644 --- a/dbus/dbus-spawn-test.c +++ b/dbus/dbus-spawn-test.c @@ -38,7 +38,7 @@ get_test_exec (const char *exe, dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC"); if (dbus_test_exec == NULL) - dbus_test_exec = DBUS_TEST_EXEC; + return NULL; if (!_dbus_string_init (scratch_space)) return NULL; @@ -111,7 +111,7 @@ check_spawn_segfault (void *data) if (argv[0] == NULL) { - /* OOM was simulated, never mind */ + /* OOM was simulated or DBUS_TEST_EXEC was unset; either is OK */ return TRUE; } @@ -166,7 +166,7 @@ check_spawn_exit (void *data) if (argv[0] == NULL) { - /* OOM was simulated, never mind */ + /* OOM was simulated or DBUS_TEST_EXEC was unset; either is OK */ return TRUE; } @@ -217,7 +217,7 @@ check_spawn_and_kill (void *data) if (argv[0] == NULL) { - /* OOM was simulated, never mind */ + /* OOM was simulated or DBUS_TEST_EXEC was unset; either is OK */ return TRUE; } diff --git a/test/Makefile.am b/test/Makefile.am index 42f193b9..5beb1b29 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -235,6 +235,7 @@ installcheck_environment = \ export DBUS_TEST_DBUS_LAUNCH=$(DESTDIR)$(bindir)/dbus-launch$(EXEEXT); \ export DBUS_TEST_DBUS_MONITOR=$(DESTDIR)$(bindir)/dbus-monitor$(EXEEXT); \ export DBUS_TEST_DBUS_SEND=$(DESTDIR)$(bindir)/dbus-send$(EXEEXT); \ + export DBUS_TEST_EXEC=@abs_top_builddir@/test; \ export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \ export DBUS_TEST_DATADIR=$(DESTDIR)$(datadir); \ ${NULL} @@ -253,6 +254,7 @@ AM_TESTS_ENVIRONMENT = \ export DBUS_TEST_DBUS_MONITOR=@abs_top_builddir@/tools/dbus-monitor$(EXEEXT); \ export DBUS_TEST_DBUS_SEND=@abs_top_builddir@/tools/dbus-send$(EXEEXT); \ export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \ + export DBUS_TEST_EXEC=@abs_top_builddir@/test; \ export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \ $(NULL) -- 2.11.0