[Concept,24/24] test/py: Add an option to disable the console timeout

Message ID 20260103011908.149445-25-sjg@u-boot.org
State New
Headers
Series Malloc debugging and test/py improvements |

Commit Message

Simon Glass Jan. 3, 2026, 1:19 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

When debugging, particularly when stepping through code in a debugger or
dealing with very slow operations, the console timeout can interfere.

Add a --no-timeout command-line option that disables the console
timeout. Adjust get_default_timeout() to checks for both --gdbserver and
--no-timeout, returning None to disable timeouts in either case. This
consolidates the timeout-disable logic that was previously spread across
multiple locations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 test/py/console_base.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
  

Patch

diff --git a/test/py/console_base.py b/test/py/console_base.py
index c4472420c31..7f044b587b6 100644
--- a/test/py/console_base.py
+++ b/test/py/console_base.py
@@ -271,6 +271,19 @@  class ConsoleBase():
         #   call, where the function returns None (assignment-from-none)
         return spawn.Spawn([])
 
+    def get_default_timeout(self):
+        """Get the default timeout for commands.
+
+        Subclasses can override this to provide a different timeout.
+        For example, sandbox may need a longer timeout when mcheck is enabled.
+
+        Returns:
+            int: Timeout in milliseconds, or None if timeout is disabled
+        """
+        if self.config.gdbserver or self.config.no_timeout:
+            return None
+        return TIMEOUT_MS
+
     def eval_patterns(self):
         """Set up lists of regexes for patterns we don't expect on console"""
         self.bad_patterns = [pat.pattern for pat in self.avail_patterns
@@ -328,7 +341,7 @@  class ConsoleBase():
                     m = pattern_ready_prompt.search(self.after)
                     self.u_boot_version_string = m.group(2)
                     self.log.info('Lab: Board is ready')
-                    self.timeout = TIMEOUT_MS
+                    self.timeout = self.get_default_timeout()
                     break
                 if m == 2:
                     self.log.info(f'Found autoboot prompt {m}')
@@ -616,8 +629,7 @@  class ConsoleBase():
         if self.p:
             # Reset the console timeout value as some tests may change
             # its default value during the execution
-            if not self.config.gdbserver:
-                self.timeout = TIMEOUT_MS
+            self.timeout = self.get_default_timeout()
             return
         try:
             self.log.start_section('Starting U-Boot')
@@ -628,8 +640,7 @@  class ConsoleBase():
             # text if LCD is enabled. This value may need tweaking in the
             # future, possibly per-test to be optimal. This works for 'help'
             # on board 'seaboard'.
-            if not self.config.gdbserver:
-                self.timeout = TIMEOUT_MS
+            self.timeout = self.get_default_timeout()
             self.logfile_read = self.logstream
             if self.config.use_running_system:
                 # Send an empty command to set up the 'expect' logic. This has