summaryrefslogtreecommitdiffstats
path: root/test.pl.in
diff options
context:
space:
mode:
authorPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 (GMT)
committerPeter Bray <illumino@users.sourceforge.net>2005-07-25 01:47:15 (GMT)
commitcdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch)
tree62b074eaca618762fb03f94708ec3def50037697 /test.pl.in
parent05853f47eb6e608de993cc59343c73b96b9b33e2 (diff)
downloadmonitoring-plugins-cdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1.tar.gz
[1185704] New Testing Infrastructure.
Complete rewrite of the original testing infrastructure and all test cases (to use the new infrastructure) See NPTest.pm and issue 1185704 for more details. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1207 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'test.pl.in')
-rwxr-xr-xtest.pl.in116
1 files changed, 38 insertions, 78 deletions
diff --git a/test.pl.in b/test.pl.in
index e88c473..22d0576 100755
--- a/test.pl.in
+++ b/test.pl.in
@@ -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
2use strict; 8use strict;
3 9
4my $file = '../Cache'; 10use Getopt::Long;
5unless (-f "$file.pm") {
6 open(CACHE,">$file.pm") or die "Cannot open cache";
7 print CACHE "package Cache;
8require Exporter;
9\@ISA=qw(Exporter);
10\@EXPORT=qw();
111;
12";
13 close CACHE;
14}
15 11
16use Helper; 12use NPTest qw(DetermineTestHarnessDirectory TestsFrom);
17my ($tstdir,$spath,$hostname,$httphost,$mailhost,$dnshost,$noserver,$nullhost,$quickcheck);
18 13
19use Getopt::Long; 14my $tstdir;
20GetOptions 15
21 ("tstdir:s"=>\$tstdir, 16if ( ! 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); 22my @tests;
32 23
33unless ($quickcheck) { 24if ( 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}
28else
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
46my @dots; 38 @tests = TestsFrom( $directory, 1 );
47if (@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}
76my $prog; 40
77my $test; 41if ( ! scalar( @tests ) )
78my @progs; 42{
79foreach $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
89use Test::Harness; 47use Test::Harness;
48
90#$Test::Harness::verbose=1; 49#$Test::Harness::verbose=1;
91runtests(@progs); 50
51runtests( @tests );