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
|
|
@ -2949,6 +2949,13 @@ Test options (after the `test` subcommand):
|
|||
--runner=<spec> Override the test runner for this run. Specs:
|
||||
local
|
||||
cmd:<command> (e.g. cmd:wine)
|
||||
--compositor=<command> The headless Wayland compositor each test that sets
|
||||
Test::wayland runs with, a command run through sh
|
||||
that listens on a wayland-<n> socket in the
|
||||
XDG_RUNTIME_DIR it is given. Default: weston
|
||||
--backend=headless --renderer=gl --no-config
|
||||
--idle-time=0. `host` runs those tests on this
|
||||
session's own display.
|
||||
--target=<triple> Filter to tests whose cfg.target matches. Default:
|
||||
sweep across every distinct target declared by the
|
||||
project's tests plus the host triple.
|
||||
|
|
@ -3052,6 +3059,9 @@ Environment:
|
|||
CRAFTER_BUILD_RUNNER_<TARGET> Default test runner for a target triple.
|
||||
Replace '-' and '.' with '_' in the
|
||||
triple. CLI --runner= overrides this.
|
||||
CRAFTER_BUILD_COMPOSITOR Default headless Wayland compositor for
|
||||
tests that set Test::wayland, as for
|
||||
--compositor=, which overrides it.
|
||||
CRAFTER_BUILD_LLVM_DIR LLVM prefix to use instead of a toolchain
|
||||
installed beside crafter-build or PATH.
|
||||
CRAFTER_BUILD_LIBCXX_DIR libc++ install to compile and link against
|
||||
|
|
@ -3175,6 +3185,8 @@ std::int32_t Crafter::Run(std::int32_t argc, char** argv) {
|
|||
testOpts.listOnly = true;
|
||||
} else if (verb == Verb::Test && arg.starts_with("--runner=")) {
|
||||
testOpts.runnerOverride = std::string(arg.substr(std::string_view("--runner=").size()));
|
||||
} else if (verb == Verb::Test && arg.starts_with("--compositor=")) {
|
||||
testOpts.compositorOverride = std::string(arg.substr(std::string_view("--compositor=").size()));
|
||||
} else if (verb == Verb::Test && !arg.starts_with("-")) {
|
||||
testOpts.globs.emplace_back(arg);
|
||||
} else if ((verb == Verb::Lint || verb == Verb::Format) && arg == "--list") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue