diff options
| -rw-r--r-- | NPTest.pm | 29 | ||||
| -rw-r--r-- | plugins/t/check_fping.t | 14 |
2 files changed, 34 insertions, 9 deletions
| @@ -6,7 +6,7 @@ package NPTest; | |||
| 6 | 6 | ||
| 7 | require Exporter; | 7 | require Exporter; |
| 8 | @ISA = qw(Exporter); | 8 | @ISA = qw(Exporter); |
| 9 | @EXPORT = qw(getTestParameter checkCmd skipMissingCmd); | 9 | @EXPORT = qw(getTestParameter checkCmd skipMissingCmd skipMsg); |
| 10 | @EXPORT_OK = qw(DetermineTestHarnessDirectory TestsFrom SetCacheFilename); | 10 | @EXPORT_OK = qw(DetermineTestHarnessDirectory TestsFrom SetCacheFilename); |
| 11 | 11 | ||
| 12 | use strict; | 12 | use strict; |
| @@ -38,8 +38,8 @@ testing. | |||
| 38 | 38 | ||
| 39 | =head1 FUNCTIONS | 39 | =head1 FUNCTIONS |
| 40 | 40 | ||
| 41 | This module defines three public functions, C<getTestParameter(...)>, | 41 | This module defines four public functions, C<getTestParameter(...)>, |
| 42 | C<checkCmd(...)> and C<skipMissingCmd(...)>. These are exported by | 42 | C<checkCmd(...)>, C<skipMissingCmd(...)> and C<skipMsg(...)>. These are exported by |
| 43 | default via the C<use NPTest;> statement. | 43 | default via the C<use NPTest;> statement. |
| 44 | 44 | ||
| 45 | =over | 45 | =over |
| @@ -185,6 +185,15 @@ of times. | |||
| 185 | 185 | ||
| 186 | =back | 186 | =back |
| 187 | 187 | ||
| 188 | =item C<skipMsg(...)> | ||
| 189 | |||
| 190 | If for any reason the test harness must C<Test::skip()> some | ||
| 191 | or all of the tests in a given test harness this function provides a | ||
| 192 | simple iterator to issue an appropriate message the requested number | ||
| 193 | of times. | ||
| 194 | |||
| 195 | =back | ||
| 196 | |||
| 188 | =head1 SEE ALSO | 197 | =head1 SEE ALSO |
| 189 | 198 | ||
| 190 | L<Test> | 199 | L<Test> |
| @@ -304,6 +313,20 @@ sub skipMissingCmd | |||
| 304 | return $testStatus; | 313 | return $testStatus; |
| 305 | } | 314 | } |
| 306 | 315 | ||
| 316 | sub skipMsg | ||
| 317 | { | ||
| 318 | my( $msg, $count ) = @_; | ||
| 319 | |||
| 320 | my $testStatus; | ||
| 321 | |||
| 322 | for ( 1 .. $count ) | ||
| 323 | { | ||
| 324 | $testStatus += skip( $msg, 1 ); | ||
| 325 | } | ||
| 326 | |||
| 327 | return $testStatus; | ||
| 328 | } | ||
| 329 | |||
| 307 | sub getTestParameter | 330 | sub getTestParameter |
| 308 | { | 331 | { |
| 309 | my( $param, $envvar, $default, $brief, $scoped ); | 332 | my( $param, $envvar, $default, $brief, $scoped ); |
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t index 45a9be8a..08692e46 100644 --- a/plugins/t/check_fping.t +++ b/plugins/t/check_fping.t | |||
| @@ -27,16 +27,18 @@ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_IN | |||
| 27 | 27 | ||
| 28 | my $t; | 28 | my $t; |
| 29 | 29 | ||
| 30 | if ( -x "./check_fping" ) | 30 | my $fping = qx(which fping 2> /dev/null); |
| 31 | { | 31 | chomp($fping); |
| 32 | if( ! -x "./check_fping") { | ||
| 33 | $t += skipMissingCmd( "./check_fping", $tests ); | ||
| 34 | } | ||
| 35 | elsif ( $> != 0 && (!$fping || ! -u $fping)) { | ||
| 36 | $t += skipMsg( "./check_fping", $tests ); | ||
| 37 | } else { | ||
| 32 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); | 38 | $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); |
| 33 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); | 39 | $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); |
| 34 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); | 40 | $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); |
| 35 | } | 41 | } |
| 36 | else | ||
| 37 | { | ||
| 38 | $t += skipMissingCmd( "./check_fping", $tests ); | ||
| 39 | } | ||
| 40 | 42 | ||
| 41 | exit(0) if defined($Test::Harness::VERSION); | 43 | exit(0) if defined($Test::Harness::VERSION); |
| 42 | exit($tests - $t); | 44 | exit($tests - $t); |
