CI: Use higher-level interaction with GDB in example tests and test apps

This commit is contained in:
Roland Dobai
2020-05-19 14:27:31 +02:00
committed by bot
parent 8526cb577c
commit 493c852b73
10 changed files with 159 additions and 145 deletions

View File

@@ -1,8 +1,10 @@
from __future__ import unicode_literals
from io import open
import debug_backend
import os
import re
import tempfile
import time
import ttfw_idf
@@ -29,7 +31,7 @@ def test_examples_sysview_tracing(env, extra_data):
new_content = new_content.replace('file:///tmp/sysview_example.svdat', 'file://{}'.format(tempfiles[1]), 1)
f_out.write(new_content)
with ttfw_idf.OCDProcess(os.path.join(proj_path, 'openocd.log')):
with ttfw_idf.OCDBackend(os.path.join(proj_path, 'openocd.log'), dut.app.target) as oocd:
dut.start_app()
def dut_expect_task_event():
@@ -37,17 +39,20 @@ def test_examples_sysview_tracing(env, extra_data):
dut_expect_task_event()
gdb_args = '-x {} --directory={}'.format(tempfiles[0], os.path.join(proj_path, 'main'))
with ttfw_idf.GDBProcess(os.path.join(proj_path, 'gdb.log'), elf_path, dut.app.target, gdb_args) as gdb:
gdb.pexpect_proc.expect_exact('Thread 1 hit Breakpoint 1, app_main ()')
gdb.pexpect_proc.expect_exact('Targets connected.')
gdb.pexpect_proc.expect(re.compile(r'\d+'))
gdb_log = os.path.join(proj_path, 'gdb.log')
gdb_workdir = os.path.join(proj_path, 'main')
with ttfw_idf.GDBBackend(gdb_log, elf_path, dut.app.target, tempfiles[0], gdb_workdir) as p:
p.gdb.wait_target_state(debug_backend.TARGET_STATE_RUNNING)
stop_reason = p.gdb.wait_target_state(debug_backend.TARGET_STATE_STOPPED)
assert stop_reason == debug_backend.TARGET_STOP_REASON_BP, 'STOP reason: {}'.format(stop_reason)
dut.expect('example: Created task') # dut has been restarted by gdb since the last dut.expect()
dut_expect_task_event()
gdb.pexpect_proc.sendcontrol('c')
gdb.pexpect_proc.expect_exact('(gdb)')
# Do a sleep while sysview samples are captured.
time.sleep(3)
# GDBMI isn't responding now to any commands, therefore, the following command is issued to openocd
oocd.cmd_exec('esp sysview stop')
finally:
for x in tempfiles:
try: