Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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;
00075
00076 multi_perform(m, &running);
00077
00078 abort_on_test_timeout();
00079
00080 if(!running)
00081 break;
00082
00083 FD_ZERO(&fdread);
00084 FD_ZERO(&fdwrite);
00085 FD_ZERO(&fdexcep);
00086
00087 multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
00088
00089
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
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