tests: gdbstub: qemu: Cross-validate test behavior
Add a testcase to run the same test application and GDB script which we use for Zephyr GDB stub testing, but now with the GDB stub enabled at QEMU itself using it as a reference RDP backend implementation. This allows to check the Zephyr's gdbstub implementation has similar behavior as the reference. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
parent
236c1ac5de
commit
664d96785b
2 changed files with 45 additions and 5 deletions
|
@ -18,7 +18,7 @@ from twisterlib.cmakecache import CMakeCache
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def gdb_process(dut: DeviceAdapter, gdb_script, gdb_timeout, gdb_target_remote):
|
def gdb_process(dut: DeviceAdapter, gdb_script, gdb_timeout, gdb_target_remote) -> subprocess.CompletedProcess:
|
||||||
build_dir = dut.device_config.build_dir
|
build_dir = dut.device_config.build_dir
|
||||||
cmake_cache = CMakeCache.from_file(os.path.join(build_dir, 'CMakeCache.txt'))
|
cmake_cache = CMakeCache.from_file(os.path.join(build_dir, 'CMakeCache.txt'))
|
||||||
gdb_exec = cmake_cache.get('CMAKE_GDB', None)
|
gdb_exec = cmake_cache.get('CMAKE_GDB', None)
|
||||||
|
@ -59,7 +59,15 @@ def expected_gdb():
|
||||||
re.compile(r'GDB:PASSED'),
|
re.compile(r'GDB:PASSED'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_gdbstub(dut: DeviceAdapter, gdb_process, expected_app, expected_gdb):
|
@pytest.fixture(scope="module")
|
||||||
|
def expected_gdb_detach():
|
||||||
|
return [
|
||||||
|
re.compile(r'Inferior.*will be killed'), # Zephyr gdbstub
|
||||||
|
re.compile(r'Inferior.*detached') # QEMU gdbstub
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_gdbstub(dut: DeviceAdapter, gdb_process, expected_app, expected_gdb, expected_gdb_detach):
|
||||||
"""
|
"""
|
||||||
Test gdbstub feature using a GDB script. We connect to the DUT, run the
|
Test gdbstub feature using a GDB script. We connect to the DUT, run the
|
||||||
GDB script then evaluate return code and expected patterns at the GDB
|
GDB script then evaluate return code and expected patterns at the GDB
|
||||||
|
@ -68,7 +76,7 @@ def test_gdbstub(dut: DeviceAdapter, gdb_process, expected_app, expected_gdb):
|
||||||
logger.debug(f"GDB output:\n{gdb_process.stdout}\n")
|
logger.debug(f"GDB output:\n{gdb_process.stdout}\n")
|
||||||
assert gdb_process.returncode == 0
|
assert gdb_process.returncode == 0
|
||||||
assert all([ex_re.search(gdb_process.stdout, re.MULTILINE) for ex_re in expected_gdb]), 'No expected GDB output'
|
assert all([ex_re.search(gdb_process.stdout, re.MULTILINE) for ex_re in expected_gdb]), 'No expected GDB output'
|
||||||
assert 'Inferior 1 [Remote target] will be killed' in gdb_process.stdout,'Expecting explicit quit from the GDB script and kill QEMU test app.'
|
assert any([ex_re.search(gdb_process.stdout, re.MULTILINE) for ex_re in expected_gdb_detach]), 'No expected GDB quit'
|
||||||
app_output = '\n'.join(dut.readlines(print_output = False))
|
app_output = '\n'.join(dut.readlines(print_output = False))
|
||||||
logger.debug(f"App output:\n{app_output}\n")
|
logger.debug(f"App output:\n{app_output}\n")
|
||||||
assert all([ex_re.search(app_output, re.MULTILINE) for ex_re in expected_app]), 'No expected Application output'
|
assert all([ex_re.search(app_output, re.MULTILINE) for ex_re in expected_app]), 'No expected Application output'
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
|
# Connect to Zephyr gdbstub and run a simple GDB script
|
||||||
debug.gdbstub.breakpoints:
|
debug.gdbstub.breakpoints:
|
||||||
platform_allow: qemu_x86
|
platform_allow: qemu_x86
|
||||||
harness: pytest
|
harness: pytest
|
||||||
|
@ -17,11 +18,42 @@ tests:
|
||||||
- "--gdb_script"
|
- "--gdb_script"
|
||||||
- "test_breakpoints.gdbinit"
|
- "test_breakpoints.gdbinit"
|
||||||
- "--gdb_target_remote"
|
- "--gdb_target_remote"
|
||||||
- "tcp:127.0.0.1:5678"
|
- "tcp::5678"
|
||||||
tags:
|
tags:
|
||||||
- debug
|
- debug
|
||||||
- gdbstub
|
- gdbstub
|
||||||
extra_configs:
|
extra_configs:
|
||||||
# Make sure the gdbstub port chosen is unique for this test to avoid conflicts
|
# Make sure the gdbstub port chosen is unique for this test to avoid conflicts
|
||||||
# when Twister runs tests in parallel on the same host.
|
# when Twister runs tests in parallel on the same host.
|
||||||
- CONFIG_QEMU_EXTRA_FLAGS="-serial tcp:127.0.0.1:5678,server"
|
- CONFIG_QEMU_EXTRA_FLAGS="-serial tcp::5678,server"
|
||||||
|
|
||||||
|
# Connect to QEMU gdbstub backend and run the same GDB test script
|
||||||
|
# to check it against a reference RDP backend implementation expecting
|
||||||
|
# similar behavior as for Zephyr's gdbstub.
|
||||||
|
# Use non-default QEMU gdbstub port 1235 for this test to avoid conflicts
|
||||||
|
# with some other test on QEMU running in parallel.
|
||||||
|
debug.gdbstub_qemu.breakpoints:
|
||||||
|
platform_allow: qemu_x86
|
||||||
|
harness: pytest
|
||||||
|
harness_config:
|
||||||
|
pytest_root:
|
||||||
|
- "pytest/test_gdbstub.py"
|
||||||
|
pytest_args:
|
||||||
|
- "--gdb_timeout"
|
||||||
|
- "20"
|
||||||
|
- "--gdb_script"
|
||||||
|
- "test_breakpoints.gdbinit"
|
||||||
|
- "--gdb_target_remote"
|
||||||
|
- "tcp::1235"
|
||||||
|
tags:
|
||||||
|
- debug
|
||||||
|
- gdbstub
|
||||||
|
extra_configs:
|
||||||
|
# Turn off Zephyr's gdbstub for this test case.
|
||||||
|
- CONFIG_GDBSTUB=n
|
||||||
|
- CONFIG_GDBSTUB_SERIAL_BACKEND=n
|
||||||
|
# Make sure the gdbstub port chosen is unique for this test to avoid conflicts
|
||||||
|
# when Twister runs tests in parallel on the same host.
|
||||||
|
- CONFIG_QEMU_EXTRA_FLAGS="-S -gdb tcp::1235"
|
||||||
|
# Clear QEMU default 'tcp::1234'
|
||||||
|
- CONFIG_QEMU_GDBSERVER_LISTEN_DEV=""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue