[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest
authorTom de Vries <tdevries@suse.de>
Tue, 19 Oct 2021 21:50:50 +0000 (23:50 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 19 Oct 2021 21:50:50 +0000 (23:50 +0200)
commitc82f680a94399a0f1c9fdc53ed79a8cf333213a6
tree2f8984a012c205b65b357f93be8f5b02a9977dd5
parent5a8edb756a56cdfb563006cbc39561994acf6d2d
[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittest

The test-case gdb.gdb/python-interrupts.exp:
- runs to captured_command_loop
- sets a breakpoint at set_active_ext_lang
- calls a python command
- verifies the command triggers the breakpoint
- sends a signal and verifies the result

The test-case is fragile, because (f.i. with -flto) it cannot be guaranteed
that captured_command_loop and set_active_ext_lang are available for setting
breakpoints.

Reimplement the test-case as unittest, using:
- execute_command_to_string to capture the output
- try/catch to catch the "Error while executing Python code" exception
- a new hook selftests::hook_set_active_ext_lang to raise the signal

Tested on x86_64-linux.
gdb/extension.c
gdb/extension.h
gdb/python/python.c
gdb/testsuite/gdb.gdb/python-interrupts.exp [deleted file]