From 33fee211a41973f3a056a9028c5e94966b62fe76 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 17 Feb 2021 12:58:21 +1100 Subject: [PATCH] autotest: extend pexpect timeouts when running under Valgrind --- Tools/autotest/common.py | 10 +++++++++- Tools/autotest/pysim/util.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index a5a8f0f55a..fb311830b5 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -5273,10 +5273,18 @@ Also, ignores heartbeats not from our target system''' def start_mavproxy(self): self.progress("Starting MAVProxy") + + # determine a good pexpect timeout for reading MAVProxy's + # output; some regmes may require longer timeouts. + pexpect_timeout=60 + if self.valgrind: + pexpect_timeout *= 10 + self.mavproxy = util.start_MAVProxy_SITL( self.vehicleinfo_key(), logfile=self.mavproxy_logfile, - options=self.mavproxy_options()) + options=self.mavproxy_options(), + pexpect_timeout=pexpect_timeout) self.mavproxy.expect('Telemetry log: (\S+)\r\n') self.logfile = self.mavproxy.match.group(1) self.progress("LOGFILE %s" % self.logfile) diff --git a/Tools/autotest/pysim/util.py b/Tools/autotest/pysim/util.py index afe005c417..6c256be974 100644 --- a/Tools/autotest/pysim/util.py +++ b/Tools/autotest/pysim/util.py @@ -431,8 +431,13 @@ def MAVProxy_version(): raise ValueError("Unable to determine MAVProxy version from (%s)" % output) return (int(match.group(1)), int(match.group(2)), int(match.group(3))) -def start_MAVProxy_SITL(atype, aircraft=None, setup=False, master='tcp:127.0.0.1:5762', - options=[], logfile=sys.stdout): +def start_MAVProxy_SITL(atype, + aircraft=None, + setup=False, + master='tcp:127.0.0.1:5762', + options=[], + pexpect_timeout=60, + logfile=sys.stdout): """Launch mavproxy connected to a SITL instance.""" local_mp_modules_dir = os.path.abspath( os.path.join(__file__, '..', '..', '..', 'mavproxy_modules')) @@ -458,7 +463,7 @@ def start_MAVProxy_SITL(atype, aircraft=None, setup=False, master='tcp:127.0.0.1 print("PYTHONPATH: %s" % str(env['PYTHONPATH'])) print("Running: %s" % cmd_as_shell(cmd)) - ret = pexpect.spawn(cmd[0], cmd[1:], logfile=logfile, encoding=ENCODING, timeout=60, env=env) + ret = pexpect.spawn(cmd[0], cmd[1:], logfile=logfile, encoding=ENCODING, timeout=pexpect_timeout, env=env) ret.delaybeforesend = 0 pexpect_autoclose(ret) return ret