lib1510.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 2013, Linus Nielsen Feltzing <linus@haxx.se>
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 #include "testutil.h"
00025 #include "warnless.h"
00026 #include "memdebug.h"
00027 
00028 #define TEST_HANG_TIMEOUT 60 * 1000
00029 
00030 #define NUM_URLS 4
00031 
00032 int test(char *URL)
00033 {
00034   int res = 0;
00035   CURL *curl = NULL;
00036   int i;
00037   char target_url[256];
00038   char dnsentry[256];
00039   struct curl_slist *slist = NULL, *slist2;
00040   char *port = libtest_arg3;
00041   char *address = libtest_arg2;
00042 
00043   (void)URL;
00044 
00045   /* Create fake DNS entries for serverX.example.com for all handles */
00046   for(i=0; i < NUM_URLS; i++) {
00047     snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
00048              port, address);
00049     printf("%s\n", dnsentry);
00050     slist2 = curl_slist_append(slist, dnsentry);
00051     if(!slist2) {
00052       fprintf(stderr, "curl_slist_append() failed\n");
00053       goto test_cleanup;
00054     }
00055     slist = slist2;
00056   }
00057 
00058   start_test_timing();
00059 
00060   global_init(CURL_GLOBAL_ALL);
00061 
00062   /* get an easy handle */
00063   easy_init(curl);
00064 
00065   /* go verbose */
00066   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
00067   /* include headers */
00068   easy_setopt(curl, CURLOPT_HEADER, 1L);
00069 
00070   easy_setopt(curl, CURLOPT_RESOLVE, slist);
00071 
00072   easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
00073 
00074   /* get NUM_HANDLES easy handles */
00075   for(i=0; i < NUM_URLS; i++) {
00076     /* specify target */
00077     snprintf(target_url, sizeof(target_url),
00078              "http://server%d.example.com:%s/path/1510%04i",
00079              i + 1, port, i + 1);
00080     target_url[sizeof(target_url) - 1] = '\0';
00081     easy_setopt(curl, CURLOPT_URL, target_url);
00082 
00083     res = curl_easy_perform(curl);
00084 
00085     abort_on_test_timeout();
00086   }
00087 
00088 test_cleanup:
00089 
00090   /* proper cleanup sequence - type PB */
00091 
00092   curl_easy_cleanup(curl);
00093 
00094   curl_slist_free_all(slist);
00095 
00096   curl_global_cleanup();
00097 
00098   return res;
00099 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05