diff options
Diffstat (limited to 'plugins/t/check_dns.t')
-rw-r--r-- | plugins/t/check_dns.t | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index bee1d34b..fbaca794 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
@@ -1,28 +1,42 @@ | |||
1 | #! /usr/bin/perl -w | 1 | #! /usr/bin/perl -w -I .. |
2 | # | ||
3 | # Domain Name Server (DNS) Tests via check_dns | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
2 | 7 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
6 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 6; plan tests => $tests} | ||
14 | |||
15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/'; | ||
7 | 16 | ||
8 | BEGIN {$tests = 3; plan tests => $tests} | 17 | my $hostname_valid = getTestParameter( "hostname_valid", "NP_HOSTNAME_VALID", "localhost", |
18 | "A valid (known to DNS) hostname" ); | ||
9 | 19 | ||
10 | #`nslookup localhost > /dev/null 2>&1` || exit(77); | 20 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
21 | "An invalid (not known to DNS) hostname" ); | ||
22 | |||
23 | my $dns_server = getTestParameter( "dns_server", "NP_DNS_SERVER", undef, | ||
24 | "A non default (remote) DNS server" ); | ||
11 | 25 | ||
12 | my $null = ''; | ||
13 | my $cmd; | ||
14 | my $str; | ||
15 | my $t; | 26 | my $t; |
16 | 27 | ||
17 | $str = `./check_dns $Cache::dnshost -to 5`; | 28 | # |
18 | $t += ok $?>>8,0; | 29 | # Default DNS Server |
19 | print "Test was: $cmd\n" if ($?); | 30 | # |
20 | $t += ok $str, '/DNS OK: +[\.0-9]+ seconds response time, /'; | 31 | $t += checkCmd( "./check_dns -H $hostname_valid -t 5", 0, $successOutput ); |
32 | $t += checkCmd( "./check_dns -H $hostname_invalid -t 1", 2 ); | ||
21 | 33 | ||
22 | $cmd = "./check_dns $Cache::nullhost -to 1"; | 34 | # |
23 | $str = `$cmd`; | 35 | # Specified DNS Server |
24 | $t += ok $?>>8,2; | 36 | # |
25 | print "Test was: $cmd\n" unless ($?); | 37 | $t += checkCmd( "./check_dns -H $hostname_valid -s $dns_server -t 5", 0, $successOutput ); |
38 | $t += checkCmd( "./check_dns -H $hostname_invalid -s $dns_server -t 1", 2 ); | ||
26 | 39 | ||
27 | exit(0) if defined($Test::Harness::VERSION); | 40 | exit(0) if defined($Test::Harness::VERSION); |
28 | exit($tests - $t); | 41 | exit($tests - $t); |
42 | |||