summaryrefslogtreecommitdiff
path: root/test/py/u_boot_console_base.py
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2016-01-22 12:30:12 -0700
committerSimon Glass <sjg@chromium.org>2016-01-28 21:01:23 -0700
commit76b4693928920d7c30fa935b3c46a02b637a29e1 (patch)
tree4959a04a3f568044d768d25d71c806e801e9fb92 /test/py/u_boot_console_base.py
parent3f2faf7327ae7cf1a78097a8089f91e3f2aa8652 (diff)
test/py: add various utility code
Add various common utility functions. These will be used by a forthcoming re-written UMS test, and a brand-new DFU test. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
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 433bec6e9fd..06f61f98718 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.