Browse Source

tests: fix http servers to run with a dynamic log directory

Ref: #10818
Dan Fandrich 1 year ago
parent
commit
8a298119f1
4 changed files with 37 additions and 4 deletions
  1. 15 0
      tests/http-server.pl
  2. 9 2
      tests/http2-server.pl
  3. 9 2
      tests/http3-server.pl
  4. 4 0
      tests/runtests.pl

+ 15 - 0
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);

+ 9 - 2
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];

+ 9 - 2
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];

+ 4 - 0
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' ";