From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Baptiste Le Duc <baptiste.le-duc@vates.tech>,
xen-devel@lists.xenproject.org
Cc: Doug Goldstein <cardoe@cardoe.com>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v2 4/6] automation/qtb: add unit tests for the QTB framework
Date: Tue, 27 Oct 2026 17:51:00 +0100 [thread overview]
Message-ID: <5ada3d12-5569-4e14-8178-815da3665a52@gmail.com> (raw)
In-Reply-To: <1787823789.8631fc262581453bbf619ec5b2062170.1a0429a13b8000c4f3@vates.tech>
On 8/27/26 11:42 AM, Baptiste Le Duc wrote:
> The QTB framework is meant to be extended: new test types, new machines and
> new device trees aim to be added by other people.
>
> Add pytest coverage of the framework's functions, and of the console-test
> type's config validation and expect/retry loop, so that such changes get
> immediate feedback and existing behaviour does not silently regress.
Nothing runs these tests, though: there is no CI job for them, and the
container from patch 1 doesn't even have pytest. So the feedback only
comes if whoever changes the framework has pytest and the QTB fork
installed locally and remembers to run them.
Probably, we want to consider to have a separate job for that (mainly
question to CI maintainers then)?
Nit: probably "immedidate feedback" will be clearer if this part ...
>
> The suite covers 100% of the framework's statements, so a new code path
> added without a test shows up as a coverage drop.
Running the suggested pytest-cov command gives 99% here:
Name Stmts Miss
Cover Missing
-----------------------------------------------------------------------------------------
...
automation/scripts/qtb/riscv/paths.py 32 1
97% 50
...
automation/scripts/qtb/riscv/xen_dt.py 26 1
96% 21
-----------------------------------------------------------------------------------------
TOTAL 592 2
99%
============================== 51 passed in 0.22s
==============================
Not a problem as
such, but the commit message shouldn't claim 100%.
>
> The tests are meant to be run locally, from the Xen tree root:
... and part below will be moved up.>
> python3 -m pytest automation/scripts/qtb/riscv/unit/
>
> and, with pytest-cov installed, the coverage report is:
>
> python3 -m pytest --cov=automation/scripts/qtb \
> automation/scripts/qtb/riscv/unit/
>
> The tests drive fakes rather than QEMU, so they need no artifacts to run.
>
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Baptiste Le Duc <baptiste.le-duc@vates.tech>
> ---
> automation/scripts/qtb/riscv/unit/__init__.py | 2 +
> automation/scripts/qtb/riscv/unit/conftest.py | 42 ++++
> .../scripts/qtb/riscv/unit/test_config.py | 121 ++++++++++
> .../qtb/riscv/unit/test_console_test.py | 217 ++++++++++++++++++
> automation/scripts/qtb/riscv/unit/test_dt.py | 99 ++++++++
> .../scripts/qtb/riscv/unit/test_machine.py | 60 +++++
> .../scripts/qtb/riscv/unit/test_temp_dir.py | 42 ++++
> .../scripts/qtb/riscv/unit/test_xen_dt.py | 46 ++++
> 8 files changed, 629 insertions(+)
[...]
> diff --git a/automation/scripts/qtb/riscv/unit/test_machine.py b/automation/scripts/qtb/riscv/unit/test_machine.py
> new file mode 100644
> index 0000000000..68a1564072
> --- /dev/null
> +++ b/automation/scripts/qtb/riscv/unit/test_machine.py
> @@ -0,0 +1,60 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +"""Unit tests for RiscvTestMachine QEMU argument assembly."""
> +
> +from __future__ import annotations
> +
> +from stat import S_IEXEC
> +from unittest import mock
> +
> +from ..machine import RiscvTestMachine
> +from ..config import MACHINE_MEMORY, BinariesConfig
> +
> +
> +def _binaries(tmp_path):
> + xen = tmp_path / "xen"
> + xen.write_bytes(b"")
> + return BinariesConfig(xen=xen)
> +
> +
> +def _machine(mc) -> RiscvTestMachine:
> + """Build the machine with QtbMachine.__init__ stubbed out (it spawns QEMU)."""
> + with mock.patch("qemu.qtb.QtbMachine.__init__", return_value=None):
> + return RiscvTestMachine(mc, timeout=30)
> +
> +
> +def test_init_forwards_cpus_to_qtbmachine(tmp_path, make_machine):
> + mc = make_machine(name="machine", binaries=_binaries(tmp_path))
> +
> + with mock.patch("qemu.qtb.QtbMachine.__init__", return_value=None) as base_init:
> + vm = RiscvTestMachine(mc, timeout=30, log_dir="/logs")
> +
> + assert vm.machine_conf is mc
> + assert base_init.call_args.kwargs == {
> + "memory": MACHINE_MEMORY,
> + "cpus": mc.pcpu,
> + "mirror_console": False,
> + "timeout": 30,
> + "log_dir": "/logs",
> + }
Many of the tests check how the code is written rather than what it
does: the exact keyword arguments passed to QtbMachine.__init__() here,
the exact dtc argv in test_dt.py, the number of expect_exact() calls of
the attempts loop in test_console_test.py. With everything else mocked
out, these mostly restate the implementation, so each change asked for
in review of patch 3 (mirroring the console, dropping attempts, ...)
has to be repeated here, without the tests catching anything real in
between.
FWIW, all 51 tests pass for me (Debian trixie container from patch 1
plus python3-pytest).
~ Oleksii
next prev parent reply other threads:[~2026-10-27 16:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 9:35 [PATCH v2 0/6] automation: add QTB test framework for riscv64 smoke tests Baptiste Le Duc
2026-08-27 9:42 ` [PATCH v2 1/6] Add a QTB container to run the Xen riscv64 tests Baptiste Le Duc
2026-10-22 13:28 ` Oleksii Kurochko
2026-10-28 10:29 ` Anthony PERARD
2026-10-29 15:53 ` Baptiste Le Duc
2026-10-29 15:47 ` Baptiste Le Duc
2026-08-27 9:42 ` [PATCH v2 2/6] automation/qtb: add jinja2 device trees for riscv64 smoke tests Baptiste Le Duc
2026-09-10 10:00 ` Zhang Zheng
2026-09-10 11:28 ` Baptiste Le Duc
2026-09-21 14:08 ` Alejandro Vallejo
2026-09-22 11:13 ` Baptiste Le Duc
2026-10-22 14:01 ` Oleksii Kurochko
2026-08-27 9:42 ` [PATCH v2 3/6] automation/qtb: add Python QTB framework with the console-test type Baptiste Le Duc
2026-10-22 15:15 ` Oleksii Kurochko
2026-10-28 9:49 ` Anthony PERARD
2026-10-28 17:09 ` Baptiste Le Duc
2026-08-27 9:42 ` [PATCH v2 4/6] automation/qtb: add unit tests for the QTB framework Baptiste Le Duc
2026-10-27 16:51 ` Oleksii Kurochko [this message]
2026-10-29 15:57 ` Baptiste Le Duc
2026-08-27 9:42 ` [PATCH v2 5/6] automation/qtb: add QTB framework README Baptiste Le Duc
2026-10-27 17:32 ` Oleksii Kurochko
2026-10-29 16:07 ` Baptiste Le Duc
2026-10-29 17:12 ` Baptiste Le Duc
2026-08-27 9:42 ` [PATCH v2 6/6] CI: run the riscv64 smoke test via QTB framework console-test Baptiste Le Duc
2026-09-21 14:37 ` Alejandro Vallejo
2026-09-22 9:34 ` Baptiste Le Duc
2026-10-27 17:44 ` Oleksii Kurochko
2026-10-28 10:07 ` Anthony PERARD
[not found] ` <20260827094301.338069-6-baptiste.le-duc@vates.tech>
2026-09-15 20:29 ` Baptiste Le Duc
2026-09-21 14:39 ` [PATCH v2 0/6] automation: add QTB test framework for riscv64 smoke tests Alejandro Vallejo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ada3d12-5569-4e14-8178-815da3665a52@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=baptiste.le-duc@vates.tech \
--cc=cardoe@cardoe.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.