qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Subject: [PULL 05/10] tests/functional: add skipLockedMemoryTest decorator
Date: Wed, 11 Jun 2025 14:58:41 +0200	[thread overview]
Message-ID: <20250611125846.125918-6-thuth@redhat.com> (raw)
In-Reply-To: <20250611125846.125918-1-thuth@redhat.com>

From: Alexandr Moshkov <dtalexundeer@yandex-team.ru>

Used in future commit to skipping execution of a tests if the system's
locked memory limit is below the required threshold.

Signed-off-by: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20250605065908.299979-2-dtalexundeer@yandex-team.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/__init__.py   |  2 +-
 tests/functional/qemu_test/decorators.py | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index af41c2c6a22..6e666a059fc 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, skipIfOperatingSystem
+    skipIfMissingImports, skipIfOperatingSystem, skipLockedMemoryTest
 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 50d29de533d..c0d1567b142 100644
--- a/tests/functional/qemu_test/decorators.py
+++ b/tests/functional/qemu_test/decorators.py
@@ -5,6 +5,7 @@
 import importlib
 import os
 import platform
+import resource
 from unittest import skipIf, skipUnless
 
 from .cmd import which
@@ -131,3 +132,20 @@ def skipIfMissingImports(*args):
 
     return skipUnless(has_imports, 'required import(s) "%s" not installed' %
                                    ", ".join(args))
+
+'''
+Decorator to skip execution of a test if the system's
+locked memory limit is below the required threshold.
+Takes required locked memory threshold in kB.
+Example:
+
+  @skipLockedMemoryTest(2_097_152)
+'''
+def skipLockedMemoryTest(locked_memory):
+    # get memlock hard limit in bytes
+    _, ulimit_memory = resource.getrlimit(resource.RLIMIT_MEMLOCK)
+
+    return skipUnless(
+        ulimit_memory == resource.RLIM_INFINITY or ulimit_memory >= locked_memory * 1024,
+        f'Test required {locked_memory} kB of available locked memory',
+    )
-- 
2.49.0



  parent reply	other threads:[~2025-06-11 13:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 12:58 [PULL 00/10] Misc patches (functional tests, travis.yml, MAINTAINERS, ...) Thomas Huth
2025-06-11 12:58 ` [PULL 01/10] travis.yml: Remove the aarch64 job Thomas Huth
2025-06-11 12:58 ` [PULL 02/10] hw/s390x/s390-virtio-ccw: Remove the deprecated 4.1 machine type Thomas Huth
2025-06-11 12:58 ` [PULL 03/10] tests/functional: Use the 'none' machine for the VNC test Thomas Huth
2025-06-11 12:58 ` [PULL 04/10] tests/functional: Speed up the avr_mega2560 test Thomas Huth
2025-06-11 12:58 ` Thomas Huth [this message]
2025-06-11 12:58 ` [PULL 06/10] tests/functional: add memlock tests Thomas Huth
2025-10-24  7:45   ` Philippe Mathieu-Daudé
2025-10-24  7:51     ` Philippe Mathieu-Daudé
2025-06-11 12:58 ` [PULL 07/10] tests/vm/README: fix documentation path in tests/vm/README Thomas Huth
2025-06-11 12:58 ` [PULL 08/10] MAINTAINERS: Update the paths to the testing documentation files Thomas Huth
2025-06-11 12:58 ` [PULL 09/10] MAINTAINERS: Update Akihiko Odaki's affiliation Thomas Huth
2025-06-11 12:58 ` [PULL 10/10] scripts/meson-buildoptions: Sort coroutine_backend choices lexicographically Thomas Huth
2025-06-11 18:22 ` [PULL 00/10] Misc patches (functional tests, travis.yml, MAINTAINERS, ...) 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=20250611125846.125918-6-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=dtalexundeer@yandex-team.ru \
    --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 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).