diff options
Diffstat (limited to 'plugins/t/check_disk.t')
-rw-r--r-- | plugins/t/check_disk.t | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index f1e436d..f2427fb 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -1,31 +1,33 @@ | |||
1 | #! /usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # Disk Space Tests via check_disk | ||
4 | # | ||
5 | # $Id$ | ||
6 | # | ||
7 | |||
1 | use strict; | 8 | use strict; |
2 | use Test; | 9 | use Test; |
10 | use NPTest; | ||
11 | |||
3 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | BEGIN {$tests = 10; plan tests => $tests} | ||
14 | |||
15 | my $successOutput = '/^DISK OK - /'; | ||
16 | my $failureOutput = '/^DISK CRITICAL - /'; | ||
17 | |||
18 | my $mountpoint_valid = getTestParameter( "mountpoint_valid", "NP_MOUNTPOINT_VALID", "/", | ||
19 | "The path to a valid mountpoint" ); | ||
4 | 20 | ||
5 | BEGIN {$tests = 6; plan tests => $tests} | 21 | my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing", |
22 | "The path to a invalid (non-existent) mountpoint" ); | ||
6 | 23 | ||
7 | my $null = ''; | ||
8 | my $cmd; | ||
9 | my $str; | ||
10 | my $t; | 24 | my $t; |
11 | 25 | ||
12 | $cmd = "./check_disk 100 100 /"; | 26 | $t += checkCmd( "./check_disk 100 100 ${mountpoint_valid}", 0, $successOutput ); |
13 | $str = `$cmd`; | 27 | $t += checkCmd( "./check_disk -w 0 -c 0 ${mountpoint_valid}", 0, $successOutput ); |
14 | $t += ok $?>>8,0; | 28 | $t += checkCmd( "./check_disk -w 1\% -c 1\% ${mountpoint_valid}", 0, $successOutput ); |
15 | print "Test was: $cmd\n" if ($?); | 29 | $t += checkCmd( "./check_disk 0 0 ${mountpoint_valid}", 2, $failureOutput ); |
16 | $t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; | 30 | $t += checkCmd( "./check_disk 100 100 ${mountpoint_invalid}", 2, '/not found/' ); |
17 | |||
18 | $cmd = "./check_disk -w 0 -c 0 /"; | ||
19 | $str = `$cmd`; | ||
20 | $t += ok $?>>8,0; | ||
21 | print "Test was: $cmd\n" if ($?); | ||
22 | $t += ok $str, '/^(Disk ok - +[\.0-9]+|DISK OK - )/'; | ||
23 | |||
24 | $cmd = "./check_disk 0 0 /"; | ||
25 | $str = `$cmd`; | ||
26 | $t += ok $?>>8,2; | ||
27 | print "Test was: $cmd\n" unless ($?); | ||
28 | $t += ok $str, '/^(Only +[\.0-9]+|DISK CRITICAL - )/'; | ||
29 | 31 | ||
30 | exit(0) if defined($Test::Harness::VERSION); | 32 | exit(0) if defined($Test::Harness::VERSION); |
31 | exit($tests - $t); | 33 | exit($tests - $t); |