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