diff options
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 @@ | |||
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 | ||
3 | use strict; | 8 | use strict; |
4 | use Cache; | ||
5 | use Helper; | ||
6 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
7 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 8; plan tests => $tests} | ||
8 | 14 | ||
9 | BEGIN {$tests = 6; 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" ); | ||
10 | 17 | ||
11 | my $null = ''; | 18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", |
12 | my $cmd; | 19 | "The hostname of system not responsive to network requests" ); |
13 | my $str; | ||
14 | my $t; | ||
15 | my $udp_hostname=get_option("udp_hostname","UDP host name"); | ||
16 | 20 | ||
17 | # standard mode | 21 | my $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"; | 24 | my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; |
20 | $str = `$cmd`; | ||
21 | $t += ok $?>>8,0; | ||
22 | print "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"; | 26 | my $t; |
26 | $str = `$cmd`; | ||
27 | $t += ok $?>>8,0; | ||
28 | print "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; | ||
36 | print "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 | ||
51 | exit(0) if defined($Test::Harness::VERSION); | 39 | exit(0) if defined($Test::Harness::VERSION); |
52 | exit($tests - $t); | 40 | exit($tests - $t); |