Commit 578ea41d authored by Ralf Habacker's avatar Ralf Habacker

Add cmake support for session based test executables

This patch introduces a new cmake macro add_session_test_executable,
which uses dbus-run-session to start a dbus-daemon process with a
temporary session bus in the background and the desired client file.

add_session_test_executable requires additional environment variables
defined in the top level CMakeLists.txt.

Bug: #135Signed-off-by: Ralf Habacker's avatarRalf Habacker <ralf.habacker@freenet.de>
parent a9e25f06
......@@ -488,6 +488,7 @@ if (DBUS_BUILD_TESTS)
set(DBUS_TEST_DAEMON ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/dbus-daemon${EXEEXT})
set(DBUS_TEST_DBUS_LAUNCH ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/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}/dbus-run-session${EXEEXT}
set(TEST_LAUNCH_HELPER_BINARY ${Z_DRIVE_IF_WINE}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/dbus-daemon-launch-helper-test${EXEEXT})
if (UNIX)
set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR})
......
......@@ -78,6 +78,32 @@ macro(add_helper_executable _target _source)
target_link_libraries(${_target} ${ARGN})
endmacro(add_helper_executable)
macro(add_session_test_executable _target _source)
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})
add_test(NAME ${_target}
COMMAND
${TEST_WRAPPER}
${DBUS_TEST_RUN_SESSION}
--config-file=${DBUS_TEST_DATA}/valid-config-files/tmp-session.conf
--dbus-daemon=${DBUS_TEST_DAEMON}
${Z_DRIVE_IF_WINE}$<TARGET_FILE:${_target}>
--tap
)
set(_env)
list(APPEND _env "DBUS_SESSION_BUS_PID=")
list(APPEND _env "DBUS_SESSION_BUS_ADDRESS=")
list(APPEND _env "DBUS_FATAL_WARNINGS=1")
list(APPEND _env "DBUS_TEST_DAEMON=${DBUS_TEST_DAEMON}")
list(APPEND _env "DBUS_TEST_DATA=${DBUS_TEST_DATA}")
list(APPEND _env "DBUS_TEST_HOMEDIR=${DBUS_TEST_HOMEDIR}")
set_tests_properties(${_target} PROPERTIES ENVIRONMENT "${_env}")
endmacro(add_session_test_executable)
#
# generate compiler flags from MSVC warning identifiers (e.g. '4114') or gcc warning keys (e.g. 'pointer-sign')
......
......@@ -4,11 +4,12 @@ set (NAME_TEST_DIR ../../../test/name-test)
add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS})
add_helper_executable(test-pending-call-dispatch ${NAME_TEST_DIR}/test-pending-call-dispatch.c ${DBUS_INTERNAL_LIBRARIES})
add_helper_executable(test-pending-call-timeout ${NAME_TEST_DIR}/test-pending-call-timeout.c ${DBUS_INTERNAL_LIBRARIES})
add_helper_executable(test-thread-init ${NAME_TEST_DIR}/test-threads-init.c ${DBUS_INTERNAL_LIBRARIES})
add_helper_executable(test-ids ${NAME_TEST_DIR}/test-ids.c ${DBUS_INTERNAL_LIBRARIES})
add_helper_executable(test-shutdown ${NAME_TEST_DIR}/test-shutdown.c dbus-testutils)
add_helper_executable(test-privserver-client ${NAME_TEST_DIR}/test-privserver-client.c dbus-testutils)
add_helper_executable(test-autolaunch ${NAME_TEST_DIR}/test-autolaunch.c dbus-testutils)
add_helper_executable(test-privserver-client ${NAME_TEST_DIR}/test-privserver-client.c dbus-testutils)
add_session_test_executable(test-ids ${NAME_TEST_DIR}/test-ids.c ${DBUS_INTERNAL_LIBRARIES})
add_session_test_executable(test-pending-call-dispatch ${NAME_TEST_DIR}/test-pending-call-dispatch.c ${DBUS_INTERNAL_LIBRARIES})
add_session_test_executable(test-pending-call-timeout ${NAME_TEST_DIR}/test-pending-call-timeout.c ${DBUS_INTERNAL_LIBRARIES})
add_session_test_executable(test-shutdown ${NAME_TEST_DIR}/test-shutdown.c dbus-testutils)
add_session_test_executable(test-thread-init ${NAME_TEST_DIR}/test-threads-init.c ${DBUS_INTERNAL_LIBRARIES})
endif (DBUS_ENABLE_EMBEDDED_TESTS)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment