File: 35signal.t

package info (click to toggle)
libnet-proxy-perl 0.12-5
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 304 kB
  • ctags: 66
  • sloc: perl: 777; sh: 84; makefile: 44
file content (49 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (5)
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 Test::More;
use strict;
use warnings;
use IO::Socket::INET;
use Net::Proxy;

# fetch signal numbers
use Config;
my %sig_num;
my @names = split ' ', $Config{sig_name};
@sig_num{@names} = split ' ', $Config{sig_num};


my $tests = 1;
if( $^O eq 'MSWin32' ) {
    plan skip_all => 'Test irrelevant on MSWin32';
}
else {
    plan tests => $tests;
}

my $pid = fork;

SKIP: {
    skip "fork failed", $tests if !defined $pid;
    if ( $pid == 0 ) {

        # the child process runs the proxy
        my $proxy = Net::Proxy->new(
            {   in  => { type => 'dummy', },
                out => { type => 'dummy', },
            }
        );

        $proxy->register();

        Net::Proxy->set_verbosity( $ENV{NET_PROXY_VERBOSITY} || 0 );
        Net::Proxy->mainloop(1);
        exit;
    }
    else {

        # wait for the proxy to set up
        sleep 1;

        kill $sig_num{HUP}, $pid;
        is( wait, $pid, 'Proxy stopped by signal' );
    }
}