Beispiel #1
0
 def loop_context_test(self):
     """Test the LoopDev context manager (requires loop)"""
     with tempfile.NamedTemporaryFile(prefix="lorax.test.disk.") as disk_img:
         mksparse(disk_img.name, 42 * 1024**2)
         with LoopDev(disk_img.name) as loop_dev:
             self.assertTrue(loop_dev is not None)
             self.assertEqual(loop_dev[5:], get_loop_name(disk_img.name))
Beispiel #2
0
 def dmdev_test(self):
     """Test the DMDev context manager (requires device-mapper support)"""
     with tempfile.NamedTemporaryFile(prefix="lorax.test.disk.") as disk_img:
         mksparse(disk_img.name, 42 * 1024**2)
         with LoopDev(disk_img.name) as loop_dev:
             self.assertTrue(loop_dev  is not None)
             with DMDev(loop_dev, 42 * 1024**2) as dm_name:
                 self.assertTrue(dm_name is not None)
Beispiel #3
0
 def mount_test(self):
     """Test the Mount context manager (requires loop)"""
     with tempfile.NamedTemporaryFile(prefix="lorax.test.disk.") as disk_img:
         mksparse(disk_img.name, 42 * 1024**2)
         runcmd(["mkfs.ext4", "-L", "Anaconda", "-b", "4096", "-m", "0", disk_img.name])
         with LoopDev(disk_img.name) as loopdev:
             self.assertTrue(loopdev is not None)
             with Mount(loopdev) as mnt:
                 self.assertTrue(mnt is not None)
Beispiel #4
0
 def dm_test(self):
     """Test the dm_* functions (requires device-mapper support)"""
     with tempfile.NamedTemporaryFile(prefix="lorax.test.disk.") as disk_img:
         mksparse(disk_img.name, 42 * 1024**2)
         with LoopDev(disk_img.name) as loop_dev:
             self.assertTrue(loop_dev  is not None)
             dm_name = dm_attach(loop_dev, 42 * 1024**2)
             try:
                 self.assertTrue(dm_name is not None)
             finally:
                 dm_detach(dm_name)