diff mbox

[U-Boot,v3,59/62] test/py: Provide a way to get early console output

Message ID 1467655123-29441-60-git-send-email-sjg@chromium.org
State Accepted
Commit ebec58fbcb6da7404b535b9d860546d9baef55c2
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass July 4, 2016, 5:58 p.m. UTC
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>
---

Changes in v3:
- Add new patch to provide a way to get early console output

Changes in v2: None

 test/py/u_boot_console_base.py | 10 ++++++++++
 test/py/u_boot_spawn.py        | 13 +++++++++++++
 2 files changed, 23 insertions(+)

Comments

Simon Glass July 15, 2016, 4 a.m. UTC | #1
On 4 July 2016 at 11:58, Simon Glass <sjg@chromium.org> wrote:
> 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>
> ---
>
> Changes in v3:
> - Add new patch to provide a way to get early console output
>
> Changes in v2: None
>
>  test/py/u_boot_console_base.py | 10 ++++++++++
>  test/py/u_boot_spawn.py        | 13 +++++++++++++
>  2 files changed, 23 insertions(+)

Applied to u-boot-dm
diff mbox

Patch

diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index c2c45e7..4606ad4 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -393,6 +393,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.
 
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index a5f4a8e..e330969 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -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 = ''
@@ -149,6 +153,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()
@@ -189,3 +194,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