From 8a298119f13dc2243078bc18cc0db740cccfb29b Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 29 Mar 2023 08:54:57 -0700 Subject: [PATCH] tests: fix http servers to run with a dynamic log directory Ref: #10818 --- tests/http-server.pl | 15 +++++++++++++++ tests/http2-server.pl | 11 +++++++++-- tests/http3-server.pl | 11 +++++++++-- tests/runtests.pl | 4 ++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/http-server.pl b/tests/http-server.pl index d4978854bf..cd7401e9ca 100755 --- a/tests/http-server.pl +++ b/tests/http-server.pl @@ -49,6 +49,7 @@ my $proto = 'http'; # protocol the http server speaks my $pidfile; # pid file my $portfile; # port number file my $logfile; # log file +my $cmdfile; # command file my $connect; # IP to connect to on CONNECT my $srcdir; my $gopher = 0; @@ -70,12 +71,24 @@ while(@ARGV) { shift @ARGV; } } + elsif($ARGV[0] eq '--config') { + if($ARGV[1]) { + $cmdfile = $ARGV[1]; + shift @ARGV; + } + } elsif($ARGV[0] eq '--logfile') { if($ARGV[1]) { $logfile = $ARGV[1]; shift @ARGV; } } + elsif($ARGV[0] eq '--logdir') { + if($ARGV[1]) { + $logdir = $ARGV[1]; + shift @ARGV; + } + } elsif($ARGV[0] eq '--srcdir') { if($ARGV[1]) { $srcdir = $ARGV[1]; @@ -139,7 +152,9 @@ if(!$logfile) { } $flags .= "--pidfile \"$pidfile\" ". + "--cmdfile \"$cmdfile\" ". "--logfile \"$logfile\" ". + "--logdir \"$logdir\" ". "--portfile \"$portfile\" "; $flags .= "--gopher " if($gopher); $flags .= "--connect $connect " if($connect); diff --git a/tests/http2-server.pl b/tests/http2-server.pl index bbfaf47754..52c5284c0c 100755 --- a/tests/http2-server.pl +++ b/tests/http2-server.pl @@ -29,8 +29,9 @@ use Cwd; use Cwd 'abs_path'; use File::Basename; -my $pidfile = "log/nghttpx.pid"; -my $logfile = "log/http2.log"; +my $logdir = "log"; +my $pidfile = "$logdir/nghttpx.pid"; +my $logfile = "$logdir/http2.log"; my $nghttpx = "nghttpx"; my $listenport = 9015; my $listenport2 = 9016; @@ -82,6 +83,12 @@ while(@ARGV) { shift @ARGV; } } + elsif($ARGV[0] eq '--logdir') { + if($ARGV[1]) { + $logdir = $ARGV[1]; + shift @ARGV; + } + } elsif($ARGV[0] eq '--conf') { if($ARGV[1]) { $conf = $ARGV[1]; diff --git a/tests/http3-server.pl b/tests/http3-server.pl index 0c562fba3b..7e5f243454 100755 --- a/tests/http3-server.pl +++ b/tests/http3-server.pl @@ -30,8 +30,9 @@ use Cwd; use Cwd 'abs_path'; use File::Basename; -my $pidfile = "log/nghttpx.pid"; -my $logfile = "log/http3.log"; +my $logdir = "log"; +my $pidfile = "$logdir/nghttpx.pid"; +my $logfile = "$logdir/http3.log"; my $nghttpx = "nghttpx"; my $listenport = 9015; my $connect = "127.0.0.1,8990"; @@ -82,6 +83,12 @@ while(@ARGV) { shift @ARGV; } } + elsif($ARGV[0] eq '--logdir') { + if($ARGV[1]) { + $logdir = $ARGV[1]; + shift @ARGV; + } + } elsif($ARGV[0] eq '--conf') { if($ARGV[1]) { $conf = $ARGV[1]; diff --git a/tests/runtests.pl b/tests/runtests.pl index 06c934c74b..f0ac9e04b5 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -1479,6 +1479,7 @@ sub runhttp2server { $flags .= "--nghttpx \"$ENV{'NGHTTPX'}\" "; $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--logdir \"$LOGDIR\" "; $flags .= "--connect $HOSTIP:" . protoport("http") . " "; $flags .= $verbose_flag if($debugprotocol); @@ -1552,6 +1553,7 @@ sub runhttp3server { $flags .= "--nghttpx \"$ENV{'NGHTTPX'}\" "; $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--logdir \"$LOGDIR\" "; $flags .= "--connect $HOSTIP:" . protoport("http") . " "; $flags .= "--cert \"$cert\" " if($cert); $flags .= $verbose_flag if($debugprotocol); @@ -1639,7 +1641,9 @@ sub runhttpserver { $flags .= "--connect $HOSTIP " if($alt eq "proxy"); $flags .= $verbose_flag if($debugprotocol); $flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; + $flags .= "--logdir \"$LOGDIR\" "; $flags .= "--portfile $portfile "; + $flags .= "--config $FTPDCMD "; $flags .= "--id $idnum " if($idnum > 1); if($ipvnum eq "unix") { $flags .= "--unix-socket '$port_or_path' ";