]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Decode exceptions only with sandbox
authorSimon Glass <sjg@chromium.org>
Sun, 23 Jun 2024 20:30:30 +0000 (14:30 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 4 Jul 2024 15:25:21 +0000 (09:25 -0600)
When a real board fails we don't want to decode the exception. Reserve
that behaviour for sandbox. Also avoid raising a new exception on
failure - just re-raise the existing one.

Signed-off-by: Simon Glass <sjg@chromium.org>
test/py/u_boot_console_sandbox.py
test/py/u_boot_spawn.py

index 27c6db8d7190442ab292329d645b58ca16c7ce4d..7bc44c78b8b032c925551afbb751f0b5cf7f3105 100644 (file)
@@ -58,7 +58,7 @@ class ConsoleSandbox(ConsoleBase):
         if self.use_dtb:
             cmd += ['-d', self.config.dtb]
         cmd += self.sandbox_flags
-        return Spawn(cmd, cwd=self.config.source_dir)
+        return Spawn(cmd, cwd=self.config.source_dir, decode_signal=True)
 
     def restart_uboot_with_flags(self, flags, expect_reset=False, use_dtb=True):
         """Run U-Boot with the given command-line flags
index 7c48d96210e9dfb66737edd6169bc41a095b68f6..97e95e07c800ff2a1ba1eeeef296620ffbda8b94 100644 (file)
@@ -24,18 +24,20 @@ class Spawn:
         output: accumulated output from expect()
     """
 
-    def __init__(self, args, cwd=None):
+    def __init__(self, args, cwd=None, decode_signal=False):
         """Spawn (fork/exec) the sub-process.
 
         Args:
             args: array of processs arguments. argv[0] is the command to
               execute.
             cwd: the directory to run the process in, or None for no change.
+            decode_signal (bool): True to indicate the exception number when
+                something goes wrong
 
         Returns:
             Nothing.
         """
-
+        self.decode_signal = decode_signal
         self.waited = False
         self.exit_code = 0
         self.exit_info = ''
@@ -197,12 +199,12 @@ class Spawn:
                     # With sandbox, try to detect when U-Boot exits when it
                     # shouldn't and explain why. This is much more friendly than
                     # just dying with an I/O error
-                    if err.errno == 5:  # Input/output error
+                    if self.decode_signal and err.errno == 5:  # I/O error
                         alive, _, info = self.checkalive()
                         if alive:
                             raise err
                         raise ValueError('U-Boot exited with %s' % info)
-                    raise err
+                    raise
                 if self.logfile_read:
                     self.logfile_read.write(c)
                 self.buf += c