master
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-table.h"
27#include "curl_trc.h"
29#define TBL_SIZE 100
31static CURLcode t3212_setup(struct uint32_tbl *tbl)
32{
33 Curl_uint32_tbl_init(tbl);
34 return Curl_uint32_tbl_resize(tbl, TBL_SIZE);
35}
37static void t3212_stop(struct uint32_tbl *tbl)
38{
39 Curl_uint32_tbl_destroy(tbl);
40}
42static CURLcode test_unit3212(const char *arg)
43{
44 struct uint32_tbl tbl;
45 int dummy;
47 UNITTEST_BEGIN(t3212_setup(&tbl))
49 uint32_t i, key, n;
50 void *entry;
52 fail_unless(Curl_uint32_tbl_capacity(&tbl) == TBL_SIZE, "wrong capacity");
54 for(i = 0; i < TBL_SIZE; ++i) {
55 fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add");
56 fail_unless(key == i, "unexpected key assigned");
57 }
58 /* table should be full now */
59 fail_unless(Curl_uint32_tbl_count(&tbl) == TBL_SIZE, "wrong count");
60 fail_unless(!Curl_uint32_tbl_add(&tbl, &dummy, &key), "could add more");
61 /* remove every 2nd entry, from full table */
62 n = TBL_SIZE;
63 for(i = 0; i < TBL_SIZE; i += 2) {
64 Curl_uint32_tbl_remove(&tbl, i);
65 --n;
66 fail_unless(Curl_uint32_tbl_count(&tbl) == n, "wrong count after remove");
67 }
68 /* remove same again, should not change count */
69 for(i = 0; i < TBL_SIZE; i += 2) {
70 Curl_uint32_tbl_remove(&tbl, i);
71 fail_unless(Curl_uint32_tbl_count(&tbl) == n, "wrong count after remove");
72 }
73 /* still contains all odd entries */
74 for(i = 1; i < TBL_SIZE; i += 2) {
75 fail_unless(Curl_uint32_tbl_contains(&tbl, i), "does not contain");
76 fail_unless(Curl_uint32_tbl_get(&tbl, i) == &dummy,
77 "does not contain dummy");
78 }
79 /* get the first key */
80 fail_unless(Curl_uint32_tbl_first(&tbl, &key, &entry), "first failed");
81 fail_unless(key == 1, "unexpected first key");
82 fail_unless(entry == &dummy, "unexpected first entry");
83 /* get the second key */
84 fail_unless(Curl_uint32_tbl_next(&tbl, 1, &key, &entry), "next1 failed");
85 fail_unless(key == 3, "unexpected second key");
86 fail_unless(entry == &dummy, "unexpected second entry");
87 /* get the key after 42 */
88 fail_unless(Curl_uint32_tbl_next(&tbl, 42, &key, &entry), "next42 failed");
89 fail_unless(key == 43, "unexpected next42 key");
90 fail_unless(entry == &dummy, "unexpected next42 entry");
92 /* double capacity */
93 n = Curl_uint32_tbl_count(&tbl);
94 fail_unless(!Curl_uint32_tbl_resize(&tbl, TBL_SIZE * 2),
95 "error doubling size");
96 fail_unless(Curl_uint32_tbl_count(&tbl) == n, "wrong resize count");
97 /* resize to half of original */
98 fail_unless(!Curl_uint32_tbl_resize(&tbl, TBL_SIZE / 2),
99 "error halving size");
100 fail_unless(Curl_uint32_tbl_count(&tbl) == n / 2, "wrong half size count");
101 for(i = 1; i < TBL_SIZE / 2; i += 2) {
102 fail_unless(Curl_uint32_tbl_contains(&tbl, i), "does not contain");
103 fail_unless(Curl_uint32_tbl_get(&tbl, i) == &dummy,
104 "does not contain dummy");
105 }
106 /* clear */
107 uint32_tbl_clear(&tbl);
108 fail_unless(!Curl_uint32_tbl_count(&tbl), "count not 0 after clear");
109 for(i = 0; i < TBL_SIZE / 2; ++i) {
110 fail_unless(!Curl_uint32_tbl_contains(&tbl, i),
111 "does contain, should not");
112 }
113 /* add after clear gets key 0 again */
114 fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add");
115 fail_unless(key == 0, "unexpected key assigned");
116 /* remove it again and add, should get key 1 */
117 Curl_uint32_tbl_remove(&tbl, key);
118 fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add");
119 fail_unless(key == 1, "unexpected key assigned");
120 /* clear, fill, remove one, add, should get the removed key again */
121 uint32_tbl_clear(&tbl);
122 for(i = 0; i < Curl_uint32_tbl_capacity(&tbl); ++i)
123 fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add");
124 fail_unless(!Curl_uint32_tbl_add(&tbl, &dummy, &key), "add on full");
125 Curl_uint32_tbl_remove(&tbl, 17);
126 fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add again");
127 fail_unless(key == 17, "unexpected key assigned");
128 /* and again, triggering key search wrap around */
129 Curl_uint32_tbl_remove(&tbl, 17);
130 fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add again");
131 fail_unless(key == 17, "unexpected key assigned");
133 UNITTEST_END(t3212_stop(&tbl))
134}
Diagnostics4 git calls · 207 ms
CallStatusSizeTime0207 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 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 · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 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 · hit20 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=20 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=86Open pack map
fetch2001.6 KiB185 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=185 git.response.bytes=1606 git.response.cache=MISS git.response.duration_ms=185 git.fetch.wants=a30830b0e94fb066000b1c0df7dd8cea2d70c32a 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=1606 git.pkt.payload.max=1585 git.sideband.band1.bytes=1584 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
- a5e318b54a563e6e
- Request
- ace61b4b…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format