1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
27 #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
28 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
31 * Get a single URL without select().
40 struct timeval mp_start;
41 char mp_timedout = FALSE;
43 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
44 fprintf(stderr, "curl_global_init() failed\n");
45 return TEST_ERR_MAJOR_BAD;
48 if ((c = curl_easy_init()) == NULL) {
49 fprintf(stderr, "curl_easy_init() failed\n");
50 curl_global_cleanup();
51 return TEST_ERR_MAJOR_BAD;
54 test_setopt(c, CURLOPT_URL, URL);
56 if ((m = curl_multi_init()) == NULL) {
57 fprintf(stderr, "curl_multi_init() failed\n");
59 curl_global_cleanup();
60 return TEST_ERR_MAJOR_BAD;
63 if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) {
64 fprintf(stderr, "curl_multi_add_handle() failed, "
65 "with code %d\n", res);
66 curl_multi_cleanup(m);
68 curl_global_cleanup();
69 return TEST_ERR_MAJOR_BAD;
73 mp_start = tutil_tvnow();
76 res = (int)curl_multi_perform(m, &running);
77 if (tutil_tvdiff(tutil_tvnow(), mp_start) >
78 MULTI_PERFORM_HANG_TIMEOUT) {
83 fprintf(stderr, "nothing left running.\n");
89 if (mp_timedout) fprintf(stderr, "mp_timedout\n");
90 fprintf(stderr, "ABORTING TEST, since it seems "
91 "that it would have run forever.\n");
92 res = TEST_ERR_RUNS_FOREVER;
98 curl_multi_remove_handle(m, c);
99 curl_multi_cleanup(m);
101 curl_easy_cleanup(c);
102 curl_global_cleanup();