mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-28 11:22:47 +01:00
A virtual KWin has no output to draw on, so every test about pixels, and later about the pointer, needs a real session. The `session` node is the headless node plus a login: plasma-login-manager logs the test user in by itself, the way nixpkgs' own `plasma6` test does, and Plasma draws on the machine's display. The choice of login manager is made in `nodes/session.nix` and nowhere else, and the file says how to switch to sddm. The node adds no display device. The test driver gives every aarch64 guest one virtio-gpu and takes screenshots of it; a second device is a second KWin output that screenshots never show, which is what a first attempt did (a blank 1280x800 console). `Kde.session` attaches to the session once the desktop is up: the shell is running, the user manager knows the Wayland display, and the splash screen has gone. The display is read from the user manager because plasma-login-manager's greeter has its own KWin and takes `wayland-0`, and the user's session gets `wayland-1`. The splash condition is there because KSplash has over a thousand colors on it, so a "not blank" check passed on the splash screen. NixOS wraps programs, which is why processes are found by their command lines: `pgrep -x plasmashell` never matches `.plasmashell-wrapped`, and an exact match for the splash would have passed because nothing matched. `Kde.shot` returns a screenshot as a Pillow image. `vm-render-smoke` is the first slow suite: it starts a session, opens a terminal, and checks the middle of the window is dark and that the desktop behind it has thousands of colors. On aarch64 under HVF five runs gave the same screenshot, with the desktop up after 34 seconds. docs/dev/vm-tests.md describes the node and the two traps.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""The part of the NixOS test driver's `Machine` that the library uses.
|
|
|
|
The driver's own class is not importable outside a test run, so the library
|
|
depends on this protocol instead, and its unit tests pass a fake. The methods
|
|
take only what the library passes; the driver's accept more (a timeout, whether
|
|
to check the exit status), which does not stop its class from satisfying the
|
|
protocol.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from typing import Protocol
|
|
|
|
|
|
class Machine(Protocol):
|
|
"""A virtual machine the test can run commands on, as root."""
|
|
|
|
@property
|
|
def out_dir(self) -> Path:
|
|
"""The directory that screenshots and other artifacts go to."""
|
|
...
|
|
|
|
def execute(self, command: str, /) -> tuple[int, str]:
|
|
"""Runs `command` and returns its exit status and its output."""
|
|
...
|
|
|
|
def succeed(self, *commands: str) -> str:
|
|
"""Runs each command and fails the test unless it exits with status 0."""
|
|
...
|
|
|
|
def fail(self, *commands: str) -> str:
|
|
"""Runs each command and fails the test if it exits with status 0."""
|
|
...
|
|
|
|
def screenshot(self, filename: str, /) -> None:
|
|
"""Saves a PNG of the machine's display as `filename` in `out_dir`."""
|
|
...
|