lib1510.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 2013, 2017, 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.haxx.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  ***************************************************************************/
22 #include "test.h"
23 
24 #include "testutil.h"
25 #include "warnless.h"
26 #include "memdebug.h"
27 
28 #define TEST_HANG_TIMEOUT 60 * 1000
29 
30 #define NUM_URLS 4
31 
32 int test(char *URL)
33 {
34  int res = 0;
35  CURL *curl = NULL;
36  int i;
37  char target_url[256];
38  char dnsentry[256];
39  struct curl_slist *slist = NULL, *slist2;
40  char *port = libtest_arg3;
41  char *address = libtest_arg2;
42 
43  (void)URL;
44 
45  /* Create fake DNS entries for serverX.example.com for all handles */
46  for(i = 0; i < NUM_URLS; i++) {
47  snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
48  port, address);
49  printf("%s\n", dnsentry);
50  slist2 = curl_slist_append(slist, dnsentry);
51  if(!slist2) {
52  fprintf(stderr, "curl_slist_append() failed\n");
53  goto test_cleanup;
54  }
55  slist = slist2;
56  }
57 
59 
61 
62  /* get an easy handle */
63  easy_init(curl);
64 
65  /* go verbose */
66  easy_setopt(curl, CURLOPT_VERBOSE, 1L);
67  /* include headers */
68  easy_setopt(curl, CURLOPT_HEADER, 1L);
69 
70  easy_setopt(curl, CURLOPT_RESOLVE, slist);
71 
72  easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
73 
74  /* get NUM_HANDLES easy handles */
75  for(i = 0; i < NUM_URLS; i++) {
76  /* specify target */
77  snprintf(target_url, sizeof(target_url),
78  "http://server%d.example.com:%s/path/1510%04i",
79  i + 1, port, i + 1);
80  target_url[sizeof(target_url) - 1] = '\0';
81  easy_setopt(curl, CURLOPT_URL, target_url);
82 
83  res = curl_easy_perform(curl);
84 
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 
97 
98  return res;
99 }
#define global_init(A)
Definition: test.h:431
#define easy_setopt(A, B, C)
Definition: test.h:190
#define NUM_URLS
Definition: lib1510.c:30
static int res
unsigned int i
Definition: unit1303.c:79
#define abort_on_test_timeout()
Definition: test.h:404
char * libtest_arg2
Definition: first.c:75
CURL_EXTERN struct curl_slist * curl_slist_append(struct curl_slist *, const char *)
Definition: slist.c:89
#define printf
Definition: curl_printf.h:40
#define easy_init(A)
Definition: test.h:145
CURL_EXTERN void curl_easy_cleanup(CURL *curl)
static unsigned short port
Definition: sockfilt.c:137
char * libtest_arg3
Definition: first.c:76
void CURL
Definition: curl.h:102
int test(char *URL)
Definition: lib1510.c:32
#define fprintf
Definition: curl_printf.h:41
#define snprintf
Definition: curl_printf.h:42
CURL_EXTERN void curl_global_cleanup(void)
curl_global_cleanup() globally cleanups curl, uses the value of "init_flags" to determine what needs ...
Definition: easy.c:312
#define CURL_GLOBAL_ALL
Definition: curl.h:2519
static CURL * curl
Definition: sessioninfo.c:35
CURL_EXTERN void curl_slist_free_all(struct curl_slist *)
Definition: slist.c:129
#define start_test_timing()
Definition: test.h:383
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl)


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:15