Artifactspublic-v0

curl

master
ply4 git calls181 ms290 KiB2 cachedprotocol v2
348 lines12 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 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 https://curl.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 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
25#include "urldata.h"
26#include "uint-bset.h"
27#include "u8_strset.h"
28#include "u32_ptrset.h"
29#include "ptrarray.h"
30#include "curl_trc.h"
32static void t3211_check_bset(const char *name, uint32_t capacity,
33 const uint32_t *s, size_t slen)
35 struct uint32_bset bset;
36 size_t i, j;
37 uint32_t n, c;
39 curl_mfprintf(stderr, "test %s, capacity=%u, %zu numbers\n",
40 name, capacity, slen);
41 Curl_uint32_bset_init(&bset);
42 fail_unless(!Curl_uint32_bset_resize(&bset, capacity), "bset resize failed");
43 c = uint32_bset_capacity(&bset);
44 fail_unless(c == (((capacity + 63) / 64) * 64), "wrong capacity");
46 Curl_uint32_bset_clear(&bset);
47 c = Curl_uint32_bset_count(&bset);
48 fail_unless(c == 0, "set count is not 0");
50 for(i = 0; i < slen; ++i) { /* add all */
51 fail_unless(Curl_uint32_bset_add(&bset, s[i]), "failed to add");
52 for(j = i + 1; j < slen; ++j)
53 fail_unless(!Curl_uint32_bset_contains(&bset, s[j]),
54 "unexpectedly found");
55 }
57 for(i = 0; i < slen; ++i) { /* all present */
58 fail_unless(Curl_uint32_bset_contains(&bset, s[i]),
59 "failed presence check");
60 }
62 /* iterator over all numbers */
63 fail_unless(Curl_uint32_bset_first(&bset, &n), "first failed");
64 fail_unless(n == s[0], "first not correct number");
65 for(i = 1; i < slen; ++i) {
66 fail_unless(Curl_uint32_bset_next(&bset, n, &n), "next failed");
67 if(n != s[i]) {
68 curl_mfprintf(stderr, "expected next to be %u, not %u\n", s[i], n);
69 fail_unless(n == s[i], "next not correct number");
70 }
71 }
73 /* Adding capacity number does not work (0 - capacity-1) */
74 c = uint32_bset_capacity(&bset);
75 fail_unless(!Curl_uint32_bset_add(&bset, c), "add out of range worked");
76 /* The count it correct */
77 c = Curl_uint32_bset_count(&bset);
78 fail_unless(c == slen, "set count is wrong");
80 for(i = 0; i < slen; i += 2) { /* remove every 2nd */
81 Curl_uint32_bset_remove(&bset, s[i]);
82 fail_unless(!Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly found");
83 }
84 for(i = 1; i < slen; i += 2) { /* others still there */
85 fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly gone");
86 }
87 /* The count is half */
88 c = Curl_uint32_bset_count(&bset);
89 fail_unless(c == slen / 2, "set count is wrong");
91 Curl_uint32_bset_clear(&bset);
92 c = Curl_uint32_bset_count(&bset);
93 fail_unless(c == 0, "set count is not 0");
94 for(i = 0; i < slen; i++) { /* none present any longer */
95 fail_unless(!Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly there");
96 }
98 for(i = 0; i < slen; ++i) { /* add all again */
99 fail_unless(Curl_uint32_bset_add(&bset, s[i]), "failed to add");
100 }
102 fail_unless(!Curl_uint32_bset_resize(&bset, capacity * 2),
103 "resize double failed");
104 for(i = 0; i < slen; i++) { /* all still present after resize */
105 fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost");
106 }
108 fail_unless(!Curl_uint32_bset_resize(&bset, capacity), "resize back failed");
109 for(i = 0; i < slen; i++) /* all still present after resize back */
110 fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost");
112 fail_unless(!Curl_uint32_bset_resize(&bset, capacity / 2),
113 "resize half failed");
114 /* halved the size, what numbers remain in set? */
115 c = uint32_bset_capacity(&bset);
116 n = 0;
117 for(i = 0; i < slen; ++i) {
118 if(s[i] < c)
119 ++n;
120 }
121 fail_unless(n == Curl_uint32_bset_count(&bset), "set count(halved) wrong");
122 for(i = 0; i < n; i++) /* still present after resize half */
123 fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost");
125 Curl_uint32_bset_destroy(&bset);
128static bool t3211_strcmp(const char *s1, const char *s2)
130 if(s1 && s2)
131 return strcmp(s1, s2);
132 return s1 == s2;
135static void t3211_check_u8_strset(void)
137 struct u8_strset set;
138 char buf[128];
139 CURLcode result;
140 uint8_t i, idx;
141 int j;
143 Curl_u8_strset_init(&set);
144 fail_unless(!Curl_u8_strset_count(&set), "initial strset not empty");
146 result = u8_strset_set(&set, 0, "123");
147 fail_unless(!result, "add1 failed");
148 fail_unless(Curl_u8_strset_get(&set, 0), "get failed");
149 fail_unless(!t3211_strcmp("123", Curl_u8_strset_get(&set, 0)), "wrong get1");
150 result = u8_strset_set(&set, 0, "456");
151 fail_unless(!result, "add2 failed");
152 fail_unless(!t3211_strcmp("456", Curl_u8_strset_get(&set, 0)), "wrong get2");
153 Curl_u8_strset_unset(&set, 0);
154 fail_unless(!Curl_u8_strset_get(&set, 0), "unset failed");
156 /* Initial size is 8, add 8 hash collisions */
157 for(i = 0; i < 8; ++i) {
158 idx = (uint8_t)((8 * i) + 3);
159 curl_msnprintf(buf, sizeof(buf), "str-%d", idx);
160 result = u8_strset_set(&set, idx, buf);
161 fail_unless(!result, "loop4-add failed");
162 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, idx)),
163 "wrong get loop4");
164 }
166 /* Remove collided entry 2, check again */
167 idx = (uint8_t)((8 * 2) + 3);
168 Curl_u8_strset_unset(&set, idx);
169 fail_unless(!Curl_u8_strset_get(&set, idx), "unset2 failed");
170 for(i = 0; i < 8; ++i) {
171 if(i == 2)
172 continue;
173 idx = (uint8_t)((8 * i) + 3);
174 curl_msnprintf(buf, sizeof(buf), "str-%d", idx);
175 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, idx)),
176 "wrong get loop6");
177 }
179 /* Add entry 2 again, check */
180 idx = (uint8_t)((8 * 2) + 3);
181 curl_msnprintf(buf, sizeof(buf), "str-%d", idx);
182 result = u8_strset_set(&set, idx, buf);
183 fail_unless(!result, "re-add 2 failed");
184 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, idx)),
185 "wrong re-add 2 get");
186 for(i = 0; i < 8; ++i) {
187 idx = (uint8_t)((8 * i) + 3);
188 curl_msnprintf(buf, sizeof(buf), "str-%d", idx);
189 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, idx)),
190 "wrong get loop6");
191 }
193 /* Add a 9th, set grows */
194 fail_unless(Curl_u8_strset_count(&set) == 8, "wrong count pre add 5");
195 idx = (uint8_t)((9 * 4) + 3);
196 curl_msnprintf(buf, sizeof(buf), "str-%d", idx);
197 result = u8_strset_set(&set, idx, buf);
198 fail_unless(!result, "add4 failed");
199 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, idx)),
200 "wrong get4");
201 for(i = 0; i < 9; ++i) {
202 idx = (uint8_t)((8 * i) + 3);
203 curl_msnprintf(buf, sizeof(buf), "str-%d", idx);
204 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, idx)),
205 "wrong get loop5");
206 }
207 fail_unless(Curl_u8_strset_count(&set) == 9, "wrong count after add 5");
209 Curl_u8_strset_clear(&set);
211 /* Make a full set */
212 for(j = 0; j <= UINT8_MAX; ++j) {
213 i = (uint8_t)j;
214 curl_msnprintf(buf, sizeof(buf), "str-%d", i);
215 result = u8_strset_set(&set, i, buf);
216 fail_unless(!result, "loop256-add failed");
217 fail_unless(!t3211_strcmp(buf, Curl_u8_strset_get(&set, i)),
218 "wrong get loop256");
219 }
221 Curl_u8_strset_clear(&set);
222 fail_unless(!Curl_u8_strset_count(&set), "cleared strset not empty");
225static void t3211_check_u32_ptrset(void)
227 struct u32_ptrset set;
228 CURLcode result;
229 uint32_t i, idx;
231 Curl_u32_ptrset_init(&set, NULL);
232 fail_unless(!Curl_u32_ptrset_count(&set), "initial ptrset not empty");
234 result = Curl_u32_ptrset_set(&set, 0, CURL_UNCONST("123"));
235 fail_unless(!result, "ptrset add1 failed");
236 fail_unless(Curl_u32_ptrset_get(&set, 0), "ptrset get failed");
237 fail_unless(!t3211_strcmp("123", Curl_u32_ptrset_get(&set, 0)),
238 "ptrset wrong get1");
239 result = Curl_u32_ptrset_set(&set, 0, CURL_UNCONST("456"));
240 fail_unless(!result, "add2 failed");
241 fail_unless(!t3211_strcmp("456", Curl_u32_ptrset_get(&set, 0)),
242 "ptrset wrong get2");
243 Curl_u32_ptrset_unset(&set, 0);
244 fail_unless(!Curl_u32_ptrset_get(&set, 0), "ptrset unset failed");
246 /* Initial size is 64, add 64 hash collisions */
247 for(i = 0; i < 64; ++i) {
248 idx = (uint32_t)((64 * i) + 3);
249 result = Curl_u32_ptrset_set(&set, idx, CURL_UNCONST("loop64"));
250 fail_unless(!result, "ptrset loop64 add failed");
251 fail_unless(!t3211_strcmp("loop64", Curl_u32_ptrset_get(&set, idx)),
252 "ptrset wrong get loop64");
253 }
255 /* Remove collided entry 2, check again */
256 idx = (uint32_t)((64 * 2) + 3);
257 Curl_u32_ptrset_unset(&set, idx);
258 fail_unless(!Curl_u32_ptrset_get(&set, idx), "ptrset unset2 failed");
260 /* Add entry 2 again, check */
261 idx = (uint8_t)((64 * 2) + 3);
262 result = Curl_u32_ptrset_set(&set, idx, CURL_UNCONST("loop64b"));
263 fail_unless(!result, "ptrset re-add 2 failed");
264 fail_unless(!t3211_strcmp("loop64b", Curl_u32_ptrset_get(&set, idx)),
265 "ptrset wrong re-add 2 get");
267 /* Add a 65th, set grows */
268 fail_unless(Curl_u32_ptrset_count(&set) == 64,
269 "ptrset wrong count pre add 5");
270 idx = (uint32_t)((65 * 4) + 3);
271 result = Curl_u32_ptrset_set(&set, idx, CURL_UNCONST("add65"));
272 fail_unless(!result, "ptrset add65 failed");
273 fail_unless(!t3211_strcmp("add65", Curl_u32_ptrset_get(&set, idx)),
274 "ptrset wrong result after add65");
275 fail_unless(Curl_u32_ptrset_count(&set) == 65, "wrong count after add65");
277 Curl_u32_ptrset_clear(&set);
278 fail_unless(!Curl_u32_ptrset_count(&set), "ptrset cleared not empty");
281static void t3211_check_ptrarray(void)
283 struct ptrarray pa;
284 CURLcode result;
285 char d0 = '0', d1 = '1';
286 uint32_t i;
288 Curl_ptrarray_init(&pa);
289 fail_unless(!ptrarray_count(&pa), "ptrarray init not empty");
291 result = Curl_ptrarray_add(&pa, &d0);
292 fail_unless(!result, "ptrarray add0 failed");
293 fail_unless(ptrarray_get(&pa, 0) == &d0, "ptrarray get0 failed");
294 fail_unless(ptrarray_count(&pa) == 1, "ptrarray add0 count wrong");
295 result = Curl_ptrarray_add(&pa, &d1);
296 fail_unless(!result, "ptrarray add1 failed");
297 fail_unless(ptrarray_get(&pa, 1) == &d1, "ptrarray get1 failed");
298 fail_unless(ptrarray_count(&pa) == 2, "ptrarray add1 count wrong");
299 Curl_ptrarray_remove(&pa, 0);
300 fail_unless(ptrarray_count(&pa) == 1, "ptrarray rem count wrong");
301 fail_unless(ptrarray_get(&pa, 1) == NULL, "ptrarray rem+get1 not NULL");
302 fail_unless(ptrarray_get(&pa, 0) == &d1, "ptrarray rem+get0 failed");
303 Curl_ptrarray_remove(&pa, 0);
304 fail_unless(ptrarray_count(&pa) == 0, "ptrarray rem2 count wrong");
306 for(i = 0; i < 300; ++i) {
307 result = Curl_ptrarray_add(&pa, (i & 0x1) ? &d1 : &d0);
308 fail_unless(!result, "ptrarray loop add failed");
309 }
310 fail_unless(ptrarray_count(&pa) == 300, "ptrarray loop count wrong");
311 for(i = 0; i < 300; ++i) {
312 fail_unless(ptrarray_get(&pa, i) == ((i & 0x1) ? &d1 : &d0),
313 "ptrarray loop get failed");
314 }
316 ptrarray_clear(&pa);
317 fail_unless(!ptrarray_count(&pa), "ptrarray clear not empty");
320static CURLcode test_unit3211(const char *arg)
322 UNITTEST_BEGIN_SIMPLE
324 static const uint32_t s1[] = {
325 /* spread numbers, some at slot edges */
326 0, 1, 4, 17, 63, 64, 65, 66, 90, 99,
327 };
328 static const uint32_t s2[] = {
329 /* set with all bits in slot1 set */
330 64, 65, 66, 67, 68, 69, 70, 71,
331 72, 73, 74, 75, 76, 77, 78, 79,
332 80, 81, 82, 83, 84, 85, 86, 87,
333 88, 89, 90, 91, 92, 93, 94, 95,
334 96, 97, 98, 99, 100, 101, 102, 103,
335 104, 105, 106, 107, 108, 109, 110, 111,
336 112, 113, 114, 115, 116, 117, 118, 119,
337 120, 121, 122, 123, 124, 125, 126, 127,
338 };
340 t3211_check_bset("s1", 100, s1, CURL_ARRAYSIZE(s1));
341 t3211_check_bset("s2", 1000, s2, CURL_ARRAYSIZE(s2));
343 t3211_check_u8_strset();
344 t3211_check_u32_ptrset();
345 t3211_check_ptrarray();
347 UNITTEST_END_SIMPLE
Diagnostics4 git calls · 181 ms
CallStatusSizeTime0181 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
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 · hit25 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=25
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
fetch2002.9 KiB152 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=152
git.response.bytes=2951
git.response.cache=MISS
git.response.duration_ms=152
git.fetch.wants=4519e5e5e27bf2e2e76ca3476246f06dca64f451
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=2951
git.pkt.payload.max=2930
git.sideband.band1.bytes=2929
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
a5e2e82d4ecdecfa
Request
08e9b736…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format