summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/tests/Makefile.am57
-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
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@
6check_PROGRAMS = @EXTRA_TEST@ 6check_PROGRAMS = @EXTRA_TEST@
7 7
8TAP_LIB_DIR = $(top_srcdir)/@TAP_DIR@/src 8TAP_LIB_DIR = $(top_srcdir)/@TAP_DIR@/src
9TAP_O = $(TAP_LIB_DIR)/tap.o
9INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR) 10INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR)
10 11
11EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts 12EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts
12 13
13np_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 14np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini
15EXTRA_DIST = $(np_test_scripts) $(np_test_files) 15EXTRA_DIST = test_all.t $(np_test_files)
16
17AM_CFLAGS = -g -I..
16 18
17LIBS = @LIBINTL@ 19LIBS = @LIBINTL@
18 20
19test_utils_SOURCES = test_utils.c 21test_utils_LDADD = ../utils_base.o $(TAP_O)
20test_utils_CFLAGS = -g -I.. 22
21test_utils_LDFLAGS = -L$(TAP_LIB_DIR) -ltap 23test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a $(TAP_O)
22test_utils_LDADD = ../utils_base.o 24
23 25test_tcp_LDADD = ../utils_tcp.o $(TAP_O)
24test_disk_SOURCES = test_disk.c 26
25test_disk_CFLAGS = -g -I.. 27test_cmd_LDADD = ../utils_cmd.o ../utils_base.o $(TAP_O)
26test_disk_LDFLAGS = -L$(TAP_LIB_DIR) -ltap 28
27test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a 29test_base64_LDADD = $(top_srcdir)/gl/base64.o $(TAP_O)
28 30
29test_tcp_SOURCES = test_tcp.c 31test_ini_LDADD = ../utils_base.o ../parse_ini.o $(TAP_O)
30test_tcp_CFLAGS = -g -I.. 32
31test_tcp_LDFLAGS = -L$(TAP_LIB_DIR) -ltap 33test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o $(TAP_O)
32test_tcp_LDADD = ../utils_tcp.o
33
34test_cmd_SOURCES = test_cmd.c
35test_cmd_CFLAGS = -g -I..
36test_cmd_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
37test_cmd_LDADD = ../utils_cmd.o ../utils_base.o
38
39test_base64_SOURCES = test_base64.c
40test_base64_CFLAGS = -g -I..
41test_base64_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
42test_base64_LDADD = $(top_srcdir)/gl/base64.o
43
44test_ini_SOURCES = test_ini.c
45test_ini_CFLAGS = -g -I..
46test_ini_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
47test_ini_LDADD = ../utils_base.o ../parse_ini.o
48
49test_opts_SOURCES = test_opts.c
50test_opts_CFLAGS = -g -I..
51test_opts_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
52test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o
53 34
54test: ${noinst_PROGRAMS} 35test: ${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
57test-debug: ${noinst_PROGRAMS} 38test-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
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
deleted file mode 100755
index 4b9236f..0000000
--- a/lib/tests/test_base64.t
+++ /dev/null
@@ -1,6 +0,0 @@
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
deleted file mode 100644
index 4dd54ef..0000000
--- a/lib/tests/test_cmd.t
+++ /dev/null
@@ -1,6 +0,0 @@
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
deleted file mode 100755
index d32567a..0000000
--- a/lib/tests/test_disk.t
+++ /dev/null
@@ -1,6 +0,0 @@
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
deleted file mode 100755
index 0487098..0000000
--- a/lib/tests/test_ini.t
+++ /dev/null
@@ -1,6 +0,0 @@
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
deleted file mode 100755
index d69b8f1..0000000
--- a/lib/tests/test_opts.t
+++ /dev/null
@@ -1,6 +0,0 @@
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
deleted file mode 100755
index 8f34b67..0000000
--- a/lib/tests/test_tcp.t
+++ /dev/null
@@ -1,6 +0,0 @@
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 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
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";