diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-15 20:22:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-15 20:22:40 +0000 |
commit | a2425da6f9ba532d8a82906cdbb9ea6076d6a091 (patch) | |
tree | 8d101d57fddedb97a99cdb9502dcbf6819115b65 | |
parent | 4c1b251d7591d28257afd7bf7711350596f247ba (diff) | |
download | libmicrohttpd-a2425da6f9ba532d8a82906cdbb9ea6076d6a091.tar.gz libmicrohttpd-a2425da6f9ba532d8a82906cdbb9ea6076d6a091.zip |
proper gcrypt thread initialization in tests
-rw-r--r-- | src/testcurl/https/test_https_get.c | 8 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_parallel_threads.c | 12 | ||||
-rw-r--r-- | src/testcurl/https/test_https_multi_daemon.c | 19 | ||||
-rw-r--r-- | src/testcurl/https/test_https_session_info.c | 10 | ||||
-rw-r--r-- | src/testcurl/https/test_https_time_out.c | 11 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_authentication.c | 10 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_extensions.c | 8 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_options.c | 8 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.c | 3 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.h | 3 |
10 files changed, 82 insertions, 10 deletions
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c index f076cac4..29e6d0eb 100644 --- a/src/testcurl/https/test_https_get.c +++ b/src/testcurl/https/test_https_get.c | |||
@@ -95,6 +95,9 @@ test_secure_get (FILE * test_fd, | |||
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
99 | |||
100 | |||
98 | int | 101 | int |
99 | main (int argc, char *const *argv) | 102 | main (int argc, char *const *argv) |
100 | { | 103 | { |
@@ -106,6 +109,11 @@ main (int argc, char *const *argv) | |||
106 | 109 | ||
107 | if (!gcry_check_version (GCRYPT_VERSION)) | 110 | if (!gcry_check_version (GCRYPT_VERSION)) |
108 | abort (); | 111 | abort (); |
112 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
113 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
114 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
115 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
116 | #endif | ||
109 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 117 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) |
110 | { | 118 | { |
111 | fprintf (stderr, "Error: %s\n", strerror (errno)); | 119 | fprintf (stderr, "Error: %s\n", strerror (errno)); |
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c index 28fdfcd4..dea6e754 100644 --- a/src/testcurl/https/test_https_get_parallel_threads.c +++ b/src/testcurl/https/test_https_get_parallel_threads.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <limits.h> | 33 | #include <limits.h> |
34 | #include <curl/curl.h> | 34 | #include <curl/curl.h> |
35 | #include <gcrypt.h> | ||
35 | #include "tls_test_common.h" | 36 | #include "tls_test_common.h" |
36 | 37 | ||
37 | extern const char srv_key_pem[]; | 38 | extern const char srv_key_pem[]; |
@@ -122,6 +123,10 @@ test_parallel_clients (void *cls, const char *cipher_suite, | |||
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
126 | |||
127 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
128 | |||
129 | |||
125 | int | 130 | int |
126 | main (int argc, char *const *argv) | 131 | main (int argc, char *const *argv) |
127 | { | 132 | { |
@@ -130,6 +135,13 @@ main (int argc, char *const *argv) | |||
130 | 135 | ||
131 | /* initialize random seed used by curl clients */ | 136 | /* initialize random seed used by curl clients */ |
132 | unsigned int iseed = (unsigned int) time (NULL); | 137 | unsigned int iseed = (unsigned int) time (NULL); |
138 | |||
139 | |||
140 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
141 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
142 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
143 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
144 | #endif | ||
133 | srand (iseed); | 145 | srand (iseed); |
134 | ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; | 146 | ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; |
135 | if (NULL == ssl_version) | 147 | if (NULL == ssl_version) |
diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c index 54efcabb..30b76713 100644 --- a/src/testcurl/https/test_https_multi_daemon.c +++ b/src/testcurl/https/test_https_multi_daemon.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <curl/curl.h> | 29 | #include <curl/curl.h> |
30 | #include <limits.h> | 30 | #include <limits.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | 32 | #include <gcrypt.h> | |
33 | #include "tls_test_common.h" | 33 | #include "tls_test_common.h" |
34 | 34 | ||
35 | extern int curl_check_version (const char *req_version, ...); | 35 | extern int curl_check_version (const char *req_version, ...); |
@@ -40,14 +40,16 @@ extern const char srv_self_signed_cert_pem[]; | |||
40 | * assert initiating two separate daemons and having one shut down | 40 | * assert initiating two separate daemons and having one shut down |
41 | * doesn't affect the other | 41 | * doesn't affect the other |
42 | */ | 42 | */ |
43 | int | 43 | static int |
44 | test_concurent_daemon_pair (void * cls, char *cipher_suite, | 44 | test_concurent_daemon_pair (void *cls, |
45 | const char *cipher_suite, | ||
45 | int proto_version) | 46 | int proto_version) |
46 | { | 47 | { |
47 | 48 | ||
48 | int ret; | 49 | int ret; |
49 | struct MHD_Daemon *d1; | 50 | struct MHD_Daemon *d1; |
50 | struct MHD_Daemon *d2; | 51 | struct MHD_Daemon *d2; |
52 | |||
51 | d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | | 53 | d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | |
52 | MHD_USE_DEBUG, DEAMON_TEST_PORT, | 54 | MHD_USE_DEBUG, DEAMON_TEST_PORT, |
53 | NULL, NULL, &http_ahc, NULL, | 55 | NULL, NULL, &http_ahc, NULL, |
@@ -88,12 +90,21 @@ test_concurent_daemon_pair (void * cls, char *cipher_suite, | |||
88 | return ret; | 90 | return ret; |
89 | } | 91 | } |
90 | 92 | ||
93 | |||
94 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
95 | |||
96 | |||
91 | int | 97 | int |
92 | main (int argc, char *const *argv) | 98 | main (int argc, char *const *argv) |
93 | { | 99 | { |
94 | unsigned int errorCount = 0; | 100 | unsigned int errorCount = 0; |
95 | FILE *cert; | 101 | FILE *cert; |
96 | 102 | ||
103 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
104 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
105 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
106 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
107 | #endif | ||
97 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 108 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) |
98 | { | 109 | { |
99 | fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__, | 110 | fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__, |
@@ -106,7 +117,7 @@ main (int argc, char *const *argv) | |||
106 | return -1; | 117 | return -1; |
107 | } | 118 | } |
108 | 119 | ||
109 | char *aes256_sha = "AES256-SHA"; | 120 | const char *aes256_sha = "AES256-SHA"; |
110 | if (curl_uses_nss_ssl() == 0) | 121 | if (curl_uses_nss_ssl() == 0) |
111 | { | 122 | { |
112 | aes256_sha = "rsa_aes_256_sha"; | 123 | aes256_sha = "rsa_aes_256_sha"; |
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c index 8050a45d..aac3dcea 100644 --- a/src/testcurl/https/test_https_session_info.c +++ b/src/testcurl/https/test_https_session_info.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "microhttpd.h" | 28 | #include "microhttpd.h" |
29 | #include <curl/curl.h> | 29 | #include <curl/curl.h> |
30 | 30 | #include <gcrypt.h> | |
31 | #include "tls_test_common.h" | 31 | #include "tls_test_common.h" |
32 | 32 | ||
33 | extern int curl_check_version (const char *req_version, ...); | 33 | extern int curl_check_version (const char *req_version, ...); |
@@ -151,11 +151,19 @@ test_query_session () | |||
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
155 | |||
156 | |||
154 | int | 157 | int |
155 | main (int argc, char *const *argv) | 158 | main (int argc, char *const *argv) |
156 | { | 159 | { |
157 | unsigned int errorCount = 0; | 160 | unsigned int errorCount = 0; |
158 | 161 | ||
162 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
163 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
164 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
165 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
166 | #endif | ||
159 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 167 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) |
160 | { | 168 | { |
161 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 169 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c index 16b171ac..112f5390 100644 --- a/src/testcurl/https/test_https_time_out.c +++ b/src/testcurl/https/test_https_time_out.c | |||
@@ -29,13 +29,14 @@ | |||
29 | #include "microhttpd.h" | 29 | #include "microhttpd.h" |
30 | #include "internal.h" | 30 | #include "internal.h" |
31 | #include "tls_test_common.h" | 31 | #include "tls_test_common.h" |
32 | #include <gcrypt.h> | ||
32 | 33 | ||
33 | extern const char srv_key_pem[]; | 34 | extern const char srv_key_pem[]; |
34 | extern const char srv_self_signed_cert_pem[]; | 35 | extern const char srv_self_signed_cert_pem[]; |
35 | 36 | ||
36 | static const int TIME_OUT = 3; | 37 | static const int TIME_OUT = 3; |
37 | 38 | ||
38 | char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; | 39 | static const char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; |
39 | 40 | ||
40 | static int | 41 | static int |
41 | test_tls_session_time_out (gnutls_session_t session) | 42 | test_tls_session_time_out (gnutls_session_t session) |
@@ -89,6 +90,8 @@ test_tls_session_time_out (gnutls_session_t session) | |||
89 | return 0; | 90 | return 0; |
90 | } | 91 | } |
91 | 92 | ||
93 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
94 | |||
92 | int | 95 | int |
93 | main (int argc, char *const *argv) | 96 | main (int argc, char *const *argv) |
94 | { | 97 | { |
@@ -99,6 +102,12 @@ main (int argc, char *const *argv) | |||
99 | gnutls_datum_t cert; | 102 | gnutls_datum_t cert; |
100 | gnutls_certificate_credentials_t xcred; | 103 | gnutls_certificate_credentials_t xcred; |
101 | 104 | ||
105 | |||
106 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
107 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
108 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
109 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
110 | #endif | ||
102 | gnutls_global_init (); | 111 | gnutls_global_init (); |
103 | gnutls_global_set_log_level (11); | 112 | gnutls_global_set_log_level (11); |
104 | 113 | ||
diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c index d5a08ffa..42a33b4c 100644 --- a/src/testcurl/https/test_tls_authentication.c +++ b/src/testcurl/https/test_tls_authentication.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <curl/curl.h> | 29 | #include <curl/curl.h> |
30 | #include <limits.h> | 30 | #include <limits.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | 32 | #include <gcrypt.h> | |
33 | #include "tls_test_common.h" | 33 | #include "tls_test_common.h" |
34 | 34 | ||
35 | extern int curl_check_version (const char *req_version, ...); | 35 | extern int curl_check_version (const char *req_version, ...); |
@@ -69,11 +69,19 @@ test_secure_get (void * cls, char *cipher_suite, int proto_version) | |||
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
73 | |||
74 | |||
72 | int | 75 | int |
73 | main (int argc, char *const *argv) | 76 | main (int argc, char *const *argv) |
74 | { | 77 | { |
75 | unsigned int errorCount = 0; | 78 | unsigned int errorCount = 0; |
76 | 79 | ||
80 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
81 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
82 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
83 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
84 | #endif | ||
77 | if (setup_ca_cert () == NULL) | 85 | if (setup_ca_cert () == NULL) |
78 | { | 86 | { |
79 | fprintf (stderr, MHD_E_TEST_FILE_CREAT); | 87 | fprintf (stderr, MHD_E_TEST_FILE_CREAT); |
diff --git a/src/testcurl/https/test_tls_extensions.c b/src/testcurl/https/test_tls_extensions.c index 5d61c59e..2859fd9e 100644 --- a/src/testcurl/https/test_tls_extensions.c +++ b/src/testcurl/https/test_tls_extensions.c | |||
@@ -193,6 +193,8 @@ cleanup: | |||
193 | return ret; | 193 | return ret; |
194 | } | 194 | } |
195 | 195 | ||
196 | GCRY_THREAD_OPTION_PTHREAD_IMPL | ||
197 | |||
196 | int | 198 | int |
197 | main (int argc, char *const *argv) | 199 | main (int argc, char *const *argv) |
198 | { | 200 | { |
@@ -208,6 +210,12 @@ main (int argc, char *const *argv) | |||
208 | -1 | 210 | -1 |
209 | }; | 211 | }; |
210 | 212 | ||
213 | |||
214 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | ||
215 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | ||
216 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
217 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
218 | #endif | ||
211 | MHD_gtls_global_set_log_level (11); | 219 | MHD_gtls_global_set_log_level (11); |
212 | 220 | ||
213 | if ((test_fd = setup_test_file ()) == NULL) | 221 | if ((test_fd = setup_test_file ()) == NULL) |
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c index 1c604daf..0b065769 100644 --- a/src/testcurl/https/test_tls_options.c +++ b/src/testcurl/https/test_tls_options.c | |||
@@ -75,6 +75,8 @@ test_unmatching_ssl_version (void * cls, const char *cipher_suite, | |||
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | ||
79 | |||
78 | /* setup a temporary transfer test file */ | 80 | /* setup a temporary transfer test file */ |
79 | int | 81 | int |
80 | main (int argc, char *const *argv) | 82 | main (int argc, char *const *argv) |
@@ -85,7 +87,11 @@ main (int argc, char *const *argv) | |||
85 | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | MHD_USE_DEBUG; | 87 | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | MHD_USE_DEBUG; |
86 | gcry_control (GCRYCTL_DISABLE_SECMEM, 0); | 88 | gcry_control (GCRYCTL_DISABLE_SECMEM, 0); |
87 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | 89 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); |
88 | if (curl_check_version (MHD_REQ_CURL_VERSION)) | 90 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); |
91 | #ifdef GCRYCTL_INITIALIZATION_FINISHED | ||
92 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | ||
93 | #endif | ||
94 | if (curl_check_version (MHD_REQ_CURL_VERSION)) | ||
89 | { | 95 | { |
90 | return 0; | 96 | return 0; |
91 | } | 97 | } |
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c index af4ae277..03992ea3 100644 --- a/src/testcurl/https/tls_test_common.c +++ b/src/testcurl/https/tls_test_common.c | |||
@@ -63,7 +63,8 @@ setup_ca_cert () | |||
63 | * test HTTPS transfer | 63 | * test HTTPS transfer |
64 | */ | 64 | */ |
65 | int | 65 | int |
66 | test_daemon_get (void *cls, char *cipher_suite, int proto_version, | 66 | test_daemon_get (void *cls, |
67 | const char *cipher_suite, int proto_version, | ||
67 | int port, | 68 | int port, |
68 | int ver_peer) | 69 | int ver_peer) |
69 | { | 70 | { |
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h index 501c0226..bf5fc580 100644 --- a/src/testcurl/https/tls_test_common.h +++ b/src/testcurl/https/tls_test_common.h | |||
@@ -80,7 +80,8 @@ setup_ca_cert (); | |||
80 | * perform cURL request for file | 80 | * perform cURL request for file |
81 | */ | 81 | */ |
82 | int | 82 | int |
83 | test_daemon_get (void * cls, char *cipher_suite, int proto_version, | 83 | test_daemon_get (void * cls, |
84 | const char *cipher_suite, int proto_version, | ||
84 | int port, int ver_peer); | 85 | int port, int ver_peer); |
85 | 86 | ||
86 | void print_test_result (int test_outcome, char *test_name); | 87 | void print_test_result (int test_outcome, char *test_name); |