summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_time.t
diff options
context:
space:
mode:
authorPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 +0000
committerPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 +0000
commitcdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch)
tree62b074eaca618762fb03f94708ec3def50037697 /plugins/t/check_time.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_time.t')
-rw-r--r--plugins/t/check_time.t60
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 @@
1#! /usr/bin/perl -w 1#! /usr/bin/perl -w -I ..
2#
3# System Time Tests via check_time
4#
5# $Id$
6#
2 7
3use strict; 8use strict;
4use Cache;
5use Helper;
6use Test; 9use Test;
10use NPTest;
11
7use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 8; plan tests => $tests}
8 14
9BEGIN {$tests = 6; plan tests => $tests} 15my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost",
16 "A host providing the UDP Time Service" );
10 17
11my $null = ''; 18my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
12my $cmd; 19 "The hostname of system not responsive to network requests" );
13my $str;
14my $t;
15my $udp_hostname=get_option("udp_hostname","UDP host name");
16 20
17# standard mode 21my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
22 "An invalid (not known to DNS) hostname" );
18 23
19$cmd = "./check_time -H $udp_hostname -w 999999,59 -c 999999,59 -t 60"; 24my $successOutput = '/^TIME OK - [0-9]+ second time difference/';
20$str = `$cmd`;
21$t += ok $?>>8,0;
22print "Test was: $cmd\n" if ($?);
23$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/';
24 25
25$cmd = "./check_time -H $udp_hostname -w 999999 -W 59 -c 999999 -C 59 -t 60"; 26my $t;
26$str = `$cmd`;
27$t += ok $?>>8,0;
28print "Test was: $cmd\n" if ($?);
29$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/';
30 27
31# reverse compatibility mode 28# standard mode
29$t += checkCmd( "./check_time -H $host_udp_time -w 999999,59 -c 999999,59 -t 60", 0, $successOutput );
30$t += checkCmd( "./check_time -H $host_udp_time -w 999999 -W 59 -c 999999 -C 59 -t 60", 0, $successOutput );
32 31
33$cmd = "./check_time $udp_hostname -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60"; 32# reverse compatibility mode
34$str = `$cmd`; 33$t += checkCmd( "./check_time $host_udp_time -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60", 0, $successOutput );
35$t += ok $?>>8,0;
36print "Test was: $cmd\n" if ($?);
37$t += ok $str, '/^TIME OK - [0-9]+ second time difference$/';
38 34
39# failure mode 35# failure mode
40 36$t += checkCmd( "./check_time -H $host_nonresponsive -t 1", 2 );
41#$cmd = "./check_time -H $Cache::nullhost -t 1"; 37$t += checkCmd( "./check_time -H $hostname_invalid -t 1", 3 );
42#$str = `$cmd`;
43#$t += ok $?>>8,255;
44#print "Test was: $cmd\n" unless ($?);
45
46#$cmd = "./check_time -H $Cache::noserver -t 1";
47#$str = `$cmd`;
48#$t += ok $?>>8,255;
49#print "$cmd\n" unless ($?);
50 38
51exit(0) if defined($Test::Harness::VERSION); 39exit(0) if defined($Test::Harness::VERSION);
52exit($tests - $t); 40exit($tests - $t);