Skip to contentSkip to conversation

tests/functional/x86_64: Limit the memlock test to Linux hosts

PATCH In review Thomas Huth 3 participants 3 messages Jan 21

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests/functional/x86_64: Limit the memlock test to Linux hosts

From: Thomas Huth <[email protected]>

The memlock test analyzes /proc/*/status files and expects the layout from Linux in there. However, these files also exist on NetBSD hosts with a completely different layout, causing this test to fail. Thus limit the test to Linux hosts now. We already have a decorator to skip a test if it is running on a certain host system, but in this case, we rather want to skip if we are not running on a specific host system, so introduce a new @skipUnlessOperatingSystem decorator for this job.

---
v2: Check via a decorator, not via meson.build file

 tests/functional/qemu_test/__init__.py   |  4 ++--
 tests/functional/qemu_test/decorators.py | 12 ++++++++++++
 tests/functional/x86_64/test_memlock.py  |  3 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)
tests/functional/qemu_test/__init__.py +2 -2
index 320193591b2..03e5c73d39d 100644
@@ -15,8 +15,8 @@
 from .linuxkernel import LinuxKernelTest
 from .decorators import skipIfMissingCommands, skipIfNotMachine, \
     skipFlakyTest, skipUntrustedTest, skipBigDataTest, skipSlowTest, \
-    skipIfMissingImports, skipIfOperatingSystem, skipLockedMemoryTest, \
-    skipIfMissingEnv
+    skipIfMissingImports, skipIfOperatingSystem, skipUnlessOperatingSystem, \
+    skipLockedMemoryTest, skipIfMissingEnv
 from .archive import archive_extract
 from .uncompress import uncompress
 from .gdb import GDB
tests/functional/qemu_test/decorators.py +12 -0
index 807418359ab..fcf236ecfdf 100644
@@ -57,6 +57,18 @@ def skipIfOperatingSystem(*args):
                   'running on an OS (%s) that is not able to run this test' %
                   ", ".join(args))
 
+def skipUnlessOperatingSystem(*args):
+    '''
+    Decorator to skip execution of a test if the current host
+    operating system does not match one of the allowed ones.
+    Example:
+
+      @skipUnlessOperatingSystem("Linux", "Darwin")
+    '''
+    return skipUnless(platform.system() in args,
+                  'not running on one of the required operating systems (%s)' %
+                  ", ".join(args))
+
 def skipIfNotMachine(*args):
     '''
     Decorator to skip execution of a test if the current
tests/functional/x86_64/test_memlock.py +2 -1
index f970a2c3095..d88843ab5f9 100755
@@ -14,12 +14,13 @@
 from typing import Dict
 
 from qemu_test import QemuSystemTest
-from qemu_test import skipLockedMemoryTest
+from qemu_test import skipLockedMemoryTest, skipUnlessOperatingSystem
 
 
 STATUS_VALUE_PATTERN = re.compile(r'^(\w+):\s+(\d+) kB', re.MULTILINE)
 
 
+@skipUnlessOperatingSystem('Linux')
 @skipLockedMemoryTest(2_097_152)  # 2GB
 class MemlockTest(QemuSystemTest):
     """
Signature · 1 line
2.52.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The memlock test analyzes /proc/*/status files and expects the layout from Linux in there. However, these files also exist on NetBSD hosts with a completely different layout, causing this test to fail. Thus limit the test to Linux hosts now. We already have a decorator to skip a test if it is running on a certain host system, but in this case, we rather want to skip if we are not running on a specific host system, so introduce a new @skipUnlessOperatingSystem decorator for this job.

Quoted 8 lines

---
v2: Check via a decorator, not via meson.build file

 tests/functional/qemu_test/__init__.py   |  4 ++--
 tests/functional/qemu_test/decorators.py | 12 ++++++++++++
 tests/functional/x86_64/test_memlock.py  |  3 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Reviewed-by on v2 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 16 lines · Thomas Huth

Date: Wed, 21 Jan 2026 12:11:40 +0100
From: Thomas Huth <[email protected]>
Subject: [PATCH v2] tests/functional/x86_64: Limit the memlock test to
Linux hosts

From: Thomas Huth <[email protected]>

The memlock test analyzes /proc/*/status files and expects the layout from Linux in there. However, these files also exist on NetBSD hosts with a completely different layout, causing this test to fail. Thus limit the test to Linux hosts now. We already have a decorator to skip a test if it is running on a certain host system, but in this case, we rather want to skip if we are not running on a specific host system, so introduce a new @skipUnlessOperatingSystem decorator for this job.

Quoted 3 lines

---
v2: Check via a decorator, not via meson.build file

LGTM,