diff options
| author | Ilya Leoshkevich <iii@linux.ibm.com> | 2024-01-29 10:32:15 +0100 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2024-01-29 20:48:49 +1000 |
| commit | 4d48c1bc079147a02ec1a3df9a41497c515d2e61 (patch) | |
| tree | 6ec9659fd3c5df462a61e5a644d9081e85f0dee7 /tests/tcg/multiarch/gdbstub/registers.py | |
| parent | 87ab270429618c13a6bf6dfc90d5edf6a3fa99b9 (diff) | |
| download | focaccia-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/registers.py')
| -rw-r--r-- | tests/tcg/multiarch/gdbstub/registers.py | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/tests/tcg/multiarch/gdbstub/registers.py b/tests/tcg/multiarch/gdbstub/registers.py index 688c061107..b3d13cb077 100644 --- a/tests/tcg/multiarch/gdbstub/registers.py +++ b/tests/tcg/multiarch/gdbstub/registers.py @@ -7,20 +7,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later import gdb -import sys import xml.etree.ElementTree as ET +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 +initial_vlen = 0 def fetch_xml_regmap(): @@ -75,6 +66,7 @@ def fetch_xml_regmap(): return reg_map + def get_register_by_regnum(reg_map, regnum): """ Helper to find a register from the map via its XML regnum @@ -84,6 +76,7 @@ def get_register_by_regnum(reg_map, regnum): return entry return None + def crosscheck_remote_xml(reg_map): """ Cross-check the list of remote-registers with the XML info. @@ -144,6 +137,7 @@ def crosscheck_remote_xml(reg_map): elif "seen" not in x_reg: print(f"{x_reg} wasn't seen in remote-registers") + def initial_register_read(reg_map): """ Do an initial read of all registers that we know gdb cares about @@ -214,27 +208,4 @@ def run_test(): complete_and_diff(reg_map) -# -# 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_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) |