mirror of
https://github.com/curl/curl.git
synced 2026-08-24 17:53:33 +03:00
tidy-up: miscellaneous
- examples: sync debug output printf masks. - INSTALL-CMAKE.md: tidy up section for some options. - curl_sha512_256: delete comment suggesting an optimization. - vtls/keylog: scope a variable. - vtls/openssl: make a source code URL a permalink. - vtls/schannel: drop redundant parentheses. - test1119.pl: robustify `$1` -> `$s`. - sync arg names in comments to match the code. - tidy up and minor fixes to comments. - fix formatting/indenting/comment/newline/include nits. - move `UNITTEST` protos next to definitions, sync their argument names. - make variables static. - add parentheses to Perl `open()` calls. - drop unnecessary double quotes in Perl. - clang-format. Closes #21000
This commit is contained in:
parent
3512b673dd
commit
e0dd6eb4a4
148 changed files with 612 additions and 684 deletions
118
tests/runner.pm
118
tests/runner.pm
|
|
@ -114,9 +114,9 @@ use memanalyzer;
|
|||
#######################################################################
|
||||
# Global variables set elsewhere but used only by this package
|
||||
# These may only be set *before* runner_init is called
|
||||
our $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging
|
||||
our $valgrind_logfile="--log-file"; # the option name for valgrind >=3
|
||||
our $valgrind_tool="--tool=memcheck";
|
||||
our $DBGCURL = $CURL; #"../src/.libs/curl"; # alternative for debugging
|
||||
our $valgrind_logfile = "--log-file"; # the option name for valgrind >=3
|
||||
our $valgrind_tool = "--tool=memcheck";
|
||||
our $gdb = checktestcmd("gdb");
|
||||
our $gdbthis = 0; # run test case with debugger (gdb or lldb)
|
||||
our $gdbxwin; # use windowed gdb when using gdb
|
||||
|
|
@ -142,12 +142,12 @@ my %controllerw; # pipe that controller writes to
|
|||
|
||||
# redirected stdout/stderr to these files
|
||||
sub stdoutfilename {
|
||||
my ($logdir, $testnum)=@_;
|
||||
my ($logdir, $testnum) = @_;
|
||||
return "$logdir/stdout$testnum";
|
||||
}
|
||||
|
||||
sub stderrfilename {
|
||||
my ($logdir, $testnum)=@_;
|
||||
my ($logdir, $testnum) = @_;
|
||||
return "$logdir/stderr$testnum";
|
||||
}
|
||||
|
||||
|
|
@ -157,19 +157,19 @@ sub stderrfilename {
|
|||
# runnerac_* functions
|
||||
# Called by controller
|
||||
sub runner_init {
|
||||
my ($logdir, $jobs)=@_;
|
||||
my ($logdir, $jobs) = @_;
|
||||
|
||||
$multiprocess = !!$jobs;
|
||||
|
||||
# enable memory debugging if curl is compiled with it
|
||||
$ENV{'CURL_MEMDEBUG'} = "$logdir/$MEMDUMP";
|
||||
delete $ENV{'CURL_ENTROPY'} if($ENV{'CURL_ENTROPY'});
|
||||
$ENV{'CURL_FORCETIME'}=1; # for debug NTLM magic
|
||||
$ENV{'CURL_GLOBAL_INIT'}=1; # debug curl_global_init/cleanup use
|
||||
$ENV{'HOME'}=$pwd;
|
||||
$ENV{'CURL_HOME'}=$ENV{'HOME'};
|
||||
$ENV{'XDG_CONFIG_HOME'}=$ENV{'HOME'};
|
||||
$ENV{'COLUMNS'}=79; # screen width!
|
||||
$ENV{'CURL_FORCETIME'} = 1; # for debug NTLM magic
|
||||
$ENV{'CURL_GLOBAL_INIT'} = 1; # debug curl_global_init/cleanup use
|
||||
$ENV{'HOME'} = $pwd;
|
||||
$ENV{'CURL_HOME'} = $ENV{'HOME'};
|
||||
$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'};
|
||||
$ENV{'COLUMNS'} = 79; # screen width!
|
||||
|
||||
# Incorporate the $logdir into the random seed and re-seed the PRNG.
|
||||
# This gives each runner a unique yet consistent seed which provides
|
||||
|
|
@ -262,8 +262,8 @@ sub event_loop {
|
|||
# Check for a command in the PATH of the machine running curl.
|
||||
#
|
||||
sub checktestcmd {
|
||||
my ($cmd)=@_;
|
||||
my @testpaths=($LIBDIR . ".libs", $LIBDIR);
|
||||
my ($cmd) = @_;
|
||||
my @testpaths = ($LIBDIR . ".libs", $LIBDIR);
|
||||
return checkcmd($cmd, @testpaths);
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ sub torture {
|
|||
logmsg " CMD: $testcmd\n" if($verbose);
|
||||
|
||||
# memanalyze -v is our friend, get the number of allocations made
|
||||
my $count=0;
|
||||
my $count = 0;
|
||||
my @out = memanalyze("$LOGDIR/$MEMDUMP", 1, 0, 0);
|
||||
for(@out) {
|
||||
if(/^Operations: (\d+)/) {
|
||||
|
|
@ -498,7 +498,7 @@ sub torture {
|
|||
}
|
||||
|
||||
if($verbose) {
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
||||
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
|
||||
localtime(time());
|
||||
my $now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec);
|
||||
logmsg "Fail function no: $limit at $now\r";
|
||||
|
|
@ -550,16 +550,16 @@ sub torture {
|
|||
# and does not core dump
|
||||
if(($ret & 255) || ($ret >> 8) >= 128) {
|
||||
logmsg " system() returned $ret\n";
|
||||
$fail=1;
|
||||
$fail = 1;
|
||||
}
|
||||
else {
|
||||
my @memdata = memanalyze("$LOGDIR/$MEMDUMP", 0, 0, 0);
|
||||
my $leak=0;
|
||||
my $leak = 0;
|
||||
for(@memdata) {
|
||||
if($_ ne "") {
|
||||
# well it could be other memory problems as well, but
|
||||
# we call it leak for short here
|
||||
$leak=1;
|
||||
$leak = 1;
|
||||
}
|
||||
}
|
||||
if($leak) {
|
||||
|
|
@ -753,9 +753,9 @@ sub singletest_prepare {
|
|||
|
||||
# create (possibly-empty) files before starting the test
|
||||
for my $partsuffix (('', '1', '2', '3', '4')) {
|
||||
my @inputfile=getpart("client", "file".$partsuffix);
|
||||
my @inputfile = getpart("client", "file".$partsuffix);
|
||||
my %fileattr = getpartattr("client", "file".$partsuffix);
|
||||
my $filename=$fileattr{'name'};
|
||||
my $filename = $fileattr{'name'};
|
||||
if(@inputfile || $filename) {
|
||||
if(!$filename) {
|
||||
logmsg " $testnum: IGNORED: Section client=>file has no name attribute\n";
|
||||
|
|
@ -812,25 +812,25 @@ sub singletest_run {
|
|||
}
|
||||
else {
|
||||
# there was no command given, use something silly
|
||||
$cmd="-";
|
||||
$cmd = "-";
|
||||
}
|
||||
|
||||
my $CURLOUT="$LOGDIR/curl$testnum.out"; # curl output if not stdout
|
||||
my $CURLOUT = "$LOGDIR/curl$testnum.out"; # curl output if not stdout
|
||||
|
||||
# if stdout section exists, we verify that the stdout contained this:
|
||||
my $out="";
|
||||
my $out = "";
|
||||
my %cmdhash = getpartattr("client", "command");
|
||||
if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-output/)) {
|
||||
#We may slap on --output!
|
||||
if(!partexists("verify", "stdout") ||
|
||||
($cmdhash{'option'} && $cmdhash{'option'} =~ /force-output/)) {
|
||||
$out=" --output $CURLOUT ";
|
||||
$out = " --output $CURLOUT ";
|
||||
}
|
||||
}
|
||||
|
||||
my @codepieces = getpart("client", "tool");
|
||||
my $tool="";
|
||||
my $tool_name=""; # without exe extension
|
||||
my $tool = "";
|
||||
my $tool_name = ""; # without exe extension
|
||||
if(@codepieces) {
|
||||
$tool_name = $codepieces[0];
|
||||
chomp $tool_name;
|
||||
|
|
@ -839,27 +839,27 @@ sub singletest_run {
|
|||
|
||||
my $oldmemdebug;
|
||||
my $disablevalgrind;
|
||||
my $CMDLINE="";
|
||||
my $CMDLINE = "";
|
||||
my $cmdargs;
|
||||
my $cmdtype = $cmdhash{'type'} || "default";
|
||||
my $fail_due_event_based = $run_event_based;
|
||||
if($cmdtype eq "perl") {
|
||||
# run the command line prepended with "perl"
|
||||
$cmdargs =$cmd;
|
||||
$cmdargs = $cmd;
|
||||
$CMDLINE = "$perl ";
|
||||
$tool=$CMDLINE;
|
||||
$disablevalgrind=1;
|
||||
$tool = $CMDLINE;
|
||||
$disablevalgrind = 1;
|
||||
}
|
||||
elsif($cmdtype eq "shell") {
|
||||
# run the command line prepended with "/bin/sh"
|
||||
$cmdargs =$cmd;
|
||||
$cmdargs = $cmd;
|
||||
$CMDLINE = "/bin/sh ";
|
||||
$tool=$CMDLINE;
|
||||
$disablevalgrind=1;
|
||||
$tool = $CMDLINE;
|
||||
$disablevalgrind = 1;
|
||||
}
|
||||
elsif(!$tool && !$keywords{"unittest"}) {
|
||||
# run curl, add suitable command line options
|
||||
my $inc="";
|
||||
my $inc = "";
|
||||
if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-include/)) {
|
||||
$inc = " --include";
|
||||
}
|
||||
|
|
@ -899,21 +899,21 @@ sub singletest_run {
|
|||
|
||||
# Default the tool to a unit test with the same name as the test spec
|
||||
if($keywords{"unittest"} && !$tool) {
|
||||
$tool_name="unit$testnum";
|
||||
$tool_name = "unit$testnum";
|
||||
$tool = $tool_name . exe_ext('TOOL');
|
||||
}
|
||||
|
||||
if($tool =~ /^lib/) {
|
||||
$tool = "libtests" . exe_ext('TOOL');
|
||||
$CMDLINE=$LIBDIR . $tool;
|
||||
$CMDLINE = $LIBDIR . $tool;
|
||||
}
|
||||
elsif($tool =~ /^tool/) {
|
||||
$tool = "tunits" . exe_ext('TOOL');
|
||||
$CMDLINE=$TUNITDIR . $tool;
|
||||
$CMDLINE = $TUNITDIR . $tool;
|
||||
}
|
||||
elsif($tool =~ /^unit/) {
|
||||
$tool = "units" . exe_ext('TOOL');
|
||||
$CMDLINE=$UNITDIR . $tool;
|
||||
$CMDLINE = $UNITDIR . $tool;
|
||||
}
|
||||
|
||||
if(! -f $CMDLINE) {
|
||||
|
|
@ -921,16 +921,16 @@ sub singletest_run {
|
|||
return (-1, 0, 0, "", "", 0);
|
||||
}
|
||||
|
||||
$CMDLINE=exerunner() . $CMDLINE;
|
||||
$CMDLINE = exerunner() . $CMDLINE;
|
||||
|
||||
if($gdbthis) {
|
||||
$cmdargs =" $tool_name$cmdargs";
|
||||
$cmdargs = " $tool_name$cmdargs";
|
||||
}
|
||||
else {
|
||||
$CMDLINE.=" $tool_name";
|
||||
$CMDLINE .= " $tool_name";
|
||||
}
|
||||
|
||||
$DBGCURL=$CMDLINE;
|
||||
$DBGCURL = $CMDLINE;
|
||||
}
|
||||
|
||||
if($fail_due_event_based) {
|
||||
|
|
@ -942,13 +942,13 @@ sub singletest_run {
|
|||
# gdb is incompatible with valgrind, so disable it when debugging
|
||||
# Perhaps a better approach would be to run it under valgrind anyway
|
||||
# with --db-attach=yes or --vgdb=yes.
|
||||
$disablevalgrind=1;
|
||||
$disablevalgrind = 1;
|
||||
}
|
||||
|
||||
my @stdintest = getpart("client", "stdin");
|
||||
|
||||
if(@stdintest) {
|
||||
my $stdinfile="$LOGDIR/stdin-for-$testnum";
|
||||
my $stdinfile = "$LOGDIR/stdin-for-$testnum";
|
||||
|
||||
my %hash = getpartattr("client", "stdin");
|
||||
if($hash{'nonewline'}) {
|
||||
|
|
@ -966,7 +966,7 @@ sub singletest_run {
|
|||
}
|
||||
|
||||
if(!$tool) {
|
||||
$CMDLINE=exerunner() . shell_quote($CURL);
|
||||
$CMDLINE = exerunner() . shell_quote($CURL);
|
||||
if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-q/)) {
|
||||
$CMDLINE .= " -q";
|
||||
}
|
||||
|
|
@ -1038,13 +1038,13 @@ sub singletest_run {
|
|||
# gdb
|
||||
my $GDBW = ($gdbxwin) ? "-w" : "";
|
||||
runclient("$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " $GDBW -x $LOGDIR/gdbcmd");
|
||||
$cmdres=0; # makes it always continue after a debugged run
|
||||
$cmdres = 0; # makes it always continue after a debugged run
|
||||
}
|
||||
elsif($gdbthis == 2) {
|
||||
# $gdb is "lldb"
|
||||
print "runs lldb -- $CURL $cmdargs\n";
|
||||
runclient("lldb -- $CURL $cmdargs");
|
||||
$cmdres=0; # makes it always continue after a debugged run
|
||||
$cmdres = 0; # makes it always continue after a debugged run
|
||||
}
|
||||
else {
|
||||
# Convert the raw result code into a more useful one
|
||||
|
|
@ -1065,7 +1065,7 @@ sub singletest_run {
|
|||
#######################################################################
|
||||
# Clean up after test command
|
||||
sub singletest_clean {
|
||||
my ($testnum, $dumped_core, $testtimings)=@_;
|
||||
my ($testnum, $dumped_core, $testtimings) = @_;
|
||||
|
||||
if(!$dumped_core) {
|
||||
if(-r "core") {
|
||||
|
|
@ -1138,15 +1138,15 @@ sub singletest_clean {
|
|||
#######################################################################
|
||||
# Verify that the postcheck succeeded
|
||||
sub singletest_postcheck {
|
||||
my ($testnum)=@_;
|
||||
my ($testnum) = @_;
|
||||
|
||||
# run the postcheck command
|
||||
my @postcheck= getpart("client", "postcheck");
|
||||
my @postcheck = getpart("client", "postcheck");
|
||||
if(@postcheck) {
|
||||
die "test$testnum uses client/postcheck";
|
||||
}
|
||||
|
||||
@postcheck= getpart("verify", "postcheck");
|
||||
@postcheck = getpart("verify", "postcheck");
|
||||
if(@postcheck) {
|
||||
my $cmd = join("", @postcheck);
|
||||
chomp $cmd;
|
||||
|
|
@ -1173,7 +1173,7 @@ sub singletest_postcheck {
|
|||
###################################################################
|
||||
# Get ready to run a single test case
|
||||
sub runner_test_preprocess {
|
||||
my ($testnum)=@_;
|
||||
my ($testnum) = @_;
|
||||
my %testtimings;
|
||||
|
||||
if(clearlogs()) {
|
||||
|
|
@ -1233,7 +1233,7 @@ sub runner_test_preprocess {
|
|||
# 1=unskippable test failure, as first integer, plus any log messages,
|
||||
# plus more return values when error is 0
|
||||
sub runner_test_run {
|
||||
my ($testnum)=@_;
|
||||
my ($testnum) = @_;
|
||||
|
||||
if(clearlogs()) {
|
||||
logmsg "Warning: log messages were lost\n";
|
||||
|
|
@ -1285,7 +1285,7 @@ sub runner_test_run {
|
|||
# received.
|
||||
# Called by controller
|
||||
sub runnerac_shutdown {
|
||||
my ($runnerid)=$_[0];
|
||||
my ($runnerid) = $_[0];
|
||||
my $err = controlleripccall(\&runner_shutdown, @_);
|
||||
|
||||
# These have no more use
|
||||
|
|
@ -1362,7 +1362,7 @@ sub runnerar {
|
|||
}
|
||||
# system call was interrupted, probably by ^C; restart it so we stay in sync
|
||||
}
|
||||
my $len=unpack("L", $datalen);
|
||||
my $len = unpack("L", $datalen);
|
||||
my $buf;
|
||||
while(! defined ($err = sysread($controllerr{$runnerid}, $buf, $len)) || $err <= 0) {
|
||||
if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
|
||||
|
|
@ -1391,7 +1391,7 @@ sub runnerar_ready {
|
|||
my ($blocking) = @_;
|
||||
my $r_in = "";
|
||||
my %idbyfileno;
|
||||
my $maxfileno=0;
|
||||
my $maxfileno = 0;
|
||||
my @ready_runners = ();
|
||||
foreach my $p (keys(%controllerr)) {
|
||||
my $fd = fileno($controllerr{$p});
|
||||
|
|
@ -1408,7 +1408,7 @@ sub runnerar_ready {
|
|||
# caller will need to later call this function again.
|
||||
# TODO: this is relatively slow with hundreds of fds
|
||||
my $e_in = $r_in;
|
||||
if(select(my $r_out=$r_in, undef, my $e_out=$e_in, $blocking) >= 1) {
|
||||
if(select(my $r_out = $r_in, undef, my $e_out = $e_in, $blocking) >= 1) {
|
||||
for my $fd (0..$maxfileno) {
|
||||
# Return an error condition first in case it is both
|
||||
if(vec($e_out, $fd, 1)) {
|
||||
|
|
@ -1451,7 +1451,7 @@ sub ipcrecv {
|
|||
}
|
||||
# system call was interrupted, probably by ^C; restart it so we stay in sync
|
||||
}
|
||||
my $len=unpack("L", $datalen);
|
||||
my $len = unpack("L", $datalen);
|
||||
my $buf;
|
||||
while(! defined ($err = sysread($runnerr, $buf, $len)) || $err <= 0) {
|
||||
if((!defined $err && ! $!{EINTR}) || (defined $err && $err == 0)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue