diff --git a/Makefile.in b/Makefile.in index 5e4b2a506a1..75605671332 100644 --- a/Makefile.in +++ b/Makefile.in @@ -449,6 +449,12 @@ check/bin/apxs: sed -e 's#$(prefix)#$(top_builddir)/check#g' support/apxs > $@ chmod +x $@ +# A version of apachectl with the PREFIX overridden to point inside the install root +check/bin/apachectl: + mkdir -p check + sed -e 's#$(prefix)#$(top_builddir)/check#g' support/apachectl > $@ + chmod +x $@ + # A version of config_vars.mk with PREFIX and SBINDIR and BINDIR overridden. check/build/config_vars.mk: build/config_vars.out mkdir -p check/build @@ -468,16 +474,29 @@ $(TEST_SUITE_LOCATION)/Makefile: $(TEST_SUITE_LOCATION)/Makefile.PL $(INSTALL_HE check-make: $(TEST_SUITE_LOCATION)/Makefile -check-no: - @echo 'Re-run configure with the --with-test-suite option to enable in-tree tests.' - @false +check-tree: check-include check-dirs check-conf check/build/config_vars.mk \ + check-binaries -check-yes: check-include check-dirs check-conf check/build/config_vars.mk \ - check-binaries $(TEST_SUITE_LOCATION)/Makefile +# Run the Apache::Test Perl framework +check-test-framework: check-tree $(TEST_SUITE_LOCATION)/Makefile cd $(TEST_SUITE_LOCATION) && $(MAKE) && ./t/TEST $(TEST_CONFIG) $(TESTS) -# Run the Apache::Test suite if it has been configured with --with-test-suite. -check: check-$(WITH_TEST_SUITE) +# Generate config.ini suitable for running against the check/ install prefix +check/config.ini: test/pyhttpd/config.ini + sed -e 's#$(prefix)#$(top_builddir)/check#g' test/pyhttpd/config.ini > $@ + +check/modules/stamp: build/config_vars.mk + mkdir -p check/modules + rm -f check/modules/*.so + find modules -name \*.so -exec ln -s $(top_builddir)/{} check/modules/ \; + find server/mpm -name \*.so -exec ln -s $(top_builddir)/{} check/modules/ \; + date > $@ + +check-pytest: check-tree check/bin/apachectl check/config.ini check/modules/stamp + PYHTTPD_CONFIG=$(top_builddir)/check/config.ini $(PYTEST3) $(PYTEST_DIRS) + +# Runs all configured/available test targets. +check: $(CHECK_TARGETS) # # Unit Test Suite @@ -513,3 +532,6 @@ httpdunit_OBJECTS := test/httpdunit.lo $(testcase_OBJECTS) $(httpdunit_OBJECTS): override LTCFLAGS += $(UNITTEST_CFLAGS) test/httpdunit: $(httpdunit_OBJECTS) $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS) $(LINK) $(httpdunit_OBJECTS) $(PROGRAM_OBJECTS) $(UNITTEST_LIBS) $(PROGRAM_LDADD) + +check-unittests: test/httpdunit + test/httpdunit diff --git a/build/config_vars.sh.in b/build/config_vars.sh.in index 86439cb5c63..26e43f6dace 100644 --- a/build/config_vars.sh.in +++ b/build/config_vars.sh.in @@ -88,4 +88,6 @@ exec sed " /^EXPORTS_DOT_C/d /^LIBMAIN_LIB/d /TEST_SUITE/d +/^PYTEST3/d +/^CHECK_TARGETS/d " diff --git a/configure.in b/configure.in index b64c37b7783..57f20ea824b 100644 --- a/configure.in +++ b/configure.in @@ -791,10 +791,11 @@ AC_ARG_WITH(valgrind, dnl Enable the unit test executable if Check is installed. dnl TODO: at the moment, only pkg-config discovery is supported. AC_MSG_CHECKING([for Check to enable unit tests]) -if test "x$PKGCONFIG" != "x" -a "$ap_reduced_exports" = "no" && `$PKGCONFIG --atleast-version='0.9.12' check`; then +if test "x$PKGCONFIG" != "x" -a -d "./test" -a "$ap_reduced_exports" = "no" && `$PKGCONFIG --atleast-version='0.9.12' check`; then UNITTEST_CFLAGS=`$PKGCONFIG --cflags check` UNITTEST_LIBS=`$PKGCONFIG --libs check` other_targets="$other_targets test/httpdunit" + CHECK_TARGETS="$CHECK_TARGETS check-unittests" AC_MSG_RESULT([yes]) else @@ -803,6 +804,13 @@ fi APACHE_SUBST(UNITTEST_CFLAGS) APACHE_SUBST(UNITTEST_LIBS) +if test -d "./test"; then + AC_PATH_PROG(PYTEST3, pytest-3) + if test -n "$ac_cv_path_PYTEST3"; then + CHECK_TARGETS="$CHECK_TARGETS check-pytest" + fi +fi +APACHE_SUBST(PYTEST3) prefix="$orig_prefix" APACHE_ENABLE_MODULES @@ -817,6 +825,7 @@ APACHE_SUBST(BUILTIN_LIBS) APACHE_SUBST(SHLIBPATH_VAR) APACHE_SUBST(OS_SPECIFIC_VARS) APACHE_SUBST(HTTPD_LIBS) +APACHE_SUBST(CHECK_TARGETS) PRE_SHARED_CMDS='echo ""' POST_SHARED_CMDS='echo ""' @@ -1007,14 +1016,11 @@ AC_ARG_WITH([test-suite], else test -f "$withval/Makefile.PL" || AC_MSG_ERROR([--with-test-suite directory $withval does not contain the expected Makefile.PL]) TEST_SUITE_LOCATION="$withval" - WITH_TEST_SUITE=yes + CHECK_TARGETS="$CHECK_TARGETS check-test-framework" fi - ], - [ WITH_TEST_SUITE=no ] -) + ]) APACHE_SUBST(TEST_SUITE_LOCATION) -APACHE_SUBST(WITH_TEST_SUITE) APACHE_FAST_OUTPUT(Makefile modules/Makefile srclib/Makefile) APACHE_FAST_OUTPUT(os/Makefile server/Makefile) diff --git a/test/pyhttpd/env.py b/test/pyhttpd/env.py index 8a20d928432..7c2eb33dacb 100644 --- a/test/pyhttpd/env.py +++ b/test/pyhttpd/env.py @@ -238,8 +238,10 @@ def has_shared_module(cls, name): def __init__(self, pytestconfig=None): self._our_dir = os.path.dirname(inspect.getfile(Dummy)) + self._config_ini = os.getenv("PYHTTPD_CONFIG", + os.path.join(self._our_dir, 'config.ini')) self.config = ConfigParser(interpolation=ExtendedInterpolation()) - self.config.read(os.path.join(self._our_dir, 'config.ini')) + self.config.read(self._config_ini) self._bin_dir = self.config.get('global', 'bindir') self._apxs = self.config.get('global', 'apxs')