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 "testutil.h"
00025 #include "warnless.h"
00026 #include "memdebug.h"
00027
00028 #define TEST_HANG_TIMEOUT 60 * 1000
00029
00030 int test(char *URL)
00031 {
00032 CURL *curls = NULL;
00033 CURLM *multi = NULL;
00034 int still_running;
00035 int i = -1;
00036 int res = 0;
00037 CURLMsg *msg;
00038
00039 start_test_timing();
00040
00041 global_init(CURL_GLOBAL_ALL);
00042
00043 multi_init(multi);
00044
00045 easy_init(curls);
00046
00047 easy_setopt(curls, CURLOPT_URL, URL);
00048 easy_setopt(curls, CURLOPT_HEADER, 1L);
00049
00050 multi_add_handle(multi, curls);
00051
00052 multi_perform(multi, &still_running);
00053
00054 abort_on_test_timeout();
00055
00056 while(still_running) {
00057 struct timeval timeout;
00058 fd_set fdread;
00059 fd_set fdwrite;
00060 fd_set fdexcep;
00061 int maxfd = -99;
00062
00063 FD_ZERO(&fdread);
00064 FD_ZERO(&fdwrite);
00065 FD_ZERO(&fdexcep);
00066 timeout.tv_sec = 1;
00067 timeout.tv_usec = 0;
00068
00069 multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
00070
00071
00072
00073 select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00074
00075 abort_on_test_timeout();
00076
00077 multi_perform(multi, &still_running);
00078
00079 abort_on_test_timeout();
00080 }
00081
00082 msg = curl_multi_info_read(multi, &still_running);
00083 if(msg)
00084
00085
00086 i = msg->data.result;
00087
00088 test_cleanup:
00089
00090
00091
00092 curl_multi_cleanup(multi);
00093 curl_easy_cleanup(curls);
00094 curl_global_cleanup();
00095
00096 if(res)
00097 i = res;
00098
00099 return i;
00100 }