Slice A renamed the runtime directory in the module, but the old path was still live in the code and checks it does not own, so the VM gates pointed at a directory the module no longer creates. This moves the 21 remaining live occurrences (client/server defaults, the unit tests that pin them, all three VM checks, the diagnostics script, both READMEs) and deliberately leaves the three mentions that are history rather than configuration: the plan's problem statement, module.nix's note about the previous name, and cli.py's explanation for spelling its default out. Also here: docs/CONTRACT-sessions.md is now v2 with every gap the four slices reported resolved as a decision (Monitor.id, stable_id, pid -1, Event.data, mark(), the quarantine argv type, the corrected wlr XML path, and the state dir/frame socket rows), and docs/CONTRACT.md is v2 because its documented socket default moved -- wire format unchanged. Two comments that stated the old, wrong diagnosis (a 'misnamed' IPC socket) now state the measured one: the event socket did not fit in sun_path.
162 lines
5.8 KiB
Nix
162 lines
5.8 KiB
Nix
# checks.<system>.vm-basic -- boot a real machine with the module enabled, point
|
|
# `captureCommand` at a fake capture program, and read the socket.
|
|
#
|
|
# This check is about the module's wiring and the wire contract, not about
|
|
# Hyprland: the fake capture emits one fixed PNG, so "two frames arrived and
|
|
# they are the same image" is a real assertion rather than a coincidence.
|
|
{
|
|
testers,
|
|
hhstream,
|
|
testTools,
|
|
python3,
|
|
hhsModule,
|
|
width ? 1280,
|
|
height ? 720,
|
|
fps ? 30,
|
|
socketPath ? "/run/hypr-stream/stream.sock",
|
|
}:
|
|
testers.runNixOSTest {
|
|
name = "hhstream-vm-basic";
|
|
|
|
# KVM is available, so this is a minute or two; cap it so a hang is a failure
|
|
# rather than a wedged builder.
|
|
globalTimeout = 900;
|
|
|
|
nodes.machine = {
|
|
# gpu-session.nix is what makes the compositor able to start at all; see
|
|
# that file for the two pieces of hardware a bare test machine is missing
|
|
# (the third thing it used to carry, SEATD_VTBOUND=0, is in nix/module.nix
|
|
# now -- it is a property of the session, not of the test machine).
|
|
imports = [ hhsModule ./lib/gpu-session.nix ];
|
|
|
|
services.hyprland-headless-stream = {
|
|
enable = true;
|
|
# The module declares `package` with no default (see README.dev.md), so the
|
|
# test has to supply the flake's build.
|
|
package = hhstream;
|
|
inherit socketPath;
|
|
frameRate = fps;
|
|
format = "png";
|
|
# The fake capture fixes the frame size, so the monitor rule does not
|
|
# matter here -- but it must not be a name no connector has either, or
|
|
# this file would keep advertising a shape that does nothing.
|
|
outputs = [
|
|
{
|
|
inherit width height;
|
|
refresh = fps;
|
|
}
|
|
];
|
|
captureCommand = [
|
|
"${testTools}/bin/hhs-fake-capture"
|
|
"--width"
|
|
(toString width)
|
|
"--height"
|
|
(toString height)
|
|
];
|
|
};
|
|
|
|
environment.systemPackages = [
|
|
testTools
|
|
hhstream
|
|
# The "client dying mid-stream" subtest opens the socket from a python
|
|
# one-liner in the guest. hhstream's own interpreter is reachable only
|
|
# through its wrapper, so without this the subtest dies on exit code 127
|
|
# (`python3: command not found`) rather than on anything it asserts.
|
|
python3
|
|
];
|
|
|
|
# Mesa and the compositor together need more than the fake capture alone
|
|
# did; the GPU itself comes from gpu-session.nix.
|
|
virtualisation = {
|
|
memorySize = 2048;
|
|
cores = 2;
|
|
diskSize = 4096;
|
|
graphics = false;
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
SOCKET = "${socketPath}"
|
|
ASSERT = "hhs-assert-stream --socket " + SOCKET
|
|
|
|
|
|
def dump(label):
|
|
print(f"########## diagnostics: {label} ##########")
|
|
status, out = machine.execute("hhs-hyprland-diagnostics", timeout=120)
|
|
print(out)
|
|
print(f"########## end diagnostics (exit {status}) ##########")
|
|
|
|
|
|
start_all()
|
|
|
|
with subtest("the module's two units come up"):
|
|
try:
|
|
machine.wait_for_unit("hyprland-headless.service", timeout=120)
|
|
machine.wait_for_unit("hyprland-headless-stream.service", timeout=120)
|
|
except Exception:
|
|
dump("units did not start")
|
|
raise
|
|
|
|
with subtest("the socket exists, owned by the service user, mode 0660"):
|
|
try:
|
|
machine.wait_for_file(SOCKET, timeout=60)
|
|
print(machine.succeed(f"stat -c 'owner=%U group=%G mode=%a type=%F' {SOCKET}"))
|
|
machine.succeed(f"[ \"$(stat -c %a {SOCKET})\" = 660 ]")
|
|
machine.succeed(f"[ \"$(stat -c %U {SOCKET})\" = hhstream ]")
|
|
machine.succeed(f"[ \"$(stat -c %G {SOCKET})\" = hhstream ]")
|
|
machine.succeed(f"[ \"$(stat -c %F {SOCKET})\" = socket ]")
|
|
except Exception:
|
|
dump("socket missing or wrong ownership")
|
|
raise
|
|
|
|
with subtest("the Hello parses, magic is HHS1, size is non-zero"):
|
|
try:
|
|
print(machine.succeed(f"{ASSERT} --frames 1 --timeout 30"))
|
|
except Exception:
|
|
dump("Hello did not parse")
|
|
raise
|
|
|
|
with subtest("two frames arrive, non-empty, byte-identical, matching the Hello"):
|
|
try:
|
|
print(
|
|
machine.succeed(
|
|
f"{ASSERT} --frames 2 --timeout 60"
|
|
" --expect-width ${toString width} --expect-height ${toString height}"
|
|
" --expect-format image/png --expect-fps ${toString fps}"
|
|
" --require-png --identical-frames --min-bytes 1"
|
|
)
|
|
)
|
|
except Exception:
|
|
dump("frames did not satisfy the contract")
|
|
raise
|
|
|
|
with subtest("two clients are served concurrently and independently"):
|
|
try:
|
|
print(
|
|
machine.succeed(
|
|
f"{ASSERT} --frames 3 --timeout 60 --require-png > /tmp/a.log 2>&1 & p1=$!; "
|
|
f"{ASSERT} --frames 3 --timeout 60 --require-png > /tmp/b.log 2>&1 & p2=$!; "
|
|
"wait $p1; r1=$?; wait $p2; r2=$?; "
|
|
"echo '--- client a ---'; cat /tmp/a.log; "
|
|
"echo '--- client b ---'; cat /tmp/b.log; "
|
|
"exit $((r1 + r2))"
|
|
)
|
|
)
|
|
except Exception:
|
|
dump("concurrent clients were not both served")
|
|
raise
|
|
|
|
with subtest("a client dying mid-stream leaves the server serving"):
|
|
try:
|
|
machine.succeed(
|
|
"timeout 5 python3 -c 'import socket;"
|
|
f"s=socket.socket(socket.AF_UNIX);s.connect(\"{SOCKET}\");s.recv(1);s.close()'"
|
|
)
|
|
print(machine.succeed(f"{ASSERT} --frames 2 --timeout 60 --require-png"))
|
|
machine.succeed("systemctl is-active hyprland-headless-stream.service")
|
|
except Exception:
|
|
dump("server did not survive a client dying mid-frame")
|
|
raise
|
|
'';
|
|
}
|