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"
26#ifdef CURL_HAVE_DIAG
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wformat"
29#endif
31static CURLcode test_lib1398(const char *arg)
32{
33 UNITTEST_BEGIN_SIMPLE
35 int rc;
36 char buf[3] = { 'b', 'u', 'g' };
37 static const char str[] = "bug";
38 int width = 3;
39 char output[130];
41/* #define curl_msnprintf snprintf */
43 /* negative precision is treated as if omitted */
44 rc = curl_msnprintf(output, sizeof(output), "%.*s", -1, str);
45 fail_unless(rc == 3, "return code should be 3");
46 fail_unless(!strcmp(output, "bug"), "wrong output");
48 rc = curl_msnprintf(output, sizeof(output), "%.*s", -1, "0123456789");
49 fail_unless(rc == 10, "return code should be 10");
50 fail_unless(!strcmp(output, "0123456789"), "wrong output");
52 rc = curl_msnprintf(output, sizeof(output), "%.*s", 0, "0123456789");
53 fail_unless(rc == 0, "return code should be 0");
54 fail_unless(!strcmp(output, ""), "wrong output");
56 rc = curl_msnprintf(output, sizeof(output), "%.*s", -2, str);
57 fail_unless(rc == 3, "return code should be 3");
58 fail_unless(!strcmp(output, "bug"), "wrong output");
60 rc = curl_msnprintf(output, sizeof(output), "%.*d", -3, 10000);
61 fail_unless(rc == 5, "return code should be 5");
62 fail_unless(!strcmp(output, "10000"), "wrong output");
64 rc = curl_msnprintf(output, sizeof(output), "%.*d", 0, 1234567);
65 fail_unless(rc == 7, "return code should be 0");
66 fail_unless(!strcmp(output, "1234567"), "wrong output");
68 /* without a trailing zero */
69 rc = curl_msnprintf(output, 4, "%.*s", width, buf);
70 fail_unless(rc == 3, "return code should be 3");
71 fail_unless(!strcmp(output, "bug"), "wrong output");
73 /* with a trailing zero */
74 rc = curl_msnprintf(output, 4, "%.*s", width, str);
75 fail_unless(rc == 3, "return code should be 3");
76 fail_unless(!strcmp(output, "bug"), "wrong output");
78 width = 2;
79 /* one byte less */
80 rc = curl_msnprintf(output, 4, "%.*s", width, buf);
81 fail_unless(rc == 2, "return code should be 2");
82 fail_unless(!strcmp(output, "bu"), "wrong output");
84 /* string with larger precision */
85 rc = curl_msnprintf(output, 8, "%.8s", str);
86 fail_unless(rc == 3, "return code should be 3");
87 fail_unless(!strcmp(output, "bug"), "wrong output");
89 /* longer string with precision */
90 rc = curl_msnprintf(output, 8, "%.3s", "0123456789");
91 fail_unless(rc == 3, "return code should be 3");
92 fail_unless(!strcmp(output, "012"), "wrong output");
94 /* negative width */
95 rc = curl_msnprintf(output, 8, "%-8s", str);
96 fail_unless(rc == 7, "return code should be 7");
97 fail_unless(!strcmp(output, "bug "), "wrong output");
99 /* larger width that string length */
100 rc = curl_msnprintf(output, 8, "%8s", str);
101 fail_unless(rc == 7, "return code should be 7");
102 fail_unless(!strcmp(output, " bu"), "wrong output");
104 /* output a number in a limited output */
105 rc = curl_msnprintf(output, 4, "%d", 10240);
106 fail_unless(rc == 3, "return code should be 3");
107 fail_unless(!strcmp(output, "102"), "wrong output");
109 /* padded strings */
110 rc = curl_msnprintf(output, 16, "%8s%8s", str, str);
111 fail_unless(rc == 15, "return code should be 15");
112 fail_unless(!strcmp(output, " bug bu"), "wrong output");
114 /* padded numbers */
115 rc = curl_msnprintf(output, 16, "%8d%8d", 1234, 5678);
116 fail_unless(rc == 15, "return code should be 15");
117 fail_unless(!strcmp(output, " 1234 567"), "wrong output");
119#if defined(__clang__) && \
120 (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1))
121#pragma clang diagnostic push
122#pragma clang diagnostic ignored "-Wformat-non-iso"
123#endif
124 /* double precision */
125 rc = curl_msnprintf(output, 24, "%2$.*1$.99d", 3, 5678);
126 fail_unless(rc == 0, "return code should be 0");
127#if defined(__clang__) && \
128 (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1))
129#pragma clang diagnostic pop
130#endif
132 /* 129 input % flags */
133 rc = curl_msnprintf(output, 130,
134 "%s%s%s%s%s%s%s%s%s%s" /* 10 */
135 "%s%s%s%s%s%s%s%s%s%s" /* 20 */
136 "%s%s%s%s%s%s%s%s%s%s" /* 30 */
137 "%s%s%s%s%s%s%s%s%s%s" /* 40 */
138 "%s%s%s%s%s%s%s%s%s%s" /* 50 */
139 "%s%s%s%s%s%s%s%s%s%s" /* 60 */
140 "%s%s%s%s%s%s%s%s%s%s" /* 70 */
141 "%s%s%s%s%s%s%s%s%s%s" /* 80 */
142 "%s%s%s%s%s%s%s%s%s%s" /* 90 */
143 "%s%s%s%s%s%s%s%s%s%s" /* 100 */
144 "%s%s%s%s%s%s%s%s%s%s" /* 110 */
145 "%s%s%s%s%s%s%s%s%s%s" /* 120 */
146 "%s%s%s%s%s%s%s%s%s", /* 129 */
148 "a", "", "", "", "", "", "", "", "", "", /* 10 */
149 "b", "", "", "", "", "", "", "", "", "", /* 20 */
150 "c", "", "", "", "", "", "", "", "", "", /* 30 */
151 "d", "", "", "", "", "", "", "", "", "", /* 40 */
152 "e", "", "", "", "", "", "", "", "", "", /* 50 */
153 "f", "", "", "", "", "", "", "", "", "", /* 60 */
154 "g", "", "", "", "", "", "", "", "", "", /* 70 */
155 "h", "", "", "", "", "", "", "", "", "", /* 80 */
156 "i", "", "", "", "", "", "", "", "", "", /* 90 */
157 "j", "", "", "", "", "", "", "", "", "", /* 100 */
158 "k", "", "", "", "", "", "", "", "", "", /* 110 */
159 "l", "", "", "", "", "", "", "", "", "", /* 120 */
160 "m", "", "", "", "", "", "", "", "" /* 129 */
161 );
162 fail_unless(rc == 0, "return code should be 0");
164 /* 128 input % flags */
165 rc = curl_msnprintf(output, 130,
166 "%s%s%s%s%s%s%s%s%s%s" /* 10 */
167 "%s%s%s%s%s%s%s%s%s%s" /* 20 */
168 "%s%s%s%s%s%s%s%s%s%s" /* 30 */
169 "%s%s%s%s%s%s%s%s%s%s" /* 40 */
170 "%s%s%s%s%s%s%s%s%s%s" /* 50 */
171 "%s%s%s%s%s%s%s%s%s%s" /* 60 */
172 "%s%s%s%s%s%s%s%s%s%s" /* 70 */
173 "%s%s%s%s%s%s%s%s%s%s" /* 80 */
174 "%s%s%s%s%s%s%s%s%s%s" /* 90 */
175 "%s%s%s%s%s%s%s%s%s%s" /* 100 */
176 "%s%s%s%s%s%s%s%s%s%s" /* 110 */
177 "%s%s%s%s%s%s%s%s%s%s" /* 120 */
178 "%s%s%s%s%s%s%s%s", /* 128 */
180 "a", "", "", "", "", "", "", "", "", "", /* 10 */
181 "b", "", "", "", "", "", "", "", "", "", /* 20 */
182 "c", "", "", "", "", "", "", "", "", "", /* 30 */
183 "d", "", "", "", "", "", "", "", "", "", /* 40 */
184 "e", "", "", "", "", "", "", "", "", "", /* 50 */
185 "f", "", "", "", "", "", "", "", "", "", /* 60 */
186 "g", "", "", "", "", "", "", "", "", "", /* 70 */
187 "h", "", "", "", "", "", "", "", "", "", /* 80 */
188 "i", "", "", "", "", "", "", "", "", "", /* 90 */
189 "j", "", "", "", "", "", "", "", "", "", /* 100 */
190 "k", "", "", "", "", "", "", "", "", "", /* 110 */
191 "l", "", "", "", "", "", "", "", "", "", /* 120 */
192 "m", "", "", "", "", "", "", "" /* 128 */
193 );
194 fail_unless(rc == 13, "return code should be 13");
196 /* 129 output segments */
197 rc = curl_msnprintf(output, 130,
198 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 20 */
199 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 40 */
200 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 60 */
201 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */
202 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */
203 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */
204 "%%%%%%%%%%%%%%%%%%" /* 129 */
205 );
206 fail_unless(rc == 0, "return code should be 0");
208 /* 128 output segments */
209 rc = curl_msnprintf(output, 129,
210 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 20 */
211 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 40 */
212 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 60 */
213 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */
214 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */
215 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */
216 "%%%%%%%%%%%%%%%%" /* 128 */
217 );
218 fail_unless(rc == 128, "return code should be 128");
220 UNITTEST_END_SIMPLE
221}
223#ifdef CURL_HAVE_DIAG
224#pragma GCC diagnostic pop
225#endif
Diagnostics4 git calls · 65 ms
CallStatusSizeTime065 ms
discover200152 B3 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 · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 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 · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=58 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 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 KiB · hit59 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1622 git.response.cache=HIT git.response.duration_ms=59 git.fetch.wants=6fd9cebb04093a28ca6f63159b28101a297ee4fd 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=1622 git.pkt.payload.max=1601 git.sideband.band1.bytes=1600 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
- a5e32e49ec478821
- Request
- 1e3246a7…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format