[v2,1/6] testing/infra/emulator: allow to specify pexpect timeout

Submitted by Andrey Smirnov on July 12, 2017, 2:40 a.m.

Details

Message ID 20170712024009.2366-2-andrew.smirnov@gmail.com
State Accepted
Headers show

Commit Message

Andrey Smirnov July 12, 2017, 2:40 a.m.
Some commands take more than 5 seconds to complete under QEMU, so add
provisions to allow individual unit-test to specify different duration
to avoid false negative test failures.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 support/testing/infra/emulator.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ricardo Martincoski July 15, 2017, 4:21 a.m.
Hello,

On Tue, Jul 11, 2017 at 11:40 PM, Andrey Smirnov wrote:

> Some commands take more than 5 seconds to complete under QEMU, so add
> provisions to allow individual unit-test to specify different duration
> to avoid false negative test failures.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>

Reviewed-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[I executed all tests in the current master with this patch]
Tested-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>

[snip]
> -    def run(self, cmd):
> +    def run(self, cmd, timeout=-1):

Indeed.
From the docs: "When the keyword argument timeout is -1 (default), then TIMEOUT
will raise after the default value specified by the class timeout attribute."

Regards,
Ricardo
Thomas Petazzoni July 22, 2017, 8:39 p.m.
Hello,

On Tue, 11 Jul 2017 19:40:04 -0700, Andrey Smirnov wrote:
> Some commands take more than 5 seconds to complete under QEMU, so add
> provisions to allow individual unit-test to specify different duration
> to avoid false negative test failures.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  support/testing/infra/emulator.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Applied to master, thanks.

Thomas

Patch hide | download patch | download mbox

diff --git a/support/testing/infra/emulator.py b/support/testing/infra/emulator.py
index a39d59b..9b079cb 100644
--- a/support/testing/infra/emulator.py
+++ b/support/testing/infra/emulator.py
@@ -89,11 +89,11 @@  class Emulator(object):
             raise SystemError("Cannot login")
         self.run("dmesg -n 1")
 
-    # Run the given 'cmd' on the target
+    # Run the given 'cmd' with a 'timeout' on the target
     # return a tuple (output, exit_code)
-    def run(self, cmd):
+    def run(self, cmd, timeout=-1):
         self.qemu.sendline(cmd)
-        self.qemu.expect("# ")
+        self.qemu.expect("# ", timeout=timeout)
         # Remove double carriage return from qemu stdout so str.splitlines()
         # works as expected.
         output = self.qemu.before.replace("\r\r", "\r").splitlines()[1:]