From: Thomas Huth <thuth@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: "John Snow" <jsnow@redhat.com>, "Denis V. Lunev" <den@openvz.org>,
"Fabiano Rosas" <farosas@suse.de>,
"Laurent Vivier" <lvivier@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
qemu-block@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <th.huth+qemu@posteo.eu>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
qemu-arm@nongnu.org, "Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
qemu-s390x@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
"Glenn Miles" <milesg@linux.ibm.com>,
qemu-ppc@nongnu.org
Subject: Re: [PATCH v2 02/10] tests/functional: add skipUnlessConfig() helper
Date: Mon, 7 Sep 2026 14:02:29 +0200 [thread overview]
Message-ID: <3f5f77fc-05c9-4b26-8290-28b16dfd3be4@redhat.com> (raw)
In-Reply-To: <20260907-nohmp-v2-2-6d952d972c21@redhat.com>
Hi!
On 07/09/2026 12.30, Marc-André Lureau wrote:
> Read config-host.h and skip tests that rely on some CONFIG_*
> values.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> tests/functional/qemu_test/__init__.py | 2 +-
> tests/functional/qemu_test/decorators.py | 25 +++++++++++++++++++++++++
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
> index 03e5c73d39dc..e21fa8279281 100644
> --- a/tests/functional/qemu_test/__init__.py
> +++ b/tests/functional/qemu_test/__init__.py
> @@ -16,7 +16,7 @@
> from .decorators import skipIfMissingCommands, skipIfNotMachine, \
> skipFlakyTest, skipUntrustedTest, skipBigDataTest, skipSlowTest, \
> skipIfMissingImports, skipIfOperatingSystem, skipUnlessOperatingSystem, \
> - skipLockedMemoryTest, skipIfMissingEnv
> + skipLockedMemoryTest, skipIfMissingEnv, skipUnlessConfig
> from .archive import archive_extract
> from .uncompress import uncompress
> from .gdb import GDB
> diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py
> index aa135acc7857..7a7d30503440 100644
> --- a/tests/functional/qemu_test/decorators.py
> +++ b/tests/functional/qemu_test/decorators.py
> @@ -10,6 +10,7 @@
> from unittest import skipIf, skipUnless
>
> from .cmd import which
> +from .config import BUILD_DIR
>
>
> def skipIfMissingEnv(*vars_):
> @@ -162,6 +163,30 @@ def skipIfMissingImports(*args):
> return skipUnless(has_imports, 'required import(s) "%s" not installed' %
> ", ".join(args))
>
> +def _read_config_host():
> + config = set()
> + with open(BUILD_DIR / "config-host.h", "r") as f:
> + for line in f:
> + if line.startswith("#define CONFIG_"):
> + name = line.split()[1].removeprefix("CONFIG_")
> + config.add(name)
> + return config
> +
> +_CONFIG_HOST = _read_config_host()
This always reads in config-host.h, also for tests that don't need the
decorator ... could you change it so that the file is only read (once) if a
test calls the skipUnlessConfig decorator?
Also I'm a little bit torn whether we really need a decorator for this or
whether we should rather fence the tests in meson.build instead (similar to
what we do in tests/qtest/meson.build with config_all_devices.has_key('...')
already). What do others think about this?
Thomas
> +def skipUnlessConfig(*args):
> + '''
> + Decorator to skip execution of a test if the QEMU build
> + does not have the required CONFIG_* options enabled.
> + Example:
> +
> + @skipUnlessConfig("PIXMAN")
> + '''
> + missing = [a for a in args if a not in _CONFIG_HOST]
> + return skipUnless(len(missing) == 0,
> + 'missing build config(s): %s' %
> + ', '.join('CONFIG_' + m for m in missing))
> +
> def skipLockedMemoryTest(locked_memory):
> '''
> Decorator to skip execution of a test if the system's
>
next prev parent reply other threads:[~2026-09-07 12:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 10:30 [PATCH v2 00/10] Make HMP optional - follow-up Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 01/10] tests/ahci-test: replace HMP usage with QMP Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 02/10] tests/functional: add skipUnlessConfig() helper Marc-André Lureau
2026-09-07 12:02 ` Thomas Huth [this message]
2026-09-07 12:19 ` Daniel P. Berrangé
2026-09-07 10:30 ` [PATCH v2 03/10] tests/functional: skip if CONFIG_PIXMAN Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 04/10] tests/functional: replace HMP with QMP Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 05/10] tests/functional/s390x: use QMP for balloon Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 06/10] tests/qtest: add qtest_qmp_job_wait() Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 07/10] tests/ide-test: convert to QMP Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 08/10] tests/drive_del-test: compile out HMP-dependent tests when !CONFIG_HMP Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 09/10] qtest: compile out HMP helper " Marc-André Lureau
2026-09-07 10:30 ` [PATCH v2 10/10] tests/functional: fix some tests that require HMP Marc-André Lureau
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=3f5f77fc-05c9-4b26-8290-28b16dfd3be4@redhat.com \
--to=thuth@redhat.com \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=den@openvz.org \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=jsnow@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=milesg@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=th.huth+qemu@posteo.eu \
/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.