[gvfs] tests: Fix race condition in FTP server setup
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] tests: Fix race condition in FTP server setup
- Date: Thu, 15 May 2014 09:20:57 +0000 (UTC)
commit 2f83f3a4f883e33cf44e4a53549e26def7f5953d
Author: Martin Pitt <martin pitt ubuntu com>
Date: Thu May 15 11:18:37 2014 +0200
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.
test/gvfs-test | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/test/gvfs-test b/test/gvfs-test
index 911ace3..623743f 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'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]