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 = TEST_ERR_FAILURE;
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 int num;
00058 res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
00059 if(res != CURLM_OK) {
00060 printf("curl_multi_wait() returned %d\n", res);
00061 res = TEST_ERR_MAJOR_BAD;
00062 goto test_cleanup;
00063 }
00064
00065 abort_on_test_timeout();
00066
00067 multi_perform(multi, &still_running);
00068
00069 abort_on_test_timeout();
00070 }
00071
00072 msg = curl_multi_info_read(multi, &still_running);
00073 if(msg)
00074
00075
00076 i = msg->data.result;
00077
00078 test_cleanup:
00079
00080
00081
00082 curl_multi_cleanup(multi);
00083 curl_easy_cleanup(curls);
00084 curl_global_cleanup();
00085
00086 if(res)
00087 i = res;
00088
00089 return i;
00090 }