test.pl.in 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/perl -w
  2. use strict;
  3. my $file = '../Cache';
  4. unless (-f "$file.pm") {
  5. open(CACHE,">$file.pm") or die "Cannot open cache";
  6. print CACHE "package Cache;
  7. require Exporter;
  8. \@ISA=qw(Exporter);
  9. \@EXPORT=qw();
  10. 1;
  11. ";
  12. close CACHE;
  13. }
  14. use Helper;
  15. my ($tstdir,$spath,$hostname,$httphost,$mailhost,$dnshost,$noserver,$nullhost,$quickcheck);
  16. use Getopt::Long;
  17. GetOptions
  18. ("tstdir:s"=>\$tstdir,
  19. "spath:s"=>\$spath,
  20. "hostname:s"=>\$hostname,
  21. "httpname:s"=>\$httphost,
  22. "mailhost:s"=>\$mailhost,
  23. "dnshost:s"=>\$dnshost,
  24. "noserver:s"=>\$noserver,
  25. "nullhost:s"=>\$nullhost,
  26. "quickcheck"=>\$quickcheck);
  27. $spath = "." unless ($spath);
  28. unless ($quickcheck) {
  29. $hostname = get_option("hostname","host for FTP/UDP tests") unless ($hostname);
  30. $httphost = get_option("httphost","host for HTTP tests") unless ($httphost);
  31. $mailhost = get_option("mailhost","host for SMTP/IMAP/POP tests") unless ($mailhost);
  32. $dnshost = get_option("dnshost","hostname to lookup for DNS tests") unless ($dnshost);
  33. $noserver = get_option("noserver","host that rejects above services") unless ($noserver);
  34. # This machine should not be locatable from your network. Use IP
  35. # private addresses like 10.x.x.x and pick one that does not exist
  36. # on your LAN/WAN
  37. $nullhost = get_option("nullhost","nonexistent IP address (e.g., 10.0.0.0)") unless ($nullhost);
  38. }
  39. my @dots;
  40. if (@ARGV) {
  41. @dots = @ARGV;
  42. } else {
  43. unless ($tstdir) {
  44. if (-d './t') {
  45. $tstdir = './t';
  46. } else {
  47. $tstdir = $ENV{PWD};
  48. $tstdir = `/bin/pwd` unless defined($tstdir);
  49. chomp $tstdir;
  50. if (defined($tstdir)) {
  51. $tstdir =~ s|^(.*)/([^/]+)/?$|$1/$2|;
  52. if (-d "../../$2/t") {
  53. $tstdir = "../../$2/t";
  54. } elsif (-d "$tstdir/t") {
  55. $tstdir = "$tstdir/t";
  56. }
  57. } else {
  58. die "Could not get PWD from environment\n";
  59. }
  60. }
  61. }
  62. $tstdir = './t' unless ($tstdir);
  63. opendir(DIR, $tstdir) || die "can't opendir $tstdir: $!";
  64. while ($file = readdir(DIR)) {
  65. push @dots, "$tstdir/$file" if ($file =~ m/^[^\.]+\.t$/);
  66. }
  67. closedir DIR;
  68. }
  69. my $prog;
  70. my $test;
  71. my @progs;
  72. foreach $test (@dots) {
  73. $prog=`basename $test .t`;
  74. chomp $prog;
  75. if ( -e "$prog" ){
  76. push @progs, "$test";
  77. }else{
  78. print "No binary found for $prog\n";
  79. }
  80. }
  81. use Test::Harness;
  82. #$Test::Harness::verbose=1;
  83. runtests(@progs);