47 lines
2.4 KiB
Python
47 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2026 Storm Dragon
|
|
# Authors: Storm Dragon, Angus Kola
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Exercise quarantined destination-key ownership on a private Xvfb server."""
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
from native_test_session import run_private_session
|
|
|
|
|
|
def main():
|
|
for program in ("xvfb-run", "dbus-run-session", "setxkbmap", "go"):
|
|
if shutil.which(program) is None:
|
|
raise RuntimeError(f"Required private-test dependency is missing: {program}")
|
|
root = Path(__file__).resolve().parents[1]
|
|
with tempfile.TemporaryDirectory(prefix="cthulhu-remote-key-helper-") as temporary:
|
|
helper = str(Path(temporary) / "cthulhu-input-helper")
|
|
owner_test = str(Path(temporary) / "app.test")
|
|
environment = dict(os.environ, CTHULHU_NATIVE_REMOTE_KEYS="1",
|
|
CTHULHU_REMOTE_INPUT_HELPER=helper,
|
|
CTHULHU_REMOTE_OWNER_TEST=owner_test,
|
|
GOCACHE="/tmp/cthulhu-cache", GOPROXY="off")
|
|
subprocess.run(["go", "build", "-race", "-o", helper, "./cmd/cthulhu-input-helper"],
|
|
cwd=root, env=environment, check=True)
|
|
subprocess.run(["go", "test", "-c", "-race", "-o", owner_test, "./internal/app"],
|
|
cwd=root, env=environment, check=True)
|
|
command = ["xvfb-run", "-a", "-s", "-screen 0 1024x768x24", "dbus-run-session", "--",
|
|
"go", "test", "-race", "./internal/platform/xorg", "-count=1", "-timeout=90s",
|
|
"-run", "^TestNativeRemoteKey(Target|Helper)", "-v"]
|
|
run_private_session(command, env=environment, cwd=root, check=True)
|
|
owner_command = ["xvfb-run", "-a", "-s", "-screen 0 1024x768x24", "dbus-run-session", "--",
|
|
"go", "test", "-race", "./internal/app", "-count=1", "-timeout=90s",
|
|
"-run", "^TestNativeRemoteKeyboardOwner$", "-v"]
|
|
run_private_session(owner_command, env=environment, cwd=root, check=True)
|
|
crash_command = ["xvfb-run", "-a", "-s", "-screen 0 1024x768x24", "dbus-run-session", "--",
|
|
sys.executable, "-B", "tests/remote_keyboard_owner_crash.py"]
|
|
return run_private_session(crash_command, env=environment, cwd=root, check=True).returncode
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|