summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_dns.t
diff options
context:
space:
mode:
authorPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 (GMT)
committerPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 (GMT)
commitcdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch)
tree62b074eaca618762fb03f94708ec3def50037697 /plugins/t/check_dns.t
parent05853f47eb6e608de993cc59343c73b96b9b33e2 (diff)
downloadmonitoring-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.t44
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
3use strict; 8use strict;
4use Cache;
5use Test; 9use Test;
10use NPTest;
11
6use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 6; plan tests => $tests}
14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/';
7 16
8BEGIN {$tests = 3; plan tests => $tests} 17my $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); 20my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
21 "An invalid (not known to DNS) hostname" );
22
23my $dns_server = getTestParameter( "dns_server", "NP_DNS_SERVER", undef,
24 "A non default (remote) DNS server" );
11 25
12my $null = '';
13my $cmd;
14my $str;
15my $t; 26my $t;
16 27
17$str = `./check_dns $Cache::dnshost -to 5`; 28#
18$t += ok $?>>8,0; 29# Default DNS Server
19print "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#
25print "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
27exit(0) if defined($Test::Harness::VERSION); 40exit(0) if defined($Test::Harness::VERSION);
28exit($tests - $t); 41exit($tests - $t);
42