diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-11-15 16:12:12 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-11-15 16:12:12 +0300 |
commit | 23324164fb6fcc421a0bf081c50a00ce3f66f9b7 (patch) | |
tree | dc49ec9b64c17257665f66042054b201f238e7fe | |
parent | fd7d712823b6fd2d544a85a15f27f2a01989f29e (diff) | |
download | libmicrohttpd-23324164fb6fcc421a0bf081c50a00ce3f66f9b7.tar.gz libmicrohttpd-23324164fb6fcc421a0bf081c50a00ce3f66f9b7.zip |
https tests: supported multi-TLS selection on libcurl >= 7.56.0,
fixed error report for failed initialisation of libcurl
-rw-r--r-- | src/testcurl/https/test_empty_response.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_parallel.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_parallel_threads.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_select.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_multi_daemon.c | 8 | ||||
-rw-r--r-- | src/testcurl/https/test_https_session_info.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_sni.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_authentication.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_extensions.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_options.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.c | 19 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.h | 3 |
13 files changed, 44 insertions, 56 deletions
diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c index ba7136a8..27cb1e31 100644 --- a/src/testcurl/https/test_empty_response.c +++ b/src/testcurl/https/test_empty_response.c | |||
@@ -222,11 +222,8 @@ main (int argc, char *const *argv) | |||
222 | unsigned int errorCount = 0; | 222 | unsigned int errorCount = 0; |
223 | (void)argc; /* Unused. Silent compiler warning. */ | 223 | (void)argc; /* Unused. Silent compiler warning. */ |
224 | 224 | ||
225 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 225 | if (!testsuite_curl_global_init ()) |
226 | { | 226 | return 99; |
227 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
228 | return 99; | ||
229 | } | ||
230 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 227 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
231 | { | 228 | { |
232 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 229 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c index e417129d..8ed0028a 100644 --- a/src/testcurl/https/test_https_get.c +++ b/src/testcurl/https/test_https_get.c | |||
@@ -139,11 +139,8 @@ main (int argc, char *const *argv) | |||
139 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | 139 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); |
140 | #endif | 140 | #endif |
141 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 141 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
142 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 142 | if (!testsuite_curl_global_init ()) |
143 | { | 143 | return 99; |
144 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
145 | return 99; | ||
146 | } | ||
147 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 144 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
148 | { | 145 | { |
149 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 146 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c index 91d870d8..27c23173 100644 --- a/src/testcurl/https/test_https_get_parallel.c +++ b/src/testcurl/https/test_https_get_parallel.c | |||
@@ -150,11 +150,8 @@ main (int argc, char *const *argv) | |||
150 | /* initialize random seed used by curl clients */ | 150 | /* initialize random seed used by curl clients */ |
151 | unsigned int iseed = (unsigned int) time (NULL); | 151 | unsigned int iseed = (unsigned int) time (NULL); |
152 | srand (iseed); | 152 | srand (iseed); |
153 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 153 | if (!testsuite_curl_global_init ()) |
154 | { | 154 | return 99; |
155 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
156 | return 99; | ||
157 | } | ||
158 | 155 | ||
159 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 156 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
160 | { | 157 | { |
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c index 832b206f..c9fc8ffc 100644 --- a/src/testcurl/https/test_https_get_parallel_threads.c +++ b/src/testcurl/https/test_https_get_parallel_threads.c | |||
@@ -157,11 +157,8 @@ main (int argc, char *const *argv) | |||
157 | #endif | 157 | #endif |
158 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 158 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
159 | srand (iseed); | 159 | srand (iseed); |
160 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 160 | if (!testsuite_curl_global_init ()) |
161 | { | 161 | return 99; |
162 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
163 | return 99; | ||
164 | } | ||
165 | ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; | 162 | ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; |
166 | if (NULL == ssl_version) | 163 | if (NULL == ssl_version) |
167 | { | 164 | { |
diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c index 5e1fa238..64be861a 100644 --- a/src/testcurl/https/test_https_get_select.c +++ b/src/testcurl/https/test_https_get_select.c | |||
@@ -250,11 +250,8 @@ main (int argc, char *const *argv) | |||
250 | unsigned int errorCount = 0; | 250 | unsigned int errorCount = 0; |
251 | (void)argc; /* Unused. Silent compiler warning. */ | 251 | (void)argc; /* Unused. Silent compiler warning. */ |
252 | 252 | ||
253 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 253 | if (!testsuite_curl_global_init ()) |
254 | { | 254 | return 99; |
255 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
256 | return 99; | ||
257 | } | ||
258 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 255 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
259 | { | 256 | { |
260 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 257 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c index 75017662..130fa9df 100644 --- a/src/testcurl/https/test_https_multi_daemon.c +++ b/src/testcurl/https/test_https_multi_daemon.c | |||
@@ -136,12 +136,8 @@ main (int argc, char *const *argv) | |||
136 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | 136 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); |
137 | #endif | 137 | #endif |
138 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 138 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
139 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 139 | if (!testsuite_curl_global_init ()) |
140 | { | 140 | return 99; |
141 | fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__, | ||
142 | __FUNCTION__); | ||
143 | return 99; | ||
144 | } | ||
145 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 141 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
146 | { | 142 | { |
147 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 143 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c index 1aa50955..a58c7f7b 100644 --- a/src/testcurl/https/test_https_session_info.c +++ b/src/testcurl/https/test_https_session_info.c | |||
@@ -199,11 +199,8 @@ main (int argc, char *const *argv) | |||
199 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | 199 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); |
200 | #endif | 200 | #endif |
201 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 201 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
202 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 202 | if (!testsuite_curl_global_init ()) |
203 | { | 203 | return 99; |
204 | fprintf (stderr, "Error (code: %u)\n", errorCount); | ||
205 | return 99; | ||
206 | } | ||
207 | 204 | ||
208 | ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; | 205 | ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; |
209 | if (NULL == ssl_version) | 206 | if (NULL == ssl_version) |
diff --git a/src/testcurl/https/test_https_sni.c b/src/testcurl/https/test_https_sni.c index 1567730c..6963d62c 100644 --- a/src/testcurl/https/test_https_sni.c +++ b/src/testcurl/https/test_https_sni.c | |||
@@ -269,11 +269,8 @@ main (int argc, char *const *argv) | |||
269 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | 269 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); |
270 | #endif | 270 | #endif |
271 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 271 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
272 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 272 | if (!testsuite_curl_global_init ()) |
273 | { | 273 | return 99; |
274 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
275 | return 99; | ||
276 | } | ||
277 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 274 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
278 | { | 275 | { |
279 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 276 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c index 734a2a4a..7a6cd9a4 100644 --- a/src/testcurl/https/test_tls_authentication.c +++ b/src/testcurl/https/test_tls_authentication.c | |||
@@ -94,11 +94,8 @@ main (int argc, char *const *argv) | |||
94 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); | 94 | gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); |
95 | #endif | 95 | #endif |
96 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 96 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
97 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 97 | if (!testsuite_curl_global_init ()) |
98 | { | 98 | return 99; |
99 | fprintf (stderr, "Error (code: %u)\n", errorCount); | ||
100 | return 99; | ||
101 | } | ||
102 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 99 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
103 | { | 100 | { |
104 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 101 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
diff --git a/src/testcurl/https/test_tls_extensions.c b/src/testcurl/https/test_tls_extensions.c index 98725ee3..08cde939 100644 --- a/src/testcurl/https/test_tls_extensions.c +++ b/src/testcurl/https/test_tls_extensions.c | |||
@@ -238,11 +238,8 @@ main (int argc, char *const *argv) | |||
238 | return -1; | 238 | return -1; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 241 | if (!testsuite_curl_global_init ()) |
242 | { | 242 | return 99; |
243 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
244 | return -1; | ||
245 | } | ||
246 | 243 | ||
247 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | | 244 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | |
248 | MHD_USE_ERROR_LOG, port, | 245 | MHD_USE_ERROR_LOG, port, |
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c index 6d393bf2..e3b427d9 100644 --- a/src/testcurl/https/test_tls_options.c +++ b/src/testcurl/https/test_tls_options.c | |||
@@ -121,11 +121,8 @@ main (int argc, char *const *argv) | |||
121 | return 77; | 121 | return 77; |
122 | } | 122 | } |
123 | 123 | ||
124 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) | 124 | if (!testsuite_curl_global_init ()) |
125 | { | 125 | return 99; |
126 | fprintf (stderr, "Error: %s\n", strerror (errno)); | ||
127 | return 99; | ||
128 | } | ||
129 | 126 | ||
130 | const char *aes128_sha = "AES128-SHA"; | 127 | const char *aes128_sha = "AES128-SHA"; |
131 | const char *aes256_sha = "AES256-SHA"; | 128 | const char *aes256_sha = "AES256-SHA"; |
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c index be13ad36..24782615 100644 --- a/src/testcurl/https/tls_test_common.c +++ b/src/testcurl/https/tls_test_common.c | |||
@@ -525,3 +525,22 @@ test_wrap (const char *test_name, int | |||
525 | va_end (arg_list); | 525 | va_end (arg_list); |
526 | return ret; | 526 | return ret; |
527 | } | 527 | } |
528 | |||
529 | int testsuite_curl_global_init (void) | ||
530 | { | ||
531 | CURLcode res; | ||
532 | #if LIBCURL_VERSION_NUM >= 0x07380 | ||
533 | if (CURLSSLSET_OK != curl_global_sslset(CURLSSLBACKEND_GNUTLS, NULL, NULL)) | ||
534 | { | ||
535 | if (CURLSSLSET_TOO_LATE == curl_global_sslset(CURLSSLBACKEND_OPENSSL, NULL, NULL)) | ||
536 | fprintf (stderr, "WARNING: libcurl was already initialised.\n"); | ||
537 | } | ||
538 | #endif /* LIBCURL_VERSION_NUM >= 0x07380 */ | ||
539 | res = curl_global_init (CURL_GLOBAL_ALL); | ||
540 | if (CURLE_OK != res) | ||
541 | { | ||
542 | fprintf (stderr, "libcurl initialisation error: %s\n", curl_easy_strerror(res)); | ||
543 | return 0; | ||
544 | } | ||
545 | return 1; | ||
546 | } | ||
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h index 07849e44..490239ef 100644 --- a/src/testcurl/https/tls_test_common.h +++ b/src/testcurl/https/tls_test_common.h | |||
@@ -149,4 +149,7 @@ test_wrap (const char *test_name, int | |||
149 | int proto_version), void * cls, | 149 | int proto_version), void * cls, |
150 | int port, | 150 | int port, |
151 | int daemon_flags, const char *cipher_suite, int proto_version, ...); | 151 | int daemon_flags, const char *cipher_suite, int proto_version, ...); |
152 | |||
153 | int testsuite_curl_global_init (void); | ||
154 | |||
152 | #endif /* TLS_TEST_COMMON_H_ */ | 155 | #endif /* TLS_TEST_COMMON_H_ */ |