test: retain wrapped browser processes

This commit is contained in:
Dennis Juhler Aagaard
2026-09-24 18:21:05 +02:00
parent f231792fbb
commit 529c6b5982
2 changed files with 107 additions and 17 deletions
+53 -17
View File
@@ -108,10 +108,8 @@ wait_ready() {
fail "$container did not become ready within 90 seconds"
}
normalized_process_commands() {
local container="$1"
local top_file="${tmp_dir}/${container}-processes.txt"
docker top "$container" -eo pid,args > "$top_file"
normalize_process_file() {
local top_file="$1"
python3 - "$top_file" <<'PY'
import pathlib
import sys
@@ -120,20 +118,44 @@ commands = []
for raw_line in pathlib.Path(sys.argv[1]).read_text(encoding="utf-8").splitlines()[1:]:
fields = raw_line.split(maxsplit=1)
command = " ".join(fields[1].split()) if len(fields) == 2 else ""
lowered = command.lower()
if "/usr/local/bin/addon-supervisor" in command:
commands.append("addon-supervisor")
elif "/usr/local/bin/cloakserve" in command:
commands.append("cloakserve")
elif "/usr/local/bin/stelloauth" in command:
commands.append("stelloauth")
elif (
("/run/rosetta/rosetta" in lowered or "qemu-" in lowered)
and "chrome" not in lowered
and "chromium" not in lowered
and "headless_shell" not in lowered
tokens = command.split()
while tokens and (
tokens[0] == "/run/rosetta/rosetta"
or pathlib.Path(tokens[0]).name.startswith("qemu-")
):
continue
tokens = tokens[1:]
python_prefixes = (
[],
["python3"],
["/usr/local/bin/python3"],
["/usr/local/bin/python3", "python3"],
)
supervisor_commands = [
[*prefix, "/usr/local/bin/addon-supervisor"]
for prefix in python_prefixes
]
cloak_commands = [
[
*prefix,
"/usr/local/bin/cloakserve",
"--headless=true",
"--idle-timeout=30",
"--data-dir=/tmp/cloakserve",
]
for prefix in python_prefixes
]
stelloauth_commands = (
["/usr/local/bin/stelloauth"],
["/usr/local/bin/stelloauth", "/usr/local/bin/stelloauth"],
)
if tokens in supervisor_commands:
commands.append("addon-supervisor")
elif tokens in cloak_commands:
commands.append("cloakserve")
elif tokens in stelloauth_commands:
commands.append("stelloauth")
elif command:
commands.append(f"unexpected:{command}")
@@ -141,6 +163,13 @@ print("\n".join(sorted(commands)))
PY
}
normalized_process_commands() {
local container="$1"
local top_file="${tmp_dir}/${container}-processes.txt"
docker top "$container" -eo pid,args > "$top_file"
normalize_process_file "$top_file"
}
capture_process_baseline() {
local container="$1"
local expected current
@@ -317,6 +346,13 @@ PY
[ "$state" = "exited 0 0" ] || fail "$container state is $state, want exited 0 with PID 0"
}
if [ "${1:-}" = "--normalize-processes" ]; then
[ "$#" -eq 2 ] || fail "--normalize-processes requires one docker top file"
normalize_process_file "$2"
exit
fi
[ "$#" -eq 0 ] || fail "unexpected runtime test arguments"
mkdir -p "$artifacts_dir"
write_options