Ejemplo n.º 1
0
 def test1000EntriesValidate(self):
     mounts = list(mount.iterMounts())
     for entry in mounts:
         mountpoint = entry.fs_file
         if mountpoint.startswith('/mnt/loop'):
             expected_spec = ('/images/loop%s.img' %
                              mountpoint[len('/mnt/loop'):])
             self.assertEquals(entry.fs_spec, expected_spec)
Ejemplo n.º 2
0
 def test1000EntriesValidate(self):
     mounts = list(mount.iterMounts())
     for entry in mounts:
         mountpoint = entry.fs_file
         if mountpoint.startswith('/mnt/loop'):
             expected_spec = ('/images/loop%s.img' %
                              mountpoint[len('/mnt/loop'):])
             self.assertEquals(entry.fs_spec, expected_spec)
Ejemplo n.º 3
0
    def testLookupWipe(self):
        with open(mount._PROC_MOUNTS_PATH) as f:
            old_mounts = f.read()
        with open(mount._ETC_MTAB_PATH) as f:
            old_mtab = f.read()

        self.assertEquals(len(list(mount.iterMounts())), 1100)
        mounts_mnt = mount.MountRecord('/dev/loop10001',
                                       '/mnt/loop10001',
                                       'xfs',
                                       'rw,foobar,errors=continue',
                                       '0', '0')
        mtab_mnt = mount.MountRecord('/images/loop10001.img',
                                     '/mnt/loop%d',
                                     'xfs',
                                     'rw,loop=/dev/loop10001',
                                     '0', '0')

        with open(mount._PROC_MOUNTS_PATH, 'a') as f:
            f.write(self.line_fmt % mounts_mnt._asdict())
        with open(mount._ETC_MTAB_PATH, 'a') as f:
            f.write(self.line_fmt % mtab_mnt._asdict())

        self.assertEquals(len(list(mount.iterMounts())), 1101)
        self.assertEquals(
            len(filter(lambda x: x.fs_spec == '/images/loop10001.img',
                       mount.iterMounts())),
            1)
        self.assertTrue('/dev/loop10001' in mount._getLoopFsSpecs())

        with open(mount._PROC_MOUNTS_PATH, 'w') as f:
            f.write(old_mounts)
        with open(mount._ETC_MTAB_PATH, 'w') as f:
            f.write(old_mtab)

        self.assertEquals(len(list(mount.iterMounts())), 1100)
        self.assertEquals(
            len(filter(lambda x: x.fs_spec == '/images/loop10001.img',
                       mount.iterMounts())),
            0)
        self.assertFalse('/dev/loop10001' in mount._getLoopFsSpecs())
Ejemplo n.º 4
0
    def testLookupWipe(self):
        with open(mount._PROC_MOUNTS_PATH) as f:
            old_mounts = f.read()
        with open(mount._ETC_MTAB_PATH) as f:
            old_mtab = f.read()

        self.assertEquals(len(list(mount.iterMounts())), 1100)
        mounts_mnt = mount.MountRecord('/dev/loop10001',
                                       '/mnt/loop10001',
                                       'xfs',
                                       'rw,foobar,errors=continue',
                                       '0', '0')
        mtab_mnt = mount.MountRecord('/images/loop10001.img',
                                     '/mnt/loop%d',
                                     'xfs',
                                     'rw,loop=/dev/loop10001',
                                     '0', '0')

        with open(mount._PROC_MOUNTS_PATH, 'a') as f:
            f.write(self.line_fmt % mounts_mnt._asdict())
        with open(mount._ETC_MTAB_PATH, 'a') as f:
            f.write(self.line_fmt % mtab_mnt._asdict())

        self.assertEquals(len(list(mount.iterMounts())), 1101)
        self.assertEquals(
            len(filter(lambda x: x.fs_spec == '/images/loop10001.img',
                       mount.iterMounts())),
            1)
        self.assertTrue('/dev/loop10001' in mount._getLoopFsSpecs())

        with open(mount._PROC_MOUNTS_PATH, 'w') as f:
            f.write(old_mounts)
        with open(mount._ETC_MTAB_PATH, 'w') as f:
            f.write(old_mtab)

        self.assertEquals(len(list(mount.iterMounts())), 1100)
        self.assertEquals(
            len(filter(lambda x: x.fs_spec == '/images/loop10001.img',
                       mount.iterMounts())),
            0)
        self.assertFalse('/dev/loop10001' in mount._getLoopFsSpecs())
Ejemplo n.º 5
0
 def test1000EntriesTwice(self):
     list(mount.iterMounts())
     list(mount.iterMounts())
Ejemplo n.º 6
0
 def test1000EntriesTwice(self):
     list(mount.iterMounts())
     list(mount.iterMounts())