From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] test/py: Support setting up specific timeout
Date: Wed, 18 May 2016 16:55:21 +0200 [thread overview]
Message-ID: <573C8259.50705@xilinx.com> (raw)
In-Reply-To: <573C75F5.6040708@monstr.eu>
On 18.5.2016 16:02, Michal Simek wrote:
> On 18.5.2016 15:11, Michal Simek wrote:
>> Large file transfers, flash erasing and more complicated tests
>> requires more time to finish. Provide a way to setup specific
>> timeout directly in test.
>>
>> For example description for 50s test:
>> timeout = 50000
>> with u_boot_console.temporary_timeout(timeout):
>> u_boot_console.run_command(...)
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> test/py/u_boot_console_base.py | 33 +++++++++++++++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>>
>> diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
>> index f7434363fbcb..82bbba43463e 100644
>> --- a/test/py/u_boot_console_base.py
>> +++ b/test/py/u_boot_console_base.py
>> @@ -56,6 +56,24 @@ class ConsoleDisableCheck(object):
>> self.console.disable_check_count[self.check_type] -= 1
>> self.console.eval_bad_patterns()
>>
>> +
>> +class ConsoleSetupTimeout(object):
>> + """Context manager (for Python's with statement) that temporarily setup
>> + timeout for specific comnand. This is useful when execution time is greater
>> + then default 30s."""
>> +
>> + def __init__(self, console, timeout):
>> + self.console = console
>> + self.console.orig_timeout = self.console.p.timeout
>> + self.console.p.timeout = timeout
>> +
>> + def __enter__(self):
>> + return self
>> +
>> + def __exit__(self, extype, value, traceback):
>> + self.console.p = self.console.get_spawn()
>
> This line should be there. It is resetting console. I will do more
> testing on real hw not on qemu.
>
> Thanks,
> Michal
>
>> + self.console.p.timeout = self.console.orig_timeout
This is also wrong because self.console.p is closed when timeout occurs
which caused exception which calls cleanup_spawn which close p.
This exit should be like this.
def __exit__(self, extype, value, traceback):
if not self.console.p:
return
self.console.p.timeout = self.orig_timeout
Thanks,
Michal
next prev parent reply other threads:[~2016-05-18 14:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-18 13:11 [U-Boot] [PATCH] test/py: Support setting up specific timeout Michal Simek
2016-05-18 14:02 ` Michal Simek
2016-05-18 14:55 ` Michal Simek [this message]
2016-05-18 16:43 ` Stephen Warren
2016-05-18 17:02 ` Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=573C8259.50705@xilinx.com \
--to=michal.simek@xilinx.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox