File: wait.t

package info (click to toggle)
libtest-redisserver-perl 0.21-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 188 kB
  • sloc: perl: 171; makefile: 11; sh: 4
file content (49 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use Test::More;

use Redis;
use Test::RedisServer;
use POSIX qw/SIGTERM/;

eval { Test::RedisServer->new } or plan skip_all => 'redis-server is required in PATH to run this test';

my $server = Test::RedisServer->new;

my $pid = fork;
die 'fork failed' unless defined $pid;

if ($pid == 0) {
    sleep 1;
    kill SIGTERM, $server->pid;
    exit(0);
}

$server->wait_exit;

pass 'process exited';
is $server->pid, undef, 'no pid ok';


$pid = fork;
die 'fork failed' unless defined $pid;

if ($pid == 0) {
    # child
    my $redis = Test::RedisServer->new;
    local $SIG{TERM} = sub { $redis->stop };
    $redis->wait_exit;
    exit(0);
}
else {
    sleep 1;
    kill SIGTERM, $pid;
    while (waitpid($pid, 0) >= 0) {
    }
    pass 'redis exit ok';
}



done_testing;