testing/infra/emulator: allow to specify pexpect timeout
authorAndrey Smirnov <andrew.smirnov@gmail.com>
Wed, 12 Jul 2017 02:40:04 +0000 (19:40 -0700)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sat, 22 Jul 2017 20:37:06 +0000 (22:37 +0200)
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>
Tested-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
support/testing/infra/emulator.py

index a39d59b88129e586b218b1632c17281e5caad60d..9b079cbf237dfc5b41fe2594bead4d5ba11ab2d7 100644 (file)
@@ -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:]