On 03/04/2025 22.32, Philippe Mathieu-Daudé wrote:
Since tests might be failing on some operating systems,
introduce the skipIfOperatingSystem() decorator.

Acked-by: Michael S. Tsirkin <m...@redhat.com>
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
  tests/functional/qemu_test/__init__.py   |  2 +-
  tests/functional/qemu_test/decorators.py | 15 ++++++++++++++-
  2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/tests/functional/qemu_test/__init__.py 
b/tests/functional/qemu_test/__init__.py
index 45f7befa374..af41c2c6a22 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -15,6 +15,6 @@
  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
diff --git a/tests/functional/qemu_test/decorators.py 
b/tests/functional/qemu_test/decorators.py
index 1651eb739a7..50d29de533d 100644
--- a/tests/functional/qemu_test/decorators.py
+++ b/tests/functional/qemu_test/decorators.py
@@ -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

Reviewed-by: Thomas Huth <th...@redhat.com>


Reply via email to