From 9dd5a600431c837fca707882710e106b40c07018 Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Thu, 26 Nov 2026 20:54:02 -0500 Subject: [PATCH 1/3] test: Load mod_proxy_ajp, mod_proxy_uwsgi and mod_proxy_fcgi as optional modules. A module in ProxyTestSetup.add_modules() that the build lacks stops setup with "Unable to find modules", failing every test under test/modules/proxy, and the env.require() checks in the tests that use these modules could never be reached. Load them with add_optional_modules() so a build without one skips only those tests (or fails them under --strict-optional). * test/modules/proxy/env.py: Move proxy_ajp, proxy_uwsgi and proxy_fcgi to add_optional_modules(). * test/modules/proxy/test_03_uwsgi.py: Check for mod_proxy_uwsgi with env.require() in both class fixtures; _proxy_uwsgi_setup had no check. * test/README.pytest, AGENTS.md: Describe when a test module belongs in add_modules() and when in add_optional_modules(). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PUN2EPhoNvc4rfibgy6H72 --- AGENTS.md | 7 +++++++ test/README.pytest | 17 +++++++++++++++++ test/modules/proxy/env.py | 10 ++++++---- test/modules/proxy/test_03_uwsgi.py | 8 ++++++-- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1905d950a9a..1df4f8e2c88 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -112,6 +112,13 @@ server or MPM changes. On Unix, verify these pass locally by running `make check-pytest PYTEST_DIRS=test/modules/xxx` — this can be done without running `make install` first. +A module that only some tests in a package use goes in that package's +`add_optional_modules()`, not `add_modules()`, and those tests check +for it with `env.require(env.has_shared_module(...), ...)`. A module +listed in `add_modules()` that the build lacks stops setup with "Unable +to find modules", which fails every test in the package. See +`test/README.pytest` ("If your test needs a module"). + ## Validating changes After editing any `.github/workflows/*.yml` file or any script the diff --git a/test/README.pytest b/test/README.pytest index 30cc8f0274d..f7a31ff67e5 100644 --- a/test/README.pytest +++ b/test/README.pytest @@ -234,6 +234,23 @@ and cache the answer: @H2TestEnv.needs_h2load("1.41.0") @HttpdTestEnv.needs_multipart() +If your test needs a module, list it in the test package's +'*TestSetup' (its env.py). 'add_modules()' is for modules that +every test in the package needs: a build without one of them +stops setup with "Unable to find modules", so the whole package +fails. A module that only some of the tests use goes in +'add_optional_modules()', which loads it when it is there, and +the tests that use it check for it: + + env.require(env.has_shared_module("proxy_fcgi"), + "mod_proxy_fcgi not available", + dep="mod_proxy_fcgi", + detected=f"no mod_proxy_fcgi.so in {env.libexec_dir}") + +'has_shared_module()' is true for a module built as a DSO and for +one compiled into httpd. test/modules/proxy/test_13_fcgi_setenvif.py +is an example. + For a check that can only be made once the test is running, 'env.require()' does the same job from inside the body: diff --git a/test/modules/proxy/env.py b/test/modules/proxy/env.py index aa26f23ae09..3aa2870d58c 100644 --- a/test/modules/proxy/env.py +++ b/test/modules/proxy/env.py @@ -81,10 +81,12 @@ class ProxyTestSetup(HttpdTestSetup): def __init__(self, env: 'HttpdTestEnv'): super().__init__(env=env) self.add_source_dir(os.path.dirname(inspect.getfile(ProxyTestSetup))) - self.add_modules(["proxy", "proxy_http", "proxy_ajp", "proxy_balancer", - "proxy_connect", "proxy_uwsgi", "proxy_fcgi", - "lbmethod_byrequests", "remoteip"]) - self.add_optional_modules(["proxy_hcheck", "proxy_scgi"]) + self.add_modules(["proxy", "proxy_http", "proxy_balancer", + "proxy_connect", "lbmethod_byrequests", "remoteip"]) + # Modules only some tests use: a build without one skips those + # tests (env.require()) instead of failing setup for the package. + self.add_optional_modules(["proxy_hcheck", "proxy_scgi", "proxy_ajp", + "proxy_uwsgi", "proxy_fcgi"]) class ProxyTestEnv(HttpdTestEnv): diff --git a/test/modules/proxy/test_03_uwsgi.py b/test/modules/proxy/test_03_uwsgi.py index 07a7f616783..55ac601cb8e 100644 --- a/test/modules/proxy/test_03_uwsgi.py +++ b/test/modules/proxy/test_03_uwsgi.py @@ -44,6 +44,9 @@ class TestProxyUwsgi: @pytest.fixture(scope="class") def _proxy_uwsgi_setup(self, env): + env.require(env.has_shared_module("proxy_uwsgi"), "mod_proxy_uwsgi not available", + dep="mod_proxy_uwsgi", + detected=f"no mod_proxy_uwsgi.so in {env.libexec_dir}") faker = UwsgiFaker(port=UWSGI_PORT) faker.start() @@ -67,8 +70,9 @@ def _proxy_uwsgi_setup(self, env): @pytest.fixture(scope='class') def _class_scope(self, env): - if not env.has_shared_module("proxy_uwsgi"): - pytest.skip("mod_proxy_uwsgi not available") + env.require(env.has_shared_module("proxy_uwsgi"), "mod_proxy_uwsgi not available", + dep="mod_proxy_uwsgi", + detected=f"no mod_proxy_uwsgi.so in {env.libexec_dir}") faker = _UWSGIFaker("127.0.0.1", env.http_port2) faker.start() conf = HttpdConf(env) From 4468c242a6a48db509c516d53af8103157c5865c Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Thu, 26 Nov 2026 21:45:27 -0500 Subject: [PATCH 2/3] test: Mark the tests of the regex backreference changes not_backported. test/ is copied to 2.4.x as it is, so mark the tests from #1096 that fail on a 2.4.x without the change, expecting the backport (#1097) in 2.4.72. Marks follow a run against unfixed 2.4.x: a test that hangs the server, crashes it or leaves errors in the error log is skipped, one that fails cleanly is an expected failure, and one that passes is left unmarked. * test/modules/filters/test_010_substitute_empty_match.py: Skip the cases that loop forever or log "Line too long"; anchor_nonempty fails cleanly; lookbehind passes already. * test/modules/metadata/test_006_expr_backref.py: Skip the class: its Header edit* lines crash every request without r1915271. * test/modules/proxy/test_13_fcgi_setenvif.py: Only the short-circuit test fails without the change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PUN2ETFf8d5srUT51exsTS --- .../filters/test_010_substitute_empty_match.py | 14 +++++++++++++- test/modules/metadata/test_006_expr_backref.py | 5 +++++ test/modules/proxy/test_13_fcgi_setenvif.py | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/modules/filters/test_010_substitute_empty_match.py b/test/modules/filters/test_010_substitute_empty_match.py index 5a4a0bd48c3..b9f35cb01ca 100644 --- a/test/modules/filters/test_010_substitute_empty_match.py +++ b/test/modules/filters/test_010_substitute_empty_match.py @@ -2,6 +2,7 @@ import pytest +from pyhttpd.backport import not_backported, skip_not_backported from pyhttpd.conf import HttpdConf # Patterns that can match the empty string must not loop forever (or until @@ -33,6 +34,17 @@ 'mixed_empty_nonempty': ('b*', '-', 'f', 'abbc', '-a--c-'), } +# Without the change, most of these loop until "Line too long" is logged, +# and star_empty_* loop forever. +WHAT = "mod_substitute empty matches" +SKIP = skip_not_backported("gh-1096", WHAT, backported_in="2.4.72") +MARKS = { + 'anchor_nonempty': not_backported("gh-1096", WHAT, backported_in="2.4.72"), + 'lookbehind': (), +} +PARAMS = [pytest.param(name, id=name, marks=MARKS.get(name, SKIP)) + for name in CASES] + class TestSubstituteEmptyMatch: @@ -58,7 +70,7 @@ def configure(self, env, pattern, repl, flags): conf.install() assert env.apache_restart() == 0 - @pytest.mark.parametrize("name", list(CASES), ids=list(CASES)) + @pytest.mark.parametrize("name", PARAMS) def test_filters_010_01(self, env, name): pattern, repl, flags, _, expected = CASES[name] self.configure(env, pattern, repl, flags) diff --git a/test/modules/metadata/test_006_expr_backref.py b/test/modules/metadata/test_006_expr_backref.py index 4bfee9b223a..2fc7538baa3 100644 --- a/test/modules/metadata/test_006_expr_backref.py +++ b/test/modules/metadata/test_006_expr_backref.py @@ -1,5 +1,6 @@ import pytest +from pyhttpd.backport import skip_not_backported from pyhttpd.conf import HttpdConf # An expression that evaluates to true without evaluating a capturing regex @@ -15,6 +16,10 @@ LONG = "long-" + "x" * 200 +# Without r1915271 the Header edit* lines below crash every request, so +# none of the tests can run. +@skip_not_backported("r1915271", "mod_headers edit* recursion on empty matches", + backported_in="2.4.72") class TestExprBackref: @pytest.fixture(autouse=True, scope='class') diff --git a/test/modules/proxy/test_13_fcgi_setenvif.py b/test/modules/proxy/test_13_fcgi_setenvif.py index 53e46fde9d1..cd52084b053 100644 --- a/test/modules/proxy/test_13_fcgi_setenvif.py +++ b/test/modules/proxy/test_13_fcgi_setenvif.py @@ -1,5 +1,6 @@ import pytest +from pyhttpd.backport import not_backported from pyhttpd.conf import HttpdConf from .fcgi_faker import FCGIFaker @@ -46,6 +47,8 @@ def get_params(self, env, headers): assert r.response["status"] == 200, r.response return r.response["json"] + @not_backported("gh-1096", "ProxyFCGISetEnvIf backreferences without a capturing match", + backported_in="2.4.72") def test_proxy_13_01_short_circuit(self, env): params = self.get_params(env, {"X-Match": "skip", "X-Prev": "previous"}) assert params["PREV_CAPTURE"] == "" From c1185a1b89dc25f189c13c5ba3b1f9d7c058978b Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Thu, 26 Nov 2026 21:51:54 -0500 Subject: [PATCH 3/3] test: Name the pull request in the not_backported examples. Changes are made by pull request now, so the examples showing svn revisions led to marks waiting for a revision that never comes. Show "gh-NNNN" instead, and say that the "rNNNNNNN" names in older marks are svn revisions from before the move to git. * test/pyhttpd/backport.py, test/README.pytest: Use gh-1096 in the examples, and explain the older revision names. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PUN2ETFf8d5srUT51exsTS --- test/README.pytest | 11 +++++++---- test/pyhttpd/backport.py | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/README.pytest b/test/README.pytest index f7a31ff67e5..ed5eb6910fe 100644 --- a/test/README.pytest +++ b/test/README.pytest @@ -285,12 +285,15 @@ This directory is the same on trunk and on 2.4.x: a test is written on trunk, then `test/` is copied to 2.4.x as it is, and `check-test-sync.sh` fails if the two branches differ. A test covering a trunk change that 2.4.x does not have yet carries a mark from `pyhttpd/backport.py` (or, in `pytest_suite/`, -`apache_pytest.not_backported`) naming the trunk revision: +`apache_pytest.not_backported`) naming the pull request that made the +change: from pyhttpd.backport import not_backported, skip_not_backported - @not_backported("r1939033", "nonce-count validation") - def test_digest_001(self, env): ... + @not_backported("gh-1096", "mod_substitute empty matches") + def test_filters_010_01(self, env): ... + +Older marks name svn revisions ("r1939033"), from before the move to git. `not_backported` makes the test an expected failure on a server older than 2.5.0, `skip_not_backported` skips it where failing would hang or crash the @@ -309,7 +312,7 @@ skipped, or failed under `--strict-optional`. When the change is backported, add the 2.4.x release it first appears in: - @not_backported("r1939033", "nonce-count validation", backported_in="2.4.71") + @not_backported("gh-1096", "mod_substitute empty matches", backported_in="2.4.72") on trunk, then copy `test/` to 2.4.x again. Older 2.4.x servers keep the expectation. `platform="win32"` limits it to one `sys.platform`. diff --git a/test/pyhttpd/backport.py b/test/pyhttpd/backport.py index c258b48557a..44cfe5ba695 100644 --- a/test/pyhttpd/backport.py +++ b/test/pyhttpd/backport.py @@ -9,12 +9,15 @@ appears in, on trunk and copy the file over; older 2.4.x releases keep the expectation. - pytestmark = not_backported("r1939033", "nonce-count validation") + pytestmark = not_backported("gh-1096", "mod_substitute empty matches") - @skip_not_backported("r1938487", "recursion limit in mod_sed", - backported_in="2.4.71") + @skip_not_backported("gh-1096", "mod_substitute empty matches", + backported_in="2.4.72") def test_... +The first argument names the pull request that made the change ("gh-1096"). +Older marks name svn revisions ("r1939033"), from before the move to git. + platform limits the expectation to one sys.platform, for a failure on 2.4.x which trunk does not have there.