summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
authorSven Nierlein <sven@consol.de>2013-09-14 19:36:20 +0200
committerSven Nierlein <sven@consol.de>2013-09-14 19:36:20 +0200
commit7b122f13dbb0bd714b47e1181ba36bfbb3bd7658 (patch)
treee204afb0058a14c248dc9bcca1199b525cd2c706 /plugins/t
parent32ec6265a4161790bc3a548b0d2c1237e30b0d1a (diff)
downloadmonitoring-plugins-7b122f13dbb0bd714b47e1181ba36bfbb3bd7658.tar.gz
tests: move ipv6 detection into NPTest module
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_dig.t20
-rw-r--r--plugins/t/check_tcp.t16
2 files changed, 18 insertions, 18 deletions
diff --git a/plugins/t/check_dig.t b/plugins/t/check_dig.t
index 1ab4b426..d447f084 100644
--- a/plugins/t/check_dig.t
+++ b/plugins/t/check_dig.t
@@ -6,11 +6,16 @@
6 6
7use strict; 7use strict;
8use Test::More; 8use Test::More;
9use NPTest;
10 9
11plan skip_all => "check_dig not compiled" unless (-x "check_dig");
12 10
13plan tests => 16; 11use vars qw($tests $has_ipv6);
12BEGIN {
13 plan skip_all => "check_dig not compiled" unless (-x "check_dig");
14 use NPTest;
15 $has_ipv6 = NPTest::has_ipv6();
16 $tests = $has_ipv6 ? 16 : 14;
17 plan tests => $tests;
18}
14 19
15my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/'; 20my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/';
16 21
@@ -73,10 +78,6 @@ SKIP: {
73 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server"); 78 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
74 like ( $res->output, $successOutput, "Output OK for IPv4" ); 79 like ( $res->output, $successOutput, "Output OK for IPv4" );
75 80
76 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
77 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
78 like ( $res->output, $successOutput, "Output OK for IPv6" );
79
80 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -a $hostname_valid_ip -t 5"); 81 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -a $hostname_valid_ip -t 5");
81 cmp_ok( $res->return_code, '==', 0, "Got expected address"); 82 cmp_ok( $res->return_code, '==', 0, "Got expected address");
82 83
@@ -89,4 +90,9 @@ SKIP: {
89 cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); 90 cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
90 like ( $res->output, $successOutput, "Output OK"); 91 like ( $res->output, $successOutput, "Output OK");
91 92
93 if($has_ipv6) {
94 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
95 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
96 like ( $res->output, $successOutput, "Output OK for IPv6" );
97 }
92} 98}
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t
index 0e6a9641..abb16aec 100644
--- a/plugins/t/check_tcp.t
+++ b/plugins/t/check_tcp.t
@@ -6,19 +6,13 @@
6 6
7use strict; 7use strict;
8use Test; 8use Test;
9use NPTest;
10 9
11use vars qw($tests); 10use vars qw($tests $has_ipv6);
12my $has_ipv6;
13BEGIN { 11BEGIN {
14 $tests = 11; 12 use NPTest;
15 # do we have ipv6 13 $has_ipv6 = NPTest::has_ipv6();
16 `ping6 -c 1 2a02:2e0:3fe:100::7 2>&1`; 14 $tests = $has_ipv6 ? 14 : 11;
17 if($? == 0) { 15 plan tests => $tests;
18 $has_ipv6 = 1;
19 $tests += 3;
20 }
21 plan tests => $tests;
22} 16}
23 17
24 18