summaryrefslogtreecommitdiffstats
path: root/test/py/u_boot_console_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py/u_boot_console_base.py')
-rw-r--r--test/py/u_boot_console_base.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index 433bec6e9f..06f61f9871 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -215,6 +215,25 @@ class ConsoleBase(object):
self.log.action('Sending Ctrl-C')
self.run_command(chr(3), wait_for_echo=False, send_nl=False)
+ def wait_for(self, text):
+ '''Wait for a pattern to be emitted by U-Boot.
+
+ This is useful when a long-running command such as "dfu" is executing,
+ and it periodically emits some text that should show up at a specific
+ location in the log file.
+
+ Args:
+ text: The text to wait for; either a string (containing raw text,
+ not a regular expression) or an re object.
+
+ Returns:
+ Nothing.
+ '''
+
+ if type(text) == type(''):
+ text = re.escape(text)
+ self.p.expect([text])
+
def drain_console(self):
'''Read from and log the U-Boot console for a short time.
OpenPOWER on IntegriCloud