From d5a14503880dd412535bfba1554ddb7d0fb1ba03 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 7 Sep 2012 07:52:51 +0200 Subject: [PATCH] integration-tests: Check handling of existing mount points udisks tracks its mounts in /run/udisks2/mounted-fs, so udisks generated mount points should be reused across daemon restarts, but manually created mount points should not be. See https://bugs.freedesktop.org/show_bug.cgi?id=54487 --- src/tests/integration-test | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/tests/integration-test b/src/tests/integration-test index 17954dc..517b4bf 100755 --- a/src/tests/integration-test +++ b/src/tests/integration-test @@ -734,6 +734,63 @@ class FS(UDisksTestCase): self.client.settle() self.assertEqual(fs.get_property('mount-points'), []) + def test_existing_manual_mount_point(self): + '''fs: does not reuse existing manual mount point''' + + self.mkfs('ext4', 'udiskstest') + fs = self.udisks_filesystem() + + # mount it, determine mount path, and unmount again + mount_path = fs.call_mount_sync(no_options, None) + self.assertTrue(mount_path.endswith('udiskstest')) + + self.retry_busy(fs.call_unmount_sync, no_options, None) + self.client.settle() + self.assertEqual(fs.get_property('mount-points'), []) + + # cleans up mountpoint + self.assertFalse(os.path.exists(mount_path)) + + # now manually create the mount point + os.mkdir(mount_path) + + # now this should use mount_path + '1' + try: + new_mount_path = fs.call_mount_sync(no_options, None) + self.retry_busy(fs.call_unmount_sync, no_options, None) + self.client.settle() + self.assertEqual(fs.get_property('mount-points'), []) + self.assertEqual(new_mount_path, mount_path + '1') + finally: + os.rmdir(mount_path) + + def test_existing_udisks_mount_point(self): + '''fs: reuses existing udisks mount point''' + + self.mkfs('ext4', 'udiskstest') + fs = self.udisks_filesystem() + + # mount it, determine mount path + mount_path = fs.call_mount_sync(no_options, None) + self.assertTrue(mount_path.endswith('udiskstest')) + + # stop the daemon (happens during a package upgrade) + UDisksTestCase.stop_daemon() + + # mount should still be there; unmount it manually + self.assertTrue(self.is_mountpoint(mount_path)) + subprocess.check_call(['umount', mount_path]) + + # restart daemon, mount again; this should use the same mount point as + # before + UDisksTestCase.start_daemon() + fs = self.udisks_filesystem() + new_mount_path = fs.call_mount_sync(no_options, None) + self.retry_busy(fs.call_unmount_sync, no_options, None) + self.client.settle() + self.assertEqual(fs.get_property('mount-points'), []) + self.assertEqual(new_mount_path, mount_path) + def _do_fs_check(self, type): '''Run checks for a particular file system.''' -- 2.7.4