summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_disk.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_disk.t')
-rw-r--r--plugins/t/check_disk.t44
1 files changed, 23 insertions, 21 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index f1e436dc..f2427fbe 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
1use strict; 8use strict;
2use Test; 9use Test;
10use NPTest;
11
3use vars qw($tests); 12use vars qw($tests);
13BEGIN {$tests = 10; plan tests => $tests}
14
15my $successOutput = '/^DISK OK - /';
16my $failureOutput = '/^DISK CRITICAL - /';
17
18my $mountpoint_valid = getTestParameter( "mountpoint_valid", "NP_MOUNTPOINT_VALID", "/",
19 "The path to a valid mountpoint" );
4 20
5BEGIN {$tests = 6; plan tests => $tests} 21my $mountpoint_invalid = getTestParameter( "mountpoint_invalid", "NP_MOUNTPOINT_INVALID", "/missing",
22 "The path to a invalid (non-existent) mountpoint" );
6 23
7my $null = '';
8my $cmd;
9my $str;
10my $t; 24my $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 );
15print "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;
21print "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;
27print "Test was: $cmd\n" unless ($?);
28$t += ok $str, '/^(Only +[\.0-9]+|DISK CRITICAL - )/';
29 31
30exit(0) if defined($Test::Harness::VERSION); 32exit(0) if defined($Test::Harness::VERSION);
31exit($tests - $t); 33exit($tests - $t);