All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH 1/5] tests/functional: Add a decorator for skipping long running tests
Date: Fri, 24 Jan 2025 15:28:50 +0000	[thread overview]
Message-ID: <Z5OxsmoiSSCh485I@redhat.com> (raw)
In-Reply-To: <20250124141529.1626877-2-thuth@redhat.com>

On Fri, Jan 24, 2025 at 03:15:25PM +0100, Thomas Huth wrote:
> Some tests have a very long runtime and might run into timeout
> issues e.g. when QEMU has been compiled with --enable-debug.
> Add a decorator for marking them more easily and document the
> corresponding environment variable that is used to enable the
> tests.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  docs/devel/testing/functional.rst        |  8 ++++++++
>  tests/functional/qemu_test/__init__.py   |  2 +-
>  tests/functional/qemu_test/decorators.py | 14 ++++++++++++++
>  tests/functional/test_arm_quanta_gsj.py  |  5 +++--
>  4 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/docs/devel/testing/functional.rst b/docs/devel/testing/functional.rst
> index ae238ed3fc..7d9396b696 100644
> --- a/docs/devel/testing/functional.rst
> +++ b/docs/devel/testing/functional.rst
> @@ -351,5 +351,13 @@ the code snippet below:
>  Tests should not live in this state forever and should either be fixed
>  or eventually removed.
>  
> +QEMU_TEST_TIMEOUT_EXPECTED
> +^^^^^^^^^^^^^^^^^^^^^^^^^^
> +Tests that have a very long runtime and might run into timeout issues
> +e.g. if the QEMU binary has been compiled with debugging options enabled.
> +To avoid these timeout issues by default and to save some precious CPU
> +cycles during normal testing, such tests are disabled by default unless
> +the QEMU_TEST_TIMEOUT_EXPECTED environment variable has been set.
> +
>  
>  .. _unittest: https://docs.python.org/3/library/unittest.html
> diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
> index da1830286d..b1a19d2a4b 100644
> --- a/tests/functional/qemu_test/__init__.py
> +++ b/tests/functional/qemu_test/__init__.py
> @@ -14,7 +14,7 @@
>  from .testcase import QemuBaseTest, QemuUserTest, QemuSystemTest
>  from .linuxkernel import LinuxKernelTest
>  from .decorators import skipIfMissingCommands, skipIfNotMachine, \
> -    skipFlakyTest, skipUntrustedTest, skipBigDataTest, \
> +    skipFlakyTest, skipUntrustedTest, skipBigDataTest, skipLongRuntime, \

s/Runtime/RunningTime/, but actually in terms of naming
convention, 'skipSlowTest' would fit better.


> diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py
> index df088bc090..8f311e5309 100644
> --- a/tests/functional/qemu_test/decorators.py
> +++ b/tests/functional/qemu_test/decorators.py
> @@ -86,6 +86,20 @@ def skipBigDataTest():
>      return skipUnless(os.getenv('QEMU_TEST_ALLOW_LARGE_STORAGE'),
>                        'Test requires large host storage space')
>  
> +'''
> +Decorator to skip execution of tests which have a really long
> +runtime (and might e.g. time out if QEMU has been compiled with
> +debugging enabled) unless the $QEMU_TEST_TIMEOUT_EXPECTED
> +environment variable is set
> +
> +Example:
> +
> +  @skipLongRuntime()
> +'''
> +def skipLongRuntime():
> +    return skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'),
> +                      'Test has a very long runtime and might time out')
> +

You're preserving the existnig env var which is good,
but I have a little niggling desire to unify the
naming conventions:

  skipFlakyTest     -> $QEMU_TEST_ALLOW_FLAKY
  skipUntrustedTest -> $QEMU_TEST_ALLOW_UNTRUSTED
  skipBigDataTest   -> $QEMU_TEST_ALLOW_BIG_DATA
  skipSlowTest      -> $QEMU_TEST_ALLOW_SLOW

Could be a separate patch though if you like the idea.

>  '''
>  Decorator to skip execution of a test if the list
>  of python imports is not available.
> diff --git a/tests/functional/test_arm_quanta_gsj.py b/tests/functional/test_arm_quanta_gsj.py
> index 7b82e2185c..fe1d60d649 100755
> --- a/tests/functional/test_arm_quanta_gsj.py
> +++ b/tests/functional/test_arm_quanta_gsj.py
> @@ -8,7 +8,8 @@
>  
>  from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
>  from qemu_test import interrupt_interactive_console_until_pattern
> -from unittest import skipUnless
> +from qemu_test import skipLongRuntime
> +
>  
>  class EmcraftSf2Machine(LinuxKernelTest):
>  
> @@ -32,7 +33,7 @@ class EmcraftSf2Machine(LinuxKernelTest):
>           '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb'),
>          '3249b2da787d4b9ad4e61f315b160abfceb87b5e1895a7ce898ce7f40c8d4045')
>  
> -    @skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'), 'Test might timeout')
> +    @skipLongRuntime()
>      def test_arm_quanta_gsj(self):
>          self.set_machine('quanta-gsj')
>          image_path = self.uncompress(self.ASSET_IMAGE, format='gz')
> -- 
> 2.48.1
> 

With regards,
Daniel
-- 
|: 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 :|



  reply	other threads:[~2025-01-24 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 14:15 [PATCH 0/5] Convert the MIPS replay tests to the functional framework Thomas Huth
2025-01-24 14:15 ` [PATCH 1/5] tests/functional: Add a decorator for skipping long running tests Thomas Huth
2025-01-24 15:28   ` Daniel P. Berrangé [this message]
2025-01-28 15:23     ` Thomas Huth
2025-01-24 16:26   ` Philippe Mathieu-Daudé
2025-01-24 14:15 ` [PATCH 2/5] tests/functional: Add the ReplayKernelBase class Thomas Huth
2025-01-24 15:33   ` Daniel P. Berrangé
2025-01-24 14:15 ` [PATCH 3/5] tests/functional/test_mipsel_malta: Convert the mipsel replay tests Thomas Huth
2025-01-24 15:36   ` Daniel P. Berrangé
2025-01-27 18:07     ` Thomas Huth
2025-01-24 14:15 ` [PATCH 4/5] tests/functional/test_mips64el_malta: Convert the mips64el " Thomas Huth
2025-01-24 14:15 ` [PATCH 5/5] tests/functional/test_mips_malta: Convert the mips big endian " Thomas Huth

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=Z5OxsmoiSSCh485I@redhat.com \
    --to=berrange@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=jiaxun.yang@flygoat.com \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.