]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/functional: Add a decorator for skipping tests on particular OS
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Thu, 3 Apr 2025 20:32:38 +0000 (22:32 +0200)
committerRichard Henderson <richard.henderson@linaro.org>
Thu, 3 Apr 2025 23:11:09 +0000 (16:11 -0700)
Since tests might be failing on some operating systems,
introduce the skipIfOperatingSystem() decorator.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250403203241.46692-3-philmd@linaro.org>

tests/functional/qemu_test/__init__.py
tests/functional/qemu_test/decorators.py

index 45f7befa374ae9e069c56e2deec54086f1e72167..af41c2c6a223b9a715b26cb4eb08a6d9564bd37a 100644 (file)
@@ -15,6 +15,6 @@ from .testcase import QemuBaseTest, QemuUserTest, QemuSystemTest
 from .linuxkernel import LinuxKernelTest
 from .decorators import skipIfMissingCommands, skipIfNotMachine, \
     skipFlakyTest, skipUntrustedTest, skipBigDataTest, skipSlowTest, \
-    skipIfMissingImports
+    skipIfMissingImports, skipIfOperatingSystem
 from .archive import archive_extract
 from .uncompress import uncompress
index 1651eb739a7974ee9f817602106113962c0eeba2..50d29de533dfc316081e08e85be86ca167bfd63c 100644 (file)
@@ -5,7 +5,7 @@
 import importlib
 import os
 import platform
-from unittest import skipUnless
+from unittest import skipIf, skipUnless
 
 from .cmd import which
 
@@ -26,6 +26,19 @@ def skipIfMissingCommands(*args):
     return skipUnless(has_cmds, 'required command(s) "%s" not installed' %
                                 ", ".join(args))
 
+'''
+Decorator to skip execution of a test if the current
+host operating system does match one of the prohibited
+ones.
+Example
+
+  @skipIfOperatingSystem("Linux", "Darwin")
+'''
+def skipIfOperatingSystem(*args):
+    return skipIf(platform.system() in args,
+                  'running on an OS (%s) that is not able to run this test' %
+                  ", ".join(args))
+
 '''
 Decorator to skip execution of a test if the current
 host machine does not match one of the permitted