diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-08-21 15:18:58 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-08-21 15:18:58 (GMT) |
commit | f31cd40f7a014c076615c4a1c28b989162a6ca9d (patch) | |
tree | 4b5c4f0aa4080fd99271a60a904990500b6ad933 /lib/tests | |
parent | 6a8240dd78716967e1eccb32ccfd966f321258b6 (diff) | |
download | monitoring-plugins-f31cd40f7a014c076615c4a1c28b989162a6ca9d.tar.gz |
Correctly link to included libtap. Simplify invoking test scripts.
Removed basename test as we should use base_name from GNUlib which is
tested separately
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2042 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/Makefile.am | 57 | ||||
-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 |
10 files changed, 58 insertions, 84 deletions
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index 9eeef93..ba0973c 100644 --- a/lib/tests/Makefile.am +++ b/lib/tests/Makefile.am | |||
@@ -6,54 +6,35 @@ 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 | TAP_LIB_DIR = $(top_srcdir)/@TAP_DIR@/src |
9 | TAP_O = $(TAP_LIB_DIR)/tap.o | ||
9 | INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR) | 10 | INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR) |
10 | 11 | ||
11 | EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts | 12 | EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts |
12 | 13 | ||
13 | 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 | 14 | np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini |
15 | EXTRA_DIST = $(np_test_scripts) $(np_test_files) | 15 | EXTRA_DIST = test_all.t $(np_test_files) |
16 | |||
17 | AM_CFLAGS = -g -I.. | ||
16 | 18 | ||
17 | LIBS = @LIBINTL@ | 19 | LIBS = @LIBINTL@ |
18 | 20 | ||
19 | test_utils_SOURCES = test_utils.c | 21 | test_utils_LDADD = ../utils_base.o $(TAP_O) |
20 | test_utils_CFLAGS = -g -I.. | 22 | |
21 | test_utils_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | 23 | test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a $(TAP_O) |
22 | test_utils_LDADD = ../utils_base.o | 24 | |
23 | 25 | test_tcp_LDADD = ../utils_tcp.o $(TAP_O) | |
24 | test_disk_SOURCES = test_disk.c | 26 | |
25 | test_disk_CFLAGS = -g -I.. | 27 | test_cmd_LDADD = ../utils_cmd.o ../utils_base.o $(TAP_O) |
26 | test_disk_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | 28 | |
27 | test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a | 29 | test_base64_LDADD = $(top_srcdir)/gl/base64.o $(TAP_O) |
28 | 30 | ||
29 | test_tcp_SOURCES = test_tcp.c | 31 | test_ini_LDADD = ../utils_base.o ../parse_ini.o $(TAP_O) |
30 | test_tcp_CFLAGS = -g -I.. | 32 | |
31 | test_tcp_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | 33 | test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o $(TAP_O) |
32 | test_tcp_LDADD = ../utils_tcp.o | ||
33 | |||
34 | test_cmd_SOURCES = test_cmd.c | ||
35 | test_cmd_CFLAGS = -g -I.. | ||
36 | test_cmd_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | ||
37 | test_cmd_LDADD = ../utils_cmd.o ../utils_base.o | ||
38 | |||
39 | test_base64_SOURCES = test_base64.c | ||
40 | test_base64_CFLAGS = -g -I.. | ||
41 | test_base64_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | ||
42 | test_base64_LDADD = $(top_srcdir)/gl/base64.o | ||
43 | |||
44 | test_ini_SOURCES = test_ini.c | ||
45 | test_ini_CFLAGS = -g -I.. | ||
46 | test_ini_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | ||
47 | test_ini_LDADD = ../utils_base.o ../parse_ini.o | ||
48 | |||
49 | test_opts_SOURCES = test_opts.c | ||
50 | test_opts_CFLAGS = -g -I.. | ||
51 | test_opts_LDFLAGS = -L$(TAP_LIB_DIR) -ltap | ||
52 | test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o | ||
53 | 34 | ||
54 | test: ${noinst_PROGRAMS} | 35 | test: ${noinst_PROGRAMS} |
55 | perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) | 36 | perl ./test_all.t $(EXTRA_PROGRAMS) |
56 | 37 | ||
57 | test-debug: ${noinst_PROGRAMS} | 38 | test-debug: ${noinst_PROGRAMS} |
58 | perl -MTest::Harness -e '$$Test::Harness::verbose=1; $$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) | 39 | perl ./test_all.t -v $(EXTRA_PROGRAMS) |
59 | 40 | ||
diff --git a/lib/tests/test_all.t b/lib/tests/test_all.t new file mode 100755 index 0000000..1fae81a --- /dev/null +++ b/lib/tests/test_all.t | |||
@@ -0,0 +1,38 @@ | |||
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 deleted file mode 100755 index 4b9236f..0000000 --- a/lib/tests/test_base64.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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 deleted file mode 100644 index 4dd54ef..0000000 --- a/lib/tests/test_cmd.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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 deleted file mode 100755 index d32567a..0000000 --- a/lib/tests/test_disk.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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 deleted file mode 100755 index 0487098..0000000 --- a/lib/tests/test_ini.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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 deleted file mode 100755 index d69b8f1..0000000 --- a/lib/tests/test_opts.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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 deleted file mode 100755 index 8f34b67..0000000 --- a/lib/tests/test_tcp.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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 278f526..b2a9e69 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c | |||
@@ -30,7 +30,7 @@ main (int argc, char **argv) | |||
30 | thresholds *thresholds = NULL; | 30 | thresholds *thresholds = NULL; |
31 | int rc; | 31 | int rc; |
32 | 32 | ||
33 | plan_tests(82); | 33 | plan_tests(81); |
34 | 34 | ||
35 | range = parse_range_string("6"); | 35 | range = parse_range_string("6"); |
36 | ok( range != NULL, "'6' is valid range"); | 36 | ok( range != NULL, "'6' is valid range"); |
@@ -174,8 +174,5 @@ main (int argc, char **argv) | |||
174 | ok( strcmp(test, "everything") == 0, "everything okay"); | 174 | ok( strcmp(test, "everything") == 0, "everything okay"); |
175 | free(test); | 175 | free(test); |
176 | 176 | ||
177 | test = basename("/here/is/a/path"); | ||
178 | ok( strcmp(test, "path") == 0, "basename okay"); | ||
179 | |||
180 | return exit_status(); | 177 | return exit_status(); |
181 | } | 178 | } |
diff --git a/lib/tests/test_utils.t b/lib/tests/test_utils.t deleted file mode 100755 index 152eb71..0000000 --- a/lib/tests/test_utils.t +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
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"; | ||