All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PULL 02/20] tests/functional: Fix broken decorators with lamda functions
Date: Thu, 30 Jan 2025 14:15:16 +0100	[thread overview]
Message-ID: <20250130131535.91297-3-thuth@redhat.com> (raw)
In-Reply-To: <20250130131535.91297-1-thuth@redhat.com>

The decorators that use a lambda function are currently broken
and do not properly skip the test if the condition is not met.
Using "return skipUnless(lambda: ...)" does not work as expected.
To fix it, rewrite the decorators without lambda, it's simpler
that way anyway.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20250122134315.1448794-3-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/decorators.py | 44 +++++++++++-------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py
index 08f58f6b40..3d9c02fd59 100644
--- a/tests/functional/qemu_test/decorators.py
+++ b/tests/functional/qemu_test/decorators.py
@@ -17,15 +17,14 @@
   @skipIfMissingCommands("mkisofs", "losetup")
 '''
 def skipIfMissingCommands(*args):
-    def has_cmds(cmdlist):
-        for cmd in cmdlist:
-            if not which(cmd):
-                return False
-        return True
-
-    return skipUnless(lambda: has_cmds(args),
-                      'required command(s) "%s" not installed' %
-                      ", ".join(args))
+    has_cmds = True
+    for cmd in args:
+         if not which(cmd):
+             has_cmds = False
+             break
+
+    return skipUnless(has_cmds, 'required command(s) "%s" not installed' %
+                                ", ".join(args))
 
 '''
 Decorator to skip execution of a test if the current
@@ -36,9 +35,9 @@ def has_cmds(cmdlist):
   @skipIfNotMachine("x86_64", "aarch64")
 '''
 def skipIfNotMachine(*args):
-    return skipUnless(lambda: platform.machine() in args,
-                        'not running on one of the required machine(s) "%s"' %
-                        ", ".join(args))
+    return skipUnless(platform.machine() in args,
+                      'not running on one of the required machine(s) "%s"' %
+                      ", ".join(args))
 
 '''
 Decorator to skip execution of flaky tests, unless
@@ -95,14 +94,13 @@ def skipBigDataTest():
   @skipIfMissingImports("numpy", "cv2")
 '''
 def skipIfMissingImports(*args):
-    def has_imports(importlist):
-        for impname in importlist:
-            try:
-                importlib.import_module(impname)
-            except ImportError:
-                return False
-        return True
-
-    return skipUnless(lambda: has_imports(args),
-                      'required import(s) "%s" not installed' %
-                      ", ".join(args))
+    has_imports = True
+    for impname in args:
+        try:
+            importlib.import_module(impname)
+        except ImportError:
+            has_imports = False
+            break
+
+    return skipUnless(has_imports, 'required import(s) "%s" not installed' %
+                                   ", ".join(args))
-- 
2.48.1



  parent reply	other threads:[~2025-01-30 13:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 13:15 [PULL 00/20] Functional tests, s390x improvements and slirp fixes Thomas Huth
2025-01-30 13:15 ` [PULL 01/20] tests/functional/qemu_test/decorators: Fix bad check for imports Thomas Huth
2025-01-30 13:15 ` Thomas Huth [this message]
2025-01-30 13:15 ` [PULL 03/20] tests/functional: Convert the migration avocado test Thomas Huth
2025-01-30 13:15 ` [PULL 04/20] tests/functional: Fix the aarch64_tcg_plugins test Thomas Huth
2025-01-30 13:15 ` [PULL 05/20] tests/functional: Add a ppc64 mac99 test Thomas Huth
2025-01-30 13:15 ` [PULL 06/20] tests/functional/test_mips_malta: Fix comment about endianness of the test Thomas Huth
2025-01-30 13:15 ` [PULL 07/20] target/s390x: Fix PPNO execution with icount Thomas Huth
2025-01-30 13:15 ` [PULL 08/20] target/s390x: Fix MVC not always invalidating translation blocks Thomas Huth
2025-01-30 13:15 ` [PULL 09/20] tests/tcg/s390x: Test modifying code using the MVC instruction Thomas Huth
2025-01-30 13:15 ` [PULL 10/20] hw/s390x/s390-virtio-ccw: Fix a record/replay deadlock Thomas Huth
2025-01-30 13:15 ` [PULL 11/20] virtio-balloon-pci: Allow setting nvectors, so we can use MSI-X Thomas Huth
2025-01-30 13:15 ` [PULL 12/20] virtio-mem-pci: " Thomas Huth
2025-01-30 13:15 ` [PULL 13/20] s390x/s390-virtio-ccw: Support plugging PCI-based virtio memory devices Thomas Huth
2025-01-30 13:15 ` [PULL 14/20] tests/functional: Extend PPC 40p test with Linux boot Thomas Huth
2025-01-30 13:15 ` [PULL 15/20] tests/functional: Add a decorator for skipping long running tests Thomas Huth
2025-01-30 13:15 ` [PULL 16/20] tests/functional: Add the ReplayKernelBase class Thomas Huth
2025-01-30 13:15 ` [PULL 17/20] tests/functional/test_mipsel_malta: Convert the mipsel replay tests Thomas Huth
2025-01-30 13:15 ` [PULL 18/20] tests/functional/test_mips64el_malta: Convert the mips64el " Thomas Huth
2025-01-30 13:15 ` [PULL 19/20] tests/functional/test_mips_malta: Convert the mips big endian " Thomas Huth
2025-01-30 13:15 ` [PULL 20/20] net/slirp: libslirp 4.9.0 compatibility Thomas Huth
2025-02-01  3:03 ` [PULL 00/20] Functional tests, s390x improvements and slirp fixes Stefan Hajnoczi

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=20250130131535.91297-3-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 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.