1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

add ./configure valgrind support to test suites

This commit is contained in:
Tim Rühsen 2014-10-08 11:03:45 +02:00
parent 3eff3ad69a
commit 9c34d4ed09
9 changed files with 63 additions and 12 deletions

View File

@ -1,3 +1,7 @@
2014-10-28 Tim Ruehsen <tim.ruehsen@gmx.de>
* configure.ac: add --enable-valgrind-tests
2014-10-28 Giuseppe Scrivano <gscrivan@redhat.com> 2014-10-28 Giuseppe Scrivano <gscrivan@redhat.com>
* cfg.mk (local-checks-to-skip): Add sc_makefile_at_at_check. * cfg.mk (local-checks-to-skip): Add sc_makefile_at_at_check.

View File

@ -100,6 +100,25 @@ ENABLE_DEBUG=$enableval, ENABLE_DEBUG=yes)
test x"${ENABLE_DEBUG}" = xyes && AC_DEFINE([ENABLE_DEBUG], 1, test x"${ENABLE_DEBUG}" = xyes && AC_DEFINE([ENABLE_DEBUG], 1,
[Define if you want the debug output support compiled in.]) [Define if you want the debug output support compiled in.])
dnl
dnl Check for valgrind
dnl
AC_ARG_ENABLE(valgrind-tests,
AS_HELP_STRING([--enable-valgrind-tests], [enable using Valgrind for tests]),
[ac_enable_valgrind=$enableval], [ac_enable_valgrind=no])
if test "${ac_enable_valgrind}" != "no" ; then
AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
if test "$HAVE_VALGRIND" = "yes" ; then
VALGRIND_TESTS="1"
AC_SUBST(VALGRIND_TESTS)
VALGRIND_INFO="Test suite will be run under Valgrind"
else
VALGRIND_INFO="Valgrind not found"
fi
else
VALGRIND_INFO="Valgrind testing not enabled"
fi
dnl dnl
dnl Find the compiler dnl Find the compiler
dnl dnl
@ -599,4 +618,5 @@ AC_MSG_NOTICE([Summary of build options:
NTLM: $ENABLE_NTLM NTLM: $ENABLE_NTLM
OPIE: $ENABLE_OPIE OPIE: $ENABLE_OPIE
Debugging: $ENABLE_DEBUG Debugging: $ENABLE_DEBUG
Valgrind: $VALGRIND_INFO
]) ])

View File

@ -1,3 +1,9 @@
2014-10-25 Tim Ruehsen <tim.ruehsen@gmx.de>
* test/base_test.py (gen_cmd_line): generate valgrind command line if requested
* README: amend description of VALGRIND_TESTS
* Makefile.am: set/export VALGRIND_TESTS
2014-10-01 Darshit Shah <darnir@gmail.com> 2014-10-01 Darshit Shah <darnir@gmail.com>
* Makefile.am: Run the tests in Python's Optimizedmode * Makefile.am: Run the tests in Python's Optimizedmode

View File

@ -27,7 +27,8 @@
AUTOMAKE_OPTIONS = parallel-tests AUTOMAKE_OPTIONS = parallel-tests
AM_TESTS_ENVIRONMENT = export WGETRC=/dev/null; MAKE_CHECK=True; export MAKE_CHECK; export PYTHONPATH=$$PYTHONPATH:$(srcdir); AM_TESTS_ENVIRONMENT = export WGETRC=/dev/null; MAKE_CHECK=True; export MAKE_CHECK;\
export PYTHONPATH=$$PYTHONPATH:$(srcdir); export VALGRIND_TESTS="@VALGRIND_TESTS@";
TESTS = Test-auth-basic-fail.py \ TESTS = Test-auth-basic-fail.py \
Test-auth-basic.py \ Test-auth-basic.py \
Test-auth-both.py \ Test-auth-both.py \

View File

@ -93,8 +93,10 @@ Environment Variables:
valgrind. valgrind.
* NO_CLEANUP: Do not remove the temporary files created by the test. * NO_CLEANUP: Do not remove the temporary files created by the test.
This will prevent the ${testname}-test directory from being deleted This will prevent the ${testname}-test directory from being deleted
* VALGRIND_TESTS: If this variable is set, the test suite will execute all the * VALGRIND_TESTS: If this variable is set and contains the valgrind command line,
tests through valgrind's memcheck tool. the test suite will execute all the tests via this command.
If it is set to "1", valgrind memcheck is enabled with hard coded options.
This variable is set by ./configure --enable-valgrind-tests.
File Structure: File Structure:

View File

@ -100,11 +100,14 @@ class BaseTest:
"..", '..', 'src', "wget")) "..", '..', 'src', "wget"))
wget_options = '--debug --no-config %s' % self.wget_options wget_options = '--debug --no-config %s' % self.wget_options
if os.getenv("VALGRIND_TESTS"): valgrind = os.getenv("VALGRIND_TESTS", "")
valgrind_test = "valgrind --error-exitcode=301 --leak-check=full --track-origins=yes" if valgrind in ("", "0"):
cmd_line = '%s %s ' % (wget_path, wget_options)
elif valgrind == "1":
cmd_line = 'valgrind --error-exitcode=301 --leak-check=yes --track-origins=yes %s %s ' % (wget_path, wget_options)
else: else:
valgrind_test = "" cmd_line = '%s %s %s ' % (os.getenv("VALGRIND_TESTS", ""), wget_path, wget_options)
cmd_line = '%s %s %s ' % (valgrind_test, wget_path, wget_options)
for protocol, urls, domain in zip(self.protocols, for protocol, urls, domain in zip(self.protocols,
self.urls, self.urls,
self.domains): self.domains):

View File

@ -1,3 +1,8 @@
2014-10-25 Tim Ruehsen <tim.ruehsen@gmx.de>
* WgetTests.pm (run): generate valgrind command line if requested
* Makefile.am: set/export VALGRIND_TESTS
2014-10-28 Tim Ruehsen <tim.ruehsen@gmx.de> 2014-10-28 Tim Ruehsen <tim.ruehsen@gmx.de>
* tests/Test-proxied-https-auth.px: synchronize client and server * tests/Test-proxied-https-auth.px: synchronize client and server

View File

@ -140,6 +140,7 @@ CLEANFILES = *~ *.bak core core.[0-9]*
TESTS = ./unit-tests$(EXEEXT) $(PX_TESTS) TESTS = ./unit-tests$(EXEEXT) $(PX_TESTS)
TEST_EXTENSIONS = .px TEST_EXTENSIONS = .px
AM_TESTS_ENVIRONMENT = export WGETRC=/dev/null; export SYSTEM_WGETRC=/dev/null;
PX_LOG_COMPILER = $(PERL) PX_LOG_COMPILER = $(PERL)
AM_PX_LOG_FLAGS = -I$(srcdir) AM_PX_LOG_FLAGS = -I$(srcdir)
AM_TESTS_ENVIRONMENT = export WGETRC=/dev/null; export SYSTEM_WGETRC=/dev/null;\
export VALGRIND_TESTS="@VALGRIND_TESTS@";

View File

@ -88,13 +88,22 @@ sub run {
# Call wget # Call wget
chdir ("$self->{_workdir}/$self->{_name}/output"); chdir ("$self->{_workdir}/$self->{_name}/output");
my $cmdline = $self->{_cmdline}; my $cmdline = $self->{_cmdline};
$cmdline = $self->_substitute_port($cmdline); $cmdline = $self->_substitute_port($cmdline);
$cmdline = ($cmdline =~ m{^/.*}) ? $cmdline : "$self->{_workdir}/$cmdline";
my $valgrind = $ENV{VALGRIND_TESTS};
if (!defined $valgrind || $valgrind == "" || $valgrind == "0") {
# Valgrind not requested - leave $cmdline as it is
} elsif ($valgrind == "1") {
$cmdline = "valgrind --error-exitcode=301 --leak-check=yes --track-origins=yes " . $cmdline;
} else {
$cmdline = $valgrind . " " . $cmdline;
}
print "Calling $cmdline\n"; print "Calling $cmdline\n";
$errcode = $errcode = system($cmdline);
($cmdline =~ m{^/.*})
? system ($cmdline)
: system ("$self->{_workdir}/$cmdline");
$errcode >>= 8; # XXX: should handle abnormal error codes. $errcode >>= 8; # XXX: should handle abnormal error codes.
# Shutdown server # Shutdown server