summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am9
-rw-r--r--configure.in26
-rw-r--r--external/README4
-rw-r--r--external/tap-1.01-nagios-plugins.tar.gzbin431388 -> 0 bytes
-rw-r--r--lib/tests/Makefile.am60
-rwxr-xr-xlib/tests/test_all.t38
-rwxr-xr-xlib/tests/test_base64.t6
-rw-r--r--lib/tests/test_cmd.t6
-rwxr-xr-xlib/tests/test_disk.t6
-rwxr-xr-xlib/tests/test_ini.t6
-rwxr-xr-xlib/tests/test_opts.t6
-rwxr-xr-xlib/tests/test_tcp.t6
-rw-r--r--lib/tests/test_utils.c5
-rwxr-xr-xlib/tests/test_utils.t6
-rwxr-xr-xtools/setup3
15 files changed, 92 insertions, 95 deletions
diff --git a/Makefile.am b/Makefile.am
index 7032578..a0bc561 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,16 +1,14 @@
1## Process this file with automake to produce Makefile.in 1## Process this file with automake to produce Makefile.in
2 2
3SUBDIRS = gl @INCLUDE_TAP_DIR@ lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ 3SUBDIRS = gl lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
4 4
5# Have to list TAP_DIR manually to get in distribution
6EXTRA_DIST = config.rpath \ 5EXTRA_DIST = config.rpath \
7 ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \ 6 ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \
8 NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \ 7 NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
9 NPTest.pm contrib pkg nagios-plugins.spec \ 8 NPTest.pm contrib pkg nagios-plugins.spec \
10 config_test/Makefile config_test/run_tests config_test/child_test.c \ 9 config_test/Makefile config_test/run_tests config_test/child_test.c \
11 perlmods tools/build_perl_modules \ 10 perlmods tools/build_perl_modules \
12 tools/tinderbox_build \ 11 tools/tinderbox_build
13 external/tap-1.01
14 12
15ACLOCAL_AMFLAGS = -I gl/m4 -I m4 13ACLOCAL_AMFLAGS = -I gl/m4 -I m4
16 14
@@ -24,9 +22,6 @@ dist-hook:
24install-root: 22install-root:
25 cd plugins-root && $(MAKE) $@ 23 cd plugins-root && $(MAKE) $@
26 24
27tap:
28 cd @TAP_DIR@ && $(MAKE)
29
30test test-debug: 25test test-debug:
31 cd lib && $(MAKE) $@ 26 cd lib && $(MAKE) $@
32 if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi 27 if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi
diff --git a/configure.in b/configure.in
index 8cae534..39cd6b7 100644
--- a/configure.in
+++ b/configure.in
@@ -156,25 +156,11 @@ AC_CHECK_HEADERS(math.h)
156AC_CHECK_LIB(m,floor,MATHLIBS="-lm") 156AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
157AC_SUBST(MATHLIBS) 157AC_SUBST(MATHLIBS)
158 158
159dnl Add libtap for tests 159dnl Check for libtap, to run perl-like tests
160AC_ARG_ENABLE(libtap, 160AC_CHECK_LIB(tap, plan_tests,
161 AC_HELP_STRING([--enable-libtap],
162 [Enables configuring of libtap in external/tap/. Run "make tap" to compile (default: no)]),
163 [enable_libtap=$enableval],
164 [enable_libtap=no])
165dnl Have to define TAP_DIR so that Makefile can pull it as an extra dist
166TAP_DIR=external/tap-1.01
167AC_SUBST(TAP_DIR)
168if test "$enable_libtap" = yes; then
169 dnl Have to have AC_CONFIG_SUBDIRS as a literal
170 AC_CONFIG_SUBDIRS([external/tap-1.01])
171 dnl This is required so that TAP stuff is compiled before the libs and tests
172 dnl A make install will also install the tap library, but as this is a development tool, this should be okay
173 INCLUDE_TAP_DIR=$TAP_DIR
174 AC_SUBST(INCLUDE_TAP_DIR)
175 EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64" 161 EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
176 AC_SUBST(EXTRA_TEST) 162 AC_SUBST(EXTRA_TEST)
177fi 163 )
178 164
179dnl INI Parsing 165dnl INI Parsing
180AC_ARG_ENABLE(extra-opts, 166AC_ARG_ENABLE(extra-opts,
@@ -184,11 +170,9 @@ AC_ARG_ENABLE(extra-opts,
184 [enable_extra_opts=no]) 170 [enable_extra_opts=no])
185AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"]) 171AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
186if test "$enable_extra_opts" = "yes" ; then 172if test "$enable_extra_opts" = "yes" ; then
173 EXTRA_TEST="$EXTRA_TEST test_ini test_opts"
174 AC_SUBST(EXTRA_TEST)
187 AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.]) 175 AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
188 if test "$enable_libtap" = yes; then
189 EXTRA_TEST="$EXTRA_TEST test_ini test_opts"
190 AC_SUBST(EXTRA_TEST)
191 fi
192fi 176fi
193 177
194dnl Check for PostgreSQL libraries 178dnl Check for PostgreSQL libraries
diff --git a/external/README b/external/README
deleted file mode 100644
index 62a868b..0000000
--- a/external/README
+++ /dev/null
@@ -1,4 +0,0 @@
1Changes to tap-1.01.tar.gz from http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap:
2
3Added vasprintf from gnulib (see http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/32)
4Added -UHAVE_LIBPTHREAD (see http://nagiosplugins.org/faq/libtap)
diff --git a/external/tap-1.01-nagios-plugins.tar.gz b/external/tap-1.01-nagios-plugins.tar.gz
deleted file mode 100644
index 1130ab3..0000000
--- a/external/tap-1.01-nagios-plugins.tar.gz
+++ /dev/null
Binary files differ
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 805acf3..25e2bed 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -5,36 +5,54 @@ noinst_PROGRAMS = @EXTRA_TEST@
5TESTS = @EXTRA_TEST@ 5TESTS = @EXTRA_TEST@
6check_PROGRAMS = @EXTRA_TEST@ 6check_PROGRAMS = @EXTRA_TEST@
7 7
8TAP_LIB_DIR = $(top_srcdir)/@TAP_DIR@/src 8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
9TAP_O = $(TAP_LIB_DIR)/tap.o $(TAP_LIB_DIR)/../lib/libgnu.la
10INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR)
11 9
12EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts 10EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts
13 11
12np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini.t test_opts.t test_tcp.t test_utils.t
14np_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
15EXTRA_DIST = test_all.t $(np_test_files) 14EXTRA_DIST = $(np_test_scripts) $(np_test_files)
16
17AM_CFLAGS = -g -I..
18 15
19LIBS = @LIBINTL@ 16LIBS = @LIBINTL@
20 17
21test_utils_LDADD = ../utils_base.o $(TAP_O) 18test_utils_SOURCES = test_utils.c
22 19test_utils_CFLAGS = -g -I..
23test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a $(TAP_O) 20test_utils_LDFLAGS = -L/usr/local/lib -ltap
24 21test_utils_LDADD = ../utils_base.o
25test_tcp_LDADD = ../utils_tcp.o $(TAP_O) 22
26 23test_disk_SOURCES = test_disk.c
27test_cmd_LDADD = ../utils_cmd.o ../utils_base.o $(TAP_O) 24test_disk_CFLAGS = -g -I..
28 25test_disk_LDFLAGS = -L/usr/local/lib -ltap
29test_base64_LDADD = $(top_srcdir)/gl/base64.o $(TAP_O) 26test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a
30 27
31test_ini_LDADD = ../utils_base.o ../parse_ini.o $(TAP_O) 28test_tcp_SOURCES = test_tcp.c
32 29test_tcp_CFLAGS = -g -I..
33test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o $(TAP_O) 30test_tcp_LDFLAGS = -L/usr/local/lib -ltap
31test_tcp_LDADD = ../utils_tcp.o
32
33test_cmd_SOURCES = test_cmd.c
34test_cmd_CFLAGS = -g -I..
35test_cmd_LDFLAGS = -L/usr/local/lib -ltap
36test_cmd_LDADD = ../utils_cmd.o ../utils_base.o
37
38test_base64_SOURCES = test_base64.c
39test_base64_CFLAGS = -g -I..
40test_base64_LDFLAGS = -L/usr/local/lib -ltap
41test_base64_LDADD = $(top_srcdir)/gl/base64.o
42
43test_ini_SOURCES = test_ini.c
44test_ini_CFLAGS = -g -I..
45test_ini_LDFLAGS = -L/usr/local/lib -ltap
46test_ini_LDADD = ../utils_base.o ../parse_ini.o
47
48test_opts_SOURCES = test_opts.c
49test_opts_CFLAGS = -g -I..
50test_opts_LDFLAGS = -L/usr/local/lib -ltap
51test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o
34 52
35test: ${noinst_PROGRAMS} 53test: ${noinst_PROGRAMS}
36 perl ./test_all.t $(EXTRA_PROGRAMS) 54 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
37 55
38test-debug: ${noinst_PROGRAMS} 56test-debug: ${noinst_PROGRAMS}
39 perl ./test_all.t -v $(EXTRA_PROGRAMS) 57 perl -MTest::Harness -e '$$Test::Harness::verbose=1; $$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
40 58
diff --git a/lib/tests/test_all.t b/lib/tests/test_all.t
deleted file mode 100755
index 1fae81a..0000000
--- a/lib/tests/test_all.t
+++ /dev/null
@@ -1,38 +0,0 @@
1#!/usr/bin/perl
2# Creates $file.t for each @ARGV
3# Then calls runtests for all these files
4
5use strict;
6use Test::Harness;
7use Getopt::Std;
8
9my $opts = {};
10getopts("v", $opts) or die "Getopt failed";
11
12$Test::Harness::verbose = $opts->{v};
13$Test::Harness::switches="";
14
15my $special_errors = {
16 test_ini => "please enable parse-ini to test",
17 test_opts => "please enable parse-ini to test",
18};
19my $default_error = "could not compile";
20
21my @tests;
22foreach my $file (@ARGV) {
23 my $file_t = "$file.t";
24 my $error = $special_errors->{ $file } || $default_error;
25 open F, ">", $file_t or die "Cannot open $file_t for writing";
26 print F <<EOF;
27use Test::More;
28if (! -e "$file") {
29 plan skip_all => "./$file not compiled - $error";
30}
31exec "./$file";
32EOF
33 close F;
34 push @tests, $file_t;
35}
36chmod 0750, @tests;
37runtests @tests;
38unlink @tests;
diff --git a/lib/tests/test_base64.t b/lib/tests/test_base64.t
new file mode 100755
index 0000000..4b9236f
--- /dev/null
+++ b/lib/tests/test_base64.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_base64") {
4 plan skip_all => "./test_base64 not compiled - please install tap library to test";
5}
6exec "./test_base64";
diff --git a/lib/tests/test_cmd.t b/lib/tests/test_cmd.t
new file mode 100644
index 0000000..4dd54ef
--- /dev/null
+++ b/lib/tests/test_cmd.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_cmd") {
4 plan skip_all => "./test_cmd not compiled - please install tap library to test";
5}
6exec "./test_cmd";
diff --git a/lib/tests/test_disk.t b/lib/tests/test_disk.t
new file mode 100755
index 0000000..d32567a
--- /dev/null
+++ b/lib/tests/test_disk.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_disk") {
4 plan skip_all => "./test_disk not compiled - please install tap library to test";
5}
6exec "./test_disk";
diff --git a/lib/tests/test_ini.t b/lib/tests/test_ini.t
new file mode 100755
index 0000000..0487098
--- /dev/null
+++ b/lib/tests/test_ini.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_ini") {
4 plan skip_all => "./test_ini not compiled - please install tap library and/or enable parse-ini to test";
5}
6exec "./test_ini";
diff --git a/lib/tests/test_opts.t b/lib/tests/test_opts.t
new file mode 100755
index 0000000..d69b8f1
--- /dev/null
+++ b/lib/tests/test_opts.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_opts") {
4 plan skip_all => "./test_opts not compiled - please install tap library and/or enable parse-ini to test";
5}
6exec "./test_opts";
diff --git a/lib/tests/test_tcp.t b/lib/tests/test_tcp.t
new file mode 100755
index 0000000..8f34b67
--- /dev/null
+++ b/lib/tests/test_tcp.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_tcp") {
4 plan skip_all => "./test_tcp not compiled - please install tap library to test";
5}
6exec "./test_tcp";
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index 64efca2..5c6cce4 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -29,7 +29,7 @@ main (int argc, char **argv)
29 thresholds *thresholds = NULL; 29 thresholds *thresholds = NULL;
30 int rc; 30 int rc;
31 31
32 plan_tests(81); 32 plan_tests(82);
33 33
34 range = parse_range_string("6"); 34 range = parse_range_string("6");
35 ok( range != NULL, "'6' is valid range"); 35 ok( range != NULL, "'6' is valid range");
@@ -173,5 +173,8 @@ main (int argc, char **argv)
173 ok( strcmp(test, "everything") == 0, "everything okay"); 173 ok( strcmp(test, "everything") == 0, "everything okay");
174 free(test); 174 free(test);
175 175
176 test = basename("/here/is/a/path");
177 ok( strcmp(test, "path") == 0, "basename okay");
178
176 return exit_status(); 179 return exit_status();
177} 180}
diff --git a/lib/tests/test_utils.t b/lib/tests/test_utils.t
new file mode 100755
index 0000000..152eb71
--- /dev/null
+++ b/lib/tests/test_utils.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_utils") {
4 plan skip_all => "./test_utils not compiled - please install tap library to test";
5}
6exec "./test_utils";
diff --git a/tools/setup b/tools/setup
index cdaa9c9..1afe4f1 100755
--- a/tools/setup
+++ b/tools/setup
@@ -48,6 +48,3 @@ fi
48if [ $docbook = 1 ] ; then 48if [ $docbook = 1 ] ; then
49 ( cd doc && make ) 49 ( cd doc && make )
50fi 50fi
51
52# Untar libtap
53( cd external && gunzip -c tap-1.01-nagios-plugins.tar.gz | tar -xf - )