]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fuse_a: runtests.py: The current ubuntu python-fuse ignores the -f option and always...
authornejucomo <nejucomo@gmail.com>
Sun, 1 Jun 2008 03:16:05 +0000 (20:16 -0700)
committernejucomo <nejucomo@gmail.com>
Sun, 1 Jun 2008 03:16:05 +0000 (20:16 -0700)
contrib/fuse_a/runtests.py

index 40c5a7d94260e8e02c12b28451af57740271a0a7..a2548a60ab924ec4cd7ef69dd1bde6e6b237c917 100644 (file)
@@ -207,7 +207,7 @@ class SystemTest (object):
 
         return self.mount_fuse_layer(cap)
         
-    def mount_fuse_layer(self, fusebasecap, fusepause=2.0):
+    def mount_fuse_layer(self, fusebasecap):
         print 'Mounting fuse interface.'
 
         mp = os.path.join(self.testroot, 'mountpoint')
@@ -216,29 +216,38 @@ class SystemTest (object):
         thispath = os.path.abspath(sys.argv[0])
         thisdir = os.path.dirname(thispath)
         fusescript = os.path.join(thisdir, 'tahoe_fuse.py')
-        proc = None
-        try:
-            proc = subprocess.Popen(['python',
-                                     fusescript,
-                                     mp,
-                                     '-f',
-                                     '--basedir', self.clientbase])
 
-            # The mount is verified by the test_layer, but we sleep to
-            # avoid race conditions against the first few tests.
-            time.sleep(fusepause)
+        # Even though --help says -f means "foreground operation",
+        # my version (ubuntu's python-fuse 1:0.2-pre3-3) still forks to
+        # the background...  So now we run tahoe_fuse.py and wait for
+        # the parent process to return.  We use fusermount -u to kill
+        # the forked daemon and unmount the test directory.
+
+        exitcode, output = gather_output(['python',
+                                          fusescript,
+                                          mp,
+                                          '--basedir', self.clientbase])
+
+        if exitcode != 0 or output:
+            tmpl = 'tahoe_fuse.py failed to launch:\n'
+            tmpl += 'Exit Status: %r\n'
+            tmpl += 'Output:\n%s\n'
+            raise self.SetupFailure(tmpl, exitcode, output)
 
+        try:
             return self.run_test_layer(fusebasecap, mp)
                 
         finally:
-            print '\n*** Cleaning up system test'
+            print '\n*** Cleaning fuse mount and daemon process'
+            args = ['fusermount', '-u', mp]
+            ec, out = gather_output(args)
+            if exitcode != 0 or output:
+                tmpl = 'fusermount failed to unmount tahoe_fuse.py:\n'
+                tmpl += 'Arguments: %r\n'
+                tmpl += 'Exit Status: %r\n'
+                tmpl += 'Output:\n%s\n'
+                raise self.SetupFailure(tmpl, args, ec, out)
 
-            if proc is not None and proc.poll() is None:
-                print 'Killing fuse interface.'
-                os.kill(proc.pid, signal.SIGTERM)
-                print 'Waiting for the fuse interface to exit.'
-                proc.wait()
-            
     def run_test_layer(self, fbcap, mountpoint):
         total = failures = 0
         for name in sorted(dir(self)):