quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

lib1510.c (2765B)


      1 /***************************************************************************
      2  *                                  _   _ ____  _
      3  *  Project                     ___| | | |  _ \| |
      4  *                             / __| | | | |_) | |
      5  *                            | (__| |_| |  _ <| |___
      6  *                             \___|\___/|_| \_\_____|
      7  *
      8  * Copyright (C) Linus Nielsen Feltzing <linus@haxx.se>
      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 "first.h"
     25 
     26 #include "memdebug.h"
     27 
     28 static CURLcode test_lib1510(char *URL)
     29 {
     30   static const int NUM_URLS = 4;
     31 
     32   CURLcode res = CURLE_OK;
     33   CURL *curl = NULL;
     34   int i;
     35   char target_url[256];
     36   char dnsentry[256];
     37   struct curl_slist *slist = NULL, *slist2;
     38   char *port = libtest_arg3;
     39   char *address = libtest_arg2;
     40 
     41   (void)URL;
     42 
     43   /* Create fake DNS entries for serverX.example.com for all handles */
     44   for(i = 0; i < NUM_URLS; i++) {
     45     curl_msnprintf(dnsentry, sizeof(dnsentry),
     46                    "server%d.example.com:%s:%s", i + 1, port, address);
     47     curl_mprintf("%s\n", dnsentry);
     48     slist2 = curl_slist_append(slist, dnsentry);
     49     if(!slist2) {
     50       curl_mfprintf(stderr, "curl_slist_append() failed\n");
     51       goto test_cleanup;
     52     }
     53     slist = slist2;
     54   }
     55 
     56   start_test_timing();
     57 
     58   global_init(CURL_GLOBAL_ALL);
     59 
     60   /* get an easy handle */
     61   easy_init(curl);
     62 
     63   /* go verbose */
     64   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
     65   /* include headers */
     66   easy_setopt(curl, CURLOPT_HEADER, 1L);
     67 
     68   easy_setopt(curl, CURLOPT_RESOLVE, slist);
     69 
     70   easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
     71 
     72   /* get NUM_URLS easy handles */
     73   for(i = 0; i < NUM_URLS; i++) {
     74     /* specify target */
     75     curl_msnprintf(target_url, sizeof(target_url),
     76                    "http://server%d.example.com:%s/path/1510%04i",
     77                    i + 1, port, i + 1);
     78     target_url[sizeof(target_url) - 1] = '\0';
     79     easy_setopt(curl, CURLOPT_URL, target_url);
     80 
     81     res = curl_easy_perform(curl);
     82     if(res)
     83       goto test_cleanup;
     84 
     85     abort_on_test_timeout();
     86   }
     87 
     88 test_cleanup:
     89 
     90   /* proper cleanup sequence - type PB */
     91 
     92   curl_easy_cleanup(curl);
     93 
     94   curl_slist_free_all(slist);
     95 
     96   curl_global_cleanup();
     97 
     98   return res;
     99 }