diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-31 13:54:44 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-31 13:54:44 (GMT) |
commit | 1dd0e4c96376f2c28590dad683161ee8c57c0508 (patch) | |
tree | 4a61176ad008db3d6c835393d6a1332453d297e1 | |
parent | 35811848da1095525e6937159f6611fc8a87261b (diff) | |
download | monitoring-plugins-1dd0e4c96376f2c28590dad683161ee8c57c0508.tar.gz |
Enable tests in tests/ subdirs
-rw-r--r-- | NPTest.pm | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | plugins/tests/check_procs.t | 0 | ||||
-rwxr-xr-x | test.pl.in | 13 |
3 files changed, 29 insertions, 17 deletions
@@ -494,26 +494,35 @@ sub SetCacheFilename | |||
494 | 494 | ||
495 | sub DetermineTestHarnessDirectory | 495 | sub 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 | ||
541 | sub TestsFrom | 550 | sub TestsFrom |
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t index d71c83a..d71c83a 100644..100755 --- a/plugins/tests/check_procs.t +++ b/plugins/tests/check_procs.t | |||
@@ -9,9 +9,9 @@ use Getopt::Long; | |||
9 | 9 | ||
10 | use NPTest qw(DetermineTestHarnessDirectory TestsFrom); | 10 | use NPTest qw(DetermineTestHarnessDirectory TestsFrom); |
11 | 11 | ||
12 | my $tstdir; | 12 | my @tstdir; |
13 | 13 | ||
14 | if ( ! GetOptions( "testdir:s" => \$tstdir ) ) | 14 | if ( ! 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 | } |
26 | else | 26 | else |
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 | ||
39 | if ( ! scalar( @tests ) ) | 42 | if ( ! scalar( @tests ) ) |