예제 #1
0
    def test_injectFilesToFs_wrongfs(self):
        """
        Tests for failure mkimage.injectFilesToFs when wrong fstype is
        specified. Requires root permissions for mounting the image.
        """
        floppy = mkimage.getFileName("vmId_inject", self.files)
        command = [EXT_MKFS_MSDOS, '-C', floppy, '1440']
        try:
            rc, out, err = execCmd(command, raw=True)

            with self.assertRaises(MountError):
                mkimage.injectFilesToFs(floppy, self.files, 'ext3')
        finally:
            rm_file(floppy)
예제 #2
0
    def test_injectFilesToFs(self, fstype):
        """
        Tests mkimage.injectFilesToFs creating an image and checking its
        content. Requires root permissions for writing into the floppy image.
        """
        floppy = mkimage.getFileName("vmId_inject", self.files)
        command = [EXT_MKFS_MSDOS, '-C', floppy, '1440']
        try:
            rc, out, err = execCmd(command, raw=True)

            mkimage.injectFilesToFs(floppy, self.files, fstype)

            self.assertTrue(os.path.exists(floppy))
            m = mount.Mount(floppy, self.workdir)
            m.mount(mntOpts='loop')
            try:
                self._check_content(checkPerms=False)
            finally:
                m.umount()
        finally:
            rm_file(floppy)