diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2015-03-01 14:55:05 +0100 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2015-03-01 15:34:36 +0100 |
commit | 72838fea395bade4d2a0bd13410478cda27906ef (patch) | |
tree | e057fba91f485ba5d5dc9e435ff00237dec91cb8 | |
parent | 03cd3e8e462e82f46b64d8c62ea64db5f22fa0e5 (diff) |
integration-test: Test fstab parsing
Check that by-device, by-label, and by-UUID mounts respect mount point and
options from fstab.
-rwxr-xr-x | src/tests/integration-test | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/tests/integration-test b/src/tests/integration-test index f69ea7f..c118e5f 100755 --- a/src/tests/integration-test +++ b/src/tests/integration-test @@ -1072,6 +1072,84 @@ class FS(UDisksTestCase): # ---------------------------------------------------------------------------- +class Fstab(UDisksTestCase): + '''Test /etc/fstab custom options''' + + @classmethod + def setUpClass(kls): + kls.orig_fstab = '/etc/fstab.udiskstest' + shutil.copy2('/etc/fstab', kls.orig_fstab) + + # create one partition + subprocess.check_call( + ['parted', '-s', kls.device, 'mklabel', 'gpt'], + stdout=subprocess.PIPE) + subprocess.check_call( + ['parted', '-s', kls.device, 'mkpart', 'primary', '0', '64'], + stdout=subprocess.PIPE) + subprocess.check_call( + ['parted', '-s', kls.device, 'name', '1', 'udtestp1'], + stdout=subprocess.PIPE) + kls.sync() + + kls.mkfs('ext2', partition=1, label='udtestfst') + kls.mountpoint = tempfile.mkdtemp() + kls.block = kls.udisks_block(partition=1) + kls.fs = kls.udisks_filesystem(partition=1) + + @classmethod + def tearDownClass(kls): + os.rmdir(kls.mountpoint) + os.unlink(kls.orig_fstab) + + def tearDown(self): + shutil.copy2(self.orig_fstab, '/etc/fstab') + self.retry_busy(self.fs.call_unmount_sync, no_options, None) + + def test_devname(self): + '''by device name''' + + with open('/etc/fstab', 'a') as f: + f.write('%s %s ext4 defaults,nosuid,noexec 0 0\n' % + (self.devname(partition=1), self.mountpoint)) + os.sync() + self.do_test() + + def test_label(self): + '''by label''' + + with open('/etc/fstab', 'a') as f: + f.write('LABEL=udtestfst %s ext4 defaults,nosuid,noexec 0 0\n' % + self.mountpoint) + os.sync() + self.do_test() + + def test_uuid(self): + '''by UUID''' + + with open('/etc/fstab', 'a') as f: + f.write('UUID=%s %s ext4 defaults,nosuid,noexec 0 0\n' % + (self.block.get_property('id-uuid'), self.mountpoint)) + os.sync() + self.do_test() + + def do_test(self): + self.assertEqual(self.fs.get_property('mount-points'), []) + mount_path = self.fs.call_mount_sync(no_options, None) + self.assertEqual(mount_path, self.mountpoint) + with open('/proc/self/mounts') as f: + for line in f: + if line.startswith(self.devname()): + options = line.split()[3].split(',') + break + else: + self.fail('%s not mounted' % self.devname()) + self.assertIn('noexec', options) + self.assertIn('nosuid', options) + + +# ---------------------------------------------------------------------------- + class Smart(UDisksTestCase): '''Check SMART operation.''' |