qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/8] Fixes for functional tests
@ 2025-03-13  8:01 Thomas Huth
  2025-03-13  8:01 ` [PULL 1/8] docs: Rename default-configs to configs Thomas Huth
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

The following changes since commit 825b96dbcee23d134b691fc75618b59c5f53da32:

  Merge tag 'migration-20250310-pull-request' of https://gitlab.com/farosas/qemu into staging (2025-03-11 09:32:07 +0800)

are available in the Git repository at:

  https://gitlab.com/thuth/qemu.git tags/pull-request-2025-03-13

for you to fetch changes up to b3c03666fb10b4900e5bbff0a2b403731730e637:

  tests/functional: skip vulkan test if missing vulkaninfo (2025-03-13 08:18:26 +0100)

----------------------------------------------------------------
* Various fixes for functional tests
* Fix the name of the "configs" directory in the documentation

----------------------------------------------------------------
Alex Bennée (1):
      tests/functional: skip vulkan test if missing vulkaninfo

Cédric Le Goater (1):
      tests/functional: Require 'user' netdev for ppc64 e500 test

Greg Kurz (1):
      docs: Rename default-configs to configs

Nicholas Piggin (3):
      tests/functional/asset: Fail assert fetch when retries are exceeded
      tests/functional/asset: Verify downloaded size
      tests/functional/asset: Add AssetError exception class

Peter Maydell (1):
      tests/functional: Bump up arm_replay timeout

Thomas Huth (1):
      docs/system: Fix the information on how to run certain functional tests

 docs/devel/build-system.rst               | 10 +++---
 docs/devel/kconfig.rst                    | 16 ++++-----
 docs/system/arm/bananapi_m2u.rst          |  5 ++-
 docs/system/arm/orangepi.rst              |  6 ++--
 docs/system/devices/igb.rst               |  4 +--
 tests/functional/meson.build              |  1 +
 tests/functional/qemu_test/asset.py       | 58 +++++++++++++++++++++++--------
 tests/functional/test_aarch64_virt_gpu.py |  1 +
 tests/functional/test_ppc64_e500.py       |  1 +
 9 files changed, 67 insertions(+), 35 deletions(-)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PULL 1/8] docs: Rename default-configs to configs
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 2/8] tests/functional: Require 'user' netdev for ppc64 e500 test Thomas Huth
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, Greg Kurz, Philippe Mathieu-Daudé

From: Greg Kurz <groug@kaod.org>

This was missed at the time.

Fixes: 812b31d3f91 ("configs: rename default-configs to configs and reorganise")
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250306174113.427116-1-groug@kaod.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 docs/devel/build-system.rst | 10 +++++-----
 docs/devel/kconfig.rst      | 16 ++++++++--------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst
index d42045a2325..a759982f45c 100644
--- a/docs/devel/build-system.rst
+++ b/docs/devel/build-system.rst
@@ -260,7 +260,7 @@ Target-dependent emulator sourcesets:
   Each emulator also includes sources for files in the ``hw/`` and ``target/``
   subdirectories.  The subdirectory used for each emulator comes
   from the target's definition of ``TARGET_BASE_ARCH`` or (if missing)
-  ``TARGET_ARCH``, as found in ``default-configs/targets/*.mak``.
+  ``TARGET_ARCH``, as found in ``configs/targets/*.mak``.
 
   Each subdirectory in ``hw/`` adds one sourceset to the ``hw_arch`` dictionary,
   for example::
@@ -317,8 +317,8 @@ Utility sourcesets:
 The following files concur in the definition of which files are linked
 into each emulator:
 
-``default-configs/devices/*.mak``
-  The files under ``default-configs/devices/`` control the boards and devices
+``configs/devices/*.mak``
+  The files under ``configs/devices/`` control the boards and devices
   that are built into each QEMU system emulation targets. They merely contain
   a list of config variable definitions such as::
 
@@ -327,11 +327,11 @@ into each emulator:
     CONFIG_XLNX_VERSAL=y
 
 ``*/Kconfig``
-  These files are processed together with ``default-configs/devices/*.mak`` and
+  These files are processed together with ``configs/devices/*.mak`` and
   describe the dependencies between various features, subsystems and
   device models.  They are described in :ref:`kconfig`
 
-``default-configs/targets/*.mak``
+``configs/targets/*.mak``
   These files mostly define symbols that appear in the ``*-config-target.h``
   file for each emulator\ [#cfgtarget]_.  However, the ``TARGET_ARCH``
   and ``TARGET_BASE_ARCH`` will also be used to select the ``hw/`` and
diff --git a/docs/devel/kconfig.rst b/docs/devel/kconfig.rst
index 52d4b905f67..493b76c4fbf 100644
--- a/docs/devel/kconfig.rst
+++ b/docs/devel/kconfig.rst
@@ -38,7 +38,7 @@ originated in the Linux kernel, though it was heavily simplified and
 the handling of dependencies is stricter in QEMU.
 
 Unlike Linux, there is no user interface to edit the configuration, which
-is instead specified in per-target files under the ``default-configs/``
+is instead specified in per-target files under the ``configs/``
 directory of the QEMU source tree.  This is because, unlike Linux,
 configuration and dependencies can be treated as a black box when building
 QEMU; the default configuration that QEMU ships with should be okay in
@@ -103,7 +103,7 @@ directives can be included:
 **default value**: ``default <value> [if <expr>]``
 
   Default values are assigned to the config symbol if no other value was
-  set by the user via ``default-configs/*.mak`` files, and only if
+  set by the user via ``configs/*.mak`` files, and only if
   ``select`` or ``depends on`` directives do not force the value to true
   or false respectively.  ``<value>`` can be ``y`` or ``n``; it cannot
   be an arbitrary Boolean expression.  However, a condition for applying
@@ -119,7 +119,7 @@ directives can be included:
   This is similar to ``select`` as it applies a lower limit of ``y``
   to another symbol.  However, the lower limit is only a default
   and the "implied" symbol's value may still be set to ``n`` from a
-  ``default-configs/*.mak`` files.  The following two examples are
+  ``configs/*.mak`` files.  The following two examples are
   equivalent::
 
     config FOO
@@ -146,7 +146,7 @@ declares its dependencies in different ways:
       bool
 
   Subsystems always default to false (they have no ``default`` directive)
-  and are never visible in ``default-configs/*.mak`` files.  It's
+  and are never visible in ``configs/*.mak`` files.  It's
   up to other symbols to ``select`` whatever subsystems they require.
 
   They sometimes have ``select`` directives to bring in other required
@@ -238,7 +238,7 @@ declares its dependencies in different ways:
   include libraries (such as ``FDT``) or ``TARGET_BIG_ENDIAN``
   (possibly negated).
 
-  Boards are listed for convenience in the ``default-configs/*.mak``
+  Boards are listed for convenience in the ``configs/*.mak``
   for the target they apply to.
 
 **internal elements**
@@ -251,18 +251,18 @@ declares its dependencies in different ways:
 
   Internal elements group code that is useful in several boards or
   devices.  They are usually enabled with ``select`` and in turn select
-  other elements; they are never visible in ``default-configs/*.mak``
+  other elements; they are never visible in ``configs/*.mak``
   files, and often not even in the Makefile.
 
 Writing and modifying default configurations
 --------------------------------------------
 
 In addition to the Kconfig files under hw/, each target also includes
-a file called ``default-configs/TARGETNAME-softmmu.mak``.  These files
+a file called ``configs/TARGETNAME-softmmu.mak``.  These files
 initialize some Kconfig variables to non-default values and provide the
 starting point to turn on devices and subsystems.
 
-A file in ``default-configs/`` looks like the following example::
+A file in ``configs/`` looks like the following example::
 
     # Default configuration for alpha-softmmu
 
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 2/8] tests/functional: Require 'user' netdev for ppc64 e500 test
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
  2025-03-13  8:01 ` [PULL 1/8] docs: Rename default-configs to configs Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 3/8] tests/functional: Bump up arm_replay timeout Thomas Huth
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefan Hajnoczi, Cédric Le Goater, Bernhard Beschow,
	Philippe Mathieu-Daudé

From: Cédric Le Goater <clg@redhat.com>

When commit 72cdd672e18c extended the ppc64 e500 test to add network
support, it forgot to require the 'user' netdev backend. Fix that.

Fixes: 72cdd672e18c ("tests/functional: Replace the ppc64 e500 advent calendar test")
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250308071328.193694-1-clg@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/test_ppc64_e500.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/functional/test_ppc64_e500.py b/tests/functional/test_ppc64_e500.py
index 9ce7ae6c479..f5fcad9f6b6 100755
--- a/tests/functional/test_ppc64_e500.py
+++ b/tests/functional/test_ppc64_e500.py
@@ -20,6 +20,7 @@ class E500Test(LinuxKernelTest):
 
     def test_ppc64_e500_buildroot(self):
         self.set_machine('ppce500')
+        self.require_netdev('user')
         self.cpu = 'e5500'
 
         uimage_path = self.ASSET_BR2_E5500_UIMAGE.fetch()
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 3/8] tests/functional: Bump up arm_replay timeout
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
  2025-03-13  8:01 ` [PULL 1/8] docs: Rename default-configs to configs Thomas Huth
  2025-03-13  8:01 ` [PULL 2/8] tests/functional: Require 'user' netdev for ppc64 e500 test Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 4/8] docs/system: Fix the information on how to run certain functional tests Thomas Huth
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, Peter Maydell

From: Peter Maydell <peter.maydell@linaro.org>

On my machine the arm_replay test takes over 2 minutes to run
in a config with Rust enabled and debug enabled:

$ time (cd build/rust ; PYTHONPATH=../../python:../../tests/functional
QEMU_TEST_QEMU_BINARY=./qemu-system-arm ./pyvenv/bin/python3
../../tests/functional/test_arm_replay.py)
TAP version 13
ok 1 test_arm_replay.ArmReplay.test_cubieboard
ok 2 test_arm_replay.ArmReplay.test_vexpressa9
ok 3 test_arm_replay.ArmReplay.test_virt
1..3

real    2m16.564s
user    2m13.461s
sys     0m3.523s

Bump up the timeout to 4 minutes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20250310102830.3752440-1-peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index e78560a9011..e181ed1ea57 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -34,6 +34,7 @@ test_timeouts = {
   'arm_orangepi' : 540,
   'arm_quanta_gsj' : 240,
   'arm_raspi2' : 120,
+  'arm_replay' : 240,
   'arm_tuxrun' : 240,
   'arm_sx1' : 360,
   'intel_iommu': 300,
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 4/8] docs/system: Fix the information on how to run certain functional tests
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
                   ` (2 preceding siblings ...)
  2025-03-13  8:01 ` [PULL 3/8] tests/functional: Bump up arm_replay timeout Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 5/8] tests/functional/asset: Fail assert fetch when retries are exceeded Thomas Huth
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

The tests have been converted to the functional framework, so
we should not talk about Avocado here anymore.

Fixes: f7d6b772200 ("tests/functional: Convert BananaPi tests to the functional framework")
Fixes: 380f7268b7b ("tests/functional: Convert the OrangePi tests to the functional framework")
Fixes: 4c0a2df81c9 ("tests/functional: Convert some tests that download files via fetch_asset()")
Message-ID: <20250311160847.388670-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 docs/system/arm/bananapi_m2u.rst | 5 ++---
 docs/system/arm/orangepi.rst     | 6 +++---
 docs/system/devices/igb.rst      | 4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/docs/system/arm/bananapi_m2u.rst b/docs/system/arm/bananapi_m2u.rst
index 587b4886553..d30db8d04c3 100644
--- a/docs/system/arm/bananapi_m2u.rst
+++ b/docs/system/arm/bananapi_m2u.rst
@@ -135,6 +135,5 @@ provide the following command:
 .. code-block:: bash
 
   $ cd qemu-build-dir
-  $ AVOCADO_ALLOW_LARGE_STORAGE=yes tests/venv/bin/avocado \
-    --verbose --show=app,console run -t machine:bpim2u \
-    ../tests/avocado/boot_linux_console.py
+  $ QEMU_TEST_ALLOW_LARGE_STORAGE=1 \
+    meson test --suite thorough func-arm-arm_bpim2u
diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
index db87e81fec4..8b9448ca7b0 100644
--- a/docs/system/arm/orangepi.rst
+++ b/docs/system/arm/orangepi.rst
@@ -257,9 +257,9 @@ Orange Pi PC integration tests
 
 The Orange Pi PC machine has several integration tests included.
 To run the whole set of tests, build QEMU from source and simply
-provide the following command:
+provide the following command from the build directory:
 
 .. code-block:: bash
 
-  $ AVOCADO_ALLOW_LARGE_STORAGE=yes avocado --show=app,console run \
-     -t machine:orangepi-pc tests/avocado/boot_linux_console.py
+  $ QEMU_TEST_ALLOW_LARGE_STORAGE=1 \
+    meson test --suite thorough func-arm-arm_orangepi
diff --git a/docs/system/devices/igb.rst b/docs/system/devices/igb.rst
index 04e79dfe549..9145af5c757 100644
--- a/docs/system/devices/igb.rst
+++ b/docs/system/devices/igb.rst
@@ -57,11 +57,11 @@ directory:
   meson test qtest-x86_64/qos-test
 
 ethtool can test register accesses, interrupts, etc. It is automated as an
-Avocado test and can be ran with the following command:
+functional test and can be ran with the following command:
 
 .. code:: shell
 
-  make check-avocado AVOCADO_TESTS=tests/avocado/netdev-ethtool.py
+  meson test --suite thorough func-x86_64-netdev_ethtool
 
 References
 ==========
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 5/8] tests/functional/asset: Fail assert fetch when retries are exceeded
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
                   ` (3 preceding siblings ...)
  2025-03-13  8:01 ` [PULL 4/8] docs/system: Fix the information on how to run certain functional tests Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 6/8] tests/functional/asset: Verify downloaded size Thomas Huth
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, Nicholas Piggin, Daniel P. Berrangé

From: Nicholas Piggin <npiggin@gmail.com>

Currently the fetch code does not fail gracefully when retry limit is
exceeded, it just falls through the loop with no file, which ends up
hitting other errors.

Add a check for non-existing file, which indicates the retry limit was
exceeded.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-ID: <20250312130002.945508-2-npiggin@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/asset.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index f0730695f09..27dd839e705 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -138,6 +138,9 @@ def fetch(self):
                 tmp_cache_file.unlink()
                 raise
 
+        if not os.path.exists(tmp_cache_file):
+            raise Exception("Retries exceeded downloading %s", self.url)
+
         try:
             # Set these just for informational purposes
             os.setxattr(str(tmp_cache_file), "user.qemu-asset-url",
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 6/8] tests/functional/asset: Verify downloaded size
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
                   ` (4 preceding siblings ...)
  2025-03-13  8:01 ` [PULL 5/8] tests/functional/asset: Fail assert fetch when retries are exceeded Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 7/8] tests/functional/asset: Add AssetError exception class Thomas Huth
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, Nicholas Piggin, Daniel P. Berrangé

From: Nicholas Piggin <npiggin@gmail.com>

If the server provides a Content-Length header, use that to verify the
size of the downloaded file. This catches cases where the connection
terminates early, and gives the opportunity to retry. Without this, the
checksum will likely mismatch and fail without retry.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-ID: <20250312130002.945508-3-npiggin@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/asset.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 27dd839e705..6bbfb9e1cad 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -121,6 +121,20 @@ def fetch(self):
                 with tmp_cache_file.open("xb") as dst:
                     with urllib.request.urlopen(self.url) as resp:
                         copyfileobj(resp, dst)
+                        length_hdr = resp.getheader("Content-Length")
+
+                # Verify downloaded file size against length metadata, if
+                # available.
+                if length_hdr is not None:
+                    length = int(length_hdr)
+                    fsize = tmp_cache_file.stat().st_size
+                    if fsize != length:
+                        self.log.error("Unable to download %s: "
+                                       "connection closed before "
+                                       "transfer complete (%d/%d)",
+                                       self.url, fsize, length)
+                        tmp_cache_file.unlink()
+                        continue
                 break
             except FileExistsError:
                 self.log.debug("%s already exists, "
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 7/8] tests/functional/asset: Add AssetError exception class
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
                   ` (5 preceding siblings ...)
  2025-03-13  8:01 ` [PULL 6/8] tests/functional/asset: Verify downloaded size Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-13  8:01 ` [PULL 8/8] tests/functional: skip vulkan test if missing vulkaninfo Thomas Huth
  2025-03-14  4:46 ` [PULL 0/8] Fixes for functional tests Stefan Hajnoczi
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, Nicholas Piggin, Daniel P. Berrangé

From: Nicholas Piggin <npiggin@gmail.com>

Assets are uniquely identified by human-readable-ish url, so make an
AssetError exception class that prints url with error message.

A property 'transient' is used to capture whether the client may retry
or try again later, or if it is a serious and likely permanent error.
This is used to retain the existing behaviour of treating HTTP errors
other than 404 as 'transient' and not causing precache step to fail.
Additionally, partial-downloads and stale asset caches that fail to
resolve after the retry limit are now treated as transient and do not
cause precache step to fail.

For background: The NetBSD archive is, at the time of writing, failing
with short transfer. Retrying the fetch at that position (as wget does)
results in a "503 backend unavailable" error. We would like to get that
error code directly, but I have not found a way to do that with urllib,
so treating the short-copy as a transient failure covers that case (and
seems like a reasonable way to handle it in general).

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-ID: <20250312130002.945508-4-npiggin@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/asset.py | 43 +++++++++++++++++++----------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 6bbfb9e1cad..704b84d0ea6 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -17,6 +17,14 @@
 from shutil import copyfileobj
 from urllib.error import HTTPError
 
+class AssetError(Exception):
+    def __init__(self, asset, msg, transient=False):
+        self.url = asset.url
+        self.msg = msg
+        self.transient = transient
+
+    def __str__(self):
+        return "%s: %s" % (self.url, self.msg)
 
 # Instances of this class must be declared as class level variables
 # starting with a name "ASSET_". This enables the pre-caching logic
@@ -51,7 +59,7 @@ def _check(self, cache_file):
         elif len(self.hash) == 128:
             hl = hashlib.sha512()
         else:
-            raise Exception("unknown hash type")
+            raise AssetError(self, "unknown hash type")
 
         # Calculate the hash of the file:
         with open(cache_file, 'rb') as file:
@@ -111,7 +119,8 @@ def fetch(self):
             return str(self.cache_file)
 
         if not self.fetchable():
-            raise Exception("Asset cache is invalid and downloads disabled")
+            raise AssetError(self,
+                             "Asset cache is invalid and downloads disabled")
 
         self.log.info("Downloading %s to %s...", self.url, self.cache_file)
         tmp_cache_file = self.cache_file.with_suffix(".download")
@@ -147,13 +156,23 @@ def fetch(self):
                                tmp_cache_file)
                 tmp_cache_file.unlink()
                 continue
+            except HTTPError as e:
+                tmp_cache_file.unlink()
+                self.log.error("Unable to download %s: HTTP error %d",
+                               self.url, e.code)
+                # Treat 404 as fatal, since it is highly likely to
+                # indicate a broken test rather than a transient
+                # server or networking problem
+                if e.code == 404:
+                    raise AssetError(self, "Unable to download: "
+                                     "HTTP error %d" % e.code)
+                continue
             except Exception as e:
-                self.log.error("Unable to download %s: %s", self.url, e)
                 tmp_cache_file.unlink()
-                raise
+                raise AssetError(self, "Unable to download: " % e)
 
         if not os.path.exists(tmp_cache_file):
-            raise Exception("Retries exceeded downloading %s", self.url)
+            raise AssetError(self, "Download retries exceeded", transient=True)
 
         try:
             # Set these just for informational purposes
@@ -167,8 +186,7 @@ def fetch(self):
 
         if not self._check(tmp_cache_file):
             tmp_cache_file.unlink()
-            raise Exception("Hash of %s does not match %s" %
-                            (self.url, self.hash))
+            raise AssetError(self, "Hash does not match %s" % self.hash)
         tmp_cache_file.replace(self.cache_file)
         # Remove write perms to stop tests accidentally modifying them
         os.chmod(self.cache_file, stat.S_IRUSR | stat.S_IRGRP)
@@ -190,15 +208,10 @@ def precache_test(test):
                 log.info("Attempting to cache '%s'" % asset)
                 try:
                     asset.fetch()
-                except HTTPError as e:
-                    # Treat 404 as fatal, since it is highly likely to
-                    # indicate a broken test rather than a transient
-                    # server or networking problem
-                    if e.code == 404:
+                except AssetError as e:
+                    if not e.transient:
                         raise
-
-                    log.debug(f"HTTP error {e.code} from {asset.url} " +
-                              "skipping asset precache")
+                    log.error("%s: skipping asset precache" % e)
 
         log.removeHandler(handler)
 
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 8/8] tests/functional: skip vulkan test if missing vulkaninfo
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
                   ` (6 preceding siblings ...)
  2025-03-13  8:01 ` [PULL 7/8] tests/functional/asset: Add AssetError exception class Thomas Huth
@ 2025-03-13  8:01 ` Thomas Huth
  2025-03-14  4:46 ` [PULL 0/8] Fixes for functional tests Stefan Hajnoczi
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2025-03-13  8:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi, Alex Bennée

From: Alex Bennée <alex.bennee@linaro.org>

I could have sworn I had this is a previous iteration of the patches
but I guess it got lost in a re-base. As we are going to call
vulkaninfo to probe for "bad" drivers we need to skip if the binary
isn't available.

Fixes: 9f7e493d11 (tests/functional: skip vulkan tests with nVidia)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250312190314.1632357-1-alex.bennee@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/test_aarch64_virt_gpu.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/functional/test_aarch64_virt_gpu.py b/tests/functional/test_aarch64_virt_gpu.py
index f19a47f8b63..314d994a7aa 100755
--- a/tests/functional/test_aarch64_virt_gpu.py
+++ b/tests/functional/test_aarch64_virt_gpu.py
@@ -115,6 +115,7 @@ def test_aarch64_virt_with_virgl_blobs_gpu(self):
         self._run_virt_weston_test("glmark2-wayland -b:duration=1.0")
 
     @skipIfMissingCommands('zstd')
+    @skipIfMissingCommands('vulkaninfo')
     def test_aarch64_virt_with_vulkan_gpu(self):
 
         self.require_device('virtio-gpu-gl-pci')
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PULL 0/8] Fixes for functional tests
  2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
                   ` (7 preceding siblings ...)
  2025-03-13  8:01 ` [PULL 8/8] tests/functional: skip vulkan test if missing vulkaninfo Thomas Huth
@ 2025-03-14  4:46 ` Stefan Hajnoczi
  8 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-03-14  4:46 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/10.0 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-03-14  4:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13  8:01 [PULL 0/8] Fixes for functional tests Thomas Huth
2025-03-13  8:01 ` [PULL 1/8] docs: Rename default-configs to configs Thomas Huth
2025-03-13  8:01 ` [PULL 2/8] tests/functional: Require 'user' netdev for ppc64 e500 test Thomas Huth
2025-03-13  8:01 ` [PULL 3/8] tests/functional: Bump up arm_replay timeout Thomas Huth
2025-03-13  8:01 ` [PULL 4/8] docs/system: Fix the information on how to run certain functional tests Thomas Huth
2025-03-13  8:01 ` [PULL 5/8] tests/functional/asset: Fail assert fetch when retries are exceeded Thomas Huth
2025-03-13  8:01 ` [PULL 6/8] tests/functional/asset: Verify downloaded size Thomas Huth
2025-03-13  8:01 ` [PULL 7/8] tests/functional/asset: Add AssetError exception class Thomas Huth
2025-03-13  8:01 ` [PULL 8/8] tests/functional: skip vulkan test if missing vulkaninfo Thomas Huth
2025-03-14  4:46 ` [PULL 0/8] Fixes for functional tests Stefan Hajnoczi

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).