lib573.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
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 "testtrace.h"
00025 #include "testutil.h"
00026 #include "warnless.h"
00027 #include "memdebug.h"
00028 
00029 #define TEST_HANG_TIMEOUT 60 * 1000
00030 
00031 /*
00032  * Get a single URL without select().
00033  */
00034 
00035 int test(char *URL)
00036 {
00037   CURL *c = NULL;
00038   CURLM *m = NULL;
00039   int res = 0;
00040   int running = 1;
00041   double connect_time = 0.0;
00042   double dbl_epsilon;
00043 
00044   dbl_epsilon = 1.0;
00045   do {
00046     dbl_epsilon /= 2.0;
00047   } while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0);
00048 
00049   start_test_timing();
00050 
00051   global_init(CURL_GLOBAL_ALL);
00052 
00053   easy_init(c);
00054 
00055   easy_setopt(c, CURLOPT_HEADER, 1L);
00056   easy_setopt(c, CURLOPT_URL, URL);
00057 
00058   libtest_debug_config.nohex = 1;
00059   libtest_debug_config.tracetime = 1;
00060   easy_setopt(c, CURLOPT_DEBUGDATA, &libtest_debug_config);
00061   easy_setopt(c, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
00062   easy_setopt(c, CURLOPT_VERBOSE, 1L);
00063 
00064   multi_init(m);
00065 
00066   multi_add_handle(m, c);
00067 
00068   while(running) {
00069     struct timeval timeout;
00070     fd_set fdread, fdwrite, fdexcep;
00071     int maxfd = -99;
00072 
00073     timeout.tv_sec = 0;
00074     timeout.tv_usec = 100000L; /* 100 ms */
00075 
00076     multi_perform(m, &running);
00077 
00078     abort_on_test_timeout();
00079 
00080     if(!running)
00081       break; /* done */
00082 
00083     FD_ZERO(&fdread);
00084     FD_ZERO(&fdwrite);
00085     FD_ZERO(&fdexcep);
00086 
00087     multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
00088 
00089     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
00090 
00091     select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00092 
00093     abort_on_test_timeout();
00094   }
00095 
00096   curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
00097   if(connect_time < dbl_epsilon) {
00098     fprintf(stderr, "connect time %e is < epsilon %e\n",
00099             connect_time, dbl_epsilon);
00100     res = TEST_ERR_MAJOR_BAD;
00101   }
00102 
00103 test_cleanup:
00104 
00105   /* proper cleanup sequence - type PA */
00106 
00107   curl_multi_remove_handle(m, c);
00108   curl_multi_cleanup(m);
00109   curl_easy_cleanup(c);
00110   curl_global_cleanup();
00111 
00112   return res;
00113 }
00114 


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