test-signals-s390x.py (1822B)
1from __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 9import gdb 10import sys 11 12failcount = 0 13 14 15def 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 25def 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# 51try: 52 inferior = gdb.selected_inferior() 53 arch = inferior.architecture() 54 print("ATTACHED: %s" % arch.name()) 55except (gdb.error, AttributeError): 56 print("SKIPPING (not connected)", file=sys.stderr) 57 exit(0) 58 59if gdb.parse_and_eval("$pc") == 0: 60 print("SKIP: PC not set") 61 exit(0) 62 63try: 64 # These are not very useful in scripts 65 gdb.execute("set pagination off") 66 gdb.execute("set confirm off") 67 68 # Run the actual tests 69 run_test() 70except (gdb.error): 71 print("GDB Exception: %s" % (sys.exc_info()[0])) 72 failcount += 1 73 pass 74 75print("All tests complete: %d failures" % failcount) 76exit(failcount)