]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Arrange to pass more tests on windows.
authorJean-Frederic Clere <jfclere@apache.org>
Fri, 14 Aug 2026 17:40:23 +0000 (17:40 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Fri, 14 Aug 2026 17:40:23 +0000 (17:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1937130 13f79535-47bb-0310-9956-ffa450edef68

test/pytest_suite/apache_pytest/config.py
test/pytest_suite/conftest.py
test/pytest_suite/t/conf/core.conf.in
test/pytest_suite/tests/t/apache/test_acceptpathinfo.py
test/pytest_suite/tests/t/apache/test_mmn.py
test/pytest_suite/tests/t/modules/test_ratelimit.py
test/pytest_suite/tests/t/modules/test_substitute.py
test/pytest_suite/tests/test_framework_smoke.py

index a0639fcfa329764b6fc202ad0b601e1ff8083c2a..3995cd5753b3ff8c5b5b2707ce72e1baaf6f59d2 100644 (file)
@@ -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("</IfModule>")
         return "\n".join(lines)
 
@@ -845,8 +845,10 @@ class TestConfig:
             # Register the module in the modules set so <VirtualHost mod_X>
             # rewriting recognizes it (TestConfigC.pm:308 $self->{modules}{$cname}=1).
             self.info.modules.add(f"mod_{sym}.c")
-            # so is <src_dir>/.libs/mod_<sym>.so; source is <src_dir>/mod_<sym>.c
+            # so is <src_dir>/.libs/mod_<sym>.so (apxs) or <prefix>/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:
index 8d3fd2111c6f6875f621f318d88338d11b349c81..a0c50fd3f4cf8d7e38e2b6c63cace4f7c5d7c1c0 100644 (file)
@@ -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)
 
index c82f37569af716e5d55d1199297ada69f2747f42..b1e85f8d945f0ee1233ebb3732a8955b15938210 100644 (file)
@@ -4,6 +4,11 @@
 
 MaxMemFree 1
 
+<VirtualHost righthost:core>
+      ServerName righthost
+      ServerAlias Righthost 128.0.0.1
+</VirtualHost>
+
 <VirtualHost strict-default:core>
       ServerName default-strict
       <IfVersion >= 2.4.49>
index a4a07ee06ae4f29800295bf25f9ed3b13f397263..0e1afc55b2fcfd5a8d5dd8e310ffb709e2df9313 100644 (file)
@@ -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.
index de5fc04e18b6b26be3a30a12d1d96e4b33d500ae..341518b980f922d65bfdc92d9d9b4f07f8707979 100644 (file)
@@ -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:
index 737d5f49270360483fcb0cd494a372dd25050953..bcee559afe704dca58ca2db0e6d3594d639941aa 100644 (file)
@@ -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
index 810a6005c423721394076f46eedb354e075131fe..246435f2e2ef76b364e4c8910d0d7163f448124c 100644 (file)
@@ -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):
index d9b0990b0a2c74ce60c6b7c754e09da9e8b24edc..2488a4d3e4025de018a318e1f1d925b9956dfbde 100644 (file)
@@ -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