Artifactspublic-v0

curl

master
ply4 git calls37 ms291 KiB3 cachedprotocol v2
538 lines22 KiBRaw
1#ifndef HEADER_LIBTEST_FIRST_H
2#define HEADER_LIBTEST_FIRST_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#define CURL_NO_OLDIES
27#define CURL_DISABLE_DEPRECATION
29/* Now include the curl_setup.h file from libcurl's private libdir (the source
30 version, but that might include "curl_config.h" from the build directory so
31 we need both of them in the include path), so that we get good in-depth
32 knowledge about the system we are building this on */
33#include "curl_setup.h"
34#include "testutil.h"
36typedef CURLcode (*entry_func_t)(const char *);
38struct entry_s {
39 const char *name;
40 entry_func_t ptr;
41};
43extern const struct entry_s s_entries[];
45extern int unitfail; /* for unittests */
47#include "curlx/base64.h" /* for curlx_base64* */
48#include "curlx/dynbuf.h" /* for curlx_dyn_*() */
49#include "curlx/win32-fopen.h" /* for curlx_f*() */
50#include "curlx/inet_ntop.h" /* for curlx_inet_ntop() */
51#include "curlx/inet_pton.h" /* for curlx_inet_pton() */
52#include "curlx/strcopy.h" /* for curlx_strcopy() */
53#include "curlx/strerr.h" /* for curlx_strerror() */
54#include "curlx/strparse.h" /* for curlx_str_* parsing functions */
55#include "curlx/timediff.h" /* for timediff_t type and related functions */
56#include "curlx/timeval.h" /* for curlx_now type and related functions */
57#include "curlx/wait.h" /* for curlx_wait_ms() */
59#ifdef HAVE_SYS_SELECT_H
60/* since so many tests use select(), we can as well include it here */
61#include <sys/select.h>
62#endif
64extern const char *libtest_arg2; /* set by first.c to the argv[2] or NULL */
65extern const char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
66extern const char *libtest_arg4; /* set by first.c to the argv[4] or NULL */
67extern const char *libtest_arg5; /* set by first.c to the argv[5] or NULL */
69/* argc and argv as passed in to the main() function */
70extern int test_argc;
71extern const char **test_argv;
72extern int testnum;
73extern struct curltime tv_test_start; /* for test timing */
75extern int coptind;
76extern const char *coptarg;
77int cgetopt(int argc, const char * const argv[], const char *optstring);
79extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
80 struct timeval *tv);
82extern char *hexdump(const unsigned char *buf, size_t len);
84#ifndef CURL_DISABLE_WEBSOCKETS
85CURLcode ws_send_ping(CURL *curl, const char *send_payload);
86CURLcode ws_recv_pong(CURL *curl, const char *expected_payload);
87void ws_close(CURL *curl); /* close the connection */
88#endif
90/*
91 * TEST_ERR_* values must be within the CURLcode range to not cause compiler
92 * errors.
93 *
94 * For portability reasons TEST_ERR_* values should be less than 127.
95 */
96#define TEST_ERR_MAJOR_BAD CURLE_OBSOLETE20
97#define TEST_ERR_RUNS_FOREVER CURLE_OBSOLETE24
98#define TEST_ERR_EASY_INIT CURLE_OBSOLETE29
99#define TEST_ERR_MULTI CURLE_OBSOLETE32
100#define TEST_ERR_NUM_HANDLES CURLE_OBSOLETE34
101#define TEST_ERR_SELECT CURLE_OBSOLETE40
102#define TEST_ERR_SUCCESS CURLE_OBSOLETE41
103#define TEST_ERR_FAILURE CURLE_OBSOLETE44
104#define TEST_ERR_USAGE CURLE_OBSOLETE46
105#define TEST_ERR_FOPEN CURLE_OBSOLETE50
106#define TEST_ERR_FSTAT CURLE_OBSOLETE51
107#define TEST_ERR_BAD_TIMEOUT CURLE_OBSOLETE57
109/*
110 * Macros for test source code readability/maintainability.
111 *
112 * All of the following macros require that an int data type 'res' variable
113 * exists in scope where macro is used, and that it has been initialized to
114 * zero before the macro is used.
115 *
116 * exe_* and chk_* macros are helper macros not intended to be used from
117 * outside of this header file. Arguments 'Y' and 'Z' of these represent
118 * source code file and line number, while Arguments 'A', 'B', etc, are
119 * the arguments used to actually call a libcurl function.
120 *
121 * All easy_* and multi_* macros call a libcurl function and evaluate if
122 * the function has succeeded or failed. When the function succeeds 'res'
123 * variable is not set nor cleared and program continues normal flow. On
124 * the other hand if function fails 'res' variable is set and a jump to
125 * label 'test_cleanup' is performed.
126 *
127 * Every easy_* and multi_* macros have a res_easy_* and res_multi_* macro
128 * counterpart that operates in the same way with the exception that no
129 * jump takes place in case of failure. res_easy_* and res_multi_* macros
130 * should be immediately followed by checking if 'res' variable has been
131 * set.
132 *
133 * 'res' variable when set holds a CURLcode, CURLMcode, or any of the
134 * TEST_ERR_* values defined above. It is advisable to return this value
135 * as test result.
136 */
137#ifndef UNITTESTS
139/* ---------------------------------------------------------------- */
141#define exe_easy_init(A, Y, Z) \
142 do { \
143 (A) = curl_easy_init(); \
144 if(!(A)) { \
145 curl_mfprintf(stderr, "%s:%d curl_easy_init() failed\n", Y, Z); \
146 result = TEST_ERR_EASY_INIT; \
147 } \
148 } while(0)
150#define res_easy_init(A) \
151 exe_easy_init(A, __FILE__, __LINE__)
153#define chk_easy_init(A, Y, Z) \
154 do { \
155 exe_easy_init(A, Y, Z); \
156 if(result) \
157 goto test_cleanup; \
158 } while(0)
160#define easy_init(A) \
161 chk_easy_init(A, __FILE__, __LINE__)
163/* ---------------------------------------------------------------- */
165#define exe_multi_init(A, Y, Z) \
166 do { \
167 (A) = curl_multi_init(); \
168 if(!(A)) { \
169 curl_mfprintf(stderr, "%s:%d curl_multi_init() failed\n", Y, Z); \
170 result = TEST_ERR_MULTI; \
171 } \
172 } while(0)
174#define res_multi_init(A) \
175 exe_multi_init(A, __FILE__, __LINE__)
177#define chk_multi_init(A, Y, Z) \
178 do { \
179 exe_multi_init(A, Y, Z); \
180 if(result) \
181 goto test_cleanup; \
182 } while(0)
184#define multi_init(A) \
185 chk_multi_init(A, __FILE__, __LINE__)
187/* ---------------------------------------------------------------- */
189#define exe_easy_setopt(A, B, C, Y, Z) \
190 do { \
191 result = curl_easy_setopt(A, B, C); \
192 if(result) \
193 curl_mfprintf(stderr, \
194 "%s:%d curl_easy_setopt() failed, " \
195 "with code %d (%s)\n", \
196 Y, Z, (int)result, curl_easy_strerror(result)); \
197 } while(0)
199#define res_easy_setopt(A, B, C) \
200 exe_easy_setopt(A, B, C, __FILE__, __LINE__)
202#define chk_easy_setopt(A, B, C, Y, Z) \
203 do { \
204 exe_easy_setopt(A, B, C, Y, Z); \
205 if(result) \
206 goto test_cleanup; \
207 } while(0)
209#define easy_setopt(A, B, C) \
210 chk_easy_setopt(A, B, C, __FILE__, __LINE__)
212/* ---------------------------------------------------------------- */
214#define exe_multi_setopt(A, B, C, Y, Z) \
215 do { \
216 CURLMcode ec = curl_multi_setopt(A, B, C); \
217 if(ec != CURLM_OK) { \
218 curl_mfprintf(stderr, \
219 "%s:%d curl_multi_setopt() failed, " \
220 "with code %d (%s)\n", \
221 Y, Z, ec, curl_multi_strerror(ec)); \
222 result = TEST_ERR_MULTI; \
223 } \
224 } while(0)
226#define chk_multi_setopt(A, B, C, Y, Z) \
227 do { \
228 exe_multi_setopt(A, B, C, Y, Z); \
229 if(result) \
230 goto test_cleanup; \
231 } while(0)
233#define multi_setopt(A, B, C) \
234 chk_multi_setopt(A, B, C, __FILE__, __LINE__)
236/* ---------------------------------------------------------------- */
238#define exe_multi_add_handle(A, B, Y, Z) \
239 do { \
240 CURLMcode ec = curl_multi_add_handle(A, B); \
241 if(ec != CURLM_OK) { \
242 curl_mfprintf(stderr, \
243 "%s:%d curl_multi_add_handle() failed, " \
244 "with code %d (%s)\n", \
245 Y, Z, ec, curl_multi_strerror(ec)); \
246 result = TEST_ERR_MULTI; \
247 } \
248 } while(0)
250#define res_multi_add_handle(A, B) \
251 exe_multi_add_handle(A, B, __FILE__, __LINE__)
253#define chk_multi_add_handle(A, B, Y, Z) \
254 do { \
255 exe_multi_add_handle(A, B, Y, Z); \
256 if(result) \
257 goto test_cleanup; \
258 } while(0)
260#define multi_add_handle(A, B) \
261 chk_multi_add_handle(A, B, __FILE__, __LINE__)
263/* ---------------------------------------------------------------- */
265#define exe_multi_remove_handle(A, B, Y, Z) \
266 do { \
267 CURLMcode ec = curl_multi_remove_handle(A, B); \
268 if(ec != CURLM_OK) { \
269 curl_mfprintf(stderr, \
270 "%s:%d curl_multi_remove_handle() failed, " \
271 "with code %d (%s)\n", \
272 Y, Z, ec, curl_multi_strerror(ec)); \
273 result = TEST_ERR_MULTI; \
274 } \
275 } while(0)
277#define chk_multi_remove_handle(A, B, Y, Z) \
278 do { \
279 exe_multi_remove_handle(A, B, Y, Z); \
280 if(result) \
281 goto test_cleanup; \
282 } while(0)
284#define multi_remove_handle(A, B) \
285 chk_multi_remove_handle(A, B, __FILE__, __LINE__)
287/* ---------------------------------------------------------------- */
289#define exe_multi_perform(A, B, Y, Z) \
290 do { \
291 CURLMcode ec = curl_multi_perform(A, B); \
292 if(ec != CURLM_OK) { \
293 curl_mfprintf(stderr, \
294 "%s:%d curl_multi_perform() failed, " \
295 "with code %d (%s)\n", \
296 Y, Z, ec, curl_multi_strerror(ec)); \
297 result = TEST_ERR_MULTI; \
298 } \
299 else if(*(B) < 0) { \
300 curl_mfprintf(stderr, \
301 "%s:%d curl_multi_perform() succeeded, " \
302 "but returned invalid running_handles value (%d)\n", \
303 Y, Z, (int)*(B)); \
304 result = TEST_ERR_NUM_HANDLES; \
305 } \
306 } while(0)
308#define res_multi_perform(A, B) \
309 exe_multi_perform(A, B, __FILE__, __LINE__)
311#define chk_multi_perform(A, B, Y, Z) \
312 do { \
313 exe_multi_perform(A, B, Y, Z); \
314 if(result) \
315 goto test_cleanup; \
316 } while(0)
318#define multi_perform(A, B) \
319 chk_multi_perform(A, B, __FILE__, __LINE__)
321/* ---------------------------------------------------------------- */
323#define exe_multi_fdset(A, B, C, D, E, Y, Z) \
324 do { \
325 CURLMcode ec = curl_multi_fdset(A, B, C, D, E); \
326 if(ec != CURLM_OK) { \
327 curl_mfprintf(stderr, \
328 "%s:%d curl_multi_fdset() failed, " \
329 "with code %d (%s)\n", \
330 Y, Z, ec, curl_multi_strerror(ec)); \
331 result = TEST_ERR_MULTI; \
332 } \
333 else if(*(E) < -1) { \
334 curl_mfprintf(stderr, \
335 "%s:%d curl_multi_fdset() succeeded, " \
336 "but returned invalid max_fd value (%d)\n", \
337 Y, Z, (int)*(E)); \
338 result = TEST_ERR_NUM_HANDLES; \
339 } \
340 } while(0)
342#define res_multi_fdset(A, B, C, D, E) \
343 exe_multi_fdset(A, B, C, D, E, __FILE__, __LINE__)
345#define chk_multi_fdset(A, B, C, D, E, Y, Z) \
346 do { \
347 exe_multi_fdset(A, B, C, D, E, Y, Z); \
348 if(result) \
349 goto test_cleanup; \
350 } while(0)
352#define multi_fdset(A, B, C, D, E) \
353 chk_multi_fdset(A, B, C, D, E, __FILE__, __LINE__)
355/* ---------------------------------------------------------------- */
357#define exe_multi_timeout(A, B, Y, Z) \
358 do { \
359 CURLMcode ec = curl_multi_timeout(A, B); \
360 if(ec != CURLM_OK) { \
361 curl_mfprintf(stderr, \
362 "%s:%d curl_multi_timeout() failed, " \
363 "with code %d (%s)\n", \
364 Y, Z, ec, curl_multi_strerror(ec)); \
365 result = TEST_ERR_BAD_TIMEOUT; \
366 } \
367 else if(*(B) < -1L) { \
368 curl_mfprintf(stderr, \
369 "%s:%d curl_multi_timeout() succeeded, " \
370 "but returned invalid timeout value (%ld)\n", \
371 Y, Z, (long)*(B)); \
372 result = TEST_ERR_BAD_TIMEOUT; \
373 } \
374 } while(0)
376#define res_multi_timeout(A, B) \
377 exe_multi_timeout(A, B, __FILE__, __LINE__)
379#define chk_multi_timeout(A, B, Y, Z) \
380 do { \
381 exe_multi_timeout(A, B, Y, Z); \
382 if(result) \
383 goto test_cleanup; \
384 } while(0)
386#define multi_timeout(A, B) \
387 chk_multi_timeout(A, B, __FILE__, __LINE__)
389/* ---------------------------------------------------------------- */
391#define exe_multi_poll(A, B, C, D, E, Y, Z) \
392 do { \
393 CURLMcode ec = curl_multi_poll(A, B, C, D, E); \
394 if(ec != CURLM_OK) { \
395 curl_mfprintf(stderr, \
396 "%s:%d curl_multi_poll() failed, " \
397 "with code %d (%s)\n", \
398 Y, Z, ec, curl_multi_strerror(ec)); \
399 result = TEST_ERR_MULTI; \
400 } \
401 else if(*(E) < 0) { \
402 curl_mfprintf(stderr, \
403 "%s:%d curl_multi_poll() succeeded, " \
404 "but returned invalid numfds value (%d)\n", \
405 Y, Z, (int)*(E)); \
406 result = TEST_ERR_NUM_HANDLES; \
407 } \
408 } while(0)
410#define chk_multi_poll(A, B, C, D, E, Y, Z) \
411 do { \
412 exe_multi_poll(A, B, C, D, E, Y, Z); \
413 if(result) \
414 goto test_cleanup; \
415 } while(0)
417#define multi_poll(A, B, C, D, E) \
418 chk_multi_poll(A, B, C, D, E, __FILE__, __LINE__)
420/* ---------------------------------------------------------------- */
422#define exe_multi_wakeup(A, Y, Z) \
423 do { \
424 CURLMcode ec = curl_multi_wakeup(A); \
425 if(ec != CURLM_OK) { \
426 curl_mfprintf(stderr, \
427 "%s:%d curl_multi_wakeup() failed, " \
428 "with code %d (%s)\n", \
429 Y, Z, ec, curl_multi_strerror(ec)); \
430 result = TEST_ERR_MULTI; \
431 } \
432 } while(0)
434#define res_multi_wakeup(A) \
435 exe_multi_wakeup(A, __FILE__, __LINE__)
437/* ---------------------------------------------------------------- */
439#define exe_select_test(A, B, C, D, E, Y, Z) \
440 do { \
441 if(select_wrapper(A, B, C, D, E) == -1) { \
442 int sockerr = SOCKERRNO; \
443 char sockerrbuf[STRERROR_LEN]; \
444 curl_mfprintf(stderr, \
445 "%s:%d select() failed, with errno %d (%s)\n", Y, Z, \
446 sockerr, curlx_strerror(sockerr, sockerrbuf, \
447 sizeof(sockerrbuf))); \
448 result = TEST_ERR_SELECT; \
449 } \
450 } while(0)
452#define res_select_test(A, B, C, D, E) \
453 exe_select_test(A, B, C, D, E, __FILE__, __LINE__)
455#define chk_select_test(A, B, C, D, E, Y, Z) \
456 do { \
457 exe_select_test(A, B, C, D, E, Y, Z); \
458 if(result) \
459 goto test_cleanup; \
460 } while(0)
462#define select_test(A, B, C, D, E) \
463 chk_select_test(A, B, C, D, E, __FILE__, __LINE__)
465/* ---------------------------------------------------------------- */
467#define start_test_timing() \
468 do { \
469 tv_test_start = curlx_now(); \
470 } while(0)
472#define TEST_HANG_TIMEOUT (60 * 1000) /* global default */
474#define exe_test_timedout(T, Y, Z) \
475 do { \
476 timediff_t timediff = curlx_timediff_ms(curlx_now(), tv_test_start); \
477 if(timediff > (T)) { \
478 curl_mfprintf(stderr, \
479 "%s:%d ABORTING TEST, since it seems " \
480 "that it would have run forever (%ld ms > %ld ms)\n", \
481 Y, Z, (long)timediff, (long)TEST_HANG_TIMEOUT); \
482 result = TEST_ERR_RUNS_FOREVER; \
483 } \
484 } while(0)
486#define res_test_timedout() \
487 exe_test_timedout(TEST_HANG_TIMEOUT, __FILE__, __LINE__)
489#define chk_test_timedout(T, Y, Z) \
490 do { \
491 exe_test_timedout(T, Y, Z); \
492 if(result) \
493 goto test_cleanup; \
494 } while(0)
496#define abort_on_test_timeout() \
497 chk_test_timedout(TEST_HANG_TIMEOUT, __FILE__, __LINE__)
499#define abort_on_test_timeout_custom(T) \
500 chk_test_timedout(T, __FILE__, __LINE__)
502#define NUM_HANDLES 4 /* global default */
504#define res_global_init(A) \
505 exe_global_init(A, __FILE__, __LINE__)
507#endif /* !UNITTESTS */
509#if !defined(UNITTESTS) || defined(BUILDING_LIBCURL)
511/* ---------------------------------------------------------------- */
513#define exe_global_init(A, Y, Z) \
514 do { \
515 result = curl_global_init(A); \
516 if(result) \
517 curl_mfprintf(stderr, \
518 "%s:%d curl_global_init() failed, " \
519 "with code %d (%s)\n", \
520 Y, Z, (int)result, curl_easy_strerror(result)); \
521 } while(0)
523#define chk_global_init(A, Y, Z) \
524 do { \
525 exe_global_init(A, Y, Z); \
526 if(result) \
527 return result; \
528 } while(0)
530/* global_init() is different than other macros. In case of
531 failure it 'return's instead of going to 'test_cleanup'. */
533#define global_init(A) \
534 chk_global_init(A, __FILE__, __LINE__)
536#endif /* !UNITTESTS || BUILDING_LIBCURL */
538#endif /* HEADER_LIBTEST_FIRST_H */
Diagnostics4 git calls · 37 ms
CallStatusSizeTime037 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=4
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2004.6 KiB · hit31 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=31
git.response.bytes=4695
git.response.cache=HIT
git.response.duration_ms=31
git.fetch.wants=d5a3ec45fde0e0a96c2f15922d43a2f1e3da9720
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=4695
git.pkt.payload.max=4674
git.sideband.band1.bytes=4673
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e2ea8bffee4bc2
Request
4a8c2bb7…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format