From 4dba80239e506b5abf65a1139902136a1646692a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 30 Mar 2021 11:01:39 +1100 Subject: [PATCH] ci: Extend timeout for initial gdbstub commands in panic tests Theory is that on the runner, in rare cases, gdb may need more than 1 second to load and start responding to commands. However it's possible these timeouts are due to some other problem (like gdb failing) --- tools/test_apps/system/panic/panic_tests.py | 1 + .../panic/test_panic_util/test_panic_util.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/test_apps/system/panic/panic_tests.py b/tools/test_apps/system/panic/panic_tests.py index 01478fd553..fde69a5787 100644 --- a/tools/test_apps/system/panic/panic_tests.py +++ b/tools/test_apps/system/panic/panic_tests.py @@ -19,6 +19,7 @@ def test_common(dut, test_name, expected_backtrace=None): expected_backtrace = get_default_backtrace(dut.test_name) if 'gdbstub' in test_name: + dut.expect('Entering gdb stub now.') dut.start_gdb() frames = dut.gdb_backtrace() if not dut.match_backtrace(frames, expected_backtrace): diff --git a/tools/test_apps/system/panic/test_panic_util/test_panic_util.py b/tools/test_apps/system/panic/test_panic_util/test_panic_util.py index 99112c3ebb..aa9ac45ef1 100644 --- a/tools/test_apps/system/panic/test_panic_util/test_panic_util.py +++ b/tools/test_apps/system/panic/test_panic_util/test_panic_util.py @@ -144,6 +144,13 @@ class PanicTestMixin(object): output_file_name = os.path.join(log_folder, 'coredump_flash_result_' + self.test_name + '.txt') self._call_espcoredump(['--core-format', 'raw'], coredump_file_name, output_file_name) + def _gdb_write(self, command): + """ + Wrapper to write to gdb with a longer timeout, as test runner + host can be slow sometimes + """ + return self.gdb.write(command, timeout_sec=3) + def start_gdb(self): """ Runs GDB and connects it to the "serial" port of the DUT. @@ -168,20 +175,20 @@ class PanicTestMixin(object): # Set up logging for GDB remote protocol gdb_remotelog_file_name = os.path.join(log_folder, 'gdb_remote_log_' + self.test_name + '.txt') - self.gdb.write('-gdb-set remotelogfile ' + gdb_remotelog_file_name) + self._gdb_write('-gdb-set remotelogfile ' + gdb_remotelog_file_name) # Load the ELF file - self.gdb.write('-file-exec-and-symbols {}'.format(self.app.elf_file)) + self._gdb_write('-file-exec-and-symbols {}'.format(self.app.elf_file)) # Connect GDB to UART Utility.console_log('Connecting to GDB Stub...', 'orange') - self.gdb.write('-gdb-set serial baud 115200') - responses = self.gdb.write('-target-select remote ' + self.get_gdb_remote(), timeout_sec=3) + self._gdb_write('-gdb-set serial baud 115200') + responses = self._gdb_write('-target-select remote ' + self.get_gdb_remote()) # Make sure we get the 'stopped' notification stop_response = self.find_gdb_response('stopped', 'notify', responses) if not stop_response: - responses = self.gdb.write('-exec-interrupt', timeout_sec=3) + responses = self._gdb_write('-exec-interrupt') stop_response = self.find_gdb_response('stopped', 'notify', responses) assert stop_response frame = stop_response['payload']['frame'] @@ -201,7 +208,7 @@ class PanicTestMixin(object): """ assert self.gdb - responses = self.gdb.write('-stack-list-frames', timeout_sec=3) + responses = self._gdb_write('-stack-list-frames') return self.find_gdb_response('done', 'result', responses)['payload']['stack'] @staticmethod