test: retain wrapped browser processes
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
from __future__ import annotations
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).parents[1]
|
||||
@@ -124,3 +127,54 @@ def test_runtime_requires_process_baseline_after_cdp_close_and_zero_stopped_pid(
|
||||
assert ready_index < baseline_index < close_index < return_index
|
||||
assert "{{.State.Pid}}" in runtime_test
|
||||
assert '[ "$state" = "exited 0 0" ]' in runtime_test
|
||||
|
||||
|
||||
def test_runtime_process_normalization_retains_every_unknown_wrapped_child(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
runtime_test = ROOT / "tests/test_runtime.sh"
|
||||
top_file = tmp_path / "docker-top.txt"
|
||||
environment = os.environ.copy()
|
||||
environment.update(
|
||||
{
|
||||
"DOCKER_HOST": "unix:///nonexistent-runtime-normalization.sock",
|
||||
"SKIP_BUILD": "1",
|
||||
}
|
||||
)
|
||||
service_lines = [
|
||||
"101 /run/rosetta/rosetta /usr/local/bin/python3 python3 /usr/local/bin/addon-supervisor",
|
||||
"102 /run/rosetta/rosetta /usr/local/bin/python3 python3 /usr/local/bin/cloakserve --headless=true --idle-timeout=30 --data-dir=/tmp/cloakserve",
|
||||
"103 /usr/bin/qemu-x86_64-static /usr/local/bin/stelloauth",
|
||||
]
|
||||
|
||||
def normalize(extra_line: str | None = None) -> list[str]:
|
||||
lines = ["PID COMMAND", *service_lines]
|
||||
if extra_line is not None:
|
||||
lines.append(extra_line)
|
||||
top_file.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
completed = subprocess.run(
|
||||
[str(runtime_test), "--normalize-processes", str(top_file)],
|
||||
cwd=ROOT,
|
||||
env=environment,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
assert completed.returncode == 0, completed.stderr
|
||||
return completed.stdout.splitlines()
|
||||
|
||||
baseline = ["addon-supervisor", "cloakserve", "stelloauth"]
|
||||
assert normalize() == baseline
|
||||
|
||||
wrapped_children = [
|
||||
"/run/rosetta/rosetta /opt/vendor/headless-shell --user-data-dir=/tmp/profile",
|
||||
"/run/rosetta/rosetta /opt/vendor/browser --profile runtime-readiness",
|
||||
"/run/rosetta/rosetta /opt/vendor/crashpad_handler --database=/tmp/profile",
|
||||
"/run/rosetta/rosetta /opt/vendor/opaque-child --flag",
|
||||
"/run/rosetta/rosetta /opt/vendor/opaque-child --parent=/usr/local/bin/cloakserve",
|
||||
"/usr/bin/qemu-x86_64-static /opt/vendor/opaque-qemu-child",
|
||||
]
|
||||
for offset, child in enumerate(wrapped_children, start=104):
|
||||
normalized = normalize(f"{offset} {child}")
|
||||
assert normalized == sorted([*baseline, f"unexpected:{child}"])
|
||||
assert normalized != baseline
|
||||
|
||||
Reference in New Issue
Block a user