diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:22 +0000 |
commit | c21c3b0befeb46a51b6bf3758ffa30813bea0ff0 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/misc/p5-Server-Starter/t/04-starter-dir.t | |
parent | Adding upstream version 1.43.2. (diff) | |
download | netdata-upstream/1.44.3.tar.xz netdata-upstream/1.44.3.zip |
Adding upstream version 1.44.3.upstream/1.44.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | web/server/h2o/libh2o/misc/p5-Server-Starter/t/04-starter-dir.t | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/p5-Server-Starter/t/04-starter-dir.t b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/04-starter-dir.t new file mode 100644 index 000000000..5f1b3968a --- /dev/null +++ b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/04-starter-dir.t @@ -0,0 +1,54 @@ +use strict; +use warnings; + +use File::Temp (); +use Test::More tests => 1; +use Net::EmptyPort qw/empty_port/; +use IO::Select; +use Server::Starter qw(start_server); + +$SIG{PIPE} = sub {}; + +pipe my $logrh, my $logwh + or die "Died: failed to create pipe:$!"; +my $port = empty_port + or die "could not get any port"; +my $tempdir = File::Temp::tempdir(CLEANUP => 0); +open(my $fh, '>', "$tempdir/dir_status") or die "$!"; +close($fh); + +my $pid = fork; + +if ( ! defined $pid ) { + die "Died: fork failed: $!"; +} +elsif ( $pid == 0 ) { + close $logrh; + open STDOUT, '>&', $logwh + or die "Died: failed to redirect STDOUT"; + close $logwh; + start_server( + port => $port, #not use + exec => [ + $^X, '-e', 'printf "%s\n", -f "dir_status" ? "OK" : "NG"; sleep(1)' + ], + dir => $tempdir + ); + exit(255); +} + +close $logwh; +my $result; +my $s = IO::Select->new($logrh); +my @ready = $s->can_read(10); +die "could not read logs from pipe" unless @ready; +sysread($logrh, my $buf, 65536); +like($buf, qr/OK\W/); + +kill 'TERM', $pid; +while (wait != $pid) {} + +unlink "$tempdir/status"; +rmdir $tempdir; + + |