From bf4abd539507e1194d836e6e818bda4807f497bf Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Wed, 21 Jan 2009 01:27:06 -0500 Subject: Add die tests for extra-opts --- lib/tests/test_opts3.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 lib/tests/test_opts3.t (limited to 'lib/tests/test_opts3.t') 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 @@ +#!/usr/bin/perl +use Test::More; +use strict; +use warnings; + +if (! -e "./test_opts3") { + plan skip_all => "./test_opts3 not compiled - please install tap library and/or enable parse-ini to test"; +} + +# array of argument arrays +# - first value is the NAGIOS_CONFIG_PATH +# - 2nd value is the plugin name +# - 3rc and up are arguments +my @TESTS = ( + ['/nonexistent', 'prog_name', 'arg1', '--extra-opts', '--arg3', 'val2'], + ['.', 'prog_name', 'arg1', '--extra-opts=missing@./config-opts.ini', '--arg3', 'val2'], + ['.', 'prog_name', 'arg1', '--extra-opts', 'missing@./config-opts.ini', '--arg3', 'val2'], + ['.', 'check_missing', 'arg1', '--extra-opts=@./config-opts.ini', '--arg3', 'val2'], + ['.', 'check_missing', 'arg1', '--extra-opts', '--arg3', 'val2'], +); + +plan tests => scalar(@TESTS); + +my $count=1; + +foreach my $args (@TESTS) { + $ENV{"NAGIOS_CONFIG_PATH"} = shift(@$args); + system {'./test_opts3'} @$args; + cmp_ok($?>>8, '==', 3, "Extra-opts die " . $count++); +} + -- cgit v1.2.3-74-g34f1