Code

Add comment to recent check_disk patch
[nagiosplug.git] / plugins / t / check_time.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # System Time Tests via check_time
4 #
5 # $Id$
6 #
8 use strict;
9 use Test;
10 use NPTest;
12 use vars qw($tests);
13 BEGIN {$tests = 8; plan tests => $tests}
15 my $host_udp_time      = getTestParameter( "host_udp_time",      "NP_HOST_UDP_TIME",      "localhost",
16                                            "A host providing the UDP Time Service" );
18 my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
19                                            "The hostname of system not responsive to network requests" );
21 my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
22                                            "An invalid (not known to DNS) hostname" );
24 my $successOutput = '/^TIME OK - [0-9]+ second time difference/';
26 my %exceptions = ( 3 => "No time server present?");
28 my $t;
30 # standard mode
31 $t += checkCmd( "./check_time -H $host_udp_time -w 999999,59       -c 999999,59       -t 60", 0, $successOutput, %exceptions );
32 $t += checkCmd( "./check_time -H $host_udp_time -w 999999    -W 59 -c 999999    -C 59 -t 60", 0, $successOutput, %exceptions );
34 # reverse compatibility mode
35 $t += checkCmd( "./check_time    $host_udp_time -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60",  0, $successOutput, %exceptions );
37 # failure mode
38 $t += checkCmd( "./check_time -H $host_nonresponsive -t 1", 2 );
39 $t += checkCmd( "./check_time -H $hostname_invalid   -t 1", 3 );
41 exit(0) if defined($Test::Harness::VERSION);
42 exit($tests - $t);