Checks one control module without a window, for the module's own CI. More...
#include <PhosphorControl/ModuleTestHost.h>
Public Member Functions | |
| ModuleTestHost (QString modulePath) | |
| void | setResultTimeoutMs (int ms) |
| How long to wait for a domain's applyResult or discardResult. | |
| void | setStagingDirectory (const QString &directory) |
| Where run() stages its copies: a fresh directory <directory>/module-test-XXXXXX/, removed when run() returns, whose control/ holds the module as module.so and the target modules as target-000.so onwards, whatever their files are called. | |
| void | addTargetModule (const QString &modulePath) |
Offer the module at modulePath too, so the module under test's extensions aimed at it, and its search entries on that module's pages, are checked against what its metadata declares. | |
| void | setPreviousAnchors (const QString &anchorsPath) |
| The anchors.json of the module's previous release (phosphor_add_control_module_metadata's MODULE_ANCHORS_FILE), which holds each page's anchors, its anchors version and the versions of its named extension points. | |
| QStringList | run () |
| Every problem found, one line each. Empty means the module passes. | |
Static Public Attributes | |
| static constexpr int | DefaultResultTimeoutMs = 2000 |
Checks one control module without a window, for the module's own CI.
Lives in the PhosphorControl::PhosphorControlTest library.
run() copies the module library, and every target module (addTargetModule()), into a private search path, hosts them in a ModuleHost over a fresh ApplicationController, loads the module, and checks that:
When the module is refused, its metadata is invalid or it does not load, run() reports that and stops, since the later checks need a loaded module. The checks after loading all run and report together. A problem with a target module is reported too, by the path it was added with, and the run goes on without it: a target the catalog refuses, and one whose id is the module's or another target's, which is left out.
The apply and discard round runs on freshly loaded, clean state, which is not how the host drives a domain: it applies dirty domains only. It catches a domain that answers twice or not at all, not one whose dirty path misbehaves, so cover that in the module's own tests.
run() does not write the settings files the module opens through ModuleContext::configBackend, as long as the module's factory opens the path it is handed. It makes each of them under its staging directory instead (ModuleHost::setConfigRedirect), so the module starts from an empty file and its defaults, and the files go when run() returns. Anything else a domain's apply() writes (a file the module opens by itself, a call to a daemon) still goes where the module sends it, so point that at a scratch target first.
Needs a QCoreApplication (or QGuiApplication) running on this thread.
|
explicit |
| void PhosphorControl::ModuleTestHost::addTargetModule | ( | const QString & | modulePath | ) |
Offer the module at modulePath too, so the module under test's extensions aimed at it, and its search entries on that module's pages, are checked against what its metadata declares.
A target is never loaded, and its own metadata and extensions are not checked.
|
nodiscard |
Every problem found, one line each. Empty means the module passes.
| void PhosphorControl::ModuleTestHost::setPreviousAnchors | ( | const QString & | anchorsPath | ) |
The anchors.json of the module's previous release (phosphor_add_control_module_metadata's MODULE_ANCHORS_FILE), which holds each page's anchors, its anchors version and the versions of its named extension points.
| void PhosphorControl::ModuleTestHost::setResultTimeoutMs | ( | int | ms | ) |
How long to wait for a domain's applyResult or discardResult.
Zero or negative restores DefaultResultTimeoutMs.
| void PhosphorControl::ModuleTestHost::setStagingDirectory | ( | const QString & | directory | ) |
Where run() stages its copies: a fresh directory <directory>/module-test-XXXXXX/, removed when run() returns, whose control/ holds the module as module.so and the target modules as target-000.so onwards, whatever their files are called.
A relative directory is taken against the working directory of run(). Default: QDir::tempPath(). Pick a directory on a filesystem that allows executing libraries when /tmp is mounted noexec. A module that finds its own libraries through an $ORIGIN rpath needs them reachable from that copy, or an absolute rpath.
|
staticconstexpr |