diff options
-rw-r--r-- | plugins-root/t/check_icmp.t | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 71cc5b38..1a755866 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t | |||
@@ -12,7 +12,11 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO", | |||
12 | "no" ); | 12 | "no" ); |
13 | 13 | ||
14 | if ($allow_sudo eq "yes" or $> == 0) { | 14 | if ($allow_sudo eq "yes" or $> == 0) { |
15 | <<<<<<< HEAD | ||
15 | plan tests => 18; | 16 | plan tests => 18; |
17 | ======= | ||
18 | plan tests => 20; | ||
19 | >>>>>>> 44f19e79 (Fix tests (hopefully)) | ||
16 | } else { | 20 | } else { |
17 | plan skip_all => "Need sudo to test check_icmp"; | 21 | plan skip_all => "Need sudo to test check_icmp"; |
18 | } | 22 | } |
@@ -35,54 +39,63 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | |||
35 | 39 | ||
36 | my $res; | 40 | my $res; |
37 | 41 | ||
42 | # 1 | ||
38 | $res = NPTest->testCmd( | 43 | $res = NPTest->testCmd( |
39 | "$sudo ./check_icmp -H $host_responsive -w 10000ms,100% -c 10000ms,100%" | 44 | "$sudo ./check_icmp -H $host_responsive -w 10000ms,100% -c 10000ms,100%" |
40 | ); | 45 | ); |
41 | is( $res->return_code, 0, "Syntax ok" ); | 46 | is( $res->return_code, 0, "Syntax ok" ); |
42 | like( $res->output, $successOutput, "Output OK" ); | 47 | like( $res->output, $successOutput, "Output OK" ); |
43 | 48 | ||
49 | # 2 | ||
44 | $res = NPTest->testCmd( | 50 | $res = NPTest->testCmd( |
45 | "$sudo ./check_icmp -H $host_responsive -w 0ms,0% -c 10000ms,100%" | 51 | "$sudo ./check_icmp -H $host_responsive -w 0ms,0% -c 10000ms,100%" |
46 | ); | 52 | ); |
47 | is( $res->return_code, 1, "Syntax ok, with forced warning" ); | 53 | is( $res->return_code, 1, "Syntax ok, with forced warning" ); |
48 | like( $res->output, $failureOutput, "Output OK" ); | 54 | like( $res->output, $failureOutput, "Output OK" ); |
49 | 55 | ||
56 | # 3 | ||
50 | $res = NPTest->testCmd( | 57 | $res = NPTest->testCmd( |
51 | "$sudo ./check_icmp -H $host_responsive -w 0,0% -c 0,0%" | 58 | "$sudo ./check_icmp -H $host_responsive -w 0,0% -c 0,0%" |
52 | ); | 59 | ); |
53 | is( $res->return_code, 2, "Syntax ok, with forced critical" ); | 60 | is( $res->return_code, 2, "Syntax ok, with forced critical" ); |
54 | like( $res->output, $failureOutput, "Output OK" ); | 61 | like( $res->output, $failureOutput, "Output OK" ); |
55 | 62 | ||
63 | # 4 | ||
56 | $res = NPTest->testCmd( | 64 | $res = NPTest->testCmd( |
57 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%" | 65 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100%" |
58 | ); | 66 | ); |
59 | is( $res->return_code, 2, "Timeout - host nonresponsive" ); | 67 | is( $res->return_code, 2, "Timeout - host nonresponsive" ); |
60 | like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); | 68 | like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); |
61 | 69 | ||
70 | # 4 | ||
62 | $res = NPTest->testCmd( | 71 | $res = NPTest->testCmd( |
63 | "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" | 72 | "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" |
64 | ); | 73 | ); |
65 | is( $res->return_code, 3, "No hostname" ); | 74 | is( $res->return_code, 3, "No hostname" ); |
66 | like( $res->output, '/No hosts to check/', "Output with appropriate error message"); | 75 | like( $res->output, '/No hosts to check/', "Output with appropriate error message"); |
67 | 76 | ||
77 | # 5 | ||
68 | $res = NPTest->testCmd( | 78 | $res = NPTest->testCmd( |
69 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0" | 79 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 0" |
70 | ); | 80 | ); |
71 | is( $res->return_code, 0, "One host nonresponsive - zero required" ); | 81 | is( $res->return_code, 0, "One host nonresponsive - zero required" ); |
72 | like( $res->output, $successOutput, "Output OK" ); | 82 | like( $res->output, $successOutput, "Output OK" ); |
73 | 83 | ||
84 | # 6 | ||
74 | $res = NPTest->testCmd( | 85 | $res = NPTest->testCmd( |
75 | "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1" | 86 | "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 1" |
76 | ); | 87 | ); |
77 | is( $res->return_code, 0, "One of two host nonresponsive - one required" ); | 88 | is( $res->return_code, 0, "One of two host nonresponsive - one required" ); |
78 | like( $res->output, $successOutput, "Output OK" ); | 89 | like( $res->output, $successOutput, "Output OK" ); |
79 | 90 | ||
91 | # 7 | ||
80 | $res = NPTest->testCmd( | 92 | $res = NPTest->testCmd( |
81 | "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 2" | 93 | "$sudo ./check_icmp -H $host_responsive -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -n 1 -m 2" |
82 | ); | 94 | ); |
83 | is( $res->return_code, 2, "One of two host nonresponsive - two required" ); | 95 | is( $res->return_code, 2, "One of two host nonresponsive - two required" ); |
84 | like( $res->output, $failureOutput, "Output OK" ); | 96 | like( $res->output, $failureOutput, "Output OK" ); |
85 | 97 | ||
98 | # 8 | ||
86 | $res = NPTest->testCmd( | 99 | $res = NPTest->testCmd( |
87 | "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2" | 100 | "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2" |
88 | ); | 101 | ); |
@@ -90,11 +103,12 @@ is( $res->return_code, 0, "IPv4 source_ip accepted" ); | |||
90 | like( $res->output, $successOutput, "Output OK" ); | 103 | like( $res->output, $successOutput, "Output OK" ); |
91 | 104 | ||
92 | $res = NPTest->testCmd( | 105 | $res = NPTest->testCmd( |
93 | "$sudo ./check_icmp -H ::1 -b 65507" | 106 | "$sudo ./check_icmp -H $host_responsive -b 65507" |
94 | ); | 107 | ); |
95 | is( $res->return_code, 0, "Try max paket size" ); | 108 | is( $res->return_code, 0, "Try max paket size" ); |
96 | like( $res->output, $successOutput, "Output OK - Didn't overflow" ); | 109 | like( $res->output, $successOutput, "Output OK - Didn't overflow" ); |
97 | 110 | ||
111 | # 9 | ||
98 | $res = NPTest->testCmd( | 112 | $res = NPTest->testCmd( |
99 | "$sudo ./check_icmp -H ::1 -vvv" | 113 | "$sudo ./check_icmp -H ::1 -vvv" |
100 | ); | 114 | ); |