diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2014-05-15 11:18:37 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2014-05-15 11:18:37 +0200 |
commit | 2f83f3a4f883e33cf44e4a53549e26def7f5953d (patch) | |
tree | 5b17be03087909668801d00399b29840135242cb /test | |
parent | ee2fec7be7459b67e24b2dcd469ec95baf33f043 (diff) | |
download | gvfs-2f83f3a4f883e33cf44e4a53549e26def7f5953d.tar.gz |
tests: Fix race condition in FTP server setup
Don't sleep for 0.5 seconds but repeatedly ping the FTP server until it is
started up. Time out after 5 s.
Diffstat (limited to 'test')
-rwxr-xr-x | test/gvfs-test | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/gvfs-test b/test/gvfs-test index 911ace38..623743fe 100755 --- a/test/gvfs-test +++ b/test/gvfs-test @@ -33,6 +33,7 @@ import fcntl import re import locale import signal +import socket from glob import glob from gi.repository import GLib, Gio @@ -555,8 +556,18 @@ class Ftp(GvfsTestCase): '-r', self.workdir, '--auth', 'memory:testuser:pwd1'], stdout=subprocess.PIPE) - # give ftp server some time to start up - time.sleep(0.5) + # wait until server is started up + s = socket.socket() + for timeout in range(50): + try: + s.connect(('127.0.0.1', 2121)) + s.close() + break + except ConnectionRefusedError: + time.sleep(0.01) + pass + else: + self.fail('timed out waiting for test FTP server') def tearDown(self): '''Shut down FTP server''' |