mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-06 03:28:11 +02:00
cmake: extend macro add_test_executable() to get specific environment variables
This commit is contained in:
parent
b8292da025
commit
4cdb60a78c
3 changed files with 86 additions and 64 deletions
|
|
@ -115,10 +115,18 @@ endmacro()
|
|||
# create executable and add an associated unit test
|
||||
#
|
||||
# see @ref add_helper_executable for supported parameters
|
||||
# @param ARGS <args> additional arguments added to the test command in front of the target file
|
||||
# @param ENV <env> additional environment variables to provide to the running test
|
||||
# @param LIBS <libs> additional libraries to link the executable with
|
||||
#
|
||||
macro(add_test_executable _target _source)
|
||||
add_helper_executable(${_target} "${_source}" ${ARGN})
|
||||
add_unit_test(${_target} ${_target})
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs ARGS ENV LIBS)
|
||||
cmake_parse_arguments(ATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
add_helper_executable(${_target} "${_source}" LIBS ${ATE_LIBS})
|
||||
add_unit_test(${_target} ${_target} ARGS ${ATE_ARGS} ENV ${ATE_ENV})
|
||||
endmacro()
|
||||
|
||||
#
|
||||
|
|
@ -134,31 +142,45 @@ endmacro()
|
|||
#
|
||||
# @param _target target name
|
||||
# @param _source sources to add to this target
|
||||
# @param LIBS <libs> additional libraries to link the executable with
|
||||
#
|
||||
macro(add_helper_executable _target _source)
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs LIBS)
|
||||
cmake_parse_arguments(AHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
set(_sources "${_source}")
|
||||
if(WIN32 AND NOT MSVC)
|
||||
# avoid triggering UAC
|
||||
add_uac_manifest(_sources)
|
||||
endif()
|
||||
add_executable(${_target} ${_sources})
|
||||
target_link_libraries(${_target} ${ARGN})
|
||||
target_link_libraries(${_target} ${AHE_LIBS})
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# create executable and add an associated unit test with dbus session setup
|
||||
#
|
||||
# see @ref add_helper_executable for supported parameters
|
||||
# see @ref add_unit_test for supported parameters
|
||||
#
|
||||
macro(add_session_test_executable _target _source)
|
||||
add_helper_executable(${_target} "${_source}" ${ARGN})
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs ARGS ENV LIBS)
|
||||
cmake_parse_arguments(ASTE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
add_helper_executable(${_target} "${_source}" LIBS ${ASTE_LIBS})
|
||||
add_unit_test(${_target} ${_target}
|
||||
ARGS
|
||||
${DBUS_TEST_RUN_SESSION}
|
||||
--config-file=${DBUS_TEST_DATA}/valid-config-files/tmp-session.conf
|
||||
--dbus-daemon=${DBUS_TEST_DAEMON}
|
||||
${ASTE_ARGS}
|
||||
ENV
|
||||
"DBUS_SESSION_BUS_PID="
|
||||
${ASTE_ENV}
|
||||
)
|
||||
endmacro()
|
||||
|
||||
|
|
|
|||
|
|
@ -74,36 +74,36 @@ set(manual-paths_SOURCES
|
|||
manual-paths.c
|
||||
)
|
||||
|
||||
add_helper_executable(manual-dir-iter ${manual-dir-iter_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(test-service ${test-service_SOURCES} dbus-testutils)
|
||||
add_helper_executable(test-names ${test-names_SOURCES} dbus-testutils)
|
||||
add_test_executable(test-shell ${test-shell_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_test_executable(test-string internals/strings.c dbus-testutils)
|
||||
add_test_executable(test-printf internals/printf.c dbus-testutils)
|
||||
add_helper_executable(test-privserver test-privserver.c dbus-testutils)
|
||||
add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils)
|
||||
add_helper_executable(manual-dir-iter ${manual-dir-iter_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(test-service ${test-service_SOURCES} LIBS dbus-testutils)
|
||||
add_helper_executable(test-names ${test-names_SOURCES} LIBS dbus-testutils)
|
||||
add_test_executable(test-shell ${test-shell_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_test_executable(test-string internals/strings.c LIBS dbus-testutils)
|
||||
add_test_executable(test-printf internals/printf.c LIBS dbus-testutils)
|
||||
add_helper_executable(test-privserver test-privserver.c LIBS dbus-testutils)
|
||||
add_helper_executable(test-shell-service ${test-shell-service_SOURCES} LIBS dbus-testutils)
|
||||
if(NOT WINCE AND ENABLE_TRADITIONAL_ACTIVATION)
|
||||
add_test_executable(test-spawn-oom internals/spawn-oom.c dbus-testutils)
|
||||
add_test_executable(test-spawn-oom internals/spawn-oom.c LIBS dbus-testutils)
|
||||
endif()
|
||||
if(ENABLE_TRADITIONAL_ACTIVATION)
|
||||
add_helper_executable(test-spawn ${test-spawn_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(test-spawn ${test-spawn_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
endif()
|
||||
add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(test-exit ${test-exit_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
# the second argument of add_helper_executable() is a whitespace-separated
|
||||
# list of source files and the third and subsequent arguments are libraries
|
||||
# to link, hence the quoting here
|
||||
add_helper_executable(test-segfault "${test-segfault_SOURCES}")
|
||||
add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(manual-socket-afunix manual-socket-afunix.c dbus-testutils)
|
||||
add_helper_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(manual-backtrace manual-backtrace.c dbus-1)
|
||||
add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(manual-socket-afunix manual-socket-afunix.c LIBS dbus-testutils)
|
||||
add_helper_executable(manual-tcp ${manual-tcp_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_helper_executable(manual-backtrace manual-backtrace.c LIBS dbus-1)
|
||||
if(WIN32)
|
||||
add_helper_executable(manual-paths ${manual-paths_SOURCES} dbus-testutils)
|
||||
add_helper_executable(manual-paths ${manual-paths_SOURCES} LIBS dbus-testutils)
|
||||
endif()
|
||||
|
||||
if(DBUS_ENABLE_INTRUSIVE_TESTS)
|
||||
add_test_executable(test-atomic ${test-atomic_SOURCES} dbus-testutils)
|
||||
add_test_executable(test-hash internals/hash.c dbus-testutils)
|
||||
add_test_executable(test-atomic ${test-atomic_SOURCES} LIBS dbus-testutils)
|
||||
add_test_executable(test-hash internals/hash.c LIBS dbus-testutils)
|
||||
set_target_properties(test-hash PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
set(SOURCES
|
||||
|
|
@ -111,7 +111,7 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS)
|
|||
internals/dbus-marshal-recursive-util.h
|
||||
internals/marshal-recursive.c
|
||||
)
|
||||
add_test_executable(test-marshal-recursive "${SOURCES}" dbus-testutils)
|
||||
add_test_executable(test-marshal-recursive "${SOURCES}" LIBS dbus-testutils)
|
||||
set_target_properties(test-marshal-recursive PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
set(SOURCES
|
||||
|
|
@ -123,7 +123,7 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS)
|
|||
internals/dbus-message-util.h
|
||||
internals/message-internals.c
|
||||
)
|
||||
add_test_executable(test-message-internals "${SOURCES}" dbus-testutils)
|
||||
add_test_executable(test-message-internals "${SOURCES}" LIBS dbus-testutils)
|
||||
set_target_properties(test-message-internals PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
set(SOURCES
|
||||
|
|
@ -143,39 +143,39 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS)
|
|||
internals/misc-internals.h
|
||||
internals/sha.c
|
||||
)
|
||||
add_test_executable(test-misc-internals "${SOURCES}" dbus-testutils)
|
||||
add_test_executable(test-misc-internals "${SOURCES}" LIBS dbus-testutils)
|
||||
set_target_properties(test-misc-internals PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
add_test_executable(test-platform-mutex test-platform-mutex.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
|
||||
add_test_executable(test-platform-mutex test-platform-mutex.c LIBS ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
|
||||
|
||||
set(SOURCES bus/main.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
add_test_executable(test-bus "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
if(ENABLE_TRADITIONAL_ACTIVATION)
|
||||
set(SOURCES bus/normal-activation.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus-normal-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
add_test_executable(test-bus-normal-activation "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus-normal-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
|
||||
set(SOURCES bus/dispatch-sha1.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus-dispatch-sha1 PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
if(NOT WIN32)
|
||||
add_test_executable(test-bus-system bus/system.c launch-helper-internal dbus-testutils)
|
||||
add_test_executable(test-counter internals/counter.c dbus-testutils)
|
||||
add_test_executable(test-bus-system bus/system.c LIBS launch-helper-internal dbus-testutils)
|
||||
add_test_executable(test-counter internals/counter.c LIBS dbus-testutils)
|
||||
if(ENABLE_TRADITIONAL_ACTIVATION)
|
||||
add_test_executable(test-bus-launch-helper-oom bus/launch-helper-oom.c launch-helper-internal dbus-testutils)
|
||||
add_helper_executable(dbus-daemon-launch-helper-for-tests bus/launch-helper-for-tests.c launch-helper-internal)
|
||||
add_test_executable(test-bus-launch-helper-oom bus/launch-helper-oom.c LIBS launch-helper-internal dbus-testutils)
|
||||
add_helper_executable(dbus-daemon-launch-helper-for-tests bus/launch-helper-for-tests.c LIBS launch-helper-internal)
|
||||
|
||||
set(SOURCES bus/failed-helper-activation.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus-failed-helper-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
add_test_executable(test-bus-failed-helper-activation "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus-failed-helper-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
set(SOURCES bus/helper-activation.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus-helper-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
add_test_executable(test-bus-helper-activation "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus-helper-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
endif()
|
||||
endif()
|
||||
|
|
@ -199,26 +199,26 @@ if(DBUS_WITH_GLIB)
|
|||
|
||||
set(TEST_LIBRARIES ${DBUS_INTERNAL_LIBRARIES} dbus-testutils dbus-testutils-glib ${GLIB2_LIBRARIES})
|
||||
|
||||
add_test_executable(test-assertions internals/assertions.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-corrupt corrupt.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-dbus-daemon dbus-daemon.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-dbus-daemon-eavesdrop dbus-daemon-eavesdrop.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-desktop-file internals/desktop-file.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-fdpass fdpass.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-header-fields header-fields.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-loopback loopback.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-marshal marshal.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-monitor monitor.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-refs internals/refs.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-relay relay.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-server-oom internals/server-oom.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-syntax syntax.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-sysdeps internals/sysdeps.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-syslog internals/syslog.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-uid-permissions uid-permissions.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-userdb internals/userdb.c ${TEST_LIBRARIES})
|
||||
add_helper_executable(manual-authz manual-authz.c ${TEST_LIBRARIES})
|
||||
add_helper_executable(manual-test-thread-blocking thread-blocking.c ${TEST_LIBRARIES})
|
||||
add_test_executable(test-assertions internals/assertions.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-corrupt corrupt.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-dbus-daemon dbus-daemon.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-dbus-daemon-eavesdrop dbus-daemon-eavesdrop.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-desktop-file internals/desktop-file.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-fdpass fdpass.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-header-fields header-fields.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-loopback loopback.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-marshal marshal.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-monitor monitor.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-refs internals/refs.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-relay relay.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-server-oom internals/server-oom.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-syntax syntax.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-sysdeps internals/sysdeps.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-syslog internals/syslog.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-uid-permissions uid-permissions.c LIBS ${TEST_LIBRARIES})
|
||||
add_test_executable(test-userdb internals/userdb.c LIBS ${TEST_LIBRARIES})
|
||||
add_helper_executable(manual-authz manual-authz.c LIBS ${TEST_LIBRARIES})
|
||||
add_helper_executable(manual-test-thread-blocking thread-blocking.c LIBS ${TEST_LIBRARIES})
|
||||
endif()
|
||||
|
||||
### keep these in creation order, i.e. uppermost dirs first
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
if(WIN32)
|
||||
add_test_executable(test-autolaunch-win test-autolaunch-win.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
|
||||
add_test_executable(test-autolaunch-win test-autolaunch-win.c LIBS ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
|
||||
else()
|
||||
add_helper_executable(test-autolaunch test-autolaunch.c dbus-testutils)
|
||||
add_helper_executable(test-autolaunch test-autolaunch.c LIBS dbus-testutils)
|
||||
endif()
|
||||
|
||||
add_session_test_executable(test-ids test-ids.c ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-pending-call-disconnected test-pending-call-disconnected.c ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-ids test-ids.c LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-pending-call-disconnected test-pending-call-disconnected.c LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
|
||||
if(ENABLE_TRADITIONAL_ACTIVATION)
|
||||
add_session_test_executable(test-pending-call-dispatch test-pending-call-dispatch.c ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-pending-call-timeout test-pending-call-timeout.c ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-pending-call-dispatch test-pending-call-dispatch.c LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-pending-call-timeout test-pending-call-timeout.c LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
endif()
|
||||
add_session_test_executable(test-shutdown test-shutdown.c dbus-testutils)
|
||||
add_session_test_executable(test-shutdown test-shutdown.c LIBS dbus-testutils)
|
||||
if(ENABLE_TRADITIONAL_ACTIVATION)
|
||||
add_session_test_executable(test-privserver-client test-privserver-client.c dbus-testutils)
|
||||
add_session_test_executable(test-thread-init test-threads-init.c ${DBUS_INTERNAL_LIBRARIES})
|
||||
add_session_test_executable(test-privserver-client test-privserver-client.c LIBS dbus-testutils)
|
||||
add_session_test_executable(test-thread-init test-threads-init.c LIBS ${DBUS_INTERNAL_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue