Skip to contentSkip to conversation

tests/avocado: ppc additions and other fixes

PATCH In review Nicholas Piggin 2 participants 13 messages Jan 17, 2024 – Jan 25, 2024 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

v2 cover tests/avocado: ppc additions and other fixes

Thanks for the feedback and comments on these before. I would like to put these in the ppc tree soon (modulo the x86 patch 2). Happy for more feedback but could make them as incremental changes too.

Changes since v1:
- Patch 1 (s390x fix) merged.
- Use existing SPEED=slow convention instead of new AVOCADO_ALLOW_LONG_RUNTIME (Thomas)
- Add slightly more guideline help text for SPEED=slow (Cedric)
- Fix hypervisor test to use KVM instead of forcing TCG always (Cedric)
- Fix hypervisor test avocado syntax issue (Cedric)
- Add powernv9 FreeBSD boot test, which is a bit tricky since powernv does not have a boot loader and not sure how to pass boot options to FreeBSD kernel directly.

Haven't done the BE FreeBSD test yet that Cedric suggested, will save that for later.

Thanks,
Nick

Nicholas Piggin (8):
tests/avocado: mark boot_linux.py long runtime instead of flaky tests/avocado: Mark x86-64 boot_linux.py TCG tests as long runtime tests/avocado: Enable replay_linux.py on ppc64 pseries tests/avocado: ppc add powernv10 boot_linux_console test tests/avocado: Add ppc pseries and powernv hash MMU tests tests/avocado: Add pseries KVM boot_linux test tests/avocado: ppc add hypervisor tests
tests/avocado: Add FreeBSD distro boot tests for ppc

 MAINTAINERS                         |   1 +
 docs/devel/testing.rst              |  11 ++
 tests/avocado/boot_freebsd.py       | 174 ++++++++++++++++++++++++
 tests/avocado/boot_linux.py         |  32 +++--
 tests/avocado/boot_linux_console.py |   8 ++
 tests/avocado/ppc_hv_tests.py       | 203 ++++++++++++++++++++++++++++
 tests/avocado/ppc_powernv.py        |  23 +++-
 tests/avocado/ppc_pseries.py        |  20 ++-
 tests/avocado/replay_linux.py       |  76 ++++++++++-
 9 files changed, 525 insertions(+), 23 deletions(-)
 create mode 100644 tests/avocado/boot_freebsd.py
 create mode 100644 tests/avocado/ppc_hv_tests.py
Signature · 1 line
2.42.0
author reviewer
#1 lore raw

PATCH v2 1/8 tests/avocado: mark boot_linux.py long runtime instead of flaky

The ppc64 and s390x tests were first marked skipIf GITLAB_CI by commit c0c8687ef0f ("tests/avocado: disable BootLinuxPPC64 test in CI"), and commit 0f26d94ec9e ("tests/acceptance: skip s390x_ccw_vrtio_tcg on GitLab") due to being very heavy-weight for gitlab CI.

Commit 9b45cc99318 ("docs/devel: rationalise unstable gitlab tests under FLAKY_TESTS") changed this to being flaky but it isn't really, it just had a long runtime.

So take the SPEED=slow variable from qtests and introduce it to avocado, and make these tests require it.

---
 docs/devel/testing.rst      | 11 +++++++++++
 tests/avocado/boot_linux.py |  8 ++------
 2 files changed, 13 insertions(+), 6 deletions(-)
docs/devel/testing.rst +11 -0
index bd132306c1..5cdc23b90f 100644
@@ -1346,6 +1346,17 @@ the environment.
 The definition of *large* is a bit arbitrary here, but it usually means an
 asset which occupies at least 1GB of size on disk when uncompressed.
 
+SPEED
+^^^^^
+Tests which have a long runtime will not be run unless ``SPEED=slow`` is
+exported on the environment.
+
+The definition of *long* is a bit arbitrary here, and it depends on the
+usefulness of the test too. A unique test is worth spending more time on,
+small variations on existing tests perhaps less so. As a rough guide,
+a test or set of similar tests which take more than 100 seconds to
+complete.
+
 AVOCADO_ALLOW_UNTRUSTED_CODE
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 There are tests which will boot a kernel image or firmware that can be
tests/avocado/boot_linux.py +2 -6
index 7c4769904e..de4c8805f7 100644
@@ -93,13 +93,11 @@ class BootLinuxPPC64(LinuxTest):
 
     timeout = 360
 
-    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab')
-
+    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
     def test_pseries_tcg(self):
         """
         :avocado: tags=machine:pseries
         :avocado: tags=accel:tcg
-        :avocado: tags=flaky
         """
         self.require_accelerator("tcg")
         self.vm.add_args("-accel", "tcg")
@@ -113,13 +111,11 @@ class BootLinuxS390X(LinuxTest):
 
     timeout = 240
 
-    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab')
-
+    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
     def test_s390_ccw_virtio_tcg(self):
         """
         :avocado: tags=machine:s390-ccw-virtio
         :avocado: tags=accel:tcg
-        :avocado: tags=flaky
         """
         self.require_accelerator("tcg")
         self.vm.add_args("-accel", "tcg")
Signature · 1 line
2.42.0
author reviewer
#2 lore raw

PATCH v2 2/8 tests/avocado: Mark x86-64 boot_linux.py TCG tests as long runtime

In reply to Nicholas Piggin

Re-testing gitlab CI shows the ppc64 and s390x boot_linux tests take 100-150 seconds each. The x86-64 TCG tests take a similar ~100s each, and are the longest-running avocado tests in gitlab.
From avocado-system-centos:

boot_linux.py:BootLinuxX8664.test_pc_i440fx_tcg: PASS (112.34 s) boot_linux.py:BootLinuxX8664.test_pc_q35_tcg: PASS (97.05 s) boot_linux.py:BootLinuxPPC64.test_pseries_tcg: PASS (148.86 s) boot_linux.py:BootLinuxS390X.test_s390_ccw_virtio_tcg: PASS (149.83 s)

So mark the x86-64 tests as SPEED=slow as well.

The other way we could go is enabling them all since ppc64 and s390s are now much faster than when they were originally disabled; or to only enable q35, giving at least one boot_linux.py test.

[https://gitlab.com/npiggin/qemu/-/jobs/5842257510 for results]

---
 tests/avocado/boot_linux.py | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
tests/avocado/boot_linux.py +7 -9
index de4c8805f7..7c9cf6ae15 100644
@@ -14,6 +14,9 @@
 
 from avocado import skipUnless
 
+# We don't run TCG tests in CI, as booting the current Fedora OS in TCG tests
+# is very heavyweight (~100s per test). There are lighter weight distros which
+# we use in the machine_aarch64_virt.py, tux_baseline.py, etc.
 
 class BootLinuxX8664(LinuxTest):
     """
@@ -21,6 +24,7 @@ class BootLinuxX8664(LinuxTest):
     """
     timeout = 480
 
+    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
     def test_pc_i440fx_tcg(self):
         """
         :avocado: tags=machine:pc
@@ -39,6 +43,7 @@ def test_pc_i440fx_kvm(self):
         self.vm.add_args("-accel", "kvm")
         self.launch_and_wait(set_up_ssh_connection=False)
 
+    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
     def test_pc_q35_tcg(self):
         """
         :avocado: tags=machine:q35
@@ -58,9 +63,6 @@ def test_pc_q35_kvm(self):
         self.launch_and_wait(set_up_ssh_connection=False)
 
 
-# For Aarch64 we only boot KVM tests in CI as booting the current
-# Fedora OS in TCG tests is very heavyweight. There are lighter weight
-# distros which we use in the machine_aarch64_virt.py tests.
 class BootLinuxAarch64(LinuxTest):
     """
     :avocado: tags=arch:aarch64
@@ -84,14 +86,11 @@ def test_virt_kvm(self):
         self.launch_and_wait(set_up_ssh_connection=False)
 
 
-# See the tux_baseline.py tests for almost the same coverage in a lot
-# less time.
 class BootLinuxPPC64(LinuxTest):
     """
     :avocado: tags=arch:ppc64
     """
-
-    timeout = 360
+    timeout = 480
 
     @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
     def test_pseries_tcg(self):
@@ -108,8 +107,7 @@ class BootLinuxS390X(LinuxTest):
     """
     :avocado: tags=arch:s390x
     """
-
-    timeout = 240
+    timeout = 480
 
     @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
     def test_s390_ccw_virtio_tcg(self):
Signature · 1 line
2.42.0
Reviewed-by on v2 2/8
#3 lore raw

Re: [PATCH v2 2/8] tests/avocado: Mark x86-64 boot_linux.py TCG tests as long runtime

Quoted 12 lines · Nicholas Piggin

Re-testing gitlab CI shows the ppc64 and s390x boot_linux tests take 100-150 seconds each. The x86-64 TCG tests take a similar ~100s each, and are the longest-running avocado tests in gitlab.
From avocado-system-centos:

   boot_linux.py:BootLinuxX8664.test_pc_i440fx_tcg:  PASS (112.34 s)
   boot_linux.py:BootLinuxX8664.test_pc_q35_tcg:  PASS (97.05 s)
   boot_linux.py:BootLinuxPPC64.test_pseries_tcg:  PASS (148.86 s)
   boot_linux.py:BootLinuxS390X.test_s390_ccw_virtio_tcg:  PASS (149.83 s)

So mark the x86-64 tests as SPEED=slow as well.

Quoted 7 lines

The other way we could go is enabling them all since ppc64 and s390s are now much faster than when they were originally disabled; or to only enable q35, giving at least one boot_linux.py test.

[https://gitlab.com/npiggin/qemu/-/jobs/5842257510 for results]

Thanks,

C.

Quoted 70 lines
---
  tests/avocado/boot_linux.py | 16 +++++++---------
  1 file changed, 7 insertions(+), 9 deletions(-)
tests/avocado/boot_linux.py +7 -9
index de4c8805f7..7c9cf6ae15 100644
@@ -14,6 +14,9 @@
 
  from avocado import skipUnless
 
+# We don't run TCG tests in CI, as booting the current Fedora OS in TCG tests
+# is very heavyweight (~100s per test). There are lighter weight distros which
+# we use in the machine_aarch64_virt.py, tux_baseline.py, etc.
 
  class BootLinuxX8664(LinuxTest):
      """
@@ -21,6 +24,7 @@ class BootLinuxX8664(LinuxTest):
      """
      timeout = 480
 
+    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
      def test_pc_i440fx_tcg(self):
          """
          :avocado: tags=machine:pc
@@ -39,6 +43,7 @@ def test_pc_i440fx_kvm(self):
          self.vm.add_args("-accel", "kvm")
          self.launch_and_wait(set_up_ssh_connection=False)
 
+    @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
      def test_pc_q35_tcg(self):
          """
          :avocado: tags=machine:q35
@@ -58,9 +63,6 @@ def test_pc_q35_kvm(self):
          self.launch_and_wait(set_up_ssh_connection=False)
 
 
-# For Aarch64 we only boot KVM tests in CI as booting the current
-# Fedora OS in TCG tests is very heavyweight. There are lighter weight
-# distros which we use in the machine_aarch64_virt.py tests.
  class BootLinuxAarch64(LinuxTest):
      """
      :avocado: tags=arch:aarch64
@@ -84,14 +86,11 @@ def test_virt_kvm(self):
          self.launch_and_wait(set_up_ssh_connection=False)
 
 
-# See the tux_baseline.py tests for almost the same coverage in a lot
-# less time.
  class BootLinuxPPC64(LinuxTest):
      """
      :avocado: tags=arch:ppc64
      """
-
-    timeout = 360
+    timeout = 480
 
      @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
      def test_pseries_tcg(self):
@@ -108,8 +107,7 @@ class BootLinuxS390X(LinuxTest):
      """
      :avocado: tags=arch:s390x
      """
-
-    timeout = 240
+    timeout = 480
 
      @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
      def test_s390_ccw_virtio_tcg(self):
author reviewer
#4 lore raw

PATCH v2 3/8 tests/avocado: Enable replay_linux.py on ppc64 pseries

In reply to Nicholas Piggin

Add a ppc64 pseries test. This tends to hang in the replay phase near the end of the trace due to a missing event, so it is marked flaky.

spapr-vscsi IO is extremely slow when running in record-replay modes, particularly when driven by SLOF. This causes tests to time-out even after an hour, so this uses guestfish to extract the kernel and initrd and boot them directly.

---
 tests/avocado/replay_linux.py | 76 ++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)
tests/avocado/replay_linux.py +75 -1
index f3a43dc98c..1408d13eeb 100644
@@ -11,8 +11,9 @@
 import os
 import logging
 import time
+import subprocess
 
-from avocado import skipUnless
+from avocado import skipIf, skipUnless
 from avocado_qemu import BUILD_DIR
 from avocado.utils import cloudinit
 from avocado.utils import network
@@ -194,3 +195,76 @@ def test_virt_gicv3(self):
         self.run_rr(shift=3,
                     args=(*self.get_common_args(),
                           "-machine", "virt,gic-version=3"))
+
+# ppc64 pseries test.
+#
+# This machine tends to fail replay and hang very close to the end of the
+# trace, with missing events, which is still an open issue.
+#
+# spapr-scsi IO driven by SLOF/grub is extremely slow in record/replay mode,
+# so jump through some hoops to boot the kernel directly. With this, the test
+# runs in about 5 minutes (modulo hang), which suggests other machines may
+# have similar issues and could benefit from bypassing bootloaders.
+#
+ppc_deps = ["guestfish"] # dependent tools needed in the test setup/box.
+
+def which(tool):
+    """ looks up the full path for @tool, returns None if not found
+        or if @tool does not have executable permissions.
+    """
+    paths=os.getenv('PATH')
+    for p in paths.split(os.path.pathsep):
+        p = os.path.join(p, tool)
+        if os.path.exists(p) and os.access(p, os.X_OK):
+            return p
+    return None
+
+def ppc_missing_deps():
+    """ returns True if any of the test dependent tools are absent.
+    """
+    for dep in ppc_deps:
+        if which(dep) is None:
+            return True
+    return False
+
+@skipIf(ppc_missing_deps(), 'dependencies (%s) not installed' % ','.join(ppc_deps))
+@skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'known failure in trace replay')
+class ReplayLinuxPPC64(ReplayLinux):
+    """
+    :avocado: tags=arch:ppc64
+    :avocado: tags=accel:tcg
+    """
+
+    hdd = 'scsi-hd'
+    cd = 'scsi-cd'
+    bus = None
+
+    def setUp(self):
+        super().setUp()
+
+        # kernel, initramfs, and kernel cmdline are all taken by hand from
+        # the Fedora image.
+        self.kernel="vmlinuz-5.3.7-301.fc31.ppc64le"
+        self.initramfs="initramfs-5.3.7-301.fc31.ppc64le.img"
+        cmd = "guestfish --ro -a %s run "
+              ": mount /dev/sda2 / "
+              ": copy-out /boot/%s %s "
+              ": copy-out /boot/%s %s "
+              % (self.boot_path, self.kernel, self.workdir,
+                 self.initramfs, self.workdir)
+        subprocess.run(cmd.split())
+
+    def test_pseries(self):
+        """
+        :avocado: tags=machine:pseries
+        """
+        kernel=os.path.normpath(os.path.join(self.workdir, self.kernel))
+        initramfs=os.path.normpath(os.path.join(self.workdir, self.initramfs))
+        cmdline="root=UUID=8a409ee6-3cb3-4b06-a266-39e2dae3e5fa ro "
+                "no_timer_check net.ifnames=0 console=tty1 "
+                "console=ttyS0,115200n8"
+        self.run_rr(shift=1, args=("-device", "spapr-vscsi",
+                                   "-machine", "x-vof=on",
+                                   "-kernel", kernel,
+                                   "-initrd", initramfs,
+                                   "-append", cmdline))
Signature · 1 line
2.42.0
author reviewer
#5 lore raw

PATCH v2 4/8 tests/avocado: ppc add powernv10 boot_linux_console test

In reply to Nicholas Piggin

Add test for POWER10.

---
 tests/avocado/boot_linux_console.py | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/avocado/boot_linux_console.py +8 -0
index 3f0180e1f8..4f05bb7441 100644
@@ -1386,6 +1386,14 @@ def test_ppc_powernv9(self):
         """
         self.do_test_ppc64_powernv('P9')
 
+    def test_ppc_powernv10(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv10
+        :avocado: tags=accel:tcg
+        """
+        self.do_test_ppc64_powernv('P10')
+
     def test_ppc_g3beige(self):
         """
         :avocado: tags=arch:ppc
Signature · 1 line
2.42.0
author reviewer
#6 lore raw

Re: [PATCH v2 4/8] tests/avocado: ppc add powernv10 boot_linux_console test

This test seems to be flaky, it hangs without ever getting the MTD partition message. But I think it might be the init process quieting the kernel console messages that just happens to run first. P10 seems to just hit this up more, maybe small timing differences.

So I'll send a patch to adjust the tets harness to avoid it.

Thanks,
Nick

Quoted 27 lines · Nicholas Piggin

Add test for POWER10.

---
 tests/avocado/boot_linux_console.py | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/avocado/boot_linux_console.py +8 -0
index 3f0180e1f8..4f05bb7441 100644
@@ -1386,6 +1386,14 @@ def test_ppc_powernv9(self):
         """
         self.do_test_ppc64_powernv('P9')
 
+    def test_ppc_powernv10(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv10
+        :avocado: tags=accel:tcg
+        """
+        self.do_test_ppc64_powernv('P10')
+
     def test_ppc_g3beige(self):
         """
         :avocado: tags=arch:ppc
author reviewer
#7 lore raw

PATCH v2 5/8 tests/avocado: Add ppc pseries and powernv hash MMU tests

In reply to Nicholas Piggin

POWER CPUs support hash and radix MMU modes. Linux supports running in either mode, but defaults to radix. To keep up testing of QEMU's hash MMU implementation, add some Linux hash boot tests.

---
 tests/avocado/ppc_powernv.py | 23 +++++++++++++++++++----
 tests/avocado/ppc_pseries.py | 20 +++++++++++++++++---
 2 files changed, 36 insertions(+), 7 deletions(-)
tests/avocado/ppc_powernv.py +19 -4
index d0e5c07bde..4342941d5d 100644
@@ -12,11 +12,11 @@
 class powernvMachine(QemuSystemTest):
 
     timeout = 90
-    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
     panic_message = 'Kernel panic - not syncing'
     good_message = 'VFS: Cannot open root device'
 
-    def do_test_linux_boot(self):
+    def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE):
         self.require_accelerator("tcg")
         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                       '/fedora-secondary/releases/29/Everything/ppc64le/os'
@@ -25,9 +25,8 @@ def do_test_linux_boot(self):
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
         self.vm.set_console()
-        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
         self.vm.add_args('-kernel', kernel_path,
-                         '-append', kernel_command_line)
+                         '-append', command_line)
         self.vm.launch()
 
     def test_linux_boot(self):
@@ -54,6 +53,22 @@ def test_linux_smp_boot(self):
         wait_for_console_pattern(self, console_pattern, self.panic_message)
         wait_for_console_pattern(self, self.good_message, self.panic_message)
 
+    def test_linux_smp_hpt_boot(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv
+        :avocado: tags=accel:tcg
+        """
+
+        self.vm.add_args('-smp', '4')
+        self.do_test_linux_boot(self.KERNEL_COMMON_COMMAND_LINE +
+                                'disable_radix')
+        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
+        wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu',
+                                 self.panic_message)
+        wait_for_console_pattern(self, console_pattern, self.panic_message)
+        wait_for_console_pattern(self, self.good_message, self.panic_message)
+
     def test_linux_smt_boot(self):
         """
         :avocado: tags=arch:ppc64
tests/avocado/ppc_pseries.py +17 -3
index a8311e6555..74aaa4ac4a 100644
@@ -12,11 +12,11 @@
 class pseriesMachine(QemuSystemTest):
 
     timeout = 90
-    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
     panic_message = 'Kernel panic - not syncing'
     good_message = 'VFS: Cannot open root device'
 
-    def do_test_ppc64_linux_boot(self):
+    def do_test_ppc64_linux_boot(self, kernel_command_line = KERNEL_COMMON_COMMAND_LINE):
         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                       '/fedora-secondary/releases/29/Everything/ppc64le/os'
                       '/ppc/ppc64/vmlinuz')
@@ -24,7 +24,6 @@ def do_test_ppc64_linux_boot(self):
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
         self.vm.set_console()
-        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
         self.vm.add_args('-kernel', kernel_path,
                          '-append', kernel_command_line)
         self.vm.launch()
@@ -62,6 +61,21 @@ def test_ppc64_linux_smp_boot(self):
         wait_for_console_pattern(self, console_pattern, self.panic_message)
         wait_for_console_pattern(self, self.good_message, self.panic_message)
 
+    def test_ppc64_linux_hpt_smp_boot(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        """
+
+        self.vm.add_args('-smp', '4')
+        self.do_test_ppc64_linux_boot(self.KERNEL_COMMON_COMMAND_LINE +
+                                      'disable_radix')
+        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
+        wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu',
+                                 self.panic_message)
+        wait_for_console_pattern(self, console_pattern, self.panic_message)
+        wait_for_console_pattern(self, self.good_message, self.panic_message)
+
     def test_ppc64_linux_smt_boot(self):
         """
         :avocado: tags=arch:ppc64
Signature · 1 line
2.42.0
Reviewed-by on v2 5/8
#8 lore raw

Re: [PATCH v2 5/8] tests/avocado: Add ppc pseries and powernv hash MMU tests

Quoted 5 lines · Nicholas Piggin

POWER CPUs support hash and radix MMU modes. Linux supports running in either mode, but defaults to radix. To keep up testing of QEMU's hash MMU implementation, add some Linux hash boot tests.

Thanks,

C.

Quoted 105 lines
---
  tests/avocado/ppc_powernv.py | 23 +++++++++++++++++++----
  tests/avocado/ppc_pseries.py | 20 +++++++++++++++++---
  2 files changed, 36 insertions(+), 7 deletions(-)
tests/avocado/ppc_powernv.py +19 -4
index d0e5c07bde..4342941d5d 100644
@@ -12,11 +12,11 @@
  class powernvMachine(QemuSystemTest):
 
      timeout = 90
-    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
      panic_message = 'Kernel panic - not syncing'
      good_message = 'VFS: Cannot open root device'
 
-    def do_test_linux_boot(self):
+    def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE):
          self.require_accelerator("tcg")
          kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                        '/fedora-secondary/releases/29/Everything/ppc64le/os'
@@ -25,9 +25,8 @@ def do_test_linux_boot(self):
          kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
          self.vm.set_console()
-        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
          self.vm.add_args('-kernel', kernel_path,
-                         '-append', kernel_command_line)
+                         '-append', command_line)
          self.vm.launch()
 
      def test_linux_boot(self):
@@ -54,6 +53,22 @@ def test_linux_smp_boot(self):
          wait_for_console_pattern(self, console_pattern, self.panic_message)
          wait_for_console_pattern(self, self.good_message, self.panic_message)
 
+    def test_linux_smp_hpt_boot(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv
+        :avocado: tags=accel:tcg
+        """
+
+        self.vm.add_args('-smp', '4')
+        self.do_test_linux_boot(self.KERNEL_COMMON_COMMAND_LINE +
+                                'disable_radix')
+        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
+        wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu',
+                                 self.panic_message)
+        wait_for_console_pattern(self, console_pattern, self.panic_message)
+        wait_for_console_pattern(self, self.good_message, self.panic_message)
+
      def test_linux_smt_boot(self):
          """
          :avocado: tags=arch:ppc64
tests/avocado/ppc_pseries.py +17 -3
index a8311e6555..74aaa4ac4a 100644
@@ -12,11 +12,11 @@
  class pseriesMachine(QemuSystemTest):
 
      timeout = 90
-    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
      panic_message = 'Kernel panic - not syncing'
      good_message = 'VFS: Cannot open root device'
 
-    def do_test_ppc64_linux_boot(self):
+    def do_test_ppc64_linux_boot(self, kernel_command_line = KERNEL_COMMON_COMMAND_LINE):
          kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                        '/fedora-secondary/releases/29/Everything/ppc64le/os'
                        '/ppc/ppc64/vmlinuz')
@@ -24,7 +24,6 @@ def do_test_ppc64_linux_boot(self):
          kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
          self.vm.set_console()
-        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
          self.vm.add_args('-kernel', kernel_path,
                           '-append', kernel_command_line)
          self.vm.launch()
@@ -62,6 +61,21 @@ def test_ppc64_linux_smp_boot(self):
          wait_for_console_pattern(self, console_pattern, self.panic_message)
          wait_for_console_pattern(self, self.good_message, self.panic_message)
 
+    def test_ppc64_linux_hpt_smp_boot(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        """
+
+        self.vm.add_args('-smp', '4')
+        self.do_test_ppc64_linux_boot(self.KERNEL_COMMON_COMMAND_LINE +
+                                      'disable_radix')
+        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
+        wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu',
+                                 self.panic_message)
+        wait_for_console_pattern(self, console_pattern, self.panic_message)
+        wait_for_console_pattern(self, self.good_message, self.panic_message)
+
      def test_ppc64_linux_smt_boot(self):
          """
          :avocado: tags=arch:ppc64
author reviewer
#9 lore raw

PATCH v2 6/8 tests/avocado: Add pseries KVM boot_linux test

In reply to Nicholas Piggin

ppc has no avocado tests for the KVM backend. Add a KVM boot_linux.py test for pseries.

---
 tests/avocado/boot_linux.py | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/avocado/boot_linux.py +8 -0
index 7c9cf6ae15..4c9b15ba06 100644
@@ -102,6 +102,14 @@ def test_pseries_tcg(self):
         self.vm.add_args("-accel", "tcg")
         self.launch_and_wait(set_up_ssh_connection=False)
 
+    def test_pseries_kvm(self):
+        """
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:kvm
+        """
+        self.require_accelerator("kvm")
+        self.vm.add_args("-accel", "kvm")
+        self.launch_and_wait(set_up_ssh_connection=False)
 
 class BootLinuxS390X(LinuxTest):
     """
Signature · 1 line
2.42.0
Reviewed-by on v2 6/8
#10 lore raw

Re: [PATCH v2 6/8] tests/avocado: Add pseries KVM boot_linux test

Quoted 4 lines · Nicholas Piggin

ppc has no avocado tests for the KVM backend. Add a KVM boot_linux.py test for pseries.

Thanks,

C.

Quoted 23 lines
---
  tests/avocado/boot_linux.py | 8 ++++++++
  1 file changed, 8 insertions(+)
tests/avocado/boot_linux.py +8 -0
index 7c9cf6ae15..4c9b15ba06 100644
@@ -102,6 +102,14 @@ def test_pseries_tcg(self):
          self.vm.add_args("-accel", "tcg")
          self.launch_and_wait(set_up_ssh_connection=False)
 
+    def test_pseries_kvm(self):
+        """
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:kvm
+        """
+        self.require_accelerator("kvm")
+        self.vm.add_args("-accel", "kvm")
+        self.launch_and_wait(set_up_ssh_connection=False)
 
  class BootLinuxS390X(LinuxTest):
      """
author reviewer
#11 lore raw

PATCH v2 7/8 tests/avocado: ppc add hypervisor tests

In reply to Nicholas Piggin

The powernv and pseries machines both provide hypervisor facilities that are supported by KVM. This is a large and complicated set of features that don't get much system-level testing in ppc tests.

Add a new test case for these which runs QEMU KVM inside the target. This downloads an Alpine VM image, boots it and downloads and installs the qemu package, then boots a virtual machine under it, re-using the original Alpine VM image.

---
 MAINTAINERS                   |   1 +
 tests/avocado/ppc_hv_tests.py | 203 ++++++++++++++++++++++++++++++++++
 2 files changed, 204 insertions(+)
 create mode 100644 tests/avocado/ppc_hv_tests.py
MAINTAINERS +1 -0
index b406fb20c0..bf41ac61c8 100644
@@ -1523,6 +1523,7 @@ F: tests/qtest/libqos/*spapr*
 F: tests/qtest/rtas*
 F: tests/qtest/libqos/rtas*
 F: tests/avocado/ppc_pseries.py
+F: tests/avocado/ppc_hv_tests.py
 
 PowerNV (Non-Virtualized)
 M: Cédric Le Goater <[email protected]>
tests/avocado/ppc_hv_tests.py new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
2.42.0
author reviewer
#12 lore raw

PATCH v2 8/8 tests/avocado: Add FreeBSD distro boot tests for ppc

In reply to Nicholas Piggin

FreeBSD project provides qcow2 images that work well for testing QEMU. Add pseries tests for HPT and Radix, KVM and TCG, and powernv9 tests.

This uses short-term snapshot build artifacts, because FreeBSD has not set up long-term builds for ppc64 yet.

Other architectures could be added so this does not get a ppc_ prefix but is instead named similarly to boot_linux.

Unfortunately the latest stable (14.0) x86-64 VM image does not seem to output to console by default and I've not been able to find a reliable way to edit the filesystem to change the boot loader options, or use console input in the test case to change it on the fly.

Thanks,
Nick

---
 tests/avocado/boot_freebsd.py | 174 ++++++++++++++++++++++++++++++++++
 1 file changed, 174 insertions(+)
 create mode 100644 tests/avocado/boot_freebsd.py
tests/avocado/boot_freebsd.py new file +174 -0
new file mode 100644
index 0000000000..c01cd06cca
@@ -0,0 +1,174 @@
+# Functional tests that boot FreeBSD in various configurations
+#
+# Copyright (c) 2023 IBM Corporation
+#
+# 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
+import subprocess
+
+from avocado import skipUnless
+from avocado_qemu import QemuSystemTest
+from avocado_qemu import wait_for_console_pattern
+from avocado_qemu import exec_command
+from avocado.utils import archive
+from avocado.utils import process
+from avocado.utils.path import find_command
+
+@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
+@skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited')
+class BootFreeBSDPPC64(QemuSystemTest):
+    """
+    :avocado: tags=arch:ppc64
+    """
+
+    timeout = 360
+
+    def setUp(self):
+        super().setUp()
+
+        # We need zstd for all the tests
+        # See https://github.com/avocado-framework/avocado/issues/5609
+        zstd = find_command('zstd', False)
+        if zstd is False:
+            self.cancel('Could not find "zstd", which is required to '
+                        'decompress rootfs')
+        tar = find_command('tar', False)
+        if tar is False:
+            self.cancel('Could not find "tar", which is required to '
+                        'decompress rootfs')
+
+        drive_url = ('https://artifact.ci.freebsd.org/snapshot/15.0-CURRENT/8a735ffdf04936c6785ac4fa31486639262dd416/powerpc/powerpc64le/disk.qcow2.zst')
+        drive_hash = '95d863dbbc4b60f4899d1ef21d6489fca05bf03d'
+        drive_path_zstd = self.fetch_asset(drive_url, asset_hash=drive_hash)
+        self.drive_path = os.path.join(self.workdir, 'disk.qcow2')
+
+        cmd = f"{zstd} -d {drive_path_zstd} -o {self.drive_path}"
+        process.run(cmd)
+
+        kernel_url = ('https://artifact.ci.freebsd.org/snapshot/15.0-CURRENT/8a735ffdf04936c6785ac4fa31486639262dd416/powerpc/powerpc64le/kernel.txz')
+        kernel_hash = '31d14c2dc658858830a7acab5128a5b91ea548cf'
+        kernel_path_txz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+        self.kernel_path = os.path.join(self.workdir, 'kernel')
+
+        with open(self.kernel_path, "w") as outfile:
+            cmd = f"{tar} OJxf {kernel_path_txz} ./boot/kernel/kernel"
+            subprocess.run(cmd.split(), stdout=outfile)
+
+    def set_pseries_devices(self):
+        self.vm.add_args('-drive', f"file={self.drive_path},format=qcow2,if=virtio")
+        self.vm.add_args('-net', 'nic,model=virtio')
+
+    def set_powernv_devices(self):
+        self.vm.add_args('-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234,drive=drive0',
+                         '-device', 'e1000e,netdev=net0,mac=C0:FF:EE:00:00:02,bus=pcie.0,addr=0x0',
+                         '-netdev', 'user,id=net0,hostfwd=::20022-:22,hostname=freebsd')
+        self.vm.add_args("-drive", f"file={self.drive_path},format=qcow2,if=none,id=drive0")
+        self.vm.add_args("-kernel", self.kernel_path)
+
+    def run_pseries_test(self, force_HPT=False):
+        if force_HPT:
+            self.vm.add_args('-m', '4g')
+        else:
+            self.vm.add_args('-m', '1g')
+        self.vm.add_args('-smp', '4')
+        self.set_pseries_devices()
+        self.vm.set_console()
+        self.vm.launch()
+
+        wait_for_console_pattern(self, 'Hit [Enter] to boot immediately, or any other key for command prompt.')
+        if force_HPT:
+            exec_command(self, 'x')
+            wait_for_console_pattern(self, 'OK')
+            exec_command(self, 'set radix_mmu=0')
+            exec_command(self, 'boot')
+            wait_for_console_pattern(self, 'cas: selected hash MMU', 'panic:')
+        else:
+            exec_command(self, '')
+            wait_for_console_pattern(self, 'cas: selected radix MMU', 'panic:')
+
+        wait_for_console_pattern(self, 'FreeBSD 15.0-CURRENT', 'panic:')
+        wait_for_console_pattern(self, 'FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs', 'panic:')
+        wait_for_console_pattern(self, 'FreeBSD/powerpc (Amnesiac) (ttyu0)', 'panic:')
+        exec_command(self, 'root')
+        wait_for_console_pattern(self, 'resizewin: timeout reading from terminal')
+        exec_command(self, 'poweroff')
+        wait_for_console_pattern(self, 'Uptime:', 'panic:')
+        self.vm.wait()
+
+    # powernv does not have a bootloader so must load the kernel directly
+    # and work around manual specification of the root device. Also can't
+    # specify options like radix_mmu the same way (todo: work out how it
+    # is done, and add HPT test).
+    def run_powernv_test(self, force_HPT=False):
+        self.vm.add_args('-m', '8g')
+        self.vm.add_args('-smp', '4')
+        self.set_powernv_devices()
+        self.vm.set_console()
+        self.vm.launch()
+
+        wait_for_console_pattern(self, 'FreeBSD 15.0-CURRENT', 'panic:')
+        wait_for_console_pattern(self, 'FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs', 'panic:')
+        wait_for_console_pattern(self, '<empty line>    Abort manual input')
+        exec_command(self, 'ufs:diskid/DISK-1234s3')
+
+        wait_for_console_pattern(self, 'FreeBSD/powerpc (Amnesiac) (ttyu0)', 'panic:')
+        exec_command(self, 'root')
+        wait_for_console_pattern(self, 'resizewin: timeout reading from terminal')
+        exec_command(self, 'poweroff')
+        wait_for_console_pattern(self, 'Uptime:', 'panic:')
+        wait_for_console_pattern(self, 'OPAL: Shutdown request', 'panic:')
+        self.vm.wait()
+
+    def test_pseries_tcg(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:tcg
+        """
+        self.require_accelerator("tcg")
+        self.vm.add_args("-cpu", "power10")
+        self.vm.add_args("-accel", "tcg,thread=multi")
+        self.run_pseries_test()
+
+    def test_pseries_hpt_tcg(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:tcg
+        """
+        self.require_accelerator("tcg")
+        self.vm.add_args("-accel", "tcg,thread=multi")
+        self.run_pseries_test(force_HPT=True)
+
+    def test_pseries_kvm(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:kvm
+        """
+        self.require_accelerator("kvm")
+        self.vm.add_args("-accel", "kvm")
+        self.run_pseries_test()
+
+    def test_pseries_hpt_kvm(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:kvm
+        """
+        self.require_accelerator("kvm")
+        self.vm.add_args("-accel", "kvm")
+        self.run_pseries_test(force_HPT=True)
+
+    # powernv9 works, powernv10 fails
+    def test_powernv(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv9
+        :avocado: tags=accel:tcg
+        """
+        self.require_accelerator("tcg")
+        self.vm.add_args("-accel", "tcg,thread=multi")
+        self.run_powernv_test()
Signature · 1 line
2.42.0