summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2014-01-31 08:54:44 -0500
committerThomas Guyot-Sionnest <dermoth@aei.ca>2014-01-31 08:54:44 -0500
commit1dd0e4c96376f2c28590dad683161ee8c57c0508 (patch)
tree4a61176ad008db3d6c835393d6a1332453d297e1
parent35811848da1095525e6937159f6611fc8a87261b (diff)
downloadmonitoring-plugins-1dd0e4c.tar.gz
Enable tests in tests/ subdirs
-rw-r--r--NPTest.pm33
-rwxr-xr-x[-rw-r--r--]plugins/tests/check_procs.t0
-rwxr-xr-xtest.pl.in13
3 files changed, 29 insertions, 17 deletions
diff --git a/NPTest.pm b/NPTest.pm
index 3d6e3a28..2baed0b0 100644
--- a/NPTest.pm
+++ b/NPTest.pm
@@ -494,26 +494,35 @@ sub SetCacheFilename
494 494
495sub DetermineTestHarnessDirectory 495sub DetermineTestHarnessDirectory
496{ 496{
497 my( $userSupplied ) = @_; 497 my( @userSupplied ) = @_;
498 my @dirs;
498 499
499 # User Supplied 500 # User Supplied
500 if ( defined( $userSupplied ) && $userSupplied ) 501 if ( @userSupplied > 0 )
501 { 502 {
502 if ( -d $userSupplied ) 503 for my $u ( @userSupplied )
503 { 504 {
504 return $userSupplied; 505 if ( -d $u )
505 } 506 {
506 else 507 push ( @dirs, $u );
507 { 508 }
508 return undef; # userSupplied is invalid -> FAIL
509 } 509 }
510 } 510 }
511 511
512 # Simple Case : "t" is a subdirectory of the current directory 512 # Simple Cases: "t" and tests are subdirectories of the current directory
513 if ( -d "./t" ) 513 if ( -d "./t" )
514 { 514 {
515 return "./t"; 515 push ( @dirs, "./t");
516 } 516 }
517 if ( -d "./tests" )
518 {
519 push ( @dirs, "./tests");
520 }
521
522 if ( @dirs > 0 )
523 {
524 return @dirs;
525 }
517 526
518 # To be honest I don't understand which case satisfies the 527 # To be honest I don't understand which case satisfies the
519 # original code in test.pl : when $tstdir == `pwd` w.r.t. 528 # original code in test.pl : when $tstdir == `pwd` w.r.t.
@@ -526,7 +535,7 @@ sub DetermineTestHarnessDirectory
526 535
527 if ( $pwd =~ m|/t$| ) 536 if ( $pwd =~ m|/t$| )
528 { 537 {
529 return $pwd; 538 push ( @dirs, $pwd );
530 539
531 # The alternate that might work better is 540 # The alternate that might work better is
532 # chdir( ".." ); 541 # chdir( ".." );
@@ -535,7 +544,7 @@ sub DetermineTestHarnessDirectory
535 # to be tested is in the current directory (ie "./check_disk ....") 544 # to be tested is in the current directory (ie "./check_disk ....")
536 } 545 }
537 546
538 return undef; 547 return @dirs;
539} 548}
540 549
541sub TestsFrom 550sub TestsFrom
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index d71c83a2..d71c83a2 100644..100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
diff --git a/test.pl.in b/test.pl.in
index 85ac19da..01a97ec0 100755
--- a/test.pl.in
+++ b/test.pl.in
@@ -9,9 +9,9 @@ use Getopt::Long;
9 9
10use NPTest qw(DetermineTestHarnessDirectory TestsFrom); 10use NPTest qw(DetermineTestHarnessDirectory TestsFrom);
11 11
12my $tstdir; 12my @tstdir;
13 13
14if ( ! GetOptions( "testdir:s" => \$tstdir ) ) 14if ( ! GetOptions( "testdir:s" => \@tstdir ) )
15{ 15{
16 print "Usage: ${0} [--testdir=<directory>] [<test_harness.t> ...]\n"; 16 print "Usage: ${0} [--testdir=<directory>] [<test_harness.t> ...]\n";
17 exit 1; 17 exit 1;
@@ -25,15 +25,18 @@ if ( scalar( @ARGV ) )
25} 25}
26else 26else
27{ 27{
28 my $directory = DetermineTestHarnessDirectory( $tstdir ); 28 my @directory = DetermineTestHarnessDirectory( @tstdir );
29 29
30 if ( !defined( $directory ) ) 30 if ( @directory == 0 )
31 { 31 {
32 print STDERR "$0: Unable to determine the test harness directory - ABORTING\n"; 32 print STDERR "$0: Unable to determine the test harness directory - ABORTING\n";
33 exit 2; 33 exit 2;
34 } 34 }
35 35
36 @tests = TestsFrom( $directory, 1 ); 36 for my $d ( @directory )
37 {
38 push (@tests, TestsFrom( $d, 1 ));
39 }
37} 40}
38 41
39if ( ! scalar( @tests ) ) 42if ( ! scalar( @tests ) )