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 #define NUM_URLS 4
00031
00032 int test(char *URL)
00033 {
00034 int res = 0;
00035 CURL *curl = NULL;
00036 int i;
00037 char target_url[256];
00038 char dnsentry[256];
00039 struct curl_slist *slist = NULL, *slist2;
00040 char *port = libtest_arg3;
00041 char *address = libtest_arg2;
00042
00043 (void)URL;
00044
00045
00046 for(i=0; i < NUM_URLS; i++) {
00047 snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
00048 port, address);
00049 printf("%s\n", dnsentry);
00050 slist2 = curl_slist_append(slist, dnsentry);
00051 if(!slist2) {
00052 fprintf(stderr, "curl_slist_append() failed\n");
00053 goto test_cleanup;
00054 }
00055 slist = slist2;
00056 }
00057
00058 start_test_timing();
00059
00060 global_init(CURL_GLOBAL_ALL);
00061
00062
00063 easy_init(curl);
00064
00065
00066 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
00067
00068 easy_setopt(curl, CURLOPT_HEADER, 1L);
00069
00070 easy_setopt(curl, CURLOPT_RESOLVE, slist);
00071
00072 easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
00073
00074
00075 for(i=0; i < NUM_URLS; i++) {
00076
00077 snprintf(target_url, sizeof(target_url),
00078 "http://server%d.example.com:%s/path/1510%04i",
00079 i + 1, port, i + 1);
00080 target_url[sizeof(target_url) - 1] = '\0';
00081 easy_setopt(curl, CURLOPT_URL, target_url);
00082
00083 res = curl_easy_perform(curl);
00084
00085 abort_on_test_timeout();
00086 }
00087
00088 test_cleanup:
00089
00090
00091
00092 curl_easy_cleanup(curl);
00093
00094 curl_slist_free_all(slist);
00095
00096 curl_global_cleanup();
00097
00098 return res;
00099 }