]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Have "make check" run all of the libcheck-based unit tests,
authorJoe Orton <jorton@apache.org>
Sat, 28 Feb 2026 13:22:38 +0000 (13:22 +0000)
committerJoe Orton <jorton@apache.org>
Sat, 28 Feb 2026 13:22:38 +0000 (13:22 +0000)
pytest-based tests, and perl-framework-based tests if available.

* test/pyhttpd/env.py (HttpdTestEnv.__init__): Use config.ini from
  $PYHTTPD_CONFIG if set.

* configure.in: Check for pytest-3, add check-pytest to $CHECK_TARGETS
  if found. Add check-unittests to $CHECK_TARGETS if test/httpdunit is
  generated. Add check-test-framework to $CHECK_TARGETS if the Perl test
  framework is present. Stop generating WITH_TEST_SUITE.

* Makefile.in (check): Depend on $CHECK_TARGETS.
  (check-tree, check/bin/apachectl, check/config.ini, check/modules/stamp):
  New targets to fill out the check/ install tree for use with pyhttpd.
  (check-pytest): New target to run pytest-based tests.
  (check-unittests): New target to run libcheck-based tests.
  (check-test-framework): Renamed from "check-yes", runs Perl framework tests.

Github: closes #598

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1932079 13f79535-47bb-0310-9956-ffa450edef68

Makefile.in
build/config_vars.sh.in
configure.in
test/pyhttpd/env.py

index 5e4b2a506a1e1dde9be0a48779d88f1736c79e73..75605671332423eeb54ea7cecdfea9ace49ea737 100644 (file)
@@ -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
index 86439cb5c63f64a6fa7a91285b0b4b7ef697e6a8..26e43f6dace545abfc0c827ccf58c7d04c7fc234 100644 (file)
@@ -88,4 +88,6 @@ exec sed "
 /^EXPORTS_DOT_C/d
 /^LIBMAIN_LIB/d
 /TEST_SUITE/d
+/^PYTEST3/d
+/^CHECK_TARGETS/d
 "
index b64c37b7783f0689578f9ce32dd3832358976fbf..57f20ea824bd365b92a22942e166bd630ad0a623 100644 (file)
@@ -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)
index 8a20d928432d226c821f79ded09ff42baaa9de24..7c2eb33dacbee24b5181d8fdd0fcff0e443a9509 100644 (file)
@@ -238,8 +238,10 @@ class HttpdTestEnv:
 
     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')