1from __future__ import print_function 2# 3# Test the SVE ZReg reports the right amount of data. It uses the 4# sve-ioctl test and examines the register data each time the 5# __sve_ld_done breakpoint is hit. 6# 7# This is launched via tests/guest-debug/run-test.py 8# 9 10import gdb 11import sys 12 13initial_vlen = 0 14failcount = 0 15 16def report(cond, msg): 17 "Report success/fail of test" 18 if cond: 19 print ("PASS: %s" % (msg)) 20 else: 21 print ("FAIL: %s" % (msg)) 22 global failcount 23 failcount += 1 24 25class TestBreakpoint(gdb.Breakpoint): 26 def __init__(self, sym_name="__sve_ld_done"): 27 super(TestBreakpoint, self).__init__(sym_name) 28 # self.sym, ok = gdb.lookup_symbol(sym_name) 29 30 def stop(self): 31 val_i = gdb.parse_and_eval('i') 32 global initial_vlen 33 try: 34 for i in range(0, int(val_i)): 35 val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) 36 report(int(val_z) == i, "z0.b.u[%d] == %d" % (i, i)) 37 for i in range(i + 1, initial_vlen): 38 val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) 39 report(int(val_z) == 0, "z0.b.u[%d] == 0" % (i)) 40 except gdb.error: 41 report(False, "checking zregs (out of range)") 42 43 44def run_test(): 45 "Run through the tests one by one" 46 47 print ("Setup breakpoint") 48 bp = TestBreakpoint() 49 50 global initial_vlen 51 vg = gdb.parse_and_eval("$vg") 52 initial_vlen = int(vg) * 8 53 54 gdb.execute("c") 55 56# 57# This runs as the script it sourced (via -x, via run-test.py) 58# 59try: 60 inferior = gdb.selected_inferior() 61 arch = inferior.architecture() 62 report(arch.name() == "aarch64", "connected to aarch64") 63except (gdb.error, AttributeError): 64 print("SKIPPING (not connected)", file=sys.stderr) 65 exit(0) 66 67try: 68 # These are not very useful in scripts 69 gdb.execute("set pagination off") 70 71 # Run the actual tests 72 run_test() 73except: 74 print ("GDB Exception: %s" % (sys.exc_info()[0])) 75 failcount += 1 76 import code 77 code.InteractiveConsole(locals=globals()).interact() 78 raise 79 80print("All tests complete: %d failures" % failcount) 81exit(failcount) 82