5 from integration_test import IntegrationTest
7 class UnmountTest(IntegrationTest):
9 super(UnmountTest, self).setUp()
14 for d in self.to_delete:
16 super(UnmountTest, self).tearDown()
18 def test_replace(self):
19 subprocess.check_call(
20 ['./bin/arv-mount', '--subtype', 'test', '--replace',
22 subprocess.check_call(
23 ['./bin/arv-mount', '--subtype', 'test', '--replace',
24 '--unmount-timeout', '10',
26 subprocess.check_call(
27 ['./bin/arv-mount', '--subtype', 'test', '--replace',
28 '--unmount-timeout', '10',
31 for m in subprocess.check_output(['mount']).splitlines():
32 self.assertNotIn(' '+self.mnt+' ', m)
34 def _mounted(self, mounts):
35 all_mounts = subprocess.check_output(['mount'])
36 return [m for m in mounts
37 if ' '+m+' ' in all_mounts]
39 def _wait_for_mounts(self, mounts):
40 deadline = time.time() + 10
41 while self._mounted(mounts) != mounts:
43 self.assertLess(time.time(), deadline)
45 def test_unmount_subtype(self):
47 for d in ['foo', 'bar']:
50 self.to_delete.insert(0, mnt)
52 subprocess.check_call(
53 ['./bin/arv-mount', '--subtype', d, mnt])
55 self._wait_for_mounts(mounts)
56 self.assertEqual(mounts, self._mounted(mounts))
57 subprocess.call(['./bin/arv-mount', '--subtype', 'baz', '--unmount-all', self.tmp])
58 self.assertEqual(mounts, self._mounted(mounts))
59 subprocess.call(['./bin/arv-mount', '--subtype', 'bar', '--unmount', mounts[0]])
60 self.assertEqual(mounts, self._mounted(mounts))
61 subprocess.call(['./bin/arv-mount', '--subtype', '', '--unmount', self.tmp])
62 self.assertEqual(mounts, self._mounted(mounts))
63 subprocess.check_call(['./bin/arv-mount', '--subtype', 'foo', '--unmount', mounts[0]])
64 self.assertEqual(mounts[1:], self._mounted(mounts))
65 subprocess.check_call(['./bin/arv-mount', '--subtype', '', '--unmount-all', mounts[0]])
66 self.assertEqual(mounts[1:], self._mounted(mounts))
67 subprocess.check_call(['./bin/arv-mount', '--subtype', 'bar', '--unmount-all', self.tmp])
68 self.assertEqual([], self._mounted(mounts))
70 def test_unmount_children(self):
71 for d in ['foo', 'foo/bar', 'bar']:
74 self.to_delete.insert(0, mnt)
76 for d in ['bar', 'foo/bar']:
79 subprocess.check_call(
80 ['./bin/arv-mount', '--subtype', 'test', mnt])
82 self._wait_for_mounts(mounts)
83 self.assertEqual(mounts, self._mounted(mounts))
84 subprocess.check_call(['./bin/arv-mount', '--unmount', self.tmp])
85 self.assertEqual(mounts, self._mounted(mounts))
86 subprocess.check_call(['./bin/arv-mount', '--unmount-all', self.tmp])
87 self.assertEqual([], self._mounted(mounts))