diff options
| author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-05-24 08:53:50 +0000 |
|---|---|---|
| committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-05-24 08:53:50 +0000 |
| commit | 3f5fbd9797feffe31cc7046d2abd0ef819a703e8 (patch) | |
| tree | e38a2f306bcd9ed84d5060261014b7adf6721376 /plugins | |
| parent | eaf9908edd7bce25412dcdf4d96b23f3a3cafd57 (diff) | |
| download | monitoring-plugins-3f5fbd9797feffe31cc7046d2abd0ef819a703e8.tar.gz | |
Test for new functionality in negate (not automatically run in make test)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1717 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/t/negate.pl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/t/negate.pl b/plugins/t/negate.pl new file mode 100644 index 00000000..6c56d4f4 --- /dev/null +++ b/plugins/t/negate.pl | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | #! /usr/bin/perl -w -I .. | ||
| 2 | # | ||
| 3 | # negate checks | ||
| 4 | # Need check_dummy to work for testing | ||
| 5 | # | ||
| 6 | # $Id$ | ||
| 7 | # | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use Test::More; | ||
| 11 | use NPTest; | ||
| 12 | |||
| 13 | plan tests => 40; | ||
| 14 | |||
| 15 | my $res; | ||
| 16 | |||
| 17 | $res = NPTest->testCmd( "./negate" ); | ||
| 18 | is( $res->return_code, 3, "Not enough parameters"); | ||
| 19 | like( $res->output, "/Could not parse arguments/", "Could not parse arguments"); | ||
| 20 | |||
| 21 | $res = NPTest->testCmd( "./negate ./check_dummy 0 'a dummy okay'" ); | ||
| 22 | is( $res->return_code, 2, "OK changed to CRITICAL" ); | ||
| 23 | is( $res->output, "OK: a dummy okay" ); | ||
| 24 | |||
| 25 | $res = NPTest->testCmd( "./negate './check_dummy 0 redsweaterblog'"); | ||
| 26 | is( $res->return_code, 2, "OK => CRIT with a single quote for command to run" ); | ||
| 27 | is( $res->output, "OK: redsweaterblog" ); | ||
| 28 | |||
| 29 | $res = NPTest->testCmd( "./negate ./check_dummy 1 'a warn a day keeps the managers at bay'" ); | ||
| 30 | is( $res->return_code, 2, "WARN stays same" ); | ||
| 31 | |||
| 32 | $res = NPTest->testCmd( "./negate ./check_dummy 3 mysterious"); | ||
| 33 | is( $res->return_code, 3, "UNKNOWN stays same" ); | ||
| 34 | |||
| 35 | my %state = ( | ||
| 36 | ok => 0, | ||
| 37 | warning => 1, | ||
| 38 | critical => 2, | ||
| 39 | unknown => 3, | ||
| 40 | ); | ||
| 41 | foreach my $current_state (qw(ok warning critical unknown)) { | ||
| 42 | foreach my $new_state (qw(ok warning critical unknown)) { | ||
| 43 | $res = NPTest->testCmd( "./negate --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); | ||
| 44 | is( $res->return_code, $state{$new_state}, "Got fake $new_state" ); | ||
| 45 | is( $res->output, uc($current_state).": Fake $new_state" ); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
