| 1 |
import tempfile |
| 2 |
|
| 3 |
from .fs_test import FSTestCase, FSNoDevTestCase, mounted |
| 4 |
|
| 5 |
import overrides_hack |
| 6 |
import utils |
| 7 |
from utils import TestTags, tag_test |
| 8 |
|
| 9 |
from gi.repository import BlockDev, GLib |
| 10 |
|
| 11 |
|
| 12 |
class ExtNoDevTestCase(FSNoDevTestCase): |
| 13 |
pass |
| 14 |
|
| 15 |
|
| 16 |
class ExtTestCase(FSTestCase): |
| 17 |
def setUp(self): |
| 18 |
super(ExtTestCase, self).setUp() |
| 19 |
|
| 20 |
self.mount_dir = tempfile.mkdtemp(prefix="libblockdev.", suffix="ext_test") |
| 21 |
|
| 22 |
|
| 23 |
class ExtTestAvailability(ExtNoDevTestCase): |
| 24 |
|
| 25 |
def _test_ext_available(self, tech): |
| 26 |
available = BlockDev.fs_is_tech_avail(tech, |
| 27 |
BlockDev.FSTechMode.MKFS | |
| 28 |
BlockDev.FSTechMode.QUERY | |
| 29 |
BlockDev.FSTechMode.REPAIR | |
| 30 |
BlockDev.FSTechMode.CHECK | |
| 31 |
BlockDev.FSTechMode.SET_LABEL | |
| 32 |
BlockDev.FSTechMode.RESIZE | |
| 33 |
BlockDev.FSTechMode.SET_UUID) |
| 34 |
self.assertTrue(available) |
| 35 |
|
| 36 |
BlockDev.reinit(self.requested_plugins, True, None) |
| 37 |
|
| 38 |
# now try without mke2fs |
| 39 |
with utils.fake_path(all_but="mke2fs"): |
| 40 |
with self.assertRaisesRegex(GLib.GError, "The 'mke2fs' utility is not available"): |
| 41 |
BlockDev.fs_is_tech_avail(tech, BlockDev.FSTechMode.MKFS) |
| 42 |
|
| 43 |
# now try without e2fsck |
| 44 |
with utils.fake_path(all_but="e2fsck"): |
| 45 |
with self.assertRaisesRegex(GLib.GError, "The 'e2fsck' utility is not available"): |
| 46 |
BlockDev.fs_is_tech_avail(tech, BlockDev.FSTechMode.CHECK) |
| 47 |
|
| 48 |
with self.assertRaisesRegex(GLib.GError, "The 'e2fsck' utility is not available"): |
| 49 |
BlockDev.fs_is_tech_avail(tech, BlockDev.FSTechMode.REPAIR) |
| 50 |
|
| 51 |
# now try without tune2fs |
| 52 |
with utils.fake_path(all_but="tune2fs"): |
| 53 |
with self.assertRaisesRegex(GLib.GError, "The 'tune2fs' utility is not available"): |
| 54 |
BlockDev.fs_is_tech_avail(tech, BlockDev.FSTechMode.SET_LABEL) |
| 55 |
|
| 56 |
with self.assertRaisesRegex(GLib.GError, "The 'tune2fs' utility is not available"): |
| 57 |
BlockDev.fs_is_tech_avail(tech, BlockDev.FSTechMode.SET_UUID) |
| 58 |
|
| 59 |
# now try without resize2fs |
| 60 |
with utils.fake_path(all_but="resize2fs"): |
| 61 |
with self.assertRaisesRegex(GLib.GError, "The 'resize2fs' utility is not available"): |
| 62 |
BlockDev.fs_is_tech_avail(tech, BlockDev.FSTechMode.RESIZE) |
| 63 |
|
| 64 |
@tag_test(TestTags.CORE) |
| 65 |
def test_ext2_available(self): |
| 66 |
"""Verify that it is possible to check ext2 tech availability""" |
| 67 |
self._test_ext_available(tech=BlockDev.FSTech.EXT2) |
| 68 |
|
| 69 |
@tag_test(TestTags.CORE) |
| 70 |
def test_ext3_available(self): |
| 71 |
"""Verify that it is possible to check ext3 tech availability""" |
| 72 |
self._test_ext_available(tech=BlockDev.FSTech.EXT3) |
| 73 |
|
| 74 |
@tag_test(TestTags.CORE) |
| 75 |
def test_ext4_available(self): |
| 76 |
"""Verify that it is possible to check ext4 tech availability""" |
| 77 |
self._test_ext_available(tech=BlockDev.FSTech.EXT4) |
| 78 |
|
| 79 |
|
| 80 |
class ExtTestFeatures(ExtNoDevTestCase): |
| 81 |
|
| 82 |
def _test_ext_features(self, ext_version): |
| 83 |
features = BlockDev.fs_features(ext_version) |
| 84 |
self.assertIsNotNone(features) |
| 85 |
|
| 86 |
self.assertTrue(features.resize & BlockDev.FSResizeFlags.OFFLINE_GROW) |
| 87 |
self.assertTrue(features.resize & BlockDev.FSResizeFlags.ONLINE_GROW) |
| 88 |
self.assertTrue(features.resize & BlockDev.FSResizeFlags.OFFLINE_SHRINK) |
| 89 |
|
| 90 |
self.assertTrue(features.mkfs & BlockDev.FSMkfsOptionsFlags.LABEL) |
| 91 |
self.assertTrue(features.mkfs & BlockDev.FSMkfsOptionsFlags.UUID) |
| 92 |
self.assertTrue(features.mkfs & BlockDev.FSMkfsOptionsFlags.DRY_RUN) |
| 93 |
self.assertTrue(features.mkfs & BlockDev.FSMkfsOptionsFlags.NODISCARD) |
| 94 |
self.assertTrue(features.mkfs & BlockDev.FSMkfsOptionsFlags.FORCE) |
| 95 |
self.assertFalse(features.mkfs & BlockDev.FSMkfsOptionsFlags.NOPT) |
| 96 |
|
| 97 |
self.assertTrue(features.fsck & BlockDev.FSFsckFlags.CHECK) |
| 98 |
self.assertTrue(features.fsck & BlockDev.FSFsckFlags.REPAIR) |
| 99 |
|
| 100 |
self.assertTrue(features.configure & BlockDev.FSConfigureFlags.LABEL) |
| 101 |
self.assertTrue(features.configure & BlockDev.FSConfigureFlags.UUID) |
| 102 |
|
| 103 |
self.assertTrue(features.features & BlockDev.FSFeatureFlags.OWNERS) |
| 104 |
self.assertFalse(features.features & BlockDev.FSFeatureFlags.PARTITION_TABLE) |
| 105 |
|
| 106 |
self.assertEqual(features.partition_id, "0x83") |
| 107 |
self.assertEqual(features.partition_type, "0fc63daf-8483-4772-8e79-3d69d8477de4") |
| 108 |
|
| 109 |
def test_ext2_features(self): |
| 110 |
self._test_ext_features("ext2") |
| 111 |
|
| 112 |
def test_ext3_features(self): |
| 113 |
self._test_ext_features("ext3") |
| 114 |
|
| 115 |
def test_ext4_features(self): |
| 116 |
self._test_ext_features("ext4") |
| 117 |
|
| 118 |
|
| 119 |
class ExtTestMkfs(ExtTestCase): |
| 120 |
def _test_ext_mkfs(self, mkfs_function, ext_version): |
| 121 |
with self.assertRaises(GLib.GError): |
| 122 |
mkfs_function("/non/existing/device", None) |
| 123 |
|
| 124 |
succ = mkfs_function(self.loop_devs[0], None) |
| 125 |
self.assertTrue(succ) |
| 126 |
|
| 127 |
# just try if we can mount the file system |
| 128 |
with mounted(self.loop_devs[0], self.mount_dir): |
| 129 |
pass |
| 130 |
|
| 131 |
# check the fstype |
| 132 |
fstype = BlockDev.fs_get_fstype(self.loop_devs[0]) |
| 133 |
self.assertEqual(fstype, ext_version) |
| 134 |
|
| 135 |
BlockDev.fs_wipe(self.loop_devs[0], True) |
| 136 |
|
| 137 |
@tag_test(TestTags.CORE) |
| 138 |
def test_ext2_mkfs(self): |
| 139 |
"""Verify that it is possible to create a new ext2 file system""" |
| 140 |
self._test_ext_mkfs(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 141 |
ext_version="ext2") |
| 142 |
|
| 143 |
@tag_test(TestTags.CORE) |
| 144 |
def test_ext3_mkfs(self): |
| 145 |
"""Verify that it is possible to create a new ext3 file system""" |
| 146 |
self._test_ext_mkfs(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 147 |
ext_version="ext3") |
| 148 |
|
| 149 |
@tag_test(TestTags.CORE) |
| 150 |
def test_ext4_mkfs(self): |
| 151 |
"""Verify that it is possible to create a new ext4 file system""" |
| 152 |
self._test_ext_mkfs(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 153 |
ext_version="ext4") |
| 154 |
|
| 155 |
|
| 156 |
class ExtMkfsWithLabel(ExtTestCase): |
| 157 |
def _test_ext_mkfs_with_label(self, mkfs_function, info_function): |
| 158 |
ea = BlockDev.ExtraArg.new("-L", "TEST_LABEL") |
| 159 |
succ = mkfs_function(self.loop_devs[0], [ea]) |
| 160 |
self.assertTrue(succ) |
| 161 |
|
| 162 |
fi = info_function(self.loop_devs[0]) |
| 163 |
self.assertTrue(fi) |
| 164 |
self.assertEqual(fi.label, "TEST_LABEL") |
| 165 |
|
| 166 |
def test_ext2_mkfs_with_label(self): |
| 167 |
"""Verify that it is possible to create an ext2 file system with label""" |
| 168 |
self._test_ext_mkfs_with_label(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 169 |
info_function=BlockDev.fs_ext2_get_info) |
| 170 |
|
| 171 |
def test_ext3_mkfs_with_label(self): |
| 172 |
"""Verify that it is possible to create an ext3 file system with label""" |
| 173 |
self._test_ext_mkfs_with_label(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 174 |
info_function=BlockDev.fs_ext3_get_info) |
| 175 |
|
| 176 |
def test_ext4_mkfs_with_label(self): |
| 177 |
"""Verify that it is possible to create an ext4 file system with label""" |
| 178 |
self._test_ext_mkfs_with_label(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 179 |
info_function=BlockDev.fs_ext4_get_info) |
| 180 |
|
| 181 |
|
| 182 |
class ExtTestCheck(ExtTestCase): |
| 183 |
def _test_ext_check(self, mkfs_function, check_function): |
| 184 |
succ = mkfs_function(self.loop_devs[0], None) |
| 185 |
self.assertTrue(succ) |
| 186 |
|
| 187 |
succ = check_function(self.loop_devs[0], None) |
| 188 |
self.assertTrue(succ) |
| 189 |
|
| 190 |
def test_ext2_check(self): |
| 191 |
"""Verify that it is possible to check an ext2 file system""" |
| 192 |
self._test_ext_check(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 193 |
check_function=BlockDev.fs_ext2_check) |
| 194 |
|
| 195 |
def test_ext3_check(self): |
| 196 |
"""Verify that it is possible to check an ext3 file system""" |
| 197 |
self._test_ext_check(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 198 |
check_function=BlockDev.fs_ext3_check) |
| 199 |
|
| 200 |
def test_ext4_check(self): |
| 201 |
"""Verify that it is possible to check an ext4 file system""" |
| 202 |
self._test_ext_check(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 203 |
check_function=BlockDev.fs_ext4_check) |
| 204 |
|
| 205 |
|
| 206 |
class ExtTestRepair(ExtTestCase): |
| 207 |
def _test_ext_repair(self, mkfs_function, repair_function): |
| 208 |
succ = mkfs_function(self.loop_devs[0], None) |
| 209 |
self.assertTrue(succ) |
| 210 |
|
| 211 |
succ = repair_function(self.loop_devs[0], False, None) |
| 212 |
self.assertTrue(succ) |
| 213 |
|
| 214 |
# unsafe operations should work here too |
| 215 |
succ = repair_function(self.loop_devs[0], True, None) |
| 216 |
self.assertTrue(succ) |
| 217 |
|
| 218 |
succ = repair_function(self.loop_devs[0], False, None) |
| 219 |
self.assertTrue(succ) |
| 220 |
|
| 221 |
def test_ext2_repair(self): |
| 222 |
"""Verify that it is possible to repair an ext2 file system""" |
| 223 |
self._test_ext_repair(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 224 |
repair_function=BlockDev.fs_ext2_repair) |
| 225 |
|
| 226 |
def test_ext3_repair(self): |
| 227 |
"""Verify that it is possible to repair an ext3 file system""" |
| 228 |
self._test_ext_repair(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 229 |
repair_function=BlockDev.fs_ext3_repair) |
| 230 |
|
| 231 |
def test_ext4_repair(self): |
| 232 |
"""Verify that it is possible to repair an ext4 file system""" |
| 233 |
self._test_ext_repair(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 234 |
repair_function=BlockDev.fs_ext4_repair) |
| 235 |
|
| 236 |
|
| 237 |
class ExtGetInfo(ExtTestCase): |
| 238 |
def _test_ext_get_info(self, mkfs_function, info_function): |
| 239 |
succ = mkfs_function(self.loop_devs[0]) |
| 240 |
self.assertTrue(succ) |
| 241 |
|
| 242 |
fi = info_function(self.loop_devs[0]) |
| 243 |
self.assertTrue(fi) |
| 244 |
self.assertEqual(fi.block_size, 1024) |
| 245 |
self.assertEqual(fi.block_count, self.loop_size / 1024) |
| 246 |
# at least 50 % should be available, so it should be reported |
| 247 |
self.assertGreater(fi.free_blocks, 0.50 * self.loop_size / 1024) |
| 248 |
self.assertEqual(fi.label, "") |
| 249 |
# should be an non-empty string |
| 250 |
self.assertTrue(fi.uuid) |
| 251 |
self.assertTrue(fi.state) |
| 252 |
|
| 253 |
with mounted(self.loop_devs[0], self.mount_dir): |
| 254 |
fi = info_function(self.loop_devs[0]) |
| 255 |
self.assertEqual(fi.block_size, 1024) |
| 256 |
self.assertEqual(fi.block_count, self.loop_size / 1024) |
| 257 |
# at least 50 % should be available, so it should be reported |
| 258 |
self.assertGreater(fi.free_blocks, 0.50 * self.loop_size / 1024) |
| 259 |
self.assertEqual(fi.label, "") |
| 260 |
# should be an non-empty string |
| 261 |
self.assertTrue(fi.uuid) |
| 262 |
self.assertTrue(fi.state) |
| 263 |
|
| 264 |
@tag_test(TestTags.CORE) |
| 265 |
def test_ext2_get_info(self): |
| 266 |
"""Verify that it is possible to get info about an ext2 file system""" |
| 267 |
self._test_ext_get_info(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 268 |
info_function=BlockDev.fs_ext2_get_info) |
| 269 |
|
| 270 |
@tag_test(TestTags.CORE) |
| 271 |
def test_ext3_get_info(self): |
| 272 |
"""Verify that it is possible to get info about an ext3 file system""" |
| 273 |
self._test_ext_get_info(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 274 |
info_function=BlockDev.fs_ext3_get_info) |
| 275 |
|
| 276 |
@tag_test(TestTags.CORE) |
| 277 |
def test_ext4_get_info(self): |
| 278 |
"""Verify that it is possible to get info about an ext4 file system""" |
| 279 |
self._test_ext_get_info(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 280 |
info_function=BlockDev.fs_ext4_get_info) |
| 281 |
|
| 282 |
|
| 283 |
class ExtSetLabel(ExtTestCase): |
| 284 |
def _test_ext_set_label(self, mkfs_function, info_function, label_function, check_function): |
| 285 |
succ = mkfs_function(self.loop_devs[0], None) |
| 286 |
self.assertTrue(succ) |
| 287 |
|
| 288 |
fi = info_function(self.loop_devs[0]) |
| 289 |
self.assertTrue(fi) |
| 290 |
self.assertEqual(fi.label, "") |
| 291 |
|
| 292 |
succ = label_function(self.loop_devs[0], "TEST_LABEL") |
| 293 |
self.assertTrue(succ) |
| 294 |
fi = info_function(self.loop_devs[0]) |
| 295 |
self.assertTrue(fi) |
| 296 |
self.assertEqual(fi.label, "TEST_LABEL") |
| 297 |
|
| 298 |
succ = label_function(self.loop_devs[0], "TEST_LABEL2") |
| 299 |
self.assertTrue(succ) |
| 300 |
fi = info_function(self.loop_devs[0]) |
| 301 |
self.assertTrue(fi) |
| 302 |
self.assertEqual(fi.label, "TEST_LABEL2") |
| 303 |
|
| 304 |
succ = label_function(self.loop_devs[0], "") |
| 305 |
self.assertTrue(succ) |
| 306 |
fi = info_function(self.loop_devs[0]) |
| 307 |
self.assertTrue(fi) |
| 308 |
self.assertEqual(fi.label, "") |
| 309 |
|
| 310 |
succ = check_function("TEST_LABEL") |
| 311 |
self.assertTrue(succ) |
| 312 |
|
| 313 |
with self.assertRaisesRegex(GLib.GError, "at most 16 characters long."): |
| 314 |
check_function(20 * "a") |
| 315 |
|
| 316 |
def test_ext2_set_label(self): |
| 317 |
"""Verify that it is possible to set label of an ext2 file system""" |
| 318 |
self._test_ext_set_label(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 319 |
info_function=BlockDev.fs_ext2_get_info, |
| 320 |
label_function=BlockDev.fs_ext2_set_label, |
| 321 |
check_function=BlockDev.fs_ext2_check_label) |
| 322 |
|
| 323 |
def test_ext3_set_label(self): |
| 324 |
"""Verify that it is possible to set label of an ext3 file system""" |
| 325 |
self._test_ext_set_label(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 326 |
info_function=BlockDev.fs_ext3_get_info, |
| 327 |
label_function=BlockDev.fs_ext3_set_label, |
| 328 |
check_function=BlockDev.fs_ext3_check_label) |
| 329 |
|
| 330 |
def test_ext4_set_label(self): |
| 331 |
"""Verify that it is possible to set label of an ext4 file system""" |
| 332 |
self._test_ext_set_label(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 333 |
info_function=BlockDev.fs_ext4_get_info, |
| 334 |
label_function=BlockDev.fs_ext4_set_label, |
| 335 |
check_function=BlockDev.fs_ext4_check_label) |
| 336 |
|
| 337 |
|
| 338 |
class ExtResize(ExtTestCase): |
| 339 |
def _test_ext_resize(self, mkfs_function, info_function, resize_function, minsize_function): |
| 340 |
succ = mkfs_function(self.loop_devs[0], None) |
| 341 |
self.assertTrue(succ) |
| 342 |
|
| 343 |
fi = info_function(self.loop_devs[0]) |
| 344 |
self.assertTrue(fi) |
| 345 |
self.assertEqual(fi.block_size, 1024) |
| 346 |
self.assertEqual(fi.block_count, self.loop_size / 1024) |
| 347 |
|
| 348 |
succ = resize_function(self.loop_devs[0], 50 * 1024**2, None) |
| 349 |
self.assertTrue(succ) |
| 350 |
fi = info_function(self.loop_devs[0]) |
| 351 |
self.assertTrue(fi) |
| 352 |
self.assertEqual(fi.block_size, 1024) |
| 353 |
self.assertEqual(fi.block_count, 50 * 1024**2 / 1024) |
| 354 |
|
| 355 |
# resize back |
| 356 |
succ = resize_function(self.loop_devs[0], self.loop_size, None) |
| 357 |
self.assertTrue(succ) |
| 358 |
fi = info_function(self.loop_devs[0]) |
| 359 |
self.assertTrue(fi) |
| 360 |
self.assertEqual(fi.block_size, 1024) |
| 361 |
self.assertEqual(fi.block_count, self.loop_size / 1024) |
| 362 |
|
| 363 |
# resize again |
| 364 |
succ = resize_function(self.loop_devs[0], 50 * 1024**2, None) |
| 365 |
self.assertTrue(succ) |
| 366 |
fi = info_function(self.loop_devs[0]) |
| 367 |
self.assertTrue(fi) |
| 368 |
self.assertEqual(fi.block_size, 1024) |
| 369 |
self.assertEqual(fi.block_count, 50 * 1024**2 / 1024) |
| 370 |
|
| 371 |
# resize back again, this time to maximum size |
| 372 |
succ = resize_function(self.loop_devs[0], 0, None) |
| 373 |
self.assertTrue(succ) |
| 374 |
fi = info_function(self.loop_devs[0]) |
| 375 |
self.assertTrue(fi) |
| 376 |
self.assertEqual(fi.block_size, 1024) |
| 377 |
self.assertEqual(fi.block_count, self.loop_size / 1024) |
| 378 |
|
| 379 |
# get min size and resize to it |
| 380 |
size = minsize_function(self.loop_devs[0]) |
| 381 |
self.assertNotEqual(size, 0) |
| 382 |
|
| 383 |
succ = resize_function(self.loop_devs[0], size) |
| 384 |
self.assertTrue(succ) |
| 385 |
|
| 386 |
def test_ext2_resize(self): |
| 387 |
"""Verify that it is possible to resize an ext2 file system""" |
| 388 |
self._test_ext_resize(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 389 |
info_function=BlockDev.fs_ext2_get_info, |
| 390 |
resize_function=BlockDev.fs_ext2_resize, |
| 391 |
minsize_function=BlockDev.fs_ext2_get_min_size) |
| 392 |
|
| 393 |
def test_ext3_resize(self): |
| 394 |
"""Verify that it is possible to resize an ext3 file system""" |
| 395 |
self._test_ext_resize(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 396 |
info_function=BlockDev.fs_ext3_get_info, |
| 397 |
resize_function=BlockDev.fs_ext3_resize, |
| 398 |
minsize_function=BlockDev.fs_ext3_get_min_size) |
| 399 |
|
| 400 |
def test_ext4_resize(self): |
| 401 |
"""Verify that it is possible to resize an ext4 file system""" |
| 402 |
self._test_ext_resize(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 403 |
info_function=BlockDev.fs_ext4_get_info, |
| 404 |
resize_function=BlockDev.fs_ext4_resize, |
| 405 |
minsize_function=BlockDev.fs_ext4_get_min_size) |
| 406 |
|
| 407 |
|
| 408 |
class ExtSetUUID(ExtTestCase): |
| 409 |
|
| 410 |
test_uuid = "4d7086c4-a4d3-432f-819e-73da03870df9" |
| 411 |
|
| 412 |
def _test_ext_set_uuid(self, mkfs_function, info_function, uuid_function, check_function): |
| 413 |
succ = mkfs_function(self.loop_devs[0], None) |
| 414 |
self.assertTrue(succ) |
| 415 |
|
| 416 |
fi = info_function(self.loop_devs[0]) |
| 417 |
self.assertTrue(fi) |
| 418 |
|
| 419 |
succ = uuid_function(self.loop_devs[0], self.test_uuid) |
| 420 |
self.assertTrue(succ) |
| 421 |
fi = info_function(self.loop_devs[0]) |
| 422 |
self.assertTrue(fi) |
| 423 |
self.assertEqual(fi.uuid, self.test_uuid) |
| 424 |
|
| 425 |
succ = uuid_function(self.loop_devs[0], "clear") |
| 426 |
self.assertTrue(succ) |
| 427 |
fi = info_function(self.loop_devs[0]) |
| 428 |
self.assertTrue(fi) |
| 429 |
self.assertEqual(fi.uuid, "") |
| 430 |
|
| 431 |
succ = uuid_function(self.loop_devs[0], "random") |
| 432 |
self.assertTrue(succ) |
| 433 |
fi = info_function(self.loop_devs[0]) |
| 434 |
self.assertTrue(fi) |
| 435 |
self.assertNotEqual(fi.uuid, "") |
| 436 |
random_uuid = fi.uuid |
| 437 |
|
| 438 |
succ = uuid_function(self.loop_devs[0], "time") |
| 439 |
self.assertTrue(succ) |
| 440 |
fi = info_function(self.loop_devs[0]) |
| 441 |
self.assertTrue(fi) |
| 442 |
self.assertNotEqual(fi.uuid, "") |
| 443 |
self.assertNotEqual(fi.uuid, random_uuid) |
| 444 |
time_uuid = fi.uuid |
| 445 |
|
| 446 |
# no UUID -> random |
| 447 |
succ = uuid_function(self.loop_devs[0], None) |
| 448 |
self.assertTrue(succ) |
| 449 |
fi = info_function(self.loop_devs[0]) |
| 450 |
self.assertTrue(fi) |
| 451 |
self.assertNotEqual(fi.uuid, "") |
| 452 |
self.assertNotEqual(fi.uuid, time_uuid) |
| 453 |
|
| 454 |
succ = check_function(self.test_uuid) |
| 455 |
self.assertTrue(succ) |
| 456 |
|
| 457 |
with self.assertRaisesRegex(GLib.GError, "not a valid RFC-4122 UUID"): |
| 458 |
check_function("aaaaaaa") |
| 459 |
|
| 460 |
def test_ext2_set_uuid(self): |
| 461 |
"""Verify that it is possible to set UUID of an ext2 file system""" |
| 462 |
self._test_ext_set_uuid(mkfs_function=BlockDev.fs_ext2_mkfs, |
| 463 |
info_function=BlockDev.fs_ext2_get_info, |
| 464 |
uuid_function=BlockDev.fs_ext2_set_uuid, |
| 465 |
check_function=BlockDev.fs_ext2_check_uuid) |
| 466 |
|
| 467 |
def test_ext3_set_uuid(self): |
| 468 |
"""Verify that it is possible to set UUID of an ext3 file system""" |
| 469 |
self._test_ext_set_uuid(mkfs_function=BlockDev.fs_ext3_mkfs, |
| 470 |
info_function=BlockDev.fs_ext3_get_info, |
| 471 |
uuid_function=BlockDev.fs_ext3_set_uuid, |
| 472 |
check_function=BlockDev.fs_ext3_check_uuid) |
| 473 |
|
| 474 |
def test_ext4_set_uuid(self): |
| 475 |
"""Verify that it is possible to set UUID of an ext4 file system""" |
| 476 |
self._test_ext_set_uuid(mkfs_function=BlockDev.fs_ext4_mkfs, |
| 477 |
info_function=BlockDev.fs_ext4_get_info, |
| 478 |
uuid_function=BlockDev.fs_ext4_set_uuid, |
| 479 |
check_function=BlockDev.fs_ext4_check_uuid) |