test.pl.in 2.0 KB

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