As with x86_64 we now have the bits to add a KVM gdb test. A couple of
minor wrinkles need to be handled.

The first is applying an offset when loading the symbols to take into
account the relocation that happens.

The other minor wrinkle is the s390x only supports WP_WRITE watch
points so we skip the other watch point tests lest we get confusing
messages about failing to insert HW breakpoints.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>

---
v3
  - add symbol-offset handling
  - limit the watchpoint tests
  - add skipIfMissingEnv("QEMU_TEST_GDB") decorator
---
 .../functional/gdb-scripts/kernel_gdb_test.py  | 10 ++++++----
 tests/functional/qemu_test/tuxruntest.py       |  4 ++++
 tests/functional/s390x/test_tuxrun.py          | 18 +++++++++++++++++-
 tests/guest-debug/run-test.py                  |  7 ++++++-
 tests/lcitool/libvirt-ci                       |  2 +-
 5 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/tests/functional/gdb-scripts/kernel_gdb_test.py 
b/tests/functional/gdb-scripts/kernel_gdb_test.py
index f457ccdcbf4..975faf3d284 100644
--- a/tests/functional/gdb-scripts/kernel_gdb_test.py
+++ b/tests/functional/gdb-scripts/kernel_gdb_test.py
@@ -95,11 +95,13 @@ def do_one_watch(sym, wtype, text):
 def check_watches(sym_name):
     "Watch a symbol for any access."
 
-    # Should hit for any read
-    do_one_watch(sym_name, gdb.WP_ACCESS, "awatch")
+    # s390 only supports write watchpoints
+    if "s390" not in gdb.selected_frame().architecture().name():
+        # Should hit for any read
+        do_one_watch(sym_name, gdb.WP_ACCESS, "awatch")
 
-    # Again should hit for reads
-    do_one_watch(sym_name, gdb.WP_READ, "rwatch")
+        # Again should hit for reads
+        do_one_watch(sym_name, gdb.WP_READ, "rwatch")
 
     # Finally when it is written
     do_one_watch(sym_name, gdb.WP_WRITE, "watch")
diff --git a/tests/functional/qemu_test/tuxruntest.py 
b/tests/functional/qemu_test/tuxruntest.py
index 6ad421e897d..c43a0b0e499 100644
--- a/tests/functional/qemu_test/tuxruntest.py
+++ b/tests/functional/qemu_test/tuxruntest.py
@@ -159,6 +159,7 @@ def common_tuxrun_gdb(self,
                           rootfs_asset,
                           accel=None,
                           dtb_asset=None,
+                          symbol_off = None,
                           drive="virtio-blk-device",
                           haltmsg="reboot: System halted",
                           console_index=0):
@@ -205,6 +206,9 @@ def common_tuxrun_gdb(self,
             "--gdb", gdb_path,
         ]
 
+        if symbol_off is not None:
+            cmd.extend(["--symbol-offset", f"{symbol_off}"])
+
         log_cmd = " ".join(f'"{arg}"' if ' ' in arg else arg for arg in cmd)
         self.log.info(f"run-test: {log_cmd}")
 
diff --git a/tests/functional/s390x/test_tuxrun.py 
b/tests/functional/s390x/test_tuxrun.py
index 8e0261e2b7f..3821f985196 100755
--- a/tests/functional/s390x/test_tuxrun.py
+++ b/tests/functional/s390x/test_tuxrun.py
@@ -11,7 +11,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-from qemu_test import Asset
+from qemu_test import Asset, skipIfMissingEnv
 from qemu_test.tuxruntest import TuxRunBaselineTest
 
 class TuxRunS390xTest(TuxRunBaselineTest):
@@ -19,6 +19,9 @@ class TuxRunS390xTest(TuxRunBaselineTest):
     ASSET_S390X_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/s390/bzImage',
         '5efeb31754b211440e1595ab11355bb006fe78a2c0604ed0a8c55c4598b71aec')
+    ASSET_S390X_VMLINUX = Asset(
+        'https://storage.tuxboot.com/kernels/6.18.54/s390/vmlinux.xz',
+        '5bbd4d34e0950f88053a9bfd16078896df4b1ee1696fc2ad62488e681a6bdd8e')
     ASSET_S390X_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/s390/rootfs.ext4.zst',
         '5ba18c4d18831c50a0c743990f7bdee1d3b520629d423c55b668d8fbbac9c6f5')
@@ -42,5 +45,18 @@ def test_s390_kvm(self):
                            haltmsg="Requesting system halt",
                            accel="kvm")
 
+    @skipIfMissingEnv("QEMU_TEST_GDB")
+    def test_s390_kvm_gdb(self):
+        self.set_machine('s390-ccw-virtio')
+        self.require_accelerator('kvm')
+        self.wait_for_shutdown=False
+        self.common_tuxrun_gdb(kernel_asset=self.ASSET_S390X_KERNEL,
+                               vmlinux_asset=self.ASSET_S390X_VMLINUX,
+                               rootfs_asset=self.ASSET_S390X_ROOTFS,
+                               symbol_off="0x3ffe0000000",
+                               drive="virtio-blk-ccw",
+                               haltmsg="Requesting system halt",
+                               accel="kvm")
+
 if __name__ == '__main__':
     TuxRunBaselineTest.main()
diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 48a5261618d..0b93aae62c6 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -28,6 +28,7 @@ def get_args():
     parser.add_argument("--kargs", help="Kernel args to --append")
     parser.add_argument("--binary", help="Binary to debug")
     parser.add_argument("--symbols", help="Symbol file for binary to debug")
+    parser.add_argument("--symbol-offset", help="offset to apply to symbols")
     parser.add_argument("--test", help="GDB test script")
     parser.add_argument('test_args', nargs='*',
                         help="Additional args for GDB test script. "
@@ -134,7 +135,11 @@ def format_cmd(cmd):
     gdb_cmd.extend(["-ex", f"target remote {socket_name}"])
 
     if args.symbols:
-        gdb_cmd.extend(["-ex", f"symbol-file {args.symbols}"])
+        sym_arg = f"symbol-file {args.symbols}"
+        if args.symbol_offset:
+            sym_arg += f" -o {args.symbol_offset}"
+
+        gdb_cmd.extend(["-ex", sym_arg])
 
     # finally the test script itself
     if args.test:
diff --git a/tests/lcitool/libvirt-ci b/tests/lcitool/libvirt-ci
index f34cd57eb89..5176e136ab1 160000
--- a/tests/lcitool/libvirt-ci
+++ b/tests/lcitool/libvirt-ci
@@ -1 +1 @@
-Subproject commit f34cd57eb892259c26600187bc35cc4152f932cf
+Subproject commit 5176e136ab11e275eb9f57c3d5c80e77af6507cb
-- 
2.47.3


Reply via email to