Artifactspublic-v0

curl

master
ply4 git calls42 ms289 KiB3 cachedprotocol v2
251 lines5.3 KiBexecutableRaw
1#!/usr/bin/env perl
2# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3#
4# SPDX-License-Identifier: curl
5#
6# Input: number of seconds to run.
7#
8# 1. Figure out all existing command line options
9# 2. Generate random command line using supported options
10# 3. Run the command line
11# 4. Verify that it does not return an unexpected return code
12# 5. Iterate until the time runs out
14# Do the same with regular command lines as well as reading the options from a
15# -K config file
17# BEWARE: this may create a large amount of files using random names in the
18# directory where it runs.
21use strict;
22use warnings;
24my $curl = "../src/curl";
25my $url = "localhost:7777"; # not listening to this
27my $seconds = $ARGV[0];
28if($ARGV[1]) {
29 $curl = $ARGV[1];
32if(!$seconds) {
33 $seconds = 10;
35print "Run $curl for $seconds seconds\n";
37my @opt;
38my %arg;
39my %uniq;
40my %allrc;
42my $totalargs = 0;
43my $totalcmds = 0;
45my $counter = 0xabcdef + time();
46sub getnum {
47 my ($max) = @_;
48 return int(rand($max));
51sub storedata {
52 my ($short, $long, $arg) = @_;
53 push @opt, "-$short" if($short);
54 push @opt, "--$long";
56 if($arg =~ /^</) {
57 # these take an argument
58 $arg{"-$short"} = $arg if($short);
59 $arg{"--$long"} = $arg;
60 }
63sub getoptions {
64 my @all = qx($curl --help all);
65 for my $o (@all) {
66 chomp $o;
67 if($o =~ /^ -(.), --([^ ]*) (.*)/) {
68 storedata($1, $2, $3);
69 }
70 elsif($o =~ /^ --([^ ]*) (.*)/) {
71 storedata("", $1, $2);
72 }
73 }
76# this adds a fake randomly generated command line option
77sub addarg {
78 my $nice = "abcdefhijklmnopqrstuvwqxyz" .
79 "ABCDEFHIJKLMNOPQRSTUVWQXYZ" .
80 "0123456789-";
81 my $len = getnum(20) + 2;
82 my $o;
83 for(1 .. $len) {
84 $o .= substr($nice, getnum(length($nice)), 1);
85 }
86 return "--$o";
89sub randarg {
90 my $nice = "abcdefhijklmnopqrstuvwqxyz" .
91 "ABCDEFHIJKLMNOPQRSTUVWQXYZ" .
92 "0123456789" .
93 ",-?#$%!@ ";
94 my $len = getnum(20);
95 my $o = '';
96 for(1 .. $len) {
97 $o .= substr($nice, getnum(length($nice)), 1);
98 }
99 return "\'$o\'";
102getoptions();
104my $nopts = scalar(@opt);
106my %useropt = (
107 '-U' => 1,
108 '-u' => 1,
109 '--user' => 1,
110 '--proxy-user' => 1);
112my %commonrc = (
113 '0' => 1,
114 '1' => 1,
115 '2' => 1,
116 '26' => 1,
117 );
119sub runone {
120 my $a;
121 my $nargs = getnum(60) + 1;
123 $totalargs += $nargs;
124 $totalcmds++;
125 for(1 .. $nargs) {
126 my $o = getnum($nopts);
127 my $option = $opt[$o];
128 my $ar = "";
129 $uniq{$option}++;
130 if($arg{$option}) {
131 $ar = " ".randarg();
133 if($useropt{$option}) {
134 # append password to avoid prompting
135 $ar .= ":".randarg();
136 }
137 }
138 $a .= sprintf(" %s%s", $option, $ar);
139 }
140 if(getnum(100) < 15) {
141 # add a fake arg
142 $a .= " ".addarg();
143 }
145 my $cmd = "$curl$a $url";
147 my $rc = system("$cmd >curl-output 2>&1 </dev/null -M 0.1") >> 8;
148 #my $rc = system("valgrind -q $cmd >/dev/null 2>&1 </dev/null -M 0.1") >> 8;
150 $allrc{$rc}++;
152 #print "CMD: $cmd\n";
153 if(!$commonrc{$rc}) {
154 print "CMD: $cmd\n";
155 print "RC: $rc\n";
156 print "== curl-output == \n";
157 open(D, "<", 'curl-output');
158 my @out = <D>;
159 print @out;
160 close(D);
161 exit;
162 }
165sub runconfig {
166 my $a;
167 my $nargs = getnum(80) + 1;
169 open(C, ">", 'config');
171 $totalargs += $nargs;
172 $totalcmds++;
173 for(1 .. $nargs) {
174 my $o = getnum($nopts);
175 my $option = $opt[$o];
176 my $ar = "";
177 $uniq{$option} = 0 if(!exists $uniq{$option});
178 $uniq{$option}++;
179 if($arg{$option}) {
180 $ar = " ".randarg();
182 if($useropt{$option}) {
183 # append password
184 $ar .= ":".randarg();
185 }
186 }
187 $a .= sprintf("\n%s%s", $option, $ar);
188 }
189 if(getnum(100) < 15) {
190 # add a fake arg
191 $a .= "\n".addarg();
192 }
194 print C "$a\n";
195 close(C);
197 my $cmd = "$curl -K config $url";
199 my $rc = system("$cmd >curl-output 2>&1 </dev/null -M 0.1") >> 8;
201 $allrc{$rc}++;
203 if(!$commonrc{$rc}) {
204 print "CMD: $cmd\n";
205 print "RC: $rc\n";
206 print "== config == \n";
207 open(D, "<", 'config');
208 my @all = <D>;
209 print @all;
210 close(D);
211 print "\n== curl-output == \n";
212 open(D, "<", 'curl-output');
213 my @out = <D>;
214 print @out;
215 close(D);
216 exit 2;
217 }
220# run curl command lines using -K
221my $end = time() + $seconds / 2;
222my $c = 0;
223print "Running command lines\n";
224do {
225 runconfig();
226 $c++;
227} while(time() <= $end);
228print "$c command lines\n";
230# run curl command lines
231$end = time() + $seconds / 2;
232$c = 0;
233print "Running config lines\n";
234do {
235 runone();
236 $c++;
237} while(time() <= $end);
239print "$c config line uses\n";
241print "Recorded exit codes:\n";
242for my $rc (keys %allrc) {
243 printf " %2d: %d times\n", $rc, $allrc{$rc};
245printf "Number or command lines tested:\n" .
246 " $totalcmds (%.1f/second)\n", $totalcmds/$seconds;
247printf "Number or command line options tested:\n" .
248 " $totalargs (average %.1f per command line)\n",
249 $totalargs/$totalcmds;
250printf "Number or different options tested:\n" .
251 " %u out of %u\n", scalar(keys %uniq), $nopts;
Diagnostics4 git calls · 42 ms
CallStatusSizeTime042 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 · 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 · hit2 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=2
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
fetch2001.9 KiB · hit37 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=37
git.response.bytes=1959
git.response.cache=HIT
git.response.duration_ms=37
git.fetch.wants=0f748f447a98b1cbdd14f821fb4e796ed9d5a20e
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=1959
git.pkt.payload.max=1938
git.sideband.band1.bytes=1937
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
a5e22d1c2ff5a594
Request
7757a6e1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format