[monitoring-plugins] tests: parts of the check_procs test only work ...
Sven Nierlein
git at monitoring-plugins.org
Fri Jun 13 16:20:09 CEST 2014
Module: monitoring-plugins
Branch: master
Commit: 3529d7465d31234ec634939ed1a6bdc915b73ccd
Author: Sven Nierlein <Sven.Nierlein at consol.de>
Date: Thu Jun 12 11:45:49 2014 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=3529d74
tests: parts of the check_procs test only work when uid -2 exists
skip those tests if the uid does not exist
Signed-off-by: Sven Nierlein <Sven.Nierlein at consol.de>
---
plugins/tests/check_procs.t | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 1ad2c2f..b153d5d 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -48,21 +48,25 @@ SKIP: {
like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
}
-$result = NPTest->testCmd( "$command -u -2 -w 2:2" );
-is( $result->return_code, 1, "Checking processes with userid=-2" );
-like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
+SKIP: {
+ skip 'user with uid -2 required', 8 unless getpwuid(-2);
+
+ $result = NPTest->testCmd( "$command -u -2 -w 2:2" );
+ is( $result->return_code, 1, "Checking processes with userid=-2" );
+ like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
-$result = NPTest->testCmd( "$command -u -2 -w 3:3" );
-is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
-like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
+ $result = NPTest->testCmd( "$command -u -2 -w 3:3" );
+ is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
+ like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
-$result = NPTest->testCmd( "$command -u -2 -a usb" );
-is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
-like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
+ $result = NPTest->testCmd( "$command -u -2 -a usb" );
+ is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
+ like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
-$result = NPTest->testCmd( "$command -u -2 -a UsB" );
-is( $result->return_code, 0, "Checking case sensitivity of args" );
-like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
+ $result = NPTest->testCmd( "$command -u -2 -a UsB" );
+ is( $result->return_code, 0, "Checking case sensitivity of args" );
+ like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
+};
$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
is( $result->return_code, 0, "Checking regexp search of arguments" );
More information about the Commits
mailing list