check_time.t 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # System Time Tests via check_time
  4. #
  5. # $Id$
  6. #
  7. use strict;
  8. use Test;
  9. use NPTest;
  10. use vars qw($tests);
  11. BEGIN {$tests = 8; plan tests => $tests}
  12. my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost",
  13. "A host providing the UDP Time Service" );
  14. my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
  15. "The hostname of system not responsive to network requests" );
  16. my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
  17. "An invalid (not known to DNS) hostname" );
  18. my $successOutput = '/^TIME OK - [0-9]+ second time difference/';
  19. my $t;
  20. # standard mode
  21. $t += checkCmd( "./check_time -H $host_udp_time -w 999999,59 -c 999999,59 -t 60", 0, $successOutput );
  22. $t += checkCmd( "./check_time -H $host_udp_time -w 999999 -W 59 -c 999999 -C 59 -t 60", 0, $successOutput );
  23. # reverse compatibility mode
  24. $t += checkCmd( "./check_time $host_udp_time -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60", 0, $successOutput );
  25. # failure mode
  26. $t += checkCmd( "./check_time -H $host_nonresponsive -t 1", 2 );
  27. $t += checkCmd( "./check_time -H $hostname_invalid -t 1", 3 );
  28. exit(0) if defined($Test::Harness::VERSION);
  29. exit($tests - $t);