mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-20 07:31:39 +01:00
build(nix): a Plasma session node for tests
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.
This commit is contained in:
1 parent
3c51b9b4bf
commit
fec9c2773a
12 files changed
+247
-10
No files matched your search
+30
-1
@@ -48,6 +48,21 @@ place windows and answer questions about them, but it cannot take a screenshot.
|
||||
KWin wants a DRM render node, which needs a GPU. The test driver gives every aarch64 guest one
|
||||
`virtio-gpu-pci`; on x86_64 the node adds it, unless `komorebi.vm.renderNode` is false.
|
||||
|
||||
`session` is the headless node plus a login: plasma-login-manager logs the test
|
||||
user in by itself, as in nixpkgs' own `plasma6` test, and Plasma draws on the
|
||||
machine's display device. It is the node for anything that needs pixels. The
|
||||
choice of login manager is made in
|
||||
[`nodes/session.nix`](../../nix/tests/vm/nodes/session.nix) and nowhere else;
|
||||
the file says how to switch to sddm, the other one that has been seen to work.
|
||||
Its display is 1280x800, because screenshots are taken of the machine's one
|
||||
display device: the `virtio-gpu-pci` that the test driver adds to every aarch64
|
||||
guest, and the default VGA of an x86_64 one. The node sets
|
||||
`komorebi.vm.renderNode` to false, so that an x86_64 guest does not get a second
|
||||
device: KWin would draw on it, and the screenshot would show the other one.
|
||||
|
||||
On aarch64 under HVF, at time of writing (2026-10-27), the session has the
|
||||
Wayland socket after 11 to 19 seconds and a painted desktop after 35 seconds.
|
||||
|
||||
## The library
|
||||
|
||||
Suites import from `komorebi_vm`, in
|
||||
@@ -66,10 +81,24 @@ the run.
|
||||
`outputs` counts the enabled outputs through `kscreen-doctor`, `spawn` starts
|
||||
a client, and `wait_for(predicate, timeout)` polls, with the timeout
|
||||
multiplied by `scale`.
|
||||
- `Kde.session(machine, scale=)` attaches to the session node's own Plasma
|
||||
session once its desktop is up, and `shot(name)` returns a screenshot as a
|
||||
Pillow image, keeping `NAME.png` in the output directory.
|
||||
|
||||
Poll for what the test needs with `wait_for`. A fixed sleep is too long on
|
||||
KVM and too short on TCG.
|
||||
|
||||
Two traps are worth knowing about before writing a screenshot test:
|
||||
|
||||
- A splash screen is not a blank screen. KSplash has more than a thousand colors
|
||||
on it, so "the screenshot is not blank" passes while Plasma is still
|
||||
starting. `Kde.session` waits for the splash process to exit, and a test
|
||||
should check a pixel it knows, such as the middle of a terminal.
|
||||
- NixOS wraps programs, so a process's name is the wrapper's (`.plasmashell-wrapped`),
|
||||
and `pgrep -x plasmashell` never matches. Match the command line instead, with
|
||||
a bracket in the pattern (`pgrep -f '[p]lasmashell'`) so that the shell running
|
||||
`pgrep` does not match itself.
|
||||
|
||||
## Running a test on a Mac
|
||||
|
||||
QEMU has to run on the Mac to use HVF, and the guest is Linux, so the guest's
|
||||
@@ -108,7 +137,7 @@ Add `git add -N` for new files first: a flake only sees files git knows about.
|
||||
|
||||
## Looking inside a failed run
|
||||
|
||||
`nix build -L` prints the guest's console. Run the driver by hand, as
|
||||
`nix build -L` prints the guest's console, and a session test keeps its screenshots. Run the driver by hand, as
|
||||
`scripts/vm-mac` does, to keep the screenshots. For an interactive session
|
||||
build `driverInteractive` instead of `driver`, run it, and call `start_all()`
|
||||
and `machine.shell_interact()` at its prompt. In the guest, KWin's own log is
|
||||
|
||||
Reference in new issue
Block a user