summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2007-08-31 13:21:10 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2007-08-31 13:21:10 +0000
commit95dba9c4213c2e7e8f4b572efd873c1979406221 (patch)
treec39a8dc0022ae98b09bfe5fa75f2dc67b3c97a69 /t
parent4421aa3c2a695335cad006f32ece6c9c5da11165 (diff)
downloadmonitoring-plugin-perl-95dba9c4213c2e7e8f4b572efd873c1979406221.tar.gz
Fixed bug where warn or crit = 0 will raise an error. Optional flag to
tell nagios_die to use die instead of exit so trappable by eval git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1772 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't')
-rw-r--r--t/Nagios-Plugin-Functions-01.t7
-rw-r--r--t/Nagios-Plugin-Performance.t14
2 files changed, 19 insertions, 2 deletions
diff --git a/t/Nagios-Plugin-Functions-01.t b/t/Nagios-Plugin-Functions-01.t
index 70db221..5268255 100644
--- a/t/Nagios-Plugin-Functions-01.t
+++ b/t/Nagios-Plugin-Functions-01.t
@@ -1,6 +1,6 @@
1 1
2use strict; 2use strict;
3use Test::More tests => 112; 3use Test::More tests => 113;
4 4
5BEGIN { use_ok("Nagios::Plugin::Functions", ":all"); } 5BEGIN { use_ok("Nagios::Plugin::Functions", ":all"); }
6Nagios::Plugin::Functions::_fake_exit(1); 6Nagios::Plugin::Functions::_fake_exit(1);
@@ -154,3 +154,8 @@ for (@ok) {
154 $_->[1] . '.*' . $_->[2])); 154 $_->[1] . '.*' . $_->[2]));
155} 155}
156 156
157# Check that _use_die set to 1 will catch exceptions correctly
158Nagios::Plugin::Functions::_fake_exit(0);
159Nagios::Plugin::Functions::_use_die(1);
160eval { nagios_die("Using die") };
161is( $@, "NAGIOS-PLUGIN-FUNCTIONS-01 UNKNOWN - Using die\n", "Caught exception");
diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t
index 0dcb800..c4d518c 100644
--- a/t/Nagios-Plugin-Performance.t
+++ b/t/Nagios-Plugin-Performance.t
@@ -1,6 +1,6 @@
1 1
2use strict; 2use strict;
3use Test::More tests => 77; 3use Test::More tests => 84;
4BEGIN { use_ok('Nagios::Plugin::Performance') }; 4BEGIN { use_ok('Nagios::Plugin::Performance') };
5 5
6diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; 6diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE};
@@ -120,5 +120,17 @@ cmp_ok( $p[0]->rrdlabel, "eq", "home_a_m", "changing / to _");
120cmp_ok( $p[1]->rrdlabel, "eq", "shared_folder_big", "replacing bad characters"); 120cmp_ok( $p[1]->rrdlabel, "eq", "shared_folder_big", "replacing bad characters");
121cmp_ok( $p[2]->rrdlabel, "eq", "1234567890123456789", "shortening rrd label"); 121cmp_ok( $p[2]->rrdlabel, "eq", "1234567890123456789", "shortening rrd label");
122 122
123# turn off fake_exit and enable use_die so we pick up on errors via nagios_die
124Nagios::Plugin::Functions::_use_die(1);
125Nagios::Plugin::Functions::_fake_exit(0);
126
127@p = Nagios::Plugin::Performance->parse_perfstring("time=0.002722s;0.000000;0.000000;0.000000;10.000000");
128cmp_ok( $p[0]->label, "eq", "time", "label okay");
129cmp_ok( $p[0]->value, "eq", "0.002722", "value okay");
130cmp_ok( $p[0]->uom, "eq", "s", "uom okay");
131 ok( defined $p[0]->threshold->warning->is_set, "Warning range has been set");
132 ok( defined $p[0]->threshold->critical->is_set, "Critical range has been set");
133cmp_ok( $p[0]->threshold->warning, 'eq', "0", "warn okay");
134cmp_ok( $p[0]->threshold->critical, 'eq', "0", "crit okay");
123 135
124# add_perfdata tests in t/Nagios-Plugin-01.t 136# add_perfdata tests in t/Nagios-Plugin-01.t