2011-03-10 05:48:02 -05:00
|
|
|
/***************************************************************************
|
2009-05-11 07:43:55 -04:00
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2013-07-22 15:07:06 -04:00
|
|
|
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2011-03-10 05:48:02 -05:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
|
|
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2009-05-11 07:43:55 -04:00
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "testutil.h"
|
2013-01-03 20:50:28 -05:00
|
|
|
#include "warnless.h"
|
|
|
|
#include "memdebug.h"
|
2009-05-11 07:43:55 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
#define TEST_HANG_TIMEOUT 60 * 1000
|
2009-05-11 07:43:55 -04:00
|
|
|
|
|
|
|
int test(char *URL)
|
|
|
|
{
|
|
|
|
int res = 0;
|
2011-10-21 10:26:18 -04:00
|
|
|
CURL *curl = NULL;
|
2009-05-11 07:43:55 -04:00
|
|
|
int running;
|
2010-02-05 13:07:19 -05:00
|
|
|
CURLM *m = NULL;
|
2009-05-11 07:43:55 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
start_test_timing();
|
2009-05-11 07:43:55 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
global_init(CURL_GLOBAL_ALL);
|
2009-05-11 07:43:55 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
easy_init(curl);
|
2009-05-11 07:43:55 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
easy_setopt(curl, CURLOPT_URL, URL);
|
|
|
|
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
|
|
|
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
2013-07-22 15:07:06 -04:00
|
|
|
easy_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);
|
2009-05-11 07:43:55 -04:00
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_init(m);
|
|
|
|
|
|
|
|
multi_add_handle(m, curl);
|
2009-05-11 07:43:55 -04:00
|
|
|
|
|
|
|
fprintf(stderr, "Start at URL 0\n");
|
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
for(;;) {
|
2009-05-11 07:43:55 -04:00
|
|
|
struct timeval interval;
|
2011-10-21 10:26:18 -04:00
|
|
|
fd_set rd, wr, exc;
|
|
|
|
int maxfd = -99;
|
2009-05-11 07:43:55 -04:00
|
|
|
|
|
|
|
interval.tv_sec = 1;
|
|
|
|
interval.tv_usec = 0;
|
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_perform(m, &running);
|
|
|
|
|
|
|
|
abort_on_test_timeout();
|
|
|
|
|
|
|
|
if(!running)
|
|
|
|
break; /* done */
|
2009-05-11 07:43:55 -04:00
|
|
|
|
|
|
|
FD_ZERO(&rd);
|
|
|
|
FD_ZERO(&wr);
|
|
|
|
FD_ZERO(&exc);
|
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
multi_fdset(m, &rd, &wr, &exc, &maxfd);
|
|
|
|
|
|
|
|
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
|
|
|
|
|
|
|
|
select_test(maxfd+1, &rd, &wr, &exc, &interval);
|
|
|
|
|
|
|
|
abort_on_test_timeout();
|
2009-05-11 07:43:55 -04:00
|
|
|
}
|
|
|
|
|
2010-02-05 13:07:19 -05:00
|
|
|
test_cleanup:
|
|
|
|
|
2011-10-21 10:26:18 -04:00
|
|
|
/* undocumented cleanup sequence - type UB */
|
|
|
|
|
2009-05-11 07:43:55 -04:00
|
|
|
curl_easy_cleanup(curl);
|
2011-10-21 10:26:18 -04:00
|
|
|
curl_multi_cleanup(m);
|
2009-05-11 07:43:55 -04:00
|
|
|
curl_global_cleanup();
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|