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)
# 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:
# 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
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)
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>
@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.
@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:
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
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):
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