forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_replay_harness_lc3_frame_timing.py
More file actions
71 lines (56 loc) · 2.09 KB
/
Copy pathtest_replay_harness_lc3_frame_timing.py
File metadata and controls
71 lines (56 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Regression coverage for the package-free LC3 replay-oracle runner."""
from __future__ import annotations
import json
import os
from pathlib import Path
import subprocess
from testing.shell import bash_command, bash_path
REPO_ROOT = Path(__file__).resolve().parents[2]
HARNESS_DIR = REPO_ROOT / "backend" / "testing" / "replay_harness_lc3_frame_timing"
RUNNER = HARNESS_DIR / "run.sh"
def _unsupported_uname(tmp_path: Path) -> Path:
"""Provide a deterministic unsupported-host response for the shell runner."""
uname = tmp_path / "uname"
uname.write_text(
"#!/usr/bin/env bash\n"
"if [[ \"${1:-}\" == \"-s\" ]]; then\n"
" printf '%s\\n' Darwin\n"
"elif [[ \"${1:-}\" == \"-m\" ]]; then\n"
" printf '%s\\n' arm64\n"
"else\n"
" exit 64\n"
"fi\n",
encoding="utf-8",
newline="\n",
)
uname.chmod(0o755)
return tmp_path
def test_lc3_replay_runner_fails_closed_on_an_unsupported_host(tmp_path: Path) -> None:
environment = os.environ.copy()
environment["OMI_TEST_FAKE_BIN"] = bash_path(_unsupported_uname(tmp_path), cwd=REPO_ROOT)
completed = subprocess.run(
bash_command(
"-c",
'export PATH="$OMI_TEST_FAKE_BIN:$PATH"\nexec "$BASH" "$@"',
"bash",
RUNNER,
cwd=REPO_ROOT,
),
cwd=REPO_ROOT,
env=environment,
capture_output=True,
check=False,
text=True,
)
assert completed.returncode == 2
assert completed.stdout == ""
assert "requires Linux x86_64" in completed.stderr
assert "unsupported" in completed.stderr
def test_lc3_replay_oracle_is_registered_without_a_private_package_init() -> None:
"""Static repository contract for the dedicated, package-free test runner."""
package = json.loads((REPO_ROOT / "package.json").read_text(encoding="utf-8"))
assert package["scripts"]["test:replay-lc3-frame-timing"] == (
"backend/testing/replay_harness_lc3_frame_timing/run.sh"
)
assert RUNNER.is_file()
assert not (HARNESS_DIR / "__init__.py").exists()