aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-04-10 20:00:02 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-04-10 20:00:02 +0300
commitfea6bf18a105c03509caeae84030eff990baaec5 (patch)
tree9ce20fbd1d07fe53c70b099eb91e779d5fe7b8ae /src
parentab406a9e6a0568bcb607ff737397bdc5b0cf533b (diff)
downloadlibmicrohttpd-fea6bf18a105c03509caeae84030eff990baaec5.tar.gz
libmicrohttpd-fea6bf18a105c03509caeae84030eff990baaec5.zip
HTTPS test fixes and improvements:
always skip tests if libcurl do not support HTTPS (instead of failing) return 99 in case of global errors (MHD-unrelated) print error result if test if failed fixed ignored result of epoll test in test_https_get_select allow compilation by C89 compiler
Diffstat (limited to 'src')
-rw-r--r--src/testcurl/https/test_empty_response.c12
-rw-r--r--src/testcurl/https/test_https_get.c10
-rw-r--r--src/testcurl/https/test_https_get_parallel.c13
-rw-r--r--src/testcurl/https/test_https_get_parallel_threads.c30
-rw-r--r--src/testcurl/https/test_https_get_select.c19
-rw-r--r--src/testcurl/https/test_https_multi_daemon.c17
-rw-r--r--src/testcurl/https/test_https_session_info.c8
-rw-r--r--src/testcurl/https/test_https_sni.c9
-rw-r--r--src/testcurl/https/test_https_time_out.c2
-rw-r--r--src/testcurl/https/test_tls_authentication.c23
-rw-r--r--src/testcurl/https/test_tls_options.c4
-rw-r--r--src/testcurl/https/tls_test_common.c4
12 files changed, 101 insertions, 50 deletions
diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c
index 57e2d676..37061b65 100644
--- a/src/testcurl/https/test_empty_response.c
+++ b/src/testcurl/https/test_empty_response.c
@@ -201,10 +201,16 @@ main (int argc, char *const *argv)
201 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 201 if (0 != curl_global_init (CURL_GLOBAL_ALL))
202 { 202 {
203 fprintf (stderr, "Error: %s\n", strerror (errno)); 203 fprintf (stderr, "Error: %s\n", strerror (errno));
204 return -1; 204 return 99;
205 }
206 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
207 {
208 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
209 curl_global_cleanup ();
210 return 77;
205 } 211 }
206 if (0 != (errorCount = testInternalSelectGet ())) 212 if (0 != (errorCount = testInternalSelectGet ()))
207 fprintf (stderr, "Fail: %d\n", errorCount); 213 fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
208 curl_global_cleanup (); 214 curl_global_cleanup ();
209 return errorCount != 0; 215 return errorCount != 0 ? 1 : 0;
210} 216}
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c
index f8795b9b..0b82bf0f 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -109,7 +109,13 @@ main (int argc, char *const *argv)
109 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 109 if (0 != curl_global_init (CURL_GLOBAL_ALL))
110 { 110 {
111 fprintf (stderr, "Error: %s\n", strerror (errno)); 111 fprintf (stderr, "Error: %s\n", strerror (errno));
112 return -1; 112 return 99;
113 }
114 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
115 {
116 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
117 curl_global_cleanup ();
118 return 77;
113 } 119 }
114 120
115 if (curl_uses_nss_ssl() == 0) 121 if (curl_uses_nss_ssl() == 0)
@@ -126,5 +132,5 @@ main (int argc, char *const *argv)
126 132
127 curl_global_cleanup (); 133 curl_global_cleanup ();
128 134
129 return errorCount != 0; 135 return errorCount != 0 ? 1 : 0;
130} 136}
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c
index d9d6eefa..45c08d0c 100644
--- a/src/testcurl/https/test_https_get_parallel.c
+++ b/src/testcurl/https/test_https_get_parallel.c
@@ -142,11 +142,16 @@ main (int argc, char *const *argv)
142 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 142 if (0 != curl_global_init (CURL_GLOBAL_ALL))
143 { 143 {
144 fprintf (stderr, "Error: %s\n", strerror (errno)); 144 fprintf (stderr, "Error: %s\n", strerror (errno));
145 return -1; 145 return 99;
146 } 146 }
147 147
148 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
149 {
150 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
151 return 77;
152 }
148 if (curl_uses_nss_ssl() == 0) 153 if (curl_uses_nss_ssl() == 0)
149 aes256_sha = "rsa_aes_256_sha"; 154 aes256_sha = "rsa_aes_256_sha";
150#ifdef EPOLL_SUPPORT 155#ifdef EPOLL_SUPPORT
151 errorCount += 156 errorCount +=
152 test_wrap ("single threaded daemon, single client, epoll", &test_single_client, 157 test_wrap ("single threaded daemon, single client, epoll", &test_single_client,
@@ -181,5 +186,7 @@ main (int argc, char *const *argv)
181 srv_self_signed_cert_pem, MHD_OPTION_END); 186 srv_self_signed_cert_pem, MHD_OPTION_END);
182 187
183 curl_global_cleanup (); 188 curl_global_cleanup ();
184 return errorCount != 0; 189 if (errorCount != 0)
190 fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
191 return errorCount != 0 ? 1 : 0;
185} 192}
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c
index ef1ecf69..239559ac 100644
--- a/src/testcurl/https/test_https_get_parallel_threads.c
+++ b/src/testcurl/https/test_https_get_parallel_threads.c
@@ -144,21 +144,23 @@ main (int argc, char *const *argv)
144 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 144 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
145#endif 145#endif
146 srand (iseed); 146 srand (iseed);
147 ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;
148 if (NULL == ssl_version)
149 {
150 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
151 return 0;
152 }
153 if (0 != strncmp (ssl_version, "GnuTLS", 6))
154 {
155 fprintf (stderr, "This test can be run only with libcurl-gnutls.\n");
156 return 0;
157 }
158 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 147 if (0 != curl_global_init (CURL_GLOBAL_ALL))
159 { 148 {
160 fprintf (stderr, "Error: %s\n", strerror (errno)); 149 fprintf (stderr, "Error: %s\n", strerror (errno));
161 return -1; 150 return 99;
151 }
152 ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;
153 if (0 != strncmp (ssl_version, "GnuTLS", 6))
154 {
155 fprintf (stderr, "This test can be run only with libcurl-gnutls.\n");
156 curl_global_cleanup ();
157 return 77;
158 }
159 if (NULL == ssl_version)
160 {
161 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
162 curl_global_cleanup ();
163 return 77;
162 } 164 }
163 165
164 char *aes256_sha = "AES256-SHA"; 166 char *aes256_sha = "AES256-SHA";
@@ -184,8 +186,8 @@ main (int argc, char *const *argv)
184 srv_self_signed_cert_pem, MHD_OPTION_END); 186 srv_self_signed_cert_pem, MHD_OPTION_END);
185 187
186 if (errorCount != 0) 188 if (errorCount != 0)
187 fprintf (stderr, "Failed test: %s.\n", argv[0]); 189 fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
188 190
189 curl_global_cleanup (); 191 curl_global_cleanup ();
190 return errorCount != 0; 192 return errorCount != 0 ? 1 : 0;
191} 193}
diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c
index a9ae7f62..56bed223 100644
--- a/src/testcurl/https/test_https_get_select.c
+++ b/src/testcurl/https/test_https_get_select.c
@@ -230,14 +230,21 @@ main (int argc, char *const *argv)
230 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 230 if (0 != curl_global_init (CURL_GLOBAL_ALL))
231 { 231 {
232 fprintf (stderr, "Error: %s\n", strerror (errno)); 232 fprintf (stderr, "Error: %s\n", strerror (errno));
233 return -1; 233 return 99;
234 } 234 }
235 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
236 {
237 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
238 curl_global_cleanup ();
239 return 77;
240 }
241
235#ifdef EPOLL_SUPPORT 242#ifdef EPOLL_SUPPORT
236 if (0 != (errorCount = testExternalGet (MHD_USE_EPOLL))) 243 errorCount += testExternalGet (MHD_USE_EPOLL);
237 fprintf (stderr, "Fail: %d\n", errorCount);
238#endif 244#endif
239 if (0 != (errorCount = testExternalGet (0))) 245 errorCount += testExternalGet (0);
240 fprintf (stderr, "Fail: %d\n", errorCount);
241 curl_global_cleanup (); 246 curl_global_cleanup ();
242 return errorCount != 0; 247 if (errorCount != 0)
248 fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
249 return errorCount != 0 ? 1 : 0;
243} 250}
diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c
index b7f541b6..fdd4b74e 100644
--- a/src/testcurl/https/test_https_multi_daemon.c
+++ b/src/testcurl/https/test_https_multi_daemon.c
@@ -96,6 +96,7 @@ main (int argc, char *const *argv)
96{ 96{
97 unsigned int errorCount = 0; 97 unsigned int errorCount = 0;
98 FILE *cert; 98 FILE *cert;
99 const char *aes256_sha = "AES256-SHA";
99 100
100 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 101 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
101#ifdef GCRYCTL_INITIALIZATION_FINISHED 102#ifdef GCRYCTL_INITIALIZATION_FINISHED
@@ -105,20 +106,26 @@ main (int argc, char *const *argv)
105 { 106 {
106 fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__, 107 fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__,
107 __FUNCTION__); 108 __FUNCTION__);
108 return -1; 109 return 99;
110 }
111 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
112 {
113 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
114 curl_global_cleanup ();
115 return 77;
109 } 116 }
110 if ((cert = setup_ca_cert ()) == NULL) 117 if ((cert = setup_ca_cert ()) == NULL)
111 { 118 {
112 fprintf (stderr, MHD_E_TEST_FILE_CREAT); 119 fprintf (stderr, MHD_E_TEST_FILE_CREAT);
113 return -1; 120 curl_global_cleanup ();
121 return 99;
114 } 122 }
115 123
116 const char *aes256_sha = "AES256-SHA";
117 if (curl_uses_nss_ssl() == 0) 124 if (curl_uses_nss_ssl() == 0)
118 { 125 {
119 aes256_sha = "rsa_aes_256_sha"; 126 aes256_sha = "rsa_aes_256_sha";
120 } 127 }
121 128
122 errorCount += 129 errorCount +=
123 test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_TLSv1); 130 test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_TLSv1);
124 131
@@ -130,5 +137,5 @@ main (int argc, char *const *argv)
130 fprintf (stderr, 137 fprintf (stderr,
131 "Failed to remove `%s'\n", 138 "Failed to remove `%s'\n",
132 ca_cert_file_name); 139 ca_cert_file_name);
133 return errorCount != 0; 140 return errorCount != 0 ? 1 : 0;
134} 141}
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c
index 62a01518..d4f2985e 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -180,18 +180,20 @@ main (int argc, char *const *argv)
180 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 180 if (0 != curl_global_init (CURL_GLOBAL_ALL))
181 { 181 {
182 fprintf (stderr, "Error (code: %u)\n", errorCount); 182 fprintf (stderr, "Error (code: %u)\n", errorCount);
183 return -1; 183 return 99;
184 } 184 }
185 185
186 ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; 186 ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;
187 if (NULL == ssl_version) 187 if (NULL == ssl_version)
188 { 188 {
189 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); 189 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
190 curl_global_cleanup ();
190 return 77; 191 return 77;
191 } 192 }
192 if (0 != strncmp (ssl_version, "GnuTLS", 6)) 193 if (0 != strncmp (ssl_version, "GnuTLS", 6))
193 { 194 {
194 fprintf (stderr, "This test can be run only with libcurl-gnutls.\n"); 195 fprintf (stderr, "This test can be run only with libcurl-gnutls.\n");
196 curl_global_cleanup ();
195 return 77; 197 return 77;
196 } 198 }
197#if LIBCURL_VERSION_NUM >= 0x072200 199#if LIBCURL_VERSION_NUM >= 0x072200
@@ -199,7 +201,5 @@ main (int argc, char *const *argv)
199#endif 201#endif
200 print_test_result (errorCount, argv[0]); 202 print_test_result (errorCount, argv[0]);
201 curl_global_cleanup (); 203 curl_global_cleanup ();
202 if (errorCount > 0) 204 return errorCount != 0 ? 1 : 0;
203 fprintf (stderr, "Error (code: %u)\n", errorCount);
204 return errorCount;
205} 205}
diff --git a/src/testcurl/https/test_https_sni.c b/src/testcurl/https/test_https_sni.c
index 137c6a37..6603cace 100644
--- a/src/testcurl/https/test_https_sni.c
+++ b/src/testcurl/https/test_https_sni.c
@@ -256,8 +256,15 @@ main (int argc, char *const *argv)
256 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 256 if (0 != curl_global_init (CURL_GLOBAL_ALL))
257 { 257 {
258 fprintf (stderr, "Error: %s\n", strerror (errno)); 258 fprintf (stderr, "Error: %s\n", strerror (errno));
259 return 99;
260 }
261 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
262 {
263 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
264 curl_global_cleanup ();
259 return 77; 265 return 77;
260 } 266 }
267
261 load_keys ("host1", ABS_SRCDIR "/host1.crt", ABS_SRCDIR "/host1.key"); 268 load_keys ("host1", ABS_SRCDIR "/host1.crt", ABS_SRCDIR "/host1.key");
262 load_keys ("host2", ABS_SRCDIR "/host2.crt", ABS_SRCDIR "/host2.key"); 269 load_keys ("host2", ABS_SRCDIR "/host2.crt", ABS_SRCDIR "/host2.key");
263 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, 270 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG,
@@ -278,6 +285,8 @@ main (int argc, char *const *argv)
278 285
279 MHD_stop_daemon (d); 286 MHD_stop_daemon (d);
280 curl_global_cleanup (); 287 curl_global_cleanup ();
288 if (error_count != 0)
289 fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], error_count);
281 return (0 != error_count) ? 1 : 0; 290 return (0 != error_count) ? 1 : 0;
282} 291}
283 292
diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c
index 3d76b2b6..de619206 100644
--- a/src/testcurl/https/test_https_time_out.c
+++ b/src/testcurl/https/test_https_time_out.c
@@ -143,5 +143,5 @@ main (int argc, char *const *argv)
143 MHD_stop_daemon (d); 143 MHD_stop_daemon (d);
144 gnutls_global_deinit (); 144 gnutls_global_deinit ();
145 145
146 return errorCount != 0; 146 return errorCount != 0 ? 1 : 0;
147} 147}
diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c
index b5fe8f28..9f337a32 100644
--- a/src/testcurl/https/test_tls_authentication.c
+++ b/src/testcurl/https/test_tls_authentication.c
@@ -73,24 +73,31 @@ int
73main (int argc, char *const *argv) 73main (int argc, char *const *argv)
74{ 74{
75 unsigned int errorCount = 0; 75 unsigned int errorCount = 0;
76 char *aes256_sha = "AES256-SHA";
76 77
77 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 78 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
78#ifdef GCRYCTL_INITIALIZATION_FINISHED 79#ifdef GCRYCTL_INITIALIZATION_FINISHED
79 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 80 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
80#endif 81#endif
81 if (setup_ca_cert () == NULL) 82 if (0 != curl_global_init (CURL_GLOBAL_ALL))
82 { 83 {
83 fprintf (stderr, MHD_E_TEST_FILE_CREAT); 84 fprintf (stderr, "Error (code: %u)\n", errorCount);
84 return -1; 85 return 99;
86 }
87 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
88 {
89 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
90 curl_global_cleanup ();
91 return 77;
85 } 92 }
86 93
87 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 94 if (setup_ca_cert () == NULL)
88 { 95 {
89 fprintf (stderr, "Error (code: %u)\n", errorCount); 96 fprintf (stderr, MHD_E_TEST_FILE_CREAT);
90 return -1; 97 curl_global_cleanup ();
98 return 99;
91 } 99 }
92 100
93 char *aes256_sha = "AES256-SHA";
94 if (curl_uses_nss_ssl() == 0) 101 if (curl_uses_nss_ssl() == 0)
95 { 102 {
96 aes256_sha = "rsa_aes_256_sha"; 103 aes256_sha = "rsa_aes_256_sha";
@@ -106,5 +113,5 @@ main (int argc, char *const *argv)
106 fprintf (stderr, 113 fprintf (stderr,
107 "Failed to remove `%s'\n", 114 "Failed to remove `%s'\n",
108 ca_cert_file_name); 115 ca_cert_file_name);
109 return errorCount != 0; 116 return errorCount != 0 ? 1 : 0;
110} 117}
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c
index 3aa8dc0f..ff8d1137 100644
--- a/src/testcurl/https/test_tls_options.c
+++ b/src/testcurl/https/test_tls_options.c
@@ -109,7 +109,7 @@ main (int argc, char *const *argv)
109 if (0 != curl_global_init (CURL_GLOBAL_ALL)) 109 if (0 != curl_global_init (CURL_GLOBAL_ALL))
110 { 110 {
111 fprintf (stderr, "Error: %s\n", strerror (errno)); 111 fprintf (stderr, "Error: %s\n", strerror (errno));
112 return 77; 112 return 99;
113 } 113 }
114 114
115 const char *aes128_sha = "AES128-SHA"; 115 const char *aes128_sha = "AES128-SHA";
@@ -151,5 +151,5 @@ main (int argc, char *const *argv)
151 } 151 }
152 curl_global_cleanup (); 152 curl_global_cleanup ();
153 153
154 return errorCount != 0; 154 return errorCount != 0 ? 1 : 0;
155} 155}
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
index 728842e0..edbc785c 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -139,9 +139,9 @@ test_daemon_get (void *cls,
139void 139void
140print_test_result (int test_outcome, char *test_name) 140print_test_result (int test_outcome, char *test_name)
141{ 141{
142#if 0
143 if (test_outcome != 0) 142 if (test_outcome != 0)
144 fprintf (stderr, "running test: %s [fail]\n", test_name); 143 fprintf (stderr, "running test: %s [fail: %u]\n", test_name, (unsigned int)test_outcome);
144#if 0
145 else 145 else
146 fprintf (stdout, "running test: %s [pass]\n", test_name); 146 fprintf (stdout, "running test: %s [pass]\n", test_name);
147#endif 147#endif