diff options
-rw-r--r-- | Makefile.am | 9 | ||||
-rw-r--r-- | configure.in | 26 | ||||
-rw-r--r-- | external/README | 4 | ||||
-rw-r--r-- | external/tap-1.01-nagios-plugins.tar.gz | bin | 431388 -> 0 bytes | |||
-rw-r--r-- | lib/tests/Makefile.am | 60 | ||||
-rwxr-xr-x | lib/tests/test_all.t | 38 | ||||
-rwxr-xr-x | lib/tests/test_base64.t | 6 | ||||
-rw-r--r-- | lib/tests/test_cmd.t | 6 | ||||
-rwxr-xr-x | lib/tests/test_disk.t | 6 | ||||
-rwxr-xr-x | lib/tests/test_ini.t | 6 | ||||
-rwxr-xr-x | lib/tests/test_opts.t | 6 | ||||
-rwxr-xr-x | lib/tests/test_tcp.t | 6 | ||||
-rw-r--r-- | lib/tests/test_utils.c | 5 | ||||
-rwxr-xr-x | lib/tests/test_utils.t | 6 | ||||
-rwxr-xr-x | tools/setup | 3 |
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 | ||
3 | SUBDIRS = gl @INCLUDE_TAP_DIR@ lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ | 3 | SUBDIRS = gl lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ |
4 | 4 | ||
5 | # Have to list TAP_DIR manually to get in distribution | ||
6 | EXTRA_DIST = config.rpath \ | 5 | EXTRA_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 | ||
15 | ACLOCAL_AMFLAGS = -I gl/m4 -I m4 | 13 | ACLOCAL_AMFLAGS = -I gl/m4 -I m4 |
16 | 14 | ||
@@ -24,9 +22,6 @@ dist-hook: | |||
24 | install-root: | 22 | install-root: |
25 | cd plugins-root && $(MAKE) $@ | 23 | cd plugins-root && $(MAKE) $@ |
26 | 24 | ||
27 | tap: | ||
28 | cd @TAP_DIR@ && $(MAKE) | ||
29 | |||
30 | test test-debug: | 25 | test 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) | |||
156 | AC_CHECK_LIB(m,floor,MATHLIBS="-lm") | 156 | AC_CHECK_LIB(m,floor,MATHLIBS="-lm") |
157 | AC_SUBST(MATHLIBS) | 157 | AC_SUBST(MATHLIBS) |
158 | 158 | ||
159 | dnl Add libtap for tests | 159 | dnl Check for libtap, to run perl-like tests |
160 | AC_ARG_ENABLE(libtap, | 160 | AC_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]) | ||
165 | dnl Have to define TAP_DIR so that Makefile can pull it as an extra dist | ||
166 | TAP_DIR=external/tap-1.01 | ||
167 | AC_SUBST(TAP_DIR) | ||
168 | if 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) |
177 | fi | 163 | ) |
178 | 164 | ||
179 | dnl INI Parsing | 165 | dnl INI Parsing |
180 | AC_ARG_ENABLE(extra-opts, | 166 | AC_ARG_ENABLE(extra-opts, |
@@ -184,11 +170,9 @@ AC_ARG_ENABLE(extra-opts, | |||
184 | [enable_extra_opts=no]) | 170 | [enable_extra_opts=no]) |
185 | AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"]) | 171 | AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"]) |
186 | if test "$enable_extra_opts" = "yes" ; then | 172 | if 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 | ||
192 | fi | 176 | fi |
193 | 177 | ||
194 | dnl Check for PostgreSQL libraries | 178 | dnl 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 @@ | |||
1 | Changes to tap-1.01.tar.gz from http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap: | ||
2 | |||
3 | Added vasprintf from gnulib (see http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/32) | ||
4 | Added -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@ | |||
5 | TESTS = @EXTRA_TEST@ | 5 | TESTS = @EXTRA_TEST@ |
6 | check_PROGRAMS = @EXTRA_TEST@ | 6 | check_PROGRAMS = @EXTRA_TEST@ |
7 | 7 | ||
8 | TAP_LIB_DIR = $(top_srcdir)/@TAP_DIR@/src | 8 | INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins |
9 | TAP_O = $(TAP_LIB_DIR)/tap.o $(TAP_LIB_DIR)/../lib/libgnu.la | ||
10 | INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR) | ||
11 | 9 | ||
12 | EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts | 10 | EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts |
13 | 11 | ||
12 | np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini.t test_opts.t test_tcp.t test_utils.t | ||
14 | np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini | 13 | np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini |
15 | EXTRA_DIST = test_all.t $(np_test_files) | 14 | EXTRA_DIST = $(np_test_scripts) $(np_test_files) |
16 | |||
17 | AM_CFLAGS = -g -I.. | ||
18 | 15 | ||
19 | LIBS = @LIBINTL@ | 16 | LIBS = @LIBINTL@ |
20 | 17 | ||
21 | test_utils_LDADD = ../utils_base.o $(TAP_O) | 18 | test_utils_SOURCES = test_utils.c |
22 | 19 | test_utils_CFLAGS = -g -I.. | |
23 | test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a $(TAP_O) | 20 | test_utils_LDFLAGS = -L/usr/local/lib -ltap |
24 | 21 | test_utils_LDADD = ../utils_base.o | |
25 | test_tcp_LDADD = ../utils_tcp.o $(TAP_O) | 22 | |
26 | 23 | test_disk_SOURCES = test_disk.c | |
27 | test_cmd_LDADD = ../utils_cmd.o ../utils_base.o $(TAP_O) | 24 | test_disk_CFLAGS = -g -I.. |
28 | 25 | test_disk_LDFLAGS = -L/usr/local/lib -ltap | |
29 | test_base64_LDADD = $(top_srcdir)/gl/base64.o $(TAP_O) | 26 | test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a |
30 | 27 | ||
31 | test_ini_LDADD = ../utils_base.o ../parse_ini.o $(TAP_O) | 28 | test_tcp_SOURCES = test_tcp.c |
32 | 29 | test_tcp_CFLAGS = -g -I.. | |
33 | test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o $(TAP_O) | 30 | test_tcp_LDFLAGS = -L/usr/local/lib -ltap |
31 | test_tcp_LDADD = ../utils_tcp.o | ||
32 | |||
33 | test_cmd_SOURCES = test_cmd.c | ||
34 | test_cmd_CFLAGS = -g -I.. | ||
35 | test_cmd_LDFLAGS = -L/usr/local/lib -ltap | ||
36 | test_cmd_LDADD = ../utils_cmd.o ../utils_base.o | ||
37 | |||
38 | test_base64_SOURCES = test_base64.c | ||
39 | test_base64_CFLAGS = -g -I.. | ||
40 | test_base64_LDFLAGS = -L/usr/local/lib -ltap | ||
41 | test_base64_LDADD = $(top_srcdir)/gl/base64.o | ||
42 | |||
43 | test_ini_SOURCES = test_ini.c | ||
44 | test_ini_CFLAGS = -g -I.. | ||
45 | test_ini_LDFLAGS = -L/usr/local/lib -ltap | ||
46 | test_ini_LDADD = ../utils_base.o ../parse_ini.o | ||
47 | |||
48 | test_opts_SOURCES = test_opts.c | ||
49 | test_opts_CFLAGS = -g -I.. | ||
50 | test_opts_LDFLAGS = -L/usr/local/lib -ltap | ||
51 | test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o | ||
34 | 52 | ||
35 | test: ${noinst_PROGRAMS} | 53 | test: ${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 | ||
38 | test-debug: ${noinst_PROGRAMS} | 56 | test-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 | |||
5 | use strict; | ||
6 | use Test::Harness; | ||
7 | use Getopt::Std; | ||
8 | |||
9 | my $opts = {}; | ||
10 | getopts("v", $opts) or die "Getopt failed"; | ||
11 | |||
12 | $Test::Harness::verbose = $opts->{v}; | ||
13 | $Test::Harness::switches=""; | ||
14 | |||
15 | my $special_errors = { | ||
16 | test_ini => "please enable parse-ini to test", | ||
17 | test_opts => "please enable parse-ini to test", | ||
18 | }; | ||
19 | my $default_error = "could not compile"; | ||
20 | |||
21 | my @tests; | ||
22 | foreach 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; | ||
27 | use Test::More; | ||
28 | if (! -e "$file") { | ||
29 | plan skip_all => "./$file not compiled - $error"; | ||
30 | } | ||
31 | exec "./$file"; | ||
32 | EOF | ||
33 | close F; | ||
34 | push @tests, $file_t; | ||
35 | } | ||
36 | chmod 0750, @tests; | ||
37 | runtests @tests; | ||
38 | unlink @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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_base64") { | ||
4 | plan skip_all => "./test_base64 not compiled - please install tap library to test"; | ||
5 | } | ||
6 | exec "./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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_cmd") { | ||
4 | plan skip_all => "./test_cmd not compiled - please install tap library to test"; | ||
5 | } | ||
6 | exec "./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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_disk") { | ||
4 | plan skip_all => "./test_disk not compiled - please install tap library to test"; | ||
5 | } | ||
6 | exec "./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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_ini") { | ||
4 | plan skip_all => "./test_ini not compiled - please install tap library and/or enable parse-ini to test"; | ||
5 | } | ||
6 | exec "./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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_opts") { | ||
4 | plan skip_all => "./test_opts not compiled - please install tap library and/or enable parse-ini to test"; | ||
5 | } | ||
6 | exec "./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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_tcp") { | ||
4 | plan skip_all => "./test_tcp not compiled - please install tap library to test"; | ||
5 | } | ||
6 | exec "./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 | ||
2 | use Test::More; | ||
3 | if (! -e "./test_utils") { | ||
4 | plan skip_all => "./test_utils not compiled - please install tap library to test"; | ||
5 | } | ||
6 | exec "./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 | |||
48 | if [ $docbook = 1 ] ; then | 48 | if [ $docbook = 1 ] ; then |
49 | ( cd doc && make ) | 49 | ( cd doc && make ) |
50 | fi | 50 | fi |
51 | |||
52 | # Untar libtap | ||
53 | ( cd external && gunzip -c tap-1.01-nagios-plugins.tar.gz | tar -xf - ) | ||