diff options
author | Peter Bray <illumino@users.sourceforge.net> | 2005-07-25 01:47:15 +0000 |
---|---|---|
committer | Peter Bray <illumino@users.sourceforge.net> | 2005-07-25 01:47:15 +0000 |
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 bee1d34b..fbaca794 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t @@ -1,28 +1,42 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# Domain Name Server (DNS) Tests via check_dns +# +# $Id$ +# use strict; -use Cache; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 6; plan tests => $tests} + +my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/'; -BEGIN {$tests = 3; plan tests => $tests} +my $hostname_valid = getTestParameter( "hostname_valid", "NP_HOSTNAME_VALID", "localhost", + "A valid (known to DNS) hostname" ); -#`nslookup localhost > /dev/null 2>&1` || exit(77); +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); + +my $dns_server = getTestParameter( "dns_server", "NP_DNS_SERVER", undef, + "A non default (remote) DNS server" ); -my $null = ''; -my $cmd; -my $str; my $t; -$str = `./check_dns $Cache::dnshost -to 5`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/DNS OK: +[\.0-9]+ seconds response time, /'; +# +# Default DNS Server +# +$t += checkCmd( "./check_dns -H $hostname_valid -t 5", 0, $successOutput ); +$t += checkCmd( "./check_dns -H $hostname_invalid -t 1", 2 ); -$cmd = "./check_dns $Cache::nullhost -to 1"; -$str = `$cmd`; -$t += ok $?>>8,2; -print "Test was: $cmd\n" unless ($?); +# +# Specified DNS Server +# +$t += checkCmd( "./check_dns -H $hostname_valid -s $dns_server -t 5", 0, $successOutput ); +$t += checkCmd( "./check_dns -H $hostname_invalid -s $dns_server -t 1", 2 ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); + |