Debian Codegraph @

ci/test-07-options-i-m.pl

raw
1 #!/usr/bin/perl -w
2
3 use Test::Command tests => 9;
4 use Test::More;
5
6 # -i n interval between sending ping packets (in millisec) (default 25)
7 # -l loop sending pings forever
8 # -m ping multiple interfaces on target host
9 # -M don't fragment
10
11 # fping -i n
12 {
13 my $cmd = Test::Command->new(cmd => "fping -i 100 127.0.0.1 127.0.0.2");
14 $cmd->exit_is_num(0);
15 $cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
16 $cmd->stderr_is_eq("");
17 }
18
19 # fping -l
20 {
21 my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
22 $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
23 127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
24 });
25 }
26
27 # fping -l with SIGQUIT
28 {
29 my $cmd = Test::Command->new(cmd => '(sleep 2; pkill -QUIT fping; sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
30 $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
31 127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
32 127\.0\.0\.1 : \[2\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
33 127\.0\.0\.1 : \[3\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
34 127\.0\.0\.1 : \[4\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
35 });
36 $cmd->stderr_like(qr{\[\d+:\d+:\d+\]
37 127\.0\.0\.1 : xmt/rcv/%loss = \d+/\d+/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
38 });
39 }
40
41
42 # fping -M
43 SKIP: {
44 if($^O eq 'darwin') {
45 skip '-M option not supported on macOS', 3;
46 }
47 my $cmd = Test::Command->new(cmd => "fping -M 127.0.0.1");
48 $cmd->exit_is_num(0);
49 $cmd->stdout_is_eq("127.0.0.1 is alive\n");
50 $cmd->stderr_is_eq("");
51 }
52
53 # fping -m -> test-14-internet-hosts