3 use strict
; use warnings
;
4 #use Test::More qw(no_plan);
5 use Test
::More tests
=> 14;
8 my $s = 't/check_stuff.pl';
13 # Monitoring status strings and exit codes
22 is
$?
>>8 , $e{UNKNOWN
}, "exits($e{UNKNOWN}) with no args";
23 like
$r, qr/^$n UNKNOWN/, "UNKNOWN with no args";
26 is
$?
>>8 , $e{UNKNOWN
}, "exits($e{UNKNOWN}) with -V arg";
27 like
$r, qr/^[\w\.]+ \d+/i, "looks like there's a version";
30 is
$?
>>8 , $e{UNKNOWN
}, "exits($e{UNKNOWN}) with -h arg";
31 like
$r, qr/usage/i, "looks like there's something helpful"; # broken
34 diag
"running `$s $args`" if $ENV{TEST_VERBOSE
};
36 diag
"output: '$r'" if $ENV{TEST_VERBOSE
};
37 is
$?
>>8 , $e{UNKNOWN
}, "exits($e{UNKNOWN}) with $args";
38 like
$r, qr/UNKNOWN.+invalid/i, "UNKNOWN (warning: invalid -r) with $args";
42 " -w 10:15 -c~:15 -r 0" => 'WARNING',
43 " -w 10:15 -c~:15 -r 11" => 'OK',
44 " -w 10:15 -c~:15 -r 15.8" => 'CRITICAL',
47 test_expected
( $s, $expected );
53 foreach ( keys %$expected ) {
54 diag
"running `$s $_`" if $ENV{TEST_VERBOSE
};
56 diag
"output: '$r'" if $ENV{TEST_VERBOSE
};
57 is
$?
>>8 , $e{$expected->{$_}}, "exits($e{$expected->{$_}}) with $_";
58 like
$r, qr/^$n $expected->{$_}/i, "looks $expected->{$_} with $_";