qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Romero <gustavo.romero@linaro.org>
To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com,
	berrange@redhat.com
Cc: qemu-arm@nongnu.org, gustavo.romero@linaro.org
Subject: [PATCH v5 7/9] tests/functional: Add decorator to skip test on missing env vars
Date: Thu,  2 Oct 2025 02:04:30 +0000	[thread overview]
Message-ID: <20251002020432.54443-8-gustavo.romero@linaro.org> (raw)
In-Reply-To: <20251002020432.54443-1-gustavo.romero@linaro.org>

Add a decorator to skip tests on missing env variable(s). Multiple
variable names can be provided and if one or more of them are not set in
the test environment the test is skipped and the missing vars are
printed out.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
 tests/functional/qemu_test/__init__.py   |  3 ++-
 tests/functional/qemu_test/decorators.py | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index 60d19891bf..320193591b 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -15,7 +15,8 @@
 from .linuxkernel import LinuxKernelTest
 from .decorators import skipIfMissingCommands, skipIfNotMachine, \
     skipFlakyTest, skipUntrustedTest, skipBigDataTest, skipSlowTest, \
-    skipIfMissingImports, skipIfOperatingSystem, skipLockedMemoryTest
+    skipIfMissingImports, skipIfOperatingSystem, skipLockedMemoryTest, \
+    skipIfMissingEnv
 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 c0d1567b14..b239295804 100644
--- a/tests/functional/qemu_test/decorators.py
+++ b/tests/functional/qemu_test/decorators.py
@@ -11,6 +11,24 @@
 from .cmd import which
 
 '''
+Decorator to skip execution of a test if the provided
+environment variables are not set.
+Example:
+
+  @skipIfMissingEnv("QEMU_ENV_VAR0", "QEMU_ENV_VAR1")
+'''
+def skipIfMissingEnv(*vars_):
+    missing_vars = []
+    for var in vars_:
+        if os.getenv(var) == None:
+            missing_vars.append(var)
+
+    has_vars = True if len(missing_vars) == 0 else False
+
+    return skipUnless(has_vars, f"Missing env var(s): {', '.join(missing_vars)}")
+
+'''
+
 Decorator to skip execution of a test if the list
 of command binaries is not available in $PATH.
 Example:
-- 
2.34.1



  parent reply	other threads:[~2025-10-02  2:10 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02  2:04 [PATCH v5 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado Gustavo Romero
2025-10-02  2:04 ` [PATCH v5 1/9] tests/functional: Re-activate the check-venv target Gustavo Romero
2025-10-02 13:06   ` Daniel P. Berrangé
2025-10-02 16:08   ` Thomas Huth
2025-10-02  2:04 ` [PATCH v5 2/9] python: Install pygdbmi in meson's venv Gustavo Romero
2025-10-02 13:06   ` Daniel P. Berrangé
2025-10-14 17:39   ` John Snow
2025-10-14 18:21     ` Thomas Huth
2025-10-14 18:55       ` John Snow
2025-10-14 18:59         ` Thomas Huth
2025-10-14 19:05           ` John Snow
2025-10-14 19:19             ` Thomas Huth
2025-10-02  2:04 ` [PATCH v5 3/9] tests/functional: Provide GDB to the functional tests Gustavo Romero
2025-10-02 13:08   ` Daniel P. Berrangé
2025-10-02  2:04 ` [PATCH v5 4/9] tests/functional: Add GDB class Gustavo Romero
2025-10-02 13:11   ` Daniel P. Berrangé
2025-10-02 16:24     ` Alex Bennée
2025-10-02  2:04 ` [PATCH v5 5/9] tests/functional: replace avocado process with subprocess Gustavo Romero
2025-10-02  2:04 ` [PATCH v5 6/9] tests/functional: drop datadrainer class in reverse debugging Gustavo Romero
2025-10-02  2:04 ` Gustavo Romero [this message]
2025-10-02 13:12   ` [PATCH v5 7/9] tests/functional: Add decorator to skip test on missing env vars Daniel P. Berrangé
2025-10-02  2:04 ` [PATCH v5 8/9] tests/functional: Adapt reverse_debugging to run w/o Avocado Gustavo Romero
2025-10-02 13:13   ` Daniel P. Berrangé
2025-10-02  2:04 ` [PATCH v5 9/9] tests/functional: Adapt arches to reverse_debugging " Gustavo Romero
2025-10-02 13:14   ` Daniel P. Berrangé
2025-10-02 16:53 ` [PATCH v5 0/9] tests/functional: Adapt reverse_debugging to run " Thomas Huth
2025-10-02 17:52   ` Thomas Huth
2025-10-03 13:30     ` Gustavo Romero
2025-10-03 14:38       ` Gustavo Romero
2025-10-03 15:07         ` Gustavo Romero
2025-10-06  7:24           ` Thomas Huth
2025-10-06  9:58             ` Alex Bennée
2025-10-06 10:07               ` Thomas Huth

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=20251002020432.54443-8-gustavo.romero@linaro.org \
    --to=gustavo.romero@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).