Artifactspublic-v0

curl

master
ply4 git calls28 ms301 KiB2 cachedprotocol v2
1546 lines48 KiBRaw
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.
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.
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
21# SPDX-License-Identifier: curl
23###########################################################################
25# This module contains entry points to run a single test. runner_init
26# determines whether they run in a separate process or in the process of
27# the caller. The relevant interface is asynchronous so it works in either
28# case. Program arguments are marshalled and then written to the end of a pipe
29# (in controlleripccall) which is later read from and the arguments
30# unmarshalled (in ipcrecv) before the desired function is called normally.
31# The function return values are then marshalled and written into another pipe
32# (again in ipcrecv) which is later read from and unmarshalled (in runnerar)
33# before being returned to the caller.
35package runner;
37use strict;
38use warnings;
39use 5.006;
41use File::Basename;
42use Time::HiRes;
44BEGIN {
45 use base qw(Exporter);
47 our @EXPORT = qw(
48 checktestcmd
49 prepro
50 readtestkeywords
51 restore_test_env
52 runner_init
53 runnerac_shutdown
54 runnerac_stopservers
55 runnerac_test_preprocess
56 runnerac_test_run
57 runnerar
58 runnerar_ready
59 stderrfilename
60 stdoutfilename
61 $DBGCURL
62 $gdb
63 $gdbthis
64 $gdbxwin
65 $shallow
66 $tortalloc
67 );
69 # these are for debugging only
70 our @EXPORT_OK = qw(
71 singletest_preprocess
72 );
75use B qw(
76 svref_2object
77 );
78use Storable qw(
79 freeze
80 thaw
81 );
83use pathhelp qw(
84 exe_ext
85 shell_quote
86 );
87use servers qw(
88 checkcmd
89 initserverconfig
90 serverfortest
91 stopserver
92 stopservers
93 subvariables
94 );
95use getpart;
96use globalconfig;
97use testutil qw(
98 clearlogs
99 logmsg
100 runclient
101 exerunner
102 subtextfile
103 subchars
104 subfuncs
105 subsha256base64file
106 substrippemfile
107 subnewlines
108 );
109use valgrind;
110use memanalyzer;
112#######################################################################
113# Global variables set elsewhere but used only by this package
114# These may only be set *before* runner_init is called
115our $DBGCURL = $CURL; # "../src/.libs/curl"; # alternative for debugging
116our $gdb = checktestcmd("gdb");
117our $gdbthis = 0; # run test case with debugger (gdb or lldb)
118our $gdbxwin; # use windowed gdb when using gdb
120# torture test variables
121our $shallow;
122our $tortalloc;
124# local variables
125my %oldenv; # environment variables before test is started
126my $CURLLOG = "commands.log"; # all command lines run
127my $defserverlogslocktimeout = 5; # timeout to await server logs lock removal
128my $defpostcommanddelay = 0; # delay between command and postcheck sections
129my $multiprocess; # nonzero with a separate test runner process
131# pipes
132my $runnerr; # pipe that runner reads from
133my $runnerw; # pipe that runner writes to
135# per-runner variables, indexed by runner ID; these are used by controller only
136my %controllerr; # pipe that controller reads from
137my %controllerw; # pipe that controller writes to
139# redirected stdout/stderr to these files
140sub stdoutfilename {
141 my ($logdir, $testnum) = @_;
142 return "$logdir/stdout$testnum";
145sub stderrfilename {
146 my ($logdir, $testnum) = @_;
147 return "$logdir/stderr$testnum";
150#######################################################################
151# Initialize the runner and prepare it to run tests
152# The runner ID returned by this function must be passed into the other
153# runnerac_* functions
154# Called by controller
155sub runner_init {
156 my ($logdir, $jobs) = @_;
158 $multiprocess = !!$jobs;
160 # enable memory debugging if curl is compiled with it
161 $ENV{'CURL_MEMDEBUG'} = "$logdir/$MEMDUMP";
162 delete $ENV{'CURL_ENTROPY'} if($ENV{'CURL_ENTROPY'});
163 $ENV{'CURL_FORCETIME'} = 1; # for debug
164 $ENV{'CURL_GLOBAL_INIT'} = 1; # debug curl_global_init/cleanup use
165 $ENV{'HOME'} = $pwd;
166 $ENV{'CURL_HOME'} = $ENV{'HOME'};
167 $ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'};
168 $ENV{'COLUMNS'} = 79; # screen width!
170 # Incorporate the $logdir into the random seed and re-seed the PRNG.
171 # This gives each runner a unique yet consistent seed which provides
172 # more unique port number selection in each runner, yet is deterministic
173 # across runs.
174 $randseed += unpack('%16C*', $logdir);
175 srand $randseed;
177 # create pipes for communication with runner
178 my ($thisrunnerr, $thiscontrollerw, $thiscontrollerr, $thisrunnerw);
179 pipe $thisrunnerr, $thiscontrollerw;
180 pipe $thiscontrollerr, $thisrunnerw;
182 my $thisrunnerid;
183 if($multiprocess) {
184 # Create a separate process in multiprocess mode
185 my $child = fork();
186 if(0 == $child) {
187 # TODO: set up better signal handlers
188 $SIG{INT} = 'IGNORE';
189 $SIG{TERM} = 'IGNORE';
190 eval {
191 # some MSYS2 Perl versions do not define SIGUSR1, also missing from Win32 Perl
192 $SIG{USR1} = 'IGNORE';
193 };
195 $thisrunnerid = $$;
196 print "Runner $thisrunnerid starting\n" if($verbose);
198 # Here we are the child (runner).
199 close($thiscontrollerw);
200 close($thiscontrollerr);
201 $runnerr = $thisrunnerr;
202 $runnerw = $thisrunnerw;
204 # Set this directory as ours
205 $LOGDIR = $logdir;
206 mkdir("$LOGDIR/$PIDDIR", 0777);
207 mkdir("$LOGDIR/$LOCKDIR", 0777);
209 # Initialize various server variables
210 initserverconfig();
212 # handle IPC calls
213 event_loop();
215 # Cannot rely on logmsg here in case it is buffered
216 print "Runner $thisrunnerid exiting\n" if($verbose);
218 # To reach this point, either the controller has sent
219 # runnerac_stopservers() and runnerac_shutdown() or we have called
220 # runnerabort(). In both cases, there are no more of our servers
221 # running and we can safely exit.
222 exit 0;
223 }
225 # Here we are the parent (controller).
226 close($thisrunnerw);
227 close($thisrunnerr);
229 $thisrunnerid = $child;
230 }
231 else {
232 # Create our pid directory
233 mkdir("$LOGDIR/$PIDDIR", 0777);
235 # Do not create a separate process
236 $thisrunnerid = "integrated";
237 }
239 $controllerw{$thisrunnerid} = $thiscontrollerw;
240 if(!$multiprocess) {
241 $runnerr = $thisrunnerr;
242 $runnerw = $thisrunnerw;
243 }
244 $controllerr{$thisrunnerid} = $thiscontrollerr;
246 return $thisrunnerid;
249#######################################################################
250# Loop to execute incoming IPC calls until the shutdown call
251sub event_loop {
252 while(1) {
253 if(ipcrecv()) {
254 last;
255 }
256 }
259#######################################################################
260# Check for a command in the PATH of the machine running curl.
262sub checktestcmd {
263 my ($cmd) = @_;
264 my @testpaths = ($LIBDIR . ".libs", $LIBDIR);
265 return checkcmd($cmd, @testpaths);
268# See if Valgrind should actually be used
269sub use_valgrind {
270 if($valgrind) {
271 my @valgrindoption = getpart("verify", "valgrind");
272 if((!@valgrindoption) || ($valgrindoption[0] !~ /disable/)) {
273 return 1;
274 }
275 }
276 return 0;
279# Massage the command result code into a useful form
280sub normalize_cmdres {
281 my $cmdres = $_[0];
282 my $signal_num = $cmdres & 127;
283 my $dumped_core = $cmdres & 128;
285 if(!$anyway && ($signal_num || $dumped_core)) {
286 $cmdres = 1000;
287 }
288 else {
289 $cmdres >>= 8;
290 $cmdres = (2000 + $signal_num) if($signal_num && !$cmdres);
291 }
292 return ($cmdres, $dumped_core);
295# 'prepro' processes the input array and replaces %-variables in the array
296# etc. Returns the processed version of the array
297sub prepro {
298 my $testnum = shift;
299 my (@entiretest) = @_;
300 my $show = 1;
301 my @out;
302 my $data_crlf = "";
303 my @pshow;
304 my @altshow;
305 my $plvl;
306 my $line;
307 for my $s (@entiretest) {
308 my $f = $s;
309 $line++;
310 if($s =~ /^ *%if ([A-Za-z0-9!_-]*)/) {
311 my $cond = $1;
312 my $rev = 0;
314 if($cond =~ /^!(.*)/) {
315 $cond = $1;
316 $rev = 1;
317 }
318 $rev ^= $feature{$cond} ? 1 : 0;
319 push @pshow, $show; # push the previous state
320 $plvl++;
321 if($show) {
322 # only if this was showing before we can allow the alternative
323 # to go showing as well
324 push @altshow, $rev ^ 1; # push the reversed show state
325 }
326 else {
327 push @altshow, 0; # the alt should still hide
328 }
329 if($show) {
330 # we only allow show if already showing
331 $show = $rev;
332 }
333 next;
334 }
335 elsif($s =~ /^ *%else/) {
336 if(!$plvl) {
337 print STDERR "error: test$testnum:$line: %else no %if\n";
338 last;
339 }
340 $show = pop @altshow;
341 push @altshow, $show; # put it back for consistency
342 next;
343 }
344 elsif($s =~ /^ *%endif/) {
345 if(!$plvl--) {
346 print STDERR "error: test$testnum:$line: %endif had no %if\n";
347 last;
348 }
349 $show = pop @pshow;
350 pop @altshow; # not used here but we must pop it
351 next;
352 }
353 if($show) {
354 # The processor does CRLF replacements in the <data*> and <connect*>
355 # sections if necessary since those parts might be read by separate
356 # servers.
357 if($s =~ /^ *<(data|connect)(.*)\>/) {
358 if($2 =~ /crlf="yes"/) {
359 $data_crlf = "yes";
360 }
361 elsif($2 =~ /crlf="headers"/) {
362 $data_crlf = "headers";
363 }
364 }
365 elsif(($s =~ /^ *<\/(data|connect)/) && $data_crlf ne "") {
366 $data_crlf = "";
367 }
368 subvariables(\$s, $testnum, "%");
369 if(subtextfile(\$s)) {
370 subvariables(\$s, $testnum, "%");
371 }
372 subchars(\$s);
373 subfuncs(\$s);
374 subsha256base64file(\$s);
375 substrippemfile(\$s);
376 subnewlines(1, \$s) if($data_crlf eq "yes");
377 subnewlines(0, \$s) if($data_crlf eq "headers");
378 push @out, $s;
379 }
380 }
381 return @out;
384#######################################################################
385# Load test keywords into %keywords hash
387sub readtestkeywords {
388 my @info_keywords = getpart("info", "keywords");
390 # Clear the list of keywords from the last test
391 %keywords = ();
392 for my $k (@info_keywords) {
393 chomp $k;
394 $keywords{$k} = 1;
395 }
398#######################################################################
399# Return a list of log locks that still exist
401sub logslocked {
402 opendir(my $lockdir, "$LOGDIR/$LOCKDIR");
403 my @locks;
404 foreach (readdir $lockdir) {
405 if(/^(.*)\.lock$/) {
406 push @locks, $1;
407 }
408 }
409 return @locks;
412#######################################################################
413# Wait log locks to be unlocked
415sub waitlockunlock {
416 # If a server logs advisor read lock file exists, it is an indication
417 # that the server has not yet finished writing out all its log files,
418 # including server request log files used for protocol verification.
419 # So, if the lock file exists the script waits here a certain amount
420 # of time until the server removes it, or the given time expires.
421 my $serverlogslocktimeout = shift;
423 if($serverlogslocktimeout) {
424 my $lockretry = $serverlogslocktimeout * 20;
425 my @locks;
426 while((@locks = logslocked()) && $lockretry--) {
427 Time::HiRes::sleep(0.05);
428 }
429 if(($lockretry < 0) &&
430 ($serverlogslocktimeout >= $defserverlogslocktimeout)) {
431 logmsg "Warning: server logs lock timeout ",
432 "($serverlogslocktimeout seconds) expired (locks: " .
433 join(", ", @locks) . ")\n";
434 }
435 }
438#######################################################################
439# Memory allocation test and failure torture testing.
441sub torture {
442 my ($testcmd, $testnum, $gdbline) = @_;
444 # remove memdump first to be sure we get a new nice and clean one
445 unlink("$LOGDIR/$MEMDUMP");
447 # First get URL from test server, ignore the output/result
448 runclient($testcmd);
450 logmsg " CMD: $testcmd\n" if($verbose);
452 # memanalyze -v is our friend, get the number of allocations made
453 my $count = 0;
454 my @out = memanalyze("$LOGDIR/$MEMDUMP", 1, 0, 0);
455 for(@out) {
456 if(/^Operations: (\d+)/) {
457 $count = $1;
458 last;
459 }
460 }
461 if(!$count) {
462 logmsg " found no functions to make fail\n";
463 return 0;
464 }
466 my @torture_tests = (1 .. $count);
467 if($shallow && ($shallow < $count)) {
468 my $discard = scalar(@torture_tests) - $shallow;
469 my $percent = sprintf("%.2f%%", $shallow * 100 / scalar(@torture_tests));
470 logmsg " $count functions found, but only fail $shallow ($percent)\n";
471 while($discard) {
472 my $rm;
473 do {
474 # find a test to discard
475 $rm = rand(scalar(@torture_tests));
476 } while(!$torture_tests[$rm]);
477 $torture_tests[$rm] = undef;
478 $discard--;
479 }
480 }
481 else {
482 logmsg " $count functions to make fail\n";
483 }
485 for(@torture_tests) {
486 my $limit = $_;
487 my $fail;
488 my $dumped_core;
490 if(!defined($limit)) {
491 # --shallow can undefine them
492 next;
493 }
494 if($tortalloc && ($tortalloc != $limit)) {
495 next;
496 }
498 if($verbose) {
499 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
500 localtime(time());
501 my $now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec);
502 logmsg "Fail function no: $limit at $now\n";
503 }
505 # make the memory allocation function number $limit return failure
506 $ENV{'CURL_MEMLIMIT'} = $limit;
508 # remove memdump first to be sure we get a new nice and clean one
509 unlink("$LOGDIR/$MEMDUMP");
511 my $cmd = $testcmd;
512 logmsg "*** Function number $limit is now set to fail ***\n" if($gdbthis);
514 my $ret = 0;
515 if($gdbthis) {
516 runclient($gdbline);
517 }
518 else {
519 $ret = runclient($cmd);
520 }
521 #logmsg "$_ Returned " . ($ret >> 8) . "\n";
523 # Now clear the variable again
524 delete $ENV{'CURL_MEMLIMIT'} if($ENV{'CURL_MEMLIMIT'});
526 if(-r "core") {
527 # there is core file present now!
528 logmsg " core dumped\n";
529 $dumped_core = 1;
530 $fail = 2;
531 }
533 if($valgrind) {
534 my @e = valgrindparse("$LOGDIR/valgrind$testnum");
535 if(@e && $e[0]) {
536 if($automakestyle) {
537 logmsg "FAIL: torture $testnum - valgrind\n";
538 }
539 else {
540 logmsg " valgrind ERROR ";
541 logmsg @e;
542 }
543 $fail = 1;
544 }
545 }
547 # verify that it returns a proper error code, does not leak memory
548 # and does not core dump
549 if(($ret & 255) || ($ret >> 8) >= 128) {
550 logmsg " system() returned $ret\n";
551 $fail = 1;
552 }
553 else {
554 my @memdata = memanalyze("$LOGDIR/$MEMDUMP", 0, 0, 0);
555 my $leak = 0;
556 for(@memdata) {
557 if($_ ne "") {
558 # well it could be other memory problems as well, but
559 # we call it leak for short here
560 $leak = 1;
561 }
562 }
563 if($leak) {
564 logmsg "** MEMORY FAILURE\n";
565 logmsg @memdata;
566 logmsg memanalyze("$LOGDIR/$MEMDUMP", 0, 0, 1);
567 $fail = 1;
568 }
569 }
570 if($fail) {
571 logmsg " $testnum: torture FAILED: function number $limit in test.\n",
572 " invoke with \"-t$limit\" to repeat this single case.\n";
573 stopservers($verbose);
574 return 1;
575 }
576 }
578 logmsg "\n" if($verbose);
579 logmsg "torture OK\n";
580 return 0;
583#######################################################################
584# restore environment variables that were modified in test
585sub restore_test_env {
586 my $deleteoldenv = $_[0]; # 1 to delete the saved contents after restore
587 foreach my $var (keys %oldenv) {
588 if($oldenv{$var} eq 'notset') {
589 delete $ENV{$var} if($ENV{$var});
590 }
591 else {
592 $ENV{$var} = $oldenv{$var};
593 }
594 if($deleteoldenv) {
595 delete $oldenv{$var};
596 }
597 }
600#######################################################################
601# Start the servers needed to run this test case
602sub singletest_startservers {
603 my ($testnum, $testtimings) = @_;
605 # remove old test server files before servers are started/verified
606 unlink("$LOGDIR/$SERVERCMD");
607 unlink("$LOGDIR/$SERVERIN");
608 unlink("$LOGDIR/$PROXYIN");
610 # timestamp required servers verification start
611 $$testtimings{"timesrvrini"} = Time::HiRes::time();
613 my $why;
614 my $error;
615 if(!$listonly) {
616 my @what = getpart("client", "server");
617 if($what[0]) {
618 my $err;
619 ($why, $err) = serverfortest(@what);
620 if($err == 1) {
621 # Error indicates an actual problem starting the server
622 $error = -2;
623 }
624 else {
625 $error = -1;
626 }
627 }
628 }
630 # timestamp required servers verification end
631 $$testtimings{"timesrvrend"} = Time::HiRes::time();
633 return ($why, $error);
636#######################################################################
637# Generate preprocessed test file
638sub singletest_preprocess {
639 my $testnum = $_[0];
641 # Save a preprocessed version of the entire test file. This allows more
642 # "basic" test case readers to enjoy variable replacements.
643 my @entiretest = fulltest();
644 my $otest = "$LOGDIR/test$testnum";
646 @entiretest = prepro($testnum, @entiretest);
648 # save the new version
649 open(my $fulltesth, ">", $otest) or die "Failure writing test file";
650 foreach my $bytes (@entiretest) {
651 print $fulltesth pack('a*', $bytes) or die "Failed to print '$bytes': $!";
652 }
653 close($fulltesth) or die "Failure writing test file";
655 # in case the process changed the file, force a reload
656 loadtest("$LOGDIR/test${testnum}", 0, 1);
659#######################################################################
660# Set up the test environment to run this test case
661sub singletest_setenv {
662 my @setenv = getpart("client", "setenv");
663 foreach my $s (@setenv) {
664 chomp $s;
665 if($s !~ /^#/ && $s =~ /([^=]*)(.*)/) {
666 my ($var, $content) = ($1, $2);
667 # remember current setting, to restore it once test runs
668 $oldenv{$var} = $ENV{$var} ? $ENV{$var} : 'notset';
670 if($content =~ /^=(.*)/) {
671 # assign it
672 $content = $1;
673 $ENV{$var} = $content;
674 logmsg "setenv $var = $content\n" if($verbose);
675 }
676 else {
677 # remove it
678 delete $ENV{$var} if($ENV{$var});
679 }
680 }
681 }
682 if($proxy_address) {
683 $ENV{http_proxy} = $proxy_address;
684 $ENV{HTTPS_PROXY} = $proxy_address;
685 }
688#######################################################################
689# Check that test environment is fine to run this test case
690sub singletest_precheck {
691 my $testnum = $_[0];
692 my $why;
693 my @precheck = getpart("client", "precheck");
694 if(@precheck) {
695 my $cmd = $precheck[0];
696 chomp $cmd;
697 if($cmd) {
698 my @p = split(/ /, $cmd);
699 if($p[0] !~ /\//) {
700 # the first word, the command, does not contain a slash so we
701 # scan the "improved" PATH to find the command to be able
702 # to run it
703 my $fullp = checktestcmd($p[0]);
705 if($fullp) {
706 $p[0] = $fullp;
707 }
708 $cmd = join(" ", @p);
709 }
711 # provide an environment variable
712 $ENV{'CURL_TESTNUM'} = $testnum;
714 my @o = qx($cmd 2> $LOGDIR/precheck-$testnum);
715 if($o[0]) {
716 $why = $o[0];
717 $why =~ s/[\r\n]//g;
718 }
719 elsif($?) {
720 $why = "precheck command error";
721 }
722 logmsg "prechecked $cmd\n" if($verbose);
723 }
724 }
725 return $why;
728#######################################################################
729# Prepare the test environment to run this test case
730sub singletest_prepare {
731 my ($testnum) = @_;
733 if($feature{"TrackMemory"}) {
734 unlink("$LOGDIR/$MEMDUMP");
735 }
736 unlink("core");
738 # remove server output logfiles after servers are started/verified
739 unlink("$LOGDIR/$SERVERIN");
740 unlink("$LOGDIR/$PROXYIN");
742 # if this section exists, it might be server instructions:
743 my @servercmd = getpart("reply", "servercmd");
744 push @servercmd, "Testnum $testnum\n";
745 # write the instructions to file
746 writearray("$LOGDIR/$SERVERCMD", \@servercmd);
748 # if this section exists, it might be DNS instructions:
749 my @dnscmd = getpart("reply", "dns");
750 # write the instructions to file
751 writearray("$LOGDIR/$DNSCMD", \@dnscmd);
753 # provide an environment variable
754 $ENV{'CURL_TESTNUM'} = $testnum;
756 # create (possibly-empty) files before starting the test
757 for my $partsuffix (('', '1', '2', '3', '4')) {
758 my @inputfile = getpart("client", "file" . $partsuffix);
759 my %fileattr = getpartattr("client", "file" . $partsuffix);
760 my $filename = $fileattr{'name'};
761 if(@inputfile || $filename) {
762 if(!$filename) {
763 logmsg " $testnum: IGNORED: Section client=>file has no name attribute\n";
764 return -1;
765 }
767 # make directories if needed
768 my $path = dirname($filename);
769 my @ldparts = split(/\//, $LOGDIR);
770 my $nparts = @ldparts;
771 my @parts = split(/\//, $path);
772 if(join("/", @parts[0..$nparts - 1]) eq $LOGDIR) {
773 # the file is in $LOGDIR/
774 my $d = shift @parts;
775 for(@parts) {
776 $d .= "/$_";
777 mkdir $d; # 0777
778 }
779 }
780 if(open(my $outfile, ">", $filename)) {
781 binmode $outfile; # for crapage systems, use binary
783 if($fileattr{'nonewline'}) {
784 # cut off the final newline
785 chomp($inputfile[-1]);
786 }
787 if($fileattr{'crlf'}) {
788 subnewlines(1, \$_) for @inputfile;
789 }
790 print $outfile join('', @inputfile);
791 close($outfile);
792 }
793 else {
794 logmsg "ERROR: cannot write $filename\n";
795 }
796 }
797 }
798 return 0;
801#######################################################################
802# Run the test command
803sub singletest_run {
804 my ($testnum, $testtimings) = @_;
806 # get the command line options to use
807 my $cmd;
808 my @cmd = getpart("client", "command");
809 if(@cmd) {
810 # allow splitting the command-line to multiple lines
811 $cmd = join(' ', @cmd);
812 $cmd =~ s/\n//g; # no newlines please
813 chomp $cmd; # no newlines please
814 # substitute variables in the command line
815 }
816 else {
817 # there was no command given, use something silly
818 $cmd = "-";
819 }
821 my $CURLOUT = "$LOGDIR/curl$testnum.out"; # curl output if not stdout
823 # if stdout section exists, we verify that the stdout contained this:
824 my $out = "";
825 my %cmdhash = getpartattr("client", "command");
826 if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-output/)) {
827 #We may slap on --output!
828 if(!partexists("verify", "stdout") ||
829 ($cmdhash{'option'} && $cmdhash{'option'} =~ /force-output/)) {
830 $out = " --output $CURLOUT ";
831 }
832 }
834 my @codepieces = getpart("client", "tool");
835 my $tool = "";
836 my $tool_name = ""; # without exe extension
837 if(@codepieces) {
838 $tool_name = $codepieces[0];
839 chomp $tool_name;
840 $tool = $tool_name . exe_ext('TOOL');
841 }
843 my $oldmemdebug;
844 my $disablevalgrind;
845 my $CMDLINE = "";
846 my $cmdargs;
847 my $cmdtype = $cmdhash{'type'} || "default";
848 my $fail_due_event_based = $run_event_based;
849 if($cmdtype eq "perl") {
850 # run the command line prepended with "perl"
851 $cmdargs = $cmd;
852 $CMDLINE = "$perl ";
853 $tool = $CMDLINE;
854 $disablevalgrind = 1;
855 }
856 elsif($cmdtype eq "shell") {
857 # run the command line prepended with "/bin/sh"
858 $cmdargs = $cmd;
859 $CMDLINE = "/bin/sh ";
860 $tool = $CMDLINE;
861 $disablevalgrind = 1;
862 }
863 elsif(!$tool &&
864 !$keywords{"unittest"} &&
865 !$keywords{"tunittest"} &&
866 !$keywords{"libtest"}) {
867 # run curl, add suitable command line options
868 my $inc = "";
869 if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-include/)) {
870 $inc = " --include";
871 }
872 $cmdargs = "$out$inc ";
874 if($cmdhash{'option'} && ($cmdhash{'option'} =~ /binary-trace/)) {
875 $cmdargs .= "--trace $LOGDIR/trace$testnum ";
876 }
877 else {
878 $cmdargs .= "--trace-ascii $LOGDIR/trace$testnum ";
879 }
880 $cmdargs .= "--trace-time ";
881 if($run_event_based) {
882 $cmdargs .= "--test-event ";
883 $fail_due_event_based--;
884 }
885 if($run_duphandle) {
886 $cmdargs .= "--test-duphandle ";
887 my @dis = getpart("client", "disable");
888 if(@dis) {
889 chomp $dis[0] if($dis[0]);
890 if($dis[0] eq "test-duphandle") {
891 # marked to not run with duphandle
892 logmsg " $testnum: IGNORED: Cannot run test-duphandle\n";
893 return (-1, 0, 0, "", "", 0);
894 }
895 }
896 }
897 $cmdargs .= $cmd;
898 if($proxy_address) {
899 $cmdargs .= " --proxy $proxy_address ";
900 }
901 }
902 else {
903 $cmdargs = " $cmd"; # $cmd is the command line for the test file
904 $CURLOUT = stdoutfilename($LOGDIR, $testnum); # sends received data to stdout
906 # Default the tool to a unit test with the same name as the test spec
907 if($keywords{"unittest"} && !$tool) {
908 $tool_name = "unit$testnum";
909 $tool = $tool_name . exe_ext('TOOL');
910 }
911 # Default the tool to a libtest with the same number as the test
912 elsif($keywords{"libtest"} && !$tool) {
913 $tool_name = "lib$testnum";
914 $tool = $tool_name . exe_ext('TOOL');
915 }
916 elsif($keywords{"tunittest"} && !$tool) {
917 $tool_name = "tool$testnum";
918 $tool = $tool_name . exe_ext('TOOL');
919 }
921 if($tool =~ /^(lib|cli_)/) {
922 $tool = "libtests" . exe_ext('TOOL');
923 $CMDLINE = $LIBDIR . $tool;
924 }
925 elsif($tool =~ /^tool/) {
926 $tool = "tunits" . exe_ext('TOOL');
927 $CMDLINE = $TUNITDIR . $tool;
928 }
929 elsif($tool =~ /^unit/) {
930 $tool = "units" . exe_ext('TOOL');
931 $CMDLINE = $UNITDIR . $tool;
932 }
934 if(! -f $CMDLINE) {
935 logmsg " $testnum: IGNORED: The tool set in the test case for this: '$tool' does not exist\n";
936 return (-1, 0, 0, "", "", 0);
937 }
939 $CMDLINE = exerunner() . $CMDLINE;
941 if($gdbthis) {
942 $cmdargs = " $tool_name$cmdargs";
943 }
944 else {
945 $CMDLINE .= " $tool_name";
946 }
948 $DBGCURL = $CMDLINE;
949 }
951 if($fail_due_event_based) {
952 logmsg " $testnum: IGNORED: This test cannot run event based\n";
953 return (-1, 0, 0, "", "", 0);
954 }
956 if($gdbthis) {
957 # gdb is incompatible with valgrind, so disable it when debugging
958 # Perhaps a better approach would be to run it under valgrind anyway
959 # with --db-attach=yes or --vgdb=yes.
960 $disablevalgrind = 1;
961 }
963 my @stdintest = getpart("client", "stdin");
965 if(@stdintest) {
966 my $stdinfile = "$LOGDIR/stdin-for-$testnum";
968 my %hash = getpartattr("client", "stdin");
969 if($hash{'nonewline'}) {
970 # cut off the final newline from the final line of the stdin data
971 chomp($stdintest[-1]);
972 }
974 if($hash{'crlf'}) {
975 subnewlines(1, \$_) for @stdintest;
976 }
978 writearray($stdinfile, \@stdintest);
980 $cmdargs .= " <$stdinfile";
981 }
983 if(!$tool) {
984 $CMDLINE = exerunner() . shell_quote($CURL);
985 if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-q/)) {
986 $CMDLINE .= " -q";
987 }
988 if($maxtime) {
989 $CMDLINE .= " --max-time $maxtime";
990 }
991 }
993 if(use_valgrind() && !$disablevalgrind) {
994 my $valgrindcmd = "$valgrind ";
995 $valgrindcmd .= "--tool=memcheck "; # valgrind 2.1.x+
996 $valgrindcmd .= "--quiet --leak-check=yes ";
997 $valgrindcmd .= "--suppressions=$srcdir/valgrind.supp ";
998 # $valgrindcmd .= "--gen-suppressions=all ";
999 $valgrindcmd .= "--num-callers=16 ";
1000 $valgrindcmd .= "--log-file=$LOGDIR/valgrind$testnum"; # valgrind >=3
1001 $CMDLINE = "$valgrindcmd $CMDLINE";
1004 my $redirstdout = "> " . stdoutfilename($LOGDIR, $testnum);
1005 if($cmdhash{'option'} && ($cmdhash{'option'} =~ /no-stdout/)) {
1006 $redirstdout = "";
1008 $CMDLINE .= "$cmdargs $redirstdout" .
1009 " 2> " . stderrfilename($LOGDIR, $testnum);
1011 if($verbose) {
1012 logmsg "$CMDLINE\n";
1015 open(my $cmdlog, ">", "$LOGDIR/$CURLLOG") or die "Failure writing log file";
1016 print $cmdlog "$CMDLINE\n";
1017 close($cmdlog) or die "Failure writing log file";
1019 my $dumped_core;
1020 my $cmdres;
1022 if($gdbthis) {
1023 my $gdbinit = "$TESTDIR/gdbinit$testnum";
1024 open(my $gdbcmd, ">", "$LOGDIR/gdbcmd") or die "Failure writing gdb file";
1025 if($gdbthis == 1) {
1026 # gdb mode
1027 print $gdbcmd "set args $cmdargs\n";
1028 print $gdbcmd "show args\n";
1029 print $gdbcmd "source $gdbinit\n" if -e $gdbinit;
1031 else {
1032 # lldb mode
1033 print $gdbcmd "set args $cmdargs\n";
1035 close($gdbcmd) or die "Failure writing gdb file";
1038 # Flush output.
1039 $| = 1;
1041 # timestamp starting of test command
1042 $$testtimings{"timetoolini"} = Time::HiRes::time();
1044 if($cmdhash{'option'} && ($cmdhash{'option'} =~ /no-memdebug/)) {
1045 $oldmemdebug = $ENV{'CURL_MEMDEBUG'};
1046 delete $ENV{'CURL_MEMDEBUG'};
1049 # run the command line we built
1050 if($torture) {
1051 $cmdres = torture($CMDLINE,
1052 $testnum,
1053 "$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " -x $LOGDIR/gdbcmd");
1055 elsif($gdbthis == 1) {
1056 # gdb
1057 my $GDBW = ($gdbxwin) ? "-w" : "";
1058 runclient("$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " $GDBW -x $LOGDIR/gdbcmd");
1059 $cmdres = 0; # makes it always continue after a debugged run
1061 elsif($gdbthis == 2) {
1062 # $gdb is "lldb"
1063 print "runs lldb -- $CURL $cmdargs\n";
1064 runclient("lldb -- $CURL $cmdargs");
1065 $cmdres = 0; # makes it always continue after a debugged run
1067 else {
1068 # Convert the raw result code into a more useful one
1069 ($cmdres, $dumped_core) = normalize_cmdres(runclient($CMDLINE));
1072 # restore contents
1073 if($oldmemdebug) {
1074 $ENV{'CURL_MEMDEBUG'} = $oldmemdebug;
1077 # timestamp finishing of test command
1078 $$testtimings{"timetoolend"} = Time::HiRes::time();
1080 return (0, $cmdres, $dumped_core, $CURLOUT, $tool, use_valgrind() && !$disablevalgrind);
1083#######################################################################
1084# Clean up after test command
1085sub singletest_clean {
1086 my ($testnum, $dumped_core, $testtimings) = @_;
1088 if(!$dumped_core) {
1089 if(-r "core") {
1090 # there is core file present now!
1091 $dumped_core = 1;
1095 if($dumped_core) {
1096 logmsg "core dumped\n";
1097 if(0 && $gdb) {
1098 logmsg "running gdb for post-mortem analysis:\n";
1099 open(my $gdbcmd, ">", "$LOGDIR/gdbcmd2") or die "Failure writing gdb file";
1100 print $gdbcmd "bt\n";
1101 close($gdbcmd) or die "Failure writing gdb file";
1102 runclient("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch " . shell_quote($DBGCURL) . " core ");
1103 # unlink("$LOGDIR/gdbcmd2");
1107 my $serverlogslocktimeout = $defserverlogslocktimeout;
1108 my %cmdhash = getpartattr("client", "command");
1109 if($cmdhash{'timeout'}) {
1110 # test is allowed to override default server logs lock timeout
1111 if($cmdhash{'timeout'} =~ /(\d+)/) {
1112 $serverlogslocktimeout = $1 if($1 >= 0);
1116 # Test harness ssh server does not have this synchronization mechanism,
1117 # this implies that some ssh server based tests might need a small delay
1118 # once that the client command has run to avoid false test failures.
1120 # gnutls-serv also lacks this synchronization mechanism, so gnutls-serv
1121 # based tests might need a small delay once that the client command has
1122 # run to avoid false test failures.
1123 my $postcommanddelay = $defpostcommanddelay;
1124 if($cmdhash{'delay'}) {
1125 # test is allowed to specify a delay after command is executed
1126 if($cmdhash{'delay'} =~ /(\d+)/) {
1127 $postcommanddelay = $1 if($1 > 0);
1131 Time::HiRes::sleep($postcommanddelay) if($postcommanddelay);
1133 my @killtestservers = getpart("client", "killserver");
1134 if(@killtestservers) {
1135 foreach my $server (@killtestservers) {
1136 chomp $server;
1137 if(stopserver($server)) {
1138 logmsg " $testnum: killserver FAILED\n";
1139 return 1; # normal error if asked to fail on unexpected alive
1144 # wait for any servers left running to release their locks
1145 waitlockunlock($serverlogslocktimeout);
1147 # timestamp removal of server logs advisor read lock
1148 $$testtimings{"timesrvrlog"} = Time::HiRes::time();
1150 # test definition might instruct to stop some servers
1151 # stop also all servers relative to the given one
1153 return 0;
1156#######################################################################
1157# Verify that the postcheck succeeded
1158sub singletest_postcheck {
1159 my ($testnum) = @_;
1161 # run the postcheck command
1162 my @postcheck = getpart("client", "postcheck");
1163 if(@postcheck) {
1164 die "test$testnum uses client/postcheck";
1167 @postcheck = getpart("verify", "postcheck");
1168 if(@postcheck) {
1169 my $cmd = join("", @postcheck);
1170 chomp $cmd;
1171 if($cmd) {
1172 logmsg "postcheck $cmd\n" if($verbose);
1173 my $rc = runclient($cmd);
1174 # Must run the postcheck command in torture mode in order
1175 # to clean up, but the result cannot be relied upon.
1176 if($rc != 0 && !$torture) {
1177 logmsg " $testnum: postcheck FAILED\n";
1178 return -1;
1183 if(checktest("${TESTDIR}/test${testnum}")) {
1184 logmsg " $testnum: postcheck FAILED: issue(s) found in test data\n";
1185 return -1;
1188 return 0;
1191###################################################################
1192# Get ready to run a single test case
1193sub runner_test_preprocess {
1194 my ($testnum) = @_;
1195 my %testtimings;
1197 if(clearlogs()) {
1198 logmsg "Warning: log messages were lost\n";
1201 # timestamp test preparation start
1202 # TODO: this metric now shows only a portion of the prep time; better would
1203 # be to time singletest_preprocess below instead
1204 $testtimings{"timeprepini"} = Time::HiRes::time();
1206 ###################################################################
1207 # Load test metadata
1208 # ignore any error here--if there were one, it would have been
1209 # caught during the selection phase and this test would not be
1210 # running now
1211 loadtest("${TESTDIR}/test${testnum}", 1);
1212 readtestkeywords();
1214 ###################################################################
1215 # Restore environment variables that were modified in a previous run.
1216 # Test definition may instruct to (un)set environment vars.
1217 restore_test_env(1);
1219 ###################################################################
1220 # Start the servers needed to run this test case
1221 my ($why, $error) = singletest_startservers($testnum, \%testtimings);
1223 # make sure no locks left for responsive test
1224 waitlockunlock($defserverlogslocktimeout);
1226 if(!$why) {
1228 ###############################################################
1229 # Generate preprocessed test file
1230 # This must be done after the servers are started so server
1231 # variables are available for substitution.
1232 singletest_preprocess($testnum);
1234 ###############################################################
1235 # Set up the test environment to run this test case
1236 singletest_setenv();
1238 ###############################################################
1239 # Check that the test environment is fine to run this test case
1240 if(!$listonly) {
1241 $why = singletest_precheck($testnum);
1242 $error = -1;
1245 return ($why, $error, clearlogs(), \%testtimings);
1248###################################################################
1249# Run a single test case with an environment that already been prepared
1250# Returns 0=success, -1=skippable failure, -2=permanent error,
1251# 1=unskippable test failure, as first integer, plus any log messages,
1252# plus more return values when error is 0
1253sub runner_test_run {
1254 my ($testnum) = @_;
1256 if(clearlogs()) {
1257 logmsg "Warning: log messages were lost\n";
1260 #######################################################################
1261 # Prepare the test environment to run this test case
1262 my $error = singletest_prepare($testnum);
1263 if($error) {
1264 return (-2, clearlogs());
1267 #######################################################################
1268 # Run the test command
1269 my %testtimings;
1270 my $cmdres;
1271 my $dumped_core;
1272 my $CURLOUT;
1273 my $tool;
1274 my $usedvalgrind;
1275 ($error, $cmdres, $dumped_core, $CURLOUT, $tool, $usedvalgrind) = singletest_run($testnum, \%testtimings);
1276 if($error) {
1277 return (-2, clearlogs(), \%testtimings);
1280 #######################################################################
1281 # Clean up after test command
1282 $error = singletest_clean($testnum, $dumped_core, \%testtimings);
1283 if($error) {
1284 return ($error, clearlogs(), \%testtimings);
1287 #######################################################################
1288 # Verify that the postcheck succeeded
1289 $error = singletest_postcheck($testnum);
1290 if($error) {
1291 return ($error, clearlogs(), \%testtimings);
1294 #######################################################################
1295 # restore environment variables that were modified
1296 restore_test_env(0);
1298 return (0, clearlogs(), \%testtimings, $cmdres, $CURLOUT, $tool, $usedvalgrind);
1301# Async call runner_shutdown
1302# This call does NOT generate an IPC response and must be the last IPC call
1303# received.
1304# Called by controller
1305sub runnerac_shutdown {
1306 my ($runnerid) = $_[0];
1307 my $err = controlleripccall(\&runner_shutdown, @_);
1309 # These have no more use
1310 close($controllerw{$runnerid});
1311 undef $controllerw{$runnerid};
1312 close($controllerr{$runnerid});
1313 undef $controllerr{$runnerid};
1314 return $err;
1317# Async call of runner_stopservers
1318# Called by controller
1319sub runnerac_stopservers {
1320 return controlleripccall(\&runner_stopservers, @_);
1323# Async call of runner_test_preprocess
1324# Called by controller
1325sub runnerac_test_preprocess {
1326 return controlleripccall(\&runner_test_preprocess, @_);
1329# Async call of runner_test_run
1330# Called by controller
1331sub runnerac_test_run {
1332 return controlleripccall(\&runner_test_run, @_);
1335###################################################################
1336# Call an arbitrary function via IPC
1337# The first argument is the function reference, the second is the runner ID
1338# Returns 0 on success, -1 on error writing to runner
1339# Called by controller (indirectly, via a more specific function)
1340sub controlleripccall {
1341 my $funcref = shift @_;
1342 my $runnerid = shift @_;
1343 # Get the name of the function from the reference
1344 my $cv = svref_2object($funcref);
1345 my $gv = $cv->GV;
1346 # Prepend the name to the function arguments so it is marshalled along with them
1347 unshift @_, $gv->NAME;
1348 # Marshall the arguments into a flat string
1349 my $margs = freeze \@_;
1351 # Send IPC call via pipe
1352 length($margs) < 1000 or die "A large IPC write risks blocking on some platforms";
1353 my $err;
1354 while(! defined ($err = syswrite($controllerw{$runnerid}, (pack "L", length($margs)) . $margs)) || $err <= 0) {
1355 if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
1356 # Runner has likely died
1357 return -1;
1359 # system call was interrupted, probably by ^C; restart it so we stay in sync
1362 if(!$multiprocess) {
1363 # Call the remote function here in single process mode
1364 ipcrecv();
1366 return 0;
1369###################################################################
1370# Receive async response of a previous call via IPC
1371# The first return value is the runner ID or undef on error
1372# Called by controller
1373sub runnerar {
1374 my ($runnerid) = @_;
1375 my $err;
1376 my $datalen;
1377 while(! defined ($err = sysread($controllerr{$runnerid}, $datalen, 4)) || $err <= 0) {
1378 if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
1379 # Runner is likely dead and closed the pipe
1380 return undef;
1382 # system call was interrupted, probably by ^C; restart it so we stay in sync
1384 my $len = unpack("L", $datalen);
1385 my $buf;
1386 while(! defined ($err = sysread($controllerr{$runnerid}, $buf, $len)) || $err <= 0) {
1387 if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
1388 # Runner is likely dead and closed the pipe
1389 return undef;
1391 # system call was interrupted, probably by ^C; restart it so we stay in sync
1394 # Decode response values
1395 my $resarrayref = thaw $buf;
1397 # First argument is runner ID
1398 # TODO: remove this; it is unneeded since it is passed in
1399 unshift @$resarrayref, $runnerid;
1400 return @$resarrayref;
1403###################################################################
1404# Returns runner ID if a response from an async call is ready or error
1405# First value is ready, second is error, however an error case shows up
1406# as ready in Linux, so you cannot trust it.
1407# argument is 0 for nonblocking, undef for blocking, anything else for timeout
1408# Called by controller
1409sub runnerar_ready {
1410 my ($blocking) = @_;
1411 my $r_in = "";
1412 my %idbyfileno;
1413 my $maxfileno = 0;
1414 my @ready_runners = ();
1415 foreach my $p (keys(%controllerr)) {
1416 my $fd = fileno($controllerr{$p});
1417 vec($r_in, $fd, 1) = 1;
1418 $idbyfileno{$fd} = $p; # save the runner ID for each pipe fd
1419 if($fd > $maxfileno) {
1420 $maxfileno = $fd;
1423 $maxfileno or die "Internal error: no runners are available to wait on\n";
1425 # Wait for any pipe from any runner to be ready
1426 # This may be interrupted and return EINTR, but this is ignored and the
1427 # caller needs to later call this function again.
1428 # TODO: this is relatively slow with hundreds of fds
1429 my $e_in = $r_in;
1430 if(select(my $r_out = $r_in, undef, my $e_out = $e_in, $blocking) >= 1) {
1431 for my $fd (0..$maxfileno) {
1432 # Return an error condition first in case it is both
1433 if(vec($e_out, $fd, 1)) {
1434 return (undef, $idbyfileno{$fd});
1436 if(vec($r_out, $fd, 1)) {
1437 push(@ready_runners, $idbyfileno{$fd});
1440 die "Internal pipe readiness inconsistency\n" if(!@ready_runners);
1441 return (@ready_runners, undef);
1443 return (undef, undef);
1446###################################################################
1447# Cleanly abort and exit the runner
1448# This uses print since there is no longer any controller to write logs.
1449sub runnerabort{
1450 print "Controller is gone: runner $$ for $LOGDIR exiting\n";
1451 my ($error, $logs) = runner_stopservers();
1452 print $logs;
1453 runner_shutdown();
1456###################################################################
1457# Receive an IPC call in the runner and execute it
1458# The IPC is read from the $runnerr pipe and the response is
1459# written to the $runnerw pipe
1460# Returns 0 if more IPC calls are expected or 1 if the runner should exit
1461sub ipcrecv {
1462 my $err;
1463 my $datalen;
1464 while(! defined ($err = sysread($runnerr, $datalen, 4)) || $err <= 0) {
1465 if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
1466 # pipe has closed; controller is gone and we must exit
1467 runnerabort();
1468 # Special case: no response is forthcoming
1469 return 1;
1471 # system call was interrupted, probably by ^C; restart it so we stay in sync
1473 my $len = unpack("L", $datalen);
1474 my $buf;
1475 while(! defined ($err = sysread($runnerr, $buf, $len)) || $err <= 0) {
1476 if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
1477 # pipe has closed; controller is gone and we must exit
1478 runnerabort();
1479 # Special case: no response is forthcoming
1480 return 1;
1482 # system call was interrupted, probably by ^C; restart it so we stay in sync
1485 # Decode the function name and arguments
1486 my $argsarrayref = thaw $buf;
1488 # The name of the function to call is the first argument
1489 my $funcname = shift @$argsarrayref;
1491 # print "ipcrecv $funcname\n";
1492 # Synchronously call the desired function
1493 my @res;
1494 if($funcname eq "runner_shutdown") {
1495 runner_shutdown(@$argsarrayref);
1496 # Special case: no response is forthcoming
1497 return 1;
1499 elsif($funcname eq "runner_stopservers") {
1500 @res = runner_stopservers(@$argsarrayref);
1502 elsif($funcname eq "runner_test_preprocess") {
1503 @res = runner_test_preprocess(@$argsarrayref);
1505 elsif($funcname eq "runner_test_run") {
1506 @res = runner_test_run(@$argsarrayref);
1508 else {
1509 die "Unknown IPC function $funcname\n";
1511 # print "ipcrecv results\n";
1513 # Marshall the results to return
1514 $buf = freeze \@res;
1516 while(! defined ($err = syswrite($runnerw, (pack "L", length($buf)) . $buf)) || $err <= 0) {
1517 if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
1518 # pipe has closed; controller is gone and we must exit
1519 runnerabort();
1520 # Special case: no response is forthcoming
1521 return 1;
1523 # system call was interrupted, probably by ^C; restart it so we stay in sync
1526 return 0;
1529###################################################################
1530# Kill all server processes
1531sub runner_stopservers {
1532 my $error = stopservers($verbose);
1533 my $logs = clearlogs();
1534 return ($error, $logs);
1537###################################################################
1538# Shut down this runner
1539sub runner_shutdown {
1540 close($runnerr);
1541 undef $runnerr;
1542 close($runnerw);
1543 undef $runnerw;
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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 B3 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=UPDATING
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 · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
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=86
Open pack map
fetch20014 KiB · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=21
git.response.bytes=14631
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=f8ac7e083fd1d2670e25f1bb3b8af31961784b2e
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=14631
git.pkt.payload.max=14610
git.sideband.band1.bytes=14609
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
a5e2a7bd5fd11293
Request
6e2c14b2…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format