summary refs log tree commit diff stats
path: root/tests/tcg/multiarch/gdbstub/sha1.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/sha1.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/sha1.py')
-rw-r--r--tests/tcg/multiarch/gdbstub/sha1.py40
1 files changed, 5 insertions, 35 deletions
diff --git a/tests/tcg/multiarch/gdbstub/sha1.py b/tests/tcg/multiarch/gdbstub/sha1.py
index 416728415f..1ce711a402 100644
--- a/tests/tcg/multiarch/gdbstub/sha1.py
+++ b/tests/tcg/multiarch/gdbstub/sha1.py
@@ -7,19 +7,11 @@ from __future__ import print_function
 #
 
 import gdb
-import sys
+from test_gdbstub import main, report
+
 
 initial_vlen = 0
-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_break(sym_name):
     "Setup breakpoint, continue and check we stopped."
@@ -35,6 +27,7 @@ def check_break(sym_name):
 
     bp.delete()
 
+
 def run_test():
     "Run through the tests one by one"
 
@@ -57,28 +50,5 @@ def run_test():
     # finally check we don't barf inspecting registers
     gdb.execute("info registers")
 
-#
-# 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)
-
-try:
-    # Run the actual tests
-    run_test()
-except (gdb.error):
-    print ("GDB Exception: %s" % (sys.exc_info()[0]))
-    failcount += 1
-    pass
-
-print("All tests complete: %d failures" % failcount)
-exit(failcount)
+
+main(run_test)