Changeset 658:f198d16fa7f4 in freeDiameter for tests/tests.h
- Timestamp:
- Jan 14, 2011, 3:15:23 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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.