summary refs log tree commit diff stats
path: root/tests/tcg/multiarch/gdbstub/test-proc-mappings.py
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2024-01-29 10:32:15 +0100
committerRichard Henderson <richard.henderson@linaro.org>2024-01-29 20:48:49 +1000
commit4d48c1bc079147a02ec1a3df9a41497c515d2e61 (patch)
tree6ec9659fd3c5df462a61e5a644d9081e85f0dee7 /tests/tcg/multiarch/gdbstub/test-proc-mappings.py
parent87ab270429618c13a6bf6dfc90d5edf6a3fa99b9 (diff)
downloadfocaccia-qemu-4d48c1bc079147a02ec1a3df9a41497c515d2e61.tar.gz
focaccia-qemu-4d48c1bc079147a02ec1a3df9a41497c515d2e61.zip
tests/tcg: Factor out gdbstub test functions
Both the report() function as well as the initial gdbstub test sequence
are copy-pasted into ~10 files with slight modifications. This
indicates that they are indeed generic, so factor them out. While
at it, add a few newlines to make the formatting closer to PEP-8.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20240129093410.3151-3-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests/tcg/multiarch/gdbstub/test-proc-mappings.py')
-rw-r--r--tests/tcg/multiarch/gdbstub/test-proc-mappings.py39
1 files changed, 2 insertions, 37 deletions
diff --git a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py
index 04ec61d219..564613fabf 100644
--- a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py
+++ b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py
@@ -3,20 +3,7 @@
 This runs as a sourced script (via -x, via run-test.py)."""
 from __future__ import print_function
 import gdb
-import sys
-
-
-n_failures = 0
-
-
-def report(cond, msg):
-    """Report success/fail of a test"""
-    if cond:
-        print("PASS: {}".format(msg))
-    else:
-        print("FAIL: {}".format(msg))
-        global n_failures
-        n_failures += 1
+from test_gdbstub import main, report
 
 
 def run_test():
@@ -37,26 +24,4 @@ def run_test():
     # report("/sha1" in mappings, "Found the test binary name in the mappings")
 
 
-def main():
-    """Prepare the environment and run through the tests"""
-    try:
-        inferior = gdb.selected_inferior()
-        print("ATTACHED: {}".format(inferior.architecture().name()))
-    except (gdb.error, AttributeError):
-        print("SKIPPING (not connected)")
-        exit(0)
-
-    if gdb.parse_and_eval('$pc') == 0:
-        print("SKIP: PC not set")
-        exit(0)
-
-    try:
-        # Run the actual tests
-        run_test()
-    except gdb.error:
-        report(False, "GDB Exception: {}".format(sys.exc_info()[0]))
-    print("All tests complete: %d failures" % n_failures)
-    exit(n_failures)
-
-
-main()
+main(run_test)