diff options
Diffstat (limited to 'lib')
-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 |
10 files changed, 85 insertions, 60 deletions
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index 805acf33..25e2bed3 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 1fae81a8..00000000 --- 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 00000000..4b9236f0 --- /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 00000000..4dd54ef9 --- /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 00000000..d32567a9 --- /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 00000000..0487098c --- /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 00000000..d69b8f1d --- /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 00000000..8f34b67b --- /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 64efca23..5c6cce41 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 00000000..152eb718 --- /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"; | ||