diff options
author | Peter Bray <illumino@users.sourceforge.net> | 2005-07-25 01:47:15 (GMT) |
---|---|---|
committer | Peter Bray <illumino@users.sourceforge.net> | 2005-07-25 01:47:15 (GMT) |
commit | cdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch) | |
tree | 62b074eaca618762fb03f94708ec3def50037697 /plugins/t/check_dns.t | |
parent | 05853f47eb6e608de993cc59343c73b96b9b33e2 (diff) | |
download | monitoring-plugins-cdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1.tar.gz |
[1185704] New Testing Infrastructure.
Complete rewrite of the original testing infrastructure and
all test cases (to use the new infrastructure)
See NPTest.pm and issue 1185704 for more details.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1207 f882894a-f735-0410-b71e-b25c423dba1c
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 bee1d34..fbaca79 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 | |||