test: Move dbus-daemon-launch-helper-test here, and rename

The -test suffix does not indicate that this is a test, but rather that
it is for tests (similar to the -unix and -win suffixes on modules like
dbus-sysdeps). This seems unnecessarily confusing, so rename it to end
with -for-tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2018-10-03 19:01:42 +01:00
parent b28e0886ed
commit e23bba929a
7 changed files with 19 additions and 44 deletions

View file

@ -155,8 +155,8 @@ liblaunch_helper_internal_la_SOURCES = \
## This is the installed launch helper with the setuid checks
## All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must
## be here and in dbus_daemon_launch_helper_test_SOURCES, not in
## liblaunch-helper-internal.la.
## be listed here and included in test/bus/launch-helper-for-tests.c,
## not in liblaunch-helper-internal.la.
dbus_daemon_launch_helper_SOURCES = \
activation-helper.c \
activation-helper-bin.c \
@ -168,21 +168,6 @@ liblaunch_helper_internal_la_LIBADD = \
$(top_builddir)/dbus/libdbus-internal.la \
$(DBUS_LAUNCHER_LIBS)
## we build another binary so we can do the launch testing without root privs.
## DO NOT INSTALL THIS FILE
## All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must
## be here and in dbus_daemon_launch_helper_SOURCES, not in
## liblaunch-helper-internal.la.
dbus_daemon_launch_helper_test_SOURCES= \
activation-helper.c \
activation-helper-bin.c \
$(NULL)
dbus_daemon_launch_helper_test_LDADD = liblaunch-helper-internal.la
dbus_daemon_launch_helper_test_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DACTIVATION_LAUNCHER_TEST
noinst_PROGRAMS =
dbus_daemon_exec_PROGRAMS = dbus-daemon
if DBUS_UNIX
@ -190,22 +175,6 @@ noinst_LTLIBRARIES += liblaunch-helper-internal.la
libexec_PROGRAMS = dbus-daemon-launch-helper
endif DBUS_UNIX
## Note that TESTS has special meaning (stuff to use in make check).
## We don't actually want to run any of these tests until test/ has been
## compiled, so we don't put them in TESTS here; we run them in test/
## instead.
if DBUS_ENABLE_EMBEDDED_TESTS
## we use noinst_PROGRAMS not check_PROGRAMS so that we build
## even when not doing "make check"
if DBUS_UNIX
# this is used by the tests but is not,itself, a test
noinst_PROGRAMS += dbus-daemon-launch-helper-test
endif DBUS_UNIX
endif DBUS_ENABLE_EMBEDDED_TESTS
install-data-hook:
$(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/session.d
$(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/services

View file

@ -495,7 +495,7 @@ if (DBUS_BUILD_TESTS)
set(DBUS_TEST_DBUS_LAUNCH ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN}/dbus-launch${EXEEXT})
set(DBUS_TEST_HOMEDIR ${Z_DRIVE_IF_WINE}${CMAKE_BINARY_DIR}/dbus)
set(DBUS_TEST_RUN_SESSION ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN}/dbus-run-session${EXEEXT})
set(TEST_LAUNCH_HELPER_BINARY ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${IDE_BIN}/dbus-daemon-launch-helper-test${EXEEXT})
set(TEST_LAUNCH_HELPER_BINARY ${Z_DRIVE_IF_WINE}${DBUS_TEST_EXEC}/dbus-daemon-launch-helper-for-tests${EXEEXT})
if (UNIX)
set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR})
set(TEST_LISTEN "unix:tmpdir=${TEST_SOCKET_DIR}")

View file

@ -155,14 +155,6 @@ if(NOT WIN32)
target_link_libraries(dbus-daemon-launch-helper launch-helper-internal)
endif(NOT WIN32)
if (DBUS_ENABLE_EMBEDDED_TESTS)
if (NOT WIN32)
add_executable(dbus-daemon-launch-helper-test ${BUS_DIR}/activation-helper.c ${BUS_DIR}/activation-helper-bin.c)
set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST")
target_link_libraries(dbus-daemon-launch-helper-test launch-helper-internal)
endif()
endif (DBUS_ENABLE_EMBEDDED_TESTS)
if(MSVC)
project_source_group(${GROUP_CODE} bus_test_SOURCES dummy)
endif(MSVC)

View file

@ -111,6 +111,7 @@ if(DBUS_ENABLE_EMBEDDED_TESTS)
if(NOT WIN32)
add_test_executable(test-bus-system ${TEST_DIR}/bus/system.c launch-helper-internal)
add_test_executable(test-bus-launch-helper-oom ${TEST_DIR}/bus/launch-helper-oom.c launch-helper-internal)
add_helper_executable(dbus-daemon-launch-helper-for-tests ${TEST_DIR}/bus/launch-helper-for-tests.c launch-helper-internal)
endif()
endif()

View file

@ -1565,7 +1565,7 @@ AC_DEFINE_UNQUOTED([DBUS_EXEEXT], ["$EXEEXT"],
[Extension for executables, typically empty or .exe])
## Export the non-setuid external helper
TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test$EXEEXT"
TEST_LAUNCH_HELPER_BINARY="$DBUS_TEST_EXEC/dbus-daemon-launch-helper-for-tests$EXEEXT"
AC_SUBST(TEST_LAUNCH_HELPER_BINARY)
AC_DEFINE_UNQUOTED(DBUS_TEST_LAUNCH_HELPER_BINARY, "$TEST_LAUNCH_HELPER_BINARY",
[Full path to the launch helper test program in the builddir])

View file

@ -89,6 +89,8 @@ uninstallable_test_programs += \
if DBUS_UNIX
uninstallable_test_programs += test-bus-launch-helper-oom
uninstallable_test_programs += test-bus-system
# this is used by the tests but is not, itself, a test
TEST_BINARIES += dbus-daemon-launch-helper-for-tests
endif
noinst_PROGRAMS += $(uninstallable_test_programs)
@ -165,6 +167,9 @@ manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la
test_bus_launch_helper_oom_SOURCES = bus/launch-helper-oom.c
test_bus_launch_helper_oom_LDADD = $(top_builddir)/bus/liblaunch-helper-internal.la
dbus_daemon_launch_helper_for_tests_SOURCES = bus/launch-helper-for-tests.c
dbus_daemon_launch_helper_for_tests_LDADD = $(top_builddir)/bus/liblaunch-helper-internal.la
test_bus_system_SOURCES = bus/system.c
test_bus_system_LDADD = $(top_builddir)/bus/liblaunch-helper-internal.la
@ -661,7 +666,7 @@ uninstalled-config-local:
-e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
-e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
-e 's,[@]EXEEXT[@],$(EXEEXT),' \
-e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],@abs_top_builddir@/bus/dbus-daemon-launch-helper-test$(EXEEXT),' \
-e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],@abs_top_builddir@/test/dbus-daemon-launch-helper-for-tests$(EXEEXT),' \
-e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
< $(srcdir)/"$$F" > "$${F%.in}"; \
done

View file

@ -0,0 +1,8 @@
/* Embed a version of the real activation helper that has been altered
* to be testable. We monkey-patch it like this because we don't want to
* compile test-only code into the real setuid executable, and Automake
* versions older than 1.16 can't cope with expanding directory variables
* in SOURCES when using subdir-objects. */
#define ACTIVATION_LAUNCHER_TEST
#include "bus/activation-helper.c"
#include "bus/activation-helper-bin.c"