Skip to contentSkip to conversation

tests/functional: Convert Aarch64 Virt machine avocado tests

PATCH Superseded Philippe Mathieu-Daudé 2 participants 2 messages Aug 23, 2024 – Aug 26, 2024 Arm/Amlogic Meson SoC support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests/functional: Convert Aarch64 Virt machine avocado tests

Straight forward conversion. Update the SHA1 hash to SHA256 since SHA1 should not be used anymore nowadays.

Provide get_qemu_img() helper in qemu_test.

  $ make check-functional-aarch64 V=1
  ...
  ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv2                 OK
  ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv3                 OK
  ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_alpine_virt_tcg_gic_max            OK
  1/4 qemu:func-thorough+func-aarch64-thorough+thorough / func-aarch64-aarch64_virt  OK   30.44s  3 subtests passed

---
Based-on: <[email protected]>

---
 MAINTAINERS                                   |  2 +-
 tests/functional/meson.build                  |  2 +
 tests/functional/qemu_test/__init__.py        |  2 +-
 tests/functional/qemu_test/cmd.py             | 15 ++++
 .../test_aarch64_virt.py}                     | 69 ++++++++-----------
 5 files changed, 46 insertions(+), 44 deletions(-)
 rename tests/{avocado/machine_aarch64_virt.py => functional/test_aarch64_virt.py} (69%)
 mode change 100644 => 100755
MAINTAINERS +1 -1
index c720c02800..502065a1f2 100644
@@ -1023,7 +1023,7 @@ S: Maintained
 F: hw/arm/virt*
 F: include/hw/arm/virt.h
 F: docs/system/arm/virt.rst
-F: tests/avocado/machine_aarch64_virt.py
+F: tests/functional/test_aarch64_virt.py
 
 Xilinx Zynq
 M: Edgar E. Iglesias <[email protected]>
tests/functional/meson.build +2 -0
index 2445239a5c..8e04695a4c 100644
@@ -12,6 +12,7 @@ endif
 # Timeouts for individual tests that can be slow e.g. with debugging enabled
 test_timeouts = {
   'aarch64_sbsaref' : 180,
+  'aarch64_virt' : 360,
   'acpi_bits' : 240,
   'netdev_ethtool' : 180,
   'ppc_40p' : 240,
@@ -29,6 +30,7 @@ tests_generic = [
 
 tests_aarch64_thorough = [
   'aarch64_sbsaref',
+  'aarch64_virt',
 ]
 
 tests_arm_thorough = [
tests/functional/qemu_test/__init__.py +1 -1
index 6e9b017264..f33282efe8 100644
@@ -10,5 +10,5 @@
 from .config import BUILD_DIR
 from .cmd import has_cmd, has_cmds, run_cmd, is_readable_executable_file, \
     interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
-    exec_command, exec_command_and_wait_for_pattern
+    exec_command, exec_command_and_wait_for_pattern, get_qemu_img
 from .testcase import QemuBaseTest, QemuUserTest, QemuSystemTest
tests/functional/qemu_test/cmd.py +15 -0
index 8580ee8faf..7db609aac9 100644
@@ -16,6 +16,8 @@
 import os.path
 import subprocess
 
+from .config import BUILD_DIR
+
 
 def has_cmd(name, args=None):
     """
@@ -176,3 +178,16 @@ def exec_command_and_wait_for_pattern(test, command,
     :param failure_message: if this message appears, test fails
     """
     _console_interaction(test, success_message, failure_message, command + '\r')
+
+def get_qemu_img(test):
+    test.log.debug('Looking for and selecting a qemu-img binary')
+
+    # If qemu-img has been built, use it, otherwise the system wide one
+    # will be used.
+    qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
+    if os.path.exists(qemu_img):
+        return qemu_img
+    if has_cmd('qemu-img'):
+        return 'qemu-img'
+    test.cancel('Could not find "qemu-img", which is required to '
+                'create temporary images')
tests/functional/test_aarch64_virt.py renamed from tests/avocado/machine_aarch64_virt.py +27 -42

115 lines not on this page · raw message

Signature · 1 line
2.45.2
#1 lore raw
Quoted 24 lines · Philippe Mathieu-Daudé

Straight forward conversion. Update the SHA1 hash to SHA256 since SHA1 should not be used anymore nowadays.

Provide get_qemu_img() helper in qemu_test.

   $ make check-functional-aarch64 V=1
   ...
   ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv2                 OK
   ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv3                 OK
   ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_alpine_virt_tcg_gic_max            OK
   1/4 qemu:func-thorough+func-aarch64-thorough+thorough / func-aarch64-aarch64_virt  OK   30.44s  3 subtests passed

---
Based-on: <[email protected]>

---
  MAINTAINERS                                   |  2 +-
  tests/functional/meson.build                  |  2 +
  tests/functional/qemu_test/__init__.py        |  2 +-
  tests/functional/qemu_test/cmd.py             | 15 ++++
  .../test_aarch64_virt.py}                     | 69 ++++++++-----------
  5 files changed, 46 insertions(+), 44 deletions(-)

rename tests/{avocado/machine_aarch64_virt.py => functional/test_aarch64_virt.py} (69%) mode change 100644 => 100755

...

Quoted 7 lines
tests/functional/qemu_test/cmd.py +3 -0
@@ -176,3 +178,16 @@ def exec_command_and_wait_for_pattern(test, command,
      :param failure_message: if this message appears, test fails
      """
      _console_interaction(test, success_message, failure_message, command + '\r')
+
+def get_qemu_img(test):
+    test.log.debug('Looking for and selecting a qemu-img binary')

tests/functional/qemu_test/cmd.py def exec_command_and_wait_for_pattern(test, command, · line 193

Quoted 10 lines
tests/functional/qemu_test/cmd.py +10 -0
+
+    # If qemu-img has been built, use it, otherwise the system wide one
+    # will be used.
+    qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
+    if os.path.exists(qemu_img):
+        return qemu_img
+    if has_cmd('qemu-img'):
+        return 'qemu-img'
+    test.cancel('Could not find "qemu-img", which is required to '
+                'create temporary images')

Please use self.skipTest() instead ... cancel() was something from the Avocado framework only.

Apart from that the patch looks fine to me now, thanks!

Thomas