use Cwd 'abs_path';
BEGIN {
- require Exporter;
-
- our @ISA = qw(Exporter);
+ use base qw(Exporter);
our @EXPORT = qw(
sys_native_abs_path
# Returns boolean true if 'cygpath' utility should be used for path conversion.
sub should_use_cygpath {
- unless (os_is_win()) {
+ if(!os_is_win()) {
$use_cygpath = 0;
return 0;
}
# Returns current working directory in Win32 format on Windows.
#
sub sys_native_current_path {
- return Cwd::getcwd() unless os_is_win();
+ return Cwd::getcwd() if !os_is_win();
my $cur_dir;
if($^O eq 'msys') {
my ($path) = @_;
# Return untouched on non-Windows platforms.
- return $path unless (os_is_win());
+ return $path if (!os_is_win());
# Do not process empty path.
return $path if ($path eq '');
# Convert leading slash back to forward slash to indicate
# directory on Win32 current drive or capitalize drive letter.
- substr($path, 0, 1) = $first_char;
+ substr($path, 0, 1, $first_char);
return $path;
}
elsif(should_use_cygpath()) {
# program parameters if program is not Msys-based.
$path = do_msys_transform($path);
- return undef unless defined $path;
+ return undef if !defined $path;
# Capitalize drive letter for Win32 paths.
$path =~ s{^([a-z]:)}{\u$1};
sub sys_native_abs_path {
my ($path) = @_;
- unless(os_is_win()) {
+ if(!os_is_win()) {
# Convert path to absolute form.
$path = Cwd::abs_path($path);
# Path is directory or filename on Win32 current drive. ('\Windows')
my $w32drive = get_win32_current_drive();
- return undef unless defined $w32drive;
+ return undef if !defined $w32drive;
# Combine drive and path.
# Replace any possible back slashes with forward slashes,
return normalize_path($w32drive . $path);
}
- unless (substr($path, 0, 1) eq '/') {
+ if(substr($path, 0, 1) ne '/') {
# Path is in relative form. Resolve relative directories in Unix form
# *BEFORE* converting to Win32 form otherwise paths like
# '../../../cygdrive/c/windows' will not be resolved.
# Msys transforms automatically path to Windows native form in staring
# program parameters if program is not Msys-based.
$path = do_msys_transform($path);
- return undef unless defined $path;
+ return undef if !defined $path;
# Replace any back and duplicated slashes with single forward slashes.
$path =~ s{[\\/]+}{/}g;
sub build_sys_abs_path {
my ($path) = @_;
- unless(os_is_win()) {
+ if(!os_is_win()) {
# Convert path to absolute form.
$path = Cwd::abs_path($path);
# Replace any possible back slashes with forward slashes,
# remove any duplicated slashes.
$path = get_abs_path_on_win32_drive($1, $2);
- return undef unless defined $path;
+ return undef if !defined $path;
return simple_transform_win32_to_unix($path);
}
# Unix-style paths.
# Remove duplicated slashes, as they may be not processed.
$path = normalize_path($path);
- return undef unless defined $path;
+ return undef if !defined $path;
# Use 'cygpath', '-u' means Unix-stile path,
# '-a' means absolute path
# Replace any possible back slashes with forward slashes,
# remove any duplicated slashes.
$path = normalize_path($path);
- return undef unless defined $path;
+ return undef if !defined $path;
return simple_transform_win32_to_unix($path);
}
# Path is directory or filename on Win32 current drive. ('\Windows')
my $w32drive = get_win32_current_drive();
- return undef unless defined $w32drive;
+ return undef if !defined $w32drive;
# Combine drive and path.
# Resolve relative dirs in Win32-style path or paths like 'D:/../c/'
# Replace any possible back slashes with forward slashes,
# remove any duplicated slashes.
$path = normalize_path($w32drive . $path);
- return undef unless defined $path;
+ return undef if !defined $path;
return simple_transform_win32_to_unix($path);
}
# Path is not in any Win32 form.
- unless (substr($path, 0, 1) eq '/') {
+ if(substr($path, 0, 1) ne '/') {
# Path in relative form. Resolve relative directories in Unix form
# *BEFORE* converting to Win32 form otherwise paths like
# '../../../cygdrive/c/windows' will not be resolved.
# Don't process empty paths.
return $path if $path eq '';
- unless($path =~ m{(?:^|\\|/)\.{1,2}(?:\\|/|$)}) {
+ if($path !~ m{(?:^|\\|/)\.{1,2}(?:\\|/|$)}) {
# Speed up processing of simple paths.
my $first_char = substr($path, 0, 1);
$path =~ s{[\\/]+}{/}g;
# Restore starting backslash if any.
- substr($path, 0, 1) = $first_char;
+ substr($path, 0, 1, $first_char);
return $path;
}
# Process path separately from drive letter.
@arr = split(m{\/|\\}, $3);
# Replace backslash with forward slash if required.
- substr($prefix, 2, 1) = '/' if $have_root;
+ substr($prefix, 2, 1, '/') if $have_root;
}
else {
if($path =~ m{^(\/|\\)}) {
if(length($el) == 0 || $el eq '.') {
next;
}
- elsif($el eq '..' && @res > 0 && $res[$#res] ne '..') {
+ elsif($el eq '..' && @res > 0 && $res[-1] ne '..') {
pop @res;
next;
}
# '/bin/' can be mapped to '/usr/bin/'.
my $check_path = $path;
my $path_tail = '';
- do {
+ while(1) {
if(-d $check_path) {
my $res =
`(cd "$check_path" && cmd /c "echo %__CD__%") 2>/dev/null`;
return $res . $path_tail;
}
else {
- $res =~ s{/$}{} unless $check_path =~ m{/$};
+ $res =~ s{/$}{} if $check_path !~ m{/$};
return $res;
}
}
warn "Can't determine Win32 directory for path \"$path\".\n";
return undef;
}
- } while(1);
+ }
}
}
# 'cygpath' is not available, use guessed transformation.
- unless($path =~ s{^([a-zA-Z]):(?:/|\\)}{/\l$1/}) {
+ if($path !~ s{^([a-zA-Z]):(?:/|\\)}{/\l$1/}) {
warn "Can't determine Unix-style directory for Win32 " .
"directory \"$path\".\n";
return undef;
# fixed. As long as the -g option is never given, and the -n is always
# given, this won't be a problem.
+use strict;
+# Promote all warnings to fatal
+use warnings FATAL => 'all';
+use 5.006;
# These should be the only variables that might be needed to get edited:
}
}
-use 5.006;
-use strict;
-# Promote all warnings to fatal
-use warnings FATAL => 'all';
use Cwd;
use Digest::MD5 qw(md5);
use MIME::Base64;
use pathhelp;
-require "getpart.pm"; # array functions
-require "valgrind.pm"; # valgrind report parser
-require "ftp.pm";
-require "azure.pm";
-require "appveyor.pm";
+require getpart; # array functions
+require valgrind; # valgrind report parser
+require ftp;
+require azure;
+require appveyor;
my $HOSTIP="127.0.0.1"; # address on which the test server listens
my $HOST6IP="[::1]"; # address on which the test server listens
my $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key
my $SSHSRVSHA256 = "[uninitialized]"; # SHA256 of ssh server public key
-my $VERSION=""; # curl's reported version number
+my $CURLVERSION=""; # curl's reported version number
my $srcdir = $ENV{'srcdir'} || '.';
my $CURL="../src/curl".exe_ext('TOOL'); # what curl binary to run on the tests
# torture test variables
my $torture;
-my $tortnum;
my $tortalloc;
my $shallow;
my $randseed = 0;
# Clear all possible '*_proxy' environment variables for various protocols
# to prevent them to interfere with our testing!
-my $protocol;
-foreach $protocol (('ftp', 'http', 'ftps', 'https', 'no', 'all')) {
+foreach my $protocol (('ftp', 'http', 'ftps', 'https', 'no', 'all')) {
my $proxy = "${protocol}_proxy";
# clear lowercase version
delete $ENV{$proxy} if($ENV{$proxy});
# Check if a given child process has just died. Reaps it if so.
#
sub checkdied {
- use POSIX ":sys_wait_h";
my $pid = $_[0];
if((not defined $pid) || $pid <= 0) {
return 0;
}
+ use POSIX ":sys_wait_h";
my $rc = pidwait($pid, &WNOHANG);
return ($rc == $pid)?1:0;
}
if ($fake) {
if(open(OUT, ">$pidfile")) {
print OUT $child . "\n";
- close(OUT);
+ close(OUT) || die "Failure writing pidfile";
logmsg "startnew: $pidfile faked with pid=$child\n" if($verbose);
}
else {
#
sub checkcmd {
my ($cmd)=@_;
- my @paths=(split(":", $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
+ my @paths=(split(m/[:]/, $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
"/sbin", "/usr/bin", "/usr/local/bin",
"$LIBDIR/.libs", "$LIBDIR");
for(@paths) {
return "$_/$cmd";
}
}
+ return "";
}
#######################################################################
logmsg "RUN: curl command returned $res\n";
if(open(FILE, "<$verifylog")) {
while(my $string = <FILE>) {
- logmsg "RUN: $string" if($string !~ /^([ \t]*)$/);
+ logmsg "RUN: $string" if($string !~ /^[ \t]*$/);
}
close(FILE);
}
# start the http2 server
#
sub runhttp2server {
- my ($verbose) = @_;
+ my ($verb) = @_;
my $server;
my $srvrname;
my $pidfile;
}
$doesntrun{$pidfile} = 0;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $http2pid ".
"http-port $port https-port $port2 ".
"backend $HOSTIP:" . protoport("http") . "\n";
# start the http3 server
#
sub runhttp3server {
- my ($verbose, $cert) = @_;
+ my ($verb, $cert) = @_;
my $server;
my $srvrname;
my $pidfile;
}
$doesntrun{$pidfile} = 0;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $http3pid port $port\n";
}
last;
# start the http server
#
sub runhttpserver {
- my ($proto, $verbose, $alt, $port_or_path) = @_;
+ my ($proto, $verb, $alt, $port_or_path) = @_;
my $ip = $HOSTIP;
my $ipvnum = 4;
my $idnum = 1;
}
$pid2 = $pid3;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server is on PID $httppid port $port_or_path\n";
}
# start the https stunnel based server
#
sub runhttpsserver {
- my ($verbose, $proto, $proxy, $certfile) = @_;
+ my ($verb, $proto, $proxy, $certfile) = @_;
my $ip = $HOSTIP;
my $ipvnum = 4;
my $idnum = 1;
next;
}
# we have a server!
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server is PID $httpspid port $port\n";
}
last;
# start the non-stunnel HTTP TLS extensions capable server
#
sub runhttptlsserver {
- my ($verbose, $ipv6) = @_;
+ my ($verb, $ipv6) = @_;
my $proto = "httptls";
my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
}
$doesntrun{$pidfile} = 0;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $httptlspid port $port\n";
}
last;
# start the pingpong server (FTP, POP3, IMAP, SMTP)
#
sub runpingpongserver {
- my ($proto, $id, $verbose, $ipv6) = @_;
+ my ($proto, $id, $verb, $ipv6) = @_;
my $port;
my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
# where is it?
$port = pidfromfile($portfile);
- logmsg "PINGPONG runs on port $port ($portfile)\n" if($verbose);
+ logmsg "PINGPONG runs on port $port ($portfile)\n" if($verb);
# Server is up. Verify that we can speak to it.
my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
}
$pid2 = $pid3;
- logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verbose);
+ logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verb);
# Assign the correct port variable!
if($proto =~ /^(?:ftp|imap|pop3|smtp)$/) {
# start the ftps/imaps/pop3s/smtps server (or rather, tunnel)
#
sub runsecureserver {
- my ($verbose, $ipv6, $certfile, $proto, $clearport) = @_;
+ my ($verb, $ipv6, $certfile, $proto, $clearport) = @_;
my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
my $idnum = 1;
$doesntrun{$pidfile} = 0;
$runcert{$server} = $certfile;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server is PID $protospid port $port\n";
}
last;
# start the tftp server
#
sub runtftpserver {
- my ($id, $verbose, $ipv6) = @_;
+ my ($id, $verb, $ipv6) = @_;
my $ip = $HOSTIP;
my $proto = 'tftp';
my $ipvnum = 4;
}
$pid2 = $pid3;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server on PID $tftppid port $port\n";
}
# start the rtsp server
#
sub runrtspserver {
- my ($verbose, $ipv6) = @_;
+ my ($verb, $ipv6) = @_;
my $ip = $HOSTIP;
my $proto = 'rtsp';
my $ipvnum = 4;
}
$pid2 = $pid3;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $rtsppid port $port\n";
}
# Start the ssh (scp/sftp) server
#
sub runsshserver {
- my ($id, $verbose, $ipv6) = @_;
+ my ($id, $verb, $ipv6) = @_;
my $ip=$HOSTIP;
my $proto = 'ssh';
my $ipvnum = 4;
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
my $flags = "";
- $flags .= "--verbose " if($verbose);
+ $flags .= "--verbose " if($verb);
$flags .= "--debugprotocol " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
{
my $msg = "Fatal: $srvrname pubkey md5 missing : \"$hstpubmd5f\" : $!";
logmsg "$msg\n";
- stopservers($verbose);
+ stopservers($verb);
die $msg;
}
{
my $msg = "Fatal: $srvrname pubkey sha256 missing : \"$hstpubsha256f\" : $!";
logmsg "$msg\n";
- stopservers($verbose);
+ stopservers($verb);
die $msg;
}
- logmsg "RUN: $srvrname on PID $pid2 port $wport\n" if($verbose);
+ logmsg "RUN: $srvrname on PID $pid2 port $wport\n" if($verb);
return ($pid2, $sshpid, $wport);
}
# Start the MQTT server
#
sub runmqttserver {
- my ($id, $verbose, $ipv6) = @_;
+ my ($id, $verb, $ipv6) = @_;
my $ip=$HOSTIP;
my $proto = 'mqtt';
my $port = protoport($proto);
my $mqttport = pidfromfile($portfile);
$PORT{"mqtt"} = $mqttport;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server is now running PID $pid2 on PORT $mqttport\n";
}
# Start the socks server
#
sub runsocksserver {
- my ($id, $verbose, $ipv6, $is_unix) = @_;
+ my ($id, $verb, $ipv6, $is_unix) = @_;
my $ip=$HOSTIP;
my $proto = 'socks';
my $ipvnum = 4;
my $port = pidfromfile($portfile);
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server is now running PID $pid2\n";
}
# start the dict server
#
sub rundictserver {
- my ($verbose, $alt) = @_;
+ my ($verb, $alt) = @_;
my $proto = "dict";
my $ip = $HOSTIP;
my $ipvnum = 4;
}
$doesntrun{$pidfile} = 0;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $dictpid port $port\n";
}
last;
# start the SMB server
#
sub runsmbserver {
- my ($verbose, $alt) = @_;
+ my ($verb, $alt) = @_;
my $proto = "smb";
my $ip = $HOSTIP;
my $ipvnum = 4;
}
$doesntrun{$pidfile} = 0;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $smbpid port $port\n";
}
last;
# start the telnet server
#
sub runnegtelnetserver {
- my ($verbose, $alt) = @_;
+ my ($verb, $alt) = @_;
my $proto = "telnet";
my $ip = $HOSTIP;
my $ipvnum = 4;
}
$doesntrun{$pidfile} = 0;
- if($verbose) {
+ if($verb) {
logmsg "RUN: $srvrname server PID $ntelpid port $port\n";
}
last;
# be used to verify that a server present in %run hash is still functional
#
sub responsive_http_server {
- my ($proto, $verbose, $alt, $port_or_path) = @_;
+ my ($proto, $verb, $alt, $port_or_path) = @_;
my $ip = $HOSTIP;
my $ipvnum = 4;
my $idnum = 1;
# used to verify that a server present in %run hash is still functional
#
sub responsive_pingpong_server {
- my ($proto, $id, $verbose, $ipv6) = @_;
+ my ($proto, $id, $verb, $ipv6) = @_;
my $port;
my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
# used to verify that a server present in %run hash is still functional
#
sub responsive_rtsp_server {
- my ($verbose, $ipv6) = @_;
+ my ($verb, $ipv6) = @_;
my $proto = 'rtsp';
my $port = protoport($proto);
my $ip = $HOSTIP;
# used to verify that a server present in %run hash is still functional
#
sub responsive_tftp_server {
- my ($id, $verbose, $ipv6) = @_;
+ my ($id, $verb, $ipv6) = @_;
my $proto = 'tftp';
my $port = protoport($proto);
my $ip = $HOSTIP;
# server present in %run hash is still functional
#
sub responsive_httptls_server {
- my ($verbose, $ipv6) = @_;
+ my ($verb, $ipv6) = @_;
my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
my $proto = "httptls";
my $port = protoport($proto);
$handle = "handle64.exe";
}
my @handles = `$handle $dir -accepteula -nobanner`;
- for $handle (@handles) {
- if($handle =~ /^(\S+)\s+pid:\s+(\d+)\s+type:\s+(\w+)\s+([0-9A-F]+):\s+(.+)\r\r/) {
+ for my $tryhandle (@handles) {
+ if($tryhandle =~ /^(\S+)\s+pid:\s+(\d+)\s+type:\s+(\w+)\s+([0-9A-F]+):\s+(.+)\r\r/) {
logmsg "Found $3 lock of '$5' ($4) by $1 ($2)\n";
# Ignore stunnel since we cannot do anything about its locks
if("$3" eq "File" && "$1" ne "tstunnel.exe") {
close(DISABLED);
if($disabled[0]) {
- map s/[\r\n]//g, @disabled;
+ s/[\r\n]//g for @disabled;
$dis = join(", ", @disabled);
}
if($_ =~ /^curl ([^ ]*)/) {
$curl = $_;
- $VERSION = $1;
- $curl =~ s/^(.*)(libcurl.*)/$1/g;
+ $CURLVERSION = $1;
+ $curl =~ s/^(.*)(libcurl.*)/$1/g || die "Failure determining curl binary version";
$libcurl = $2;
if($curl =~ /linux|bsd|solaris/) {
$$thing =~ s/${prefix}CURL/$CURL/g;
$$thing =~ s/${prefix}PWD/$pwd/g;
$$thing =~ s/${prefix}POSIX_PWD/$posix_pwd/g;
- $$thing =~ s/${prefix}VERSION/$VERSION/g;
+ $$thing =~ s/${prefix}VERSION/$CURLVERSION/g;
$$thing =~ s/${prefix}TESTNUMBER/$testnum/g;
my $file_pwd = $pwd;
my @info_keywords = getpart("info", "keywords");
if(!$why) {
my $match;
- my $k;
# Clear the list of keywords from the last test
%keywords = ();
$why = "missing the <keywords> section!";
}
- for $k (@info_keywords) {
+ for my $k (@info_keywords) {
chomp $k;
if ($disabled_keywords{lc($k)}) {
$why = "disabled by keyword";
@entiretest = prepro($testnum, @entiretest);
# save the new version
- open(D, ">$otest");
+ open(D, ">$otest") || die "Failure writing test file";
foreach my $bytes (@entiretest) {
print D pack('a*', $bytes) or die "Failed to print '$bytes': $!";
}
- close(D);
+ close(D) || die "Failure writing test file";
# in case the process changed the file, reload it
loadtest("log/test${testnum}");
# Set up the test environment to run this test case
sub singletest_setenv {
my @setenv = getpart("client", "setenv");
- if(@setenv) {
- foreach my $s (@setenv) {
- chomp $s;
- if($s =~ /([^=]*)=(.*)/) {
- my ($var, $content) = ($1, $2);
- # remember current setting, to restore it once test runs
- $oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset';
- # set new value
- if(!$content) {
- delete $ENV{$var} if($ENV{$var});
- }
- else {
- if($var =~ /^LD_PRELOAD/) {
- if(exe_ext('TOOL') && (exe_ext('TOOL') eq '.exe')) {
- # print "Skipping LD_PRELOAD due to lack of OS support\n";
- next;
- }
- if($feature{"debug"} || !$has_shared) {
- # print "Skipping LD_PRELOAD due to no release shared build\n";
- next;
- }
+ foreach my $s (@setenv) {
+ chomp $s;
+ if($s =~ /([^=]*)=(.*)/) {
+ my ($var, $content) = ($1, $2);
+ # remember current setting, to restore it once test runs
+ $oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset';
+ # set new value
+ if(!$content) {
+ delete $ENV{$var} if($ENV{$var});
+ }
+ else {
+ if($var =~ /^LD_PRELOAD/) {
+ if(exe_ext('TOOL') && (exe_ext('TOOL') eq '.exe')) {
+ # print "Skipping LD_PRELOAD due to lack of OS support\n";
+ next;
+ }
+ if($feature{"debug"} || !$has_shared) {
+ # print "Skipping LD_PRELOAD due to no release shared build\n";
+ next;
}
- $ENV{$var} = "$content";
- print "setenv $var = $content\n" if($verbose);
}
+ $ENV{$var} = "$content";
+ print "setenv $var = $content\n" if($verbose);
}
}
}
my %hash = getpartattr("client", "stdin");
if($hash{'nonewline'}) {
# cut off the final newline from the final line of the stdin data
- chomp($stdintest[$#stdintest]);
+ chomp($stdintest[-1]);
}
writearray($stdinfile, \@stdintest);
logmsg "$CMDLINE\n";
}
- open(CMDLOG, ">", "$LOGDIR/$CURLLOG");
+ open(CMDLOG, ">", "$LOGDIR/$CURLLOG") || die "Failure writing log file";
print CMDLOG "$CMDLINE\n";
- close(CMDLOG);
+ close(CMDLOG) || die "Failure writing log file";
my $dumped_core;
my $cmdres;
if($gdbthis) {
my $gdbinit = "$TESTDIR/gdbinit$testnum";
- open(GDBCMD, ">$LOGDIR/gdbcmd");
+ open(GDBCMD, ">$LOGDIR/gdbcmd") || die "Failure writing gdb file";
print GDBCMD "set args $cmdargs\n";
print GDBCMD "show args\n";
print GDBCMD "source $gdbinit\n" if -e $gdbinit;
- close(GDBCMD);
+ close(GDBCMD) || die "Failure writing gdb file";
}
# Flush output.
logmsg "core dumped\n";
if(0 && $gdb) {
logmsg "running gdb for post-mortem analysis:\n";
- open(GDBCMD, ">$LOGDIR/gdbcmd2");
+ open(GDBCMD, ">$LOGDIR/gdbcmd2") || die "Failure writing gdb file";
print GDBCMD "bt\n";
- close(GDBCMD);
+ close(GDBCMD) || die "Failure writing gdb file";
runclient("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch $DBGCURL core ");
# unlink("$LOGDIR/gdbcmd2");
}
my $filemode=$hash{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on windows: fix line endings
- map s/\r\n/\n/g, @validstdout;
- map s/\n/\r\n/g, @validstdout;
+ s/\r\n/\n/g for @validstdout;
+ s/\n/\r\n/g for @validstdout;
}
if($hash{'nonewline'}) {
# Yes, we must cut off the final newline from the final line
# of the protocol data
- chomp($validstdout[$#validstdout]);
+ chomp($validstdout[-1]);
}
if($hash{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"}
|| $keywords{"HTTPS"}))) {
- map subNewlines(0, \$_), @validstdout;
+ subNewlines(0, \$_) for @validstdout;
}
$res = compare($testnum, $testname, "stdout", \@actual, \@validstdout);
# text mode check in hyper-mode. Sometimes necessary if the stderr
# data *looks* like HTTP and thus has gotten CRLF newlines
# mistakenly
- map s/\r\n/\n/g, @validstderr;
+ s/\r\n/\n/g for @validstderr;
}
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on windows: fix line endings
- map s/\r\n/\n/g, @validstderr;
- map s/\n/\r\n/g, @validstderr;
+ s/\r\n/\n/g for @validstderr;
+ s/\n/\r\n/g for @validstderr;
}
if($hash{'nonewline'}) {
# Yes, we must cut off the final newline from the final line
# of the protocol data
- chomp($validstderr[$#validstderr]);
+ chomp($validstderr[-1]);
}
$res = compare($testnum, $testname, "stderr", \@actual, \@validstderr);
if($hash{'nonewline'}) {
# Yes, we must cut off the final newline from the final line
# of the protocol data
- chomp($protocol[$#protocol]);
+ chomp($protocol[-1]);
}
for(@strip) {
@protocol= striparray( $_, \@protocol);
}
- my $strip;
-
- for $strip (@strippart) {
+ for my $strip (@strippart) {
chomp $strip;
for(@out) {
eval $strip;
}
if($hash{'crlf'}) {
- map subNewlines(1, \$_), @protocol;
+ subNewlines(1, \$_) for @protocol;
}
if((!$out[0] || ($out[0] eq "")) && $protocol[0]) {
my $filemode=$replycheckpartattr{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on windows: fix line endings
- map s/\r\n/\n/g, @replycheckpart;
- map s/\n/\r\n/g, @replycheckpart;
+ s/\r\n/\n/g for @replycheckpart;
+ s/\n/\r\n/g for @replycheckpart;
}
if($replycheckpartattr{'nonewline'}) {
# Yes, we must cut off the final newline from the final line
# of the datacheck
- chomp($replycheckpart[$#replycheckpart]);
+ chomp($replycheckpart[-1]);
}
if($replycheckpartattr{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"}
|| $keywords{"HTTPS"}))) {
- map subNewlines(0, \$_), @replycheckpart;
+ subNewlines(0, \$_) for @replycheckpart;
}
push(@reply, @replycheckpart);
}
if(@reply) {
if($replyattr{'nonewline'}) {
# cut off the final newline from the final line of the data
- chomp($reply[$#reply]);
+ chomp($reply[-1]);
}
}
# get the mode attribute
my $filemode=$replyattr{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on windows: fix line endings
- map s/\r\n/\n/g, @reply;
- map s/\n/\r\n/g, @reply;
+ s/\r\n/\n/g for @reply;
+ s/\n/\r\n/g for @reply;
}
if($replyattr{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"}
|| $keywords{"HTTPS"}))) {
- map subNewlines(0, \$_), @reply;
+ subNewlines(0, \$_) for @reply;
}
}
my %hash = getpartattr("verify", "upload");
if($hash{'nonewline'}) {
# cut off the final newline from the final line of the upload data
- chomp($upload[$#upload]);
+ chomp($upload[-1]);
}
# verify uploaded data
my @out = loadarray("$LOGDIR/upload.$testnum");
- my $strip;
- for $strip (@strippart) {
+ for my $strip (@strippart) {
chomp $strip;
for(@out) {
eval $strip;
if($hash{'nonewline'}) {
# Yes, we must cut off the final newline from the final line
# of the protocol data
- chomp($proxyprot[$#proxyprot]);
+ chomp($proxyprot[-1]);
}
my @out = loadarray($PROXYIN);
@proxyprot= striparray( $_, \@proxyprot);
}
- my $strip;
- for $strip (@strippart) {
+ for my $strip (@strippart) {
chomp $strip;
for(@out) {
eval $strip;
if($hash{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"} || $keywords{"HTTPS"}))) {
- map subNewlines(0, \$_), @proxyprot;
+ subNewlines(0, \$_) for @proxyprot;
}
$res = compare($testnum, $testname, "proxy", \@out, \@proxyprot);
my @generated=loadarray($filename);
# what parts to cut off from the file
- my @stripfile = getpart("verify", "stripfile".$partsuffix);
+ my @stripfilepar = getpart("verify", "stripfile".$partsuffix);
my $filemode=$hash{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on windows: fix line endings
- map s/\r\n/\n/g, @outfile;
- map s/\n/\r\n/g, @outfile;
+ s/\r\n/\n/g for @outfile;
+ s/\n/\r\n/g for @outfile;
}
if($hash{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"}
|| $keywords{"HTTPS"}))) {
- map subNewlines(0, \$_), @outfile;
+ subNewlines(0, \$_) for @outfile;
}
- my $strip;
- for $strip (@stripfile) {
+ for my $strip (@stripfilepar) {
chomp $strip;
my @newgen;
for(@generated) {
if($valgrind) {
if(use_valgrind() && !$disablevalgrind) {
- unless(opendir(DIR, "$LOGDIR")) {
+ if(!opendir(DIR, "$LOGDIR")) {
logmsg "ERROR: unable to read $LOGDIR\n";
# timestamp test result verification end
$timevrfyend{$testnum} = Time::HiRes::time();
my $sofar= time()-$start;
my $esttotal = $sofar/$count * $total;
my $estleft = $esttotal - $sofar;
- my $left=sprintf("remaining: %02d:%02d",
+ my $timeleft=sprintf("remaining: %02d:%02d",
$estleft/60,
$estleft%60);
my $took = $timevrfyend{$testnum} - $timeprepini{$testnum};
$sofar/60, $sofar%60);
if(!$automakestyle) {
logmsg sprintf("OK (%-3d out of %-3d, %s, took %.3fs, %s)\n",
- $count, $total, $left, $took, $duration);
+ $count, $total, $timeleft, $took, $duration);
}
else {
my $testname= (getpart("client", "name"))[0];
# Stop all running test servers
#
sub stopservers {
- my $verbose = $_[0];
+ my $verb = $_[0];
#
# kill sockfilter processes for all pingpong servers
#
- killallsockfilters($verbose);
+ killallsockfilters($verb);
#
# kill all server pids from %run hash clearing them
#
my $pidlist;
foreach my $server (keys %run) {
if($run{$server}) {
- if($verbose) {
+ if($verb) {
my $prev = 0;
my $pids = $run{$server};
foreach my $pid (split(' ', $pids)) {
}
$runcert{$server} = 0 if($runcert{$server});
}
- killpid($verbose, $pidlist);
+ killpid($verb, $pidlist);
#
# cleanup all server pid files
#
logmsg "Warning: ";
}
logmsg "$server server unexpectedly alive\n";
- killpid($verbose, $pid);
+ killpid($verb, $pid);
}
unlink($pidfile) if(-f $pidfile);
}
die "Unsupported type: $type\n" if($type !~ /^keyword|test|tool$/);
foreach my $pattern (split(/,/, $patterns)) {
- if($type =~ /^test$/) {
+ if($type eq "test") {
# Strip leading zeros in the test number
$pattern = int($pattern);
}
}
elsif(($ARGV[0] eq "-h") || ($ARGV[0] eq "--help")) {
# show help text
- print <<EOHELP
+ print <<"EOHELP"
Usage: runtests.pl [options] [test selection(s)]
-a continue even if a test fails
-ac path use this curl only to talk to APIs (currently only CI test APIs)
}
else {
my $verified="";
- map {
+ for(split(" ", $TESTCASES)) {
if (-e "$TESTDIR/test$_") {
$verified.="$_ ";
}
- } split(" ", $TESTCASES);
+ }
if($verified eq "") {
print "No existing test cases were specified\n";
exit;
$string =~ s/[\r\f\032]/\n/g;
$string .= "\n" unless ($string =~ /\n$/);
$string =~ tr/\n//;
- for my $line (split("\n", $string)) {
+ for my $line (split(m/\n/, $string)) {
$line =~ s/\s*\!$//;
if ($truncate) {
push @tail, " $line\n";
$truncate = $linecount > 1000;
}
}
+ close(SINGLE);
if(@tail) {
my $tailshow = 200;
my $tailskip = 0;
logmsg "$tail[$_]";
}
}
- close(SINGLE);
}
}
if(($log =~ /^trace\d+/) && ($log !~ /^trace$testnum/)) {
next; # skip traceNnn of other tests
}
- if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(\..*|)$/)) {
+ if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(?:\..*)?$/)) {
next; # skip valgrindNnn of other tests
}
if(($log =~ /^test$testnum$/)) {
my $failed;
my $failedign;
-my $testnum;
my $ok=0;
my $ign=0;
my $total=0;
$start = time();
-foreach $testnum (@at) {
+foreach my $testnum (@at) {
$lasttest = $testnum if($testnum > $lasttest);
$count++;