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
00023
00024
00025
00026
00027
00028
00029
00030 #include "test.h"
00031
00032 #ifdef HAVE_LIMITS_H
00033 #include <limits.h>
00034 #endif
00035
00036 #include "testutil.h"
00037 #include "warnless.h"
00038 #include "memdebug.h"
00039
00040 #define TEST_HANG_TIMEOUT 60 * 1000
00041
00042 int test(char *URL)
00043 {
00044 CURL *easy = NULL;
00045 CURLM *multi = NULL;
00046 int still_running;
00047 int res = 0;
00048
00049 char redirect[160];
00050
00051
00052 struct curl_slist *dns_cache_list;
00053
00054 snprintf(redirect, sizeof(redirect), "google.com:%s:%s", libtest_arg2,
00055 libtest_arg3);
00056
00057 start_test_timing();
00058
00059 dns_cache_list = curl_slist_append(NULL, redirect);
00060 if(!dns_cache_list) {
00061 fprintf(stderr, "curl_slist_append() failed\n");
00062 return TEST_ERR_MAJOR_BAD;
00063 }
00064
00065 res_global_init(CURL_GLOBAL_ALL);
00066 if(res) {
00067 curl_slist_free_all(dns_cache_list);
00068 return res;
00069 }
00070
00071 easy_init(easy);
00072
00073 easy_setopt(easy, CURLOPT_URL, URL);
00074 easy_setopt(easy, CURLOPT_HEADER, 1L);
00075 easy_setopt(easy, CURLOPT_RESOLVE, dns_cache_list);
00076
00077 multi_init(multi);
00078
00079 multi_add_handle(multi, easy);
00080
00081 multi_perform(multi, &still_running);
00082
00083 abort_on_test_timeout();
00084
00085 while(still_running) {
00086 struct timeval timeout;
00087 fd_set fdread;
00088 fd_set fdwrite;
00089 fd_set fdexcep;
00090 int maxfd = -99;
00091
00092 FD_ZERO(&fdread);
00093 FD_ZERO(&fdwrite);
00094 FD_ZERO(&fdexcep);
00095 timeout.tv_sec = 1;
00096 timeout.tv_usec = 0;
00097
00098 multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
00099
00100
00101
00102 select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
00103
00104 abort_on_test_timeout();
00105
00106 multi_perform(multi, &still_running);
00107
00108 abort_on_test_timeout();
00109 }
00110
00111 test_cleanup:
00112
00113 #ifdef LIB1502
00114
00115 curl_multi_cleanup(multi);
00116 curl_easy_cleanup(easy);
00117 curl_global_cleanup();
00118 #endif
00119
00120 #ifdef LIB1503
00121
00122 curl_multi_remove_handle(multi, easy);
00123 curl_multi_cleanup(multi);
00124 curl_easy_cleanup(easy);
00125 curl_global_cleanup();
00126 #endif
00127
00128 #ifdef LIB1504
00129
00130 curl_easy_cleanup(easy);
00131 curl_multi_cleanup(multi);
00132 curl_global_cleanup();
00133 #endif
00134
00135 #ifdef LIB1505
00136
00137 curl_multi_remove_handle(multi, easy);
00138 curl_easy_cleanup(easy);
00139 curl_multi_cleanup(multi);
00140 curl_global_cleanup();
00141 #endif
00142
00143 curl_slist_free_all(dns_cache_list);
00144
00145 return res;
00146 }