From: Jean-Frederic Clere Date: Fri, 14 Aug 2026 17:40:23 +0000 (+0000) Subject: Arrange to pass more tests on windows. X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=dc63be883d3bd526865a6e440fb0637e073a8401;p=thirdparty%2Fapache%2Fhttpd.git Arrange to pass more tests on windows. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1937130 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/pytest_suite/apache_pytest/config.py b/test/pytest_suite/apache_pytest/config.py index a0639fcfa3..3995cd5753 100644 --- a/test/pytest_suite/apache_pytest/config.py +++ b/test/pytest_suite/apache_pytest/config.py @@ -588,7 +588,7 @@ class TestConfig: var = self._GETFILES_ALIASES[label] val = self.vars.get(var) if val: - lines.append(f" Alias /getfiles-{label} {val}") + lines.append(f' Alias /getfiles-{label} "{val}"') lines.append("") return "\n".join(lines) @@ -845,8 +845,10 @@ class TestConfig: # Register the module in the modules set so # rewriting recognizes it (TestConfigC.pm:308 $self->{modules}{$cname}=1). self.info.modules.add(f"mod_{sym}.c") - # so is /.libs/mod_.so; source is /mod_.c + # so is /.libs/mod_.so (apxs) or /modules/ (CMake). c_source = so.parent.parent / f"mod_{sym}.c" + if not c_source.is_file(): + c_source = Path(self.vars["top_dir"]) / "c-modules" / sym / f"mod_{sym}.c" if c_source.is_file(): self.add_module_config(c_source, cmodule_args) if cmodule_args: diff --git a/test/pytest_suite/conftest.py b/test/pytest_suite/conftest.py index 8d3fd2111c..a0c50fd3f4 100644 --- a/test/pytest_suite/conftest.py +++ b/test/pytest_suite/conftest.py @@ -168,13 +168,11 @@ def _probed_info(config: pytest.Config) -> HttpdInfo | None: # fixture, so need_module("authany") etc. should be satisfied at collection # time too. Augment the probed set with the C modules that WILL be built # (honoring the same HTTPD_TEST_REQUIRE_APACHE gating discover() applies). - # Without apxs the modules can't be compiled, so don't promise them. - if _apxs is not None: - from apache_pytest.cmodules import discover + from apache_pytest.cmodules import discover - cmods, _skipped = discover(REPO_ROOT / "c-modules", info) - for mod in cmods: - info.modules.add(f"mod_{mod.name}.c") + cmods, _skipped = discover(REPO_ROOT / "c-modules", info) + for mod in cmods: + info.modules.add(f"mod_{mod.name}.c") _probe_cache = info return _probe_cache @@ -263,6 +261,14 @@ def framework(request: pytest.FixtureRequest): cmodule_loads, _skipped = compile_all( cmodules_dir, apxs, info, defines=["APACHE2", "APACHE2_4", *defines] ) + else: + from apache_pytest.cmodules import discover + modules_dir = (install_prefix / "modules") if install_prefix else httpd.parent + cmods, _skipped = discover(REPO_ROOT / "c-modules", info) + for mod in cmods: + so = modules_dir / f"mod_{mod.name}.so" + if so.exists(): + cmodule_loads.append((mod.symbol, so)) config.generate(cmodule_loads=cmodule_loads) diff --git a/test/pytest_suite/t/conf/core.conf.in b/test/pytest_suite/t/conf/core.conf.in index c82f37569a..b1e85f8d94 100644 --- a/test/pytest_suite/t/conf/core.conf.in +++ b/test/pytest_suite/t/conf/core.conf.in @@ -4,6 +4,11 @@ MaxMemFree 1 + + ServerName righthost + ServerAlias Righthost 128.0.0.1 + + ServerName default-strict = 2.4.49> diff --git a/test/pytest_suite/tests/t/apache/test_acceptpathinfo.py b/test/pytest_suite/tests/t/apache/test_acceptpathinfo.py index a4a07ee06a..0e1afc55b2 100644 --- a/test/pytest_suite/tests/t/apache/test_acceptpathinfo.py +++ b/test/pytest_suite/tests/t/apache/test_acceptpathinfo.py @@ -59,9 +59,10 @@ def _cases(http): @need_module("include") @need_lwp() -@pytest.mark.skipif(sys.platform == "win32", reason="uses shell CGI scripts") def test_acceptpathinfo(http): for mode, req, exp_rc, exp_body in _cases(http): + if "/test.sh" in req and sys.platform == "win32": + continue # Apache::TestRequest's GET follows redirects by default; the bare # directory request 301-redirects to add a trailing slash before the # index.shtml (which echoes PATH_INFO) is served. diff --git a/test/pytest_suite/tests/t/apache/test_mmn.py b/test/pytest_suite/tests/t/apache/test_mmn.py index de5fc04e18..341518b980 100644 --- a/test/pytest_suite/tests/t/apache/test_mmn.py +++ b/test/pytest_suite/tests/t/apache/test_mmn.py @@ -20,11 +20,14 @@ _MINOR = re.compile(r"^#define\s+MODULE_MAGIC_NUMBER_MINOR\s+(\d+)(?:\s|$)") @need_min_apache_version("2") def test_mmn(http): incdir = http.apxs("INCLUDEDIR") - if not incdir: - pytest.skip("apxs INCLUDEDIR unavailable") - filename = os.path.join(incdir, "ap_mmn.h") - if not os.path.isfile(filename): - pytest.skip(f"can't read {filename}") + filename = os.path.join(incdir, "ap_mmn.h") if incdir else None + if not filename or not os.path.isfile(filename): + # Fall back to the source tree include/ directory. + src_inc = os.path.join(http.vars("top_dir"), "..", "..", "include", "ap_mmn.h") + if os.path.isfile(src_inc): + filename = src_inc + else: + pytest.skip("ap_mmn.h not found (no apxs and not in source tree)") cmajor = cminor = major = minor = None with open(filename) as fh: diff --git a/test/pytest_suite/tests/t/modules/test_ratelimit.py b/test/pytest_suite/tests/t/modules/test_ratelimit.py index 737d5f4927..bcee559afe 100644 --- a/test/pytest_suite/tests/t/modules/test_ratelimit.py +++ b/test/pytest_suite/tests/t/modules/test_ratelimit.py @@ -17,17 +17,15 @@ import pytest from apache_pytest import need_min_apache_version, need_module, t_cmp CASES = [ - ("/apache/ratelimit/", 200, "ratelimited small file", False), - ("/apache/ratelimit/autoindex/", 200, "ratelimited small autoindex output", False), - ("/apache/ratelimit/chunk?0,8192", 200, "ratelimited chunked response", True), + ("/apache/ratelimit/", 200, "ratelimited small file"), + ("/apache/ratelimit/autoindex/", 200, "ratelimited small autoindex output"), + ("/apache/ratelimit/chunk?0,8192", 200, "ratelimited chunked response"), ] @need_module("ratelimit", "autoindex") @need_min_apache_version("2.4.35") -@pytest.mark.parametrize("url,code,desc,needs_cmod", CASES, ids=[c[2] for c in CASES]) -def test_ratelimit(http, url, code, desc, needs_cmod): - if needs_cmod and not http.have_module("random_chunk"): - pytest.skip("random_chunk C test module not available") +@pytest.mark.parametrize("url,code,desc", CASES, ids=[c[2] for c in CASES]) +def test_ratelimit(http, url, code, desc): r = http.GET(url) assert t_cmp(r.status_code, code), desc diff --git a/test/pytest_suite/tests/t/modules/test_substitute.py b/test/pytest_suite/tests/t/modules/test_substitute.py index 810a6005c4..246435f2e2 100644 --- a/test/pytest_suite/tests/t/modules/test_substitute.py +++ b/test/pytest_suite/tests/t/modules/test_substitute.py @@ -68,16 +68,16 @@ def _docroot_file(http, *parts): def _write_testfile(http, content): - with open(_docroot_file(http, "test.txt"), "w") as f: - f.write(content) + with open(_docroot_file(http, "test.txt"), "wb") as f: + f.write(content.encode("utf-8")) def _write_htaccess(http, rules): content = "SetOutputFilter BUCKETEER;SUBSTITUTE\n" for rule in rules: content += f"Substitute {rule}\n" - with open(_docroot_file(http, ".htaccess"), "w") as f: - f.write(content) + with open(_docroot_file(http, ".htaccess"), "wb") as f: + f.write(content.encode("utf-8")) def _httpd_rule_to_python(content, rule): diff --git a/test/pytest_suite/tests/test_framework_smoke.py b/test/pytest_suite/tests/test_framework_smoke.py index d9b0990b0a..2488a4d3e4 100644 --- a/test/pytest_suite/tests/test_framework_smoke.py +++ b/test/pytest_suite/tests/test_framework_smoke.py @@ -39,8 +39,8 @@ def test_cmodule_compiled_and_loaded(config) -> None: config.vars["t_conf_file"] and open(config.vars["t_conf_file"]).read() # noqa: SIM115 ) - if "LoadModule echo_post_module" not in conf_text: - pytest.skip("C test modules not compiled (no --apxs)") + assert "LoadModule echo_post_module" in conf_text + # echo_post.c registers the echo_post handler; the module is now in scope. assert config.info.has_module("mod_echo_post") or "echo_post" in conf_text