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 "llist.h"
27static void test_Curl_llist_dtor(void *key, void *value)
28{
29 /* used by the llist API, does nothing here */
30 (void)key;
31 (void)value;
32}
34static CURLcode test_unit1300(const char *arg)
35{
36 UNITTEST_BEGIN_SIMPLE
38 struct Curl_llist llist;
39 struct Curl_llist llist_destination;
41 int unusedData_case1 = 1;
42 int unusedData_case2 = 2;
43 int unusedData_case3 = 3;
44 struct Curl_llist_node case1_list;
45 struct Curl_llist_node case2_list;
46 struct Curl_llist_node case3_list;
47 struct Curl_llist_node case4_list;
48 struct Curl_llist_node *head;
49 struct Curl_llist_node *element_next;
50 struct Curl_llist_node *element_prev;
51 struct Curl_llist_node *to_remove;
52 size_t llist_size;
54 Curl_llist_init(&llist, test_Curl_llist_dtor);
55 Curl_llist_init(&llist_destination, test_Curl_llist_dtor);
57 /**
58 * testing llist_init
59 * case 1:
60 * list initiation
61 * @assumptions:
62 * 1: list size is 0
63 * 2: list head is NULL
64 * 3: list tail is NULL
65 * 4: list dtor is NULL
66 */
68 fail_unless(Curl_llist_count(&llist) == 0,
69 "list initial size should be zero");
70 fail_unless(!Curl_llist_head(&llist),
71 "list head should initiate to NULL");
72 fail_unless(!llist_tail(&llist),
73 "list tail should initiate to NULL");
75 /**
76 * testing llist_insert_next
77 * case 1:
78 * list is empty
79 * @assumptions:
80 * 1: list size is 1
81 * 2: list head holds the data "unusedData_case1"
82 * 3: list tail is the same as list head
83 */
85 llist_insert_next(&llist, Curl_llist_head(&llist), &unusedData_case1,
86 &case1_list);
88 fail_unless(Curl_llist_count(&llist) == 1,
89 "List size should be 1 after adding a new element");
90 /* test that the list head data holds my unusedData */
91 fail_unless(Curl_node_elem(Curl_llist_head(&llist)) == &unusedData_case1,
92 "head ptr should be first entry");
93 /* same goes for the list tail */
94 fail_unless(llist_tail(&llist) == Curl_llist_head(&llist),
95 "tail and head should be the same");
97 /**
98 * testing llist_insert_next
99 * case 2:
100 * list has 1 element, adding one element after the head
101 * @assumptions:
102 * 1: the element next to head should be our newly created element
103 * 2: the list tail should be our newly created element
104 */
106 llist_insert_next(&llist, Curl_llist_head(&llist),
107 &unusedData_case3, &case3_list);
108 fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
109 &unusedData_case3,
110 "the node next to head is not getting set correctly");
111 fail_unless(Curl_node_elem(llist_tail(&llist)) == &unusedData_case3,
112 "the list tail is not getting set correctly");
114 /**
115 * testing llist_insert_next
116 * case 3:
117 * list has >1 element, adding one element after "NULL"
118 * @assumptions:
119 * 1: the element next to head should be our newly created element
120 * 2: the list tail should different from newly created element
121 */
123 llist_insert_next(&llist, Curl_llist_head(&llist),
124 &unusedData_case2, &case2_list);
125 fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
126 &unusedData_case2,
127 "the node next to head is not getting set correctly");
128 /* better safe than sorry, check that the tail is not corrupted */
129 fail_unless(Curl_node_elem(llist_tail(&llist)) != &unusedData_case2,
130 "the list tail is not getting set correctly");
132 /* unit tests for Curl_node_remove */
134 /**
135 * case 1:
136 * list has >1 element, removing head
137 * @assumptions:
138 * 1: list size is decremented by one
139 * 2: head is head->next
140 * 3: "new" head's previous is NULL
141 */
143 head = Curl_llist_head(&llist);
144 abort_unless(head, "llist.head is NULL");
145 element_next = Curl_node_next(head);
146 llist_size = Curl_llist_count(&llist);
148 Curl_node_remove(Curl_llist_head(&llist));
150 fail_unless(Curl_llist_count(&llist) == (llist_size - 1),
151 "llist size not decremented as expected");
152 fail_unless(Curl_llist_head(&llist) == element_next,
153 "llist new head not modified properly");
154 abort_unless(Curl_llist_head(&llist), "llist.head is NULL");
155 fail_unless(!llist_node_prev(Curl_llist_head(&llist)),
156 "new head previous not set to null");
158 /**
159 * case 2:
160 * removing non head element, with list having >=2 elements
161 * @setup:
162 * 1: insert another element to the list to make element >=2
163 * @assumptions:
164 * 1: list size is decremented by one ; tested
165 * 2: element->previous->next is element->next
166 * 3: element->next->previous is element->previous
167 */
168 llist_insert_next(&llist, Curl_llist_head(&llist), &unusedData_case3,
169 &case4_list);
170 llist_size = Curl_llist_count(&llist);
171 fail_unless(llist_size == 3, "should be 3 list members");
173 to_remove = Curl_node_next(Curl_llist_head(&llist));
174 abort_unless(to_remove, "to_remove is NULL");
175 element_next = Curl_node_next(to_remove);
176 element_prev = llist_node_prev(to_remove);
177 Curl_node_remove(to_remove);
178 fail_unless(Curl_node_next(element_prev) == element_next,
179 "element previous->next is not being adjusted");
180 abort_unless(element_next, "element_next is NULL");
181 fail_unless(llist_node_prev(element_next) == element_prev,
182 "element next->previous is not being adjusted");
184 /**
185 * case 3:
186 * removing the tail with list having >=1 element
187 * @assumptions
188 * 1: list size is decremented by one ;tested
189 * 2: element->previous->next is element->next ;tested
190 * 3: element->next->previous is element->previous ;tested
191 * 4: list->tail is tail->previous
192 */
194 to_remove = llist_tail(&llist);
195 element_prev = llist_node_prev(to_remove);
196 Curl_node_remove(to_remove);
197 fail_unless(llist_tail(&llist) == element_prev,
198 "llist tail is not being adjusted when removing tail");
200 /**
201 * case 4:
202 * removing head with list having 1 element
203 * @assumptions:
204 * 1: list size is decremented by one ;tested
205 * 2: list head is NULL
206 * 3: list tail is NULL
207 */
209 to_remove = Curl_llist_head(&llist);
210 Curl_node_remove(to_remove);
211 fail_unless(!Curl_llist_head(&llist),
212 "llist head is not NULL while the llist is empty");
213 fail_unless(!llist_tail(&llist),
214 "llist tail is not NULL while the llist is empty");
216 /**
217 * testing Curl_llist_append
218 * case 1:
219 * list is empty
220 * @assumptions:
221 * 1: the element next to head should be our newly created element
222 * 2: the list tail should different from newly created element
223 */
224 Curl_llist_append(&llist, &unusedData_case1, &case1_list);
225 fail_unless(Curl_llist_count(&llist) == 1,
226 "List size should be 1 after appending a new element");
227 /* test that the list head data holds my unusedData */
228 fail_unless(Curl_node_elem(Curl_llist_head(&llist)) == &unusedData_case1,
229 "head ptr should be first entry");
230 /* same goes for the list tail */
231 fail_unless(llist_tail(&llist) == Curl_llist_head(&llist),
232 "tail and head should be the same");
234 /**
235 * testing Curl_llist_append
236 * case 2:
237 * list is not empty
238 * @assumptions:
239 * 1: the list head-next should be the newly created element
240 * 2: the list tail should be the newly created element
241 */
242 Curl_llist_append(&llist, &unusedData_case2, &case2_list);
243 fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
244 &unusedData_case2,
245 "the node next to head is not getting set correctly");
246 fail_unless(Curl_node_elem(llist_tail(&llist)) == &unusedData_case2,
247 "the list tail is not getting set correctly");
249 /**
250 * testing Curl_llist_append
251 * case 3:
252 * list is has 2 members
253 * @assumptions:
254 * 1: the list head-next should remain the same
255 * 2: the list tail should be the newly created element
256 */
257 Curl_llist_append(&llist, &unusedData_case3, &case3_list);
258 fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
259 &unusedData_case2,
260 "the node next to head did not stay the same");
261 fail_unless(Curl_node_elem(llist_tail(&llist)) == &unusedData_case3,
262 "the list tail is not getting set correctly");
264 Curl_llist_destroy(&llist, NULL);
265 Curl_llist_destroy(&llist_destination, NULL);
267 UNITTEST_END_SIMPLE
268}
Diagnostics4 git calls · 48 ms
CallStatusSizeTime048 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 · hit4 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=4 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
fetch2002.3 KiB · hit42 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=42 git.response.bytes=2340 git.response.cache=HIT git.response.duration_ms=42 git.fetch.wants=bd7be156bda7a0581bee36211bc4ab1e357a92b7 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=2340 git.pkt.payload.max=2319 git.sideband.band1.bytes=2318 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
- a5e2faf6484d90c0
- Request
- ef2d0743…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format