diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-06-16 00:41:21 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-06-16 00:42:44 +0300 |
commit | e8d937beb5e0bf118c381846f2392cab973a2528 (patch) | |
tree | a7bec6dece0675986811e967d7e9756cc19e415a /src/testcurl/test_put.c | |
parent | 36bf651023e2f810bd2ae4aa1ab2354338b9f00c (diff) | |
download | libmicrohttpd-e8d937beb5e0bf118c381846f2392cab973a2528.tar.gz libmicrohttpd-e8d937beb5e0bf118c381846f2392cab973a2528.zip |
Make testsuite parallel build compatible (part 1)
Diffstat (limited to 'src/testcurl/test_put.c')
-rw-r--r-- | src/testcurl/test_put.c | 94 |
1 files changed, 85 insertions, 9 deletions
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c index 54725374..f448c408 100644 --- a/src/testcurl/test_put.c +++ b/src/testcurl/test_put.c | |||
@@ -127,17 +127,36 @@ testInternalPut () | |||
127 | unsigned int pos = 0; | 127 | unsigned int pos = 0; |
128 | int done_flag = 0; | 128 | int done_flag = 0; |
129 | CURLcode errornum; | 129 | CURLcode errornum; |
130 | int port; | ||
131 | |||
132 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
133 | port = 0; | ||
134 | else | ||
135 | { | ||
136 | port = 1450; | ||
137 | if (oneone) | ||
138 | port += 10; | ||
139 | } | ||
130 | 140 | ||
131 | cbc.buf = buf; | 141 | cbc.buf = buf; |
132 | cbc.size = 2048; | 142 | cbc.size = 2048; |
133 | cbc.pos = 0; | 143 | cbc.pos = 0; |
134 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 144 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
135 | 1080, | 145 | port, |
136 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 146 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
137 | if (d == NULL) | 147 | if (d == NULL) |
138 | return 1; | 148 | return 1; |
149 | if (0 == port) | ||
150 | { | ||
151 | const union MHD_DaemonInfo *dinfo; | ||
152 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
153 | if (NULL == dinfo || 0 == dinfo->port) | ||
154 | { MHD_stop_daemon (d); return 32; } | ||
155 | port = (int)dinfo->port; | ||
156 | } | ||
139 | c = curl_easy_init (); | 157 | c = curl_easy_init (); |
140 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); | 158 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
159 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
141 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 160 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
142 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 161 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
143 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 162 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -183,17 +202,36 @@ testMultithreadedPut () | |||
183 | unsigned int pos = 0; | 202 | unsigned int pos = 0; |
184 | int done_flag = 0; | 203 | int done_flag = 0; |
185 | CURLcode errornum; | 204 | CURLcode errornum; |
205 | int port; | ||
206 | |||
207 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
208 | port = 0; | ||
209 | else | ||
210 | { | ||
211 | port = 1451; | ||
212 | if (oneone) | ||
213 | port += 10; | ||
214 | } | ||
186 | 215 | ||
187 | cbc.buf = buf; | 216 | cbc.buf = buf; |
188 | cbc.size = 2048; | 217 | cbc.size = 2048; |
189 | cbc.pos = 0; | 218 | cbc.pos = 0; |
190 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 219 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
191 | 1081, | 220 | port, |
192 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 221 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
193 | if (d == NULL) | 222 | if (d == NULL) |
194 | return 16; | 223 | return 16; |
224 | if (0 == port) | ||
225 | { | ||
226 | const union MHD_DaemonInfo *dinfo; | ||
227 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
228 | if (NULL == dinfo || 0 == dinfo->port) | ||
229 | { MHD_stop_daemon (d); return 32; } | ||
230 | port = (int)dinfo->port; | ||
231 | } | ||
195 | c = curl_easy_init (); | 232 | c = curl_easy_init (); |
196 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); | 233 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
234 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
197 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 235 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
198 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 236 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
199 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 237 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -240,18 +278,37 @@ testMultithreadedPoolPut () | |||
240 | unsigned int pos = 0; | 278 | unsigned int pos = 0; |
241 | int done_flag = 0; | 279 | int done_flag = 0; |
242 | CURLcode errornum; | 280 | CURLcode errornum; |
281 | int port; | ||
282 | |||
283 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
284 | port = 0; | ||
285 | else | ||
286 | { | ||
287 | port = 1452; | ||
288 | if (oneone) | ||
289 | port += 10; | ||
290 | } | ||
243 | 291 | ||
244 | cbc.buf = buf; | 292 | cbc.buf = buf; |
245 | cbc.size = 2048; | 293 | cbc.size = 2048; |
246 | cbc.pos = 0; | 294 | cbc.pos = 0; |
247 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 295 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
248 | 1081, | 296 | port, |
249 | NULL, NULL, &ahc_echo, &done_flag, | 297 | NULL, NULL, &ahc_echo, &done_flag, |
250 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); | 298 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
251 | if (d == NULL) | 299 | if (d == NULL) |
252 | return 16; | 300 | return 16; |
301 | if (0 == port) | ||
302 | { | ||
303 | const union MHD_DaemonInfo *dinfo; | ||
304 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
305 | if (NULL == dinfo || 0 == dinfo->port) | ||
306 | { MHD_stop_daemon (d); return 32; } | ||
307 | port = (int)dinfo->port; | ||
308 | } | ||
253 | c = curl_easy_init (); | 309 | c = curl_easy_init (); |
254 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); | 310 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
311 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
255 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 312 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
256 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 313 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
257 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 314 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -313,19 +370,38 @@ testExternalPut () | |||
313 | struct timeval tv; | 370 | struct timeval tv; |
314 | unsigned int pos = 0; | 371 | unsigned int pos = 0; |
315 | int done_flag = 0; | 372 | int done_flag = 0; |
373 | int port; | ||
374 | |||
375 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
376 | port = 0; | ||
377 | else | ||
378 | { | ||
379 | port = 1453; | ||
380 | if (oneone) | ||
381 | port += 10; | ||
382 | } | ||
316 | 383 | ||
317 | multi = NULL; | 384 | multi = NULL; |
318 | cbc.buf = buf; | 385 | cbc.buf = buf; |
319 | cbc.size = 2048; | 386 | cbc.size = 2048; |
320 | cbc.pos = 0; | 387 | cbc.pos = 0; |
321 | d = MHD_start_daemon (MHD_USE_ERROR_LOG, | 388 | d = MHD_start_daemon (MHD_USE_ERROR_LOG, |
322 | 1082, | 389 | port, |
323 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 390 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
324 | if (d == NULL) | 391 | if (d == NULL) |
325 | return 256; | 392 | return 256; |
393 | if (0 == port) | ||
394 | { | ||
395 | const union MHD_DaemonInfo *dinfo; | ||
396 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
397 | if (NULL == dinfo || 0 == dinfo->port) | ||
398 | { MHD_stop_daemon (d); return 32; } | ||
399 | port = (int)dinfo->port; | ||
400 | } | ||
326 | c = curl_easy_init (); | 401 | c = curl_easy_init (); |
327 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1082/hello_world"); | 402 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
328 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 403 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); |
404 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
329 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 405 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
330 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 406 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
331 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | 407 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); |