From b64fa2eb84b63286ca3c72b985d631873c3ef21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Wed, 24 Sep 2014 16:40:03 +0200 Subject: [PATCH] Switched to parallel test harness --- .gitignore | 3 +- ChangeLog | 5 + configure.ac | 2 +- tests/ChangeLog | 8 ++ tests/FTPTest.pm | 2 +- tests/HTTPTest.pm | 2 +- tests/Makefile.am | 32 ++--- tests/Test-proxied-https-auth.px | 18 ++- tests/WgetFeature.pm | 2 +- tests/{WgetTest.pm.in => WgetTests.pm} | 12 +- tests/run-px | 174 ------------------------- 11 files changed, 52 insertions(+), 208 deletions(-) rename tests/{WgetTest.pm.in => WgetTests.pm} (97%) delete mode 100755 tests/run-px diff --git a/.gitignore b/.gitignore index 2b3c5967..b4e2b946 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ po/*.gmo* po/*.po* src/*.o +tests/*.log +tests/*.trs testenv/*.log testenv/*.trs # build-aux/ @@ -81,7 +83,6 @@ testenv/Makefile.in # tests/ tests/Makefile tests/Makefile.in -tests/WgetTest.pm tests/unit-tests # util/ util/Makefile diff --git a/ChangeLog b/ChangeLog index c4e7809b..d1b755a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-25 Tim Ruehsen + + * configure.ac: removed WgetTest.pm.in + * .gitignore: removed WgetTest.pm + 2014-09-12 Darshit Shah * bootstrap.conf: Add GNULib module mbiter diff --git a/configure.ac b/configure.ac index 273fc642..3cbe6188 100644 --- a/configure.ac +++ b/configure.ac @@ -578,7 +578,7 @@ dnl dnl Create output dnl AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile util/Makefile - po/Makefile.in tests/Makefile tests/WgetTest.pm + po/Makefile.in tests/Makefile lib/Makefile testenv/Makefile]) AC_CONFIG_HEADERS([src/config.h]) AC_OUTPUT diff --git a/tests/ChangeLog b/tests/ChangeLog index d957b57c..f71ef879 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2014-09-25 Tim Ruehsen + + * Makefile.am: Modified to use parallel test harness + * Test-proxied-https-auth.px: get $top_srcdir from ENV + * run-px: removed + * WgetTest.pm.in: removed + * WgetTest.pm: get $top_srcdir from ENV + 2014-06-11 Giuseppe Scrivano * Makefile.am: Remove @VAR@ with $FOO. diff --git a/tests/FTPTest.pm b/tests/FTPTest.pm index f1412faa..98fc061f 100644 --- a/tests/FTPTest.pm +++ b/tests/FTPTest.pm @@ -4,7 +4,7 @@ use strict; use warnings; use FTPServer; -use WgetTest; +use WgetTests; our @ISA = qw(WgetTest); my $VERSION = 0.01; diff --git a/tests/HTTPTest.pm b/tests/HTTPTest.pm index 04213b23..e0e436f5 100644 --- a/tests/HTTPTest.pm +++ b/tests/HTTPTest.pm @@ -4,7 +4,7 @@ use strict; use warnings; use HTTPServer; -use WgetTest; +use WgetTests; our @ISA = qw(WgetTest); my $VERSION = 0.01; diff --git a/tests/Makefile.am b/tests/Makefile.am index 4bd3ebf6..76f6f441 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,20 +27,12 @@ # shall include the source code for the parts of OpenSSL used as well # as that of the covered work. +# see http://www.gnu.org/software/automake/manual/html_node/Parallel-Test-Harness.html#Parallel-Test-Harness + # # Version: $(VERSION) # -PERL = perl -PERLRUN = $(PERL) -I$(srcdir) - -LIBS += $(LIBICONV) $(LIBINTL) $(LIB_CLOCK_GETTIME) - -.PHONY: test run-unit-tests run-px-tests - -check-local: test - -test: ../src/wget$(EXEEXT) run-unit-tests run-px-tests ../src/wget$(EXEEXT): cd ../src && $(MAKE) $(AM_MAKEFLAGS) @@ -53,14 +45,7 @@ test: ../src/wget$(EXEEXT) run-unit-tests run-px-tests ../lib/libgnu.a: cd ../lib && $(MAKE) $(AM_MAKEFLAGS) -run-unit-tests: unit-tests$(EXEEXT) ../src/libunittest.a - ./unit-tests$(EXEEXT) - -run-px-tests: WgetTest.pm ../src/wget$(EXEEXT) - $(srcdir)/run-px $(top_srcdir) - -EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ - WgetFeature.pm WgetFeature.cfg \ +PX_TESTS = \ Test-auth-basic.px \ Test-auth-no-challenge.px \ Test-auth-no-challenge-url.px \ @@ -142,7 +127,10 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ Test--start-pos.px \ Test--start-pos--continue.px \ Test--httpsonly-r.px \ - Test-204.px \ + Test-204.px + +EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ + WgetTests.pm WgetFeature.pm WgetFeature.cfg $(PX_TESTS) \ run-px certs check_PROGRAMS = unit-tests @@ -150,3 +138,9 @@ unit_tests_SOURCES = LDADD = ../src/libunittest.a ../lib/libgnu.a $(LIBS) CLEANFILES = *~ *.bak core core.[0-9]* + +TESTS = ./unit-tests$(EXEEXT) $(PX_TESTS) +TEST_EXTENSIONS = .px +AM_TESTS_ENVIRONMENT = export WGETRC=/dev/null; export SYSTEM_WGETRC=/dev/null; +PX_LOG_COMPILER = $(PERL) +AM_PX_LOG_FLAGS = -I$(srcdir) diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px index 1de53578..28f147a4 100755 --- a/tests/Test-proxied-https-auth.px +++ b/tests/Test-proxied-https-auth.px @@ -4,16 +4,26 @@ use strict; use warnings; use WgetFeature qw(https); -use WgetTest; # For $WGETPATH. +use WgetTests; # For $WGETPATH. my $cert_path; my $key_path; +my $srcdir; if (@ARGV) { - my $top_srcdir = shift @ARGV; - $key_path = "$top_srcdir/tests/certs/server-key.pem"; - $cert_path = "$top_srcdir/tests/certs/server-cert.pem"; + $srcdir = shift @ARGV; +} elsif (defined $ENV{srcdir}) { + $srcdir = $ENV{srcdir}; } +print "srcdir=",$ENV{srcdir},"\n"; +if (defined $srcdir) { + $key_path = "$srcdir/certs/server-key.pem"; + $cert_path = "$srcdir/certs/server-cert.pem"; +} else { + $key_path = "certs/server-key.pem"; + $cert_path = "certs/server-cert.pem"; +} + use HTTP::Daemon; use HTTP::Request; diff --git a/tests/WgetFeature.pm b/tests/WgetFeature.pm index f58b9983..07623147 100644 --- a/tests/WgetFeature.pm +++ b/tests/WgetFeature.pm @@ -3,7 +3,7 @@ package WgetFeature; use strict; use warnings; -use WgetTest; +use WgetTests; our %skip_messages; require 'WgetFeature.cfg'; diff --git a/tests/WgetTest.pm.in b/tests/WgetTests.pm similarity index 97% rename from tests/WgetTest.pm.in rename to tests/WgetTests.pm index 4151445a..02413ecc 100644 --- a/tests/WgetTest.pm.in +++ b/tests/WgetTests.pm @@ -1,7 +1,3 @@ -# WARNING! -# WgetTest.pm is a generated file! Do not edit! Edit WgetTest.pm.in -# instead. - package WgetTest; $VERSION = 0.01; @@ -10,8 +6,10 @@ use warnings; use Cwd; use File::Path; +use POSIX qw(locale_h); +use locale; -our $WGETPATH = "@abs_top_builddir@/src/wget"; +our $WGETPATH = "../src/wget"; my @unexpected_downloads = (); @@ -94,7 +92,7 @@ sub run { $errcode = ($cmdline =~ m{^/.*}) ? system ($cmdline) - : system ("$self->{_workdir}/../src/$cmdline"); + : system ("$self->{_workdir}/$cmdline"); $errcode >>= 8; # XXX: should handle abnormal error codes. # Shutdown server @@ -307,6 +305,8 @@ sub _fork_and_launch_server } elsif ($pid == 0) { # child close FROM_CHILD; + # FTP Server has to start with english locale due to use of strftime month names in LIST command + setlocale(LC_ALL,"C"); $self->_launch_server(sub { print TO_PARENT "SYNC\n"; close TO_PARENT }); } else { # father diff --git a/tests/run-px b/tests/run-px deleted file mode 100755 index 49dcb740..00000000 --- a/tests/run-px +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env perl - -use 5.006; -use strict; -use warnings; - -use Term::ANSIColor; - -die "Please specify the top source directory.\n" if (!@ARGV); -my $top_srcdir = shift @ARGV; - -my @tests = ( - 'Test-auth-basic.px', - 'Test-auth-no-challenge.px', - 'Test-auth-no-challenge-url.px', - 'Test-auth-with-content-disposition.px', - 'Test-auth-retcode.px', - 'Test-cookies.px', - 'Test-cookies-401.px', - 'Test-proxy-auth-basic.px', - 'Test-proxied-https-auth.px', - 'Test-N-HTTP-Content-Disposition.px', - 'Test--spider.px', - 'Test-c-full.px', - 'Test-c-partial.px', - 'Test-c-shorter.px', - 'Test-c.px', - 'Test-E-k-K.px', - 'Test-E-k.px', - 'Test-ftp.px', - 'Test-ftp-pasv-fail.px', - 'Test-ftp-bad-list.px', - 'Test-ftp-recursive.px', - 'Test-ftp-iri.px', - 'Test-ftp-iri-fallback.px', - 'Test-ftp-iri-recursive.px', - 'Test-ftp-iri-disabled.px', - 'Test-ftp-list-Multinet.px', - 'Test-ftp-list-Unknown.px', - 'Test-ftp-list-Unknown-a.px', - 'Test-ftp-list-Unknown-hidden.px', - 'Test-ftp-list-Unknown-list-a-fails.px', - 'Test-ftp-list-UNIX-hidden.px', - 'Test-HTTP-Content-Disposition-1.px', - 'Test-HTTP-Content-Disposition-2.px', - 'Test-HTTP-Content-Disposition.px', - 'Test-i-ftp.px', - 'Test-i-http.px', - 'Test-idn-headers.px', - 'Test-idn-meta.px', - 'Test-idn-cmd.px', - 'Test-idn-cmd-utf8.px', - 'Test-idn-robots.px', - 'Test-idn-robots-utf8.px', - 'Test-iri.px', - 'Test-iri-percent.px', - 'Test-iri-disabled.px', - 'Test-iri-forced-remote.px', - 'Test-iri-list.px', - 'Test-k.px', - 'Test-meta-robots.px', - 'Test-N-current.px', - 'Test-N-smaller.px', - 'Test-N-no-info.px', - 'Test-N--no-content-disposition.px', - 'Test-N--no-content-disposition-trivial.px', - 'Test--no-content-disposition.px', - 'Test--no-content-disposition-trivial.px', - 'Test-N-old.px', - 'Test-nonexisting-quiet.px', - 'Test-noop.px', - 'Test-np.px', - 'Test-N.px', - 'Test-O-HTTP-Content-Disposition.px', - 'Test-O--no-content-disposition.px', - 'Test-O--no-content-disposition-trivial.px', - 'Test-O-nonexisting.px', - 'Test-O.px', - 'Test--post-file.px', - 'Test-O-nc.px', - 'Test-restrict-ascii.px', - 'Test-Restrict-Lowercase.px', - 'Test-Restrict-Uppercase.px', - 'Test-stdouterr.px', - 'Test--spider-fail.px', - 'Test--spider-r-HTTP-Content-Disposition.px', - 'Test--spider-r--no-content-disposition.px', - 'Test--spider-r--no-content-disposition-trivial.px', - 'Test--spider-r.px', - 'Test--httpsonly-r.px', - 'Test--start-pos.px', - 'Test-ftp--start-pos.px', - 'Test--start-pos--continue.px', - 'Test-204.px', -); - -foreach my $var (qw(SYSTEM_WGETRC WGETRC)) { - $ENV{$var} = '/dev/null'; -} - -my @tested; - -foreach my $test (@tests) { - print "Running $test\n\n"; - system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir"); - push @tested, { name => $test, result => $? >> 8 }; -} - -foreach my $var (qw(SYSTEM_WGETRC WGETRC)) { - delete $ENV{$var}; -} - -my %exit = ( - pass => 0, - fail => 1, - skip => 2, - unknown => 3, # or greater -); - -my %colors = ( - $exit{pass} => colored('pass:', 'green' ), - $exit{fail} => colored('FAIL:', 'red' ), - $exit{skip} => colored('Skip:', 'yellow' ), - $exit{unknown} => colored('Unknown:', 'magenta'), -); - -print "\n"; -foreach my $test (@tested) { - my $colored = exists $colors{$test->{result}} - ? $colors{$test->{result}} - : $colors{$exit{unknown}}; - print "$colored $test->{name}\n"; -} - -my $count = sub -{ - return { - pass => sub { scalar grep $_->{result} == $exit{pass}, @tested }, - fail => sub { scalar grep $_->{result} == $exit{fail}, @tested }, - skip => sub { scalar grep $_->{result} == $exit{skip}, @tested }, - unknown => sub { scalar grep $_->{result} >= $exit{unknown}, @tested }, - }->{$_[0]}->(); -}; - -my $summary = sub -{ - my @lines = ( - "${\scalar @tested} tests were run", - "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL", - "${\$count->('skip')} SKIP, ${\$count->('unknown')} UNKNOWN", - ); - my $len_longest = sub - { - local $_ = 0; - foreach my $line (@lines) { - if (length $line > $_) { - $_ = length $line; - } - } - return $_; - }->(); - return join "\n", - '=' x $len_longest, - @lines, - '=' x $len_longest; -}->(); - -print "\n"; -print $count->('fail') || $count->('unknown') - ? colored($summary, 'red') - : colored($summary, 'green'); -print "\n"; - -exit $count->('fail') + $count->('unknown');