lib573.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
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 "testtrace.h"
25 #include "testutil.h"
26 #include "warnless.h"
27 #include "memdebug.h"
28 
29 #define TEST_HANG_TIMEOUT 60 * 1000
30 
31 /*
32  * Get a single URL without select().
33  */
34 
35 int test(char *URL)
36 {
37  CURL *c = NULL;
38  CURLM *m = NULL;
39  int res = 0;
40  int running = 1;
41  double connect_time = 0.0;
42  double dbl_epsilon;
43 
44  dbl_epsilon = 1.0;
45  do {
46  dbl_epsilon /= 2.0;
47  } while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0);
48 
50 
52 
53  easy_init(c);
54 
55  easy_setopt(c, CURLOPT_HEADER, 1L);
56  easy_setopt(c, CURLOPT_URL, URL);
57 
60  easy_setopt(c, CURLOPT_DEBUGDATA, &libtest_debug_config);
61  easy_setopt(c, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
62  easy_setopt(c, CURLOPT_VERBOSE, 1L);
63 
64  multi_init(m);
65 
66  multi_add_handle(m, c);
67 
68  while(running) {
69  struct timeval timeout;
70  fd_set fdread, fdwrite, fdexcep;
71  int maxfd = -99;
72 
73  timeout.tv_sec = 0;
74  timeout.tv_usec = 100000L; /* 100 ms */
75 
76  multi_perform(m, &running);
77 
79 
80  if(!running)
81  break; /* done */
82 
83  FD_ZERO(&fdread);
84  FD_ZERO(&fdwrite);
85  FD_ZERO(&fdexcep);
86 
87  multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
88 
89  /* At this point, maxfd is guaranteed to be greater or equal than -1. */
90 
91  select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
92 
94  }
95 
96  curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
97  if(connect_time < dbl_epsilon) {
98  fprintf(stderr, "connect time %e is < epsilon %e\n",
99  connect_time, dbl_epsilon);
100  res = TEST_ERR_MAJOR_BAD;
101  }
102 
103 test_cleanup:
104 
105  /* proper cleanup sequence - type PA */
106 
111 
112  return res;
113 }
114 
int test(char *URL)
Definition: lib573.c:35
#define select_test(A, B, C, D, E)
Definition: test.h:378
#define global_init(A)
Definition: test.h:431
int libtest_debug_cb(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp)
Definition: testtrace.c:85
#define easy_setopt(A, B, C)
Definition: test.h:190
#define multi_add_handle(A, B)
Definition: test.h:238
static int res
#define abort_on_test_timeout()
Definition: test.h:404
#define TEST_ERR_MAJOR_BAD
Definition: test.h:85
#define curl_easy_getinfo(handle, info, arg)
#define easy_init(A)
Definition: test.h:145
#define multi_fdset(A, B, C, D, E)
Definition: test.h:323
CURL_EXTERN void curl_easy_cleanup(CURL *curl)
#define multi_perform(A, B)
Definition: test.h:293
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle)
#define multi_init(A)
Definition: test.h:166
void CURLM
Definition: multi.h:58
void CURL
Definition: curl.h:102
#define fprintf
Definition: curl_printf.h:41
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
struct libtest_trace_cfg libtest_debug_config
Definition: testtrace.c:28
#define start_test_timing()
Definition: test.h:383
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle)


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