summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dummy.c4
-rw-r--r--plugins/t/check_dummy.t55
2 files changed, 58 insertions, 1 deletions
diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c
index dfd6c9c2..876ebb11 100644
--- a/plugins/check_dummy.c
+++ b/plugins/check_dummy.c
@@ -84,8 +84,10 @@ main (int argc, char **argv)
84 printf (_("UNKNOWN")); 84 printf (_("UNKNOWN"));
85 break; 85 break;
86 default: 86 default:
87 printf (_("UNKNOWN"));
88 printf (": ");
87 printf (_("Status %d is not a supported error state\n"), result); 89 printf (_("Status %d is not a supported error state\n"), result);
88 break; 90 return STATE_UNKNOWN;
89 } 91 }
90 92
91 if (argc >= 3) 93 if (argc >= 3)
diff --git a/plugins/t/check_dummy.t b/plugins/t/check_dummy.t
new file mode 100644
index 00000000..aaa7a410
--- /dev/null
+++ b/plugins/t/check_dummy.t
@@ -0,0 +1,55 @@
1#! /usr/bin/perl -w -I ..
2#
3# check_dummy tests
4#
5# $Id$
6#
7
8use strict;
9use Test::More;
10use NPTest;
11
12plan tests => 20;
13
14my $res;
15
16$res = NPTest->testCmd("./check_dummy");
17is( $res->return_code, 3, "No args" );
18like( $res->output, "/Could not parse arguments/", "Correct usage message");
19
20$res = NPTest->testCmd("./check_dummy 0");
21is( $res->return_code, 0, "OK state returned");
22is( $res->output, "OK", "Says 'OK'");
23
24$res = NPTest->testCmd("./check_dummy 0 'some random data'");
25is( $res->return_code, 0, "Still OK");
26is( $res->output, "OK: some random data", "Sample text okay");
27
28$res = NPTest->testCmd("./check_dummy 1");
29is( $res->return_code, 1, "Warning okay");
30is( $res->output, "WARNING", "Says 'WARNING'");
31
32$res = NPTest->testCmd("./check_dummy 1 'more stuff'");
33is( $res->return_code, 1, "Still warning");
34is( $res->output, "WARNING: more stuff", "optional text okay" );
35
36$res = NPTest->testCmd("./check_dummy 2");
37is( $res->return_code, 2, "Critical ok" );
38is( $res->output, "CRITICAL", "Says 'CRITICAL'");
39
40$res = NPTest->testCmd("./check_dummy 2 'roughly drafted'");
41is( $res->return_code, 2, "Still critical");
42is( $res->output, "CRITICAL: roughly drafted", "optional text okay" );
43
44$res = NPTest->testCmd("./check_dummy 3");
45is( $res->return_code, 3, "Unknown ok" );
46is( $res->output, "UNKNOWN", "Says 'UNKNOWN'");
47
48$res = NPTest->testCmd("./check_dummy 3 'daringfireball'");
49is( $res->return_code, 3, "Still unknown");
50is( $res->output, "UNKNOWN: daringfireball", "optional text okay" );
51
52$res = NPTest->testCmd("./check_dummy 4");
53is( $res->return_code, 3, "Invalid error code" );
54is( $res->output, "UNKNOWN: Status 4 is not a supported error state", "With appropriate error message");
55