From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 22 Jan 2016 09:45:13 -0700 Subject: [U-Boot] [PATCH 6/8] test/py: add various utility code In-Reply-To: References: <1453328158-23818-1-git-send-email-swarren@wwwdotorg.org> <1453328158-23818-6-git-send-email-swarren@wwwdotorg.org> Message-ID: <56A25C99.2080902@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/21/2016 08:36 PM, Simon Glass wrote: > Hi Stephen, > > On 20 January 2016 at 15:15, Stephen Warren wrote: >> From: Stephen Warren >> >> 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 >> --- >> test/py/u_boot_console_base.py | 19 +++++ >> test/py/u_boot_utils.py | 171 +++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 190 insertions(+) >> create mode 100644 test/py/u_boot_utils.py > > Acked-by: Simon Glass > >> diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py >> index 433bec6e9fdd..06f61f987180 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. > > I meant to say we should use """ for function comments to keep it > consistent with the rest of U-Boot. Maybe could adjust this in a > follow-on patch? That feels inconsistent with using ' for strings everywhere else. I don't see a good reason why the docstrings should use a different quote character. Should the existing Python code be made consistent instead? >> + >> + 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]) > > Does this potentially wait forever? The expect() function throws a Timeout exception if none of the strings/regexs passed to it match within the defined timeout (which is stored in self.p.timeout).