Skip to contentSkip to conversation

testing/next: functional testing updates for gdb (pre-PR)

PATCH In review Alex Bennée 5 participants 41 messages Oct 19 – Oct 27 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 cover testing/next: functional testing updates for gdb (pre-PR)

Hi,

This is the current state of my testing/next tree. There a are a few minor tweaks and fixes that I've picked up. The majority of the new code adds testing for the gdb stub when used via KVM.

As a result I spoke to Anders who handles the tuxrun images and he was able to turn on debugging symbols and provide a vmlinux alongside the bootable image. With these updates I was able to resurrect the old test script I was running by hand and then plumb it into a functional test.

So far I've done x86_64, aarch64 and s390x. I can't test ppc because our CI machines don't support nested KVM. I don't have access to any riscv kvm capable hardware.

The reason I went on the side-quest is because when working on cleaning up QEMU's internal KVM api I realised that quite a large chunk of it is not exercised by our functional tests. This would ensure that at least:

kvm_arch_update_guest_debug
kvm_arch_get_registers
kvm_arch_set_registers

is exercised and I'm less likely to break things in my re-factor ;-)

v3
- address review comments
- convert run-test to use arrays for gdb and qemu cmd lines
- fix errors on s390x and aarch64 hosts

v2

- fixed up the sh4 direct call
- dropped the fw tracing test case as tuxrun images cover it all
- added aarch64 and s390x cases
- worked around s390x watchpoint issues

The following still need review:

tests/functional: teach tuxrun about launching gdb tests tests/guest-debug: convert cmd to an qemu_cmd array tests/guest-debug: convert gdb_cmd to an array

Alex.

Alex Bennée (18):
tests/functional: test_acpi_bits requires TCG .dir-locals: include QEMU code in PYTHONPATH
meson: move gdb detection into the top level build file tests/functional: allow tuxrun tests to be passed "accel" tests/functional: split x86_64 tuxrun into tcg and kvm run tests/functional: update x86_64 tuxrun images tests/guest-debug: convert gdb_cmd to an array tests/guest-debug: convert cmd to an qemu_cmd array tests/guest-debug: add --kargs option to run-test tests/guest-debug: add --symbols option to run-test tests/functional: teach tuxrun about launching gdb tests tests/functional: add tuxrun kvm gdb test for x86_64 tests/functional: split aarch64 tuxrun into tcg and kvm run tests/functional: update arm64 tuxrun images tests/functional: add tuxrun kvm gdb test for arm64 tests/functional: split s390x tuxrun into tcg and kvm run tests/functional: update s390x tuxrun images tests/functional: add tuxrun kvm gdb test for s390x

Max Filippov (1):
tests/tcg: fix buffer overflow in multiarch/linux/linux-sigrtminmax

 meson.build                                   |  15 +-
 tests/tcg/multiarch/linux/linux-sigrtminmax.c |   2 +-
 .dir-locals.el                                |   8 +-
 tests/functional/aarch64/test_tuxrun.py       |  35 +++-
 .../functional/gdb-scripts/kernel_gdb_test.py | 164 ++++++++++++++++++
 tests/functional/meson.build                  |   5 +-
 tests/functional/qemu_test/tuxruntest.py      | 108 ++++++++++--
 tests/functional/s390x/test_tuxrun.py         |  37 +++-
 tests/functional/sh4/test_tuxrun.py           |   6 +-
 tests/functional/x86_64/test_acpi_bits.py     |   3 +
 tests/functional/x86_64/test_tuxrun.py        |  45 ++++-
 tests/guest-debug/run-test.py                 |  83 ++++++---
 tests/lcitool/libvirt-ci                      |   2 +-
 tests/tcg/meson.build                         |   5 -
 14 files changed, 444 insertions(+), 74 deletions(-)
 create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py
Signature · 1 line
2.47.3
#1 lore raw

PATCH v3 1/19 tests/functional: test_acpi_bits requires TCG

Running a full thorough test suite on a KVM-only build fails due to acpi bits needing icount, therefor tcg. Declare the restriction so the test harness can skip it.

Message-ID: <[email protected]>

---
v2
- add comment

---
 tests/functional/x86_64/test_acpi_bits.py | 3 +++
 1 file changed, 3 insertions(+)
tests/functional/x86_64/test_acpi_bits.py +3 -0
index ec716d643bf..d445660f0ed 100755
@@ -303,6 +303,9 @@ def test_acpi_smbios_bits(self):
         """The main test case implementation."""
 
         self.set_machine('pc')
+        # see icount comment below
+        self.require_accelerator('tcg')
+
         iso_file = self.scratch_file('bits-%d.iso' % self.BITS_INTERNAL_VER)
 
         self.assertTrue(os.access(iso_file, os.R_OK))
Signature · 1 line
2.47.3
Reviewed-by on v3 1/19
#2 lore raw

Re: [PATCH v3 01/19] tests/functional: test_acpi_bits requires TCG

Quoted 2 lines · Alex Bennée

Running a full thorough test suite on a KVM-only build fails due to acpi bits needing icount, therefor tcg. Declare the restriction so the

therefore?

Quoted 6 lines

test harness can skip it.

Message-ID: <[email protected]>

Quoted 8 lines

---
v2
- add comment

---
  tests/functional/x86_64/test_acpi_bits.py | 3 +++
  1 file changed, 3 insertions(+) 
#3 lore raw

PATCH v3 2/19 tests/tcg: fix buffer overflow in multiarch/linux/linux-sigrtminmax

In reply to Alex Bennée

From: Max Filippov <[email protected]>

Fix new_argv allocation size to be (argc + 2) * sizeof(char *) bytes, which matches the way it's used to store argc + 2 pointers.

This fixes the test for me, which otherwise fails on xtensa with the following message

linux-sigrtminmax.c: 59: main: Assertion `execve(new_argv[0], new_argv, environ) == 0' failed.'.

Message-ID: <[email protected]>

Message-ID: <[email protected]>

---
 tests/tcg/multiarch/linux/linux-sigrtminmax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/multiarch/linux/linux-sigrtminmax.c +1 -1
index a7059aacd9c..b5ea65f3d39 100644
@@ -39,7 +39,7 @@ int main(int argc, char **argv)
     assert(qemu);
 
     if (!getenv("QEMU_RTSIG_MAP")) {
-        char **new_argv = malloc((argc + 2) + sizeof(char *));
+        char **new_argv = malloc((argc + 2) * sizeof(char *));
         int tsig1, hsig1, count1, tsig2, hsig2, count2;
         char rt_sigmap[64];
 
Signature · 1 line
2.47.3
#4 lore raw

PATCH v3 3/19 .dir-locals: include QEMU code in PYTHONPATH

In reply to Alex Bennée

When editing python code the linters tools have a hard time with our imports as they can't be found. To ease this we can expand a PYTHONPATH in .dir-locals so at least Emacs users can have less warnings in their editor.

I still get complaints from python-mypy about missing library stubs that mean it can't do proper type analysis though.

Message-ID: <[email protected]>

---
 .dir-locals.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
.dir-locals.el +7 -1
index 3ac0cfc6f0d..51871619422 100644
@@ -1,2 +1,8 @@
 ((c-mode . ((c-file-style . "stroustrup")
-	    (indent-tabs-mode . nil))))
+	    (indent-tabs-mode . nil)))
+ (python-mode .
+              ((eval . (when-let* ((root (locate-dominating-file default-directory ".dir-locals.el")))
+                         (setq-local process-environment (copy-sequence process-environment))
+                         (setenv "PYTHONPATH"
+                                 (concat (expand-file-name "python" root) ":"
+                                         (expand-file-name "tests/functional" root))))))))
Signature · 1 line
2.47.3
Reviewed-by on v3 3/19
#5 lore raw

Re: [PATCH v3 03/19] .dir-locals: include QEMU code in PYTHONPATH

Quoted 9 lines · Alex Bennée

When editing python code the linters tools have a hard time with our imports as they can't be found. To ease this we can expand a PYTHONPATH in .dir-locals so at least Emacs users can have less warnings in their editor.

I still get complaints from python-mypy about missing library stubs that mean it can't do proper type analysis though.

[...]

Signature · 1 line
Marc-André Lureau <[email protected]>
#6 lore raw

PATCH v3 4/19 meson: move gdb detection into the top level build file

In reply to Alex Bennée

Currently gdb is only used by TCG based tests but hypervisors want to use gdbstub too. To be able to test this case we need to always probe and report the gdb we have.

Message-ID: <[email protected]>

---
 meson.build                  | 15 +++++++--------
 tests/functional/meson.build |  5 ++---
 tests/tcg/meson.build        |  5 -----
 3 files changed, 9 insertions(+), 16 deletions(-)
meson.build +7 -8
index bbef9d9c293..4f29bc6cc33 100644
@@ -163,6 +163,12 @@ else
   iasl = find_program(get_option('iasl'), required: true)
 endif
 
+if get_option('gdb') == ''
+  gdb = find_program(['gdb-multiarch', 'gdb'], required: false)
+else
+  gdb = find_program(get_option('gdb'), required: true)
+endif
+
 edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'riscv64-softmmu', 'loongarch64-softmmu' ]
 unpack_edk2_blobs = false
 foreach target : edk2_targets
@@ -4710,14 +4716,7 @@ summary(summary_info, bool_yn: true, section: 'Directories')
 summary_info = {}
 summary_info += {'python':            '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
 summary_info += {'sphinx-build':      sphinx_build}
-
-# FIXME: the [binaries] section of machine files, which can be probed
-# with find_program(), would be great for passing gdb and genisoimage
-# paths from configure to Meson.  However, there seems to be no way to
-# hide a program (for example if gdb is too old).
-if config_host.has_key('GDB')
-  summary_info += {'gdb':             config_host['GDB']}
-endif
+summary_info += {'gdb':               gdb}
 summary_info += {'iasl':              iasl}
 summary_info += {'genisoimage':       config_host['GENISOIMAGE']}
 if host_os == 'windows' and have_ga
tests/functional/meson.build +2 -3
index c7362dd00ef..68c601d4036 100644
@@ -83,9 +83,8 @@ foreach speed : ['quick', 'thorough']
                      separator : ':')
 
     # Define the GDB environment variable if gdb is available.
-    gdb = get_option('gdb')
-    if gdb != ''
-      test_env.set('QEMU_TEST_GDB', gdb)
+    if gdb.found()
+      test_env.set('QEMU_TEST_GDB', gdb.full_path())
     endif
 
     foreach test : target_tests
tests/tcg/meson.build +0 -5
index 1cd2d421cea..06f013fbe3d 100644
@@ -1,11 +1,6 @@
 env = find_program('env')
 
 docker_wrapper = find_program('../docker/docker.py')
-if get_option('gdb') != ''
-  gdb = find_program(get_option('gdb'), required: true)
-else
-  gdb = find_program(['gdb-multiarch', 'gdb'], required: false)
-endif
 prog_check_plugin_output = find_program('./scripts/check_plugin_output.sh')
 prog_gdb_test = find_program('../guest-debug/run-test.py')
 prog_record_replay = find_program('./scripts/record_replay.sh')
Signature · 1 line
2.47.3
#7 lore raw

PATCH v3 5/19 tests/functional: allow tuxrun tests to be passed "accel"

In reply to Alex Bennée

For some tests we are about to add we want the flexibility to force "kvm" so give them that ability.

Message-ID: <[email protected]>

---
v2
- fix the sh4 direct call to prepare run.

---
 tests/functional/qemu_test/tuxruntest.py | 9 +++++++--
 tests/functional/sh4/test_tuxrun.py      | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)
tests/functional/qemu_test/tuxruntest.py +7 -2
index 6c442ff0dc4..ca1589fea37 100644
@@ -65,7 +65,7 @@ def fetch_tuxrun_assets(self, kernel_asset, rootfs_asset, dtb_asset=None):
 
         return (kernel_image, disk_image, dtb)
 
-    def prepare_run(self, kernel, disk, drive, dtb=None, console_index=0):
+    def prepare_run(self, accel, kernel, disk, drive, dtb=None, console_index=0):
         """
         Setup to run and add the common parameters to the system
         """
@@ -79,6 +79,10 @@ def prepare_run(self, kernel, disk, drive, dtb=None, console_index=0):
         self.kcmd_line += f" root=/dev/{self.root}"
         self.kcmd_line += f" console={self.console}"
 
+        # have we specified an accelerator?
+        if accel:
+            self.vm.add_args('-accel', accel)
+
         self.vm.add_args('-kernel', kernel,
                          '-append', self.kcmd_line,
                          '-blockdev', blockdev)
@@ -118,6 +122,7 @@ def run_tuxtest_tests(self, haltmsg):
     def common_tuxrun(self,
                       kernel_asset,
                       rootfs_asset,
+                      accel=None,
                       dtb_asset=None,
                       drive="virtio-blk-device",
                       haltmsg="reboot: System halted",
@@ -130,7 +135,7 @@ def common_tuxrun(self,
         (kernel, disk, dtb) = self.fetch_tuxrun_assets(kernel_asset, rootfs_asset,
                                                        dtb_asset)
 
-        self.prepare_run(kernel, disk, drive, dtb, console_index)
+        self.prepare_run(accel, kernel, disk, drive, dtb, console_index)
         self.vm.launch()
         self.run_tuxtest_tests(haltmsg)
         os.remove(disk)
tests/functional/sh4/test_tuxrun.py +1 -1
index 1748f8c7eff..42b503585b2 100755
@@ -35,7 +35,7 @@ def test_sh4(self):
                                                        self.ASSET_SH4_ROOTFS)
 
         # the console comes on the second serial port
-        self.prepare_run(kernel, disk,
+        self.prepare_run(None, kernel, disk,
                          "driver=ide-hd,bus=ide.0,unit=0",
                          console_index=1)
         self.vm.launch()
Signature · 1 line
2.47.3
#8 lore raw

PATCH v3 6/19 tests/functional: split x86_64 tuxrun into tcg and kvm run

In reply to Alex Bennée

Add an explicit "kvm" run to the tuxrun tests. Although running on an x86_64 host would probably have defaulted to "kvm" anyway we want to exercise specific features later.

Message-ID: <[email protected]>

---
 tests/functional/x86_64/test_tuxrun.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
tests/functional/x86_64/test_tuxrun.py +16 -1
index fcbc62b1b0f..729f6447d05 100755
@@ -24,13 +24,28 @@ class TuxRunX86Test(TuxRunBaselineTest):
         '4b8b2a99117519c5290e1202cb36eb6c7aaba92b357b5160f5970cf5fb78a751')
 
     def test_x86_64(self):
+        self.require_accelerator("tcg")
+
+        self.set_machine('q35')
+        self.cpu="Nehalem"
+        self.root='sda'
+        self.wait_for_shutdown=False
+        self.common_tuxrun(kernel_asset=self.ASSET_X86_64_KERNEL,
+                           rootfs_asset=self.ASSET_X86_64_ROOTFS,
+                           drive="driver=ide-hd,bus=ide.0,unit=0",
+                           accel="tcg")
+
+    def test_x86_64_kvm(self):
+        self.require_accelerator("kvm")
+
         self.set_machine('q35')
         self.cpu="Nehalem"
         self.root='sda'
         self.wait_for_shutdown=False
         self.common_tuxrun(kernel_asset=self.ASSET_X86_64_KERNEL,
                            rootfs_asset=self.ASSET_X86_64_ROOTFS,
-                           drive="driver=ide-hd,bus=ide.0,unit=0")
+                           drive="driver=ide-hd,bus=ide.0,unit=0",
+                           accel="kvm")
 
 if __name__ == '__main__':
     TuxRunBaselineTest.main()
Signature · 1 line
2.47.3
#9 lore raw

PATCH v3 7/19 tests/functional: update x86_64 tuxrun images

In reply to Alex Bennée

We now split the fetching of the buildroot image from the kernel itself. This is because we will want to access additional metadata in future tests.

Message-ID: <[email protected]>

---
 tests/functional/x86_64/test_tuxrun.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/functional/x86_64/test_tuxrun.py +4 -4
index 729f6447d05..026b373accb 100755
@@ -17,11 +17,11 @@
 class TuxRunX86Test(TuxRunBaselineTest):
 
     ASSET_X86_64_KERNEL = Asset(
-        'https://storage.tuxboot.com/buildroot/20241119/x86_64/bzImage',
-        'f57bfc6553bcd6e0a54aab86095bf642b33b5571d14e3af1731b18c87ed5aef8')
+        'https://storage.tuxboot.com/kernels/6.18.54/x86_64/bzImage',
+        '24a3ade610c2cc426ff821050de8a35930b0371357d94cc2c334abac6658552b')
     ASSET_X86_64_ROOTFS = Asset(
-        'https://storage.tuxboot.com/buildroot/20241119/x86_64/rootfs.ext4.zst',
-        '4b8b2a99117519c5290e1202cb36eb6c7aaba92b357b5160f5970cf5fb78a751')
+        'https://storage.tuxboot.com/buildroot/20260924/x86_64/rootfs.ext4.zst',
+        '8e310455b0244414ccff29c507f7ccfd4032e3587cc405e49ab0322738e3e27c')
 
     def test_x86_64(self):
         self.require_accelerator("tcg")
Signature · 1 line
2.47.3
#10 lore raw

PATCH v3 8/19 tests/guest-debug: convert gdb_cmd to an array

In reply to Alex Bennée

Passing a plain string to subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. This can be tricky to track across multiple processes. To simplify this build the command as an array and execute gdb directly without involving the shell.

We add a mini-helper to make the log output a bit more copy and paste friendly.

---
 tests/guest-debug/run-test.py | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
tests/guest-debug/run-test.py +15 -11
index 838c1c26971..e8b69f85cd1 100755
@@ -51,6 +51,10 @@ def log(output, msg):
         print(msg)
 
 
+def format_cmd(cmd):
+    return " ".join(f'"{arg}"' if ' ' in arg else arg for arg in cmd)
+
+
 if __name__ == '__main__':
     args = get_args()
 
@@ -98,32 +102,32 @@ def log(output, msg):
     inferior = subprocess.Popen(shlex.split(cmd))
 
     # Now launch gdb with our test and collect the result
-    gdb_cmd = "%s %s" % (args.gdb, args.binary)
+    gdb_cmd = [args.gdb, args.binary]
     if args.gdb_args:
-        gdb_cmd += " %s" % (args.gdb_args)
+        gdb_cmd.extend(shlex.split(args.gdb_args))
+
     # run quietly and ignore .gdbinit
-    gdb_cmd += " -q -n -batch"
+    gdb_cmd.extend(["-q", "-n", "-batch"])
     # disable pagination
-    gdb_cmd += " -ex 'set pagination off'"
+    gdb_cmd.extend(["-ex", "set pagination off"])
     # disable prompts in case of crash
-    gdb_cmd += " -ex 'set confirm off'"
+    gdb_cmd.extend(["-ex", "set confirm off"])
     # connect to remote
-    gdb_cmd += " -ex 'target remote %s'" % (socket_name)
+    gdb_cmd.extend(["-ex", f"target remote {socket_name}"])
     # finally the test script itself
     if args.test:
         if args.test_args:
-            gdb_cmd += f" -ex \"py sys.argv={args.test_args}\""
-        gdb_cmd += " -x %s" % (args.test)
-
+            gdb_cmd.extend(["-ex", f"py sys.argv={args.test_args}"])
+        gdb_cmd.extend(["-x", args.test])
 
     sleep(1)
-    log(output, "GDB CMD: %s" % (gdb_cmd))
+    log(output, "GDB CMD: %s" % (format_cmd(gdb_cmd)))
 
     gdb_env = dict(os.environ)
     gdb_pythonpath = gdb_env.get("PYTHONPATH", "").split(os.pathsep)
     gdb_pythonpath.append(os.path.dirname(os.path.realpath(__file__)))
     gdb_env["PYTHONPATH"] = os.pathsep.join(gdb_pythonpath)
-    result = subprocess.call(gdb_cmd, shell=True, stdout=output, stderr=stderr,
+    result = subprocess.call(gdb_cmd, stdout=output, stderr=stderr,
                              env=gdb_env)
 
     # A result of greater than 128 indicates a fatal signal (likely a
Signature · 1 line
2.47.3
Reviewed-by on v3 8/19
#11 lore raw

Re: [PATCH v3 08/19] tests/guest-debug: convert gdb_cmd to an array

Quoted 6 lines · Alex Bennée

Passing a plain string to subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. This can be tricky to track across multiple processes. To simplify this build the command as an array and execute gdb directly without involving the shell.

Quoted 8 lines

We add a mini-helper to make the log output a bit more copy and paste friendly.

---
  tests/guest-debug/run-test.py | 26 +++++++++++++++-----------
  1 file changed, 15 insertions(+), 11 deletions(-)
Reviewed-by on v3 8/19
#12 lore raw

Re: [PATCH v3 08/19] tests/guest-debug: convert gdb_cmd to an array

In reply to Alex Bennée
Quoted 20 lines · Alex Bennée

Passing a plain string to subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. This can be tricky to track across multiple processes. To simplify this build the command as an array and execute gdb directly without involving the shell.

We add a mini-helper to make the log output a bit more copy and paste friendly.

---
  tests/guest-debug/run-test.py | 26 +++++++++++++++-----------
  1 file changed, 15 insertions(+), 11 deletions(-)
tests/guest-debug/run-test.py +0 -0
index 838c1c26971..e8b69f85cd1 100755

tests/guest-debug/run-test.py def log(output, msg): · line 55

Quoted 5 lines
tests/guest-debug/run-test.py +2 -0
@@ -51,6 +51,10 @@ def log(output, msg):
          print(msg)
 
 
+def format_cmd(cmd):
+    return " ".join(f'"{arg}"' if ' ' in arg else arg for arg in cmd)

I would use shlex.quote() here.
It doesn't do anything to strings that don't require quoting:

tests/guest-debug/run-test.py def log(output, msg): · line 56

Quoted 1 line
tests/guest-debug/run-test.py +0 -0
 >> print(shlex.quote('aaa'))

aaa

tests/guest-debug/run-test.py def log(output, msg): · line 57

Quoted 1 line
tests/guest-debug/run-test.py +0 -0
 >> print(shlex.quote('"aaa'))

'"aaa'

With that:

[...]

Reviewed-by on v3 8/19
#13 lore raw

Re: [PATCH v3 08/19] tests/guest-debug: convert gdb_cmd to an array

In reply to Alex Bennée
Quoted 10 lines · Alex Bennée

Passing a plain string to subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. This can be tricky to track across multiple processes. To simplify this build the command as an array and execute gdb directly without involving the shell.

We add a mini-helper to make the log output a bit more copy and paste friendly.

[...]

Signature · 1 line
Marc-André Lureau <[email protected]>
#14 lore raw

PATCH v3 9/19 tests/guest-debug: convert cmd to an qemu_cmd array

In reply to Alex Bennée

As with gdb_cmd passing a plain string to a subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. Do the same as gdb_cmd and make the whole thing an array.

There are a few minor wrinkles with when args.binary is expected so add some comments for that.

---
 tests/guest-debug/run-test.py | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)
tests/guest-debug/run-test.py +18 -13
index e8b69f85cd1..d5ffaaa9ffc 100755
@@ -79,27 +79,32 @@ def format_cmd(cmd):
     socket_name = os.path.join(socket_dir.name, "gdbstub.socket")
 
     # Launch QEMU with binary
+    qemu_cmd = [args.qemu]
+    if args.qargs:
+        qemu_cmd.extend(shlex.split(args.qargs))
+
     if "system" in args.qemu:
-        if args.no_suspend:
-            suspend = ''
-        else:
-            suspend = ' -S'
-        cmd = f'{args.qemu} {args.qargs} {args.binary}' \
-            f'{suspend} -gdb unix:path={socket_name},server=on'
+        # for system mode we assume qargs has set-up for binary
+        qemu_cmd.append(args.binary)
+        if not args.no_suspend:
+            qemu_cmd.append("-S")
+        qemu_cmd.extend(["-gdb", f"unix:path={socket_name},server=on"])
         # There is no guest program command-line in system mode.
         assert not args.pargs
     else:
+        qemu_cmd.append("-g")
         if args.no_suspend:
-            suspend = ',suspend=n'
+            qemu_cmd.append(f"{socket_name},suspend=n")
         else:
-            suspend = ''
-        cmd = f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \
-            f' {args.binary}'
+            qemu_cmd.append(f"{socket_name}")
+
+        # for user mode binary and args always go at the end
+        qemu_cmd.append(args.binary)
         if args.pargs:
-            cmd += f' {args.pargs}'
+            qemu_cmd.extend(shlex.split(args.pargs))
 
-    log(output, "QEMU CMD: %s" % (cmd))
-    inferior = subprocess.Popen(shlex.split(cmd))
+    log(output, "QEMU CMD: %s" % (format_cmd(qemu_cmd)))
+    inferior = subprocess.Popen(qemu_cmd)
 
     # Now launch gdb with our test and collect the result
     gdb_cmd = [args.gdb, args.binary]
Signature · 1 line
2.47.3
Reviewed-by on v3 9/19
#15 lore raw

Re: [PATCH v3 09/19] tests/guest-debug: convert cmd to an qemu_cmd array

Quoted 4 lines · Alex Bennée

As with gdb_cmd passing a plain string to a subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. Do the same as gdb_cmd and make the whole thing an array.

Quoted 8 lines

There are a few minor wrinkles with when args.binary is expected so add some comments for that.

---
  tests/guest-debug/run-test.py | 31 ++++++++++++++++++-------------
  1 file changed, 18 insertions(+), 13 deletions(-)
Reviewed-by on v3 9/19
#16 lore raw

Re: [PATCH v3 09/19] tests/guest-debug: convert cmd to an qemu_cmd array

In reply to Alex Bennée
Quoted 4 lines · Alex Bennée

As with gdb_cmd passing a plain string to a subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. Do the same as gdb_cmd and make the whole thing an array.

Quoted 8 lines

There are a few minor wrinkles with when args.binary is expected so add some comments for that.

---
  tests/guest-debug/run-test.py | 31 ++++++++++++++++++-------------
  1 file changed, 18 insertions(+), 13 deletions(-)
Reviewed-by on v3 9/19
#17 lore raw

Re: [PATCH v3 09/19] tests/guest-debug: convert cmd to an qemu_cmd array

In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

As with gdb_cmd passing a plain string to a subprocess involves making sure the escaping is correct so the underlying shell doesn't get confused. Do the same as gdb_cmd and make the whole thing an array.

There are a few minor wrinkles with when args.binary is expected so add some comments for that.

[...]

Signature · 1 line
Marc-André Lureau <[email protected]>
#18 lore raw

PATCH v3 10/19 tests/guest-debug: add --kargs option to run-test

In reply to Alex Bennée

When passing kernel arguments to QEMU with --append we need to take care that things are properly escaped. It's easier if we get the run script to do it for us that constructed the nested escaped --qargs.

Message-ID: <[email protected]>

---
v3
- fix merge with array

---
 tests/guest-debug/run-test.py | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/guest-debug/run-test.py +8 -0
index d5ffaaa9ffc..782c0c5da19 100755
@@ -25,6 +25,7 @@ def get_args():
                         required=True)
     parser.add_argument("--qargs", help="Qemu arguments for test")
     parser.add_argument("--pargs", help="Program arguments for test")
+    parser.add_argument("--kargs", help="Kernel args to --append")
     parser.add_argument("--binary", help="Binary to debug",
                         required=True)
     parser.add_argument("--test", help="GDB test script")
@@ -89,6 +90,10 @@ def format_cmd(cmd):
         if not args.no_suspend:
             qemu_cmd.append("-S")
         qemu_cmd.extend(["-gdb", f"unix:path={socket_name},server=on"])
+
+        if args.kargs:
+            qemu_cmd.extend(["--append", args.kargs])
+
         # There is no guest program command-line in system mode.
         assert not args.pargs
     else:
@@ -98,6 +103,9 @@ def format_cmd(cmd):
         else:
             qemu_cmd.append(f"{socket_name}")
 
+        # There are no appended args in user-mode
+        assert not args.kargs
+
         # for user mode binary and args always go at the end
         qemu_cmd.append(args.binary)
         if args.pargs:
Signature · 1 line
2.47.3
Reviewed-by on v3 10/19
#19 lore raw

Re: [PATCH v3 10/19] tests/guest-debug: add --kargs option to run-test

Quoted 6 lines · Alex Bennée

When passing kernel arguments to QEMU with --append we need to take care that things are properly escaped. It's easier if we get the run script to do it for us that constructed the nested escaped --qargs.

Message-ID: <[email protected]>

Quoted 8 lines

---
v3
- fix merge with array

---
  tests/guest-debug/run-test.py | 8 ++++++++
  1 file changed, 8 insertions(+)
Reviewed-by on v3 10/19
#20 lore raw

Re: [PATCH v3 10/19] tests/guest-debug: add --kargs option to run-test

In reply to Alex Bennée
Quoted 9 lines · Alex Bennée

When passing kernel arguments to QEMU with --append we need to take care that things are properly escaped. It's easier if we get the run script to do it for us that constructed the nested escaped --qargs.

Message-ID: <[email protected]>

[...]

Signature · 1 line
Marc-André Lureau <[email protected]>
#21 lore raw

PATCH v3 11/19 tests/guest-debug: add --symbols option to run-test

In reply to Alex Bennée

Sometimes the debug symbols are not in the kernel binary image but in a separate elf blob. Provide --symbols to facilitate using them.

Message-ID: <[email protected]>

---
v3
- fix merge conflict now we use array for gdb_cmd

---
 tests/guest-debug/run-test.py | 5 +++++
 1 file changed, 5 insertions(+)
tests/guest-debug/run-test.py +5 -0
index 782c0c5da19..e74bb489ee1 100755
@@ -28,6 +28,7 @@ def get_args():
     parser.add_argument("--kargs", help="Kernel args to --append")
     parser.add_argument("--binary", help="Binary to debug",
                         required=True)
+    parser.add_argument("--symbols", help="Symbol file for binary to debug")
     parser.add_argument("--test", help="GDB test script")
     parser.add_argument('test_args', nargs='*',
                         help="Additional args for GDB test script. "
@@ -127,6 +128,10 @@ def format_cmd(cmd):
     gdb_cmd.extend(["-ex", "set confirm off"])
     # connect to remote
     gdb_cmd.extend(["-ex", f"target remote {socket_name}"])
+
+    if args.symbols:
+        gdb_cmd.extend(["-ex", f"symbol-file {args.symbols}"])
+
     # finally the test script itself
     if args.test:
         if args.test_args:
Signature · 1 line
2.47.3
Reviewed-by on v3 11/19
#22 lore raw

Re: [PATCH v3 11/19] tests/guest-debug: add --symbols option to run-test

Quoted 5 lines · Alex Bennée

Sometimes the debug symbols are not in the kernel binary image but in a separate elf blob. Provide --symbols to facilitate using them.

Message-ID: <[email protected]>

Quoted 8 lines

---
v3
- fix merge conflict now we use array for gdb_cmd

---
  tests/guest-debug/run-test.py | 5 +++++
  1 file changed, 5 insertions(+)
Reviewed-by on v3 11/19
#23 lore raw

Re: [PATCH v3 11/19] tests/guest-debug: add --symbols option to run-test

In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

Sometimes the debug symbols are not in the kernel binary image but in a separate elf blob. Provide --symbols to facilitate using them.

Message-ID: <[email protected]>

[...]

Signature · 1 line
Marc-André Lureau <[email protected]>
#24 lore raw

PATCH v3 12/19 tests/functional: teach tuxrun about launching gdb tests

In reply to Alex Bennée

This resurrects the hand run test script from d84842be6c5 (tests:
remove test-gdbstub.py) and modernises it to use the shared test infrastructure for run-test.

We then tweak the common tuxrun code to over an alternative "launch via gdbstub" helper which reuses the existing code but:

- needs a vmlinux with symbols
- drops kaslr because it doesn't play nice with symbols
- extend qargs with stuff normally added by vm.launch
- passes kargs directly
- runs with the gdb run-test script
- log the run-test output to the console log
- makes --binary not mandatory

Message-ID: <[email protected]>

---
v3
- mention the nokaslr in the commit message
- add a comment about it to the shared kernel args
- drop unused failcount
- remove stale comment about hbreak
- always delete the watch point pass or fail
- fix unbalanced tuple in sh4's direct call of fetch_tuxrun_assets
- simplify the symbol to watchpoint logic
- drop the mandatory --binary
- make the command copy and paste friendly
v2
- add self.vm._machine to qargs
- drop leading spaces in print () calls
- add register read tests
- use gdb.Breakpoint for hwbreak as for swbreak
- drop flaky symbol evaluation, verify hit_count instead
- explicit gdb.BP_BREAKPOINT for CatchBreakpoint

---
 .../functional/gdb-scripts/kernel_gdb_test.py | 162 ++++++++++++++++++
 tests/functional/qemu_test/tuxruntest.py      |  97 ++++++++++-
 tests/functional/sh4/test_tuxrun.py           |   4 +-
 tests/guest-debug/run-test.py                 |  14 +-
 4 files changed, 261 insertions(+), 16 deletions(-)
 create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py
tests/functional/gdb-scripts/kernel_gdb_test.py new file +162 -0
new file mode 100644
index 00000000000..f457ccdcbf4
@@ -0,0 +1,162 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Generic Kernel GDB script to verify functionality:
+#  - Single-stepping
+#  - Hardware breakpoints
+#  - Software breakpoints
+#  - Watchpoints
+#
+# It relies on fairly common kernel points to break at and symbols for
+# the kernel. Address space randomisation (kaslr) needs to be disabled.
+#
+# Copyright (c) 2026 Linaro Limited
+#
+# Author:
+#  Alex Bennée <[email protected]>
+#
+# This is launched by the tuxrun functional tests via tests/guest-debug/run-test.py
+
+import gdb
+from test_gdbstub import main, report
+
+def parse_registers():
+    """Parse 'info registers' into a name -> value dictionary."""
+    regs = {}
+    for line in gdb.execute("info registers", to_string=True).splitlines():
+        parts = line.split()
+        if len(parts) >= 2:
+            regs[parts[0]] = parts[1]
+    return regs
+
+
+def check_step():
+    "Step an instruction, check it moved."
+    start_pc = gdb.parse_and_eval('$pc')
+    gdb.execute("si")
+    end_pc = gdb.parse_and_eval('$pc')
+
+    return not (start_pc == end_pc)
+
+
+def check_reg_updates(regs_start):
+    regs_end = parse_registers()
+
+    changed = [k for k in regs_start
+               if k in regs_end and regs_start[k] != regs_end[k]]
+
+    report(len(changed) > 0, f"{len(changed)} registers changed.")
+
+
+def check_break(sym_name):
+    "Setup breakpoint, continue and check we stopped."
+    bp = gdb.Breakpoint(sym_name)
+    gdb.execute("c")
+    res = bp.hit_count == 1
+    bp.delete()
+
+    return res
+
+
+def check_hbreak(sym_name):
+    "Setup hardware breakpoint, continue and check we stopped."
+    bp = gdb.Breakpoint(sym_name, type = gdb.BP_HARDWARE_BREAKPOINT)
+    gdb.execute("c")
+    res = bp.hit_count == 1
+    bp.delete()
+
+    return res
+
+
+class WatchPoint(gdb.Breakpoint):
+
+    def __init__(self, sym_name, type):
+        super(WatchPoint, self).__init__(sym_name, gdb.BP_WATCHPOINT, type)
+
+    def stop(self):
+        end_pc = gdb.parse_and_eval('$pc')
+        print("HIT WP @ %s" % (end_pc))
+        return True
+
+
+def do_one_watch(sym, wtype, text):
+
+    wp = WatchPoint(sym, wtype)
+    gdb.execute("c")
+    report_str = "%s for %s" % (text, sym)
+
+    if wp.hit_count > 0:
+        report(True, report_str)
+    else:
+        report(False, report_str)
+
+    wp.delete()
+
+
+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")
+
+    # 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")
+
+
+class CatchBreakpoint(gdb.Breakpoint):
+    def __init__(self, sym_name):
+        super(CatchBreakpoint, self).__init__(sym_name, type = gdb.BP_BREAKPOINT)
+        self.sym, ok = gdb.lookup_symbol(sym_name)
+
+    def stop(self):
+        end_pc = gdb.parse_and_eval('$pc')
+        print("CB: %s == %s" % (end_pc, self.sym.value()))
+        if end_pc == self.sym.value():
+            report(False, "Hit final catchpoint")
+
+
+def run_test():
+    "Run through the tests one by one"
+
+    # get the initial register state
+    regs_start = parse_registers()
+
+    print("Checking we can step the first few instructions")
+    step_ok = 0
+    for i in range(3):
+        if check_step():
+            step_ok += 1
+
+    report(step_ok == 3, "single step in boot code")
+
+    # check some registers changed
+    print("Checking register access works")
+    check_reg_updates(regs_start)
+
+    print("Checking HW breakpoint works")
+    break_ok = check_hbreak("kernel_init")
+    report(break_ok, "hbreak @ kernel_init")
+
+    # Can't set this up until we are in the kernel proper
+    # if we make it to run_init_process we've over-run and
+    # one of the tests failed
+
+    print("Setup catch-all for run_init_process")
+    cbp = CatchBreakpoint("run_init_process")
+
+    # We should see wait_for_completion called right at the start of
+    # kernel_init
+    print("Checking Normal breakpoint works")
+    break_ok = check_break("wait_for_completion")
+    report(break_ok, "break @ wait_for_completion")
+
+    print("Checking watchpoint works")
+    check_watches("system_state")
+
+    # check we didn't hit the end
+    report(cbp.hit_count == 0, "CatchBreakpoint not hit")
+
+
+main(run_test)
tests/functional/qemu_test/tuxruntest.py +88 -9

138 lines not on this page · raw message

tests/functional/sh4/test_tuxrun.py +2 -2
index 42b503585b2..07c7ee6e03b 100755
@@ -31,8 +31,8 @@ def test_sh4(self):
 
         # The test is currently too unstable to do much in userspace
         # so we skip common_tuxrun and do a minimal boot and shutdown.
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(self.ASSET_SH4_KERNEL,
-                                                       self.ASSET_SH4_ROOTFS)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(self.ASSET_SH4_KERNEL,
+                                                          self.ASSET_SH4_ROOTFS)
 
         # the console comes on the second serial port
         self.prepare_run(None, kernel, disk,
tests/guest-debug/run-test.py +9 -5
index e74bb489ee1..48a5261618d 100755
@@ -26,8 +26,7 @@ def get_args():
     parser.add_argument("--qargs", help="Qemu arguments for test")
     parser.add_argument("--pargs", help="Program arguments for test")
     parser.add_argument("--kargs", help="Kernel args to --append")
-    parser.add_argument("--binary", help="Binary to debug",
-                        required=True)
+    parser.add_argument("--binary", help="Binary to debug")
     parser.add_argument("--symbols", help="Symbol file for binary to debug")
     parser.add_argument("--test", help="GDB test script")
     parser.add_argument('test_args', nargs='*',
@@ -86,8 +85,10 @@ def format_cmd(cmd):
         qemu_cmd.extend(shlex.split(args.qargs))
 
     if "system" in args.qemu:
-        # for system mode we assume qargs has set-up for binary
-        qemu_cmd.append(args.binary)
+        # for system mode we assume qargs has set-up for binary if
+        # indeed we have set one.
+        if args.binary:
+            qemu_cmd.append(args.binary)
         if not args.no_suspend:
             qemu_cmd.append("-S")
         qemu_cmd.extend(["-gdb", f"unix:path={socket_name},server=on"])
@@ -116,7 +117,10 @@ def format_cmd(cmd):
     inferior = subprocess.Popen(qemu_cmd)
 
     # Now launch gdb with our test and collect the result
-    gdb_cmd = [args.gdb, args.binary]
+    gdb_cmd = [args.gdb]
+
+    if args.binary:
+        gdb_cmd.append(args.binary)
     if args.gdb_args:
         gdb_cmd.extend(shlex.split(args.gdb_args))
 
Signature · 1 line
2.47.3
Reviewed-by on v3 12/19
#25 lore raw

Re: [PATCH v3 12/19] tests/functional: teach tuxrun about launching gdb tests

Quoted 5 lines · Alex Bennée

This resurrects the hand run test script from d84842be6c5 (tests:
remove test-gdbstub.py) and modernises it to use the shared test infrastructure for run-test.

We then tweak the common tuxrun code to over an alternative "launch

offer?

Quoted 38 lines

via gdbstub" helper which reuses the existing code but:

- needs a vmlinux with symbols
- drops kaslr because it doesn't play nice with symbols
- extend qargs with stuff normally added by vm.launch
- passes kargs directly
- runs with the gdb run-test script
- log the run-test output to the console log
- makes --binary not mandatory

Message-ID: <[email protected]>

---
v3
- mention the nokaslr in the commit message
- add a comment about it to the shared kernel args
- drop unused failcount
- remove stale comment about hbreak
- always delete the watch point pass or fail
- fix unbalanced tuple in sh4's direct call of fetch_tuxrun_assets
- simplify the symbol to watchpoint logic
- drop the mandatory --binary
- make the command copy and paste friendly
v2
- add self.vm._machine to qargs
- drop leading spaces in print () calls
- add register read tests
- use gdb.Breakpoint for hwbreak as for swbreak
- drop flaky symbol evaluation, verify hit_count instead
- explicit gdb.BP_BREAKPOINT for CatchBreakpoint

---
  .../functional/gdb-scripts/kernel_gdb_test.py | 162 ++++++++++++++++++
  tests/functional/qemu_test/tuxruntest.py      |  97 ++++++++++-
  tests/functional/sh4/test_tuxrun.py           |   4 +-
  tests/guest-debug/run-test.py                 |  14 +-
  4 files changed, 261 insertions(+), 16 deletions(-)

create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py

[...]

Quoted 13 lines
tests/functional/qemu_test/tuxruntest.py +3 -2
@@ -132,10 +144,77 @@ def common_tuxrun(self,
          special with the command line we can process most things using
          the tag metadata.
          """
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(kernel_asset, rootfs_asset,
-                                                       dtb_asset)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(kernel_asset,
+                                                          rootfs_asset,
+                                                          dtb_asset)
 
          self.prepare_run(accel, kernel, disk, drive, dtb, console_index)
          self.vm.launch()
          self.run_tuxtest_tests(haltmsg)

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 163

Quoted 10 lines
tests/functional/qemu_test/tuxruntest.py +9 -0
          os.remove(disk)
+
+    def common_tuxrun_gdb(self,
+                          kernel_asset,
+                          vmlinux_asset,
+                          rootfs_asset,
+                          accel=None,
+                          dtb_asset=None,
+                          drive="virtio-blk-device",
+                          haltmsg="reboot: System halted",

This argument seems to be unused.

Quoted 28 lines
tests/functional/qemu_test/tuxruntest.py +28 -0
+                          console_index=0):
+        """
+        Common path for LKFT tests under gdb. Unlike the common_tuxrun
+        function we need to launch with the gdb test script and deal
+        with munging the arguments for that especially.
+        """
+        (kernel, disk, dtb, vmlinux) = self.fetch_tuxrun_assets(kernel_asset,
+                                                                rootfs_asset,
+                                                                dtb_asset,
+                                                                vmlinux_asset)
+
+        gdb_path = os.getenv("QEMU_TEST_GDB")
+        run_script = self.data_file('..', 'guest-debug','run-test.py')
+        test_script = self.data_file('gdb-scripts', 'kernel_gdb_test.py')
+
+        # Instead of launching QEMU via the functional test machinery
+        # we need to launch it with the gdb run script. We utilise the
+        # existing prepare_run machinery to build the command line but
+        # we pass the kernel args separately to avoid horrible string
+        # escaping.
+
+        self.prepare_run(accel, kernel, disk, drive, dtb,
+                         console_index, append = False)
+
+        # the functional test machinery adds more stuff for handling
+        # console redirection which we need to do manually.
+
+        qargs = self.vm.args

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 201

Quoted 10 lines
tests/functional/qemu_test/tuxruntest.py +10 -0
+        qargs.extend(["-display", "none", "-serial", "stdio"])
+
+        # and the machine type
+        if self.vm._machine is not None:
+            qargs.extend(["-machine", self.vm._machine])
+
+        cmd = [
+            str(run_script),
+            "--qemu", self.qemu_bin,
+            "--qargs", " ".join(qargs),

I would use shlex.join() here, for symmetry with shlex.split() that is used to handle this.

[...]

Anyhow:

#26 lore raw

Re: [PATCH v3 12/19] tests/functional: teach tuxrun about launching gdb tests

In reply to Alex Bennée
Quoted 43 lines · Alex Bennée

This resurrects the hand run test script from d84842be6c5 (tests:
remove test-gdbstub.py) and modernises it to use the shared test infrastructure for run-test.

We then tweak the common tuxrun code to over an alternative "launch via gdbstub" helper which reuses the existing code but:

- needs a vmlinux with symbols
- drops kaslr because it doesn't play nice with symbols
- extend qargs with stuff normally added by vm.launch
- passes kargs directly
- runs with the gdb run-test script
- log the run-test output to the console log
- makes --binary not mandatory

Message-ID: <[email protected]>

---
v3
- mention the nokaslr in the commit message
- add a comment about it to the shared kernel args
- drop unused failcount
- remove stale comment about hbreak
- always delete the watch point pass or fail
- fix unbalanced tuple in sh4's direct call of fetch_tuxrun_assets
- simplify the symbol to watchpoint logic
- drop the mandatory --binary
- make the command copy and paste friendly
v2
- add self.vm._machine to qargs
- drop leading spaces in print () calls
- add register read tests
- use gdb.Breakpoint for hwbreak as for swbreak
- drop flaky symbol evaluation, verify hit_count instead
- explicit gdb.BP_BREAKPOINT for CatchBreakpoint

---
  .../functional/gdb-scripts/kernel_gdb_test.py | 162 ++++++++++++++++++
  tests/functional/qemu_test/tuxruntest.py      |  97 ++++++++++-
  tests/functional/sh4/test_tuxrun.py           |   4 +-
  tests/guest-debug/run-test.py                 |  14 +-
  4 files changed, 261 insertions(+), 16 deletions(-)

create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py

[...]

Quoted 25 lines
tests/functional/qemu_test/tuxruntest.py +14 -2
@@ -132,10 +144,77 @@ def common_tuxrun(self,
          special with the command line we can process most things using
          the tag metadata.
          """
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(kernel_asset, rootfs_asset,
-                                                       dtb_asset)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(kernel_asset,
+                                                          rootfs_asset,
+                                                          dtb_asset)
 
          self.prepare_run(accel, kernel, disk, drive, dtb, console_index)
          self.vm.launch()
          self.run_tuxtest_tests(haltmsg)
          os.remove(disk)
+
+    def common_tuxrun_gdb(self,
+                          kernel_asset,
+                          vmlinux_asset,
+                          rootfs_asset,
+                          accel=None,
+                          dtb_asset=None,
+                          drive="virtio-blk-device",
+                          haltmsg="reboot: System halted",
+                          console_index=0):
+        """

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 175

Quoted 10 lines
tests/functional/qemu_test/tuxruntest.py +10 -0
+        Common path for LKFT tests under gdb. Unlike the common_tuxrun
+        function we need to launch with the gdb test script and deal
+        with munging the arguments for that especially.
+        """
+        (kernel, disk, dtb, vmlinux) = self.fetch_tuxrun_assets(kernel_asset,
+                                                                rootfs_asset,
+                                                                dtb_asset,
+                                                                vmlinux_asset)
+
+        gdb_path = os.getenv("QEMU_TEST_GDB")

By the way, there is a minor usability issue: if I set QEMU_TEST_GDB to a non-existent binary, the test hangs instead of exiting with an error message.

Quoted 38 lines
tests/functional/qemu_test/tuxruntest.py +38 -0
+        run_script = self.data_file('..', 'guest-debug','run-test.py')
+        test_script = self.data_file('gdb-scripts', 'kernel_gdb_test.py')
+
+        # Instead of launching QEMU via the functional test machinery
+        # we need to launch it with the gdb run script. We utilise the
+        # existing prepare_run machinery to build the command line but
+        # we pass the kernel args separately to avoid horrible string
+        # escaping.
+
+        self.prepare_run(accel, kernel, disk, drive, dtb,
+                         console_index, append = False)
+
+        # the functional test machinery adds more stuff for handling
+        # console redirection which we need to do manually.
+
+        qargs = self.vm.args
+        qargs.extend(["-display", "none", "-serial", "stdio"])
+
+        # and the machine type
+        if self.vm._machine is not None:
+            qargs.extend(["-machine", self.vm._machine])
+
+        cmd = [
+            str(run_script),
+            "--qemu", self.qemu_bin,
+            "--qargs", " ".join(qargs),
+            "--kargs", self.kcmd_line,
+            "--symbols", str(vmlinux),
+            "--test", str(test_script),
+            "--gdb", gdb_path,
+        ]
+
+        log_cmd = " ".join(f'"{arg}"' if ' ' in arg else arg for arg in cmd)
+        self.log.info(f"run-test: {log_cmd}")
+
+        res = subprocess.run(cmd, text=True,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.STDOUT)

[...]

#27 lore raw

Re: [PATCH v3 12/19] tests/functional: teach tuxrun about launching gdb tests

Quoted 74 lines · Ilya Leoshkevich
Quoted 39 lines · Alex Bennée

This resurrects the hand run test script from d84842be6c5 (tests:
remove test-gdbstub.py) and modernises it to use the shared test infrastructure for run-test.
We then tweak the common tuxrun code to over an alternative "launch via gdbstub" helper which reuses the existing code but:
- needs a vmlinux with symbols
- drops kaslr because it doesn't play nice with symbols
- extend qargs with stuff normally added by vm.launch
- passes kargs directly
- runs with the gdb run-test script
- log the run-test output to the console log
- makes --binary not mandatory
Message-ID: <[email protected]>

---
v3
- mention the nokaslr in the commit message
- add a comment about it to the shared kernel args
- drop unused failcount
- remove stale comment about hbreak
- always delete the watch point pass or fail
- fix unbalanced tuple in sh4's direct call of fetch_tuxrun_assets
- simplify the symbol to watchpoint logic
- drop the mandatory --binary
- make the command copy and paste friendly
v2
- add self.vm._machine to qargs
- drop leading spaces in print () calls
- add register read tests
- use gdb.Breakpoint for hwbreak as for swbreak
- drop flaky symbol evaluation, verify hit_count instead
- explicit gdb.BP_BREAKPOINT for CatchBreakpoint

---
  .../functional/gdb-scripts/kernel_gdb_test.py | 162 ++++++++++++++++++
  tests/functional/qemu_test/tuxruntest.py      |  97 ++++++++++-
  tests/functional/sh4/test_tuxrun.py           |   4 +-
  tests/guest-debug/run-test.py                 |  14 +-
  4 files changed, 261 insertions(+), 16 deletions(-)

create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py

[...]

Quoted 31 lines
tests/functional/qemu_test/tuxruntest.py +20 -2
@@ -132,10 +144,77 @@ def common_tuxrun(self,
          special with the command line we can process most things using
          the tag metadata.
          """
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(kernel_asset, rootfs_asset,
-                                                       dtb_asset)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(kernel_asset,
+                                                          rootfs_asset,
+                                                          dtb_asset)
            self.prepare_run(accel, kernel, disk, drive, dtb,
 console_index)
          self.vm.launch()
          self.run_tuxtest_tests(haltmsg)
          os.remove(disk)
+
+    def common_tuxrun_gdb(self,
+                          kernel_asset,
+                          vmlinux_asset,
+                          rootfs_asset,
+                          accel=None,
+                          dtb_asset=None,
+                          drive="virtio-blk-device",
+                          haltmsg="reboot: System halted",
+                          console_index=0):
+        """
+        Common path for LKFT tests under gdb. Unlike the common_tuxrun
+        function we need to launch with the gdb test script and deal
+        with munging the arguments for that especially.
+        """
+        (kernel, disk, dtb, vmlinux) = self.fetch_tuxrun_assets(kernel_asset,
+                                                                rootfs_asset,
Quoted 8 lines

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 175

Quoted 4 lines
tests/functional/qemu_test/tuxruntest.py +4 -0
+                                                                dtb_asset,
+                                                                vmlinux_asset)
+
+        gdb_path = os.getenv("QEMU_TEST_GDB")

By the way, there is a minor usability issue: if I set QEMU_TEST_GDB to a non-existent binary, the test hangs instead of exiting with an error message.

I can add a guard - but in normal invocation meson should take care only to pass the env variable if configure detects gdb.

Quoted 41 lines
Quoted 39 lines
tests/functional/qemu_test/tuxruntest.py +38 -0
+        run_script = self.data_file('..', 'guest-debug','run-test.py')
+        test_script = self.data_file('gdb-scripts', 'kernel_gdb_test.py')
+
+        # Instead of launching QEMU via the functional test machinery
+        # we need to launch it with the gdb run script. We utilise the
+        # existing prepare_run machinery to build the command line but
+        # we pass the kernel args separately to avoid horrible string
+        # escaping.
+
+        self.prepare_run(accel, kernel, disk, drive, dtb,
+                         console_index, append = False)
+
+        # the functional test machinery adds more stuff for handling
+        # console redirection which we need to do manually.
+
+        qargs = self.vm.args
+        qargs.extend(["-display", "none", "-serial", "stdio"])
+
+        # and the machine type
+        if self.vm._machine is not None:
+            qargs.extend(["-machine", self.vm._machine])
+
+        cmd = [
+            str(run_script),
+            "--qemu", self.qemu_bin,
+            "--qargs", " ".join(qargs),
+            "--kargs", self.kcmd_line,
+            "--symbols", str(vmlinux),
+            "--test", str(test_script),
+            "--gdb", gdb_path,
+        ]
+
+        log_cmd = " ".join(f'"{arg}"' if ' ' in arg else arg for arg in cmd)
+        self.log.info(f"run-test: {log_cmd}")
+
+        res = subprocess.run(cmd, text=True,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.STDOUT)

[...]

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#28 lore raw

Re: [PATCH v3 12/19] tests/functional: teach tuxrun about launching gdb tests

Quoted 85 lines · Alex Bennée
Quoted 74 lines · Ilya Leoshkevich
Quoted 39 lines · Alex Bennée

This resurrects the hand run test script from d84842be6c5 (tests:
remove test-gdbstub.py) and modernises it to use the shared test infrastructure for run-test.
We then tweak the common tuxrun code to over an alternative "launch via gdbstub" helper which reuses the existing code but:
- needs a vmlinux with symbols
- drops kaslr because it doesn't play nice with symbols
- extend qargs with stuff normally added by vm.launch
- passes kargs directly
- runs with the gdb run-test script
- log the run-test output to the console log
- makes --binary not mandatory
Message-ID: <[email protected]>

---
v3
- mention the nokaslr in the commit message
- add a comment about it to the shared kernel args
- drop unused failcount
- remove stale comment about hbreak
- always delete the watch point pass or fail
- fix unbalanced tuple in sh4's direct call of fetch_tuxrun_assets
- simplify the symbol to watchpoint logic
- drop the mandatory --binary
- make the command copy and paste friendly
v2
- add self.vm._machine to qargs
- drop leading spaces in print () calls
- add register read tests
- use gdb.Breakpoint for hwbreak as for swbreak
- drop flaky symbol evaluation, verify hit_count instead
- explicit gdb.BP_BREAKPOINT for CatchBreakpoint

---
   .../functional/gdb-scripts/kernel_gdb_test.py | 162 ++++++++++++++++++
   tests/functional/qemu_test/tuxruntest.py      |  97 ++++++++++-
   tests/functional/sh4/test_tuxrun.py           |   4 +-
   tests/guest-debug/run-test.py                 |  14 +-
   4 files changed, 261 insertions(+), 16 deletions(-)

create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py

[...]

Quoted 31 lines
tests/functional/qemu_test/tuxruntest.py +20 -2
@@ -132,10 +144,77 @@ def common_tuxrun(self,
           special with the command line we can process most things using
           the tag metadata.
           """
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(kernel_asset, rootfs_asset,
-                                                       dtb_asset)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(kernel_asset,
+                                                          rootfs_asset,
+                                                          dtb_asset)
             self.prepare_run(accel, kernel, disk, drive, dtb,
 console_index)
           self.vm.launch()
           self.run_tuxtest_tests(haltmsg)
           os.remove(disk)
+
+    def common_tuxrun_gdb(self,
+                          kernel_asset,
+                          vmlinux_asset,
+                          rootfs_asset,
+                          accel=None,
+                          dtb_asset=None,
+                          drive="virtio-blk-device",
+                          haltmsg="reboot: System halted",
+                          console_index=0):
+        """
+        Common path for LKFT tests under gdb. Unlike the common_tuxrun
+        function we need to launch with the gdb test script and deal
+        with munging the arguments for that especially.
+        """
+        (kernel, disk, dtb, vmlinux) = self.fetch_tuxrun_assets(kernel_asset,
+                                                                rootfs_asset,
Quoted 8 lines

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 175

Quoted 4 lines
tests/functional/qemu_test/tuxruntest.py +4 -0
+                                                                dtb_asset,
+                                                                vmlinux_asset)
+
+        gdb_path = os.getenv("QEMU_TEST_GDB")

By the way, there is a minor usability issue: if I set QEMU_TEST_GDB to a non-existent binary, the test hangs instead of exiting with an error message.

Quoted 2 lines

I can add a guard - but in normal invocation meson should take care only to pass the env variable if configure detects gdb.

I haven't debugged this, but I wonder if it would rather be possible to structure the code in a way that does not lead to a hang on GDB failure. I suspect that GDB crashes or GDB script errors may also lead to hangs.

#29 lore raw

Re: [PATCH v3 12/19] tests/functional: teach tuxrun about launching gdb tests

In reply to Alex Bennée
Quoted 293 lines

This resurrects the hand run test script from d84842be6c5 (tests:
remove test-gdbstub.py) and modernises it to use the shared test infrastructure for run-test.

We then tweak the common tuxrun code to over an alternative "launch via gdbstub" helper which reuses the existing code but:

- needs a vmlinux with symbols
- drops kaslr because it doesn't play nice with symbols
- extend qargs with stuff normally added by vm.launch
- passes kargs directly
- runs with the gdb run-test script
- log the run-test output to the console log
- makes --binary not mandatory

Message-ID: <[email protected]>

Message-ID: <[email protected]>
---
v3
- mention the nokaslr in the commit message
- add a comment about it to the shared kernel args
- drop unused failcount
- remove stale comment about hbreak
- always delete the watch point pass or fail
- fix unbalanced tuple in sh4's direct call of fetch_tuxrun_assets
- simplify the symbol to watchpoint logic
- drop the mandatory --binary
- make the command copy and paste friendly
v2
- add self.vm._machine to qargs
- drop leading spaces in print () calls
- add register read tests
- use gdb.Breakpoint for hwbreak as for swbreak
- drop flaky symbol evaluation, verify hit_count instead
- explicit gdb.BP_BREAKPOINT for CatchBreakpoint

---
 .../functional/gdb-scripts/kernel_gdb_test.py | 162 ++++++++++++++++++
 tests/functional/qemu_test/tuxruntest.py      |  97 ++++++++++-
 tests/functional/sh4/test_tuxrun.py           |   4 +-
 tests/guest-debug/run-test.py                 |  14 +-
 4 files changed, 261 insertions(+), 16 deletions(-)
 create mode 100644 tests/functional/gdb-scripts/kernel_gdb_test.py
tests/functional/gdb-scripts/kernel_gdb_test.py new file +162 -0
new file mode 100644
index 000000000000..f457ccdcbf41
@@ -0,0 +1,162 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Generic Kernel GDB script to verify functionality:
+#  - Single-stepping
+#  - Hardware breakpoints
+#  - Software breakpoints
+#  - Watchpoints
+#
+# It relies on fairly common kernel points to break at and symbols for
+# the kernel. Address space randomisation (kaslr) needs to be disabled.
+#
+# Copyright (c) 2026 Linaro Limited
+#
+# Author:
+#  Alex Bennée <[email protected]>
+#
+# This is launched by the tuxrun functional tests via tests/guest-debug/run-test.py
+
+import gdb
+from test_gdbstub import main, report
+
+def parse_registers():
+    """Parse 'info registers' into a name -> value dictionary."""
+    regs = {}
+    for line in gdb.execute("info registers", to_string=True).splitlines():
+        parts = line.split()
+        if len(parts) >= 2:
+            regs[parts[0]] = parts[1]
+    return regs
+
+
+def check_step():
+    "Step an instruction, check it moved."
+    start_pc = gdb.parse_and_eval('$pc')
+    gdb.execute("si")
+    end_pc = gdb.parse_and_eval('$pc')
+
+    return not (start_pc == end_pc)
+
+
+def check_reg_updates(regs_start):
+    regs_end = parse_registers()
+
+    changed = [k for k in regs_start
+               if k in regs_end and regs_start[k] != regs_end[k]]
+
+    report(len(changed) > 0, f"{len(changed)} registers changed.")
+
+
+def check_break(sym_name):
+    "Setup breakpoint, continue and check we stopped."
+    bp = gdb.Breakpoint(sym_name)
+    gdb.execute("c")
+    res = bp.hit_count == 1
+    bp.delete()
+
+    return res
+
+
+def check_hbreak(sym_name):
+    "Setup hardware breakpoint, continue and check we stopped."
+    bp = gdb.Breakpoint(sym_name, type = gdb.BP_HARDWARE_BREAKPOINT)
+    gdb.execute("c")
+    res = bp.hit_count == 1
+    bp.delete()
+
+    return res
+
+
+class WatchPoint(gdb.Breakpoint):
+
+    def __init__(self, sym_name, type):
+        super(WatchPoint, self).__init__(sym_name, gdb.BP_WATCHPOINT, type)
+
+    def stop(self):
+        end_pc = gdb.parse_and_eval('$pc')
+        print("HIT WP @ %s" % (end_pc))
+        return True
+
+
+def do_one_watch(sym, wtype, text):
+
+    wp = WatchPoint(sym, wtype)
+    gdb.execute("c")
+    report_str = "%s for %s" % (text, sym)
+
+    if wp.hit_count > 0:
+        report(True, report_str)
+    else:
+        report(False, report_str)
+
+    wp.delete()
+
+
+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")
+
+    # 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")
+
+
+class CatchBreakpoint(gdb.Breakpoint):
+    def __init__(self, sym_name):
+        super(CatchBreakpoint, self).__init__(sym_name, type = gdb.BP_BREAKPOINT)
+        self.sym, ok = gdb.lookup_symbol(sym_name)
+
+    def stop(self):
+        end_pc = gdb.parse_and_eval('$pc')
+        print("CB: %s == %s" % (end_pc, self.sym.value()))
+        if end_pc == self.sym.value():
+            report(False, "Hit final catchpoint")
+
+
+def run_test():
+    "Run through the tests one by one"
+
+    # get the initial register state
+    regs_start = parse_registers()
+
+    print("Checking we can step the first few instructions")
+    step_ok = 0
+    for i in range(3):
+        if check_step():
+            step_ok += 1
+
+    report(step_ok == 3, "single step in boot code")
+
+    # check some registers changed
+    print("Checking register access works")
+    check_reg_updates(regs_start)
+
+    print("Checking HW breakpoint works")
+    break_ok = check_hbreak("kernel_init")
+    report(break_ok, "hbreak @ kernel_init")
+
+    # Can't set this up until we are in the kernel proper
+    # if we make it to run_init_process we've over-run and
+    # one of the tests failed
+
+    print("Setup catch-all for run_init_process")
+    cbp = CatchBreakpoint("run_init_process")
+
+    # We should see wait_for_completion called right at the start of
+    # kernel_init
+    print("Checking Normal breakpoint works")
+    break_ok = check_break("wait_for_completion")
+    report(break_ok, "break @ wait_for_completion")
+
+    print("Checking watchpoint works")
+    check_watches("system_state")
+
+    # check we didn't hit the end
+    report(cbp.hit_count == 0, "CatchBreakpoint not hit")
+
+
+main(run_test)
tests/functional/qemu_test/tuxruntest.py +22 -9
index ca1589fea37d..6ad421e897d4 100644
@@ -9,7 +9,9 @@
 #
 # SPDX-License-Identifier: GPL-2.0-or-later
 
+import logging
 import os
+import subprocess
 
 from qemu_test import QemuSystemTest
 from qemu_test import exec_command_and_wait_for_pattern
@@ -18,7 +20,8 @@
 
 class TuxRunBaselineTest(QemuSystemTest):
 
-    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0'
+    # nokaslr is needed for gdb tests but it makes things simpler anyway
+    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 nokaslr'
     # Tests are ~10-40s, allow for --debug/--enable-gcov overhead
     timeout = 100
 
@@ -55,17 +58,20 @@ def wait_for_console_pattern(self, success_message, vm=None):
                                  failure_message='Kernel panic - not syncing',
                                  vm=vm)
 
-    def fetch_tuxrun_assets(self, kernel_asset, rootfs_asset, dtb_asset=None):
+    def fetch_tuxrun_assets(self, kernel_asset, rootfs_asset,
+                            dtb_asset=None, vmlinux_asset=None):
         """
         Fetch the TuxBoot assets.
         """
         kernel_image =  kernel_asset.fetch()
         disk_image = self.uncompress(rootfs_asset)
         dtb = dtb_asset.fetch() if dtb_asset is not None else None
+        vmlinux = self.uncompress(vmlinux_asset) if vmlinux_asset is not None else None
 
-        return (kernel_image, disk_image, dtb)
+        return (kernel_image, disk_image, dtb, vmlinux)
 
-    def prepare_run(self, accel, kernel, disk, drive, dtb=None, console_index=0):
+    def prepare_run(self, accel, kernel, disk, drive,
+                    dtb=None, console_index=0, append = True):
         """
         Setup to run and add the common parameters to the system
         """
@@ -83,9 +89,15 @@ def prepare_run(self, accel, kernel, disk, drive, dtb=None, console_index=0):
         if accel:
             self.vm.add_args('-accel', accel)
 
-        self.vm.add_args('-kernel', kernel,
-                         '-append', self.kcmd_line,
-                         '-blockdev', blockdev)
+        if kernel:
+            self.vm.add_args('-kernel', kernel)
+
+        # When using the gdb run script we might not want to include
+        # the kcmd line directly in the QEMU args.
+        if append:
+            self.vm.add_args('-append', self.kcmd_line)
+
+        self.vm.add_args('-blockdev', blockdev)
 
         # Sometimes we need extra devices attached
         if self.extradev:
@@ -132,10 +144,77 @@ def common_tuxrun(self,
         special with the command line we can process most things using
         the tag metadata.
         """
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(kernel_asset, rootfs_asset,
-                                                       dtb_asset)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(kernel_asset,
+                                                          rootfs_asset,
+                                                          dtb_asset)
 
         self.prepare_run(accel, kernel, disk, drive, dtb, console_index)
         self.vm.launch()
         self.run_tuxtest_tests(haltmsg)

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 163

Quoted 10 lines
tests/functional/qemu_test/tuxruntest.py +9 -0
         os.remove(disk)
+
+    def common_tuxrun_gdb(self,
+                          kernel_asset,
+                          vmlinux_asset,
+                          rootfs_asset,
+                          accel=None,
+                          dtb_asset=None,
+                          drive="virtio-blk-device",
+                          haltmsg="reboot: System halted",

haltmsg is unused, drop it?

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 175

Quoted 12 lines
tests/functional/qemu_test/tuxruntest.py +12 -0
+                          console_index=0):
+        """
+        Common path for LKFT tests under gdb. Unlike the common_tuxrun
+        function we need to launch with the gdb test script and deal
+        with munging the arguments for that especially.
+        """
+        (kernel, disk, dtb, vmlinux) = self.fetch_tuxrun_assets(kernel_asset,
+                                                                rootfs_asset,
+                                                                dtb_asset,
+                                                                vmlinux_asset)
+
+        gdb_path = os.getenv("QEMU_TEST_GDB")

perhaps assert gdb_path is set (or raise SkipTest)?

Quoted 16 lines
tests/functional/qemu_test/tuxruntest.py +16 -0
+        run_script = self.data_file('..', 'guest-debug','run-test.py')
+        test_script = self.data_file('gdb-scripts', 'kernel_gdb_test.py')
+
+        # Instead of launching QEMU via the functional test machinery
+        # we need to launch it with the gdb run script. We utilise the
+        # existing prepare_run machinery to build the command line but
+        # we pass the kernel args separately to avoid horrible string
+        # escaping.
+
+        self.prepare_run(accel, kernel, disk, drive, dtb,
+                         console_index, append = False)
+
+        # the functional test machinery adds more stuff for handling
+        # console redirection which we need to do manually.
+
+        qargs = self.vm.args

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 201

Quoted 10 lines
tests/functional/qemu_test/tuxruntest.py +10 -0
+        qargs.extend(["-display", "none", "-serial", "stdio"])
+
+        # and the machine type
+        if self.vm._machine is not None:
+            qargs.extend(["-machine", self.vm._machine])
+
+        cmd = [
+            str(run_script),
+            "--qemu", self.qemu_bin,
+            "--qargs", " ".join(qargs),

use shlex.join(qargs)

Quoted 8 lines
tests/functional/qemu_test/tuxruntest.py +8 -0
+            "--kargs", self.kcmd_line,
+            "--symbols", str(vmlinux),
+            "--test", str(test_script),
+            "--gdb", gdb_path,
+        ]
+
+        log_cmd = " ".join(f'"{arg}"' if ' ' in arg else arg for arg in cmd)
+        self.log.info(f"run-test: {log_cmd}")

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 219

Quoted 10 lines
tests/functional/qemu_test/tuxruntest.py +10 -0
+
+        res = subprocess.run(cmd, text=True,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.STDOUT)
+
+        if res.stdout:
+            console_logger = logging.getLogger('console')
+            console_logger.info(res.stdout)
+
+        self.assertEqual(res.returncode, 0,

Include res.stdout in the assertion message (or call self.fail with it) so the GDB/QEMU transcript is visible when this fails in CI?

tests/functional/qemu_test/tuxruntest.py def common_tuxrun(self, · line 220

Quoted 1 line
tests/functional/qemu_test/tuxruntest.py +1 -0
+                         f"run-test.py failed ({res.returncode}):\n")

Unlike common_tuxrun(), this helper never removes the decompressed rootfs image. Add os.remove(disk) after the run?

Quoted 20 lines
tests/functional/sh4/test_tuxrun.py +2 -2
index 42b503585b2d..07c7ee6e03ba 100755
@@ -31,8 +31,8 @@ def test_sh4(self):
 
         # The test is currently too unstable to do much in userspace
         # so we skip common_tuxrun and do a minimal boot and shutdown.
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(self.ASSET_SH4_KERNEL,
-                                                       self.ASSET_SH4_ROOTFS)
+        (kernel, disk, dtb, _) = self.fetch_tuxrun_assets(self.ASSET_SH4_KERNEL,
+                                                          self.ASSET_SH4_ROOTFS)
 
         # the console comes on the second serial port
         self.prepare_run(None, kernel, disk,
tests/guest-debug/run-test.py +0 -0
index e74bb489ee19..48a5261618de 100755

tests/guest-debug/run-test.py def get_args(): · line 29

Quoted 6 lines
tests/guest-debug/run-test.py +1 -2
@@ -26,8 +26,7 @@ def get_args():
     parser.add_argument("--qargs", help="Qemu arguments for test")
     parser.add_argument("--pargs", help="Program arguments for test")
     parser.add_argument("--kargs", help="Kernel args to --append")
-    parser.add_argument("--binary", help="Binary to debug",
-                        required=True)
+    parser.add_argument("--binary", help="Binary to debug")

Now that --binary is optional, the user-mode branch below still does qemu_cmd.append(args.binary) unconditionally. If --binary is omitted for a non-system QEMU, subprocess.Popen() will get None and raise TypeError. assert args.binary in the user-mode branch?

Signature · 1 line
Marc-André Lureau <[email protected]>
#30 lore raw

PATCH v3 13/19 tests/functional: add tuxrun kvm gdb test for x86_64

In reply to Alex Bennée

With all the bits in place we can now exercise the KVM gdb interfaces.

Message-ID: <[email protected]>

---
 tests/functional/x86_64/test_tuxrun.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
tests/functional/x86_64/test_tuxrun.py +19 -1
index 026b373accb..1a1138d16ae 100755
@@ -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 TuxRunX86Test(TuxRunBaselineTest):
@@ -19,6 +19,9 @@ class TuxRunX86Test(TuxRunBaselineTest):
     ASSET_X86_64_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/x86_64/bzImage',
         '24a3ade610c2cc426ff821050de8a35930b0371357d94cc2c334abac6658552b')
+    ASSET_X86_64_VMLINUX = Asset(
+        'https://storage.tuxboot.com/kernels/6.18.54/x86_64/vmlinux.xz',
+        '77bf44cca48c9c1b9c142e16a2311d58b8ae3462b61bce44bcaf9243b5f26628')
     ASSET_X86_64_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/x86_64/rootfs.ext4.zst',
         '8e310455b0244414ccff29c507f7ccfd4032e3587cc405e49ab0322738e3e27c')
@@ -47,5 +50,20 @@ def test_x86_64_kvm(self):
                            drive="driver=ide-hd,bus=ide.0,unit=0",
                            accel="kvm")
 
+    @skipIfMissingEnv("QEMU_TEST_GDB")
+    def test_x86_64_kvm_gdb(self):
+        self.require_accelerator("kvm")
+
+        self.set_machine('q35')
+        self.cpu="Nehalem"
+        self.root='sda'
+        self.wait_for_shutdown=False
+        self.common_tuxrun_gdb(kernel_asset=self.ASSET_X86_64_KERNEL,
+                               vmlinux_asset=self.ASSET_X86_64_VMLINUX,
+                               rootfs_asset=self.ASSET_X86_64_ROOTFS,
+                               drive="driver=ide-hd,bus=ide.0,unit=0",
+                               accel="kvm")
+
+
 if __name__ == '__main__':
     TuxRunBaselineTest.main()
Signature · 1 line
2.47.3
#31 lore raw

PATCH v3 14/19 tests/functional: split aarch64 tuxrun into tcg and kvm run

In reply to Alex Bennée

Add an explicit "kvm" run to the tuxrun tests. Although running on an aarch64 host would probably have defaulted to "kvm" anyway we want to exercise specific features later.

Message-ID: <[email protected]>

---
v2
- pass "host" cpu type for KVM run

---
 tests/functional/aarch64/test_tuxrun.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
tests/functional/aarch64/test_tuxrun.py +10 -0
index 7dd50c3de17..0ef1b126fae 100755
@@ -32,6 +32,16 @@ def test_arm64(self):
         self.common_tuxrun(kernel_asset=self.ASSET_ARM64_KERNEL,
                            rootfs_asset=self.ASSET_ARM64_ROOTFS)
 
+    def test_arm64_kvm(self):
+        self.set_machine('virt')
+        self.require_accelerator('kvm')
+        self.cpu='host'
+        self.console='ttyAMA0'
+        self.wait_for_shutdown=False
+        self.common_tuxrun(kernel_asset=self.ASSET_ARM64_KERNEL,
+                           rootfs_asset=self.ASSET_ARM64_ROOTFS,
+                           accel="kvm")
+
     ASSET_ARM64BE_KERNEL = Asset(
         'https://storage.tuxboot.com/buildroot/20241119/arm64be/Image',
         'fd6af4f16689d17a2c24fe0053cc212edcdf77abdcaf301800b8d38fa9f6e109')
Signature · 1 line
2.47.3
#32 lore raw

PATCH v3 15/19 tests/functional: update arm64 tuxrun images

In reply to Alex Bennée

We now fetch the kernel from a different location to the buildroot image itself. This is because we will want to access additional kernel metadata in future tests.

---
v3
- reword commit to make it clearer

---
 tests/functional/aarch64/test_tuxrun.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/functional/aarch64/test_tuxrun.py +4 -4
index 0ef1b126fae..6de02e1d8b2 100755
@@ -17,11 +17,11 @@
 class TuxRunAarch64Test(TuxRunBaselineTest):
 
     ASSET_ARM64_KERNEL = Asset(
-        'https://storage.tuxboot.com/buildroot/20241119/arm64/Image',
-        'b74743c5e89e1cea0f73368d24ae0ae85c5204ff84be3b5e9610417417d2f235')
+        'https://storage.tuxboot.com/kernels/6.18.54/arm64/Image.gz',
+        '39f4633bbcb444267d4d829bd28d8868a287c4c160cda64b0fd23fb090571c4e')
     ASSET_ARM64_ROOTFS = Asset(
-        'https://storage.tuxboot.com/buildroot/20241119/arm64/rootfs.ext4.zst',
-        'a1acaaae2068df4648d04ff75f532aaa8c5edcd6b936122b6f0db4848a07b465')
+        'https://storage.tuxboot.com/buildroot/20260924/arm64/rootfs.ext4.zst',
+        '4ab8cec9d1e17dbb1abdf2ae1939ad4f9d0dc2466230f6a119a7c1845cdef0b1')
 
     def test_arm64(self):
         self.set_machine('virt')
Signature · 1 line
2.47.3
#33 lore raw

PATCH v3 16/19 tests/functional: add tuxrun kvm gdb test for arm64

In reply to Alex Bennée

As with x86_64 we now have the bits to add a KVM gdb test

---
 tests/functional/aarch64/test_tuxrun.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
tests/functional/aarch64/test_tuxrun.py +16 -1
index 6de02e1d8b2..2ff321582d3 100755
@@ -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 TuxRunAarch64Test(TuxRunBaselineTest):
@@ -19,6 +19,9 @@ class TuxRunAarch64Test(TuxRunBaselineTest):
     ASSET_ARM64_KERNEL = Asset(
         'https://storage.tuxboot.com/kernels/6.18.54/arm64/Image.gz',
         '39f4633bbcb444267d4d829bd28d8868a287c4c160cda64b0fd23fb090571c4e')
+    ASSET_ARM64_VMLINUX = Asset(
+        'https://storage.tuxboot.com/kernels/6.18.54/arm64/vmlinux.xz',
+        '6487eb113ef6e841aedab6cb6fa704006377d68f64dd544570aa42f462a52b85')
     ASSET_ARM64_ROOTFS = Asset(
         'https://storage.tuxboot.com/buildroot/20260924/arm64/rootfs.ext4.zst',
         '4ab8cec9d1e17dbb1abdf2ae1939ad4f9d0dc2466230f6a119a7c1845cdef0b1')
@@ -42,6 +45,18 @@ def test_arm64_kvm(self):
                            rootfs_asset=self.ASSET_ARM64_ROOTFS,
                            accel="kvm")
 
+    @skipIfMissingEnv("QEMU_TEST_GDB")
+    def test_arm64_kvm_gdb(self):
+        self.set_machine('virt')
+        self.require_accelerator('kvm')
+        self.cpu='host'
+        self.console='ttyAMA0'
+        self.wait_for_shutdown=False
+        self.common_tuxrun_gdb(kernel_asset=self.ASSET_ARM64_KERNEL,
+                               vmlinux_asset=self.ASSET_ARM64_VMLINUX,
+                               rootfs_asset=self.ASSET_ARM64_ROOTFS,
+                               accel="kvm")
+
     ASSET_ARM64BE_KERNEL = Asset(
         'https://storage.tuxboot.com/buildroot/20241119/arm64be/Image',
         'fd6af4f16689d17a2c24fe0053cc212edcdf77abdcaf301800b8d38fa9f6e109')
Signature · 1 line
2.47.3
#34 lore raw

PATCH v3 17/19 tests/functional: split s390x tuxrun into tcg and kvm run

In reply to Alex Bennée

Add an explicit "kvm" run to the tuxrun tests. Although running on an s390x host would probably have defaulted to "kvm" anyway we want to exercise specific features later.

---
 tests/functional/s390x/test_tuxrun.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
tests/functional/s390x/test_tuxrun.py +11 -0
index 8df3c6893b7..086466af81f 100755
@@ -25,11 +25,22 @@ class TuxRunS390xTest(TuxRunBaselineTest):
 
     def test_s390(self):
         self.set_machine('s390-ccw-virtio')
+        self.require_accelerator('tcg')
         self.wait_for_shutdown=False
         self.common_tuxrun(kernel_asset=self.ASSET_S390X_KERNEL,
                            rootfs_asset=self.ASSET_S390X_ROOTFS,
                            drive="virtio-blk-ccw",
                            haltmsg="Requesting system halt")
 
+    def test_s390_kvm(self):
+        self.set_machine('s390-ccw-virtio')
+        self.require_accelerator('kvm')
+        self.wait_for_shutdown=False
+        self.common_tuxrun(kernel_asset=self.ASSET_S390X_KERNEL,
+                           rootfs_asset=self.ASSET_S390X_ROOTFS,
+                           drive="virtio-blk-ccw",
+                           haltmsg="Requesting system halt",
+                           accel="kvm")
+
 if __name__ == '__main__':
     TuxRunBaselineTest.main()
Signature · 1 line
2.47.3
#35 lore raw

PATCH v3 18/19 tests/functional: update s390x tuxrun images

In reply to Alex Bennée

We now fetch the kernel from a different location to the buildroot image itself. This is because we will want to access additional kernel metadata in future tests.

---
v3
- rewrote commit message for clarity

---
 tests/functional/s390x/test_tuxrun.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/functional/s390x/test_tuxrun.py +4 -4
index 086466af81f..8e0261e2b7f 100755
@@ -17,11 +17,11 @@
 class TuxRunS390xTest(TuxRunBaselineTest):
 
     ASSET_S390X_KERNEL = Asset(
-        'https://storage.tuxboot.com/buildroot/20241119/s390/bzImage',
-        'ee67e91db52a2aed104a7c72b2a08987c678f8179c029626789c35d6dd0fedf1')
+        'https://storage.tuxboot.com/kernels/6.18.54/s390/bzImage',
+        '5efeb31754b211440e1595ab11355bb006fe78a2c0604ed0a8c55c4598b71aec')
     ASSET_S390X_ROOTFS = Asset(
-        'https://storage.tuxboot.com/buildroot/20241119/s390/rootfs.ext4.zst',
-        'bff7971fc2fef56372d98afe4557b82fd0a785a241e44c29b058e577ad1bbb44')
+        'https://storage.tuxboot.com/buildroot/20260924/s390/rootfs.ext4.zst',
+        '5ba18c4d18831c50a0c743990f7bdee1d3b520629d423c55b668d8fbbac9c6f5')
 
     def test_s390(self):
         self.set_machine('s390-ccw-virtio')
Signature · 1 line
2.47.3
#36 lore raw

PATCH v3 19/19 tests/functional: add tuxrun kvm gdb test for s390x

In reply to Alex Bennée

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.

---
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(-)
tests/functional/gdb-scripts/kernel_gdb_test.py +6 -4
index f457ccdcbf4..975faf3d284 100644
@@ -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")
tests/functional/qemu_test/tuxruntest.py +4 -0
index 6ad421e897d..c43a0b0e499 100644
@@ -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}")
 
tests/functional/s390x/test_tuxrun.py +17 -1
index 8e0261e2b7f..3821f985196 100755
@@ -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()
tests/guest-debug/run-test.py +6 -1
index 48a5261618d..0b93aae62c6 100755
@@ -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:
tests/lcitool/libvirt-ci +1 -1
index f34cd57eb89..5176e136ab1 160000
@@ -1 +1 @@
-Subproject commit f34cd57eb892259c26600187bc35cc4152f932cf
+Subproject commit 5176e136ab11e275eb9f57c3d5c80e77af6507cb
Signature · 1 line
2.47.3
Reviewed-by on v3 19/19
#37 lore raw

Re: [PATCH v3 19/19] tests/functional: add tuxrun kvm gdb test for s390x

Quoted 18 lines · Alex Bennée

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.

---
v3
- add symbol-offset handling
- limit the watchpoint tests
- add skipIfMissingEnv("QEMU_TEST_GDB") decorator

Quoted 6 lines
---
  .../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 +-

Did you intend to bump this submodule here?

Otherwise: this now works and LGTM.

[...]

#38 lore raw

Re: [PATCH v3 19/19] tests/functional: add tuxrun kvm gdb test for s390x

Quoted 23 lines · Ilya Leoshkevich
Quoted 15 lines · Alex Bennée

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.

---
v3
- add symbol-offset handling
- limit the watchpoint tests
- add skipIfMissingEnv("QEMU_TEST_GDB") decorator

Quoted 6 lines
---
  .../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 +-
Quoted 1 line

Did you intend to bump this submodule here?

oops - no. I've never figured out the git foo needed to reset submodules automatically on checkout. If you jump branches a lot its invariably out of date.

Will fix.

Quoted 5 lines

Otherwise: this now works and LGTM.

[...]

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#39 lore raw

Re: [PATCH v3 19/19] tests/functional: add tuxrun kvm gdb test for s390x

In reply to Alex Bennée

Am 19.10.26 um 21:27 schrieb Alex Bennée:

Quoted 6 lines

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.

Quoted 6 lines

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.

Hi Alex,

on an s390x KVM host, test_s390_kvm_gdb fails on current master before gdb is even started:

Traceback (most recent call last):
File "/root/REPOS/qemu/tests/functional/s390x/test_tuxrun.py", line 53, in test_s390_kvm_gdb

    self.common_tuxrun_gdb(kernel_asset=self.ASSET_S390X_KERNEL,
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           vmlinux_asset=self.ASSET_S390X_VMLINUX,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
                           haltmsg="Requesting system halt",
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           accel="kvm")
                           ^^^^^^^^^^^^

TypeError: TuxRunBaselineTest.common_tuxrun_gdb() got an unexpected keyword argument 'haltmsg'

not ok 3 test_tuxrun.TuxRunS390xTest.test_s390_kvm_gdb

haltmsg was removed after review, but not from this patch.

In any case, zhank you for enabling s390 gdb testing,

#40 lore raw

Re: [PATCH v3 19/19] tests/functional: add tuxrun kvm gdb test for s390x

Quoted 29 lines · Christian Borntraeger

Am 19.10.26 um 21:27 schrieb Alex Bennée:

Quoted 10 lines

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.

Hi Alex,

on an s390x KVM host, test_s390_kvm_gdb fails on current master before gdb is even started:

Traceback (most recent call last):
File "/root/REPOS/qemu/tests/functional/s390x/test_tuxrun.py", line 53, in test_s390_kvm_gdb

    self.common_tuxrun_gdb(kernel_asset=self.ASSET_S390X_KERNEL,
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           vmlinux_asset=self.ASSET_S390X_VMLINUX,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
                           haltmsg="Requesting system halt",
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           accel="kvm")
                           ^^^^^^^^^^^^
Quoted 5 lines

TypeError: TuxRunBaselineTest.common_tuxrun_gdb() got an unexpected keyword argument 'haltmsg'

not ok 3 test_tuxrun.TuxRunS390xTest.test_s390_kvm_gdb

haltmsg was removed after review, but not from this patch.

doh will fix.

Quoted 4 lines

In any case, zhank you for enabling s390 gdb testing,

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro