summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2013-05-29 12:36:31 +0200
committerMartin Pitt <martinpitt@gnome.org>2013-05-29 12:36:31 +0200
commit5c1843f5905255cbb471fe414a66eeee78102662 (patch)
tree8e81eff5fce9c4eb325ad9cc893aa8e2a278faa2
parentba7981734456b86787777c119821a17e7dbe5737 (diff)
gvfs-test: Avoid deadlocks when waiting for CLI user prompts
Force subprocess' stdout to be non-blocking, so that we do not potentially wait forever, but time out properly.
-rwxr-xr-xtest/gvfs-test7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/gvfs-test b/test/gvfs-test
index e8b14168..00b846af 100755
--- a/test/gvfs-test
+++ b/test/gvfs-test
@@ -174,6 +174,10 @@ class GvfsTestCase(unittest.TestCase):
'''Wait for a gvfs-mount Popen process to show an User auth prompt'''
empty_timeout = 50
+
+ # set stdout to nonblocking
+ flags = fcntl.fcntl(popen.stdout, fcntl.F_GETFL)
+ fcntl.fcntl(popen.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
while True:
r = popen.stdout.read(1000)
#print(' wait_for_gvfs_mount_user_prompt: got "%s"' % str(r))
@@ -185,6 +189,9 @@ class GvfsTestCase(unittest.TestCase):
empty_timeout -= 1
time.sleep(0.1)
+ # restore flags
+ fcntl.fcntl(popen.stdout, fcntl.F_SETFL, flags)
+
def mount_api(self, gfile, mount_op=None):
'''Mount a Gio.File using the Gio API