diff options
-rw-r--r-- | tests/LightyTest.pm | 43 | ||||
-rw-r--r-- | tests/condition.conf | 3 | ||||
-rw-r--r-- | tests/fastcgi-responder.conf | 3 | ||||
-rw-r--r-- | tests/lighttpd.conf | 3 | ||||
-rw-r--r-- | tests/proxy.conf | 3 | ||||
-rw-r--r-- | tests/scgi-responder.conf | 3 |
6 files changed, 45 insertions, 13 deletions
diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm index e71fd2e6..6415413f 100644 --- a/tests/LightyTest.pm +++ b/tests/LightyTest.pm @@ -195,7 +195,7 @@ sub start_proc { } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'valgrind') { @cmdline = (qw(valgrind --tool=memcheck --track-origins=yes --show-reachable=yes --leak-check=yes --log-file=valgrind.%p), @cmdline); } - # diag("\nstarting lighttpd at :".$self->{PORT}.", cmdline: ".@cmdline ); + # diag("\nstarting lighttpd at :".$self->{PORT}.", cmdline: @cmdline"); my $child = fork(); if (not defined $child) { diag("\nFork failed"); @@ -203,21 +203,38 @@ sub start_proc { return -1; } if ($child == 0) { - # set up systemd socket activation env vars - $ENV{LISTEN_FDS} = "1"; - $ENV{LISTEN_PID} = $$; - if (defined($ENV{"TRACEME"}) && $ENV{"TRACEME"} ne "valgrind") { - $ENV{LISTEN_PID} = "parent:$$"; # lighttpd extension - } - listen($SOCK, 1024) || die "listen: $!"; - if (fileno($SOCK) != 3) { # SD_LISTEN_FDS_START 3 - require POSIX; - POSIX::dup2(fileno($SOCK), 3) || die "dup2: $!"; + if ($^O eq "MSWin32") { + # On platforms where systemd socket activation is not supported + # or inconvenient for testing (i.e. cygwin <-> native Windows exe), + # there is a race condition with close() before server start, + # but port specific port is unlikely to be reused so quickly, + # and the point is to avoid a port which is already in use. close($SOCK); + my $CONF; + open($CONF,'>',"$ENV{'SRCDIR'}/tmp/bind.conf") || die "open: $!"; + print $CONF <<BIND_OVERRIDE; +server.systemd-socket-activation := "disable" +server.bind = "127.0.0.1" +server.port = $ENV{'PORT'} +BIND_OVERRIDE } else { - require Fcntl; - fcntl($SOCK, Fcntl::F_SETFD(), 0); # clr FD_CLOEXEC + # set up systemd socket activation env vars + $ENV{LISTEN_FDS} = "1"; + $ENV{LISTEN_PID} = $$; + if (defined($ENV{"TRACEME"}) && $ENV{"TRACEME"} ne "valgrind") { + $ENV{LISTEN_PID} = "parent:$$"; # lighttpd extension + } + listen($SOCK, 1024) || die "listen: $!"; + if (fileno($SOCK) != 3) { # SD_LISTEN_FDS_START 3 + require POSIX; + POSIX::dup2(fileno($SOCK), 3) || die "dup2: $!"; + close($SOCK); + } + else { + require Fcntl; + fcntl($SOCK, Fcntl::F_SETFD(), 0); # clr FD_CLOEXEC + } } exec @cmdline or die($?); } diff --git a/tests/condition.conf b/tests/condition.conf index bbd2dd1c..55e2959a 100644 --- a/tests/condition.conf +++ b/tests/condition.conf @@ -2,6 +2,9 @@ debug.log-request-handling = "enable" debug.log-condition-handling = "enable" server.systemd-socket-activation = "enable" +# optional bind spec override, e.g. for platforms without socket activation +include env.SRCDIR + "/tmp/bind*.conf" + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" diff --git a/tests/fastcgi-responder.conf b/tests/fastcgi-responder.conf index 427d71af..3b90af07 100644 --- a/tests/fastcgi-responder.conf +++ b/tests/fastcgi-responder.conf @@ -3,6 +3,9 @@ debug.log-response-header = "enable" debug.log-request-handling = "enable" server.systemd-socket-activation = "enable" +# optional bind spec override, e.g. for platforms without socket activation +include env.SRCDIR + "/tmp/bind*.conf" + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" diff --git a/tests/lighttpd.conf b/tests/lighttpd.conf index c17d29fc..f8a064ca 100644 --- a/tests/lighttpd.conf +++ b/tests/lighttpd.conf @@ -7,6 +7,9 @@ debug.log-response-header = "enable" server.max-request-size = 65000 server.systemd-socket-activation = "enable" +# optional bind spec override, e.g. for platforms without socket activation +include env.SRCDIR + "/tmp/bind*.conf" + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" diff --git a/tests/proxy.conf b/tests/proxy.conf index 23a5173f..72d27a9c 100644 --- a/tests/proxy.conf +++ b/tests/proxy.conf @@ -1,4 +1,7 @@ server.systemd-socket-activation = "enable" +# optional bind spec override, e.g. for platforms without socket activation +include env.SRCDIR + "/tmp/bind*.conf" + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" diff --git a/tests/scgi-responder.conf b/tests/scgi-responder.conf index b1368d7e..15726b38 100644 --- a/tests/scgi-responder.conf +++ b/tests/scgi-responder.conf @@ -3,6 +3,9 @@ #debug.log-request-handling = "enable" server.systemd-socket-activation = "enable" +# optional bind spec override, e.g. for platforms without socket activation +include env.SRCDIR + "/tmp/bind*.conf" + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log" |