Skip to content

Commit

Permalink
Don't use utilsAvailable to skip tests.
Browse files Browse the repository at this point in the history
Related: #12

Use the methods that check the availability of the specific tasks required.
With the additional granularity can test a bunch more things.

Note that it is not possible to use resizable to check availability of test.

Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed May 12, 2015
1 parent 3f0aa44 commit bb4ec0d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
18 changes: 16 additions & 2 deletions tests/formats_test/fslabeling.py
Expand Up @@ -26,8 +26,10 @@ def __init__(self, methodName='runTest'):

def setUp(self):
an_fs = self._fs_class()
if not an_fs.utilsAvailable:
self.skipTest("utilities unavailable for filesystem %s" % an_fs.name)
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
if not an_fs.labeling():
self.skipTest("can not label filesystem %s" % an_fs.name)
super(LabelingAsRoot, self).setUp()

def testLabeling(self):
Expand All @@ -38,6 +40,8 @@ def testLabeling(self):
* raise an exception when relabeling the filesystem
"""
an_fs = self._fs_class(device=self.loopDevices[0], label=self._invalid_label)
if an_fs._readlabel.availabilityErrors or not an_fs.relabels():
self.skipTest("can not read or write label for filesystem %s" % an_fs.name)
self.assertIsNone(an_fs.create())

with self.assertRaises(FSReadLabelError):
Expand Down Expand Up @@ -79,6 +83,8 @@ def testLabeling(self):
* raise an exception when relabeling with an invalid label
"""
an_fs = self._fs_class(device=self.loopDevices[0], label=self._invalid_label)
if an_fs._readlabel.availabilityErrors or not an_fs.relabels():
self.skipTest("can not read or write label for filesystem %s" % an_fs.name)
self.assertIsNone(an_fs.create())

with self.assertRaises(FSReadLabelError):
Expand Down Expand Up @@ -116,6 +122,8 @@ def testLabeling(self):
* raise an exception when relabeling with an invalid label
"""
an_fs = self._fs_class(device=self.loopDevices[0], label=self._invalid_label)
if an_fs._readlabel.availabilityErrors or not an_fs.relabels():
self.skipTest("can not read or write label for filesystem %s" % an_fs.name)
self.assertIsNone(an_fs.create())
self.assertEqual(an_fs.readLabel(), an_fs._labelfs.default_label)

Expand All @@ -140,6 +148,8 @@ def testCreating(self):
Verify that the filesystem has that label.
"""
an_fs = self._fs_class(device=self.loopDevices[0], label="start")
if an_fs._readlabel.availabilityErrors:
self.skipTest("can not read label for filesystem %s" % an_fs.name)
self.assertIsNone(an_fs.create())
self.assertEqual(an_fs.readLabel(), "start")

Expand All @@ -148,6 +158,8 @@ def testCreatingNone(self):
Verify that the filesystem has the default label.
"""
an_fs = self._fs_class(device=self.loopDevices[0], label=None)
if an_fs._readlabel.availabilityErrors:
self.skipTest("can not read label for filesystem %s" % an_fs.name)
self.assertIsNone(an_fs.create())
self.assertEqual(an_fs.readLabel(), an_fs._labelfs.default_label)

Expand All @@ -156,5 +168,7 @@ def testCreatingEmpty(self):
Verify that the filesystem has the empty label.
"""
an_fs = self._fs_class(device=self.loopDevices[0], label="")
if an_fs._readlabel.availabilityErrors:
self.skipTest("can not read label for filesystem %s" % an_fs.name)
self.assertIsNone(an_fs.create())
self.assertEqual(an_fs.readLabel(), "")
55 changes: 35 additions & 20 deletions tests/formats_test/fstesting.py
Expand Up @@ -26,9 +26,6 @@ def __init__(self, methodName='runTest'):
super(FSAsRoot, self).__init__(methodName=methodName, deviceSpec=[self._DEVICE_SIZE])

def setUp(self):
an_fs = self._fs_class()
if not an_fs.utilsAvailable:
self.skipTest("utilities unavailable for filesystem %s" % an_fs.name)
super(FSAsRoot, self).setUp()

def _test_sizes(self, an_fs):
Expand Down Expand Up @@ -112,7 +109,7 @@ def testInstantiation(self):
def testCreation(self):
an_fs = self._fs_class()
if not an_fs.formattable:
return
self.skipTest("can not create filesystem %s" % an_fs.name)
an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
self.assertEqual(an_fs.resizable, False)
Expand All @@ -130,8 +127,8 @@ def testCreation(self):

def testLabeling(self):
an_fs = self._fs_class()
if not an_fs.labeling():
return
if not an_fs.formattable or not an_fs.labeling():
self.skipTest("can not label filesystem %s" % an_fs.name)
an_fs.device = self.loopDevices[0]
an_fs.label = "label"
self.assertTrue(an_fs.labelFormatOK("label"))
Expand All @@ -144,8 +141,8 @@ def testLabeling(self):

def testRelabeling(self):
an_fs = self._fs_class()
if not an_fs.labeling():
return
if not an_fs.formattable or not an_fs.labeling():
self.skipTest("can not label filesystem %s" % an_fs.name)
an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.label = "label"
Expand All @@ -160,9 +157,9 @@ def testMounting(self):
an_fs = self._fs_class()
# FIXME: BTRFS fails to mount
if isinstance(an_fs, fs.BTRFS):
return
self.skipTest("no mounting filesystem %s" % an_fs.name)
if not an_fs.formattable:
return
self.skipTest("can not create filesystem %s" % an_fs.name)
an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
self.assertTrue(an_fs.testMount())
Expand All @@ -171,9 +168,9 @@ def testMountpoint(self):
an_fs = self._fs_class()
# FIXME: BTRFS fails to mount
if isinstance(an_fs, fs.BTRFS):
return
self.skipTest("no mounting filesystem %s" % an_fs.name)
if not an_fs.formattable or not an_fs.mountable:
return
self.skipTest("can not create or mount filesystem %s" % an_fs.name)
an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
mountpoint = tempfile.mkdtemp()
Expand All @@ -185,8 +182,8 @@ def testMountpoint(self):

def testResize(self):
an_fs = self._fs_class()
if not an_fs.formattable or not an_fs.resizable:
return
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand Down Expand Up @@ -225,9 +222,12 @@ def testNoExplicitTargetSize(self):
# gets value of _size in constructor, so if _size is set to not-zero
# in constructor call behavior would be different.
if not self._resizable:
return
self.skipTest("Not checking resize for this test category.")

an_fs = self._fs_class()
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)

an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand All @@ -245,10 +245,13 @@ def testNoExplicitTargetSize2(self):
resize action resizes filesystem to that size.
"""
if not self._resizable:
return
self.skipTest("Not checking resize for this test category.")

SIZE = Size("64 MiB")
an_fs = self._fs_class(size=SIZE)
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)

an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand All @@ -264,9 +267,12 @@ def testNoExplicitTargetSize2(self):

def testShrink(self):
if not self._resizable:
return
self.skipTest("Not checking resize for this test category.")

an_fs = self._fs_class()
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)

an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand Down Expand Up @@ -294,9 +300,12 @@ def testShrink(self):

def testTooSmall(self):
if not self._resizable:
return
self.skipTest("Not checking resize for this test category.")

an_fs = self._fs_class()
if not an_fs.formattable:
self.skipTest("can not create or resize filesystem %s" % an_fs.name)

an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand All @@ -311,9 +320,12 @@ def testTooSmall(self):

def testTooBig(self):
if not self._resizable:
return
self.skipTest("Not checking resize for this test category.")

an_fs = self._fs_class()
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)

an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand All @@ -328,9 +340,12 @@ def testTooBig(self):

def testTooBig2(self):
if not self._resizable:
return
self.skipTest("Not checking resize for this test category.")

an_fs = self._fs_class()
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)

an_fs.device = self.loopDevices[0]
self.assertIsNone(an_fs.create())
an_fs.updateSizeInfo()
Expand Down

0 comments on commit bb4ec0d

Please sign in to comment.