[U-Boot] [PATCH 6/8] test/py: add various utility code
Stephen Warren
swarren at wwwdotorg.org
Fri Jan 22 17:45:13 CET 2016
On 01/21/2016 08:36 PM, Simon Glass wrote:
> Hi Stephen,
>
> On 20 January 2016 at 15:15, Stephen Warren <swarren at wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren at nvidia.com>
>>
>> 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 at nvidia.com>
>> ---
>> 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 <sjg at chromium.org>
>
>> 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).
More information about the U-Boot
mailing list