-
Notifications
You must be signed in to change notification settings - Fork 84
/
fs_test.py
140 lines (101 loc) · 3.75 KB
/
fs_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import os
import tempfile
import unittest
import blivet.formats.fs as fs
from blivet.size import Size, ROUND_DOWN
from tests import loopbackedtestcase
from . import fstesting
class Ext2FSTestCase(fstesting.FSAsRoot):
_fs_class = fs.Ext2FS
class Ext3FSTestCase(Ext2FSTestCase):
_fs_class = fs.Ext3FS
class Ext4FSTestCase(Ext3FSTestCase):
_fs_class = fs.Ext4FS
class FATFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.FATFS
class EFIFSTestCase(FATFSTestCase):
_fs_class = fs.EFIFS
class BTRFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.BTRFS
@unittest.skip("Unable to create GFS2 filesystem.")
class GFS2TestCase(fstesting.FSAsRoot):
_fs_class = fs.GFS2
class JFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.JFS
class ReiserFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.ReiserFS
class XFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.XFS
class HFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.HFS
class AppleBootstrapFSTestCase(HFSTestCase):
_fs_class = fs.AppleBootstrapFS
class HFSPlusTestCase(fstesting.FSAsRoot):
_fs_class = fs.HFSPlus
class MacEFIFSTestCase(HFSPlusTestCase):
_fs_class = fs.MacEFIFS
@unittest.skip("Unable to create because NTFS._formattable is False.")
class NTFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.NTFS
@unittest.skip("Unable to create because device fails deviceCheck().")
class NFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.NFS
class NFSv4TestCase(NFSTestCase):
_fs_class = fs.NFSv4
class Iso9660FS(fstesting.FSAsRoot):
_fs_class = fs.Iso9660FS
@unittest.skip("Too strange to test using this framework.")
class NoDevFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.NoDevFS
class DevPtsFSTestCase(NoDevFSTestCase):
_fs_class = fs.DevPtsFS
class ProcFSTestCase(NoDevFSTestCase):
_fs_class = fs.ProcFS
class SysFSTestCase(NoDevFSTestCase):
_fs_class = fs.SysFS
class TmpFSTestCase(NoDevFSTestCase):
_fs_class = fs.TmpFS
class SELinuxFSTestCase(NoDevFSTestCase):
_fs_class = fs.SELinuxFS
class USBFSTestCase(NoDevFSTestCase):
_fs_class = fs.USBFS
class BindFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.BindFS
class SimpleTmpFSTestCase(loopbackedtestcase.LoopBackedTestCase):
def __init__(self, methodName='runTest'):
super(SimpleTmpFSTestCase, self).__init__(methodName=methodName)
def testSimple(self):
an_fs = fs.TmpFS()
# a nodev fs need not have been created to exist
self.assertTrue(an_fs.exists)
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._resize.unit, 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)