[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2139] nagiosplug/trunk

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Thu Jan 22 08:08:45 CET 2009


Revision: 2139
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2139&view=rev
Author:   dermoth
Date:     2009-01-22 07:08:45 +0000 (Thu, 22 Jan 2009)

Log Message:
-----------
Add die tests for extra-opts

From: Thomas Guyot-Sionnest <dermoth at aei.ca>

Modified Paths:
--------------
    nagiosplug/trunk/.gitignore
    nagiosplug/trunk/configure.in
    nagiosplug/trunk/lib/tests/Makefile.am
    nagiosplug/trunk/lib/tests/test_opts1.c
    nagiosplug/trunk/lib/tests/test_opts2.c

Added Paths:
-----------
    nagiosplug/trunk/lib/tests/test_opts3.c
    nagiosplug/trunk/lib/tests/test_opts3.t

Modified: nagiosplug/trunk/.gitignore
===================================================================
--- nagiosplug/trunk/.gitignore	2009-01-22 07:08:24 UTC (rev 2138)
+++ nagiosplug/trunk/.gitignore	2009-01-22 07:08:45 UTC (rev 2139)
@@ -96,6 +96,7 @@
 /lib/tests/test_ini
 /lib/tests/test_opts1
 /lib/tests/test_opts2
+/lib/tests/test_opts3
 /lib/tests/extra_opts.Po
 
 # /m4/

Modified: nagiosplug/trunk/configure.in
===================================================================
--- nagiosplug/trunk/configure.in	2009-01-22 07:08:24 UTC (rev 2138)
+++ nagiosplug/trunk/configure.in	2009-01-22 07:08:45 UTC (rev 2139)
@@ -188,7 +188,7 @@
 if test "$enable_extra_opts" = "yes" ; then
 	AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
 	if test "$enable_libtap" = "yes"; then
-		EXTRA_TEST="$EXTRA_TEST test_ini test_opts1 test_opts2"
+		EXTRA_TEST="$EXTRA_TEST test_ini test_opts1 test_opts2 test_opts3"
 		AC_SUBST(EXTRA_TEST)
 	fi
 fi

Modified: nagiosplug/trunk/lib/tests/Makefile.am
===================================================================
--- nagiosplug/trunk/lib/tests/Makefile.am	2009-01-22 07:08:24 UTC (rev 2138)
+++ nagiosplug/trunk/lib/tests/Makefile.am	2009-01-22 07:08:45 UTC (rev 2139)
@@ -7,9 +7,9 @@
 
 INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
 
-EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts1 test_opts2
+EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts1 test_opts2 test_opts3
 
-np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini.t test_opts1.t test_opts2.t test_tcp.t test_utils.t
+np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini.t test_opts1.t test_opts2.t test_opts3.t test_tcp.t test_utils.t
 np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini
 EXTRA_DIST = $(np_test_scripts) $(np_test_files)
 
@@ -28,7 +28,7 @@
 AM_LDFLAGS = $(tap_ldflags) -ltap
 LDADD = $(top_srcdir)/lib/libnagiosplug.a $(top_srcdir)/gl/libgnu.a
 
-SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini.c test_opts1.c test_opts2.c
+SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini.c test_opts1.c test_opts2.c test_opts3.c
 
 test: ${noinst_PROGRAMS}
 	perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)

Modified: nagiosplug/trunk/lib/tests/test_opts1.c
===================================================================
--- nagiosplug/trunk/lib/tests/test_opts1.c	2009-01-22 07:08:24 UTC (rev 2138)
+++ nagiosplug/trunk/lib/tests/test_opts1.c	2009-01-22 07:08:45 UTC (rev 2139)
@@ -1,18 +1,18 @@
 /*****************************************************************************
-* 
+*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
-* 
+*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-* 
+*
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
-* 
+*
 *****************************************************************************/
 
 #include "common.h"

Modified: nagiosplug/trunk/lib/tests/test_opts2.c
===================================================================
--- nagiosplug/trunk/lib/tests/test_opts2.c	2009-01-22 07:08:24 UTC (rev 2138)
+++ nagiosplug/trunk/lib/tests/test_opts2.c	2009-01-22 07:08:45 UTC (rev 2139)
@@ -1,15 +1,15 @@
 /*****************************************************************************
-* 
+*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
-* 
+*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-* 
+*
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 

Added: nagiosplug/trunk/lib/tests/test_opts3.c
===================================================================
--- nagiosplug/trunk/lib/tests/test_opts3.c	                        (rev 0)
+++ nagiosplug/trunk/lib/tests/test_opts3.c	2009-01-22 07:08:45 UTC (rev 2139)
@@ -0,0 +1,31 @@
+/*****************************************************************************
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*
+*****************************************************************************/
+
+#include "extra_opts.h"
+
+int
+main (int argc, char **argv)
+{
+
+	/*
+	 * This is for testing arguments expected to die.
+	 */
+	argv=np_extra_opts(&argc, argv, argv[0]);
+
+	return 0;
+}
+

Added: nagiosplug/trunk/lib/tests/test_opts3.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_opts3.t	                        (rev 0)
+++ nagiosplug/trunk/lib/tests/test_opts3.t	2009-01-22 07:08:45 UTC (rev 2139)
@@ -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 at ./config-opts.ini', '--arg3', 'val2'],
+	['.', 'prog_name', 'arg1', '--extra-opts', 'missing at ./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++);
+}
+


Property changes on: nagiosplug/trunk/lib/tests/test_opts3.t
___________________________________________________________________
Added: svn:executable
   + *


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list