samples: gdbstub: test using pytest
Test gdb stub using pytest. Co-developed-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no> Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
037618a638
commit
31c22c9a77
3 changed files with 37 additions and 3 deletions
34
samples/subsys/debug/gdbstub/pytest/test_gdbstub.py
Executable file
34
samples/subsys/debug/gdbstub/pytest/test_gdbstub.py
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright (c) 2023 Intel Corporation.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from twister_harness import DeviceAdapter
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
ZEPHYR_BASE = os.getenv("ZEPHYR_BASE")
|
||||||
|
sys.path.insert(0, os.path.join(ZEPHYR_BASE, "scripts", "pylib", "twister"))
|
||||||
|
from twisterlib.cmakecache import CMakeCache
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def test_gdbstub(dut: DeviceAdapter):
|
||||||
|
"""
|
||||||
|
Test gdbstub feature using a gdb script. We connect to the DUT and run some
|
||||||
|
basic gdb commands and evaluate return code to determine pass or failure.
|
||||||
|
"""
|
||||||
|
build_dir = dut.device_config.build_dir
|
||||||
|
cmake_cache = CMakeCache.from_file(build_dir / 'CMakeCache.txt')
|
||||||
|
gdb = cmake_cache.get('CMAKE_GDB', None)
|
||||||
|
assert gdb
|
||||||
|
source_dir = cmake_cache.get('APPLICATION_SOURCE_DIR', None)
|
||||||
|
assert source_dir
|
||||||
|
cmd = [gdb, '-x', f'{source_dir}/run.gdbinit', f'{build_dir}/zephyr/zephyr.elf']
|
||||||
|
logger.info(f'Test command: {shlex.join(cmd)}')
|
||||||
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=20)
|
||||||
|
logger.debug('Output:\n%s' % result.stdout)
|
||||||
|
assert result.returncode == 0
|
|
@ -1,6 +1,6 @@
|
||||||
set pagination off
|
set pagination off
|
||||||
symbol-file zephyr/zephyr.elf
|
#symbol-file build/zephyr/zephyr.elf
|
||||||
target remote 127.0.0.1:1234
|
target remote :5678
|
||||||
b test
|
b test
|
||||||
b main.c:33
|
b main.c:33
|
||||||
c
|
c
|
||||||
|
|
|
@ -8,8 +8,8 @@ sample:
|
||||||
name: gdbstub sample
|
name: gdbstub sample
|
||||||
tests:
|
tests:
|
||||||
sample.debug.gdbstub:
|
sample.debug.gdbstub:
|
||||||
build_only: true
|
|
||||||
platform_allow: qemu_x86
|
platform_allow: qemu_x86
|
||||||
|
harness: pytest
|
||||||
tags:
|
tags:
|
||||||
- debug
|
- debug
|
||||||
- gdbstub
|
- gdbstub
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue