Skip to content

Improve tests for execution in sandboxed environments - #4

Merged
haxtibal merged 11 commits into
mainfrom
tdmg/test_improvements
Sep 8, 2026
Merged

Improve tests for execution in sandboxed environments#4
haxtibal merged 11 commits into
mainfrom
tdmg/test_improvements

Conversation

@haxtibal

@haxtibal haxtibal commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

The main driver for this series is to enable idiomatic testing with Debian pybuild / autopkgtest.

@haxtibal
haxtibal requested a review from koalo September 4, 2026 17:45
@haxtibal
haxtibal force-pushed the tdmg/test_improvements branch from 4a03cf5 to d5082db Compare September 7, 2026 08:15
Comment thread test/conftest.py
)
monkeypatch.setenv("SOFTHSM2_CONF", str(conf_file))

openssl_conf = tmp_path / "openssl.cnf"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is great! The test should not rely on systemwide settings.

@haxtibal
haxtibal force-pushed the tdmg/test_improvements branch from d5082db to 9e03fa5 Compare September 7, 2026 13:41
c47cc10 ("signers: protect from in-place overwrite") added a new
attribute force_overwrite, but test_uefi_variable_sign_cli was not
updated to initialize it. The test crashes since then.

Initialize the attribute now to fix the test.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
This prevents using systemwide /etc/softhsm2.conf and
/etc/ssl/openssl.conf in tests to limit side effects of system
configuration to test execution and vice versa.

It comes with a workaround for SoftHSMv2 (exclude digest calculation
from pkcs11 operations), because SoftHSMv2 is known to cause deadlock if
used along with pkcs11-provider. The workaround mitigates it. See for
example see openssl-projects/pkcs11-provider#634 for details.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
Test environments should have the ability to control where build
artifacts are generated. Enable this by evaluating make BUILD_DIR=...
and pytest --build-dir=...

Artifact paths are communicated to tests through fixtures that also
assert existence of the required input artifacts.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
debsign was only tested against debian.org, which is good as
compatibility evidence. But it's not suitable for frequent integration
test suite and the referenced packages may vanish from the external
archive (replaced by newer versions).

Now tests create their own deterministic input apt archive consisting of
a minimal Debian package, containing minimal signables and a signed
template package. Integration tests can now run without external
dependencies.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
The previous unit / integration grouping was not sufficient when
distributions want to replay the tests in their restricted environment.

Let's categorize as follows:
- Unit tests: Fast, no system dependencies. Suitable to run for TDD and
  on every build.
- Integration tests: Slower, system dependencies. Suitable to run as
  regression tests.
- Live tests: Test against external services for compatibility. Not
  suited for isolated environments, maybe unstable.

The tests can be started with invoke tu / ti / tl.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
pkcs11-tool (opensc) and p11tool (gnutls-bin) have comparable
functionality. p11tool is already used by the production code and
support PKCS11 URIs. Thus replace pkcs11-tool entirely.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
The path to sign-file was as a fallback derived from the running kernel
version. However, on sandboxed systems installed kernel and running
kernel may differ.

It is more reliable to require explicit pytest --sign-file-path=...

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
The path to the module build infrastructure was derived from the running
kernel version. However, on sandboxed systems installed kernel and
running kernel may differ.

Searching in the well known directory is more reliable. Where tighter
control is needed, users can explicitly define the path with make -C
KDIR=...

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
test_swu_sign relied on a committed .swu file as test input. We
generally want to avoid committed blobs. Build the artifact with
swugenerator from textual input instead.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
@haxtibal
haxtibal force-pushed the tdmg/test_improvements branch from 9e03fa5 to 923c029 Compare September 7, 2026 15:00
test_cert_from_file doesn't rely on real certificates from the system
bundle. It just needs *some* file to test lookup when the URI ist not
pkcs11 scheme.

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Reviewed-by: Florian Kauer <florian.kauer@linutronix.de>
@haxtibal
haxtibal force-pushed the tdmg/test_improvements branch from 6156e39 to a097827 Compare September 8, 2026 07:33
@haxtibal
haxtibal merged commit c7c44f5 into main Sep 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants