aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-04-12 20:46:26 +0000
committerChristian Grothoff <christian@grothoff.org>2008-04-12 20:46:26 +0000
commitd44981481087d7abbbebdd98c12cb8675d171981 (patch)
treed874670ce5d57e242524a4f74fcf48ee20c18852
parent5e9c5b7621d550d92f5565622ad0bf147d4d8a3f (diff)
downloadlibmicrohttpd-d44981481087d7abbbebdd98c12cb8675d171981.tar.gz
libmicrohttpd-d44981481087d7abbbebdd98c12cb8675d171981.zip
noncurl
-rw-r--r--src/daemon/daemontest.c (renamed from src/testcurl/daemontest.c)0
-rw-r--r--src/testzzuf/daemontest.c163
2 files changed, 0 insertions, 163 deletions
diff --git a/src/testcurl/daemontest.c b/src/daemon/daemontest.c
index 8048b438..8048b438 100644
--- a/src/testcurl/daemontest.c
+++ b/src/daemon/daemontest.c
diff --git a/src/testzzuf/daemontest.c b/src/testzzuf/daemontest.c
deleted file mode 100644
index 8048b438..00000000
--- a/src/testzzuf/daemontest.c
+++ /dev/null
@@ -1,163 +0,0 @@
1/*
2 This file is part of libmicrohttpd
3 (C) 2007 Christian Grothoff
4
5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 libmicrohttpd is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with libmicrohttpd; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file daemontest.c
23 * @brief Testcase for libmicrohttpd starts and stops
24 * @author Christian Grothoff
25 */
26
27#include "config.h"
28#include "microhttpd.h"
29#include <stdlib.h>
30#include <string.h>
31#include <stdio.h>
32
33#ifndef WINDOWS
34#include <unistd.h>
35#endif
36
37
38static int
39testStartError ()
40{
41 struct MHD_Daemon *d;
42
43 d = MHD_start_daemon (MHD_USE_DEBUG, 0, NULL, NULL, NULL, NULL);
44 if (d != NULL)
45 return 1;
46 return 0;
47}
48
49static int
50apc_nothing (void *cls, const struct sockaddr *addr, socklen_t addrlen)
51{
52 return MHD_NO;
53}
54
55static int
56apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen)
57{
58 return MHD_YES;
59}
60
61static int
62ahc_nothing (void *cls,
63 struct MHD_Connection *connection,
64 const char *url,
65 const char *method,
66 const char *version,
67 const char *upload_data, unsigned int *upload_data_size,
68 void **unused)
69{
70 return MHD_NO;
71}
72
73static int
74testStartStop ()
75{
76 struct MHD_Daemon *d;
77
78 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
79 1080,
80 &apc_nothing,
81 NULL, &ahc_nothing, NULL, MHD_OPTION_END);
82 if (d == NULL)
83 return 2;
84 MHD_stop_daemon (d);
85 return 0;
86}
87
88static int
89testExternalRun ()
90{
91 struct MHD_Daemon *d;
92 fd_set rs;
93 int maxfd;
94 int i;
95
96 d = MHD_start_daemon (MHD_USE_DEBUG,
97 1081,
98 &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END);
99
100 if (d == NULL)
101 return 4;
102 i = 0;
103 while (i < 15)
104 {
105 maxfd = 0;
106 FD_ZERO (&rs);
107 MHD_get_fdset (d, &rs, &rs, &rs, &maxfd);
108 if (MHD_run (d) == MHD_NO)
109 {
110 MHD_stop_daemon (d);
111 return 8;
112 }
113 i++;
114 }
115 MHD_stop_daemon (d);
116 return 0;
117}
118
119static int
120testThread ()
121{
122 struct MHD_Daemon *d;
123 d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SELECT_INTERNALLY,
124 1082,
125 &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END);
126
127 if (d == NULL)
128 return 16;
129 if (MHD_run (d) != MHD_NO)
130 return 32;
131 MHD_stop_daemon (d);
132 return 0;
133}
134
135static int
136testMultithread ()
137{
138 struct MHD_Daemon *d;
139 d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_THREAD_PER_CONNECTION,
140 1083,
141 &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END);
142
143 if (d == NULL)
144 return 64;
145 if (MHD_run (d) != MHD_NO)
146 return 128;
147 MHD_stop_daemon (d);
148 return 0;
149}
150
151int
152main (int argc, char *const *argv)
153{
154 unsigned int errorCount = 0;
155 errorCount += testStartError ();
156 errorCount += testStartStop ();
157 errorCount += testExternalRun ();
158 errorCount += testThread ();
159 errorCount += testMultithread ();
160 if (errorCount != 0)
161 fprintf (stderr, "Error (code: %u)\n", errorCount);
162 return errorCount != 0; /* 0 == pass */
163}