test-sve-ioctl.py (2653B)
1 from __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 10 import gdb 11 import sys 12 13 initial_vlen = 0 14 failcount = 0 15 16 def 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 25 class 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 # Check the aliased V registers are set and GDB has correctly 44 # created them for us having recognised and handled SVE. 45 try: 46 for i in range(0, 16): 47 val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) 48 val_v = gdb.parse_and_eval("$v0.b.u[%d]" % i) 49 report(int(val_z) == int(val_v), 50 "v0.b.u[%d] == z0.b.u[%d]" % (i, i)) 51 except gdb.error: 52 report(False, "checking vregs (out of range)") 53 54 55 def run_test(): 56 "Run through the tests one by one" 57 58 print ("Setup breakpoint") 59 bp = TestBreakpoint() 60 61 global initial_vlen 62 vg = gdb.parse_and_eval("$vg") 63 initial_vlen = int(vg) * 8 64 65 gdb.execute("c") 66 67 # 68 # This runs as the script it sourced (via -x, via run-test.py) 69 # 70 try: 71 inferior = gdb.selected_inferior() 72 arch = inferior.architecture() 73 report(arch.name() == "aarch64", "connected to aarch64") 74 except (gdb.error, AttributeError): 75 print("SKIPPING (not connected)", file=sys.stderr) 76 exit(0) 77 78 try: 79 # These are not very useful in scripts 80 gdb.execute("set pagination off") 81 82 # Run the actual tests 83 run_test() 84 except: 85 print ("GDB Exception: %s" % (sys.exc_info()[0])) 86 failcount += 1 87 import code 88 code.InteractiveConsole(locals=globals()).interact() 89 raise 90 91 print("All tests complete: %d failures" % failcount) 92 exit(failcount)