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_time.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_time.t')
-rw-r--r-- | plugins/t/check_time.t | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t index 4d8c5c2b..05878dc2 100644 --- a/plugins/t/check_time.t +++ b/plugins/t/check_time.t @@ -1,52 +1,40 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl -w -I .. +# +# System Time Tests via check_time +# +# $Id$ +# use strict; -use Cache; -use Helper; use Test; +use NPTest; + use vars qw($tests); +BEGIN {$tests = 8; plan tests => $tests} -BEGIN {$tests = 6; plan tests => $tests} +my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", + "A host providing the UDP Time Service" ); -my $null = ''; -my $cmd; -my $str; -my $t; -my $udp_hostname=get_option("udp_hostname","UDP host name"); +my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", + "The hostname of system not responsive to network requests" ); -# standard mode +my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", + "An invalid (not known to DNS) hostname" ); -$cmd = "./check_time -H $udp_hostname -w 999999,59 -c 999999,59 -t 60"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; +my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; -$cmd = "./check_time -H $udp_hostname -w 999999 -W 59 -c 999999 -C 59 -t 60"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; +my $t; -# reverse compatibility mode +# standard mode +$t += checkCmd( "./check_time -H $host_udp_time -w 999999,59 -c 999999,59 -t 60", 0, $successOutput ); +$t += checkCmd( "./check_time -H $host_udp_time -w 999999 -W 59 -c 999999 -C 59 -t 60", 0, $successOutput ); -$cmd = "./check_time $udp_hostname -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60"; -$str = `$cmd`; -$t += ok $?>>8,0; -print "Test was: $cmd\n" if ($?); -$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/'; +# reverse compatibility mode +$t += checkCmd( "./check_time $host_udp_time -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60", 0, $successOutput ); # failure mode - -#$cmd = "./check_time -H $Cache::nullhost -t 1"; -#$str = `$cmd`; -#$t += ok $?>>8,255; -#print "Test was: $cmd\n" unless ($?); - -#$cmd = "./check_time -H $Cache::noserver -t 1"; -#$str = `$cmd`; -#$t += ok $?>>8,255; -#print "$cmd\n" unless ($?); +$t += checkCmd( "./check_time -H $host_nonresponsive -t 1", 2 ); +$t += checkCmd( "./check_time -H $hostname_invalid -t 1", 3 ); exit(0) if defined($Test::Harness::VERSION); exit($tests - $t); |