]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/tcg/multiarch/gdbstub/interrupt.py
1 from __future__
import print_function
3 # Test some of the system debug features with the multiarch memory
4 # test. It is a port of the original vmlinux focused test case but
5 # using the "memory" test instead.
7 # This is launched via tests/guest-debug/run-test.py
16 def report(cond
, msg
):
17 "Report success/fail of test"
19 print("PASS: %s" % (msg
))
21 print("FAIL: %s" % (msg
))
26 def check_interrupt(thread
):
28 Check that, if thread is resumed, we go back to the same thread when the
29 program gets interrupted.
32 # Switch to the thread we're going to be running the test in.
33 print("thread ", thread
.num
)
34 gdb
.execute("thr %d" % thread
.num
)
36 # Enter the loop() function on this thread.
38 # While there are cleaner ways to do this, we want to minimize the number of
39 # side effects on the gdbstub's internal state, since those may mask bugs.
40 # Ideally, there should be no difference between what we're doing here and
41 # the program reaching the loop() function on its own.
43 # For this to be safe, we only need the prologue of loop() to not have
44 # instructions that may have problems with what we're doing here. We don't
45 # have to worry about anything else, as this function never returns.
46 gdb
.execute("set $pc = loop")
48 # Continue and then interrupt the task.
49 gdb
.post_event(lambda: gdb
.execute("interrupt"))
52 # Check whether the thread we're in after the interruption is the same we
54 return (thread
.num
== gdb
.selected_thread().num
)
59 Test if interrupting the code always lands us on the same thread when
60 running with scheduler-lock enabled.
63 gdb
.execute("set scheduler-locking on")
64 for thread
in gdb
.selected_inferior().threads():
65 report(check_interrupt(thread
),
66 "thread %d resumes correctly on interrupt" % thread
.num
)
70 # This runs as the script it sourced (via -x, via run-test.py)
73 inferior
= gdb
.selected_inferior()
74 arch
= inferior
.architecture()
75 print("ATTACHED: %s" % arch
.name())
76 except (gdb
.error
, AttributeError):
77 print("SKIPPING (not connected)", file=sys
.stderr
)
80 if gdb
.parse_and_eval('$pc') == 0:
81 print("SKIP: PC not set")
83 if len(gdb
.selected_inferior().threads()) == 1:
84 print("SKIP: set to run on a single thread")
88 # Run the actual tests
91 print("GDB Exception: %s" % (sys
.exc_info()[0]))
95 # Finally kill the inferior and exit gdb with a count of failures