/***************************************************************************1* _ _ ____ _2* Project ___| | | | _ \| |3* / __| | | | |_) | |4* | (__| |_| | _ <| |___5* \___|\___/|_| \_\_____|6*7* Copyright (C) Linus Nielsen Feltzing <[email protected]>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 * 10003031#define NUM_URLS 43233CURLcode test(char *URL)34{35CURLcode res = CURLE_OK;36CURL *curl = NULL;37int i;38char target_url[256];39char dnsentry[256];40struct curl_slist *slist = NULL, *slist2;41char *port = libtest_arg3;42char *address = libtest_arg2;4344(void)URL;4546/* Create fake DNS entries for serverX.example.com for all handles */47for(i = 0; i < NUM_URLS; i++) {48curl_msnprintf(dnsentry, sizeof(dnsentry),49"server%d.example.com:%s:%s", i + 1, port, address);50curl_mprintf("%s\n", dnsentry);51slist2 = curl_slist_append(slist, dnsentry);52if(!slist2) {53curl_mfprintf(stderr, "curl_slist_append() failed\n");54goto test_cleanup;55}56slist = slist2;57}5859start_test_timing();6061global_init(CURL_GLOBAL_ALL);6263/* get an easy handle */64easy_init(curl);6566/* go verbose */67easy_setopt(curl, CURLOPT_VERBOSE, 1L);68/* include headers */69easy_setopt(curl, CURLOPT_HEADER, 1L);7071easy_setopt(curl, CURLOPT_RESOLVE, slist);7273easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);7475/* get NUM_HANDLES easy handles */76for(i = 0; i < NUM_URLS; i++) {77/* specify target */78curl_msnprintf(target_url, sizeof(target_url),79"http://server%d.example.com:%s/path/1510%04i",80i + 1, port, i + 1);81target_url[sizeof(target_url) - 1] = '\0';82easy_setopt(curl, CURLOPT_URL, target_url);8384res = curl_easy_perform(curl);85if(res)86goto test_cleanup;8788abort_on_test_timeout();89}9091test_cleanup:9293/* proper cleanup sequence - type PB */9495curl_easy_cleanup(curl);9697curl_slist_free_all(slist);9899curl_global_cleanup();100101return res;102}103104105