summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--configure.in2
-rw-r--r--lib/tests/Makefile.am6
-rw-r--r--lib/tests/test_ini1.c (renamed from lib/tests/test_ini.c)0
-rwxr-xr-xlib/tests/test_ini1.t (renamed from lib/tests/test_ini.t)0
-rw-r--r--lib/tests/test_ini3.c33
-rwxr-xr-xlib/tests/test_ini3.t34
-rwxr-xr-xlib/tests/test_opts3.t8
8 files changed, 79 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 780461f9..be40c084 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,7 +93,8 @@ NP-VERSION-FILE
93/lib/tests/utils_disk.Po 93/lib/tests/utils_disk.Po
94/lib/tests/utils_tcp.Po 94/lib/tests/utils_tcp.Po
95/lib/tests/parse_ini.Po 95/lib/tests/parse_ini.Po
96/lib/tests/test_ini 96/lib/tests/test_ini1
97/lib/tests/test_ini3
97/lib/tests/test_opts1 98/lib/tests/test_opts1
98/lib/tests/test_opts2 99/lib/tests/test_opts2
99/lib/tests/test_opts3 100/lib/tests/test_opts3
diff --git a/configure.in b/configure.in
index 57e438c5..68ac0a00 100644
--- a/configure.in
+++ b/configure.in
@@ -188,7 +188,7 @@ AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
188if test "$enable_extra_opts" = "yes" ; then 188if test "$enable_extra_opts" = "yes" ; then
189 AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.]) 189 AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
190 if test "$enable_libtap" = "yes"; then 190 if test "$enable_libtap" = "yes"; then
191 EXTRA_TEST="$EXTRA_TEST test_ini test_opts1 test_opts2 test_opts3" 191 EXTRA_TEST="$EXTRA_TEST test_ini1 test_ini3 test_opts1 test_opts2 test_opts3"
192 AC_SUBST(EXTRA_TEST) 192 AC_SUBST(EXTRA_TEST)
193 fi 193 fi
194fi 194fi
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 4bab2f2a..694baf00 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -7,9 +7,9 @@ check_PROGRAMS = @EXTRA_TEST@
7 7
8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins 8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
9 9
10EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts1 test_opts2 test_opts3 10EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini1 test_ini3 test_opts1 test_opts2 test_opts3
11 11
12np_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 12np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini1.t test_ini3.t test_opts1.t test_opts2.t test_opts3.t test_tcp.t test_utils.t
13np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini 13np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini
14EXTRA_DIST = $(np_test_scripts) $(np_test_files) 14EXTRA_DIST = $(np_test_scripts) $(np_test_files)
15 15
@@ -28,7 +28,7 @@ AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags)
28AM_LDFLAGS = $(tap_ldflags) -ltap 28AM_LDFLAGS = $(tap_ldflags) -ltap
29LDADD = $(top_srcdir)/lib/libnagiosplug.a $(top_srcdir)/gl/libgnu.a 29LDADD = $(top_srcdir)/lib/libnagiosplug.a $(top_srcdir)/gl/libgnu.a
30 30
31SOURCES = 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 31SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c
32 32
33test: ${noinst_PROGRAMS} 33test: ${noinst_PROGRAMS}
34 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) 34 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
diff --git a/lib/tests/test_ini.c b/lib/tests/test_ini1.c
index c0853d7c..c0853d7c 100644
--- a/lib/tests/test_ini.c
+++ b/lib/tests/test_ini1.c
diff --git a/lib/tests/test_ini.t b/lib/tests/test_ini1.t
index 0487098c..0487098c 100755
--- a/lib/tests/test_ini.t
+++ b/lib/tests/test_ini1.t
diff --git a/lib/tests/test_ini3.c b/lib/tests/test_ini3.c
new file mode 100644
index 00000000..814b3ec0
--- /dev/null
+++ b/lib/tests/test_ini3.c
@@ -0,0 +1,33 @@
1/*****************************************************************************
2*
3* This program is free software: you can redistribute it and/or modify
4* it under the terms of the GNU General Public License as published by
5* the Free Software Foundation, either version 3 of the License, or
6* (at your option) any later version.
7*
8* This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16*
17*****************************************************************************/
18
19#include "parse_ini.h"
20
21int
22main (int argc, char **argv)
23{
24
25 /*
26 * This is for testing arguments expected to die.
27 */
28
29 np_get_defaults(argv[1], argv[0]);
30
31 return 0;
32}
33
diff --git a/lib/tests/test_ini3.t b/lib/tests/test_ini3.t
new file mode 100755
index 00000000..57388dda
--- /dev/null
+++ b/lib/tests/test_ini3.t
@@ -0,0 +1,34 @@
1#!/usr/bin/perl
2use Test::More;
3use strict;
4use warnings;
5
6if (! -e "./test_ini") {
7 plan skip_all => "./test_ini 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 expected return code
12# - 2nd value is the NAGIOS_CONFIG_PATH
13# TODO: looks like we look in default path after looking trough this variable - shall we?
14# - 3rd value is the plugin name
15# - 4th is the ini locator
16my @TESTS = (
17 [3, undef, "section", "section_unknown@./config-tiny.ini"],
18);
19
20plan tests => scalar(@TESTS);
21
22my $count=1;
23
24foreach my $args (@TESTS) {
25 my $rc = shift(@$args);
26 if (my $env = shift(@$args)) {
27 $ENV{"NAGIOS_CONFIG_PATH"} = $env;
28 } else {
29 delete($ENV{"NAGIOS_CONFIG_PATH"});
30 }
31 system {'./test_ini2'} @$args;
32 cmp_ok($?>>8, '==', $rc, "Parse-ini die " . $count++);
33}
34
diff --git a/lib/tests/test_opts3.t b/lib/tests/test_opts3.t
index 35b44687..fa7876d0 100755
--- a/lib/tests/test_opts3.t
+++ b/lib/tests/test_opts3.t
@@ -28,8 +28,12 @@ plan tests => scalar(@TESTS);
28my $count=1; 28my $count=1;
29 29
30foreach my $args (@TESTS) { 30foreach my $args (@TESTS) {
31 my $rc = shift(@$args); 31 my $rc = shift(@$args);
32 $ENV{"NAGIOS_CONFIG_PATH"} = shift(@$args); 32 if (my $env = shift(@$args)) {
33 $ENV{"NAGIOS_CONFIG_PATH"} = $env;
34 } else {
35 delete($ENV{"NAGIOS_CONFIG_PATH"});
36 }
33 system {'./test_opts3'} @$args; 37 system {'./test_opts3'} @$args;
34 cmp_ok($?>>8, '==', $rc, "Extra-opts die " . $count++); 38 cmp_ok($?>>8, '==', $rc, "Extra-opts die " . $count++);
35} 39}