Exemple #1
0
    def testGetLabelArgs(self):
        self.longMessage = True

        # ReiserFS uses a -l flag
        reiserfs = self.fs["reiserfs"]
        self.assertEqual(reiserfs._labelfs.label_app.setLabelCommand(reiserfs),
                         ["reiserfstune", "-l", "myfs", "/dev"],
                         msg="reiserfs")

        # JFS, XFS use a -L flag
        lflag_classes = [fs.JFS, fs.XFS]
        for name, klass in [(k, v) for k, v in self.fs.items() if any(
                isinstance(v, c) for c in lflag_classes)]:
            self.assertEqual(
                klass._labelfs.label_app.setLabelCommand(v),
                [klass._labelfs.label_app.name, "-L", "myfs", "/dev"],
                msg=name)

        # Ext2FS and descendants and FATFS do not use a flag
        noflag_classes = [fs.Ext2FS, fs.FATFS]
        for name, klass in [(k, v) for k, v in self.fs.items() if any(
                isinstance(v, c) for c in noflag_classes)]:
            self.assertEqual(klass._labelfs.label_app.setLabelCommand(klass),
                             [klass._labelfs.label_app.name, "/dev", "myfs"],
                             msg=name)

        # all of the remaining are non-labeling so will accept any label
        label = "Houston, we have a problem!"
        for name, klass in device_formats.items():
            if issubclass(klass,
                          fs.FS) and not klass.labeling() and not issubclass(
                              klass, fs.NFS):
                self.assertEqual(klass(device="/dev", label=label).label,
                                 label,
                                 msg=name)
Exemple #2
0
    def test_labels(self):
        """Initialize some filesystems with valid and invalid labels."""

        # Ext2FS has a maximum length of 16
        self.assertFalse(fs.Ext2FS().label_format_ok("root___filesystem"))
        self.assertTrue(fs.Ext2FS().label_format_ok("root__filesystem"))

        # FATFS has a maximum length of 11
        self.assertFalse(fs.FATFS().label_format_ok("rtfilesystem"))
        self.assertTrue(fs.FATFS().label_format_ok("rfilesystem"))

        # JFS has a maximum length of 16
        self.assertFalse(fs.JFS().label_format_ok("root___filesystem"))
        self.assertTrue(fs.JFS().label_format_ok("root__filesystem"))

        # ReiserFS has a maximum length of 16
        self.assertFalse(fs.ReiserFS().label_format_ok("root___filesystem"))
        self.assertTrue(fs.ReiserFS().label_format_ok("root__filesystem"))

        # XFS has a maximum length 12 and does not allow spaces
        self.assertFalse(fs.XFS().label_format_ok("root_filesyst"))
        self.assertFalse(fs.XFS().label_format_ok("root file"))
        self.assertTrue(fs.XFS().label_format_ok("root_filesys"))

        # HFS has a maximum length of 27, minimum length of 1, and does not allow colons
        self.assertFalse(fs.HFS().label_format_ok("n" * 28))
        self.assertFalse(fs.HFS().label_format_ok("root:file"))
        self.assertFalse(fs.HFS().label_format_ok(""))
        self.assertTrue(fs.HFS().label_format_ok("n" * 27))

        # HFSPlus has a maximum length of 128, minimum length of 1, and does not allow colons
        self.assertFalse(fs.HFSPlus().label_format_ok("n" * 129))
        self.assertFalse(fs.HFSPlus().label_format_ok("root:file"))
        self.assertFalse(fs.HFSPlus().label_format_ok(""))
        self.assertTrue(fs.HFSPlus().label_format_ok("n" * 128))

        # NTFS has a maximum length of 128
        self.assertFalse(fs.NTFS().label_format_ok("n" * 129))
        self.assertTrue(fs.NTFS().label_format_ok("n" * 128))

        # all devices are permitted to be passed a label argument of None
        # some will ignore it completely
        for _k, v in device_formats.items():
            self.assertIsNotNone(v(label=None))
Exemple #3
0
    def testLabels(self):
        """Initialize some filesystems with valid and invalid labels."""

        # Ext2FS has a maximum length of 16
        self.assertFalse(fs.Ext2FS().labelFormatOK("root___filesystem"))
        self.assertTrue(fs.Ext2FS().labelFormatOK("root__filesystem"))

        # FATFS has a maximum length of 11
        self.assertFalse(fs.FATFS().labelFormatOK("rtfilesystem"))
        self.assertTrue(fs.FATFS().labelFormatOK("rfilesystem"))

        # JFS has a maximum length of 16
        self.assertFalse(fs.JFS().labelFormatOK("root___filesystem"))
        self.assertTrue(fs.JFS().labelFormatOK("root__filesystem"))

        # ReiserFS has a maximum length of 16
        self.assertFalse(fs.ReiserFS().labelFormatOK("root___filesystem"))
        self.assertTrue(fs.ReiserFS().labelFormatOK("root__filesystem"))

        #XFS has a maximum length 12 and does not allow spaces
        self.assertFalse(fs.XFS().labelFormatOK("root_filesyst"))
        self.assertFalse(fs.XFS().labelFormatOK("root file"))
        self.assertTrue(fs.XFS().labelFormatOK("root_filesys"))

        #HFS has a maximum length of 27, minimum length of 1, and does not allow colons
        self.assertFalse(fs.HFS().labelFormatOK("n" * 28))
        self.assertFalse(fs.HFS().labelFormatOK("root:file"))
        self.assertFalse(fs.HFS().labelFormatOK(""))
        self.assertTrue(fs.HFS().labelFormatOK("n" * 27))

        #HFSPlus has a maximum length of 128, minimum length of 1, and does not allow colons
        self.assertFalse(fs.HFSPlus().labelFormatOK("n" * 129))
        self.assertFalse(fs.HFSPlus().labelFormatOK("root:file"))
        self.assertFalse(fs.HFSPlus().labelFormatOK(""))
        self.assertTrue(fs.HFSPlus().labelFormatOK("n" * 128))

        # NTFS has a maximum length of 128
        self.assertFalse(fs.NTFS().labelFormatOK("n" * 129))
        self.assertTrue(fs.NTFS().labelFormatOK("n" * 128))

        # all devices are permitted to be passed a label argument of None
        # some will ignore it completely
        for _k, v  in device_formats.items():
            self.assertIsNotNone(v(label=None))
Exemple #4
0
    def testGetLabelArgs(self):
        self.longMessage = True

        # ReiserFS uses a -l flag
        reiserfs = self.fs["reiserfs"]
        self.assertEqual(reiserfs._labelfs.labelApp.setLabelCommand(reiserfs),
           ["reiserfstune", "-l", "myfs", "/dev"], msg="reiserfs")

        # JFS, XFS use a -L flag
        lflag_classes = [fs.JFS, fs.XFS]
        for k, v in [(k, v) for k, v in self.fs.items() if any(isinstance(v, c) for c in lflag_classes)]:
            self.assertEqual(v._labelfs.labelApp.setLabelCommand(v), [v._labelfs.labelApp.name, "-L", "myfs", "/dev"], msg=k)

        # Ext2FS and descendants and FATFS do not use a flag
        noflag_classes = [fs.Ext2FS, fs.FATFS]
        for k, v in [(k, v) for k, v in self.fs.items() if any(isinstance(v, c) for c in noflag_classes)]:
            self.assertEqual(v._labelfs.labelApp.setLabelCommand(v), [v._labelfs.labelApp.name, "/dev", "myfs"], msg=k)

        # all of the remaining are non-labeling so will accept any label
        label = "Houston, we have a problem!"
        for k, v in device_formats.items():
            if issubclass(v, fs.FS) and not v.labeling() and not issubclass(v, fs.NFS):
                self.assertEqual(v(device="/dev", label=label).label, label)
Exemple #5
0
 def setUp(self):
     self.fs = {}
     for k, v  in device_formats.items():
         if issubclass(v, fs.FS) and v.labeling():
             self.fs[k] = v(device="/dev", label="myfs")
Exemple #6
0
 def setUp(self):
     self.fs = {}
     for k, v in device_formats.items():
         if issubclass(v, fs.FS) and v.labeling():
             self.fs[k] = v(device="/dev", label="myfs")