test(gateway): isolate the escaping test from the host's installed unit

Gate review: with the installed-unit fallback, the absent-env assertions read the real
~/.config/systemd/user unit (conftest does not redirect HOME).
This commit is contained in:
kshitijk4poor
2026-09-20 16:22:25 +05:30
committed by kshitij
parent 1d7acabc13
commit 05275281d0

View File

@@ -332,9 +332,11 @@ class TestGeneratedSystemdUnits:
assert f"RestartForceExitStatus={GATEWAY_SERVICE_RESTART_EXIT_CODE}" in unit
assert f"RestartPreventExitStatus={GATEWAY_FATAL_CONFIG_EXIT_CODE}" in unit
def test_user_unit_carries_ld_library_path_escaped_for_systemd(self, monkeypatch):
def test_user_unit_carries_ld_library_path_escaped_for_systemd(self, monkeypatch, tmp_path):
"""#14613: glibc reads LD_LIBRARY_PATH only at process start, so the unit file is the
only place it can reach CUDA-backed tools; quotes/backslashes must survive systemd quoting."""
# The absent-env branch falls back to the installed unit: keep the host's real one out.
monkeypatch.setattr(gateway_cli, "get_systemd_unit_path", lambda system=False: tmp_path / "hermes-gateway.service")
monkeypatch.setenv("LD_LIBRARY_PATH", '/opt/cu"da/lib64:/opt/back\\slash/lib')
unit = gateway_cli.generate_systemd_unit(system=False)