testsuite: Test forced removal of standard devices
authorMartin Pitt <martin.pitt@ubuntu.com>
Sun, 24 Oct 2010 13:48:51 +0000 (09:48 -0400)
committerMartin Pitt <martin.pitt@ubuntu.com>
Sun, 24 Oct 2010 13:48:51 +0000 (09:48 -0400)
Corresponding to the previous test for forced removal of LUKS encrypted
devices, also test handling of forced removal for plain unencrypted devices.

tests/run

index 030b880..725d254 100755 (executable)
--- a/tests/run
+++ b/tests/run
@@ -508,6 +508,34 @@ class FS(UDisksTestCase):
         '''fs: nilfs2'''
         self._do_fs_check('nilfs2')
 
+    def test_force_removal(self):
+        '''fs: forced removal'''
+
+        # create a fs and mount it
+        self.fs_create(None, 'ext4', ['label=udiskstest'])
+        mount_path = self.partition_iface().FilesystemMount('', [])
+        self.assertEqual(mount_path, '/media/udiskstest')
+
+        # removal should clean up mounts
+        self.remove_device(self.device)
+        self.failIf(os.path.exists(mount_path))
+        self.failIf(self.device in self.manager_iface.EnumerateDeviceFiles())
+        props = self.partition_props()
+        self.assertRaises(dbus.DBusException, props.Get, I_D, 'DeviceIsPartition')
+
+        # after putting it back, it should be mountable again
+        self.readd_devices()
+        self.assert_(self.device in self.manager_iface.EnumerateDeviceFiles())
+        props = self.partition_props()
+        self.assertEqual(props.Get(I_D, 'DeviceIsPartition'), False)
+        self.assertEqual(props.Get(I_D, 'DeviceIsMounted'), False)
+
+        mount_path = self.partition_iface().FilesystemMount('', [])
+        self.assertEqual(mount_path, '/media/udiskstest')
+        self.assertEqual(props.Get(I_D, 'DeviceIsMounted'), True)
+
+        self.retry_busy(self.partition_iface().FilesystemUnmount, [])
+
     def _do_fs_check(self, type):
         '''Run checks for a particular file system.'''