/***************************************************************************1* _ _ ____ _2* Project ___| | | | _ \| |3* / __| | | | |_) | |4* | (__| |_| | _ <| |___5* \___|\___/|_| \_\_____|6*7* Copyright (C) Daniel Stenberg, <[email protected]>, et al.8*9* This software is licensed as described in the file COPYING, which10* you should have received as part of this distribution. The terms11* are also available at https://curl.se/docs/copyright.html.12*13* You may opt to use, copy, modify, merge, publish, distribute and/or sell14* copies of the Software, and permit persons to whom the Software is15* furnished to do so, under the terms of the COPYING file.16*17* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY18* KIND, either express or implied.19*20* SPDX-License-Identifier: curl21*22***************************************************************************/23#include "test.h"2425#include "testutil.h"26#include "warnless.h"27#include "memdebug.h"2829#define TEST_HANG_TIMEOUT 60 * 10003031CURLcode test(char *URL)32{33CURL *curls = NULL;34CURLM *multi = NULL;35int still_running;36CURLcode i = TEST_ERR_FAILURE;37CURLcode res = CURLE_OK;38CURLMsg *msg;3940start_test_timing();4142global_init(CURL_GLOBAL_ALL);4344multi_init(multi);4546easy_init(curls);4748easy_setopt(curls, CURLOPT_URL, URL);49easy_setopt(curls, CURLOPT_HEADER, 1L);5051multi_add_handle(multi, curls);5253multi_perform(multi, &still_running);5455abort_on_test_timeout();5657while(still_running) {58CURLMcode mres;59int num;60mres = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);61if(mres != CURLM_OK) {62curl_mprintf("curl_multi_wait() returned %d\n", mres);63res = TEST_ERR_MAJOR_BAD;64goto test_cleanup;65}6667abort_on_test_timeout();6869multi_perform(multi, &still_running);7071abort_on_test_timeout();72}7374msg = curl_multi_info_read(multi, &still_running);75if(msg)76/* this should now contain a result code from the easy handle,77get it */78i = msg->data.result;7980test_cleanup:8182/* undocumented cleanup sequence - type UA */8384curl_multi_cleanup(multi);85curl_easy_cleanup(curls);86curl_global_cleanup();8788if(res)89i = res;9091return i; /* return the final return code */92}939495