mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 05:36:32 +00:00
testing/infra/emulator: allow to specify pexpect timeout
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>
This commit is contained in:
parent
5a8484dec2
commit
255b8ab406
@ -89,11 +89,11 @@ class Emulator(object):
|
|||||||
raise SystemError("Cannot login")
|
raise SystemError("Cannot login")
|
||||||
self.run("dmesg -n 1")
|
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)
|
# return a tuple (output, exit_code)
|
||||||
def run(self, cmd):
|
def run(self, cmd, timeout=-1):
|
||||||
self.qemu.sendline(cmd)
|
self.qemu.sendline(cmd)
|
||||||
self.qemu.expect("# ")
|
self.qemu.expect("# ", timeout=timeout)
|
||||||
# Remove double carriage return from qemu stdout so str.splitlines()
|
# Remove double carriage return from qemu stdout so str.splitlines()
|
||||||
# works as expected.
|
# works as expected.
|
||||||
output = self.qemu.before.replace("\r\r", "\r").splitlines()[1:]
|
output = self.qemu.before.replace("\r\r", "\r").splitlines()[1:]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user