qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests
@ 2024-08-26 22:10 Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-26 22:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cleber Rosa, Thomas Huth, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell,
	Philippe Mathieu-Daudé

▶ 4/5 test_aarch64_raspi3.Aarch64Raspi3Machine.test_aarch64_raspi3_atf                OK
4/5 qemu:func-thorough+func-aarch64-thorough+thorough / func-aarch64-aarch64_raspi3   OK   1.96s   1 subtests passed
▶ 5/5 test_aarch64_raspi4.Aarch64Raspi4Machine.test_arm_raspi4                        OK
5/5 qemu:func-thorough+func-aarch64-thorough+thorough / func-aarch64-aarch64_raspi4   OK   5.19s   1 subtests passed
▶ 6/6 test_arm_raspi2.ArmRaspi2Machine.test_arm_raspi2_initrd                         OK
▶ 6/6 test_arm_raspi2.ArmRaspi2Machine.test_arm_raspi2_uart0                          OK
6/6 qemu:func-thorough+func-arm-thorough+thorough / func-arm-arm_raspi2               OK   15.31s   2 subtests passed

Based-on: <20240821082748.65853-1-thuth@redhat.com>

Philippe Mathieu-Daudé (4):
  tests/functional: Add a class containing Linux kernel helpers
  tests/functional: Convert ARM Raspi2 avocado tests
  tests/functional: Convert Aarch64 Raspi3 avocado tests
  tests/functional: Convert Aarch64 Raspi4 avocado tests

 MAINTAINERS                                |   3 +
 tests/avocado/boot_linux_console.py        | 205 ---------------------
 tests/functional/meson.build               |   6 +
 tests/functional/qemu_test/linux_kernel.py |  19 ++
 tests/functional/test_aarch64_raspi3.py    |  42 +++++
 tests/functional/test_aarch64_raspi4.py    | 106 +++++++++++
 tests/functional/test_arm_raspi2.py        | 103 +++++++++++
 7 files changed, 279 insertions(+), 205 deletions(-)
 create mode 100644 tests/functional/qemu_test/linux_kernel.py
 create mode 100755 tests/functional/test_aarch64_raspi3.py
 create mode 100755 tests/functional/test_aarch64_raspi4.py
 create mode 100755 tests/functional/test_arm_raspi2.py

-- 
2.45.2



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

* [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers
  2024-08-26 22:10 [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests Philippe Mathieu-Daudé
@ 2024-08-26 22:10 ` Philippe Mathieu-Daudé
  2024-08-27  5:34   ` Thomas Huth
  2024-08-26 22:10 ` [PATCH 2/4] tests/functional: Convert ARM Raspi2 avocado tests Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-26 22:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cleber Rosa, Thomas Huth, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell,
	Philippe Mathieu-Daudé

Use the 'linux_kernel' namespace to provide common helpers
to functional tests booting a Linux kernel.

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tests/functional/qemu_test/linux_kernel.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 tests/functional/qemu_test/linux_kernel.py

diff --git a/tests/functional/qemu_test/linux_kernel.py b/tests/functional/qemu_test/linux_kernel.py
new file mode 100644
index 0000000000..917beb7fb6
--- /dev/null
+++ b/tests/functional/qemu_test/linux_kernel.py
@@ -0,0 +1,19 @@
+# Linux kernel functional test helpers
+#
+# Copyright (c) 2024 Linaro Ltd.
+#
+# Author:
+#  Philippe Mathieu-Daudé <philmd@linaro.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from . import wait_for_console_pattern
+
+KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+
+KERNEL_PANIC_MESSAGE = 'Kernel panic - not syncing'
+
+def linux_kernel_wait_for_pattern(test, success_message):
+    wait_for_console_pattern(test,
+                             success_message=success_message,
+                             failure_message=KERNEL_PANIC_MESSAGE)
-- 
2.45.2



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

* [PATCH 2/4] tests/functional: Convert ARM Raspi2 avocado tests
  2024-08-26 22:10 [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers Philippe Mathieu-Daudé
@ 2024-08-26 22:10 ` Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 3/4] tests/functional: Convert Aarch64 Raspi3 " Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 4/4] tests/functional: Convert Aarch64 Raspi4 " Philippe Mathieu-Daudé
  3 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-26 22:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cleber Rosa, Thomas Huth, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell,
	Philippe Mathieu-Daudé

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS                         |   1 +
 tests/avocado/boot_linux_console.py |  85 -----------------------
 tests/functional/meson.build        |   1 +
 tests/functional/test_arm_raspi2.py | 103 ++++++++++++++++++++++++++++
 4 files changed, 105 insertions(+), 85 deletions(-)
 create mode 100755 tests/functional/test_arm_raspi2.py

diff --git a/MAINTAINERS b/MAINTAINERS
index e2e62afcdc..e2bbf1a994 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -910,6 +910,7 @@ F: hw/*/bcm283*
 F: include/hw/arm/rasp*
 F: include/hw/*/bcm283*
 F: docs/system/arm/raspi.rst
+F: tests/functional/test_arm_raspi2.py
 
 Real View
 M: Peter Maydell <peter.maydell@linaro.org>
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
index 370beb795a..226b92d057 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -203,91 +203,6 @@ def test_arm_emcraft_sf2(self):
         exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
             '3 packets transmitted, 3 packets received, 0% packet loss')
 
-    def do_test_arm_raspi2(self, uart_id):
-        """
-        :avocado: tags=accel:tcg
-
-        The kernel can be rebuilt using the kernel source referenced
-        and following the instructions on the on:
-        https://www.raspberrypi.org/documentation/linux/kernel/building.md
-        """
-        serial_kernel_cmdline = {
-            0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
-        }
-        deb_url = ('http://archive.raspberrypi.org/debian/'
-                   'pool/main/r/raspberrypi-firmware/'
-                   'raspberrypi-kernel_1.20190215-1_armhf.deb')
-        deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
-        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
-        kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
-        dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
-
-        self.vm.set_console()
-        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
-                               serial_kernel_cmdline[uart_id] +
-                               ' root=/dev/mmcblk0p2 rootwait ' +
-                               'dwc_otg.fiq_fsm_enable=0')
-        self.vm.add_args('-kernel', kernel_path,
-                         '-dtb', dtb_path,
-                         '-append', kernel_command_line,
-                         '-device', 'usb-kbd')
-        self.vm.launch()
-        console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
-        console_pattern = 'Product: QEMU USB Keyboard'
-        self.wait_for_console_pattern(console_pattern)
-
-    def test_arm_raspi2_uart0(self):
-        """
-        :avocado: tags=arch:arm
-        :avocado: tags=machine:raspi2b
-        :avocado: tags=device:pl011
-        :avocado: tags=accel:tcg
-        """
-        self.do_test_arm_raspi2(0)
-
-    def test_arm_raspi2_initrd(self):
-        """
-        :avocado: tags=arch:arm
-        :avocado: tags=machine:raspi2b
-        """
-        deb_url = ('http://archive.raspberrypi.org/debian/'
-                   'pool/main/r/raspberrypi-firmware/'
-                   'raspberrypi-kernel_1.20190215-1_armhf.deb')
-        deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
-        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
-        kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
-        dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
-
-        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
-                      '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
-                      'arm/rootfs-armv7a.cpio.gz')
-        initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
-        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
-        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
-        archive.gzip_uncompress(initrd_path_gz, initrd_path)
-
-        self.vm.set_console()
-        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
-                               'earlycon=pl011,0x3f201000 console=ttyAMA0 '
-                               'panic=-1 noreboot ' +
-                               'dwc_otg.fiq_fsm_enable=0')
-        self.vm.add_args('-kernel', kernel_path,
-                         '-dtb', dtb_path,
-                         '-initrd', initrd_path,
-                         '-append', kernel_command_line,
-                         '-no-reboot')
-        self.vm.launch()
-        self.wait_for_console_pattern('Boot successful.')
-
-        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
-                                                'BCM2835')
-        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
-                                                '/soc/cprman@7e101000')
-        exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted')
-        # Wait for VM to shut down gracefully
-        self.vm.wait()
-
     def test_arm_raspi4(self):
         """
         :avocado: tags=arch:aarch64
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 175e88bb87..ec77835199 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -29,6 +29,7 @@ tests_generic = [
 tests_arm_thorough = [
   'arm_canona1100',
   'arm_n8x0',
+  'arm_raspi2',
 ]
 
 tests_avr_thorough = [
diff --git a/tests/functional/test_arm_raspi2.py b/tests/functional/test_arm_raspi2.py
new file mode 100755
index 0000000000..7a8f86edee
--- /dev/null
+++ b/tests/functional/test_arm_raspi2.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on a Raspberry Pi machine
+# and checks the console
+#
+# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+
+from qemu_test import QemuSystemTest, Asset
+from qemu_test import wait_for_console_pattern
+from qemu_test import exec_command_and_wait_for_pattern
+from qemu_test.linux_kernel import linux_kernel_wait_for_pattern
+from qemu_test.linux_kernel import KERNEL_COMMON_COMMAND_LINE
+from qemu_test.utils import extract_from_deb
+from qemu_test.utils import gzip_uncompress
+
+
+class ArmRaspi2Machine(QemuSystemTest):
+
+    ASSET_KERNEL_20190215 = Asset(
+        ('http://archive.raspberrypi.org/debian/'
+         'pool/main/r/raspberrypi-firmware/'
+         'raspberrypi-kernel_1.20190215-1_armhf.deb'),
+        '9f1759f7228113da24f5ee2aa6312946ec09a83e076aba9406c46ff776dfb291')
+
+    ASSET_INITRD = Asset(
+        ('https://github.com/groeck/linux-build-test/raw/'
+         '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
+         'arm/rootfs-armv7a.cpio.gz'),
+        '2c8dbdb16ea7af2dfbcbea96044dde639fb07d09fd3c4fb31f2027ef71e55ddd')
+
+    def do_test_arm_raspi2(self, uart_id):
+        """
+        The kernel can be rebuilt using the kernel source referenced
+        and following the instructions on the on:
+        https://www.raspberrypi.org/documentation/linux/kernel/building.md
+        """
+        serial_kernel_cmdline = {
+            0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
+        }
+        deb_path = self.ASSET_KERNEL_20190215.fetch()
+        kernel_path = extract_from_deb(deb_path, self.workdir,
+                                       '/boot/kernel7.img')
+        dtb_path = extract_from_deb(deb_path, self.workdir,
+                                    '/boot/bcm2709-rpi-2-b.dtb')
+
+        self.set_machine('raspi2b')
+        self.vm.set_console()
+        kernel_command_line = (KERNEL_COMMON_COMMAND_LINE +
+                               serial_kernel_cmdline[uart_id] +
+                               ' root=/dev/mmcblk0p2 rootwait ' +
+                               'dwc_otg.fiq_fsm_enable=0')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-append', kernel_command_line,
+                         '-device', 'usb-kbd')
+        self.vm.launch()
+
+        console_pattern = 'Kernel command line: %s' % kernel_command_line
+        linux_kernel_wait_for_pattern(self, console_pattern)
+        linux_kernel_wait_for_pattern(self, 'Product: QEMU USB Keyboard')
+
+    def test_arm_raspi2_uart0(self):
+        self.do_test_arm_raspi2(0)
+
+    def test_arm_raspi2_initrd(self):
+        deb_path = self.ASSET_KERNEL_20190215.fetch()
+        kernel_path = extract_from_deb(deb_path, self.workdir,
+                                       '/boot/kernel7.img')
+        dtb_path = extract_from_deb(deb_path, self.workdir,
+                                    '/boot/bcm2709-rpi-2-b.dtb')
+        initrd_path_gz = self.ASSET_INITRD.fetch()
+        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
+        gzip_uncompress(initrd_path_gz, initrd_path)
+
+        self.set_machine('raspi2b')
+        self.vm.set_console()
+        kernel_command_line = (KERNEL_COMMON_COMMAND_LINE +
+                               'earlycon=pl011,0x3f201000 console=ttyAMA0 '
+                               'panic=-1 noreboot ' +
+                               'dwc_otg.fiq_fsm_enable=0')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-initrd', initrd_path,
+                         '-append', kernel_command_line,
+                         '-no-reboot')
+        self.vm.launch()
+        wait_for_console_pattern(self, 'Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'BCM2835')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
+                                                '/soc/cprman@7e101000')
+        exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted')
+        # Wait for VM to shut down gracefully
+        self.vm.wait()
+
+
+if __name__ == '__main__':
+    QemuSystemTest.main()
-- 
2.45.2



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

* [PATCH 3/4] tests/functional: Convert Aarch64 Raspi3 avocado tests
  2024-08-26 22:10 [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 2/4] tests/functional: Convert ARM Raspi2 avocado tests Philippe Mathieu-Daudé
@ 2024-08-26 22:10 ` Philippe Mathieu-Daudé
  2024-08-26 22:10 ` [PATCH 4/4] tests/functional: Convert Aarch64 Raspi4 " Philippe Mathieu-Daudé
  3 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-26 22:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cleber Rosa, Thomas Huth, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell,
	Philippe Mathieu-Daudé

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS                             |  1 +
 tests/avocado/boot_linux_console.py     | 23 --------------
 tests/functional/meson.build            |  4 +++
 tests/functional/test_aarch64_raspi3.py | 42 +++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 23 deletions(-)
 create mode 100755 tests/functional/test_aarch64_raspi3.py

diff --git a/MAINTAINERS b/MAINTAINERS
index e2bbf1a994..9ce41df6d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -911,6 +911,7 @@ F: include/hw/arm/rasp*
 F: include/hw/*/bcm283*
 F: docs/system/arm/raspi.rst
 F: tests/functional/test_arm_raspi2.py
+F: tests/functional/test_aarch64_raspi3.py
 
 Real View
 M: Peter Maydell <peter.maydell@linaro.org>
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
index 226b92d057..cb7301a456 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -979,29 +979,6 @@ def test_arm_orangepi_uboot_netbsd9(self):
         # Wait for user-space
         wait_for_console_pattern(self, 'Starting root file system check')
 
-    def test_aarch64_raspi3_atf(self):
-        """
-        :avocado: tags=accel:tcg
-        :avocado: tags=arch:aarch64
-        :avocado: tags=machine:raspi3b
-        :avocado: tags=cpu:cortex-a53
-        :avocado: tags=device:pl011
-        :avocado: tags=atf
-        """
-        zip_url = ('https://github.com/pbatard/RPi3/releases/download/'
-                   'v1.15/RPi3_UEFI_Firmware_v1.15.zip')
-        zip_hash = '74b3bd0de92683cadb14e008a7575e1d0c3cafb9'
-        zip_path = self.fetch_asset(zip_url, asset_hash=zip_hash)
-
-        archive.extract(zip_path, self.workdir)
-        efi_fd = os.path.join(self.workdir, 'RPI_EFI.fd')
-
-        self.vm.set_console(console_index=1)
-        self.vm.add_args('-nodefaults',
-                         '-device', 'loader,file=%s,force-raw=true' % efi_fd)
-        self.vm.launch()
-        self.wait_for_console_pattern('version UEFI Firmware v1.15')
-
     def test_alpha_clipper(self):
         """
         :avocado: tags=arch:alpha
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index ec77835199..3fab8e0d0c 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -26,6 +26,10 @@ tests_generic = [
   'version',
 ]
 
+tests_aarch64_thorough = [
+  'aarch64_raspi3',
+]
+
 tests_arm_thorough = [
   'arm_canona1100',
   'arm_n8x0',
diff --git a/tests/functional/test_aarch64_raspi3.py b/tests/functional/test_aarch64_raspi3.py
new file mode 100755
index 0000000000..630b1039ee
--- /dev/null
+++ b/tests/functional/test_aarch64_raspi3.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on a Raspberry Pi machine
+# and checks the console
+#
+# Copyright (c) 2020 Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+from zipfile import ZipFile
+
+from qemu_test import QemuSystemTest, Asset
+from qemu_test.linux_kernel import linux_kernel_wait_for_pattern
+
+
+class Aarch64Raspi3Machine(QemuSystemTest):
+
+    ASSET_RPI3_UEFI = Asset(
+        ('https://github.com/pbatard/RPi3/releases/download/'
+         'v1.15/RPi3_UEFI_Firmware_v1.15.zip'),
+        '8cff2e979560048b4c84921f41a91893240b9fb71a88f0b5c5d6c8edd994bd5b')
+
+    def test_aarch64_raspi3_atf(self):
+        efi_name = 'RPI_EFI.fd'
+        zip_path = self.ASSET_RPI3_UEFI.fetch()
+
+        with ZipFile(zip_path, 'r') as zf:
+                     zf.extract(efi_name, path=self.workdir)
+        efi_fd = os.path.join(self.workdir, efi_name)
+
+        self.set_machine('raspi3b')
+        self.vm.set_console(console_index=1)
+        self.vm.add_args('-cpu', 'cortex-a53',
+                         '-nodefaults',
+                         '-device', f'loader,file={efi_fd},force-raw=true')
+        self.vm.launch()
+        linux_kernel_wait_for_pattern(self, 'version UEFI Firmware v1.15')
+
+
+if __name__ == '__main__':
+    QemuSystemTest.main()
-- 
2.45.2



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

* [PATCH 4/4] tests/functional: Convert Aarch64 Raspi4 avocado tests
  2024-08-26 22:10 [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-08-26 22:10 ` [PATCH 3/4] tests/functional: Convert Aarch64 Raspi3 " Philippe Mathieu-Daudé
@ 2024-08-26 22:10 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-26 22:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cleber Rosa, Thomas Huth, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell,
	Philippe Mathieu-Daudé

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS                             |   1 +
 tests/avocado/boot_linux_console.py     |  97 ----------------------
 tests/functional/meson.build            |   1 +
 tests/functional/test_aarch64_raspi4.py | 106 ++++++++++++++++++++++++
 4 files changed, 108 insertions(+), 97 deletions(-)
 create mode 100755 tests/functional/test_aarch64_raspi4.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 9ce41df6d8..75816b0606 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -912,6 +912,7 @@ F: include/hw/*/bcm283*
 F: docs/system/arm/raspi.rst
 F: tests/functional/test_arm_raspi2.py
 F: tests/functional/test_aarch64_raspi3.py
+F: tests/functional/test_aarch64_raspi4.py
 
 Real View
 M: Peter Maydell <peter.maydell@linaro.org>
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
index cb7301a456..3efb7f652a 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -203,103 +203,6 @@ def test_arm_emcraft_sf2(self):
         exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
             '3 packets transmitted, 3 packets received, 0% packet loss')
 
-    def test_arm_raspi4(self):
-        """
-        :avocado: tags=arch:aarch64
-        :avocado: tags=machine:raspi4b
-        :avocado: tags=device:pl011
-        :avocado: tags=accel:tcg
-        :avocado: tags=rpi4b
-
-        The kernel can be rebuilt using the kernel source referenced
-        and following the instructions on the on:
-        https://www.raspberrypi.org/documentation/linux/kernel/building.md
-        """
-
-        deb_url = ('http://archive.raspberrypi.org/debian/'
-            'pool/main/r/raspberrypi-firmware/'
-            'raspberrypi-kernel_1.20230106-1_arm64.deb')
-        deb_hash = '08dc55696535b18a6d4fe6fa10d4c0d905cbb2ed'
-        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
-        kernel_path = self.extract_from_deb(deb_path, '/boot/kernel8.img')
-        dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2711-rpi-4-b.dtb')
-
-        self.vm.set_console()
-        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
-                               'earlycon=pl011,mmio32,0xfe201000 ' +
-                               'console=ttyAMA0,115200 ' +
-                               'root=/dev/mmcblk1p2 rootwait ' +
-                               'dwc_otg.fiq_fsm_enable=0')
-        self.vm.add_args('-kernel', kernel_path,
-                         '-dtb', dtb_path,
-                         '-append', kernel_command_line)
-        # When PCI is supported we can add a USB controller:
-        #                '-device', 'qemu-xhci,bus=pcie.1,id=xhci',
-        #                '-device', 'usb-kbd,bus=xhci.0',
-        self.vm.launch()
-        console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
-        # When USB is enabled we can look for this
-        # console_pattern = 'Product: QEMU USB Keyboard'
-        # self.wait_for_console_pattern(console_pattern)
-        console_pattern = 'Waiting for root device'
-        self.wait_for_console_pattern(console_pattern)
-
-
-    def test_arm_raspi4_initrd(self):
-        """
-        :avocado: tags=arch:aarch64
-        :avocado: tags=machine:raspi4b
-        :avocado: tags=device:pl011
-        :avocado: tags=accel:tcg
-        :avocado: tags=rpi4b
-
-        The kernel can be rebuilt using the kernel source referenced
-        and following the instructions on the on:
-        https://www.raspberrypi.org/documentation/linux/kernel/building.md
-        """
-        deb_url = ('http://archive.raspberrypi.org/debian/'
-            'pool/main/r/raspberrypi-firmware/'
-            'raspberrypi-kernel_1.20230106-1_arm64.deb')
-        deb_hash = '08dc55696535b18a6d4fe6fa10d4c0d905cbb2ed'
-        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
-        kernel_path = self.extract_from_deb(deb_path, '/boot/kernel8.img')
-        dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2711-rpi-4-b.dtb')
-
-        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
-                      '86b2be1384d41c8c388e63078a847f1e1c4cb1de/rootfs/'
-                      'arm64/rootfs.cpio.gz')
-        initrd_hash = 'f3d4f9fa92a49aa542f1b44d34be77bbf8ca5b9d'
-        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
-        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
-        archive.gzip_uncompress(initrd_path_gz, initrd_path)
-
-        self.vm.set_console()
-        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
-                               'earlycon=pl011,mmio32,0xfe201000 ' +
-                               'console=ttyAMA0,115200 ' +
-                               'panic=-1 noreboot ' +
-                               'dwc_otg.fiq_fsm_enable=0')
-        self.vm.add_args('-kernel', kernel_path,
-                         '-dtb', dtb_path,
-                         '-initrd', initrd_path,
-                         '-append', kernel_command_line,
-                         '-no-reboot')
-        # When PCI is supported we can add a USB controller:
-        #                '-device', 'qemu-xhci,bus=pcie.1,id=xhci',
-        #                '-device', 'usb-kbd,bus=xhci.0',
-        self.vm.launch()
-        self.wait_for_console_pattern('Boot successful.')
-
-        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
-                                                'BCM2835')
-        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
-                                                'cprman@7e101000')
-        exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted')
-        # TODO: Raspberry Pi4 doesn't shut down properly with recent kernels
-        # Wait for VM to shut down gracefully
-        #self.vm.wait()
-
     def test_arm_exynos4210_initrd(self):
         """
         :avocado: tags=arch:arm
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 3fab8e0d0c..a03a4b9156 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -28,6 +28,7 @@ tests_generic = [
 
 tests_aarch64_thorough = [
   'aarch64_raspi3',
+  'aarch64_raspi4',
 ]
 
 tests_arm_thorough = [
diff --git a/tests/functional/test_aarch64_raspi4.py b/tests/functional/test_aarch64_raspi4.py
new file mode 100755
index 0000000000..62178416fd
--- /dev/null
+++ b/tests/functional/test_aarch64_raspi4.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel on a Raspberry Pi machine
+# and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+
+from qemu_test import QemuSystemTest, Asset
+from qemu_test import wait_for_console_pattern
+from qemu_test import exec_command_and_wait_for_pattern
+from qemu_test.linux_kernel import KERNEL_COMMON_COMMAND_LINE
+from qemu_test.utils import extract_from_deb
+from qemu_test.utils import gzip_uncompress
+
+
+class Aarch64Raspi4Machine(QemuSystemTest):
+
+    """
+    The kernel can be rebuilt using the kernel source referenced
+    and following the instructions on the on:
+    https://www.raspberrypi.org/documentation/linux/kernel/building.md
+    """
+    ASSET_KERNEL_20190215 = Asset(
+        ('http://archive.raspberrypi.org/debian/'
+         'pool/main/r/raspberrypi-firmware/'
+         'raspberrypi-kernel_1.20230106-1_arm64.deb'),
+        '56d5713c8f6eee8a0d3f0e73600ec11391144fef318b08943e9abd94c0a9baf7')
+
+    ASSET_INITRD = Asset(
+        ('https://github.com/groeck/linux-build-test/raw/'
+         '86b2be1384d41c8c388e63078a847f1e1c4cb1de/rootfs/'
+         'arm64/rootfs.cpio.gz'),
+        '7c0b16d1853772f6f4c3ca63e789b3b9ff4936efac9c8a01fb0c98c05c7a7648')
+
+    def test_arm_raspi4(self):
+        deb_path = self.ASSET_KERNEL_20190215.fetch()
+        kernel_path = extract_from_deb(deb_path, self.workdir,
+                                       '/boot/kernel8.img')
+        dtb_path = extract_from_deb(deb_path, self.workdir,
+                                    '/boot/bcm2711-rpi-4-b.dtb')
+
+        self.set_machine('raspi4b')
+        self.vm.set_console()
+        kernel_command_line = (KERNEL_COMMON_COMMAND_LINE +
+                               'earlycon=pl011,mmio32,0xfe201000 ' +
+                               'console=ttyAMA0,115200 ' +
+                               'root=/dev/mmcblk1p2 rootwait ' +
+                               'dwc_otg.fiq_fsm_enable=0')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-append', kernel_command_line)
+        # When PCI is supported we can add a USB controller:
+        #                '-device', 'qemu-xhci,bus=pcie.1,id=xhci',
+        #                '-device', 'usb-kbd,bus=xhci.0',
+        self.vm.launch()
+        console_pattern = 'Kernel command line: %s' % kernel_command_line
+        wait_for_console_pattern(self, console_pattern)
+        # When USB is enabled we can look for this
+        # console_pattern = 'Product: QEMU USB Keyboard'
+        # self.wait_for_console_pattern(console_pattern)
+        console_pattern = 'Waiting for root device'
+        wait_for_console_pattern(self, console_pattern)
+
+
+    def atest_arm_raspi4_initrd(self):
+        deb_path = self.ASSET_KERNEL_20190215.fetch()
+        kernel_path = extract_from_deb(deb_path, self.workdir,
+                                       '/boot/kernel8.img')
+        dtb_path = extract_from_deb(deb_path, self.workdir,
+                                    '/boot/bcm2711-rpi-4-b.dtb')
+        initrd_path_gz = self.ASSET_INITRD.fetch()
+        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
+        gzip_uncompress(initrd_path_gz, initrd_path)
+
+        self.set_machine('raspi4b')
+        self.vm.set_console()
+        kernel_command_line = (KERNEL_COMMON_COMMAND_LINE +
+                               'earlycon=pl011,mmio32,0xfe201000 ' +
+                               'console=ttyAMA0,115200 ' +
+                               'panic=-1 noreboot ' +
+                               'dwc_otg.fiq_fsm_enable=0')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-initrd', initrd_path,
+                         '-append', kernel_command_line,
+                         '-no-reboot')
+        # When PCI is supported we can add a USB controller:
+        #                '-device', 'qemu-xhci,bus=pcie.1,id=xhci',
+        #                '-device', 'usb-kbd,bus=xhci.0',
+        self.vm.launch()
+        wait_for_console_pattern(self, 'Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'BCM2835')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
+                                                'cprman@7e101000')
+        exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted')
+        # TODO: Raspberry Pi4 doesn't shut down properly with recent kernels
+        # Wait for VM to shut down gracefully
+        #self.vm.wait()
+
+
+if __name__ == '__main__':
+    QemuSystemTest.main()
-- 
2.45.2



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

* Re: [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers
  2024-08-26 22:10 ` [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers Philippe Mathieu-Daudé
@ 2024-08-27  5:34   ` Thomas Huth
  2024-08-27  9:21     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Huth @ 2024-08-27  5:34 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Cleber Rosa, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell

On 27/08/2024 00.10, Philippe Mathieu-Daudé wrote:
> Use the 'linux_kernel' namespace to provide common helpers
> to functional tests booting a Linux kernel.
> 
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tests/functional/qemu_test/linux_kernel.py | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>   create mode 100644 tests/functional/qemu_test/linux_kernel.py
> 
> diff --git a/tests/functional/qemu_test/linux_kernel.py b/tests/functional/qemu_test/linux_kernel.py
> new file mode 100644
> index 0000000000..917beb7fb6
> --- /dev/null
> +++ b/tests/functional/qemu_test/linux_kernel.py
> @@ -0,0 +1,19 @@
> +# Linux kernel functional test helpers
> +#
> +# Copyright (c) 2024 Linaro Ltd.
> +#
> +# Author:
> +#  Philippe Mathieu-Daudé <philmd@linaro.org>
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +from . import wait_for_console_pattern
> +
> +KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
> +
> +KERNEL_PANIC_MESSAGE = 'Kernel panic - not syncing'
> +
> +def linux_kernel_wait_for_pattern(test, success_message):
> +    wait_for_console_pattern(test,
> +                             success_message=success_message,
> +                             failure_message=KERNEL_PANIC_MESSAGE)

I'd prefer to have the whole LinuxKernelTest class here (without the 
BootLinuxConsole class of course), that way the modifications that we have 
to do to the converted tests are definitely smaller when we don't have to 
change the "wait_for_console_pattern" lines everywhere. And it's also nicer 
if the variables are properly wrapped in a class.

  Thomas



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

* Re: [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers
  2024-08-27  5:34   ` Thomas Huth
@ 2024-08-27  9:21     ` Philippe Mathieu-Daudé
  2024-08-27 12:29       ` Thomas Huth
  2024-08-27 12:31       ` [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test Thomas Huth
  0 siblings, 2 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-27  9:21 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: Cleber Rosa, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell

Hi Thomas,

On 27/8/24 07:34, Thomas Huth wrote:
> On 27/08/2024 00.10, Philippe Mathieu-Daudé wrote:
>> Use the 'linux_kernel' namespace to provide common helpers
>> to functional tests booting a Linux kernel.
>>
>> Suggested-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   tests/functional/qemu_test/linux_kernel.py | 19 +++++++++++++++++++
>>   1 file changed, 19 insertions(+)
>>   create mode 100644 tests/functional/qemu_test/linux_kernel.py
>>
>> diff --git a/tests/functional/qemu_test/linux_kernel.py 
>> b/tests/functional/qemu_test/linux_kernel.py
>> new file mode 100644
>> index 0000000000..917beb7fb6
>> --- /dev/null
>> +++ b/tests/functional/qemu_test/linux_kernel.py
>> @@ -0,0 +1,19 @@
>> +# Linux kernel functional test helpers
>> +#
>> +# Copyright (c) 2024 Linaro Ltd.
>> +#
>> +# Author:
>> +#  Philippe Mathieu-Daudé <philmd@linaro.org>
>> +#
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +from . import wait_for_console_pattern
>> +
>> +KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>> +
>> +KERNEL_PANIC_MESSAGE = 'Kernel panic - not syncing'
>> +
>> +def linux_kernel_wait_for_pattern(test, success_message):
>> +    wait_for_console_pattern(test,
>> +                             success_message=success_message,
>> +                             failure_message=KERNEL_PANIC_MESSAGE)
> 
> I'd prefer to have the whole LinuxKernelTest class here (without the 
> BootLinuxConsole class of course), that way the modifications that we 
> have to do to the converted tests are definitely smaller when we don't 
> have to change the "wait_for_console_pattern" lines everywhere. And it's 
> also nicer if the variables are properly wrapped in a class.

I'm a bit confused by your comment. I exposed my view on LinuxKernelTest
methods (which I don't see specific to this class) here:
https://lore.kernel.org/qemu-devel/9910ebc8-b7c4-4505-a987-3a5e308fb3d1@linaro.org/

Could your request be implemented on top on this patch, as we go (as it
is already helpful in its current state)? Otherwise I'll ask you to
share a snippet of what you mean, or even better to post a v2 :)

Regards,

Phil.


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

* Re: [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers
  2024-08-27  9:21     ` Philippe Mathieu-Daudé
@ 2024-08-27 12:29       ` Thomas Huth
  2024-08-27 12:31       ` [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test Thomas Huth
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2024-08-27 12:29 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Cleber Rosa, Sergey Kambalin, qemu-arm,
	Wainer dos Santos Moschetta, Beraldo Leal, Peter Maydell

On 27/08/2024 11.21, Philippe Mathieu-Daudé wrote:
> Hi Thomas,
> 
> On 27/8/24 07:34, Thomas Huth wrote:
>> On 27/08/2024 00.10, Philippe Mathieu-Daudé wrote:
>>> Use the 'linux_kernel' namespace to provide common helpers
>>> to functional tests booting a Linux kernel.
>>>
>>> Suggested-by: Thomas Huth <thuth@redhat.com>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>>   tests/functional/qemu_test/linux_kernel.py | 19 +++++++++++++++++++
>>>   1 file changed, 19 insertions(+)
>>>   create mode 100644 tests/functional/qemu_test/linux_kernel.py
>>>
>>> diff --git a/tests/functional/qemu_test/linux_kernel.py 
>>> b/tests/functional/qemu_test/linux_kernel.py
>>> new file mode 100644
>>> index 0000000000..917beb7fb6
>>> --- /dev/null
>>> +++ b/tests/functional/qemu_test/linux_kernel.py
>>> @@ -0,0 +1,19 @@
>>> +# Linux kernel functional test helpers
>>> +#
>>> +# Copyright (c) 2024 Linaro Ltd.
>>> +#
>>> +# Author:
>>> +#  Philippe Mathieu-Daudé <philmd@linaro.org>
>>> +#
>>> +# SPDX-License-Identifier: GPL-2.0-or-later
>>> +
>>> +from . import wait_for_console_pattern
>>> +
>>> +KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
>>> +
>>> +KERNEL_PANIC_MESSAGE = 'Kernel panic - not syncing'
>>> +
>>> +def linux_kernel_wait_for_pattern(test, success_message):
>>> +    wait_for_console_pattern(test,
>>> +                             success_message=success_message,
>>> +                             failure_message=KERNEL_PANIC_MESSAGE)
>>
>> I'd prefer to have the whole LinuxKernelTest class here (without the 
>> BootLinuxConsole class of course), that way the modifications that we have 
>> to do to the converted tests are definitely smaller when we don't have to 
>> change the "wait_for_console_pattern" lines everywhere. And it's also 
>> nicer if the variables are properly wrapped in a class.
> 
> I'm a bit confused by your comment. I exposed my view on LinuxKernelTest
> methods (which I don't see specific to this class) here:
> https://lore.kernel.org/qemu-devel/9910ebc8-b7c4-4505-a987-3a5e308fb3d1@linaro.org/
> 
> Could your request be implemented on top on this patch, as we go (as it
> is already helpful in its current state)? Otherwise I'll ask you to
> share a snippet of what you mean, or even better to post a v2 :)

I'll post a mini patch series (converting the Q800 test) in reply to your 
mail to show what I had in mind...

  Thomas



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

* [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test
  2024-08-27  9:21     ` Philippe Mathieu-Daudé
  2024-08-27 12:29       ` Thomas Huth
@ 2024-08-27 12:31       ` Thomas Huth
  2024-08-27 12:31         ` [PATCH 1/2] tests/functional: Add the LinuxKernelTest for testing the Linux boot process Thomas Huth
  2024-08-27 12:31         ` [PATCH 2/2] tests/functional: Convert the m68k Q800 Avocado test into a functional test Thomas Huth
  1 sibling, 2 replies; 11+ messages in thread
From: Thomas Huth @ 2024-08-27 12:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Laurent Vivier

Here's how I'd suggest to convert the tests from
tests/avocado/boot_linux_console.py :
Copy the whole LinuxKernelTest class (well, let's drop extract_from_rpm
for now since it is completely unused), so we can copy the test code
with only some few modifications (using the Q800 test as an example here).

Thomas Huth (2):
  tests/functional: Add the LinuxKernelTest for testing the Linux boot
    process
  tests/functional: Convert the m68k Q800 Avocado test into a functional
    test

 MAINTAINERS                               |  1 +
 tests/avocado/boot_linux_console.py       | 24 -------------
 tests/functional/meson.build              |  3 +-
 tests/functional/qemu_test/__init__.py    |  1 +
 tests/functional/qemu_test/linuxkernel.py | 41 +++++++++++++++++++++++
 tests/functional/test_m68k_q800.py        | 37 ++++++++++++++++++++
 6 files changed, 82 insertions(+), 25 deletions(-)
 create mode 100644 tests/functional/qemu_test/linuxkernel.py
 create mode 100755 tests/functional/test_m68k_q800.py

-- 
2.46.0



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

* [PATCH 1/2] tests/functional: Add the LinuxKernelTest for testing the Linux boot process
  2024-08-27 12:31       ` [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test Thomas Huth
@ 2024-08-27 12:31         ` Thomas Huth
  2024-08-27 12:31         ` [PATCH 2/2] tests/functional: Convert the m68k Q800 Avocado test into a functional test Thomas Huth
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2024-08-27 12:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Laurent Vivier

Copy the LinuxKernelTest from tests/acceptance/boot_linux_console.py
to be able to convert the related tests to the functional test framework
in the following patches.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/__init__.py    |  1 +
 tests/functional/qemu_test/linuxkernel.py | 41 +++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 tests/functional/qemu_test/linuxkernel.py

diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index db05c8f412..4e7268c58d 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -12,3 +12,4 @@
     interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
     exec_command, exec_command_and_wait_for_pattern
 from .testcase import QemuSystemTest, QemuBaseTest
+from .linuxkernel import LinuxKernelTest
diff --git a/tests/functional/qemu_test/linuxkernel.py b/tests/functional/qemu_test/linuxkernel.py
new file mode 100644
index 0000000000..fdd5307629
--- /dev/null
+++ b/tests/functional/qemu_test/linuxkernel.py
@@ -0,0 +1,41 @@
+# Test class for testing the boot process of a Linux kernel
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+import os
+
+from .testcase import QemuSystemTest
+from .cmd import run_cmd, wait_for_console_pattern
+from .utils import archive_extract
+
+class LinuxKernelTest(QemuSystemTest):
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+
+    def wait_for_console_pattern(self, success_message, vm=None):
+        wait_for_console_pattern(self, success_message,
+                                 failure_message='Kernel panic - not syncing',
+                                 vm=vm)
+
+    def extract_from_deb(self, deb_path, path):
+        """
+        Extracts a file from a deb package into the test workdir
+
+        :param deb_path: path to the deb archive
+        :param path: path within the deb archive of the file to be extracted
+        :returns: path of the extracted file
+        """
+        cwd = os.getcwd()
+        os.chdir(self.workdir)
+        (stdout, stderr, ret) = run_cmd(['ar', 't', deb_path])
+        file_path = stdout.split()[2]
+        run_cmd(['ar', 'x', deb_path, file_path])
+        archive_extract(file_path, self.workdir)
+        os.chdir(cwd)
+        # Return complete path to extracted file.  Because callers to
+        # extract_from_deb() specify 'path' with a leading slash, it is
+        # necessary to use os.path.relpath() as otherwise os.path.join()
+        # interprets it as an absolute path and drops the self.workdir part.
+        return os.path.normpath(os.path.join(self.workdir,
+                                             os.path.relpath(path, '/')))
+
-- 
2.46.0



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

* [PATCH 2/2] tests/functional: Convert the m68k Q800 Avocado test into a functional test
  2024-08-27 12:31       ` [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test Thomas Huth
  2024-08-27 12:31         ` [PATCH 1/2] tests/functional: Add the LinuxKernelTest for testing the Linux boot process Thomas Huth
@ 2024-08-27 12:31         ` Thomas Huth
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2024-08-27 12:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Laurent Vivier

Just had to update the asset checksum to use SHA256 instead of SHA1,
but apart from that it is a pretty much straightforward conversion.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 MAINTAINERS                         |  1 +
 tests/avocado/boot_linux_console.py | 24 -------------------
 tests/functional/meson.build        |  3 ++-
 tests/functional/test_m68k_q800.py  | 37 +++++++++++++++++++++++++++++
 4 files changed, 40 insertions(+), 25 deletions(-)
 create mode 100755 tests/functional/test_m68k_q800.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 25e71ac14c..972476cd7c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1309,6 +1309,7 @@ F: include/hw/m68k/q800-glue.h
 F: include/hw/misc/djmemc.h
 F: include/hw/misc/iosb.h
 F: include/hw/audio/asc.h
+F: tests/functional/test_m68k_q800.py
 
 virt
 M: Laurent Vivier <laurent@vivier.eu>
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
index 18c69d6acc..396836bf64 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -1325,30 +1325,6 @@ def test_alpha_clipper(self):
         console_pattern = 'Kernel command line: %s' % kernel_command_line
         self.wait_for_console_pattern(console_pattern)
 
-    def test_m68k_q800(self):
-        """
-        :avocado: tags=arch:m68k
-        :avocado: tags=machine:q800
-        """
-        deb_url = ('https://snapshot.debian.org/archive/debian-ports'
-                   '/20191021T083923Z/pool-m68k/main'
-                   '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
-        deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
-        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
-        kernel_path = self.extract_from_deb(deb_path,
-                                            '/boot/vmlinux-5.3.0-1-m68k')
-
-        self.vm.set_console()
-        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
-                               'console=ttyS0 vga=off')
-        self.vm.add_args('-kernel', kernel_path,
-                         '-append', kernel_command_line)
-        self.vm.launch()
-        console_pattern = 'Kernel command line: %s' % kernel_command_line
-        self.wait_for_console_pattern(console_pattern)
-        console_pattern = 'No filesystem could mount root'
-        self.wait_for_console_pattern(console_pattern)
-
     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')
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 851f33c459..bf7a554a1d 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -40,7 +40,8 @@ tests_loongarch64_thorough = [
 ]
 
 tests_m68k_thorough = [
-  'm68k_nextcube'
+  'm68k_nextcube',
+  'm68k_q800',
 ]
 
 tests_microblaze_thorough = [
diff --git a/tests/functional/test_m68k_q800.py b/tests/functional/test_m68k_q800.py
new file mode 100755
index 0000000000..3b17244b98
--- /dev/null
+++ b/tests/functional/test_m68k_q800.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+#
+# Functional test for testing the q800 m68k machine
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+from qemu_test import LinuxKernelTest, Asset
+
+class Q800MachineTest(LinuxKernelTest):
+
+    ASSET_KERNEL = Asset(
+        ('https://snapshot.debian.org/'
+         'archive/debian-ports/20191021T083923Z/pool-m68k/main/l/linux/'
+         'kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb'),
+        '949e50d74d4b9bc15d26c06d402717b7a4c0e32ff8100014f5930d8024de7b73')
+
+    def test_m68k_q800(self):
+        self.set_machine('q800')
+
+        deb_path = self.ASSET_KERNEL.fetch()
+        kernel_path = self.extract_from_deb(deb_path,
+                                            '/boot/vmlinux-5.3.0-1-m68k')
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'console=ttyS0 vga=off')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-append', kernel_command_line)
+        self.vm.launch()
+        console_pattern = 'Kernel command line: %s' % kernel_command_line
+        self.wait_for_console_pattern(console_pattern)
+        console_pattern = 'No filesystem could mount root'
+        self.wait_for_console_pattern(console_pattern)
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
-- 
2.46.0



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

end of thread, other threads:[~2024-08-27 12:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26 22:10 [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests Philippe Mathieu-Daudé
2024-08-26 22:10 ` [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers Philippe Mathieu-Daudé
2024-08-27  5:34   ` Thomas Huth
2024-08-27  9:21     ` Philippe Mathieu-Daudé
2024-08-27 12:29       ` Thomas Huth
2024-08-27 12:31       ` [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test Thomas Huth
2024-08-27 12:31         ` [PATCH 1/2] tests/functional: Add the LinuxKernelTest for testing the Linux boot process Thomas Huth
2024-08-27 12:31         ` [PATCH 2/2] tests/functional: Convert the m68k Q800 Avocado test into a functional test Thomas Huth
2024-08-26 22:10 ` [PATCH 2/4] tests/functional: Convert ARM Raspi2 avocado tests Philippe Mathieu-Daudé
2024-08-26 22:10 ` [PATCH 3/4] tests/functional: Convert Aarch64 Raspi3 " Philippe Mathieu-Daudé
2024-08-26 22:10 ` [PATCH 4/4] tests/functional: Convert Aarch64 Raspi4 " Philippe Mathieu-Daudé

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