diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-01-21 01:27:06 -0500 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-01-22 02:04:31 -0500 |
commit | bf4abd539507e1194d836e6e818bda4807f497bf (patch) | |
tree | 0647c6b830d464e88cd7970034b03f836ea7412d /lib/tests/test_opts3.t | |
parent | a4647be424c9350ab967eeacccd2761c71f9c6a9 (diff) | |
download | monitoring-plugins-bf4abd539507e1194d836e6e818bda4807f497bf.tar.gz |
Add die tests for extra-opts
Diffstat (limited to 'lib/tests/test_opts3.t')
-rwxr-xr-x | lib/tests/test_opts3.t | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/tests/test_opts3.t b/lib/tests/test_opts3.t new file mode 100755 index 00000000..47ec26b3 --- /dev/null +++ b/lib/tests/test_opts3.t | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use Test::More; | ||
3 | use strict; | ||
4 | use warnings; | ||
5 | |||
6 | if (! -e "./test_opts3") { | ||
7 | plan skip_all => "./test_opts3 not compiled - please install tap library and/or enable parse-ini to test"; | ||
8 | } | ||
9 | |||
10 | # array of argument arrays | ||
11 | # - first value is the NAGIOS_CONFIG_PATH | ||
12 | # - 2nd value is the plugin name | ||
13 | # - 3rc and up are arguments | ||
14 | my @TESTS = ( | ||
15 | ['/nonexistent', 'prog_name', 'arg1', '--extra-opts', '--arg3', 'val2'], | ||
16 | ['.', 'prog_name', 'arg1', '--extra-opts=missing@./config-opts.ini', '--arg3', 'val2'], | ||
17 | ['.', 'prog_name', 'arg1', '--extra-opts', 'missing@./config-opts.ini', '--arg3', 'val2'], | ||
18 | ['.', 'check_missing', 'arg1', '--extra-opts=@./config-opts.ini', '--arg3', 'val2'], | ||
19 | ['.', 'check_missing', 'arg1', '--extra-opts', '--arg3', 'val2'], | ||
20 | ); | ||
21 | |||
22 | plan tests => scalar(@TESTS); | ||
23 | |||
24 | my $count=1; | ||
25 | |||
26 | foreach my $args (@TESTS) { | ||
27 | $ENV{"NAGIOS_CONFIG_PATH"} = shift(@$args); | ||
28 | system {'./test_opts3'} @$args; | ||
29 | cmp_ok($?>>8, '==', 3, "Extra-opts die " . $count++); | ||
30 | } | ||
31 | |||