1project(test) 2 3add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) 4 5add_library(dbus_testutils STATIC 6 ${CMAKE_SOURCE_DIR}/../test/test-utils.h 7 ${CMAKE_SOURCE_DIR}/../test/test-utils.c 8) 9target_link_libraries(dbus_testutils ${DBUS_INTERNAL_LIBRARIES}) 10 11add_subdirectory( name-test ) 12 13set (test-service_SOURCES 14 ${CMAKE_SOURCE_DIR}/../test/test-service.c 15 ${CMAKE_SOURCE_DIR}/../test/test-utils.c 16 ${CMAKE_SOURCE_DIR}/../test/test-utils.h 17) 18 19set (test-names_SOURCES 20 ${CMAKE_SOURCE_DIR}/../test/test-names.c 21 ${CMAKE_SOURCE_DIR}/../test/test-utils.c 22 ${CMAKE_SOURCE_DIR}/../test/test-utils.h 23) 24 25set (break_loader_SOURCES 26 ${CMAKE_SOURCE_DIR}/../test/break-loader.c 27) 28 29set (test-shell-service_SOURCES 30 ${CMAKE_SOURCE_DIR}/../test/test-shell-service.c 31 ${CMAKE_SOURCE_DIR}/../test/test-utils.c 32 ${CMAKE_SOURCE_DIR}/../test/test-utils.h 33) 34 35set (shell-test_SOURCES 36 ${CMAKE_SOURCE_DIR}/../test/shell-test.c 37) 38 39set (spawn-test_SOURCES 40 ${CMAKE_SOURCE_DIR}/../test/spawn-test.c 41) 42 43set (test-exit_SOURCES 44 ${CMAKE_SOURCE_DIR}/../test/test-exit.c 45) 46 47set (test-segfault_SOURCES 48 ${CMAKE_SOURCE_DIR}/../test/test-segfault.c 49) 50 51set (test-sleep-forever_SOURCES 52 ${CMAKE_SOURCE_DIR}/../test/test-sleep-forever.c 53) 54 55set (decode_gcov_SOURCES 56 ${CMAKE_SOURCE_DIR}/../test/decode-gcov.c 57) 58 59add_executable(test-service ${test-service_SOURCES}) 60target_link_libraries(test-service ${DBUS_INTERNAL_LIBRARIES}) 61 62add_executable(test-names ${test-names_SOURCES}) 63target_link_libraries(test-names ${DBUS_INTERNAL_LIBRARIES}) 64 65add_executable(shell-test ${shell-test_SOURCES}) 66target_link_libraries(shell-test ${DBUS_INTERNAL_LIBRARIES}) 67ADD_TEST(shell-test ${EXECUTABLE_OUTPUT_PATH}/shell-test${EXT}) 68 69add_executable(test-shell-service ${test-shell-service_SOURCES}) 70target_link_libraries(test-shell-service ${DBUS_INTERNAL_LIBRARIES}) 71 72add_executable(spawn-test ${spawn-test_SOURCES}) 73target_link_libraries(spawn-test ${DBUS_INTERNAL_LIBRARIES}) 74 75add_executable(test-exit ${test-exit_SOURCES}) 76target_link_libraries(test-exit ${DBUS_INTERNAL_LIBRARIES}) 77 78add_executable(test-segfault ${test-segfault_SOURCES}) 79target_link_libraries(test-segfault ${DBUS_INTERNAL_LIBRARIES}) 80 81add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) 82target_link_libraries(test-sleep-forever ${DBUS_INTERNAL_LIBRARIES}) 83 84#add_executable(decode-gcov ${decode_gcov_SOURCES}) 85#target_link_libraries(decode-gcov ${DBUS_INTERNAL_LIBRARIES}) 86 87### keep these in creation order, i.e. uppermost dirs first 88set (TESTDIRS 89 test/data 90 test/data/valid-messages 91 test/data/invalid-messages 92 test/data/incomplete-messages 93 test/data/auth 94 test/data/sha-1 95 test/data/valid-config-files 96 test/data/valid-config-files/basic.d 97 test/data/valid-config-files/system.d 98 test/data/valid-config-files-system 99 test/data/valid-introspection-files 100 test/data/valid-messages 101 test/data/valid-service-files 102 test/data/valid-service-files-system 103 test/data/invalid-config-files 104 test/data/invalid-config-files-system 105 test/data/invalid-messages 106 test/data/invalid-service-files-system 107 test/data/equiv-config-files 108 test/data/equiv-config-files/basic 109 test/data/equiv-config-files/basic/basic.d 110 test/data/equiv-config-files/entities 111 test/data/equiv-config-files/entities/basic.d 112) 113set (CONFIG_VERBOSE 0) 114 115### copy tests to builddir so that generated tests and static tests 116### are all in one place. 117MESSAGE(STATUS "Copying test files to test directory") 118FOREACH(FILE_TYPE *.message *.message-raw *.auth-script *.sha1 *.txt *.conf *.service) 119 FOREACH(DIR ${TESTDIRS}) 120 FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" ) 121 FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR}) 122 FOREACH(FILE ${FILES}) 123 GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) 124 SET (TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME}) 125 configure_file(${FILE} ${TARGET} COPYONLY) 126 IF (CONFIG_VERBOSE) 127 MESSAGE("${FILE}") 128 ENDIF (CONFIG_VERBOSE) 129 ENDFOREACH(FILE) 130 ENDFOREACH(DIR) 131ENDFOREACH(FILE_TYPE) 132 133### generate test files 134MESSAGE(STATUS "Generating test files from templates into test directory") 135 136FOREACH(FILE_TYPE *.conf.in *.service.in) 137 FOREACH(DIR ${TESTDIRS}) 138 FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" ) 139 FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR}) 140 FOREACH(FILE ${FILES}) 141 GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) 142 STRING(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME}) 143 SET (TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME}) 144 STRING(REGEX REPLACE "\\.in$" ".cmake" _file ${FILE}) 145 IF (EXISTS ${_file}) 146 SET (FILE ${_file}) 147 ENDIF (EXISTS ${_file}) 148 configure_file(${FILE} ${TARGET} @ONLY IMMEDIATE) 149 IF (CONFIG_VERBOSE) 150 MESSAGE("${FILE}") 151 ENDIF (CONFIG_VERBOSE) 152 ENDFOREACH(FILE) 153 ENDFOREACH(DIR) 154ENDFOREACH(FILE_TYPE) 155 156MESSAGE(STATUS "Copying generated bus config files to test directory") 157set (OUTDIR ${CMAKE_BINARY_DIR}/test/data/valid-config-files) 158 159FILE(GLOB FILES "${CMAKE_BINARY_DIR}/bus/*.conf" ) 160FILE(MAKE_DIRECTORY ${OUTDIR}) 161FOREACH(FILE ${FILES}) 162 GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) 163 SET (TARGET ${OUTDIR}/${FILENAME}) 164 configure_file(${FILE} ${TARGET} COPYONLY) 165 IF (CONFIG_VERBOSE) 166 MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n") 167 ENDIF (CONFIG_VERBOSE) 168ENDFOREACH(FILE) 169 170# todo: for installation the TEST_..._BINARY variables must reflect the 171# installation dir or has to be defined relative 172# 173