1 from __future__
import print_function
3 # A very simple smoke test for debugging the SHA1 userspace test on
6 # This is launched via tests/guest-debug/run-test.py
15 def report(cond
, msg
):
16 "Report success/fail of test"
18 print("PASS: %s" % (msg
))
20 print("FAIL: %s" % (msg
))
24 def check_break(sym_name
):
25 "Setup breakpoint, continue and check we stopped."
26 sym
, ok
= gdb
.lookup_symbol(sym_name
)
27 bp
= gdb
.Breakpoint(sym_name
)
31 # hopefully we came back
32 end_pc
= gdb
.parse_and_eval('$pc')
33 report(bp
.hit_count
== 1,
34 "break @ %s (%s %d hits)" % (end_pc
, sym
.value(), bp
.hit_count
))
39 "Run through the tests one by one"
41 check_break("SHA1Init")
43 # check step and inspect values
45 val_ctx
= gdb
.parse_and_eval("context->state[0]")
47 report(int(val_ctx
) == exp_ctx
, "context->state[0] == %x" % exp_ctx
);
50 val_ctx
= gdb
.parse_and_eval("context->state[1]")
52 report(int(val_ctx
) == exp_ctx
, "context->state[1] == %x" % exp_ctx
);
54 # finally check we don't barf inspecting registers
55 gdb
.execute("info registers")
58 # This runs as the script it sourced (via -x, via run-test.py)
61 inferior
= gdb
.selected_inferior()
62 arch
= inferior
.architecture()
63 print("ATTACHED: %s" % arch
.name())
64 except (gdb
.error
, AttributeError):
65 print("SKIPPING (not connected)", file=sys
.stderr
)
69 # These are not very useful in scripts
70 gdb
.execute("set pagination off")
71 gdb
.execute("set confirm off")
73 # Run the actual tests
76 print ("GDB Exception: %s" % (sys
.exc_info()[0]))
80 print("All tests complete: %d failures" % failcount
)