Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | # Test directory |
| 2 | PROJECT("freeDiameter tests" C) |
| 3 | |
| 4 | # give the possibility to configure the timeout duration for the tests |
| 5 | OPTION(TEST_TIMEOUT "Timeout for the tests, in seconds (default: 120)?") |
| 6 | IF(TEST_TIMEOUT) |
| 7 | ADD_DEFINITIONS(-DTEST_TIMEOUT=${TEST_TIMEOUT}) |
| 8 | ENDIF(TEST_TIMEOUT) |
| 9 | |
| 10 | # default command line for the tests |
| 11 | OPTION(OPT_TEST_ARGUMENTS "Specify the default arguments for the tests" OFF) |
| 12 | IF(OPT_TEST_ARGUMENTS) |
| 13 | SET(TEST_ARGUMENTS ${OPT_TEST_ARGUMENTS}) |
| 14 | ELSE(OPT_TEST_ARGUMENTS) |
| 15 | SET(TEST_ARGUMENTS "") |
| 16 | ENDIF(OPT_TEST_ARGUMENTS) |
| 17 | |
| 18 | |
| 19 | ############################# |
| 20 | # List the test cases |
| 21 | SET(TEST_LIST |
| 22 | testsctp |
| 23 | testostr |
| 24 | testfifo |
| 25 | testpeers |
| 26 | testdict |
| 27 | testmesg |
| 28 | testmesg_stress |
| 29 | testsess |
| 30 | testdisp |
| 31 | testcnx |
| 32 | testloadext |
| 33 | ) |
| 34 | |
| 35 | ############################# |
| 36 | # Some parameters for the tests |
| 37 | |
| 38 | ADD_DEFINITIONS(-DTEST_DEBUG) |
| 39 | ADD_DEFINITIONS(-DBUILD_DIR="${CMAKE_BINARY_DIR}") |
| 40 | |
| 41 | INCLUDE_DIRECTORIES( "../libfdproto" ) |
| 42 | INCLUDE_DIRECTORIES( "../libfdcore" ) |
| 43 | INCLUDE_DIRECTORIES(${LFDCORE_INCLUDES}) |
| 44 | |
| 45 | |
| 46 | SET(testcnx_ADDITIONAL_LIB ${CLOCK_GETTIME_LIBS}) |
| 47 | SET(testfifo_ADDITIONAL_LIB ${CLOCK_GETTIME_LIBS}) |
| 48 | SET(testsess_ADDITIONAL_LIB ${CLOCK_GETTIME_LIBS}) |
| 49 | SET(testloadext_ADDITIONAL_LIB ${CMAKE_DL_LIBS}) |
| 50 | SET(testmesg_stress_ADDITIONAL_LIB ${CLOCK_GETTIME_LIBS} ${CMAKE_DL_LIBS}) |
| 51 | |
| 52 | ############################## |
| 53 | # App_acct test |
| 54 | |
| 55 | IF(BUILD_APP_ACCT OR ALL_EXTENSIONS) |
| 56 | OPTION(TEST_APP_ACCT "Test app_acct extension? (Requires a configured database, see testappacct.c for details)" OFF) |
| 57 | IF(TEST_APP_ACCT) |
| 58 | |
| 59 | OPTION(TEST_APP_ACCT_CONNINFO "The connection string to the database") |
| 60 | IF(TEST_APP_ACCT_CONNINFO) |
| 61 | ADD_DEFINITIONS(-DTEST_CONNINFO="${TEST_APP_ACCT_CONNINFO}") |
| 62 | ENDIF(TEST_APP_ACCT_CONNINFO) |
| 63 | |
| 64 | SET(TEST_LIST ${TEST_LIST} testappacct) |
| 65 | |
| 66 | # Extension dependencies |
| 67 | FIND_PACKAGE(PostgreSQL REQUIRED) |
| 68 | INCLUDE_DIRECTORIES(${POSTGRESQL_INCLUDE_DIR}) |
| 69 | SET(testappacct_ADDITIONAL_LIB ${POSTGRESQL_LIBRARIES}) |
| 70 | |
| 71 | # List of source files, copied from the extension CMakeLists. |
| 72 | BISON_FILE(../extensions/app_acct/acct_conf.y) |
| 73 | FLEX_FILE(../extensions/app_acct/acct_conf.l) |
| 74 | #SET_SOURCE_FILES_PROPERTIES(lex.acct_conf.c acct_conf.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}") |
| 75 | |
| 76 | SET( APP_ACCT_SRC |
| 77 | app_acct.h |
| 78 | app_acct.c |
| 79 | acct_db.c |
| 80 | acct_records.c |
| 81 | ) |
| 82 | SET( APP_ACCT_SRC_GEN |
| 83 | lex.acct_conf.c |
| 84 | acct_conf.tab.c |
| 85 | acct_conf.tab.h |
| 86 | ) |
| 87 | |
| 88 | # The extension headers |
| 89 | INCLUDE_DIRECTORIES( "../extensions/app_acct" ) |
| 90 | |
| 91 | SET(testappacct_ADDITIONAL "") |
| 92 | |
| 93 | FOREACH( SRC_FILE ${APP_ACCT_SRC}) |
| 94 | SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "../extensions/app_acct/${SRC_FILE}") |
| 95 | ENDFOREACH(SRC_FILE) |
| 96 | |
| 97 | FOREACH( SRC_FILE ${APP_ACCT_SRC_GEN}) |
| 98 | SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "${CMAKE_CURRENT_BINARY_DIR}/../extensions/app_acct/${SRC_FILE}") |
| 99 | ENDFOREACH(SRC_FILE) |
| 100 | |
| 101 | ENDIF(TEST_APP_ACCT) |
| 102 | ENDIF(BUILD_APP_ACCT OR ALL_EXTENSIONS) |
| 103 | |
| 104 | |
| 105 | ############################# |
| 106 | # Compile each test |
| 107 | FOREACH( TEST ${TEST_LIST} ) |
| 108 | ADD_EXECUTABLE(${TEST} ${TEST}.c tests.h ${${TEST}_ADDITIONAL}) |
| 109 | TARGET_LINK_LIBRARIES(${TEST} libfdproto libfdcore ${GNUTLS_LIBRARIES} ${GCRYPT_LIBRARY} ${${TEST}_ADDITIONAL_LIB}) |
| 110 | ADD_TEST(${TEST} ${EXECUTABLE_OUTPUT_PATH}/${TEST} ${TEST_ARGUMENTS}) |
| 111 | ENDFOREACH( TEST ) |
| 112 | |
| 113 | |
| 114 | #### |
| 115 | ## INSTALL section ## |
| 116 | |
| 117 | # we do not install the tests |