/***************************************************************************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 = CURLE_OK;37CURLcode res = CURLE_OK;38CURLMsg *msg;39int counter = 3;4041start_test_timing();4243global_init(CURL_GLOBAL_ALL);4445multi_init(multi);4647easy_init(curls);4849easy_setopt(curls, CURLOPT_URL, URL);50easy_setopt(curls, CURLOPT_HEADER, 1L);51easy_setopt(curls, CURLOPT_VERBOSE, 1L);52easy_setopt(curls, CURLOPT_USERPWD, "u:s");5354multi_add_handle(multi, curls);5556multi_perform(multi, &still_running);5758abort_on_test_timeout();5960while(still_running && counter--) {61CURLMcode mres;62int num;63mres = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);64if(mres != CURLM_OK) {65curl_mprintf("curl_multi_wait() returned %d\n", mres);66res = TEST_ERR_MAJOR_BAD;67goto test_cleanup;68}6970abort_on_test_timeout();7172multi_perform(multi, &still_running);7374abort_on_test_timeout();75}7677msg = curl_multi_info_read(multi, &still_running);78if(msg)79/* this should now contain a result code from the easy handle,80get it */81i = msg->data.result;8283test_cleanup:8485/* undocumented cleanup sequence - type UA */8687curl_multi_cleanup(multi);88curl_easy_cleanup(curls);89curl_global_cleanup();9091if(res)92i = res;9394return i; /* return the final return code */95}969798