diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/misc/p5-Server-Starter/t/12-stop.t | |
parent | Initial commit. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/misc/p5-Server-Starter/t/12-stop.t')
-rw-r--r-- | web/server/h2o/libh2o/misc/p5-Server-Starter/t/12-stop.t | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/p5-Server-Starter/t/12-stop.t b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/12-stop.t new file mode 100644 index 00000000..6d40c25f --- /dev/null +++ b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/12-stop.t @@ -0,0 +1,50 @@ +use strict; +use warnings; +use utf8; +use Test::More; +use Server::Starter qw(start_server restart_server stop_server); +use File::Temp qw(tempdir); +use Test::TCP; + +plan tests => 2; + +my $dir = tempdir( CLEANUP => 1 ); +my $pidfile = "$dir/pid"; + +test_tcp( + server => sub { + my $port = shift; + + start_server( + pid_file => $pidfile, + daemonize => 1, + port => $port, + exec => [ $^X, 't/12-stop-server.pl' ], + ); + exit 0; + }, + client => sub { + my $port = shift; + + while (!-s $pidfile) { + note 'pid file is not available'; + sleep 1; # wait pid file + } + + my $pid = do { + open my $fh, '<', $pidfile + or die "Cannot open $pidfile: $!"; + local $/; + <$fh>; + }; + note "PID=$pid"; + is(kill(0, $pid), 1, 'there is a process'); + + stop_server( + pid_file => $pidfile, + port => $port, + ); + ok((!-e $pidfile), 'pid file was unlinked'); + }, +); + |