diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-05-24 08:35:53 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-05-24 08:35:53 +0000 |
commit | eaf9908edd7bce25412dcdf4d96b23f3a3cafd57 (patch) | |
tree | 33f2ef0cf963e4a7a606b2b3089479821c704e40 | |
parent | f8766fe505898d1617e11703840ac0a42f25272e (diff) | |
download | monitoring-plugins-eaf9908edd7bce25412dcdf4d96b23f3a3cafd57.tar.gz |
Tests for check_dummy
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1716 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | plugins/check_dummy.c | 4 | ||||
-rw-r--r-- | plugins/t/check_dummy.t | 55 |
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 | |||
8 | use strict; | ||
9 | use Test::More; | ||
10 | use NPTest; | ||
11 | |||
12 | plan tests => 20; | ||
13 | |||
14 | my $res; | ||
15 | |||
16 | $res = NPTest->testCmd("./check_dummy"); | ||
17 | is( $res->return_code, 3, "No args" ); | ||
18 | like( $res->output, "/Could not parse arguments/", "Correct usage message"); | ||
19 | |||
20 | $res = NPTest->testCmd("./check_dummy 0"); | ||
21 | is( $res->return_code, 0, "OK state returned"); | ||
22 | is( $res->output, "OK", "Says 'OK'"); | ||
23 | |||
24 | $res = NPTest->testCmd("./check_dummy 0 'some random data'"); | ||
25 | is( $res->return_code, 0, "Still OK"); | ||
26 | is( $res->output, "OK: some random data", "Sample text okay"); | ||
27 | |||
28 | $res = NPTest->testCmd("./check_dummy 1"); | ||
29 | is( $res->return_code, 1, "Warning okay"); | ||
30 | is( $res->output, "WARNING", "Says 'WARNING'"); | ||
31 | |||
32 | $res = NPTest->testCmd("./check_dummy 1 'more stuff'"); | ||
33 | is( $res->return_code, 1, "Still warning"); | ||
34 | is( $res->output, "WARNING: more stuff", "optional text okay" ); | ||
35 | |||
36 | $res = NPTest->testCmd("./check_dummy 2"); | ||
37 | is( $res->return_code, 2, "Critical ok" ); | ||
38 | is( $res->output, "CRITICAL", "Says 'CRITICAL'"); | ||
39 | |||
40 | $res = NPTest->testCmd("./check_dummy 2 'roughly drafted'"); | ||
41 | is( $res->return_code, 2, "Still critical"); | ||
42 | is( $res->output, "CRITICAL: roughly drafted", "optional text okay" ); | ||
43 | |||
44 | $res = NPTest->testCmd("./check_dummy 3"); | ||
45 | is( $res->return_code, 3, "Unknown ok" ); | ||
46 | is( $res->output, "UNKNOWN", "Says 'UNKNOWN'"); | ||
47 | |||
48 | $res = NPTest->testCmd("./check_dummy 3 'daringfireball'"); | ||
49 | is( $res->return_code, 3, "Still unknown"); | ||
50 | is( $res->output, "UNKNOWN: daringfireball", "optional text okay" ); | ||
51 | |||
52 | $res = NPTest->testCmd("./check_dummy 4"); | ||
53 | is( $res->return_code, 3, "Invalid error code" ); | ||
54 | is( $res->output, "UNKNOWN: Status 4 is not a supported error state", "With appropriate error message"); | ||
55 | |||