]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - QRScanner/mobile/jni/thirdparty/curl/tests/libtest/lib530.c
Add MuPDF native source codes
[hornmich/skoda-qr-demo.git] / QRScanner / mobile / jni / thirdparty / curl / tests / libtest / lib530.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22 #include "test.h"
23
24 #include "testutil.h"
25 #include "warnless.h"
26 #include "memdebug.h"
27
28 #define TEST_HANG_TIMEOUT 60 * 1000
29
30 #define NUM_HANDLES 4
31
32 int test(char *URL)
33 {
34   int res = 0;
35   CURL *curl[NUM_HANDLES];
36   int running;
37   CURLM *m = NULL;
38   int i;
39   char target_url[256];
40   int handles_added = 0;
41
42   for(i=0; i < NUM_HANDLES; i++)
43     curl[i] = NULL;
44
45   start_test_timing();
46
47   global_init(CURL_GLOBAL_ALL);
48
49   multi_init(m);
50
51   /* get NUM_HANDLES easy handles */
52   for(i=0; i < NUM_HANDLES; i++) {
53     /* get an easy handle */
54     easy_init(curl[i]);
55     /* specify target */
56     sprintf(target_url, "%s%04i", URL, i + 1);
57     target_url[sizeof(target_url) - 1] = '\0';
58     easy_setopt(curl[i], CURLOPT_URL, target_url);
59     /* go verbose */
60     easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
61     /* include headers */
62     easy_setopt(curl[i], CURLOPT_HEADER, 1L);
63   }
64
65   /* Add the first handle to multi. We do this to let libcurl detect
66      that the server can do pipelining. The rest of the handles will be
67      added later. */
68   multi_add_handle(m, curl[handles_added++]);
69
70   multi_setopt(m, CURLMOPT_PIPELINING, 1L);
71
72   fprintf(stderr, "Start at URL 0\n");
73
74   for(;;) {
75     struct timeval interval;
76     fd_set rd, wr, exc;
77     int maxfd = -99;
78
79     interval.tv_sec = 1;
80     interval.tv_usec = 0;
81
82     multi_perform(m, &running);
83
84     abort_on_test_timeout();
85
86     if(!running && handles_added >= NUM_HANDLES)
87       break; /* done */
88
89     /* Add the rest of the handles now that the first handle has sent the
90        request. */
91     while(handles_added < NUM_HANDLES)
92       multi_add_handle(m, curl[handles_added++]);
93
94     FD_ZERO(&rd);
95     FD_ZERO(&wr);
96     FD_ZERO(&exc);
97
98     multi_fdset(m, &rd, &wr, &exc, &maxfd);
99
100     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
101
102     select_test(maxfd+1, &rd, &wr, &exc, &interval);
103
104     abort_on_test_timeout();
105   }
106
107 test_cleanup:
108
109   /* proper cleanup sequence - type PB */
110
111   for(i=0; i < NUM_HANDLES; i++) {
112     curl_multi_remove_handle(m, curl[i]);
113     curl_easy_cleanup(curl[i]);
114   }
115
116   curl_multi_cleanup(m);
117   curl_global_cleanup();
118
119   return res;
120 }