feat(test): give a test that sets Test::wayland a compositor of its own
A test that opens a window opened it on the display of whoever ran the suite: every `crafter-build test` of Crafter.Graphics put the windows of its window tests on the desktop, and its other GPU tests connect to the session's compositor too, since Device::Initialize calls wl_display_connect whether a window follows or not. A test that sets the new Test::wayland (TestBuilder::Wayland) now runs with a headless compositor started for it alone. RunSingleTest starts the compositor through sh, with XDG_RUNTIME_DIR naming a directory made for it and without WAYLAND_DISPLAY, WAYLAND_SOCKET or DISPLAY, waits up to 30 s for a wayland-<n> socket in that directory, runs the test with WAYLAND_DISPLAY set to the socket's path and with DISPLAY and WAYLAND_SOCKET unset, then stops the compositor's process group and removes the directory. The test's command is env with those changes, and env's command is sh, which execs the test's words: env takes every word with an '=' in it ahead of its command for an assignment, a binary's path among them. The compositor runs under timeout(1) as long as the test may, the wait and 30 s more, and with no limit for a test that has none, a timeout of 0. It is weston on its headless backend with its GL renderer, unless CRAFTER_BUILD_COMPOSITOR or the new --compositor= names another command; `host` gives the tests the session's own display instead, to watch them. A compositor that ends before it listens, sh not finding it included, or does not listen in time fails the test with what it printed. A test that may run where its compositor is missing declares it in requires_ (tool:weston for the default), the check RunTests makes before the build, so no skip of its own is added, and no probe of the command: the command is any sh command, whose first word need not be the compositor. A test that fails, crashes or times out keeps what its compositor printed (TestResult::compositorLog), which RunTests writes to build/test-logs/<name>.compositor.log, and says when the compositor ended while it ran. One compositor per test rather than one per run: no two tests share one, so tests that run at once cannot cover each other's windows or take each other's focus, for weston's start-up on every test. weston's GL renderer, because it imports the dmabufs that a GPU's Vulkan driver presents, as Mesa's and NVIDIA's do, and the headless backend's default renderer and pixman import none: against pixman, the NVIDIA driver reports no format for a window's surface, and Crafter.Graphics's FrameLoopSync stops at its formatCount > 0 assertion. weston cannot run the test itself, as `weston -- <test>` exits 0 whatever the test returned, so crafter-build runs the compositor beside it. :Platform gains BackgroundCommand, the compositor's process, and PrivateDirectory, its directory. The process is forked with PR_SET_PDEATHSIG and runs under `timeout`, which passes the SIGTERM it gets when crafter-build dies on to the compositor's group, so a crafter-build killed by Ctrl-C leaves no compositor running. The directory is made in $XDG_RUNTIME_DIR, or in /tmp where that is not a directory, rather than in the temp directory, since a socket's path holds 107 bytes, and is flocked while in use; one that a killed crafter-build left is removed when the next is made beside it, once it has not changed for a minute. New members and a parameter with a default, nothing removed: a minor release.
This commit is contained in:
parent
cb8914d387
commit
dc8e9e6f9e
7 changed files with 418 additions and 13 deletions
|
|
@ -176,6 +176,11 @@ export namespace Crafter {
|
|||
std::int32_t signal = 0;
|
||||
std::chrono::milliseconds duration{0};
|
||||
std::string output;
|
||||
// What the headless compositor of a test that sets Test::wayland
|
||||
// printed, kept when the test ran and failed, crashed or timed out,
|
||||
// for RunTests to write beside the test's own log. A compositor that
|
||||
// did not start has what it printed in `output`.
|
||||
std::string compositorLog;
|
||||
};
|
||||
|
||||
// One lint diagnostic. Produced by LintContext::Report — or derived by
|
||||
|
|
@ -817,6 +822,19 @@ export namespace Crafter {
|
|||
// unavailable runner becomes a Fail instead of a silent Skip — the
|
||||
// dependency has to be declared to be allowed to be missing.
|
||||
std::vector<std::string> requires_;
|
||||
// The test talks to a Wayland compositor, so every run of it gets one
|
||||
// of its own: a headless compositor started for it alone and stopped
|
||||
// when it ends. The test finds it through WAYLAND_DISPLAY, the full
|
||||
// path of its socket, and runs with DISPLAY unset, so the windows it
|
||||
// opens through WAYLAND_DISPLAY do not reach the session's display.
|
||||
// The compositor is weston on
|
||||
// its headless backend unless --compositor= or CRAFTER_BUILD_COMPOSITOR
|
||||
// names another, or names `host` to give the test the session's own
|
||||
// display. A test whose compositor cannot be started fails, unless it
|
||||
// declares the compositor in requires_ (tool:weston for the default),
|
||||
// which skips it where that is missing. README, "Tests that open
|
||||
// windows".
|
||||
bool wayland = false;
|
||||
};
|
||||
|
||||
// Directory holding the std module PCM for this Configuration,
|
||||
|
|
|
|||
Loading…
Reference in a new issue