]> git.proxmox.com Git - mirror_qemu.git/blob - tests/tcg/s390x/gdbstub/test-signals-s390x.py
ca2bbc0b03e6ad72de3c31c51b4a5c7adbb0a8b3
[mirror_qemu.git] / tests / tcg / s390x / gdbstub / test-signals-s390x.py
1 from __future__ import print_function
2
3 #
4 # Test that signals and debugging mix well together on s390x.
5 #
6 # This is launched via tests/guest-debug/run-test.py
7 #
8
9 import gdb
10 import sys
11
12 failcount = 0
13
14
15 def report(cond, msg):
16 """Report success/fail of test"""
17 if cond:
18 print("PASS: %s" % (msg))
19 else:
20 print("FAIL: %s" % (msg))
21 global failcount
22 failcount += 1
23
24
25 def run_test():
26 """Run through the tests one by one"""
27 illegal_op = gdb.Breakpoint("illegal_op")
28 stg = gdb.Breakpoint("stg")
29 mvc_8 = gdb.Breakpoint("mvc_8")
30
31 # Expect the following events:
32 # 1x illegal_op breakpoint
33 # 2x stg breakpoint, segv, breakpoint
34 # 2x mvc_8 breakpoint, segv, breakpoint
35 for _ in range(14):
36 gdb.execute("c")
37 report(illegal_op.hit_count == 1, "illegal_op.hit_count == 1")
38 report(stg.hit_count == 4, "stg.hit_count == 4")
39 report(mvc_8.hit_count == 4, "mvc_8.hit_count == 4")
40
41 # The test must succeed.
42 gdb.Breakpoint("_exit")
43 gdb.execute("c")
44 status = int(gdb.parse_and_eval("$r2"))
45 report(status == 0, "status == 0");
46
47
48 #
49 # This runs as the script it sourced (via -x, via run-test.py)
50 #
51 try:
52 inferior = gdb.selected_inferior()
53 arch = inferior.architecture()
54 print("ATTACHED: %s" % arch.name())
55 except (gdb.error, AttributeError):
56 print("SKIPPING (not connected)", file=sys.stderr)
57 exit(0)
58
59 if gdb.parse_and_eval("$pc") == 0:
60 print("SKIP: PC not set")
61 exit(0)
62
63 try:
64 # Run the actual tests
65 run_test()
66 except (gdb.error):
67 print("GDB Exception: %s" % (sys.exc_info()[0]))
68 failcount += 1
69 pass
70
71 print("All tests complete: %d failures" % failcount)
72 exit(failcount)