Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / multiarch / gdbstub / test-qxfer-auxv-read.py
blobd91e8fdf19abd42537c3c5fc323e8f8033bcd0bd
1 from __future__ import print_function
3 # Test auxiliary vector is loaded via gdbstub
5 # This is launched via tests/guest-debug/run-test.py
8 import gdb
9 import sys
11 failcount = 0
13 def report(cond, msg):
14 "Report success/fail of test"
15 if cond:
16 print ("PASS: %s" % (msg))
17 else:
18 print ("FAIL: %s" % (msg))
19 global failcount
20 failcount += 1
22 def run_test():
23 "Run through the tests one by one"
25 auxv = gdb.execute("info auxv", False, True)
26 report(isinstance(auxv, str), "Fetched auxv from inferior")
27 report(auxv.find("sha1"), "Found test binary name in auxv")
30 # This runs as the script it sourced (via -x, via run-test.py)
32 try:
33 inferior = gdb.selected_inferior()
34 arch = inferior.architecture()
35 print("ATTACHED: %s" % arch.name())
36 except (gdb.error, AttributeError):
37 print("SKIPPING (not connected)", file=sys.stderr)
38 exit(0)
40 if gdb.parse_and_eval('$pc') == 0:
41 print("SKIP: PC not set")
42 exit(0)
44 try:
45 # These are not very useful in scripts
46 gdb.execute("set pagination off")
47 gdb.execute("set confirm off")
49 # Run the actual tests
50 run_test()
51 except (gdb.error):
52 print ("GDB Exception: %s" % (sys.exc_info()[0]))
53 failcount += 1
54 pass
56 print("All tests complete: %d failures" % failcount)
57 exit(failcount)