Mercurial > hg > freeDiameter
annotate tests/tests.h @ 1357:925470fbe59d
Avoid deprecated functions (like in libfdcore/core.c).
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Sat, 18 May 2019 17:58:48 +0200 |
parents | 1af09cc156d6 |
children | 566bb46cc73f |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
731
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
0 | 4 * * |
1127
1af09cc156d6
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
5 * Copyright (c) 2013, WIDE Project and NICT * |
0 | 6 * All rights reserved. * |
7 * * | |
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
9 * permitted provided that the following conditions are met: * | |
10 * * | |
11 * * Redistributions of source code must retain the above * | |
12 * copyright notice, this list of conditions and the * | |
13 * following disclaimer. * | |
14 * * | |
15 * * Redistributions in binary form must reproduce the above * | |
16 * copyright notice, this list of conditions and the * | |
17 * following disclaimer in the documentation and/or other * | |
18 * materials provided with the distribution. * | |
19 * * | |
20 * * Neither the name of the WIDE Project or NICT nor the * | |
21 * names of its contributors may be used to endorse or * | |
22 * promote products derived from this software without * | |
23 * specific prior written permission of WIDE Project and * | |
24 * NICT. * | |
25 * * | |
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
34 *********************************************************************************************************/ | |
35 | |
36 /* This file contains the definition of our test harness. | |
37 * The harness is very simple yet. | |
38 * It may be interessant to go to dejagnu later... | |
39 * | |
40 */ | |
41 #ifndef _TESTS_H | |
42 #define _TESTS_H | |
43 | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
44 #include "fdproto-internal.h" |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
45 #include "fdcore-internal.h" |
0 | 46 |
47 #include <pthread.h> | |
48 #include <errno.h> | |
1034
f4a73a991623
Fix warning on old GCC versions
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1033
diff
changeset
|
49 GCC_DIAG_OFF("-Wdeprecated-declarations") |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
50 #include <gcrypt.h> |
1034
f4a73a991623
Fix warning on old GCC versions
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1033
diff
changeset
|
51 GCC_DIAG_ON("-Wdeprecated-declarations") |
0 | 52 |
53 /* Test timeout duration, unless -n is passed on the command line */ | |
54 #ifndef TEST_TIMEOUT | |
731
ef199d6185df
Increase tests timeout to 120 seconds
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
729
diff
changeset
|
55 #define TEST_TIMEOUT 120 /* in seconds */ |
0 | 56 #endif /* TEST_TIMEOUT */ |
57 | |
58 /* Standard includes */ | |
59 #include <getopt.h> | |
60 #include <time.h> | |
61 #include <libgen.h> | |
236
60f34df3e025
Remove dependency on signalent.h
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
235
diff
changeset
|
62 #include <signal.h> |
0 | 63 |
64 /* Define the return code values */ | |
65 #define PASS 0 | |
66 #define FAIL 1 | |
67 | |
68 /* Define the macro to fail a test with a message */ | |
69 #define FAILTEST( message... ){ \ | |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
70 LOG_F(message); \ |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
71 LOG_F("FAILED: %s ", __STRIPPED_FILE__); \ |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
72 free(tbuf); \ |
0 | 73 exit(FAIL); \ |
74 } | |
75 | |
76 /* Define the macro to pass a test */ | |
77 #define PASSTEST( ){ \ | |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
78 LOG_N("PASS: %s", __STRIPPED_FILE__); \ |
676
684f9e0e0c96
Clean termination of tests when possible
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
79 (void)fd_core_shutdown(); \ |
684f9e0e0c96
Clean termination of tests when possible
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
80 (void)fd_core_wait_shutdown_complete(); \ |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
81 (void)fd_thr_term(&signal_thr); \ |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
82 free(tbuf); \ |
0 | 83 exit(PASS); \ |
84 } | |
85 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
86 static struct fd_config conf; |
854
51a056d78aba
Resolve conflict on duplicated fd_g_config pointer
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
87 extern struct fd_config * fd_g_config; |
2
d8ce06172629
Added a global debug level var
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
88 |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
89 /* for dumps */ |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
90 static char * tbuf = NULL; size_t tbuflen = 0; |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
91 #define FD_DUMP_TEST_PARAMS &tbuf, &tbuflen, NULL |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
92 |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
93 |
0 | 94 /* Define the standard check routines */ |
95 #define CHECK( _val, _assert ){ \ | |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
96 LOG_D("CHECK( %s == %s )", \ |
1000
aeb202e2dbef
Cleanup test messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
97 #_assert, \ |
aeb202e2dbef
Cleanup test messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
98 #_val); \ |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
99 { \ |
0 | 100 __typeof__ (_val) __ret = (_assert); \ |
101 if (__ret != (_val)) { \ | |
994 | 102 FAILTEST( "%s:%d: CHECK FAILED : %s == %lx != %lx", \ |
1000
aeb202e2dbef
Cleanup test messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
103 __STRIPPED_FILE__, \ |
0 | 104 __LINE__, \ |
105 #_assert, \ | |
106 (unsigned long)__ret, \ | |
107 (unsigned long)(_val)); \ | |
108 }} \ | |
109 } | |
110 | |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
111 static pthread_t signal_thr; |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
112 static void * signal_catch(void * arg) |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
113 { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
114 int sig; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
115 sigset_t ss; |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
116 fd_log_threadname ( "Signal catcher" ); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
117 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
118 sigemptyset(&ss); |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
119 |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
120 /* We use SIGALRM */ |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
121 sigaddset(&ss, SIGALRM); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
122 |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
123 /* Unblock any other signal for this thread, so that default handler is enabled */ |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
124 CHECK_SYS_DO( pthread_sigmask( SIG_SETMASK, &ss, NULL ), ); |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
125 |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
126 /* Now wait for sigwait or cancelation */ |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
127 CHECK_POSIX_DO( sigwait(&ss, &sig), ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
128 FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute."); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
129 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
130 return NULL; |
0 | 131 } |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
132 |
0 | 133 |
1357
925470fbe59d
Avoid deprecated functions (like in libfdcore/core.c).
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
134 #ifndef GNUTLS_VERSION_210 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
135 GCRY_THREAD_OPTION_PTHREAD_IMPL; |
1357
925470fbe59d
Avoid deprecated functions (like in libfdcore/core.c).
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
136 #endif /* GNUTLS_VERSION_210 */ |
236
60f34df3e025
Remove dependency on signalent.h
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
235
diff
changeset
|
137 |
794
004bd7272b9f
Get TID in GNUTLS logs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
793
diff
changeset
|
138 /* gnutls debug. */ |
793
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
139 static void fd_gnutls_debug(int level, const char * str) { |
794
004bd7272b9f
Get TID in GNUTLS logs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
793
diff
changeset
|
140 const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed"); |
004bd7272b9f
Get TID in GNUTLS logs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
793
diff
changeset
|
141 fd_log_debug("tid:%-20s[gnutls:%d] %s", __thn, level, str); |
793
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
142 } |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
143 static int gnutls_debug = 0; |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
144 |
1090
8be95f757b08
Improved the testmesg_stress with more functions tested and configurable number of samples.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
145 static int test_parameter = 0; |
793
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
146 |
0 | 147 static inline void parse_cmdline(int argc, char * argv[]) { |
148 int c; | |
149 int no_timeout = 0; | |
1090
8be95f757b08
Improved the testmesg_stress with more functions tested and configurable number of samples.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
150 while ((c = getopt (argc, argv, "dqnf:F:g:p:")) != -1) { |
0 | 151 switch (c) { |
152 case 'd': /* Increase verbosity of debug messages. */ | |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
153 fd_g_debug_lvl--; |
0 | 154 break; |
155 | |
2
d8ce06172629
Added a global debug level var
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
156 case 'q': /* Decrease verbosity. */ |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
157 fd_g_debug_lvl++; |
0 | 158 break; |
159 | |
160 case 'n': /* Disable the timeout of the test. */ | |
161 no_timeout = 1; | |
162 break; | |
163 | |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
164 case 'f': /* Full debug for the function with this name. */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
165 #ifdef DEBUG |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
166 fd_debug_one_function = optarg; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
167 #else /* DEBUG */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
168 TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature"); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
169 #endif /* DEBUG */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
170 break; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
171 |
480
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
172 case 'F': /* Full debug for the functions in file with this name. */ |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
173 #ifdef DEBUG |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
174 fd_debug_one_file = optarg; |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
175 #else /* DEBUG */ |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
176 TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature"); |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
177 #endif /* DEBUG */ |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
178 break; |
907b00ae3679
Allow file-based debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
462
diff
changeset
|
179 |
793
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
180 case 'g': /* Set a debug level and function for GNU TLS calls. */ |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
181 gnutls_debug = (int)atoi(optarg); |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
182 break; |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
183 |
1090
8be95f757b08
Improved the testmesg_stress with more functions tested and configurable number of samples.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
184 case 'p': /* Set a debug level and function for GNU TLS calls. */ |
8be95f757b08
Improved the testmesg_stress with more functions tested and configurable number of samples.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
185 test_parameter = (int)atoi(optarg); |
8be95f757b08
Improved the testmesg_stress with more functions tested and configurable number of samples.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
186 break; |
8be95f757b08
Improved the testmesg_stress with more functions tested and configurable number of samples.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
187 |
0 | 188 default: /* bug: option not considered. */ |
189 return; | |
190 } | |
191 } | |
236
60f34df3e025
Remove dependency on signalent.h
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
235
diff
changeset
|
192 if (!no_timeout) { |
0 | 193 alarm(TEST_TIMEOUT); |
236
60f34df3e025
Remove dependency on signalent.h
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
235
diff
changeset
|
194 } |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
195 CHECK( 0, pthread_create(&signal_thr, NULL, signal_catch, NULL) ); |
0 | 196 } |
197 | |
693 | 198 static inline void test_init(int argc, char * argv[], char *fname) |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
199 { |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
200 sigset_t sig_all; |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
201 sigfillset(&sig_all); |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
202 |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
203 CHECK( 0, pthread_sigmask(SIG_BLOCK, &sig_all, NULL)); |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
204 |
854
51a056d78aba
Resolve conflict on duplicated fd_g_config pointer
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
205 fd_g_config = &conf; |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
206 memset(fd_g_config, 0, sizeof(struct fd_config)); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
207 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
208 CHECK( 0, fd_libproto_init() ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
209 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1090
diff
changeset
|
210 CHECK( 0, fd_hooks_init() ); |
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1090
diff
changeset
|
211 |
1000
aeb202e2dbef
Cleanup test messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
212 fd_log_threadname(fname); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
213 |
729
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
214 /* Parse the command line */ |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
215 parse_cmdline(argc, argv); |
5d8ac5da7092
Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
695
diff
changeset
|
216 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
217 /* Initialize gcrypt and gnutls */ |
1357
925470fbe59d
Avoid deprecated functions (like in libfdcore/core.c).
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
218 #ifndef GNUTLS_VERSION_210 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
219 (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
220 (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); |
1357
925470fbe59d
Avoid deprecated functions (like in libfdcore/core.c).
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
221 #endif /* GNUTLS_VERSION_210 */ |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
222 CHECK( 0, gnutls_global_init()); |
793
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
223 /* Set gnutls debug level ? */ |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
224 if (gnutls_debug) { |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
225 gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug); |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
226 gnutls_global_set_log_level (gnutls_debug); |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
227 TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", gnutls_debug); |
ada5366bca4e
allow gnutls debug in tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
228 } |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
229 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
230 /* Initialize the config */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
231 CHECK( 0, fd_conf_init() ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
232 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
233 /* Add definitions of the base protocol */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
234 CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
235 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
236 /* Initialize only the sessions */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
237 CHECK( 0, fd_sess_start() ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
238 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
239 return; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
240 } |
1000
aeb202e2dbef
Cleanup test messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
241 #define INIT_FD() test_init(argc, argv, __STRIPPED_FILE__) |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
481
diff
changeset
|
242 |
0 | 243 #endif /* _TESTS_H */ |