summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_swap.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_swap.t')
-rw-r--r--plugins/t/check_swap.t14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t
index de9e0f0..1878038 100644
--- a/plugins/t/check_swap.t
+++ b/plugins/t/check_swap.t
@@ -5,7 +5,7 @@
5# 5#
6 6
7use strict; 7use strict;
8use Test::More tests => 8; 8use Test::More tests => 14;
9use NPTest; 9use NPTest;
10 10
11my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/'; 11my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
@@ -14,6 +14,10 @@ my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)
14 14
15my $result; 15my $result;
16 16
17$result = NPTest->testCmd( "./check_swap" ); # Always OK
18cmp_ok( $result->return_code, "==", 0, "Always OK" );
19like( $result->output, $successOutput, "Right output" );
20
17$result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free 21$result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576" ); # 1 MB free
18cmp_ok( $result->return_code, "==", 0, "At least 1MB free" ); 22cmp_ok( $result->return_code, "==", 0, "At least 1MB free" );
19like( $result->output, $successOutput, "Right output" ); 23like( $result->output, $successOutput, "Right output" );
@@ -29,3 +33,11 @@ like( $result->output, $failureOutput, "Right output" );
29$result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn) 33$result = NPTest->testCmd( "./check_swap -w 100% -c 1%" ); # 100% (always warn)
30cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' ); 34cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
31like( $result->output, $warnOutput, "Right output" ); 35like( $result->output, $warnOutput, "Right output" );
36
37$result = NPTest->testCmd( "./check_swap -w 100%" ); # 100% (single threshold, always warn)
38cmp_ok( $result->return_code, "==", 1, 'Get warning because not 100% free' );
39like( $result->output, $warnOutput, "Right output" );
40
41$result = NPTest->testCmd( "./check_swap -c 100%" ); # 100% (single threshold, always critical)
42cmp_ok( $result->return_code, "==", 2, 'Get critical because not 100% free' );
43like( $result->output, $failureOutput, "Right output" );