tests/tcg: Stop using exit() in the gdbstub testcases

GDB 15 does not like exit() anymore:

    (gdb) python exit(0)
    Python Exception <class 'SystemExit'>: 0
    Error occurred in Python: 0

Use the GDB's own exit command, like it's already done in a couple
places, everywhere. This is the same fix as commit 93a3048dcf
("tests: Gently exit from GDB when tests complete"), but applied to
more places.

Acked-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20241022113939.19989-1-iii@linux.ibm.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
Ilya Leoshkevich 2024-10-22 13:37:11 +02:00 committed by Alex Bennée
parent 0fbc798e4f
commit cb241df412
4 changed files with 16 additions and 10 deletions

View file

@ -10,10 +10,16 @@ import traceback
fail_count = 0
def gdb_exit(status):
gdb.execute(f"exit {status}")
class arg_parser(argparse.ArgumentParser):
def exit(self, status=None, message=""):
print("Wrong GDB script test argument! " + message)
gdb.execute("exit 1")
gdb_exit(1)
def report(cond, msg):
"""Report success/fail of a test"""
@ -38,11 +44,11 @@ def main(test, expected_arch=None):
"connected to {}".format(expected_arch))
except (gdb.error, AttributeError):
print("SKIP: not connected")
exit(0)
gdb_exit(0)
if gdb.parse_and_eval("$pc") == 0:
print("SKIP: PC not set")
exit(0)
gdb_exit(0)
try:
test()
@ -62,4 +68,4 @@ def main(test, expected_arch=None):
pass
print("All tests complete: {} failures".format(fail_count))
gdb.execute(f"exit {fail_count}")
gdb_exit(fail_count)