1 /***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
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 https://curl.se/docs/copyright.html.
13 *
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.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24 #include "test.h"
25
26 #include "testutil.h"
27 #include "warnless.h"
28 #include "memdebug.h"
29
30 #define TEST_HANG_TIMEOUT 60 * 1000
31
test(char * URL)32 CURLcode test(char *URL)
33 {
34 CURL *curls = NULL;
35 CURLM *multi = NULL;
36 CURLcode i = CURLE_OK;
37 CURLcode res = CURLE_OK;
38 CURLMcode mc;
39
40 global_init(CURL_GLOBAL_ALL);
41
42 multi_init(multi);
43
44 easy_init(curls);
45
46 easy_setopt(curls, CURLOPT_URL, URL);
47
48 multi_add_handle(multi, curls);
49
50 mc = curl_multi_remove_handle(multi, curls);
51 mc += curl_multi_remove_handle(multi, curls);
52
53 if(mc) {
54 fprintf(stderr, "%d was unexpected\n", (int)mc);
55 i = CURLE_FAILED_INIT;
56 }
57
58 test_cleanup:
59 curl_multi_cleanup(multi);
60 curl_easy_cleanup(curls);
61 curl_global_cleanup();
62
63 if(res)
64 i = res;
65
66 return i; /* return the final return code */
67 }
68