Debian Codegraph @

ci/test-08-options-n-q.pl

raw
1 #!/usr/bin/perl -w
2
3 use Test::Command tests => 18;
4
5 # -n show targets by name (-d is equivalent)
6 # -O n set the type of service (tos) flag on the ICMP packets
7 # -p n interval between ping packets to one target (in millisec)
8 # (in looping and counting modes, default 1000)
9 # -q quiet (don't show per-target/per-ping results)
10 # -Q n same as -q, but show summary every n seconds
11
12 # fping -n -> test-14-internet-hosts
13
14 # fping -d -n
15 {
16 my $cmd = Test::Command->new(cmd => "fping -d -n 127.0.0.1");
17 $cmd->exit_is_num(1);
18 $cmd->stdout_is_eq("");
19 $cmd->stderr_is_eq("fping: use either one of -d or -n\n");
20 }
21
22 # fping -n -d
23 {
24 my $cmd = Test::Command->new(cmd => "fping -n -d 127.0.0.1");
25 $cmd->exit_is_num(1);
26 $cmd->stdout_is_eq("");
27 $cmd->stderr_is_eq("fping: use either one of -d or -n\n");
28 }
29
30 # fping -o
31 {
32 my $cmd = Test::Command->new(cmd => "fping -t100 -p 100 -o -c 5 8.8.8.7");
33 $cmd->exit_is_num(1);
34 $cmd->stdout_is_eq("8.8.8.7 : [0], timed out (NaN avg, 100% loss)
35 8.8.8.7 : [1], timed out (NaN avg, 100% loss)
36 8.8.8.7 : [2], timed out (NaN avg, 100% loss)
37 8.8.8.7 : [3], timed out (NaN avg, 100% loss)
38 8.8.8.7 : [4], timed out (NaN avg, 100% loss)
39 ");
40 $cmd->stderr_like(qr{^\s*8\.8\.8\.7 : xmt/rcv/%loss = 5/0/100%, outage\(ms\) = 50\d\s*$});
41 }
42
43 # fping -O
44 {
45 my $cmd = Test::Command->new(cmd => "fping -O 2 127.0.0.1");
46 $cmd->exit_is_num(0);
47 $cmd->stdout_is_eq("127.0.0.1 is alive\n");
48 $cmd->stderr_is_eq("");
49 }
50
51 # fping -q
52 {
53 my $cmd = Test::Command->new(cmd => "fping -q -p 100 -c 3 127.0.0.1");
54 $cmd->exit_is_num(0);
55 $cmd->stdout_is_eq("");
56 $cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
57 });
58 }
59
60 # fping -Q
61 {
62 my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 400 -c 4 127.0.0.1");
63 $cmd->exit_is_num(0);
64 $cmd->stdout_is_eq("");
65 $cmd->stderr_like(qr{\[\d+:\d+:\d+\]
66 127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
67 127\.0\.0\.1 : xmt/rcv/%loss = 4/4/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
68 });
69 }
70
71