monitoring-plugins/plugins/t/check_dns.t
Peter Bray cdc06cc3e2 [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
2005-07-25 01:47:15 +00:00

42 lines
1.1 KiB
Perl

#! /usr/bin/perl -w -I ..
#
# Domain Name Server (DNS) Tests via check_dns
#
# $Id$
#
use strict;
use Test;
use NPTest;
use vars qw($tests);
BEGIN {$tests = 6; plan tests => $tests}
my $successOutput = '/DNS OK: [\.0-9]+ seconds response time/';
my $hostname_valid = getTestParameter( "hostname_valid", "NP_HOSTNAME_VALID", "localhost",
"A valid (known to DNS) hostname" );
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 $t;
#
# Default DNS Server
#
$t += checkCmd( "./check_dns -H $hostname_valid -t 5", 0, $successOutput );
$t += checkCmd( "./check_dns -H $hostname_invalid -t 1", 2 );
#
# 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);