aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_get.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_get.c')
-rw-r--r--src/testcurl/test_get.c808
1 files changed, 423 insertions, 385 deletions
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index 567b0787..dee5a9c1 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -48,10 +48,10 @@
48#include <sys/socket.h> 48#include <sys/socket.h>
49#endif 49#endif
50 50
51#if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 51#if defined(CPU_COUNT) && (CPU_COUNT + 0) < 2
52#undef CPU_COUNT 52#undef CPU_COUNT
53#endif 53#endif
54#if !defined(CPU_COUNT) 54#if ! defined(CPU_COUNT)
55#define CPU_COUNT 2 55#define CPU_COUNT 2
56#endif 56#endif
57 57
@@ -88,12 +88,12 @@ log_cb (void *cls,
88 (void) con; 88 (void) con;
89 if (0 != strcmp (uri, 89 if (0 != strcmp (uri,
90 EXPECTED_URI_PATH)) 90 EXPECTED_URI_PATH))
91 { 91 {
92 fprintf (stderr, 92 fprintf (stderr,
93 "Wrong URI: `%s'\n", 93 "Wrong URI: `%s'\n",
94 uri); 94 uri);
95 _exit (22); 95 _exit (22);
96 } 96 }
97 return NULL; 97 return NULL;
98} 98}
99 99
@@ -119,10 +119,10 @@ ahc_echo (void *cls,
119 if (0 != strcasecmp (me, method)) 119 if (0 != strcasecmp (me, method))
120 return MHD_NO; /* unexpected method */ 120 return MHD_NO; /* unexpected method */
121 if (&ptr != *unused) 121 if (&ptr != *unused)
122 { 122 {
123 *unused = &ptr; 123 *unused = &ptr;
124 return MHD_YES; 124 return MHD_YES;
125 } 125 }
126 *unused = NULL; 126 *unused = NULL;
127 v = MHD_lookup_connection_value (connection, 127 v = MHD_lookup_connection_value (connection,
128 MHD_GET_ARGUMENT_KIND, 128 MHD_GET_ARGUMENT_KIND,
@@ -130,11 +130,11 @@ ahc_echo (void *cls,
130 if ( (NULL == v) || 130 if ( (NULL == v) ||
131 (0 != strcmp ("&", 131 (0 != strcmp ("&",
132 v)) ) 132 v)) )
133 { 133 {
134 fprintf (stderr, "Found while looking for 'a=&': 'a=%s'\n", 134 fprintf (stderr, "Found while looking for 'a=&': 'a=%s'\n",
135 NULL == v ? "NULL" : v); 135 NULL == v ? "NULL" : v);
136 _exit (17); 136 _exit (17);
137 } 137 }
138 v = NULL; 138 v = NULL;
139 if (MHD_YES != MHD_lookup_connection_value_n (connection, 139 if (MHD_YES != MHD_lookup_connection_value_n (connection,
140 MHD_GET_ARGUMENT_KIND, 140 MHD_GET_ARGUMENT_KIND,
@@ -142,30 +142,30 @@ ahc_echo (void *cls,
142 1, 142 1,
143 &v, 143 &v,
144 NULL)) 144 NULL))
145 { 145 {
146 fprintf (stderr, "Not found 'b' GET argument.\n"); 146 fprintf (stderr, "Not found 'b' GET argument.\n");
147 _exit (18); 147 _exit (18);
148 } 148 }
149 if ( (NULL == v) || 149 if ( (NULL == v) ||
150 (0 != strcmp ("c", 150 (0 != strcmp ("c",
151 v)) ) 151 v)) )
152 { 152 {
153 fprintf (stderr, "Found while looking for 'b=c': 'b=%s'\n", 153 fprintf (stderr, "Found while looking for 'b=c': 'b=%s'\n",
154 NULL == v ? "NULL" : v); 154 NULL == v ? "NULL" : v);
155 _exit (19); 155 _exit (19);
156 } 156 }
157 response = MHD_create_response_from_buffer (strlen (url), 157 response = MHD_create_response_from_buffer (strlen (url),
158 (void *) url, 158 (void *) url,
159 MHD_RESPMEM_MUST_COPY); 159 MHD_RESPMEM_MUST_COPY);
160 ret = MHD_queue_response (connection, 160 ret = MHD_queue_response (connection,
161 MHD_HTTP_OK, 161 MHD_HTTP_OK,
162 response); 162 response);
163 MHD_destroy_response (response); 163 MHD_destroy_response (response);
164 if (ret == MHD_NO) 164 if (ret == MHD_NO)
165 { 165 {
166 fprintf (stderr, "Failed to queue response.\n"); 166 fprintf (stderr, "Failed to queue response.\n");
167 _exit (19); 167 _exit (19);
168 } 168 }
169 return ret; 169 return ret;
170} 170}
171 171
@@ -181,16 +181,17 @@ testInternalGet (int poll_flag)
181 181
182 if ( (0 == global_port) && 182 if ( (0 == global_port) &&
183 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) 183 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
184 { 184 {
185 global_port = 1220; 185 global_port = 1220;
186 if (oneone) 186 if (oneone)
187 global_port += 20; 187 global_port += 20;
188 } 188 }
189 189
190 cbc.buf = buf; 190 cbc.buf = buf;
191 cbc.size = 2048; 191 cbc.size = 2048;
192 cbc.pos = 0; 192 cbc.pos = 0;
193 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 193 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
194 | poll_flag,
194 global_port, NULL, NULL, 195 global_port, NULL, NULL,
195 &ahc_echo, "GET", 196 &ahc_echo, "GET",
196 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 197 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -198,16 +199,18 @@ testInternalGet (int poll_flag)
198 if (d == NULL) 199 if (d == NULL)
199 return 1; 200 return 1;
200 if (0 == global_port) 201 if (0 == global_port)
202 {
203 const union MHD_DaemonInfo *dinfo;
204 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
205 if ((NULL == dinfo) ||(0 == dinfo->port) )
201 { 206 {
202 const union MHD_DaemonInfo *dinfo; 207 MHD_stop_daemon (d); return 32;
203 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
204 if (NULL == dinfo || 0 == dinfo->port)
205 { MHD_stop_daemon (d); return 32; }
206 global_port = (int)dinfo->port;
207 } 208 }
209 global_port = (int) dinfo->port;
210 }
208 c = curl_easy_init (); 211 c = curl_easy_init ();
209 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); 212 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH);
210 curl_easy_setopt (c, CURLOPT_PORT, (long)global_port); 213 curl_easy_setopt (c, CURLOPT_PORT, (long) global_port);
211 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 214 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
212 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 215 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
213 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 216 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
@@ -222,14 +225,14 @@ testInternalGet (int poll_flag)
222 crashes on my system!*/ 225 crashes on my system!*/
223 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 226 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
224 if (CURLE_OK != (errornum = curl_easy_perform (c))) 227 if (CURLE_OK != (errornum = curl_easy_perform (c)))
225 { 228 {
226 fprintf (stderr, 229 fprintf (stderr,
227 "curl_easy_perform failed: `%s'\n", 230 "curl_easy_perform failed: `%s'\n",
228 curl_easy_strerror (errornum)); 231 curl_easy_strerror (errornum));
229 curl_easy_cleanup (c); 232 curl_easy_cleanup (c);
230 MHD_stop_daemon (d); 233 MHD_stop_daemon (d);
231 return 2; 234 return 2;
232 } 235 }
233 curl_easy_cleanup (c); 236 curl_easy_cleanup (c);
234 MHD_stop_daemon (d); 237 MHD_stop_daemon (d);
235 if (cbc.pos != strlen ("/hello_world")) 238 if (cbc.pos != strlen ("/hello_world"))
@@ -251,16 +254,18 @@ testMultithreadedGet (int poll_flag)
251 254
252 if ( (0 == global_port) && 255 if ( (0 == global_port) &&
253 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) 256 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
254 { 257 {
255 global_port = 1221; 258 global_port = 1221;
256 if (oneone) 259 if (oneone)
257 global_port += 20; 260 global_port += 20;
258 } 261 }
259 262
260 cbc.buf = buf; 263 cbc.buf = buf;
261 cbc.size = 2048; 264 cbc.size = 2048;
262 cbc.pos = 0; 265 cbc.pos = 0;
263 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 266 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
267 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
268 | poll_flag,
264 global_port, NULL, NULL, 269 global_port, NULL, NULL,
265 &ahc_echo, "GET", 270 &ahc_echo, "GET",
266 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 271 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -268,16 +273,18 @@ testMultithreadedGet (int poll_flag)
268 if (d == NULL) 273 if (d == NULL)
269 return 16; 274 return 16;
270 if (0 == global_port) 275 if (0 == global_port)
276 {
277 const union MHD_DaemonInfo *dinfo;
278 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
279 if ((NULL == dinfo) ||(0 == dinfo->port) )
271 { 280 {
272 const union MHD_DaemonInfo *dinfo; 281 MHD_stop_daemon (d); return 32;
273 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
274 if (NULL == dinfo || 0 == dinfo->port)
275 { MHD_stop_daemon (d); return 32; }
276 global_port = (int)dinfo->port;
277 } 282 }
283 global_port = (int) dinfo->port;
284 }
278 c = curl_easy_init (); 285 c = curl_easy_init ();
279 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); 286 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH);
280 curl_easy_setopt (c, CURLOPT_PORT, (long)global_port); 287 curl_easy_setopt (c, CURLOPT_PORT, (long) global_port);
281 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 288 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
282 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 289 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
283 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 290 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
@@ -292,14 +299,14 @@ testMultithreadedGet (int poll_flag)
292 crashes on my system! */ 299 crashes on my system! */
293 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 300 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
294 if (CURLE_OK != (errornum = curl_easy_perform (c))) 301 if (CURLE_OK != (errornum = curl_easy_perform (c)))
295 { 302 {
296 fprintf (stderr, 303 fprintf (stderr,
297 "curl_easy_perform failed: `%s'\n", 304 "curl_easy_perform failed: `%s'\n",
298 curl_easy_strerror (errornum)); 305 curl_easy_strerror (errornum));
299 curl_easy_cleanup (c); 306 curl_easy_cleanup (c);
300 MHD_stop_daemon (d); 307 MHD_stop_daemon (d);
301 return 32; 308 return 32;
302 } 309 }
303 curl_easy_cleanup (c); 310 curl_easy_cleanup (c);
304 MHD_stop_daemon (d); 311 MHD_stop_daemon (d);
305 if (cbc.pos != strlen ("/hello_world")) 312 if (cbc.pos != strlen ("/hello_world"))
@@ -321,16 +328,17 @@ testMultithreadedPoolGet (int poll_flag)
321 328
322 if ( (0 == global_port) && 329 if ( (0 == global_port) &&
323 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) 330 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
324 { 331 {
325 global_port = 1222; 332 global_port = 1222;
326 if (oneone) 333 if (oneone)
327 global_port += 20; 334 global_port += 20;
328 } 335 }
329 336
330 cbc.buf = buf; 337 cbc.buf = buf;
331 cbc.size = 2048; 338 cbc.size = 2048;
332 cbc.pos = 0; 339 cbc.pos = 0;
333 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 340 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
341 | poll_flag,
334 global_port, NULL, NULL, 342 global_port, NULL, NULL,
335 &ahc_echo, "GET", 343 &ahc_echo, "GET",
336 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, 344 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT,
@@ -339,16 +347,18 @@ testMultithreadedPoolGet (int poll_flag)
339 if (d == NULL) 347 if (d == NULL)
340 return 16; 348 return 16;
341 if (0 == global_port) 349 if (0 == global_port)
350 {
351 const union MHD_DaemonInfo *dinfo;
352 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
353 if ((NULL == dinfo) ||(0 == dinfo->port) )
342 { 354 {
343 const union MHD_DaemonInfo *dinfo; 355 MHD_stop_daemon (d); return 32;
344 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
345 if (NULL == dinfo || 0 == dinfo->port)
346 { MHD_stop_daemon (d); return 32; }
347 global_port = (int)dinfo->port;
348 } 356 }
357 global_port = (int) dinfo->port;
358 }
349 c = curl_easy_init (); 359 c = curl_easy_init ();
350 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); 360 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH);
351 curl_easy_setopt (c, CURLOPT_PORT, (long)global_port); 361 curl_easy_setopt (c, CURLOPT_PORT, (long) global_port);
352 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 362 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
353 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 363 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
354 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 364 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
@@ -363,14 +373,14 @@ testMultithreadedPoolGet (int poll_flag)
363 crashes on my system!*/ 373 crashes on my system!*/
364 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 374 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
365 if (CURLE_OK != (errornum = curl_easy_perform (c))) 375 if (CURLE_OK != (errornum = curl_easy_perform (c)))
366 { 376 {
367 fprintf (stderr, 377 fprintf (stderr,
368 "curl_easy_perform failed: `%s'\n", 378 "curl_easy_perform failed: `%s'\n",
369 curl_easy_strerror (errornum)); 379 curl_easy_strerror (errornum));
370 curl_easy_cleanup (c); 380 curl_easy_cleanup (c);
371 MHD_stop_daemon (d); 381 MHD_stop_daemon (d);
372 return 32; 382 return 32;
373 } 383 }
374 curl_easy_cleanup (c); 384 curl_easy_cleanup (c);
375 MHD_stop_daemon (d); 385 MHD_stop_daemon (d);
376 if (cbc.pos != strlen ("/hello_world")) 386 if (cbc.pos != strlen ("/hello_world"))
@@ -394,7 +404,7 @@ testExternalGet ()
394 fd_set ws; 404 fd_set ws;
395 fd_set es; 405 fd_set es;
396 MHD_socket maxsock; 406 MHD_socket maxsock;
397 int maxposixs; 407 int maxposixs;
398 int running; 408 int running;
399 struct CURLMsg *msg; 409 struct CURLMsg *msg;
400 time_t start; 410 time_t start;
@@ -402,11 +412,11 @@ testExternalGet ()
402 412
403 if ( (0 == global_port) && 413 if ( (0 == global_port) &&
404 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) 414 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
405 { 415 {
406 global_port = 1223; 416 global_port = 1223;
407 if (oneone) 417 if (oneone)
408 global_port += 20; 418 global_port += 20;
409 } 419 }
410 420
411 multi = NULL; 421 multi = NULL;
412 cbc.buf = buf; 422 cbc.buf = buf;
@@ -420,16 +430,18 @@ testExternalGet ()
420 if (d == NULL) 430 if (d == NULL)
421 return 256; 431 return 256;
422 if (0 == global_port) 432 if (0 == global_port)
433 {
434 const union MHD_DaemonInfo *dinfo;
435 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
436 if ((NULL == dinfo) ||(0 == dinfo->port) )
423 { 437 {
424 const union MHD_DaemonInfo *dinfo; 438 MHD_stop_daemon (d); return 32;
425 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
426 if (NULL == dinfo || 0 == dinfo->port)
427 { MHD_stop_daemon (d); return 32; }
428 global_port = (int)dinfo->port;
429 } 439 }
440 global_port = (int) dinfo->port;
441 }
430 c = curl_easy_init (); 442 c = curl_easy_init ();
431 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); 443 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH);
432 curl_easy_setopt (c, CURLOPT_PORT, (long)global_port); 444 curl_easy_setopt (c, CURLOPT_PORT, (long) global_port);
433 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 445 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
434 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 446 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
435 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 447 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
@@ -447,90 +459,92 @@ testExternalGet ()
447 459
448 multi = curl_multi_init (); 460 multi = curl_multi_init ();
449 if (multi == NULL) 461 if (multi == NULL)
462 {
463 curl_easy_cleanup (c);
464 MHD_stop_daemon (d);
465 return 512;
466 }
467 mret = curl_multi_add_handle (multi, c);
468 if (mret != CURLM_OK)
469 {
470 curl_multi_cleanup (multi);
471 curl_easy_cleanup (c);
472 MHD_stop_daemon (d);
473 return 1024;
474 }
475 start = time (NULL);
476 while ((time (NULL) - start < 5) && (multi != NULL))
477 {
478 maxsock = MHD_INVALID_SOCKET;
479 maxposixs = -1;
480 FD_ZERO (&rs);
481 FD_ZERO (&ws);
482 FD_ZERO (&es);
483 curl_multi_perform (multi, &running);
484 mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs);
485 if (mret != CURLM_OK)
450 { 486 {
487 curl_multi_remove_handle (multi, c);
488 curl_multi_cleanup (multi);
451 curl_easy_cleanup (c); 489 curl_easy_cleanup (c);
452 MHD_stop_daemon (d); 490 MHD_stop_daemon (d);
453 return 512; 491 return 2048;
454 } 492 }
455 mret = curl_multi_add_handle (multi, c); 493 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock))
456 if (mret != CURLM_OK)
457 { 494 {
495 curl_multi_remove_handle (multi, c);
458 curl_multi_cleanup (multi); 496 curl_multi_cleanup (multi);
459 curl_easy_cleanup (c); 497 curl_easy_cleanup (c);
460 MHD_stop_daemon (d); 498 MHD_stop_daemon (d);
461 return 1024; 499 return 4096;
462 } 500 }
463 start = time (NULL); 501 tv.tv_sec = 0;
464 while ((time (NULL) - start < 5) && (multi != NULL)) 502 tv.tv_usec = 1000;
465 {
466 maxsock = MHD_INVALID_SOCKET;
467 maxposixs = -1;
468 FD_ZERO (&rs);
469 FD_ZERO (&ws);
470 FD_ZERO (&es);
471 curl_multi_perform (multi, &running);
472 mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs);
473 if (mret != CURLM_OK)
474 {
475 curl_multi_remove_handle (multi, c);
476 curl_multi_cleanup (multi);
477 curl_easy_cleanup (c);
478 MHD_stop_daemon (d);
479 return 2048;
480 }
481 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock))
482 {
483 curl_multi_remove_handle (multi, c);
484 curl_multi_cleanup (multi);
485 curl_easy_cleanup (c);
486 MHD_stop_daemon (d);
487 return 4096;
488 }
489 tv.tv_sec = 0;
490 tv.tv_usec = 1000;
491#ifdef MHD_POSIX_SOCKETS 503#ifdef MHD_POSIX_SOCKETS
492 if (maxsock > maxposixs) 504 if (maxsock > maxposixs)
493 maxposixs = maxsock; 505 maxposixs = maxsock;
494#endif /* MHD_POSIX_SOCKETS */ 506#endif /* MHD_POSIX_SOCKETS */
495 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) 507 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv))
496 { 508 {
497#ifdef MHD_POSIX_SOCKETS 509#ifdef MHD_POSIX_SOCKETS
498 if (EINTR != errno) 510 if (EINTR != errno)
499 abort (); 511 abort ();
500#else 512#else
501 if (WSAEINVAL != WSAGetLastError() || 0 != rs.fd_count || 0 != ws.fd_count || 0 != es.fd_count) 513 if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 !=
502 _exit (99); 514 ws.fd_count)
503 Sleep (1000); 515 ||(0 != es.fd_count) )
516 _exit (99);
517 Sleep (1000);
504#endif 518#endif
505 }
506 curl_multi_perform (multi, &running);
507 if (running == 0)
508 {
509 msg = curl_multi_info_read (multi, &running);
510 if (msg == NULL)
511 break;
512 if (msg->msg == CURLMSG_DONE)
513 {
514 if (msg->data.result != CURLE_OK)
515 printf ("%s failed at %s:%d: `%s'\n",
516 "curl_multi_perform",
517 __FILE__,
518 __LINE__, curl_easy_strerror (msg->data.result));
519 curl_multi_remove_handle (multi, c);
520 curl_multi_cleanup (multi);
521 curl_easy_cleanup (c);
522 c = NULL;
523 multi = NULL;
524 }
525 }
526 MHD_run (d);
527 } 519 }
528 if (multi != NULL) 520 curl_multi_perform (multi, &running);
521 if (running == 0)
529 { 522 {
530 curl_multi_remove_handle (multi, c); 523 msg = curl_multi_info_read (multi, &running);
531 curl_easy_cleanup (c); 524 if (msg == NULL)
532 curl_multi_cleanup (multi); 525 break;
526 if (msg->msg == CURLMSG_DONE)
527 {
528 if (msg->data.result != CURLE_OK)
529 printf ("%s failed at %s:%d: `%s'\n",
530 "curl_multi_perform",
531 __FILE__,
532 __LINE__, curl_easy_strerror (msg->data.result));
533 curl_multi_remove_handle (multi, c);
534 curl_multi_cleanup (multi);
535 curl_easy_cleanup (c);
536 c = NULL;
537 multi = NULL;
538 }
533 } 539 }
540 MHD_run (d);
541 }
542 if (multi != NULL)
543 {
544 curl_multi_remove_handle (multi, c);
545 curl_easy_cleanup (c);
546 curl_multi_cleanup (multi);
547 }
534 MHD_stop_daemon (d); 548 MHD_stop_daemon (d);
535 if (cbc.pos != strlen ("/hello_world")) 549 if (cbc.pos != strlen ("/hello_world"))
536 return 8192; 550 return 8192;
@@ -553,7 +567,7 @@ testUnknownPortGet (int poll_flag)
553 567
554 struct sockaddr_in addr; 568 struct sockaddr_in addr;
555 socklen_t addr_len = sizeof(addr); 569 socklen_t addr_len = sizeof(addr);
556 memset(&addr, 0, sizeof(addr)); 570 memset (&addr, 0, sizeof(addr));
557 addr.sin_family = AF_INET; 571 addr.sin_family = AF_INET;
558 addr.sin_port = 0; 572 addr.sin_port = 0;
559 addr.sin_addr.s_addr = INADDR_ANY; 573 addr.sin_addr.s_addr = INADDR_ANY;
@@ -561,38 +575,41 @@ testUnknownPortGet (int poll_flag)
561 cbc.buf = buf; 575 cbc.buf = buf;
562 cbc.size = 2048; 576 cbc.size = 2048;
563 cbc.pos = 0; 577 cbc.pos = 0;
564 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 578 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
579 | poll_flag,
565 0, NULL, NULL, &ahc_echo, "GET", 580 0, NULL, NULL, &ahc_echo, "GET",
566 MHD_OPTION_SOCK_ADDR, &addr, 581 MHD_OPTION_SOCK_ADDR, &addr,
567 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 582 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
568 MHD_OPTION_END); 583 MHD_OPTION_END);
569 if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 584 if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
570 { 585 {
571 di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); 586 di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD);
572 if (di == NULL) 587 if (di == NULL)
573 return 65536; 588 return 65536;
574 589
575 if (0 != getsockname(di->listen_fd, (struct sockaddr *) &addr, &addr_len)) 590 if (0 != getsockname (di->listen_fd, (struct sockaddr *) &addr, &addr_len))
576 return 131072; 591 return 131072;
577 592
578 if (addr.sin_family != AF_INET) 593 if (addr.sin_family != AF_INET)
579 return 26214; 594 return 26214;
580 port = (int)ntohs(addr.sin_port); 595 port = (int) ntohs (addr.sin_port);
581 } 596 }
582 else 597 else
598 {
599 const union MHD_DaemonInfo *dinfo;
600 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
601 if ((NULL == dinfo) ||(0 == dinfo->port) )
583 { 602 {
584 const union MHD_DaemonInfo *dinfo; 603 MHD_stop_daemon (d); return 32;
585 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
586 if (NULL == dinfo || 0 == dinfo->port)
587 { MHD_stop_daemon (d); return 32; }
588 port = (int)dinfo->port;
589 } 604 }
605 port = (int) dinfo->port;
606 }
590 607
591 snprintf(buf, 608 snprintf (buf,
592 sizeof(buf), 609 sizeof(buf),
593 "http://127.0.0.1:%d%s", 610 "http://127.0.0.1:%d%s",
594 port, 611 port,
595 EXPECTED_URI_PATH); 612 EXPECTED_URI_PATH);
596 613
597 c = curl_easy_init (); 614 c = curl_easy_init ();
598 curl_easy_setopt (c, CURLOPT_URL, buf); 615 curl_easy_setopt (c, CURLOPT_URL, buf);
@@ -610,14 +627,14 @@ testUnknownPortGet (int poll_flag)
610 crashes on my system! */ 627 crashes on my system! */
611 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 628 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
612 if (CURLE_OK != (errornum = curl_easy_perform (c))) 629 if (CURLE_OK != (errornum = curl_easy_perform (c)))
613 { 630 {
614 fprintf (stderr, 631 fprintf (stderr,
615 "curl_easy_perform failed: `%s'\n", 632 "curl_easy_perform failed: `%s'\n",
616 curl_easy_strerror (errornum)); 633 curl_easy_strerror (errornum));
617 curl_easy_cleanup (c); 634 curl_easy_cleanup (c);
618 MHD_stop_daemon (d); 635 MHD_stop_daemon (d);
619 return 524288; 636 return 524288;
620 } 637 }
621 curl_easy_cleanup (c); 638 curl_easy_cleanup (c);
622 MHD_stop_daemon (d); 639 MHD_stop_daemon (d);
623 if (cbc.pos != strlen ("/hello_world")) 640 if (cbc.pos != strlen ("/hello_world"))
@@ -631,115 +648,120 @@ testUnknownPortGet (int poll_flag)
631static int 648static int
632testStopRace (int poll_flag) 649testStopRace (int poll_flag)
633{ 650{
634 struct sockaddr_in sin; 651 struct sockaddr_in sin;
635 MHD_socket fd; 652 MHD_socket fd;
636 struct MHD_Daemon *d; 653 struct MHD_Daemon *d;
637
638 if ( (0 == global_port) &&
639 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
640 {
641 global_port = 1224;
642 if (oneone)
643 global_port += 20;
644 }
645
646 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag,
647 global_port, NULL, NULL,
648 &ahc_echo, "GET",
649 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
650 MHD_OPTION_END);
651 if (d == NULL)
652 return 16;
653 if (0 == global_port)
654 {
655 const union MHD_DaemonInfo *dinfo;
656 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
657 if (NULL == dinfo || 0 == dinfo->port)
658 { MHD_stop_daemon (d); return 32; }
659 global_port = (int)dinfo->port;
660 }
661 654
662 fd = socket (PF_INET, SOCK_STREAM, 0); 655 if ( (0 == global_port) &&
663 if (fd == MHD_INVALID_SOCKET) 656 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
657 {
658 global_port = 1224;
659 if (oneone)
660 global_port += 20;
661 }
662
663 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
664 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
665 | poll_flag,
666 global_port, NULL, NULL,
667 &ahc_echo, "GET",
668 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
669 MHD_OPTION_END);
670 if (d == NULL)
671 return 16;
672 if (0 == global_port)
673 {
674 const union MHD_DaemonInfo *dinfo;
675 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
676 if ((NULL == dinfo) ||(0 == dinfo->port) )
664 { 677 {
665 fprintf(stderr, "socket error\n"); 678 MHD_stop_daemon (d); return 32;
666 return 256;
667 } 679 }
680 global_port = (int) dinfo->port;
681 }
668 682
669 memset(&sin, 0, sizeof(sin)); 683 fd = socket (PF_INET, SOCK_STREAM, 0);
670 sin.sin_family = AF_INET; 684 if (fd == MHD_INVALID_SOCKET)
671 sin.sin_port = htons(global_port); 685 {
672 sin.sin_addr.s_addr = htonl(0x7f000001); 686 fprintf (stderr, "socket error\n");
687 return 256;
688 }
673 689
674 if (connect (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0) 690 memset (&sin, 0, sizeof(sin));
675 { 691 sin.sin_family = AF_INET;
676 fprintf(stderr, "connect error\n"); 692 sin.sin_port = htons (global_port);
677 MHD_socket_close_chk_ (fd); 693 sin.sin_addr.s_addr = htonl (0x7f000001);
678 return 512;
679 }
680 694
681 /* printf("Waiting\n"); */ 695 if (connect (fd, (struct sockaddr *) (&sin), sizeof(sin)) < 0)
682 /* Let the thread get going. */ 696 {
683 usleep(500000); 697 fprintf (stderr, "connect error\n");
698 MHD_socket_close_chk_ (fd);
699 return 512;
700 }
684 701
685 /* printf("Stopping daemon\n"); */ 702 /* printf("Waiting\n"); */
686 MHD_stop_daemon (d); 703 /* Let the thread get going. */
704 usleep (500000);
687 705
688 MHD_socket_close_chk_ (fd); 706 /* printf("Stopping daemon\n"); */
707 MHD_stop_daemon (d);
708
709 MHD_socket_close_chk_ (fd);
689 710
690 /* printf("good\n"); */ 711 /* printf("good\n"); */
691 return 0; 712 return 0;
692} 713}
693 714
694 715
695static int 716static int
696ahc_empty (void *cls, 717ahc_empty (void *cls,
697 struct MHD_Connection *connection, 718 struct MHD_Connection *connection,
698 const char *url, 719 const char *url,
699 const char *method, 720 const char *method,
700 const char *version, 721 const char *version,
701 const char *upload_data, size_t *upload_data_size, 722 const char *upload_data, size_t *upload_data_size,
702 void **unused) 723 void **unused)
703{ 724{
704 static int ptr; 725 static int ptr;
705 struct MHD_Response *response; 726 struct MHD_Response *response;
706 int ret; 727 int ret;
707 (void)cls;(void)url;(void)url;(void)version; /* Unused. Silent compiler warning. */ 728 (void) cls; (void) url; (void) url; (void) version; /* Unused. Silent compiler warning. */
708 (void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ 729 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
709 730
710 if (0 != strcasecmp ("GET", method)) 731 if (0 != strcasecmp ("GET", method))
711 return MHD_NO; /* unexpected method */ 732 return MHD_NO; /* unexpected method */
712 if (&ptr != *unused) 733 if (&ptr != *unused)
713 { 734 {
714 *unused = &ptr; 735 *unused = &ptr;
715 return MHD_YES; 736 return MHD_YES;
716 } 737 }
717 *unused = NULL; 738 *unused = NULL;
718 response = MHD_create_response_from_buffer (0, 739 response = MHD_create_response_from_buffer (0,
719 NULL, 740 NULL,
720 MHD_RESPMEM_PERSISTENT); 741 MHD_RESPMEM_PERSISTENT);
721 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 742 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
722 MHD_destroy_response (response); 743 MHD_destroy_response (response);
723 if (ret == MHD_NO) 744 if (ret == MHD_NO)
724 { 745 {
725 fprintf (stderr, "Failed to queue response.\n"); 746 fprintf (stderr, "Failed to queue response.\n");
726 _exit (20); 747 _exit (20);
727 } 748 }
728 return ret; 749 return ret;
729} 750}
730 751
731 752
732static int 753static int
733curlExcessFound(CURL *c, curl_infotype type, char *data, size_t size, void *cls) 754curlExcessFound (CURL *c, curl_infotype type, char *data, size_t size,
755 void *cls)
734{ 756{
735 static const char *excess_found = "Excess found"; 757 static const char *excess_found = "Excess found";
736 const size_t str_size = strlen (excess_found); 758 const size_t str_size = strlen (excess_found);
737 (void)c; /* Unused. Silent compiler warning. */ 759 (void) c; /* Unused. Silent compiler warning. */
738 760
739 if (CURLINFO_TEXT == type 761 if ((CURLINFO_TEXT == type)
740 && size >= str_size 762 &&(size >= str_size)
741 && 0 == strncmp(excess_found, data, str_size)) 763 &&(0 == strncmp (excess_found, data, str_size)))
742 *(int *)cls = 1; 764 *(int *) cls = 1;
743 return 0; 765 return 0;
744} 766}
745 767
@@ -756,16 +778,17 @@ testEmptyGet (int poll_flag)
756 778
757 if ( (0 == global_port) && 779 if ( (0 == global_port) &&
758 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) 780 (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) )
759 { 781 {
760 global_port = 1225; 782 global_port = 1225;
761 if (oneone) 783 if (oneone)
762 global_port += 20; 784 global_port += 20;
763 } 785 }
764 786
765 cbc.buf = buf; 787 cbc.buf = buf;
766 cbc.size = 2048; 788 cbc.size = 2048;
767 cbc.pos = 0; 789 cbc.pos = 0;
768 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 790 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
791 | poll_flag,
769 global_port, NULL, NULL, 792 global_port, NULL, NULL,
770 &ahc_empty, NULL, 793 &ahc_empty, NULL,
771 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 794 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -773,16 +796,18 @@ testEmptyGet (int poll_flag)
773 if (d == NULL) 796 if (d == NULL)
774 return 4194304; 797 return 4194304;
775 if (0 == global_port) 798 if (0 == global_port)
799 {
800 const union MHD_DaemonInfo *dinfo;
801 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
802 if ((NULL == dinfo) ||(0 == dinfo->port) )
776 { 803 {
777 const union MHD_DaemonInfo *dinfo; 804 MHD_stop_daemon (d); return 32;
778 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
779 if (NULL == dinfo || 0 == dinfo->port)
780 { MHD_stop_daemon (d); return 32; }
781 global_port = (int)dinfo->port;
782 } 805 }
806 global_port = (int) dinfo->port;
807 }
783 c = curl_easy_init (); 808 c = curl_easy_init ();
784 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); 809 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH);
785 curl_easy_setopt (c, CURLOPT_PORT, (long)global_port); 810 curl_easy_setopt (c, CURLOPT_PORT, (long) global_port);
786 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 811 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
787 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 812 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
788 curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound); 813 curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound);
@@ -800,14 +825,14 @@ testEmptyGet (int poll_flag)
800 crashes on my system!*/ 825 crashes on my system!*/
801 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 826 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
802 if (CURLE_OK != (errornum = curl_easy_perform (c))) 827 if (CURLE_OK != (errornum = curl_easy_perform (c)))
803 { 828 {
804 fprintf (stderr, 829 fprintf (stderr,
805 "curl_easy_perform failed: `%s'\n", 830 "curl_easy_perform failed: `%s'\n",
806 curl_easy_strerror (errornum)); 831 curl_easy_strerror (errornum));
807 curl_easy_cleanup (c); 832 curl_easy_cleanup (c);
808 MHD_stop_daemon (d); 833 MHD_stop_daemon (d);
809 return 8388608; 834 return 8388608;
810 } 835 }
811 curl_easy_cleanup (c); 836 curl_easy_cleanup (c);
812 MHD_stop_daemon (d); 837 MHD_stop_daemon (d);
813 if (cbc.pos != 0) 838 if (cbc.pos != 0)
@@ -825,7 +850,7 @@ main (int argc, char *const *argv)
825 unsigned int test_result = 0; 850 unsigned int test_result = 0;
826 int verbose = 0; 851 int verbose = 0;
827 852
828 if (NULL == argv || 0 == argv[0]) 853 if ((NULL == argv)||(0 == argv[0]))
829 return 99; 854 return 99;
830 oneone = has_in_name (argv[0], "11"); 855 oneone = has_in_name (argv[0], "11");
831 verbose = has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose"); 856 verbose = has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose");
@@ -838,115 +863,128 @@ main (int argc, char *const *argv)
838 else if (verbose) 863 else if (verbose)
839 printf ("PASSED: testExternalGet ().\n"); 864 printf ("PASSED: testExternalGet ().\n");
840 errorCount += test_result; 865 errorCount += test_result;
841 if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) 866 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS))
842 { 867 {
843 test_result += testInternalGet (0); 868 test_result += testInternalGet (0);
869 if (test_result)
870 fprintf (stderr, "FAILED: testInternalGet (0) - %u.\n", test_result);
871 else if (verbose)
872 printf ("PASSED: testInternalGet (0).\n");
873 errorCount += test_result;
874 test_result += testMultithreadedGet (0);
875 if (test_result)
876 fprintf (stderr, "FAILED: testMultithreadedGet (0) - %u.\n", test_result);
877 else if (verbose)
878 printf ("PASSED: testMultithreadedGet (0).\n");
879 errorCount += test_result;
880 test_result += testMultithreadedPoolGet (0);
881 if (test_result)
882 fprintf (stderr, "FAILED: testMultithreadedPoolGet (0) - %u.\n",
883 test_result);
884 else if (verbose)
885 printf ("PASSED: testMultithreadedPoolGet (0).\n");
886 errorCount += test_result;
887 test_result += testUnknownPortGet (0);
888 if (test_result)
889 fprintf (stderr, "FAILED: testUnknownPortGet (0) - %u.\n", test_result);
890 else if (verbose)
891 printf ("PASSED: testUnknownPortGet (0).\n");
892 errorCount += test_result;
893 test_result += testStopRace (0);
894 if (test_result)
895 fprintf (stderr, "FAILED: testStopRace (0) - %u.\n", test_result);
896 else if (verbose)
897 printf ("PASSED: testStopRace (0).\n");
898 errorCount += test_result;
899 test_result += testEmptyGet (0);
900 if (test_result)
901 fprintf (stderr, "FAILED: testEmptyGet (0) - %u.\n", test_result);
902 else if (verbose)
903 printf ("PASSED: testEmptyGet (0).\n");
904 errorCount += test_result;
905 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL))
906 {
907 test_result += testInternalGet (MHD_USE_POLL);
908 if (test_result)
909 fprintf (stderr, "FAILED: testInternalGet (MHD_USE_POLL) - %u.\n",
910 test_result);
911 else if (verbose)
912 printf ("PASSED: testInternalGet (MHD_USE_POLL).\n");
913 errorCount += test_result;
914 test_result += testMultithreadedGet (MHD_USE_POLL);
915 if (test_result)
916 fprintf (stderr, "FAILED: testMultithreadedGet (MHD_USE_POLL) - %u.\n",
917 test_result);
918 else if (verbose)
919 printf ("PASSED: testMultithreadedGet (MHD_USE_POLL).\n");
920 errorCount += test_result;
921 test_result += testMultithreadedPoolGet (MHD_USE_POLL);
844 if (test_result) 922 if (test_result)
845 fprintf (stderr, "FAILED: testInternalGet (0) - %u.\n", test_result); 923 fprintf (stderr,
924 "FAILED: testMultithreadedPoolGet (MHD_USE_POLL) - %u.\n",
925 test_result);
846 else if (verbose) 926 else if (verbose)
847 printf ("PASSED: testInternalGet (0).\n"); 927 printf ("PASSED: testMultithreadedPoolGet (MHD_USE_POLL).\n");
848 errorCount += test_result; 928 errorCount += test_result;
849 test_result += testMultithreadedGet (0); 929 test_result += testUnknownPortGet (MHD_USE_POLL);
850 if (test_result) 930 if (test_result)
851 fprintf (stderr, "FAILED: testMultithreadedGet (0) - %u.\n", test_result); 931 fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_POLL) - %u.\n",
932 test_result);
852 else if (verbose) 933 else if (verbose)
853 printf ("PASSED: testMultithreadedGet (0).\n"); 934 printf ("PASSED: testUnknownPortGet (MHD_USE_POLL).\n");
854 errorCount += test_result; 935 errorCount += test_result;
855 test_result += testMultithreadedPoolGet (0); 936 test_result += testStopRace (MHD_USE_POLL);
937 if (test_result)
938 fprintf (stderr, "FAILED: testStopRace (MHD_USE_POLL) - %u.\n",
939 test_result);
940 else if (verbose)
941 printf ("PASSED: testStopRace (MHD_USE_POLL).\n");
942 errorCount += test_result;
943 test_result += testEmptyGet (MHD_USE_POLL);
944 if (test_result)
945 fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_POLL) - %u.\n",
946 test_result);
947 else if (verbose)
948 printf ("PASSED: testEmptyGet (MHD_USE_POLL).\n");
949 errorCount += test_result;
950 }
951 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL))
952 {
953 test_result += testInternalGet (MHD_USE_EPOLL);
856 if (test_result) 954 if (test_result)
857 fprintf (stderr, "FAILED: testMultithreadedPoolGet (0) - %u.\n", test_result); 955 fprintf (stderr, "FAILED: testInternalGet (MHD_USE_EPOLL) - %u.\n",
956 test_result);
858 else if (verbose) 957 else if (verbose)
859 printf ("PASSED: testMultithreadedPoolGet (0).\n"); 958 printf ("PASSED: testInternalGet (MHD_USE_EPOLL).\n");
860 errorCount += test_result; 959 errorCount += test_result;
861 test_result += testUnknownPortGet (0); 960 test_result += testMultithreadedPoolGet (MHD_USE_EPOLL);
862 if (test_result) 961 if (test_result)
863 fprintf (stderr, "FAILED: testUnknownPortGet (0) - %u.\n", test_result); 962 fprintf (stderr,
963 "FAILED: testMultithreadedPoolGet (MHD_USE_EPOLL) - %u.\n",
964 test_result);
864 else if (verbose) 965 else if (verbose)
865 printf ("PASSED: testUnknownPortGet (0).\n"); 966 printf ("PASSED: testMultithreadedPoolGet (MHD_USE_EPOLL).\n");
866 errorCount += test_result; 967 errorCount += test_result;
867 test_result += testStopRace (0); 968 test_result += testUnknownPortGet (MHD_USE_EPOLL);
868 if (test_result) 969 if (test_result)
869 fprintf (stderr, "FAILED: testStopRace (0) - %u.\n", test_result); 970 fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_EPOLL) - %u.\n",
971 test_result);
870 else if (verbose) 972 else if (verbose)
871 printf ("PASSED: testStopRace (0).\n"); 973 printf ("PASSED: testUnknownPortGet (MHD_USE_EPOLL).\n");
872 errorCount += test_result; 974 errorCount += test_result;
873 test_result += testEmptyGet (0); 975 test_result += testEmptyGet (MHD_USE_EPOLL);
874 if (test_result) 976 if (test_result)
875 fprintf (stderr, "FAILED: testEmptyGet (0) - %u.\n", test_result); 977 fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_EPOLL) - %u.\n",
978 test_result);
876 else if (verbose) 979 else if (verbose)
877 printf ("PASSED: testEmptyGet (0).\n"); 980 printf ("PASSED: testEmptyGet (MHD_USE_EPOLL).\n");
878 errorCount += test_result; 981 errorCount += test_result;
879 if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
880 {
881 test_result += testInternalGet(MHD_USE_POLL);
882 if (test_result)
883 fprintf (stderr, "FAILED: testInternalGet (MHD_USE_POLL) - %u.\n", test_result);
884 else if (verbose)
885 printf ("PASSED: testInternalGet (MHD_USE_POLL).\n");
886 errorCount += test_result;
887 test_result += testMultithreadedGet(MHD_USE_POLL);
888 if (test_result)
889 fprintf (stderr, "FAILED: testMultithreadedGet (MHD_USE_POLL) - %u.\n", test_result);
890 else if (verbose)
891 printf ("PASSED: testMultithreadedGet (MHD_USE_POLL).\n");
892 errorCount += test_result;
893 test_result += testMultithreadedPoolGet(MHD_USE_POLL);
894 if (test_result)
895 fprintf (stderr, "FAILED: testMultithreadedPoolGet (MHD_USE_POLL) - %u.\n", test_result);
896 else if (verbose)
897 printf ("PASSED: testMultithreadedPoolGet (MHD_USE_POLL).\n");
898 errorCount += test_result;
899 test_result += testUnknownPortGet(MHD_USE_POLL);
900 if (test_result)
901 fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_POLL) - %u.\n", test_result);
902 else if (verbose)
903 printf ("PASSED: testUnknownPortGet (MHD_USE_POLL).\n");
904 errorCount += test_result;
905 test_result += testStopRace(MHD_USE_POLL);
906 if (test_result)
907 fprintf (stderr, "FAILED: testStopRace (MHD_USE_POLL) - %u.\n", test_result);
908 else if (verbose)
909 printf ("PASSED: testStopRace (MHD_USE_POLL).\n");
910 errorCount += test_result;
911 test_result += testEmptyGet(MHD_USE_POLL);
912 if (test_result)
913 fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_POLL) - %u.\n", test_result);
914 else if (verbose)
915 printf ("PASSED: testEmptyGet (MHD_USE_POLL).\n");
916 errorCount += test_result;
917 }
918 if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
919 {
920 test_result += testInternalGet(MHD_USE_EPOLL);
921 if (test_result)
922 fprintf (stderr, "FAILED: testInternalGet (MHD_USE_EPOLL) - %u.\n", test_result);
923 else if (verbose)
924 printf ("PASSED: testInternalGet (MHD_USE_EPOLL).\n");
925 errorCount += test_result;
926 test_result += testMultithreadedPoolGet(MHD_USE_EPOLL);
927 if (test_result)
928 fprintf (stderr, "FAILED: testMultithreadedPoolGet (MHD_USE_EPOLL) - %u.\n", test_result);
929 else if (verbose)
930 printf ("PASSED: testMultithreadedPoolGet (MHD_USE_EPOLL).\n");
931 errorCount += test_result;
932 test_result += testUnknownPortGet(MHD_USE_EPOLL);
933 if (test_result)
934 fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_EPOLL) - %u.\n", test_result);
935 else if (verbose)
936 printf ("PASSED: testUnknownPortGet (MHD_USE_EPOLL).\n");
937 errorCount += test_result;
938 test_result += testEmptyGet(MHD_USE_EPOLL);
939 if (test_result)
940 fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_EPOLL) - %u.\n", test_result);
941 else if (verbose)
942 printf ("PASSED: testEmptyGet (MHD_USE_EPOLL).\n");
943 errorCount += test_result;
944 }
945 } 982 }
983 }
946 if (0 != errorCount) 984 if (0 != errorCount)
947 fprintf (stderr, 985 fprintf (stderr,
948 "Error (code: %u)\n", 986 "Error (code: %u)\n",
949 errorCount); 987 errorCount);
950 else if (verbose) 988 else if (verbose)
951 printf ("All tests passed.\n"); 989 printf ("All tests passed.\n");
952 curl_global_cleanup (); 990 curl_global_cleanup ();