| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,9 +76,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,9 +66,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| from __future__ import print_function | ||
| # | ||
| # Test some of the softmmu debug features with the multiarch memory | ||
| # test. It is a port of the original vmlinux focused test case but | ||
| # using the "memory" test instead. | ||
| # | ||
| # This is launched via tests/guest-debug/run-test.py | ||
| # | ||
|
|
||
| import gdb | ||
| import sys | ||
|
|
||
| failcount = 0 | ||
|
|
||
|
|
||
| def report(cond, msg): | ||
| "Report success/fail of test" | ||
| if cond: | ||
| print("PASS: %s" % (msg)) | ||
| else: | ||
| print("FAIL: %s" % (msg)) | ||
| global failcount | ||
| failcount += 1 | ||
|
|
||
|
|
||
| def check_interrupt(thread): | ||
| """ | ||
| Check that, if thread is resumed, we go back to the same thread when the | ||
| program gets interrupted. | ||
| """ | ||
|
|
||
| # Switch to the thread we're going to be running the test in. | ||
| print("thread ", thread.num) | ||
| gdb.execute("thr %d" % thread.num) | ||
|
|
||
| # Enter the loop() function on this thread. | ||
| # | ||
| # While there are cleaner ways to do this, we want to minimize the number of | ||
| # side effects on the gdbstub's internal state, since those may mask bugs. | ||
| # Ideally, there should be no difference between what we're doing here and | ||
| # the program reaching the loop() function on its own. | ||
| # | ||
| # For this to be safe, we only need the prologue of loop() to not have | ||
| # instructions that may have problems with what we're doing here. We don't | ||
| # have to worry about anything else, as this function never returns. | ||
| gdb.execute("set $pc = loop") | ||
|
|
||
| # Continue and then interrupt the task. | ||
| gdb.post_event(lambda: gdb.execute("interrupt")) | ||
| gdb.execute("c") | ||
|
|
||
| # Check whether the thread we're in after the interruption is the same we | ||
| # ran continue from. | ||
| return (thread.num == gdb.selected_thread().num) | ||
|
|
||
|
|
||
| def run_test(): | ||
| """ | ||
| Test if interrupting the code always lands us on the same thread when | ||
| running with scheduler-lock enabled. | ||
| """ | ||
|
|
||
| gdb.execute("set scheduler-locking on") | ||
| for thread in gdb.selected_inferior().threads(): | ||
| report(check_interrupt(thread), | ||
| "thread %d resumes correctly on interrupt" % thread.num) | ||
|
|
||
|
|
||
| # | ||
| # This runs as the script it sourced (via -x, via run-test.py) | ||
| # | ||
| try: | ||
| inferior = gdb.selected_inferior() | ||
| arch = inferior.architecture() | ||
| print("ATTACHED: %s" % arch.name()) | ||
| except (gdb.error, AttributeError): | ||
| print("SKIPPING (not connected)", file=sys.stderr) | ||
| exit(0) | ||
|
|
||
| if gdb.parse_and_eval('$pc') == 0: | ||
| print("SKIP: PC not set") | ||
| exit(0) | ||
| if len(gdb.selected_inferior().threads()) == 1: | ||
| print("SKIP: set to run on a single thread") | ||
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except (gdb.error): | ||
| print("GDB Exception: %s" % (sys.exc_info()[0])) | ||
| failcount += 1 | ||
| pass | ||
|
|
||
| # Finally kill the inferior and exit gdb with a count of failures | ||
| gdb.execute("kill") | ||
| exit(failcount) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,9 +115,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except (gdb.error): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,10 +73,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except (gdb.error): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,10 +51,6 @@ def main(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except gdb.error: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,10 +42,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except (gdb.error): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,10 +45,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except (gdb.error): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * External interruption test. This test is structured in such a way that it | ||
| * passes the cases that require it to exit, but we can make it enter an | ||
| * infinite loop from GDB. | ||
| * | ||
| * We don't have the benefit of libc, just builtin C primitives and | ||
| * whatever is in minilib. | ||
| */ | ||
|
|
||
| #include <minilib.h> | ||
|
|
||
| void loop(void) | ||
| { | ||
| do { | ||
| /* | ||
| * Loop forever. Just make sure the condition is always a constant | ||
| * expression, so that this loop is not UB, as per the C | ||
| * standard. | ||
| */ | ||
| } while (1); | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,10 +61,6 @@ def run_test(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except (gdb.error): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,10 +49,6 @@ def main(): | |
| exit(0) | ||
|
|
||
| try: | ||
| # Run the actual tests | ||
| run_test() | ||
| except gdb.error: | ||
|
|
||