]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
test/py: Provide a way to get early console output
authorSimon Glass <sjg@chromium.org>
Mon, 4 Jul 2016 17:58:39 +0000 (11:58 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 15 Jul 2016 02:40:24 +0000 (20:40 -0600)
Some tests want to check the console output from SPL or U-Boot proper.
Provide a means to do this.

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

index 2dcb2894f96242902ceb897accada97622025f5d..3d2ac448757d59906135ab7e644eacd7f8801be4 100644 (file)
@@ -377,6 +377,16 @@ class ConsoleBase(object):
             pass
         self.p = None
 
+    def get_spawn_output(self):
+        """Return the start-up output from U-Boot
+
+        Returns:
+            The output produced by ensure_spawed(), as a string.
+        """
+        if self.p:
+            return self.p.get_expect_output()
+        return None
+
     def validate_version_string_in_text(self, text):
         """Assert that a command's output includes the U-Boot signon message.
 
index d15517389e510fa8ddd7d96cfa5dd4b73f86e285..3a0fbfad90f25b39aad147d046ee4d2a2c0d085b 100644 (file)
@@ -18,6 +18,9 @@ class Timeout(Exception):
 class Spawn(object):
     """Represents the stdio of a freshly created sub-process. Commands may be
     sent to the process, and responses waited for.
+
+    Members:
+        output: accumulated output from expect()
     """
 
     def __init__(self, args, cwd=None):
@@ -34,6 +37,7 @@ class Spawn(object):
 
         self.waited = False
         self.buf = ''
+        self.output = ''
         self.logfile_read = None
         self.before = ''
         self.after = ''
@@ -154,6 +158,7 @@ class Spawn(object):
                     posafter = earliest_m.end()
                     self.before = self.buf[:pos]
                     self.after = self.buf[pos:posafter]
+                    self.output += self.buf[:posafter]
                     self.buf = self.buf[posafter:]
                     return earliest_pi
                 tnow_s = time.time()
@@ -198,3 +203,11 @@ class Spawn(object):
             if not self.isalive():
                 break
             time.sleep(0.1)
+
+    def get_expect_output(self):
+        """Return the output read by expect()
+
+        Returns:
+            The output processed by expect(), as a string.
+        """
+        return self.output