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