[gvfs] test: Wait for smbd to open its port before starting the test
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] test: Wait for smbd to open its port before starting the test
- Date: Tue, 3 Feb 2015 22:16:11 +0000 (UTC)
commit 221378f58f50bdf6e780e668539e875bac581826
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Mon Feb 2 22:41:48 2015 +0000
test: Wait for smbd to open its port before starting the test
Use ss -ltn and look for port 1445 to wait for smbd to be ready before
proceeding with the test. This fixes test failures on slow machines
where smbd takes a while to start.
https://bugzilla.gnome.org/show_bug.cgi?id=742169
test/gvfs-test | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/test/gvfs-test b/test/gvfs-test
index 0e270cb..ef39e03 100755
--- a/test/gvfs-test
+++ b/test/gvfs-test
@@ -66,6 +66,8 @@ local_ip = subprocess.check_output("ip -4 addr | sed -nr '/127\.0\.0/ n; "
"/inet / { s/^.*inet ([0-9.]+).*$/\\1/; p; q }'",
shell=True, universal_newlines=True)
+SMB_USER_PORT = 1445
+
# when running in the build tree, check whether Dav backend is enabled
have_dav_backend = True
if 'GVFS_MOUNTABLE_DIR' in os.environ:
@@ -760,7 +762,7 @@ class Smb(GvfsTestCase):
f.write('''[global]
workgroup = TESTGROUP
interfaces = lo 127.0.0.0/8
-smb ports = 1445
+smb ports = %(port)d
log level = 2
map to guest = Bad User
passdb backend = smbpasswd
@@ -779,13 +781,25 @@ ncalrpc dir = %(workdir)s/samba
[private]
path = %(workdir)s/private
read only = no
-''' % {'workdir': self.workdir})
+''' % {'workdir': self.workdir,
+ 'port': SMB_USER_PORT})
# start smbd
self.smbd = subprocess.Popen(['smbd', '-FS', '-s', smbconf],
universal_newlines=True,
stdout=subprocess.PIPE)
- time.sleep(1)
+
+ timeout = 50
+ while timeout > 0:
+ (out, err) = self.program_out_err(['ss', '-ltn'])
+ if (':%d ' % SMB_USER_PORT) in out:
+ break
+ timeout -= 1
+ time.sleep(0.1)
+ else:
+ self.smbd.terminate()
+ self.smbd.wait()
+ self.fail('starting smbd failed')
def tearDown(self):
# stop smbd
@@ -1755,7 +1769,7 @@ def start_dbus():
env['GVFS_SMB_DEBUG'] = '10'
env['GVFS_HTTP_DEBUG'] = 'all'
if not in_testbed:
- env['LIBSMB_PROG'] = "nc localhost 1445"
+ env['LIBSMB_PROG'] = "nc localhost %d" % SMB_USER_PORT
# run local D-BUS; if we run this in a built tree, use our config to pick
# up the built services, otherwise the standard session one
if os.path.exists(dbus_conf):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]