Skip to contentSkip to conversation

tests/functional: Convert the advent calendar tests

PATCH In review Thomas Huth 3 participants 11 messages Sep 19, 2024 – Sep 22, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tests/functional: Convert the advent calendar tests

Convert the advent calendar avocado tests to the new functional framework. Since most tests are doing pretty much the same (add a "-kernel" parameter and maybe "-initrd" and "-dtb", then launch QEMU and wait for a string on the serial console), we first introduce a helper function to shorten this repetive task.

Thomas Huth (7):
tests/functional/qemu_test: Add a function for launching kernels more
easily
tests/functional: Convert the vexpressa9 Avocado test tests/functional: Convert the xtensa lx60 Avocado test tests/functional: Convert the SPARCStation Avocado test tests/functional: Convert the e500 ppc64 Avocado test tests/functional: Convert the mac ppc Avocado tests tests/functional: Convert the r2d sh4 Avocado test

 MAINTAINERS                               |  7 ++
 tests/avocado/boot_linux_console.py       | 92 -----------------------
 tests/functional/meson.build              | 15 ++++
 tests/functional/qemu_test/linuxkernel.py | 12 +++
 tests/functional/test_arm_vexpress.py     | 26 +++++++
 tests/functional/test_ppc64_e500.py       | 25 ++++++
 tests/functional/test_ppc_mac.py          | 38 ++++++++++
 tests/functional/test_sh4_r2d.py          | 31 ++++++++
 tests/functional/test_sparc_sun4m.py      | 25 ++++++
 tests/functional/test_xtensa_lx60.py      | 26 +++++++
 10 files changed, 205 insertions(+), 92 deletions(-)
 create mode 100755 tests/functional/test_arm_vexpress.py
 create mode 100755 tests/functional/test_ppc64_e500.py
 create mode 100755 tests/functional/test_ppc_mac.py
 create mode 100755 tests/functional/test_sh4_r2d.py
 create mode 100755 tests/functional/test_sparc_sun4m.py
 create mode 100755 tests/functional/test_xtensa_lx60.py
Signature · 1 line
2.46.0
#1 lore raw

PATCH 1/7 tests/functional/qemu_test: Add a function for launching kernels more easily

The task for launching a kernel is quite repetitive: Set the serial console, set the -kernel and maybe -initrd and -dtb parameters, launch the VM and then wait for the expected console output. So it's easier in some tests to provide these steps via a separate function.

---
 tests/functional/qemu_test/linuxkernel.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/functional/qemu_test/linuxkernel.py +12 -0
index fdd5307629..2b5b9a5fda 100644
@@ -17,6 +17,18 @@ def wait_for_console_pattern(self, success_message, vm=None):
                                  failure_message='Kernel panic - not syncing',
                                  vm=vm)
 
+    def launch_kernel(self, kernel, initrd=None, dtb=None, console_index=0,
+                      wait_for=None):
+        self.vm.set_console(console_index=console_index)
+        self.vm.add_args('-kernel', kernel)
+        if initrd:
+                self.vm.add_args('-initrd', initrd)
+        if dtb:
+                self.vm.add_args('-dtb', dtb)
+        self.vm.launch()
+        if wait_for:
+                self.wait_for_console_pattern(wait_for)
+
     def extract_from_deb(self, deb_path, path):
         """
         Extracts a file from a deb package into the test workdir
Signature · 1 line
2.46.0
#2 lore raw

PATCH 2/7 tests/functional: Convert the vexpressa9 Avocado test

In reply to Thomas Huth

Use the new launch_kernel function to convert this test in a simple way.

---
 MAINTAINERS                           |  1 +
 tests/avocado/boot_linux_console.py   |  9 ---------
 tests/functional/meson.build          |  1 +
 tests/functional/test_arm_vexpress.py | 26 ++++++++++++++++++++++++++
 4 files changed, 28 insertions(+), 9 deletions(-)
 create mode 100755 tests/functional/test_arm_vexpress.py
MAINTAINERS +1 -0
index ffacd60f40..7f7f4c2be6 100644
@@ -1005,6 +1005,7 @@ S: Maintained
 F: hw/arm/vexpress.c
 F: hw/display/sii9022.c
 F: docs/system/arm/vexpress.rst
+F: tests/functional/test_arm_vexpress.py
 
 Versatile PB
 M: Peter Maydell <[email protected]>
tests/avocado/boot_linux_console.py +0 -9
index 6c50284986..7a776c2818 100644
@@ -893,15 +893,6 @@ def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0):
         self.vm.launch()
         self.wait_for_console_pattern('QEMU advent calendar')
 
-    def test_arm_vexpressa9(self):
-        """
-        :avocado: tags=arch:arm
-        :avocado: tags=machine:vexpress-a9
-        """
-        tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
-        self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
-        self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
-
     def test_arm_ast2600_debian(self):
         """
         :avocado: tags=arch:arm
tests/functional/meson.build +1 -0
index 8d5520349d..3fc1bb192d 100644
@@ -50,6 +50,7 @@ tests_arm_system_thorough = [
   'arm_canona1100',
   'arm_integratorcp',
   'arm_raspi2',
+  'arm_vexpress',
 ]
 
 tests_arm_linuxuser_thorough = [
tests/functional/test_arm_vexpress.py new file +26 -0
new file mode 100755
index 0000000000..cc6015112b
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on an versatile express machine
+# and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class VExpressTest(LinuxKernelTest):
+
+    ASSET_DAY16 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day16.tar.xz',
+        '63311adb2d4c4e7a73214a86d29988add87266a909719c56acfadd026b4110a7')
+
+    def test_arm_vexpressa9(self):
+        self.set_machine('vexpress-a9')
+        file_path = self.ASSET_DAY16.fetch()
+        archive_extract(file_path, self.workdir)
+        self.launch_kernel(self.workdir + '/day16/winter.zImage',
+                           dtb=self.workdir + '/day16/vexpress-v2p-ca9.dtb',
+                           wait_for='QEMU advent calendar')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
Signature · 1 line
2.46.0
#3 lore raw

PATCH 3/7 tests/functional: Convert the xtensa lx60 Avocado test

In reply to Thomas Huth

Use the new launch_kernel function to convert this test in a simple way.

---
 MAINTAINERS                          |  1 +
 tests/avocado/boot_linux_console.py  |  9 ---------
 tests/functional/meson.build         |  4 ++++
 tests/functional/test_xtensa_lx60.py | 26 ++++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100755 tests/functional/test_xtensa_lx60.py
MAINTAINERS +1 -0
index 7f7f4c2be6..a75d6ba7d2 100644
@@ -1915,6 +1915,7 @@ S: Maintained
 F: hw/xtensa/xtfpga.c
 F: hw/net/opencores_eth.c
 F: include/hw/xtensa/mx_pic.h
+F: tests/functional/test_xtensa_lx60.py
 
 Devices
 -------
tests/avocado/boot_linux_console.py +0 -9
index 7a776c2818..cf58499c84 100644
@@ -1027,12 +1027,3 @@ def test_sparc_ss20(self):
         """
         tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
         self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
-
-    def test_xtensa_lx60(self):
-        """
-        :avocado: tags=arch:xtensa
-        :avocado: tags=machine:lx60
-        :avocado: tags=cpu:dc233c
-        """
-        tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
-        self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')
tests/functional/meson.build +4 -0
index 3fc1bb192d..8fd852f4ab 100644
@@ -145,6 +145,10 @@ tests_x86_64_system_thorough = [
   'virtio_gpu',
 ]
 
+tests_xtensa_system_thorough = [
+  'xtensa_lx60',
+]
+
 precache_all = []
 foreach speed : ['quick', 'thorough']
   foreach dir : target_dirs
tests/functional/test_xtensa_lx60.py new file +26 -0
new file mode 100755
index 0000000000..8ce5206a4f
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on an xtensa lx650 machine
+# and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class XTensaLX60Test(LinuxKernelTest):
+
+    ASSET_DAY02 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day02.tar.xz',
+        '68ff07f9b3fd3df36d015eb46299ba44748e94bfbb2d5295fddc1a8d4a9fd324')
+
+    def test_xtensa_lx60(self):
+        self.set_machine('lx60')
+        self.cpu = 'dc233c'
+        file_path = self.ASSET_DAY02.fetch()
+        archive_extract(file_path, self.workdir)
+        self.launch_kernel(self.workdir + '/day02/santas-sleigh-ride.elf',
+                           wait_for='QEMU advent calendar')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
Signature · 1 line
2.46.0
#4 lore raw

PATCH 4/7 tests/functional: Convert the SPARCStation Avocado test

In reply to Thomas Huth

Use the new launch_kernel function to convert this test in a simple way.

---
 MAINTAINERS                          |  1 +
 tests/avocado/boot_linux_console.py  |  8 --------
 tests/functional/meson.build         |  4 ++++
 tests/functional/test_sparc_sun4m.py | 25 +++++++++++++++++++++++++
 4 files changed, 30 insertions(+), 8 deletions(-)
 create mode 100755 tests/functional/test_sparc_sun4m.py
MAINTAINERS +1 -0
index a75d6ba7d2..b85a3fc529 100644
@@ -1693,6 +1693,7 @@ F: include/hw/nvram/sun_nvram.h
 F: include/hw/sparc/sparc32_dma.h
 F: include/hw/sparc/sun4m_iommu.h
 F: pc-bios/openbios-sparc32
+F: tests/functional/test_sparc_sun4m.py
 
 Sun4u
 M: Mark Cave-Ayland <[email protected]>
tests/avocado/boot_linux_console.py +0 -8
index cf58499c84..900af67412 100644
@@ -1019,11 +1019,3 @@ def test_sh4_r2d(self):
         tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
         self.vm.add_args('-append', 'console=ttySC1')
         self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)
-
-    def test_sparc_ss20(self):
-        """
-        :avocado: tags=arch:sparc
-        :avocado: tags=machine:SS-20
-        """
-        tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
-        self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
tests/functional/meson.build +4 -0
index 8fd852f4ab..8aacd15cf3 100644
@@ -125,6 +125,10 @@ tests_s390x_system_thorough = [
   's390x_topology',
 ]
 
+tests_sparc_system_thorough = [
+  'sparc_sun4m',
+]
+
 tests_sparc64_system_thorough = [
   'sparc64_sun4u',
 ]
tests/functional/test_sparc_sun4m.py new file +25 -0
new file mode 100755
index 0000000000..b334375820
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on a sparc sun4m machine
+# and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class Sun4mTest(LinuxKernelTest):
+
+    ASSET_DAY11 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day11.tar.xz',
+        'c776533ba756bf4dd3f1fc4c024fb50ef0d853e05c5f5ddf0900a32d1eaa49e0')
+
+    def test_sparc_ss20(self):
+        self.set_machine('SS-20')
+        file_path = self.ASSET_DAY11.fetch()
+        archive_extract(file_path, self.workdir)
+        self.launch_kernel(self.workdir + '/day11/zImage.elf',
+                           wait_for='QEMU advent calendar')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
Signature · 1 line
2.46.0
Acked-by on v1 4/7
#5 lore raw

Re: [PATCH 4/7] tests/functional: Convert the SPARCStation Avocado test

Quoted 75 lines · Thomas Huth

Use the new launch_kernel function to convert this test in a simple way.

---
  MAINTAINERS                          |  1 +
  tests/avocado/boot_linux_console.py  |  8 --------
  tests/functional/meson.build         |  4 ++++
  tests/functional/test_sparc_sun4m.py | 25 +++++++++++++++++++++++++
  4 files changed, 30 insertions(+), 8 deletions(-)

create mode 100755 tests/functional/test_sparc_sun4m.py

MAINTAINERS +1 -0
index a75d6ba7d2..b85a3fc529 100644
@@ -1693,6 +1693,7 @@ F: include/hw/nvram/sun_nvram.h
  F: include/hw/sparc/sparc32_dma.h
  F: include/hw/sparc/sun4m_iommu.h
  F: pc-bios/openbios-sparc32
+F: tests/functional/test_sparc_sun4m.py
 
  Sun4u
  M: Mark Cave-Ayland <[email protected]>
tests/avocado/boot_linux_console.py +0 -8
index cf58499c84..900af67412 100644
@@ -1019,11 +1019,3 @@ def test_sh4_r2d(self):
          tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
          self.vm.add_args('-append', 'console=ttySC1')
          self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)
-
-    def test_sparc_ss20(self):
-        """
-        :avocado: tags=arch:sparc
-        :avocado: tags=machine:SS-20
-        """
-        tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
-        self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
tests/functional/meson.build +4 -0
index 8fd852f4ab..8aacd15cf3 100644
@@ -125,6 +125,10 @@ tests_s390x_system_thorough = [
    's390x_topology',
  ]
 
+tests_sparc_system_thorough = [
+  'sparc_sun4m',
+]
+
  tests_sparc64_system_thorough = [
    'sparc64_sun4u',
  ]
tests/functional/test_sparc_sun4m.py new file +15 -0
new file mode 100755
index 0000000000..b334375820
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on a sparc sun4m machine
+# and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class Sun4mTest(LinuxKernelTest):
+
+    ASSET_DAY11 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day11.tar.xz',
+        'c776533ba756bf4dd3f1fc4c024fb50ef0d853e05c5f5ddf0900a32d1eaa49e0')

tests/functional/test_sparc_sun4m.py line 25

Quoted 10 lines
tests/functional/test_sparc_sun4m.py new file +10 -0
+
+    def test_sparc_ss20(self):
+        self.set_machine('SS-20')
+        file_path = self.ASSET_DAY11.fetch()
+        archive_extract(file_path, self.workdir)
+        self.launch_kernel(self.workdir + '/day11/zImage.elf',
+                           wait_for='QEMU advent calendar')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()

ATB,

Mark.

#6 lore raw

PATCH 5/7 tests/functional: Convert the e500 ppc64 Avocado test

In reply to Thomas Huth

Use the new launch_kernel function to convert this test in a simple way.

---
 MAINTAINERS                         |  1 +
 tests/avocado/boot_linux_console.py | 11 -----------
 tests/functional/meson.build        |  1 +
 tests/functional/test_ppc64_e500.py | 25 +++++++++++++++++++++++++
 4 files changed, 27 insertions(+), 11 deletions(-)
 create mode 100755 tests/functional/test_ppc64_e500.py
MAINTAINERS +1 -0
index b85a3fc529..3dd80a0138 100644
@@ -1445,6 +1445,7 @@ F: pc-bios/u-boot.e500
 F: hw/intc/openpic_kvm.c
 F: include/hw/ppc/openpic_kvm.h
 F: docs/system/ppc/ppce500.rst
+F: tests/functional/test_ppc64_e500.py
 
 mpc8544ds
 L: [email protected]
tests/avocado/boot_linux_console.py +0 -11
index 900af67412..344c7835a2 100644
@@ -918,17 +918,6 @@ def test_arm_ast2600_debian(self):
         self.wait_for_console_pattern("SMP: Total of 2 processors activated")
         self.wait_for_console_pattern("No filesystem could mount root")
 
-    def test_ppc64_e500(self):
-        """
-        :avocado: tags=arch:ppc64
-        :avocado: tags=machine:ppce500
-        :avocado: tags=cpu:e5500
-        :avocado: tags=accel:tcg
-        """
-        self.require_accelerator("tcg")
-        tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
-        self.do_test_advcal_2018('19', tar_hash, 'uImage')
-
     def do_test_ppc64_powernv(self, proc):
         self.require_accelerator("tcg")
         images_url = ('https://github.com/open-power/op-build/releases/download/v2.7/')
tests/functional/meson.build +1 -0
index 8aacd15cf3..bc33332313 100644
@@ -111,6 +111,7 @@ tests_ppc_system_thorough = [
 ]
 
 tests_ppc64_system_thorough = [
+  'ppc64_e500',
   'ppc64_hv',
   'ppc64_powernv',
   'ppc64_pseries',
tests/functional/test_ppc64_e500.py new file +25 -0
new file mode 100755
index 0000000000..3558ae0c8c
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+#
+# Boot a Linux kernel on a e500 ppc64 machine and check the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class E500Test(LinuxKernelTest):
+
+    ASSET_DAY19 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day19.tar.xz',
+        '20b1bb5a8488c664defbb5d283addc91a05335a936c63b3f5ff7eee74b725755')
+
+    def test_ppc64_e500(self):
+        self.set_machine('ppce500')
+        self.cpu = 'e5500'
+        file_path = self.ASSET_DAY19.fetch()
+        archive_extract(file_path, self.workdir)
+        self.launch_kernel(self.workdir + '/day19/uImage',
+                           wait_for='QEMU advent calendar')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
Signature · 1 line
2.46.0
#7 lore raw

PATCH 6/7 tests/functional: Convert the mac ppc Avocado tests

In reply to Thomas Huth

The g3beige and mac99 tests use the same asset, so put them together in a new test_ppc_mac.py file.

---
 MAINTAINERS                         |  2 ++
 tests/avocado/boot_linux_console.py | 30 -----------------------
 tests/functional/meson.build        |  1 +
 tests/functional/test_ppc_mac.py    | 38 +++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 30 deletions(-)
 create mode 100755 tests/functional/test_ppc_mac.py
MAINTAINERS +2 -0
index 3dd80a0138..63eb306d6e 100644
@@ -1474,6 +1474,7 @@ F: include/hw/ppc/mac_dbdma.h
 F: include/hw/pci-host/uninorth.h
 F: include/hw/input/adb*
 F: pc-bios/qemu_vga.ndrv
+F: tests/functional/test_ppc_mac.py
 
 Old World (g3beige)
 M: Mark Cave-Ayland <[email protected]>
@@ -1489,6 +1490,7 @@ F: include/hw/intc/heathrow_pic.h
 F: include/hw/input/adb*
 F: include/hw/pci-host/grackle.h
 F: pc-bios/qemu_vga.ndrv
+F: tests/functional/test_ppc_mac.py
 
 PReP
 M: Hervé Poussineau <[email protected]>
tests/avocado/boot_linux_console.py +0 -30
index 344c7835a2..f5dc9e9cfa 100644
@@ -965,36 +965,6 @@ def test_ppc_powernv10(self):
         """
         self.do_test_ppc64_powernv('P10')
 
-    def test_ppc_g3beige(self):
-        """
-        :avocado: tags=arch:ppc
-        :avocado: tags=machine:g3beige
-        :avocado: tags=accel:tcg
-        """
-        # TODO: g3beige works with kvm_pr but we don't have a
-        # reliable way ATM (e.g. looking at /proc/modules) to detect
-        # whether we're running kvm_hv or kvm_pr. For now let's
-        # disable this test if we don't have TCG support.
-        self.require_accelerator("tcg")
-        tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
-        self.vm.add_args('-M', 'graphics=off')
-        self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
-
-    def test_ppc_mac99(self):
-        """
-        :avocado: tags=arch:ppc
-        :avocado: tags=machine:mac99
-        :avocado: tags=accel:tcg
-        """
-        # TODO: mac99 works with kvm_pr but we don't have a
-        # reliable way ATM (e.g. looking at /proc/modules) to detect
-        # whether we're running kvm_hv or kvm_pr. For now let's
-        # disable this test if we don't have TCG support.
-        self.require_accelerator("tcg")
-        tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
-        self.vm.add_args('-M', 'graphics=off')
-        self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
-
     # This test has a 6-10% failure rate on various hosts that look
     # like issues with a buggy kernel. As a result we don't want it
     # gating releases on Gitlab.
tests/functional/meson.build +1 -0
index bc33332313..449c6a95ea 100644
@@ -106,6 +106,7 @@ tests_ppc_system_thorough = [
   'ppc_40p',
   'ppc_amiga',
   'ppc_bamboo',
+  'ppc_mac',
   'ppc_mpc8544ds',
   'ppc_virtex_ml507',
 ]
tests/functional/test_ppc_mac.py new file +38 -0
new file mode 100755
index 0000000000..a6b1ca2d4c
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+#
+# Boot Linux kernel on a mac99 and g3beige ppc machine and check the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class MacTest(LinuxKernelTest):
+
+    ASSET_DAY15 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day15.tar.xz',
+        '03e0757c131d2959decf293a3572d3b96c5a53587165bf05ce41b2818a2bccd5')
+
+    def do_day15_test(self):
+        # mac99 also works with kvm_pr but we don't have a reliable way at
+        # the moment (e.g. by looking at /proc/modules) to detect whether
+        # we're running kvm_hv or kvm_pr. For now let's disable this test
+        # if we don't have TCG support.
+        self.require_accelerator("tcg")
+
+        file_path = self.ASSET_DAY15.fetch()
+        archive_extract(file_path, self.workdir)
+        self.vm.add_args('-M', 'graphics=off')
+        self.launch_kernel(self.workdir + '/day15/invaders.elf',
+                           wait_for='QEMU advent calendar')
+
+    def test_ppc_g3beige(self):
+        self.set_machine('g3beige')
+        self.do_day15_test()
+
+    def test_ppc_mac99(self):
+        self.set_machine('mac99')
+        self.do_day15_test()
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
Signature · 1 line
2.46.0
Acked-by on v1 6/7
#8 lore raw

Re: [PATCH 6/7] tests/functional: Convert the mac ppc Avocado tests

Quoted 119 lines · Thomas Huth

The g3beige and mac99 tests use the same asset, so put them together in a new test_ppc_mac.py file.

---
  MAINTAINERS                         |  2 ++
  tests/avocado/boot_linux_console.py | 30 -----------------------
  tests/functional/meson.build        |  1 +
  tests/functional/test_ppc_mac.py    | 38 +++++++++++++++++++++++++++++
  4 files changed, 41 insertions(+), 30 deletions(-)

create mode 100755 tests/functional/test_ppc_mac.py

MAINTAINERS +2 -0
index 3dd80a0138..63eb306d6e 100644
@@ -1474,6 +1474,7 @@ F: include/hw/ppc/mac_dbdma.h
  F: include/hw/pci-host/uninorth.h
  F: include/hw/input/adb*
  F: pc-bios/qemu_vga.ndrv
+F: tests/functional/test_ppc_mac.py
 
  Old World (g3beige)
  M: Mark Cave-Ayland <[email protected]>
@@ -1489,6 +1490,7 @@ F: include/hw/intc/heathrow_pic.h
  F: include/hw/input/adb*
  F: include/hw/pci-host/grackle.h
  F: pc-bios/qemu_vga.ndrv
+F: tests/functional/test_ppc_mac.py
 
  PReP
  M: Hervé Poussineau <[email protected]>
tests/avocado/boot_linux_console.py +0 -30
index 344c7835a2..f5dc9e9cfa 100644
@@ -965,36 +965,6 @@ def test_ppc_powernv10(self):
          """
          self.do_test_ppc64_powernv('P10')
 
-    def test_ppc_g3beige(self):
-        """
-        :avocado: tags=arch:ppc
-        :avocado: tags=machine:g3beige
-        :avocado: tags=accel:tcg
-        """
-        # TODO: g3beige works with kvm_pr but we don't have a
-        # reliable way ATM (e.g. looking at /proc/modules) to detect
-        # whether we're running kvm_hv or kvm_pr. For now let's
-        # disable this test if we don't have TCG support.
-        self.require_accelerator("tcg")
-        tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
-        self.vm.add_args('-M', 'graphics=off')
-        self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
-
-    def test_ppc_mac99(self):
-        """
-        :avocado: tags=arch:ppc
-        :avocado: tags=machine:mac99
-        :avocado: tags=accel:tcg
-        """
-        # TODO: mac99 works with kvm_pr but we don't have a
-        # reliable way ATM (e.g. looking at /proc/modules) to detect
-        # whether we're running kvm_hv or kvm_pr. For now let's
-        # disable this test if we don't have TCG support.
-        self.require_accelerator("tcg")
-        tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
-        self.vm.add_args('-M', 'graphics=off')
-        self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
-
      # This test has a 6-10% failure rate on various hosts that look
      # like issues with a buggy kernel. As a result we don't want it
      # gating releases on Gitlab.
tests/functional/meson.build +1 -0
index bc33332313..449c6a95ea 100644
@@ -106,6 +106,7 @@ tests_ppc_system_thorough = [
    'ppc_40p',
    'ppc_amiga',
    'ppc_bamboo',
+  'ppc_mac',
    'ppc_mpc8544ds',
    'ppc_virtex_ml507',
  ]
tests/functional/test_ppc_mac.py new file +28 -0
new file mode 100755
index 0000000000..a6b1ca2d4c
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+#
+# Boot Linux kernel on a mac99 and g3beige ppc machine and check the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+
+class MacTest(LinuxKernelTest):
+
+    ASSET_DAY15 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day15.tar.xz',
+        '03e0757c131d2959decf293a3572d3b96c5a53587165bf05ce41b2818a2bccd5')
+
+    def do_day15_test(self):
+        # mac99 also works with kvm_pr but we don't have a reliable way at
+        # the moment (e.g. by looking at /proc/modules) to detect whether
+        # we're running kvm_hv or kvm_pr. For now let's disable this test
+        # if we don't have TCG support.
+        self.require_accelerator("tcg")
+
+        file_path = self.ASSET_DAY15.fetch()
+        archive_extract(file_path, self.workdir)
+        self.vm.add_args('-M', 'graphics=off')
+        self.launch_kernel(self.workdir + '/day15/invaders.elf',
+                           wait_for='QEMU advent calendar')
+

tests/functional/test_ppc_mac.py line 38

Quoted 10 lines
tests/functional/test_ppc_mac.py new file +10 -0
+    def test_ppc_g3beige(self):
+        self.set_machine('g3beige')
+        self.do_day15_test()
+
+    def test_ppc_mac99(self):
+        self.set_machine('mac99')
+        self.do_day15_test()
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()

ATB,

Mark.

#9 lore raw

PATCH 7/7 tests/functional: Convert the r2d sh4 Avocado test

In reply to Thomas Huth

This is the last test that is using the do_test_advcal_2018() function, so we can now remove that function from boot_linux_console.py, too.

---
 MAINTAINERS                         |  1 +
 tests/avocado/boot_linux_console.py | 25 -----------------------
 tests/functional/meson.build        |  4 ++++
 tests/functional/test_sh4_r2d.py    | 31 +++++++++++++++++++++++++++++
 4 files changed, 36 insertions(+), 25 deletions(-)
 create mode 100755 tests/functional/test_sh4_r2d.py
MAINTAINERS +1 -0
index 63eb306d6e..62f5255f40 100644
@@ -1679,6 +1679,7 @@ F: hw/pci-host/sh_pci.c
 F: hw/timer/sh_timer.c
 F: include/hw/sh4/sh_intc.h
 F: include/hw/timer/tmu012.h
+F: tests/functional/test_sh4_r2d.py
 
 SPARC Machines
 --------------
tests/avocado/boot_linux_console.py +0 -25
index f5dc9e9cfa..759fda9cc8 100644
@@ -882,17 +882,6 @@ def test_arm_orangepi_uboot_netbsd9(self):
         # Wait for user-space
         wait_for_console_pattern(self, 'Starting root file system check')
 
-    def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0):
-        tar_url = ('https://qemu-advcal.gitlab.io'
-                   '/qac-best-of-multiarch/download/day' + day + '.tar.xz')
-        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
-        archive.extract(file_path, self.workdir)
-        self.vm.set_console(console_index=console)
-        self.vm.add_args('-kernel',
-                         self.workdir + '/day' + day + '/' + kernel_name)
-        self.vm.launch()
-        self.wait_for_console_pattern('QEMU advent calendar')
-
     def test_arm_ast2600_debian(self):
         """
         :avocado: tags=arch:arm
@@ -964,17 +953,3 @@ def test_ppc_powernv10(self):
         :avocado: tags=accel:tcg
         """
         self.do_test_ppc64_powernv('P10')
-
-    # This test has a 6-10% failure rate on various hosts that look
-    # like issues with a buggy kernel. As a result we don't want it
-    # gating releases on Gitlab.
-    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab')
-    def test_sh4_r2d(self):
-        """
-        :avocado: tags=arch:sh4
-        :avocado: tags=machine:r2d
-        :avocado: tags=flaky
-        """
-        tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
-        self.vm.add_args('-append', 'console=ttySC1')
-        self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)
tests/functional/meson.build +4 -0
index 449c6a95ea..56a541530f 100644
@@ -127,6 +127,10 @@ tests_s390x_system_thorough = [
   's390x_topology',
 ]
 
+tests_sh4_system_thorough = [
+  'sh4_r2d',
+]
+
 tests_sparc_system_thorough = [
   'sparc_sun4m',
 ]
tests/functional/test_sh4_r2d.py new file +31 -0
new file mode 100755
index 0000000000..5fe8cf9f8d
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+#
+# Boot a Linux kernel on a r2d sh4 machine and check the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test.utils import archive_extract
+from unittest import skipUnless
+
+class R2dTest(LinuxKernelTest):
+
+    ASSET_DAY09 = Asset(
+        'https://www.qemu-advent-calendar.org/2018/download/day09.tar.xz',
+        'a61b44d2630a739d1380cc4ff4b80981d47ccfd5992f1484ccf48322c35f09ac')
+
+    # This test has a 6-10% failure rate on various hosts that look
+    # like issues with a buggy kernel.
+    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable')
+    def test_r2d(self):
+        self.set_machine('r2d')
+        file_path = self.ASSET_DAY09.fetch()
+        archive_extract(file_path, self.workdir)
+        self.vm.add_args('-append', 'console=ttySC1')
+        self.launch_kernel(self.workdir + '/day09/zImage', console_index=1,
+                           wait_for='QEMU advent calendar')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
Signature · 1 line
2.46.0
Reviewed-by on the v1 series
#10 lore raw
In reply to Thomas Huth
Quoted 9 lines · Thomas Huth

Thomas Huth (7):
tests/functional/qemu_test: Add a function for launching kernels more
easily
tests/functional: Convert the vexpressa9 Avocado test tests/functional: Convert the xtensa lx60 Avocado test tests/functional: Convert the SPARCStation Avocado test tests/functional: Convert the e500 ppc64 Avocado test tests/functional: Convert the mac ppc Avocado tests tests/functional: Convert the r2d sh4 Avocado test

r~