qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Alexandr Moshkov <dtalexundeer@yandex-team.ru>, qemu-devel@nongnu.org
Cc: "Cleber Rosa" <crosa@redhat.com>,
	"yc-core @ yandex-team . ru" <yc-core@yandex-team.ru>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>
Subject: Re: [PATCH v6 1/2] tests/functional: add skipLockedMemoryTest decorator
Date: Wed, 21 May 2025 12:25:01 +0200	[thread overview]
Message-ID: <6a81df21-2da2-497c-8d6e-23d04d225575@redhat.com> (raw)
In-Reply-To: <20250417114008.169350-2-dtalexundeer@yandex-team.ru>

On 17/04/2025 13.40, Alexandr Moshkov wrote:
> 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>
> ---
>   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 af41c2c6a2..6e666a059f 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 50d29de533..c0d1567b14 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',
> +    )

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



  reply	other threads:[~2025-05-21 10:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 11:40 [PATCH v6 0/2] tests/functional: add memlock tests Alexandr Moshkov
2025-04-17 11:40 ` [PATCH v6 1/2] tests/functional: add skipLockedMemoryTest decorator Alexandr Moshkov
2025-05-21 10:25   ` Thomas Huth [this message]
2025-04-17 11:40 ` [PATCH v6 2/2] tests/functional: add memlock tests Alexandr Moshkov
2025-05-21 12:06   ` Thomas Huth
2025-04-28  9:34 ` [PATCH v6 0/2] " Alexandr Moshkov
2025-05-21  8:52 ` Alexandr Moshkov

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=6a81df21-2da2-497c-8d6e-23d04d225575@redhat.com \
    --to=thuth@redhat.com \
    --cc=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=dtalexundeer@yandex-team.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yc-core@yandex-team.ru \
    /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).