diff mbox series

[4/9] tests: remove test-gdbstub.py

Message ID 20230815145126.3444183-5-alex.bennee@linaro.org
State Superseded
Headers show
Series gdbstub and testing fixes for 8.2 | expand

Commit Message

Alex Bennée Aug. 15, 2023, 2:51 p.m. UTC
This isn't directly called by our CI and because it doesn't run via
our run-test.py script does things slightly differently. Lets remove
it as we have plenty of working in-tree tests now for various aspects
of gdbstub.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/guest-debug/test-gdbstub.py | 177 ------------------------------
 1 file changed, 177 deletions(-)
 delete mode 100644 tests/guest-debug/test-gdbstub.py

Comments

Ilya Leoshkevich Aug. 16, 2023, 10:20 a.m. UTC | #1
On Tue, 2023-08-15 at 15:51 +0100, Alex Bennée wrote:
> This isn't directly called by our CI and because it doesn't run via
> our run-test.py script does things slightly differently. Lets remove
> it as we have plenty of working in-tree tests now for various aspects
> of gdbstub.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/guest-debug/test-gdbstub.py | 177 ----------------------------
> --
>  1 file changed, 177 deletions(-)
>  delete mode 100644 tests/guest-debug/test-gdbstub.py

There doesn't seem to be a hbreak test elsewhere, but according to a
comment in tcg/multiarch/gdbstub/memory.py it would be mapped to a
normal break anyway.

Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Alex Bennée Aug. 16, 2023, 12:33 p.m. UTC | #2
Ilya Leoshkevich <iii@linux.ibm.com> writes:

> On Tue, 2023-08-15 at 15:51 +0100, Alex Bennée wrote:
>> This isn't directly called by our CI and because it doesn't run via
>> our run-test.py script does things slightly differently. Lets remove
>> it as we have plenty of working in-tree tests now for various aspects
>> of gdbstub.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/guest-debug/test-gdbstub.py | 177 ----------------------------
>> --
>>  1 file changed, 177 deletions(-)
>>  delete mode 100644 tests/guest-debug/test-gdbstub.py
>
> There doesn't seem to be a hbreak test elsewhere, but according to a
> comment in tcg/multiarch/gdbstub/memory.py it would be mapped to a
> normal break anyway.

It is for TCG but for other accelerators there will be different
handling (although I'm fairly sure only x86 and aarch64 are currently
plumbed to use the CPUs hbreak bits on KVM).

However this particular script was a very early addition when I was
testing stuff manually with images I'd built on my system. If we want to
exercise the gdbstub for accelerators it might be better porting the
test to avocado?

>
> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich Aug. 16, 2023, 1:52 p.m. UTC | #3
On Wed, 2023-08-16 at 13:33 +0100, Alex Bennée wrote:
> 
> Ilya Leoshkevich <iii@linux.ibm.com> writes:
> 
> > On Tue, 2023-08-15 at 15:51 +0100, Alex Bennée wrote:
> > > This isn't directly called by our CI and because it doesn't run
> > > via
> > > our run-test.py script does things slightly differently. Lets
> > > remove
> > > it as we have plenty of working in-tree tests now for various
> > > aspects
> > > of gdbstub.
> > > 
> > > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> > > ---
> > >  tests/guest-debug/test-gdbstub.py | 177 ------------------------
> > > ----
> > > --
> > >  1 file changed, 177 deletions(-)
> > >  delete mode 100644 tests/guest-debug/test-gdbstub.py
> > 
> > There doesn't seem to be a hbreak test elsewhere, but according to
> > a
> > comment in tcg/multiarch/gdbstub/memory.py it would be mapped to a
> > normal break anyway.
> 
> It is for TCG but for other accelerators there will be different
> handling (although I'm fairly sure only x86 and aarch64 are currently
> plumbed to use the CPUs hbreak bits on KVM).
> 
> However this particular script was a very early addition when I was
> testing stuff manually with images I'd built on my system. If we want
> to
> exercise the gdbstub for accelerators it might be better porting the
> test to avocado?

That would be good, yes.

I was always wondering if the TCG sotfmmu tests could be used to test
the other accelerators? At least for s390x there is nothing
TCG-specific there (besides that they try to trigger TCG-specific
problems), and I sometimes run them manually with KVM as a sanity
check.

> 
> > 
> > Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
> 
>
diff mbox series

Patch

diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py
deleted file mode 100644
index 98a5df4d42..0000000000
--- a/tests/guest-debug/test-gdbstub.py
+++ /dev/null
@@ -1,177 +0,0 @@ 
-#
-# This script needs to be run on startup
-# qemu -kernel ${KERNEL} -s -S
-# and then:
-# gdb ${KERNEL}.vmlinux -x ${QEMU_SRC}/tests/guest-debug/test-gdbstub.py
-
-import gdb
-
-failcount = 0
-
-
-def report(cond, msg):
-    "Report success/fail of test"
-    if cond:
-        print ("PASS: %s" % (msg))
-    else:
-        print ("FAIL: %s" % (msg))
-        global failcount
-        failcount += 1
-
-
-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_break(sym_name):
-    "Setup breakpoint, continue and check we stopped."
-    sym, ok = gdb.lookup_symbol(sym_name)
-    bp = gdb.Breakpoint(sym_name)
-
-    gdb.execute("c")
-
-    # hopefully we came back
-    end_pc = gdb.parse_and_eval('$pc')
-    print ("%s == %s %d" % (end_pc, sym.value(), bp.hit_count))
-    bp.delete()
-
-    # can we test we hit bp?
-    return end_pc == sym.value()
-
-
-# We need to do hbreak manually as the python interface doesn't export it
-def check_hbreak(sym_name):
-    "Setup hardware breakpoint, continue and check we stopped."
-    sym, ok = gdb.lookup_symbol(sym_name)
-    gdb.execute("hbreak %s" % (sym_name))
-    gdb.execute("c")
-
-    # hopefully we came back
-    end_pc = gdb.parse_and_eval('$pc')
-    print ("%s == %s" % (end_pc, sym.value()))
-
-    if end_pc == sym.value():
-        gdb.execute("d 1")
-        return True
-    else:
-        return False
-
-
-class WatchPoint(gdb.Breakpoint):
-
-    def get_wpstr(self, sym_name):
-        "Setup sym and wp_str for given symbol."
-        self.sym, ok = gdb.lookup_symbol(sym_name)
-        wp_addr = gdb.parse_and_eval(sym_name).address
-        self.wp_str = '*(%(type)s)(&%(address)s)' % dict(
-            type = wp_addr.type, address = sym_name)
-
-        return(self.wp_str)
-
-    def __init__(self, sym_name, type):
-        wp_str = self.get_wpstr(sym_name)
-        super(WatchPoint, self).__init__(wp_str, 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 (%s)" % (text, sym, wp.sym.value())
-
-    if wp.hit_count > 0:
-        report(True, report_str)
-        wp.delete()
-    else:
-        report(False, report_str)
-
-
-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)
-        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"
-
-    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")
-
-    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")
-    cpb2 = CatchBreakpoint("try_to_run_init_process")
-
-    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")
-
-#
-# This runs as the script it sourced (via -x)
-#
-
-try:
-    print ("Connecting to remote")
-    gdb.execute("target remote localhost:1234")
-
-    # These are not very useful in scripts
-    gdb.execute("set pagination off")
-    gdb.execute("set confirm off")
-
-    # Run the actual tests
-    run_test()
-
-except:
-    print ("GDB Exception: %s" % (sys.exc_info()[0]))
-    failcount += 1
-    import code
-    code.InteractiveConsole(locals=globals()).interact()
-    raise
-
-# Finally kill the inferior and exit gdb with a count of failures
-gdb.execute("kill")
-exit(failcount)