[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2042] nagiosplug/trunk/lib/tests

tonvoon at users.sourceforge.net tonvoon at users.sourceforge.net
Thu Aug 21 17:18:59 CEST 2008


Revision: 2042
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2042&view=rev
Author:   tonvoon
Date:     2008-08-21 15:18:58 +0000 (Thu, 21 Aug 2008)

Log Message:
-----------
Correctly link to included libtap. Simplify invoking test scripts.
Removed basename test as we should use base_name from GNUlib which is
tested separately

Modified Paths:
--------------
    nagiosplug/trunk/lib/tests/Makefile.am
    nagiosplug/trunk/lib/tests/test_utils.c

Added Paths:
-----------
    nagiosplug/trunk/lib/tests/test_all.t

Removed Paths:
-------------
    nagiosplug/trunk/lib/tests/test_base64.t
    nagiosplug/trunk/lib/tests/test_cmd.t
    nagiosplug/trunk/lib/tests/test_disk.t
    nagiosplug/trunk/lib/tests/test_ini.t
    nagiosplug/trunk/lib/tests/test_opts.t
    nagiosplug/trunk/lib/tests/test_tcp.t
    nagiosplug/trunk/lib/tests/test_utils.t

Modified: nagiosplug/trunk/lib/tests/Makefile.am
===================================================================
--- nagiosplug/trunk/lib/tests/Makefile.am	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/Makefile.am	2008-08-21 15:18:58 UTC (rev 2042)
@@ -6,54 +6,35 @@
 check_PROGRAMS = @EXTRA_TEST@
 
 TAP_LIB_DIR = $(top_srcdir)/@TAP_DIR@/src
+TAP_O = $(TAP_LIB_DIR)/tap.o
 INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins -I$(TAP_LIB_DIR)
 
 EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini test_opts
 
-np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini.t test_opts.t test_tcp.t test_utils.t
 np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini
-EXTRA_DIST = $(np_test_scripts) $(np_test_files)
+EXTRA_DIST = test_all.t $(np_test_files)
 
+AM_CFLAGS = -g -I..
+
 LIBS = @LIBINTL@
 
-test_utils_SOURCES = test_utils.c
-test_utils_CFLAGS = -g -I..
-test_utils_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_utils_LDADD = ../utils_base.o
+test_utils_LDADD = ../utils_base.o $(TAP_O)
 
-test_disk_SOURCES = test_disk.c
-test_disk_CFLAGS = -g -I..
-test_disk_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a
+test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a $(TAP_O)
 
-test_tcp_SOURCES = test_tcp.c
-test_tcp_CFLAGS = -g -I..
-test_tcp_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_tcp_LDADD = ../utils_tcp.o 
+test_tcp_LDADD = ../utils_tcp.o $(TAP_O)
 
-test_cmd_SOURCES = test_cmd.c
-test_cmd_CFLAGS = -g -I..
-test_cmd_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_cmd_LDADD = ../utils_cmd.o ../utils_base.o
+test_cmd_LDADD = ../utils_cmd.o ../utils_base.o $(TAP_O)
 
-test_base64_SOURCES = test_base64.c
-test_base64_CFLAGS = -g -I..
-test_base64_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_base64_LDADD = $(top_srcdir)/gl/base64.o 
+test_base64_LDADD = $(top_srcdir)/gl/base64.o $(TAP_O)
 
-test_ini_SOURCES = test_ini.c
-test_ini_CFLAGS = -g -I..
-test_ini_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_ini_LDADD = ../utils_base.o ../parse_ini.o
+test_ini_LDADD = ../utils_base.o ../parse_ini.o $(TAP_O)
 
-test_opts_SOURCES = test_opts.c
-test_opts_CFLAGS = -g -I..
-test_opts_LDFLAGS = -L$(TAP_LIB_DIR) -ltap
-test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o
+test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o $(TAP_O)
 
 test: ${noinst_PROGRAMS}
-	perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
+	perl ./test_all.t $(EXTRA_PROGRAMS)
 
 test-debug: ${noinst_PROGRAMS}
-	perl -MTest::Harness -e '$$Test::Harness::verbose=1; $$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
+	perl ./test_all.t -v $(EXTRA_PROGRAMS)
 

Added: nagiosplug/trunk/lib/tests/test_all.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_all.t	                        (rev 0)
+++ nagiosplug/trunk/lib/tests/test_all.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+# Creates $file.t for each @ARGV
+# Then calls runtests for all these files
+
+use strict;
+use Test::Harness;
+use Getopt::Std;
+
+my $opts = {};
+getopts("v", $opts) or die "Getopt failed";
+
+$Test::Harness::verbose = $opts->{v};
+$Test::Harness::switches="";
+
+my $special_errors = {
+	test_ini  => "please enable parse-ini to test",
+	test_opts => "please enable parse-ini to test",
+};
+my $default_error = "could not compile";
+
+my @tests;
+foreach my $file (@ARGV) {
+	my $file_t = "$file.t";
+	my $error = $special_errors->{ $file } || $default_error;
+	open F, ">", $file_t or die "Cannot open $file_t for writing";
+	print F <<EOF;
+use Test::More;
+if (! -e "$file") {
+	plan skip_all => "./$file not compiled - $error";
+}
+exec "./$file";
+EOF
+	close F;
+	push @tests, $file_t;
+}
+chmod 0750, @tests;
+runtests @tests;
+unlink @tests;


Property changes on: nagiosplug/trunk/lib/tests/test_all.t
___________________________________________________________________
Added: svn:executable
   + *

Deleted: nagiosplug/trunk/lib/tests/test_base64.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_base64.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_base64.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_base64") {
-	plan skip_all => "./test_base64 not compiled - please install tap library to test";
-}
-exec "./test_base64";

Deleted: nagiosplug/trunk/lib/tests/test_cmd.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_cmd.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_cmd.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_cmd") {
-	plan skip_all => "./test_cmd not compiled - please install tap library to test";
-}
-exec "./test_cmd";

Deleted: nagiosplug/trunk/lib/tests/test_disk.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_disk.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_disk.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_disk") {
-	plan skip_all => "./test_disk not compiled - please install tap library to test";
-}
-exec "./test_disk";

Deleted: nagiosplug/trunk/lib/tests/test_ini.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_ini.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_ini.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_ini") {
-	plan skip_all => "./test_ini not compiled - please install tap library and/or enable parse-ini to test";
-}
-exec "./test_ini";

Deleted: nagiosplug/trunk/lib/tests/test_opts.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_opts.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_opts.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_opts") {
-	plan skip_all => "./test_opts not compiled - please install tap library and/or enable parse-ini to test";
-}
-exec "./test_opts";

Deleted: nagiosplug/trunk/lib/tests/test_tcp.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_tcp.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_tcp.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_tcp") {
-	plan skip_all => "./test_tcp not compiled - please install tap library to test";
-}
-exec "./test_tcp";

Modified: nagiosplug/trunk/lib/tests/test_utils.c
===================================================================
--- nagiosplug/trunk/lib/tests/test_utils.c	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_utils.c	2008-08-21 15:18:58 UTC (rev 2042)
@@ -30,7 +30,7 @@
 	thresholds *thresholds = NULL;
 	int	rc;
 
-	plan_tests(82);
+	plan_tests(81);
 
 	range = parse_range_string("6");
 	ok( range != NULL, "'6' is valid range");
@@ -174,8 +174,5 @@
 	ok( strcmp(test, "everything") == 0, "everything okay");
 	free(test);
 
-	test = basename("/here/is/a/path");
-	ok( strcmp(test, "path") == 0, "basename okay");
-
 	return exit_status();
 }

Deleted: nagiosplug/trunk/lib/tests/test_utils.t
===================================================================
--- nagiosplug/trunk/lib/tests/test_utils.t	2008-08-21 15:15:54 UTC (rev 2041)
+++ nagiosplug/trunk/lib/tests/test_utils.t	2008-08-21 15:18:58 UTC (rev 2042)
@@ -1,6 +0,0 @@
-#!/usr/bin/perl
-use Test::More;
-if (! -e "./test_utils") {
-	plan skip_all => "./test_utils not compiled - please install tap library to test";
-}
-exec "./test_utils";


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list