check_time.t 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #! /usr/bin/perl -w
  2. use strict;
  3. use Cache;
  4. use Helper;
  5. use Test;
  6. use vars qw($tests);
  7. BEGIN {$tests = 6; plan tests => $tests}
  8. my $null = '';
  9. my $cmd;
  10. my $str;
  11. my $t;
  12. my $udp_hostname=get_option("udp_hostname","UDP host name");
  13. # standard mode
  14. $cmd = "./check_time -H $udp_hostname -w 999999,59 -c 999999,59 -t 60";
  15. $str = `$cmd`;
  16. $t += ok $?>>8,0;
  17. print "Test was: $cmd\n" if ($?);
  18. $t += ok $str, '/^TIME OK - [0-9]+ second time difference$/';
  19. $cmd = "./check_time -H $udp_hostname -w 999999 -W 59 -c 999999 -C 59 -t 60";
  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. # reverse compatibility mode
  25. $cmd = "./check_time $udp_hostname -wt 59 -ct 59 -cd 999999 -wd 999999 -to 60";
  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. # failure mode
  31. #$cmd = "./check_time -H $Cache::nullhost -t 1";
  32. #$str = `$cmd`;
  33. #$t += ok $?>>8,255;
  34. #print "Test was: $cmd\n" unless ($?);
  35. #$cmd = "./check_time -H $Cache::noserver -t 1";
  36. #$str = `$cmd`;
  37. #$t += ok $?>>8,255;
  38. #print "$cmd\n" unless ($?);
  39. exit(0) if defined($Test::Harness::VERSION);
  40. exit($tests - $t);