aboutsummaryrefslogtreecommitdiff
path: root/support/testing/infra/emulator.py
diff options
context:
space:
mode:
authorGravatar Ricardo Martincoski <ricardo.martincoski@gmail.com>2017-08-04 23:05:19 -0300
committerGravatar Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>2017-08-10 10:08:06 +0200
commit6e45e33f27d5ae6fa0ab5aad3f032d886a886037 (patch)
tree14dc7955a31e639ceabd20c59399765162842355 /support/testing/infra/emulator.py
parent128a16aceeb43d7d22b10c6845f7c4d09439e031 (diff)
downloadbuildroot-6e45e33f27d5ae6fa0ab5aad3f032d886a886037.tar.gz
buildroot-6e45e33f27d5ae6fa0ab5aad3f032d886a886037.tar.bz2
support/testing: allow to use a multiplier for timeouts
Add a parameter to run-tests to act as a multiplier for all timeouts of emulator. It can be used to avoid sporadic failures on slow host machines as well in elastic runners on the cloud. Cc: Arnout Vandecappelle <arnout@mind.be> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> [Arnout: rename multiplier to timeout_multiplier everywhere] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Diffstat (limited to 'support/testing/infra/emulator.py')
-rw-r--r--support/testing/infra/emulator.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/support/testing/infra/emulator.py b/support/testing/infra/emulator.py
index 588a92f6a2..802e89d4b4 100644
--- a/support/testing/infra/emulator.py
+++ b/support/testing/infra/emulator.py
@@ -5,10 +5,14 @@ import infra
class Emulator(object):
- def __init__(self, builddir, downloaddir, logtofile):
+ def __init__(self, builddir, downloaddir, logtofile, timeout_multiplier):
self.qemu = None
self.downloaddir = downloaddir
self.logfile = infra.open_log_file(builddir, "run", logtofile)
+ # We use elastic runners on the cloud to runs our tests. Those runners
+ # can take a long time to run the emulator. Use a timeout multiplier
+ # when running the tests to avoid sporadic failures.
+ self.timeout_multiplier = timeout_multiplier
# Start Qemu to boot the system
#
@@ -65,7 +69,8 @@ class Emulator(object):
qemu_cmd += ["-append", " ".join(kernel_cmdline)]
self.logfile.write("> starting qemu with '%s'\n" % " ".join(qemu_cmd))
- self.qemu = pexpect.spawn(qemu_cmd[0], qemu_cmd[1:], timeout=5,
+ self.qemu = pexpect.spawn(qemu_cmd[0], qemu_cmd[1:],
+ timeout=5 * self.timeout_multiplier,
env={"QEMU_AUDIO_DRV": "none"})
# We want only stdout into the log to avoid double echo
self.qemu.logfile_read = self.logfile
@@ -76,7 +81,7 @@ class Emulator(object):
# The login prompt can take some time to appear when running multiple
# instances in parallel, so set the timeout to a large value
index = self.qemu.expect(["buildroot login:", pexpect.TIMEOUT],
- timeout=60)
+ timeout=60 * self.timeout_multiplier)
if index != 0:
self.logfile.write("==> System does not boot")
raise SystemError("System does not boot")
@@ -94,6 +99,8 @@ class Emulator(object):
# return a tuple (output, exit_code)
def run(self, cmd, timeout=-1):
self.qemu.sendline(cmd)
+ if timeout != -1:
+ timeout *= self.timeout_multiplier
self.qemu.expect("# ", timeout=timeout)
# Remove double carriage return from qemu stdout so str.splitlines()
# works as expected.