From a15839da9b4575a8f9c433c5afed85b02a044162 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 3 Oct 2018 18:49:56 +0100 Subject: [PATCH] test: Move dbus-daemon and d-d-launch-helper tests from bus/ This groups them with the other tests, and avoids having them influence the test coverage stats in bus/. Signed-off-by: Simon McVittie --- bus/Makefile.am | 24 ------------------- cmake/bus/CMakeLists.txt | 9 ------- cmake/test/CMakeLists.txt | 11 +++++++++ test/Makefile.am | 20 +++++++++------- .../bus/launch-helper-oom.c | 17 +++++++++---- bus/test-main.c => test/bus/main.c | 4 ++-- bus/test-system.c => test/bus/system.c | 2 +- 7 files changed, 38 insertions(+), 49 deletions(-) rename bus/test-launch-helper.c => test/bus/launch-helper-oom.c (86%) rename bus/test-main.c => test/bus/main.c (97%) rename bus/test-system.c => test/bus/system.c (98%) diff --git a/bus/Makefile.am b/bus/Makefile.am index 3b049df52..fef3210ac 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -183,19 +183,6 @@ dbus_daemon_launch_helper_test_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DACTIVATION_LAUNCHER_TEST -## we build yet another binary so we can do the OOM tests -## DO NOT INSTALL THIS FILE -test_bus_launch_helper_SOURCES = \ - activation-helper.c \ - test-launch-helper.c \ - $(NULL) -test_bus_launch_helper_LDADD = liblaunch-helper-internal.la - -test_bus_launch_helper_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DACTIVATION_LAUNCHER_TEST \ - -DACTIVATION_LAUNCHER_DO_OOM - noinst_PROGRAMS = dbus_daemon_exec_PROGRAMS = dbus-daemon if DBUS_UNIX @@ -212,24 +199,13 @@ if DBUS_ENABLE_EMBEDDED_TESTS ## we use noinst_PROGRAMS not check_PROGRAMS so that we build ## even when not doing "make check" -# run as a test by test/Makefile.am -noinst_PROGRAMS += test-bus - if DBUS_UNIX -# run as a test by test/Makefile.am -noinst_PROGRAMS += test-bus-launch-helper test-bus-system # 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 -test_bus_system_SOURCES = test-system.c -test_bus_system_LDADD = liblaunch-helper-internal.la - -test_bus_SOURCES = test-main.c -test_bus_LDADD = libdbus-daemon-internal.la - install-data-hook: $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/session.d $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/services diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 24f3bf69e..31a03fff8 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -156,19 +156,10 @@ if(NOT WIN32) endif(NOT WIN32) if (DBUS_ENABLE_EMBEDDED_TESTS) - set(SOURCES ${BUS_DIR}/test-main.c) - add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES}) - set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) if (NOT WIN32) - add_test_executable(test-bus-system ${BUS_DIR}/test-system.c launch-helper-internal) - 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) - - set (SOURCES ${BUS_DIR}/activation-helper.c ${BUS_DIR}/test-launch-helper.c) - add_test_executable(test-bus-launch-helper "${SOURCES}" launch-helper-internal) - set_target_properties(test-bus-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") endif() endif (DBUS_ENABLE_EMBEDDED_TESTS) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 8d18119c3..71d358d3b 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -92,6 +92,17 @@ if(WIN32) add_helper_executable(manual-paths ${manual-paths_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) endif() +if(DBUS_ENABLE_EMBEDDED_TESTS) + set(SOURCES ${TEST_DIR}/bus/main.c) + add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES}) + set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) + + 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) + endif() +endif() + if(DBUS_WITH_GLIB) message(STATUS "with glib test apps") diff --git a/test/Makefile.am b/test/Makefile.am index f408a1680..5d34f2be1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -79,16 +79,11 @@ if !DBUS_WINCE uninstallable_test_programs += test-spawn-oom endif -## These are conceptually part of directories that come earlier in SUBDIRS -## order, but we don't want to run them til we arrive in this directory, -## since they depend on stuff from this directory. We wrap some of them in a -## simple shell script to get TAP output. - -TESTS += ../bus/test-bus$(EXEEXT) +uninstallable_test_programs += test-bus if DBUS_UNIX -TESTS += ../bus/test-bus-launch-helper$(EXEEXT) -TESTS += ../bus/test-bus-system$(EXEEXT) +uninstallable_test_programs += test-bus-launch-helper-oom +uninstallable_test_programs += test-bus-system endif TESTS += ../dbus/test-dbus$(EXEEXT) @@ -164,6 +159,15 @@ manual_paths_LDADD = $(top_builddir)/dbus/libdbus-internal.la manual_tcp_SOURCES = manual-tcp.c 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 + +test_bus_system_SOURCES = bus/system.c +test_bus_system_LDADD = $(top_builddir)/bus/liblaunch-helper-internal.la + +test_bus_SOURCES = bus/main.c +test_bus_LDADD = $(top_builddir)/bus/libdbus-daemon-internal.la + EXTRA_DIST += dbus-test-runner testexecdir = $(libexecdir)/installed-tests/dbus diff --git a/bus/test-launch-helper.c b/test/bus/launch-helper-oom.c similarity index 86% rename from bus/test-launch-helper.c rename to test/bus/launch-helper-oom.c index 3b0d0d99a..4aaa03c2e 100644 --- a/bus/test-launch-helper.c +++ b/test/bus/launch-helper-oom.c @@ -23,18 +23,27 @@ */ #include -#include "test.h" -#include "activation-helper.h" + +#include "bus/test.h" #include #include #include +#include "bus/activation-helper.h" + #if !defined(DBUS_ENABLE_EMBEDDED_TESTS) || !defined(DBUS_UNIX) #error This file is only relevant for the embedded tests on Unix #endif -#ifdef ACTIVATION_LAUNCHER_DO_OOM +/* 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 +#define ACTIVATION_LAUNCHER_DO_OOM +#include "bus/activation-helper.c" /* returns true if good things happen, or if we get OOM */ static dbus_bool_t @@ -69,8 +78,6 @@ bus_activation_helper_oom_test (void *data, return retval; } -#endif - static dbus_bool_t bus_activation_helper_test (const char *test_data_dir) { diff --git a/bus/test-main.c b/test/bus/main.c similarity index 97% rename from bus/test-main.c rename to test/bus/main.c index d6dbe8b38..67e5c65ce 100644 --- a/bus/test-main.c +++ b/test/bus/main.c @@ -24,12 +24,12 @@ #include -#include "test.h" +#include "bus/test.h" #include #include -#include "selinux.h" +#include "bus/selinux.h" #ifndef DBUS_ENABLE_EMBEDDED_TESTS #error This file is only relevant for the embedded tests diff --git a/bus/test-system.c b/test/bus/system.c similarity index 98% rename from bus/test-system.c rename to test/bus/system.c index a2a4458e5..9a41826a4 100644 --- a/bus/test-system.c +++ b/test/bus/system.c @@ -24,7 +24,7 @@ #include -#include "test.h" +#include "bus/test.h" #include #include -- 2.47.3