mirror of
https://github.com/curl/curl.git
synced 2024-12-09 06:30:06 +08:00
runtests: remove directory from server filename variables
There will soon be multiple log directories so the paths will no longer be static in runtests.pl. Also, get rid of $SERVER2IN which was not used. Ref: #10818
This commit is contained in:
parent
b71a0c3ec9
commit
82fa5ca836
@ -44,14 +44,13 @@ BEGIN {
|
||||
$listonly
|
||||
$LOGDIR
|
||||
$memanalyze
|
||||
$memdump
|
||||
$MEMDUMP
|
||||
$perl
|
||||
$PIDDIR
|
||||
$proxy_address
|
||||
$PROXYIN
|
||||
$pwd
|
||||
$run_event_based
|
||||
$SERVER2IN
|
||||
$SERVERIN
|
||||
$srcdir
|
||||
$TESTDIR
|
||||
@ -87,15 +86,6 @@ our $pwd = getcwd(); # current working directory
|
||||
our $srcdir = $ENV{'srcdir'} || '.'; # root of the test source code
|
||||
our $perl="perl -I$srcdir"; # invoke perl like this
|
||||
our $LOGDIR="log"; # root of the log directory
|
||||
# TODO: $LOGDIR could eventually change later on, so must regenerate all the
|
||||
# paths depending on it after $LOGDIR itself changes.
|
||||
our $PIDDIR = "$LOGDIR/server"; # root of the server directory with PID files
|
||||
# TODO: change this to use server_inputfilename()
|
||||
our $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
|
||||
our $SERVER2IN="$LOGDIR/server2.input"; # what curl sent the second server
|
||||
our $PROXYIN="$LOGDIR/proxy.input"; # what curl sent the proxy
|
||||
our $memdump="$LOGDIR/memdump"; # file that the memory debugging creates
|
||||
our $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy server instructions here
|
||||
our $LIBDIR="./libtest";
|
||||
our $TESTDIR="$srcdir/data";
|
||||
our $CURL="../src/curl".exe_ext('TOOL'); # what curl binary to run on the tests
|
||||
@ -106,6 +96,13 @@ our $VCURL=$CURL; # what curl binary to use to verify the servers with
|
||||
our $memanalyze="$perl $srcdir/memanalyze.pl";
|
||||
our $valgrind; # path to valgrind, or empty if disabled
|
||||
|
||||
# paths in $LOGDIR
|
||||
our $PIDDIR = "server"; # root of the server directory with PID files
|
||||
our $SERVERIN="server.input"; # what curl sent the server
|
||||
our $PROXYIN="proxy.input"; # what curl sent the proxy
|
||||
our $MEMDUMP="memdump"; # file that the memory debugging creates
|
||||
our $FTPDCMD="ftpserver.cmd"; # copy server instructions here
|
||||
|
||||
# other config variables
|
||||
our @protocols; # array of lowercase supported protocol servers
|
||||
our %feature; # hash of enabled features
|
||||
|
@ -227,7 +227,7 @@ sub torture {
|
||||
my ($testcmd, $testnum, $gdbline) = @_;
|
||||
|
||||
# remove memdump first to be sure we get a new nice and clean one
|
||||
unlink($memdump);
|
||||
unlink("$LOGDIR/$MEMDUMP");
|
||||
|
||||
# First get URL from test server, ignore the output/result
|
||||
runclient($testcmd);
|
||||
@ -236,7 +236,7 @@ sub torture {
|
||||
|
||||
# memanalyze -v is our friend, get the number of allocations made
|
||||
my $count=0;
|
||||
my @out = `$memanalyze -v $memdump`;
|
||||
my @out = `$memanalyze -v "$LOGDIR/$MEMDUMP"`;
|
||||
for(@out) {
|
||||
if(/^Operations: (\d+)/) {
|
||||
$count = $1;
|
||||
@ -291,7 +291,7 @@ sub torture {
|
||||
$ENV{'CURL_MEMLIMIT'} = $limit;
|
||||
|
||||
# remove memdump first to be sure we get a new nice and clean one
|
||||
unlink($memdump);
|
||||
unlink("$LOGDIR/$MEMDUMP");
|
||||
|
||||
my $cmd = $testcmd;
|
||||
if($valgrind && !$gdbthis) {
|
||||
@ -349,7 +349,7 @@ sub torture {
|
||||
$fail=1;
|
||||
}
|
||||
else {
|
||||
my @memdata=`$memanalyze $memdump`;
|
||||
my @memdata=`$memanalyze "$LOGDIR/$MEMDUMP"`;
|
||||
my $leak=0;
|
||||
for(@memdata) {
|
||||
if($_ ne "") {
|
||||
@ -361,7 +361,7 @@ sub torture {
|
||||
if($leak) {
|
||||
logmsg "** MEMORY FAILURE\n";
|
||||
logmsg @memdata;
|
||||
logmsg `$memanalyze -l $memdump`;
|
||||
logmsg `$memanalyze -l "$LOGDIR/$MEMDUMP"`;
|
||||
$fail = 1;
|
||||
}
|
||||
}
|
||||
@ -403,10 +403,9 @@ sub singletest_startservers {
|
||||
my ($testnum, $testtimings) = @_;
|
||||
|
||||
# remove old test server files before servers are started/verified
|
||||
unlink($FTPDCMD);
|
||||
unlink($SERVERIN);
|
||||
unlink($SERVER2IN);
|
||||
unlink($PROXYIN);
|
||||
unlink("$LOGDIR/$FTPDCMD");
|
||||
unlink("$LOGDIR/$SERVERIN");
|
||||
unlink("$LOGDIR/$PROXYIN");
|
||||
|
||||
# timestamp required servers verification start
|
||||
$$testtimings{"timesrvrini"} = Time::HiRes::time();
|
||||
@ -543,20 +542,19 @@ sub singletest_prepare {
|
||||
my ($testnum) = @_;
|
||||
|
||||
if($feature{"TrackMemory"}) {
|
||||
unlink($memdump);
|
||||
unlink("$LOGDIR/$MEMDUMP");
|
||||
}
|
||||
unlink("core");
|
||||
|
||||
# remove server output logfiles after servers are started/verified
|
||||
unlink($SERVERIN);
|
||||
unlink($SERVER2IN);
|
||||
unlink($PROXYIN);
|
||||
unlink("$LOGDIR/$SERVERIN");
|
||||
unlink("$LOGDIR/$PROXYIN");
|
||||
|
||||
# if this section exists, it might be FTP server instructions:
|
||||
my @ftpservercmd = getpart("reply", "servercmd");
|
||||
push @ftpservercmd, "Testnum $testnum\n";
|
||||
# write the instructions to file
|
||||
writearray($FTPDCMD, \@ftpservercmd);
|
||||
writearray("$LOGDIR/$FTPDCMD", \@ftpservercmd);
|
||||
|
||||
# create (possibly-empty) files before starting the test
|
||||
for my $partsuffix (('', '1', '2', '3', '4')) {
|
||||
|
@ -183,7 +183,7 @@ sub logmsg {
|
||||
}
|
||||
|
||||
# enable memory debugging if curl is compiled with it
|
||||
$ENV{'CURL_MEMDEBUG'} = $memdump;
|
||||
$ENV{'CURL_MEMDEBUG'} = "$LOGDIR/$MEMDUMP";
|
||||
$ENV{'CURL_ENTROPY'}="12345678";
|
||||
$ENV{'CURL_FORCETIME'}=1; # for debug NTLM magic
|
||||
$ENV{'CURL_GLOBAL_INIT'}=1; # debug curl_global_init/cleanup use
|
||||
@ -277,7 +277,7 @@ sub cleardir {
|
||||
return 0; # can't open dir
|
||||
while($file = readdir($dh)) {
|
||||
# Don't clear the $PIDDIR since those need to live beyond one test
|
||||
if(($file !~ /^(\.|\.\.)\z/) && "$dir/$file" ne $PIDDIR) {
|
||||
if(($file !~ /^(\.|\.\.)\z/) && "$file" ne $PIDDIR) {
|
||||
if(-d "$dir/$file") {
|
||||
if(!cleardir("$dir/$file")) {
|
||||
$done = 0;
|
||||
@ -1215,7 +1215,7 @@ sub singletest_check {
|
||||
my @protocol= getpart("verify", "protocol");
|
||||
if(@protocol) {
|
||||
# Verify the sent request
|
||||
my @out = loadarray($SERVERIN);
|
||||
my @out = loadarray("$logdir/$SERVERIN");
|
||||
|
||||
# check if there's any attributes on the verify/protocol section
|
||||
my %hash = getpartattr("verify", "protocol");
|
||||
@ -1246,7 +1246,7 @@ sub singletest_check {
|
||||
|
||||
if((!$out[0] || ($out[0] eq "")) && $protocol[0]) {
|
||||
logmsg "\n $testnum: protocol FAILED!\n".
|
||||
" There was no content at all in the file $SERVERIN.\n".
|
||||
" There was no content at all in the file $logdir/$SERVERIN.\n".
|
||||
" Server glitch? Total curl failure? Returned: $cmdres\n";
|
||||
# timestamp test result verification end
|
||||
$timevrfyend{$testnum} = Time::HiRes::time();
|
||||
@ -1370,7 +1370,7 @@ sub singletest_check {
|
||||
chomp($proxyprot[-1]);
|
||||
}
|
||||
|
||||
my @out = loadarray($PROXYIN);
|
||||
my @out = loadarray("$logdir/$PROXYIN");
|
||||
for(@strip) {
|
||||
# strip off all lines that match the patterns from both arrays
|
||||
chomp $_;
|
||||
@ -1498,14 +1498,14 @@ sub singletest_check {
|
||||
}
|
||||
|
||||
if($feature{"TrackMemory"}) {
|
||||
if(! -f $memdump) {
|
||||
if(! -f "$logdir/$MEMDUMP") {
|
||||
my %cmdhash = getpartattr("client", "command");
|
||||
my $cmdtype = $cmdhash{'type'} || "default";
|
||||
logmsg "\n** ALERT! memory tracking with no output file?\n"
|
||||
if(!$cmdtype eq "perl");
|
||||
}
|
||||
else {
|
||||
my @memdata=`$memanalyze $memdump`;
|
||||
my @memdata=`$memanalyze "$logdir/$MEMDUMP"`;
|
||||
my $leak=0;
|
||||
for(@memdata) {
|
||||
if($_ ne "") {
|
||||
@ -2231,7 +2231,7 @@ if ($gdbthis) {
|
||||
|
||||
cleardir($LOGDIR);
|
||||
mkdir($LOGDIR, 0777);
|
||||
mkdir($PIDDIR, 0777);
|
||||
mkdir("$LOGDIR/$PIDDIR", 0777);
|
||||
|
||||
#######################################################################
|
||||
# initialize some variables
|
||||
@ -2246,7 +2246,7 @@ setlogfunc(\&logmsg);
|
||||
#
|
||||
|
||||
if(!$listonly) {
|
||||
unlink($memdump); # remove this if there was one left
|
||||
unlink("$LOGDIR/$MEMDUMP"); # remove this if there was one left
|
||||
checksystemfeatures();
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ sub checkcmd {
|
||||
#######################################################################
|
||||
# Initialize configuration variables
|
||||
sub initserverconfig {
|
||||
$SOCKSUNIXPATH = "$PIDDIR/socks.sock"; # SOCKS server Unix domain socket path
|
||||
$HTTPUNIXPATH = "$PIDDIR/http.sock"; # HTTP server Unix domain socket path
|
||||
$SOCKSUNIXPATH = "$LOGDIR/$PIDDIR/socks.sock"; # SOCKS Unix domain socket
|
||||
$HTTPUNIXPATH = "$LOGDIR/$PIDDIR/http.sock"; # HTTP Unix domain socket
|
||||
$stunnel = checkcmd("stunnel4") || checkcmd("tstunnel") || checkcmd("stunnel");
|
||||
|
||||
# get the name of the current user
|
||||
@ -195,9 +195,11 @@ sub init_serverpidfile_hash {
|
||||
for my $ipvnum ((4, 6)) {
|
||||
for my $idnum ((1, 2, 3)) {
|
||||
my $serv = servername_id("$proto$ssl", $ipvnum, $idnum);
|
||||
my $pidf = server_pidfilename($PIDDIR, "$proto$ssl", $ipvnum, $idnum);
|
||||
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
|
||||
$ipvnum, $idnum);
|
||||
$serverpidfile{$serv} = $pidf;
|
||||
my $portf = server_portfilename($PIDDIR, "$proto$ssl", $ipvnum, $idnum);
|
||||
my $portf = server_portfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
|
||||
$ipvnum, $idnum);
|
||||
$serverportfile{$serv} = $portf;
|
||||
}
|
||||
}
|
||||
@ -208,9 +210,11 @@ sub init_serverpidfile_hash {
|
||||
for my $ipvnum ((4, 6)) {
|
||||
for my $idnum ((1, 2)) {
|
||||
my $serv = servername_id($proto, $ipvnum, $idnum);
|
||||
my $pidf = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum);
|
||||
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
|
||||
$idnum);
|
||||
$serverpidfile{$serv} = $pidf;
|
||||
my $portf = server_portfilename($PIDDIR, $proto, $ipvnum, $idnum);
|
||||
my $portf = server_portfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
|
||||
$idnum);
|
||||
$serverportfile{$serv} = $portf;
|
||||
}
|
||||
}
|
||||
@ -218,9 +222,11 @@ sub init_serverpidfile_hash {
|
||||
for my $proto (('http', 'imap', 'pop3', 'smtp', 'http/2', 'http/3')) {
|
||||
for my $ssl (('', 's')) {
|
||||
my $serv = servername_id("$proto$ssl", "unix", 1);
|
||||
my $pidf = server_pidfilename($PIDDIR, "$proto$ssl", "unix", 1);
|
||||
my $pidf = server_pidfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
|
||||
"unix", 1);
|
||||
$serverpidfile{$serv} = $pidf;
|
||||
my $portf = server_portfilename($PIDDIR, "$proto$ssl", "unix", 1);
|
||||
my $portf = server_portfilename("$LOGDIR/$PIDDIR", "$proto$ssl",
|
||||
"unix", 1);
|
||||
$serverportfile{$serv} = $portf;
|
||||
}
|
||||
}
|
||||
@ -418,7 +424,7 @@ sub stopserver {
|
||||
my $proto = $1;
|
||||
my $idnum = ($2 && ($2 > 1)) ? $2 : 1;
|
||||
my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4;
|
||||
killsockfilters($PIDDIR, $proto, $ipvnum, $idnum, $verbose);
|
||||
killsockfilters("$LOGDIR/$PIDDIR", $proto, $ipvnum, $idnum, $verbose);
|
||||
}
|
||||
#
|
||||
# All servers relative to the given one must be stopped also
|
||||
@ -727,7 +733,8 @@ sub verifyrtsp {
|
||||
#
|
||||
sub verifyssh {
|
||||
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
|
||||
my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum);
|
||||
my $pidfile = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
|
||||
$idnum);
|
||||
my $pid = processexists($pidfile);
|
||||
if($pid < 0) {
|
||||
logmsg "RUN: SSH server has died after starting up\n";
|
||||
@ -757,7 +764,7 @@ sub verifysftp {
|
||||
}
|
||||
# Connect to sftp server, authenticate and run a remote pwd
|
||||
# command using our generated configuration and key files
|
||||
my $cmd = "\"$sftp\" -b $PIDDIR/$sftpcmds -F $PIDDIR/$sftpconfig -S \"$ssh\" $ip > $sftplog 2>&1";
|
||||
my $cmd = "\"$sftp\" -b $LOGDIR/$PIDDIR/$sftpcmds -F $LOGDIR/$PIDDIR/$sftpconfig -S \"$ssh\" $ip > $sftplog 2>&1";
|
||||
my $res = runclient($cmd);
|
||||
# Search for pwd command response in log file
|
||||
if(open(my $sftplogfile, "<", "$sftplog")) {
|
||||
@ -781,7 +788,8 @@ sub verifysftp {
|
||||
sub verifyhttptls {
|
||||
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
|
||||
my $server = servername_id($proto, $ipvnum, $idnum);
|
||||
my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum);
|
||||
my $pidfile = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
|
||||
$idnum);
|
||||
|
||||
my $verifyout = "$LOGDIR/".
|
||||
servername_canon($proto, $ipvnum, $idnum) .'_verify.out';
|
||||
@ -858,7 +866,8 @@ sub verifyhttptls {
|
||||
#
|
||||
sub verifysocks {
|
||||
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
|
||||
my $pidfile = server_pidfilename($PIDDIR, $proto, $ipvnum, $idnum);
|
||||
my $pidfile = server_pidfilename("$LOGDIR/$PIDDIR", $proto, $ipvnum,
|
||||
$idnum);
|
||||
my $pid = processexists($pidfile);
|
||||
if($pid < 0) {
|
||||
logmsg "RUN: SOCKS server has died after starting up\n";
|
||||
@ -1120,7 +1129,7 @@ sub runhttpserver {
|
||||
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
||||
$flags .= "--logdir \"$LOGDIR\" ";
|
||||
$flags .= "--portfile $portfile ";
|
||||
$flags .= "--config $FTPDCMD ";
|
||||
$flags .= "--config $LOGDIR/$FTPDCMD ";
|
||||
$flags .= "--id $idnum " if($idnum > 1);
|
||||
if($ipvnum eq "unix") {
|
||||
$flags .= "--unix-socket '$port_or_path' ";
|
||||
@ -1887,7 +1896,7 @@ sub runsshserver {
|
||||
}
|
||||
|
||||
my $hostfile;
|
||||
if(!open($hostfile, "<", $PIDDIR . "/" . $hstpubmd5f) ||
|
||||
if(!open($hostfile, "<", "$LOGDIR/$PIDDIR/$hstpubmd5f") ||
|
||||
(read($hostfile, $SSHSRVMD5, 32) != 32) ||
|
||||
!close($hostfile) ||
|
||||
($SSHSRVMD5 !~ /^[a-f0-9]{32}$/i))
|
||||
@ -1898,7 +1907,7 @@ sub runsshserver {
|
||||
die $msg;
|
||||
}
|
||||
|
||||
if(!open($hostfile, "<", $PIDDIR . "/" . $hstpubsha256f) ||
|
||||
if(!open($hostfile, "<", "$LOGDIR/$PIDDIR/$hstpubsha256f") ||
|
||||
(read($hostfile, $SSHSRVSHA256, 48) == 0) ||
|
||||
!close($hostfile))
|
||||
{
|
||||
@ -1947,7 +1956,7 @@ sub runmqttserver {
|
||||
" --port 0 ".
|
||||
" --pidfile $pidfile".
|
||||
" --portfile $portfile".
|
||||
" --config $FTPDCMD".
|
||||
" --config $LOGDIR/$FTPDCMD".
|
||||
" --logfile $logfile".
|
||||
" --logdir $LOGDIR";
|
||||
my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0);
|
||||
@ -2008,7 +2017,7 @@ sub runsocksserver {
|
||||
" --logfile $logfile".
|
||||
" --unix-socket $SOCKSUNIXPATH".
|
||||
" --backend $HOSTIP".
|
||||
" --config $FTPDCMD";
|
||||
" --config $LOGDIR/$FTPDCMD";
|
||||
} else {
|
||||
$cmd="server/socksd".exe_ext('SRV').
|
||||
" --port 0 ".
|
||||
@ -2017,7 +2026,7 @@ sub runsocksserver {
|
||||
" --reqfile $LOGDIR/$SOCKSIN".
|
||||
" --logfile $logfile".
|
||||
" --backend $HOSTIP".
|
||||
" --config $FTPDCMD";
|
||||
" --config $LOGDIR/$FTPDCMD";
|
||||
}
|
||||
my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0);
|
||||
|
||||
@ -2912,7 +2921,7 @@ sub stopservers {
|
||||
#
|
||||
# kill sockfilter processes for all pingpong servers
|
||||
#
|
||||
killallsockfilters($PIDDIR, $verb);
|
||||
killallsockfilters("$LOGDIR/$PIDDIR", $verb);
|
||||
#
|
||||
# kill all server pids from %run hash clearing them
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user