Add JTAG related example tests

This commit is contained in:
Roland Dobai
2020-04-17 11:51:00 +02:00
parent d73470a8a6
commit 79e58eff8f
17 changed files with 271 additions and 42 deletions

View File

@@ -289,7 +289,7 @@ example_test_009:
artifacts:
when: always
paths:
- $CI_PROJECT_DIR/examples/storage/semihost_vfs/*.log
- $CI_PROJECT_DIR/examples/*/*/*.log
expire_in: 1 week
variables:
SETUP_TOOLS: "1"

View File

@@ -19,7 +19,7 @@ import pexpect
class CustomProcess(object):
def __init__(self, cmd, logfile, verbose):
def __init__(self, cmd, logfile, verbose=True):
self.verbose = verbose
self.f = open(logfile, 'w')
if self.verbose:
@@ -68,8 +68,8 @@ class OCDProcess(CustomProcess):
class GDBProcess(CustomProcess):
def __init__(self, logfile_path, elffile_path, extra_args='', verbose=True):
cmd = 'xtensa-esp32-elf-gdb {} {}'.format(extra_args, elffile_path)
def __init__(self, logfile_path, elffile_path, target, extra_args='', verbose=True):
cmd = 'xtensa-{}-elf-gdb {} {}'.format(target, extra_args, elffile_path)
super(GDBProcess, self).__init__(cmd, logfile_path, verbose)
def close(self):
@@ -82,3 +82,18 @@ class GDBProcess(CustomProcess):
if self.verbose:
Utility.console_log('gdb needs to be killed', 'O')
super(GDBProcess, self).close()
class TelnetProcess(CustomProcess):
def __init__(self, logfile_path, host='localhost', port=4444, verbose=True):
cmd = 'telnet {} {}'.format(host, port)
super(TelnetProcess, self).__init__(cmd, logfile_path, verbose)
def close(self):
try:
self.pexpect_proc.sendline('exit')
self.pexpect_proc.expect_exact('Connection closed by foreign host.')
except Exception:
if self.verbose:
Utility.console_log('telnet needs to be killed', 'O')
super(TelnetProcess, self).close()

View File

@@ -17,7 +17,7 @@ import re
from tiny_test_fw import TinyFW, Utility
from .IDFApp import IDFApp, Example, LoadableElfTestApp, UT, TestApp # noqa: export all Apps for users
from .IDFDUT import IDFDUT, ESP32DUT, ESP32S2DUT, ESP8266DUT, ESP32QEMUDUT # noqa: export DUTs for users
from .DebugUtils import OCDProcess, GDBProcess # noqa: export DebugUtils for users
from .DebugUtils import OCDProcess, GDBProcess, TelnetProcess, CustomProcess # noqa: export DebugUtils for users
def format_case_id(chip, case_name):

View File

@@ -1,3 +1,4 @@
set pagination off
# Connect to a running instance of OpenOCD
target remote 127.0.0.1:3333
# Reset and halt the target

View File

@@ -39,10 +39,10 @@ def test_app_loadable_elf(env, extra_data):
rel_project_path = os.path.join('tools', 'test_apps', 'system', 'gdb_loadable_elf')
app_files = ['gdb_loadable_elf.elf']
example = ttfw_idf.LoadableElfTestApp(rel_project_path, app_files, target="esp32")
idf_path = example.get_sdk_path()
app = ttfw_idf.LoadableElfTestApp(rel_project_path, app_files, target="esp32")
idf_path = app.get_sdk_path()
proj_path = os.path.join(idf_path, rel_project_path)
elf_path = os.path.join(example.binary_path, 'gdb_loadable_elf.elf')
elf_path = os.path.join(app.binary_path, 'gdb_loadable_elf.elf')
esp_log_path = os.path.join(proj_path, 'esp.log')
with SerialThread(esp_log_path):
@@ -51,8 +51,7 @@ def test_app_loadable_elf(env, extra_data):
gdb_args = '-x {} --directory={}'.format(os.path.join(proj_path, '.gdbinit.ci'),
os.path.join(proj_path, 'main'))
with ttfw_idf.OCDProcess(openocd_log), ttfw_idf.GDBProcess(gdb_log, elf_path, gdb_args) as gdb:
gdb.pexpect_proc.sendline('') # it is for "---Type <return> to continue, or q <return> to quit---"
with ttfw_idf.OCDProcess(openocd_log), ttfw_idf.GDBProcess(gdb_log, elf_path, app.target, gdb_args) as gdb:
i = gdb.pexpect_proc.expect_exact(['Thread 1 hit Temporary breakpoint 2, app_main ()',
'Load failed'])
if i == 0: