Skip to content

Commit

Permalink
Remove resizing tests for TmpFS and also its getExistingSize method.
Browse files Browse the repository at this point in the history
Resizing is not actually enabled for TmpFS, the tests use a hack to
enable resizing so that they can be run.

Also, getExistingSize() does not work properly on RHEL6, as df on RHEL6
does not accept --output option.

Signed-off-by: Anne Mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Apr 1, 2015
1 parent c2782db commit 96c2597
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
25 changes: 0 additions & 25 deletions blivet/formats/fs.py
Expand Up @@ -1562,31 +1562,6 @@ def destroy(self, *args, **kwargs):
"""
pass

def _getExistingSize(self, info=None):
""" Get current size of tmpfs filesystem using df.
:param NoneType info: a dummy parameter
:rtype: Size
:returns: the current size of the filesystem, 0 if not found.
"""
if not self.status:
return Size(0)

df = ["df", self._mountpoint, "--output=size"]
try:
(ret, out) = util.run_program_and_capture_output(df)
except OSError:
return Size(0)

if ret:
return Size(0)

lines = out.split()
if len(lines) != 2 or lines[0] != "1K-blocks":
return Size(0)

return Size("%s KiB" % lines[1])

@property
def mountable(self):
return True
Expand Down
38 changes: 0 additions & 38 deletions tests/formats_test/fs_test.py
@@ -1,10 +1,7 @@
#!/usr/bin/python
import os
import tempfile
import unittest2 as unittest

import blivet.formats.fs as fs
from blivet.size import Size, ROUND_DOWN

from tests import loopbackedtestcase

Expand Down Expand Up @@ -119,40 +116,5 @@ def testSimple(self):
self.assertEqual(an_fs.device, "tmpfs")
self.assertTrue(an_fs.testMount())

class ResizeTmpFSTestCase(loopbackedtestcase.LoopBackedTestCase):

def __init__(self, methodName='runTest'):
super(ResizeTmpFSTestCase, self).__init__(methodName=methodName)
self.an_fs = fs.TmpFS()
self.an_fs.__class__._resizable = True
self.mountpoint = None

def setUp(self):
self.mountpoint = tempfile.mkdtemp()
self.an_fs.mountpoint = self.mountpoint
self.an_fs.mount()

def testResize(self):
self.an_fs.updateSizeInfo()
newsize = self.an_fs.currentSize * 2
self.an_fs.targetSize = newsize
self.assertIsNone(self.an_fs.doResize())
self.assertEqual(self.an_fs.size, newsize.roundToNearest(self.an_fs._resizefsUnit, rounding=ROUND_DOWN))

def testShrink(self):
# Can not shrink tmpfs, because its minimum size is its current size
self.an_fs.updateSizeInfo()
newsize = Size("2 MiB")
self.assertTrue(newsize < self.an_fs.currentSize)
with self.assertRaises(ValueError):
self.an_fs.targetSize = newsize

def teardown(self):
try:
self.an_fs.unmount()
except Exception: # pylint: disable=broad-except
pass
os.rmdir(self.mountpoint)

if __name__ == "__main__":
unittest.main()

0 comments on commit 96c2597

Please sign in to comment.