diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 9b36eb01de..53a4a5f0fb 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -217,9 +217,12 @@ def fly_ArduPlane(viewerip=None): # start fgear if os.getenv('DISPLAY'): cmd = 'fgfs %s' % fgear_options + fgear = pexpect.spawn(cmd, logfile=sys.stdout, timeout=10) else: - cmd = "xvfb-run -s '-screen 0 800x600x24' fgfs --enable-wireframe %s" % fgear_options - fgear = pexpect.spawn(cmd, logfile=sys.stdout, timeout=10) + cmd = "xvfb-run --server-num=42 -s '-screen 0 800x600x24' fgfs --enable-wireframe %s" % fgear_options + util.kill_xvfb(42) + fgear = pexpect.spawn(cmd, logfile=sys.stdout, timeout=10) + fgear.xvfb_server_num = 42 util.pexpect_autoclose(fgear) expect_list.extend([fgear, sil, mavproxy]) diff --git a/Tools/autotest/autotest.py b/Tools/autotest/autotest.py index 5af98520cc..c3f6122e76 100755 --- a/Tools/autotest/autotest.py +++ b/Tools/autotest/autotest.py @@ -94,8 +94,8 @@ steps = [ 'build2560.ArduPlane', 'build.ArduPlane', 'defaults.ArduPlane', - 'logs.ArduPlane', 'fly.ArduPlane', + 'logs.ArduPlane', 'build1280.ArduCopter', 'build2560.ArduCopter', 'build.ArduCopter', diff --git a/Tools/autotest/util.py b/Tools/autotest/util.py index ffa995ea1e..7c1d42df2f 100644 --- a/Tools/autotest/util.py +++ b/Tools/autotest/util.py @@ -73,6 +73,10 @@ def pexpect_autoclose(p): def pexpect_close(p): '''close a pexpect child''' global close_list + + xvfb_server_num = getattr(p, 'xvfb_server_num', None) + if xvfb_server_num is not None: + kill_xvfb(xvfb_server_num) try: p.close() except Exception: @@ -89,12 +93,7 @@ def pexpect_close_all(): '''close all pexpect children''' global close_list for p in close_list[:]: - try: - p.close() - time.sleep(1) - p.close(Force=True) - except Exception: - pass + pexpect_close(p) def start_SIL(atype, valgrind=False, wipe=False, CLI=False): '''launch a SIL instance''' @@ -177,3 +176,13 @@ def lock_file(fname): except Exception: return None return f + +def kill_xvfb(server_num): + '''Xvfb is tricky to kill!''' + try: + import signal + pid = int(open('/tmp/.X%s-lock' % server_num).read().strip()) + print("Killing Xvfb process %u" % pid) + os.kill(pid, signal.SIGINT) + except Exception, msg: + print("failed to kill Xvfb process - %s" % msg)