Skip to content

Commit 421f165

Browse files
author
johndoe
committed
Test: deny /proc in health test so the bridge gap-fill runs everywhere
The test assumed no /proc/uptime (true on macOS, false on Linux CI), so the runner's real uptime beat the bridge value. Now it denies /proc like Android does and the expectation holds on any host.
1 parent e0393e7 commit 421f165

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎app/src/main/python/androidtv/tests/test_tv.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,29 @@ def boom():
308308

309309

310310
def test_android_health_adds_model_and_temp(monkeypatch) -> None:
311+
import builtins
312+
311313
import androidtv.compat as compat_mod
312314

313315
monkeypatch.setattr(compat_mod, "_android_temperature", lambda: 36.6)
316+
# Deny /proc like Android (and macOS) do: the bridge must fill the
317+
# uptime gap. Without this the test reads the host's real uptime on
318+
# Linux and the bridge value never applies.
319+
real_open = builtins.open
320+
321+
def no_proc(path, *args, **kwargs):
322+
if str(path).startswith("/proc/"):
323+
raise PermissionError(f"denied: {path}")
324+
return real_open(path, *args, **kwargs)
325+
326+
monkeypatch.setattr(builtins, "open", no_proc)
314327
ex = AndroidExecutor(android_account("/tmp"), FakeTv())
315328
reply = ex.run("device.health", {})
316329
assert reply["ok"] is True, reply
317330
payload = reply["payload"]
318331
assert payload["model"] == "Fake TV / android 12 (sdk 31)"
319332
assert payload["temperature_c"] == 36.6
320-
assert payload["uptime_s"] == 12345 # Mac has no /proc/uptime either
333+
assert payload["uptime_s"] == 12345
321334
assert "version" in payload
322335

323336

0 commit comments

Comments
 (0)