fix(smoke): explicitly select known guest filesystems when mounting
This commit is contained in:
@@ -117,3 +117,27 @@ class LaptopSmokeTests(unittest.TestCase):
|
||||
self.assertNotIn('--offline', constants, 'emerge has no --offline option')
|
||||
self.assertIn('--ignore-default-opts', constants)
|
||||
self.assertIn('--nodeps', constants)
|
||||
|
||||
def test_guest_mount_explicitly_selects_known_filesystem(self):
|
||||
namespace = {}
|
||||
exec(self.mod.GUEST_COMMON, namespace)
|
||||
calls = []
|
||||
namespace['run'] = lambda *args: calls.append(args)
|
||||
for device, filesystem, options in (('/dev/vda1', 'vfat', 'ro'),
|
||||
('/dev/vda2', 'ext4', 'ro'),
|
||||
('/dev/vda3', 'btrfs', 'ro,subvol=@root')):
|
||||
with self.subTest(device=device):
|
||||
with namespace['mounted'](device, filesystem, options) as directory:
|
||||
self.assertEqual(calls[-1], ('mount', '-t', filesystem, '-o', options, device, str(directory)))
|
||||
self.assertEqual(calls[-1], ('umount', str(directory)))
|
||||
|
||||
def test_every_guest_mount_call_names_the_partition_filesystem(self):
|
||||
import ast
|
||||
expected = {'/dev/vda1': 'vfat', '/dev/vda2': 'ext4', '/dev/vda3': 'btrfs'}
|
||||
sources = [self.mod.GUEST_COMMON, *self.mod.GUEST_BODIES.values()]
|
||||
for source in sources:
|
||||
for node in ast.walk(ast.parse(source)):
|
||||
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id == 'mounted':
|
||||
with self.subTest(call=ast.unparse(node)):
|
||||
self.assertGreaterEqual(len(node.args), 2)
|
||||
self.assertEqual(ast.literal_eval(node.args[1]), expected[ast.literal_eval(node.args[0])])
|
||||
|
||||
Reference in New Issue
Block a user