libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 3a7f7a97ebb9894c31edb7c7f635784256fead73
parent 14e903bac93d80f48c0df252d0389c84bad77460
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 24 Nov 2016 11:37:55 +0300

test_quiesce_stream: use curl binary, port to W32,
use tests with fork() only when fork() is available (already checked by configure)

Diffstat:
Mconfigure.ac | 3+++
Msrc/testcurl/Makefile.am | 18++++++++++--------
Msrc/testcurl/test_quiesce_stream.c | 20++++++++++++--------
3 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -1302,6 +1302,7 @@ AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]], # Check for fork() and waitpid(). They are used for tests. AC_MSG_CHECKING([[for fork()]]) +mhd_have_fork_waitpid='no' AC_LINK_IFELSE( [ AC_LANG_PROGRAM( @@ -1336,6 +1337,7 @@ AC_LINK_IFELSE( ], [ AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.]) AC_MSG_RESULT([[yes]]) + mhd_have_fork_waitpid='yes' ],[ AC_MSG_RESULT([[no]]) ]) @@ -1343,6 +1345,7 @@ AC_LINK_IFELSE( AC_MSG_RESULT([[no]]) ]) +AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"]) MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined" diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am @@ -16,12 +16,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ $(LIBCURL_CPPFLAGS) -if !HAVE_W32 -if HAVE_CURL_BINARY -CURL_FORK_TEST = test_get_response_cleanup -endif -endif - if HAVE_CURL check_PROGRAMS = \ test_start_stop \ @@ -46,15 +40,23 @@ check_PROGRAMS = \ test_termination \ test_timeout \ test_callback \ - $(CURL_FORK_TEST) \ perf_get +if HAVE_FORK_WAITPID +if HAVE_CURL_BINARY +check_PROGRAMS += test_get_response_cleanup +endif +endif + if HAVE_POSIX_THREADS check_PROGRAMS += \ test_quiesce \ - test_quiesce_stream \ test_concurrent_stop \ perf_get_concurrent + +if HAVE_CURL_BINARY +check_PROGRAMS += test_quiesce_stream +endif endif if HAVE_POSTPROCESSOR diff --git a/src/testcurl/test_quiesce_stream.c b/src/testcurl/test_quiesce_stream.c @@ -23,15 +23,19 @@ * @author Markus Doppelbauer * @author Christian Grothoff */ +#include "mhd_options.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <fcntl.h> #include <pthread.h> #include <microhttpd.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#elif defined(_WIN32) +#include <windows.h> +#define sleep(s) (Sleep((s)*1000), 0) +#endif /* _WIN32 */ static volatile unsigned int request_counter; @@ -171,7 +175,7 @@ main() /* Flags */ unsigned int daemon_flags = MHD_USE_INTERNAL_POLLING_THREAD - | MHD_USE_EPOLL + | MHD_USE_AUTO | MHD_ALLOW_SUSPEND_RESUME | MHD_USE_ITC; @@ -184,11 +188,11 @@ main() NULL, MHD_OPTION_END); if (NULL == daemon) - return EXIT_FAILURE; - if (0 != system ("wget --server-response -q -O - 127.0.0.1:8000")) + return 1; + if (0 != system ("curl -s http://127.0.0.1:8000")) { MHD_stop_daemon (daemon); - return 77; /* skipped */ + return 1; } /* wait for a request */ while (0 == request_counter) @@ -205,5 +209,5 @@ main() "stopping daemon\n"); MHD_stop_daemon (daemon); - return EXIT_SUCCESS; + return 0; }