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,5 +1,4 @@
from __future__ import unicode_literals
from pexpect import TIMEOUT
from ttfw_idf import Utility
import os
import ttfw_idf
@@ -12,41 +11,46 @@ def test_examples_gcov(env, extra_data):
dut = env.get_dut('gcov', rel_project_path)
idf_path = dut.app.get_sdk_path()
proj_path = os.path.join(idf_path, rel_project_path)
openocd_cmd_log = os.path.join(proj_path, 'openocd_cmd.log')
with ttfw_idf.OCDProcess(os.path.join(proj_path, 'openocd.log')):
with ttfw_idf.TelnetProcess(os.path.join(proj_path, 'telnet.log')) as telnet_p:
dut.start_app()
with ttfw_idf.OCDBackend(os.path.join(proj_path, 'openocd.log'), dut.app.target) as oocd:
dut.start_app()
def expect_counter_output(loop, timeout=10):
dut.expect_all('blink_dummy_func: Counter = {}'.format(loop),
'some_dummy_func: Counter = {}'.format(loop * 2),
timeout=timeout)
def expect_counter_output(loop, timeout=10):
dut.expect_all('blink_dummy_func: Counter = {}'.format(loop),
'some_dummy_func: Counter = {}'.format(loop * 2),
timeout=timeout)
expect_counter_output(0, timeout=20)
dut.expect('Ready to dump GCOV data...', timeout=5)
expect_counter_output(0, timeout=20)
dut.expect('Ready to dump GCOV data...', timeout=5)
def dump_coverage():
try:
telnet_p.pexpect_proc.sendline('esp gcov dump')
telnet_p.pexpect_proc.expect_exact('Targets connected.')
telnet_p.pexpect_proc.expect_exact('gcov_example_main.c.gcda')
telnet_p.pexpect_proc.expect_exact('gcov_example_func.c.gcda')
telnet_p.pexpect_proc.expect_exact('some_funcs.c.gcda')
telnet_p.pexpect_proc.expect_exact('Targets disconnected.')
except TIMEOUT:
# Print what is happening with DUT. Limit the size if it is in loop and generating output.
Utility.console_log(dut.read(size=1000))
raise
def dump_coverage():
try:
response = oocd.cmd_exec('esp gcov dump')
with open(openocd_cmd_log, 'a') as f:
f.write(response)
dump_coverage()
dut.expect('GCOV data have been dumped.', timeout=5)
expect_counter_output(1)
dut.expect('Ready to dump GCOV data...', timeout=5)
dump_coverage()
dut.expect('GCOV data have been dumped.', timeout=5)
assert all(x in response for x in ['Targets connected.',
'gcov_example_main.c.gcda',
'gcov_example_func.c.gcda',
'some_funcs.c.gcda',
'Targets disconnected.',
])
for i in range(2, 6):
expect_counter_output(i)
except AssertionError:
# Print what is happening with DUT. Limit the size if it is in loop and generating output.
Utility.console_log(dut.read(size=1000))
raise
dump_coverage()
dut.expect('GCOV data have been dumped.', timeout=5)
expect_counter_output(1)
dut.expect('Ready to dump GCOV data...', timeout=5)
dump_coverage()
dut.expect('GCOV data have been dumped.', timeout=5)
for i in range(2, 6):
expect_counter_output(i)
if __name__ == '__main__':