Changeset 658:f198d16fa7f4 in freeDiameter for tests
- Timestamp:
- Jan 14, 2011, 3:15:23 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- tests
- Files:
-
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
tests/CMakeLists.txt
r585 r658 1 1 # Test directory 2 PROJECT(" libfreeDiameter tests" C)2 PROJECT("freeDiameter tests" C) 3 3 4 4 # give the possibility to configure the timeout duration for the tests … … 28 28 ADD_DEFINITIONS(-DTRACE_LEVEL=NONE) 29 29 30 INCLUDE_DIRECTORIES( ".." ) 31 INCLUDE_DIRECTORIES( "../../libfreeDiameter" ) 32 33 BISON_FILE(../fdd.y) 34 FLEX_FILE(../fdd.l) 35 36 SET(TEST_COMMON_SRC "") 37 38 FOREACH( SRC_FILE ${FD_COMMON_SRC}) 39 SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "../${SRC_FILE}") 40 ENDFOREACH(SRC_FILE) 41 42 FOREACH( SRC_FILE ${FD_COMMON_GEN_SRC}) 43 SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "${CMAKE_CURRENT_BINARY_DIR}/../${SRC_FILE}") 44 ENDFOREACH(SRC_FILE) 45 46 FOREACH( SRC_FILE ${LFD_SRC}) 47 SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "../../libfreeDiameter/${SRC_FILE}") 48 ENDFOREACH(SRC_FILE) 49 50 # Create an archive with the daemon common files (all but main) 51 ADD_LIBRARY(fDcore STATIC ${TEST_COMMON_SRC}) 30 INCLUDE_DIRECTORIES( "../libfdproto" ) 31 INCLUDE_DIRECTORIES( "../libfdcore" ) 52 32 53 33 … … 72 52 73 53 # List of source files, copied from the extension CMakeLists. 74 BISON_FILE(../ ../extensions/app_acct/acct_conf.y)75 FLEX_FILE(../ ../extensions/app_acct/acct_conf.l)54 BISON_FILE(../extensions/app_acct/acct_conf.y) 55 FLEX_FILE(../extensions/app_acct/acct_conf.l) 76 56 #SET_SOURCE_FILES_PROPERTIES(lex.acct_conf.c acct_conf.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}") 77 57 … … 89 69 90 70 # The extension headers 91 INCLUDE_DIRECTORIES( "../ ../extensions/app_acct" )71 INCLUDE_DIRECTORIES( "../extensions/app_acct" ) 92 72 93 73 SET(testappacct_ADDITIONAL "") 94 74 95 75 FOREACH( SRC_FILE ${APP_ACCT_SRC}) 96 SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "../ ../extensions/app_acct/${SRC_FILE}")76 SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "../extensions/app_acct/${SRC_FILE}") 97 77 ENDFOREACH(SRC_FILE) 98 78 99 79 FOREACH( SRC_FILE ${APP_ACCT_SRC_GEN}) 100 SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "${CMAKE_CURRENT_BINARY_DIR}/../ ../extensions/app_acct/${SRC_FILE}")80 SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "${CMAKE_CURRENT_BINARY_DIR}/../extensions/app_acct/${SRC_FILE}") 101 81 ENDFOREACH(SRC_FILE) 102 82 … … 109 89 FOREACH( TEST ${TEST_LIST} ) 110 90 ADD_EXECUTABLE(${TEST} ${TEST}.c tests.h ${${TEST}_ADDITIONAL}) 111 TARGET_LINK_LIBRARIES(${TEST} fDcore ${FD_LIBS} ${LFD_LIBS}${${TEST}_ADDITIONAL_LIB})91 TARGET_LINK_LIBRARIES(${TEST} libfdproto libfdcore ${${TEST}_ADDITIONAL_LIB}) 112 92 ADD_TEST(${TEST} ${EXECUTABLE_OUTPUT_PATH}/${TEST}) 113 93 ENDFOREACH( TEST ) -
tests/tests.h
r481 r658 42 42 #define _TESTS_H 43 43 44 #include " libfD.h"45 #include "f D.h"44 #include "fdproto-internal.h" 45 #include "fdcore-internal.h" 46 46 47 47 #include <pthread.h> … … 82 82 struct fd_config * fd_g_config = &conf; 83 83 84 /* gcrypt functions to support posix threads */85 GCRY_THREAD_OPTION_PTHREAD_IMPL;86 87 84 /* Define the standard check routines */ 88 85 #define CHECK( _val, _assert ){ \ … … 105 102 } 106 103 107 /* Minimum inits */ 108 #define INIT_FD() { \ 109 memset(fd_g_config, 0, sizeof(struct fd_config)); \ 110 CHECK( 0, fd_lib_init(1) ); \ 111 fd_log_threadname(basename(__FILE__)); \ 112 (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); \ 113 (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); \ 114 CHECK( 0, gnutls_global_init()); \ 115 CHECK( 0, fd_conf_init() ); \ 116 CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) ); \ 117 CHECK( 0, fd_sess_start() ); \ 118 parse_cmdline(argc, argv); \ 104 static pthread_t timeout_thr; 105 static void * timeout_catch(void * arg) 106 { 107 int sig; 108 sigset_t ss; 109 fd_log_threadname ( "timeout catcher" ); 110 111 sigemptyset(&ss); 112 sigaddset(&ss, SIGALRM); 113 114 CHECK_POSIX_DO( sigwait(&ss, &sig), ); 115 116 FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute."); 117 118 return NULL; 119 119 } 120 120 121 121 static void test_timeout(int signal) 122 { 123 FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute."); 124 } 122 GCRY_THREAD_OPTION_PTHREAD_IMPL; 125 123 126 124 static inline void parse_cmdline(int argc, char * argv[]) { … … 164 162 if (!no_timeout) { 165 163 alarm(TEST_TIMEOUT); 166 fd_sig_register(SIGALRM, "Test.harness", test_timeout);164 CHECK( 0, pthread_create(&timeout_thr, NULL, timeout_catch, NULL) ); 167 165 } 168 166 } 169 167 168 static inline void test_init(int argc, char * argv[]) 169 { 170 memset(fd_g_config, 0, sizeof(struct fd_config)); 171 172 CHECK( 0, fd_libproto_init() ); 173 174 fd_log_threadname(basename(__FILE__)); 175 176 /* Initialize gcrypt and gnutls */ 177 (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); 178 (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 179 CHECK( 0, gnutls_global_init()); 180 181 /* Initialize the config */ 182 CHECK( 0, fd_conf_init() ); 183 184 /* Add definitions of the base protocol */ 185 CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) ); 186 187 /* Initialize only the sessions */ 188 CHECK( 0, fd_sess_start() ); 189 190 /* Parse the command line */ 191 parse_cmdline(argc, argv); 192 193 return; 194 } 195 #define INIT_FD() test_init(argc, argv); 196 170 197 #endif /* _TESTS_H */
Note: See TracChangeset
for help on using the changeset viewer.