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 "tool_getparam.h"
26#include "tool_paramhlp.h"
28struct check1623 {
29 const char *input;
30 curl_off_t amount;
31 ParameterError err;
32};
34struct secs1623 {
35 const char *input;
36 long ms;
37 ParameterError err;
38};
40static CURLcode test_tool1623(const char *arg)
41{
42 UNITTEST_BEGIN_SIMPLE
44 int i;
45 static const struct check1623 check[] = {
46 { "0", 0, PARAM_OK },
47 { "00", 0, PARAM_OK },
48 { "000", 0, PARAM_OK },
49 { "1", 1, PARAM_OK },
50 { "1b", 1, PARAM_OK },
51 { "99B", 99, PARAM_OK },
52 { "2", 2, PARAM_OK },
53 { "3", 3, PARAM_OK },
54 { "4", 4, PARAM_OK },
55 { "5", 5, PARAM_OK },
56 { "6", 6, PARAM_OK },
57 { "7", 7, PARAM_OK },
58 { "77", 77, PARAM_OK },
59 { "8", 8, PARAM_OK },
60 { "9", 9, PARAM_OK },
61 { "10", 10, PARAM_OK },
62 { "010", 10, PARAM_OK },
63 { "000000000000000000000000000000000010", 10, PARAM_OK },
64 { "1k", 1024, PARAM_OK },
65 { "2K", 2048, PARAM_OK },
66 { "3k", 3072, PARAM_OK },
67 { "4K", 4096, PARAM_OK },
68 { "5k", 5120, PARAM_OK },
69 { "6K", 6144, PARAM_OK },
70 { "7k", 7168, PARAM_OK },
71 { "8K", 8192, PARAM_OK },
72 { "9k", 9216, PARAM_OK },
73 { "10K", 10240, PARAM_OK },
74 { "20M", 20971520, PARAM_OK },
75 { "30G", 32212254720, PARAM_OK },
76 { "40T", 43980465111040, PARAM_OK },
77 { "50P", 56294995342131200, PARAM_OK },
78 { "1.1k", 1126, PARAM_OK },
79 { "1.01k", 1034, PARAM_OK },
80 { "1.001k", 1025, PARAM_OK },
81 { "1.0001k", 1024, PARAM_OK },
82 { "22.1m", 23173529, PARAM_OK },
83 { "22.01m", 23079157, PARAM_OK },
84 { "22.001m", 23069720, PARAM_OK },
85 { "22.0001m", 23068776, PARAM_OK },
86 { "22.00001m", 23068682, PARAM_OK },
87 { "22.000001m", 23068673, PARAM_OK },
88 { "22.0000001m", 23068672, PARAM_OK },
89 { "22.000000001m", 23068672, PARAM_OK },
90 { "3.4", 0, PARAM_BAD_USE },
91 { "3.14b", 0, PARAM_BAD_USE },
92 { "5000.9P", 5630512844129278361, PARAM_OK },
93 { "5000.99P", 5630614175120894197, PARAM_OK },
94 { "5000.999P", 5630624308220055781, PARAM_OK },
95 { "5000.9999P", 5630625321529969316, PARAM_OK },
96 { "8191P", 9222246136947933184, PARAM_OK },
97 { "8191.9999999P", 9223372036735343194, PARAM_OK },
98 { "8192P", 0, PARAM_NUMBER_TOO_LARGE },
99 { "9223372036854775807", 9223372036854775807, PARAM_OK },
100 { "9223372036854775808", 0, PARAM_NUMBER_TOO_LARGE },
101 { "a", 0, PARAM_BAD_NUMERIC },
102 { "-2", 0, PARAM_BAD_NUMERIC },
103 { "+2", 0, PARAM_BAD_NUMERIC },
104 { "2,2k", 0, PARAM_BAD_USE },
105 { NULL, 0, PARAM_OK } /* end of list */
106 };
107 static const struct secs1623 secs[] = {
108#if SIZEOF_LONG > 4
109 { "9223372036854774", 9223372036854774000, PARAM_OK },
110 { "00000000000000000009223372036854774", 9223372036854774000, PARAM_OK },
111 { "9223372036854775", 0, PARAM_BAD_NUMERIC },
112 { "9223372036854780", 0, PARAM_BAD_NUMERIC },
113#endif
114 { "0", 0, PARAM_OK },
115 { "1", 1000, PARAM_OK },
116 { "10", 10000, PARAM_OK },
117 { "1.5", 1500, PARAM_OK },
118 { "0.25", 250, PARAM_OK },
119 { "0.001", 1, PARAM_OK },
120 { "2m", 0, PARAM_BAD_NUMERIC },
121 { "1.5abc", 0, PARAM_BAD_NUMERIC },
122 { "1.", 0, PARAM_BAD_NUMERIC },
123 { "1 ", 0, PARAM_BAD_NUMERIC },
124 { "-4", 0, PARAM_BAD_NUMERIC },
125 { "", 0, PARAM_BAD_NUMERIC },
126 { NULL, 0, PARAM_OK } /* end of list */
127 };
129 for(i = 0; check[i].input; i++) {
130 bool ok = FALSE;
131 curl_off_t output = 0;
132 ParameterError err = GetSizeParameter(check[i].input, &output);
133 if(err != check[i].err)
134 curl_mprintf("'%s' unexpectedly returned %d \n",
135 check[i].input, (int)err);
136 else if(check[i].amount != output)
137 curl_mprintf("'%s' unexpectedly gave %" FMT_OFF_T "\n",
138 check[i].input, output);
139 else {
140#if 0 /* enable for debugging */
141 if(err)
142 curl_mprintf("'%s' returned %d\n", check[i].input, (int)err);
143 else
144 curl_mprintf("'%s' == %" FMT_OFF_T "\n", check[i].input, output);
145#endif
146 ok = TRUE;
147 }
148 if(!ok)
149 unitfail++;
150 }
152 for(i = 0; secs[i].input; i++) {
153 long ms = 0;
154 ParameterError err = secs2ms(&ms, secs[i].input);
155 if(err != secs[i].err) {
156 curl_mprintf("secs2ms('%s') unexpectedly returned %d\n",
157 secs[i].input, (int)err);
158 unitfail++;
159 }
160 else if(!err && (ms != secs[i].ms)) {
161 curl_mprintf("secs2ms('%s') unexpectedly gave %ld\n",
162 secs[i].input, ms);
163 unitfail++;
164 }
165 }
167 UNITTEST_END_SIMPLE
168}
Diagnostics4 git calls · 32 ms
CallStatusSizeTime032 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch 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 · 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 · hit7 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=23 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=7 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.7 KiB · hit23 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1695 git.response.cache=HIT git.response.duration_ms=23 git.fetch.wants=bfb1125d8e5c7a53eba05e50cfcee3ca441be4a2 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=1695 git.pkt.payload.max=1674 git.sideband.band1.bytes=1673 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
- a5e30c197942ee28
- Request
- 5d37f524…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format