@@ -17,9 +17,7 @@ def _remove_format(self, device):
17
17
try :
18
18
device .Format ('empty' , d , dbus_interface = self .iface_prefix + '.Block' )
19
19
except dbus .exceptions .DBusException :
20
- self .udev_settle ()
21
- time .sleep (5 )
22
- device .Format ('empty' , d , dbus_interface = self .iface_prefix + '.Block' )
20
+ pass
23
21
24
22
def _create_format (self , device , ftype ):
25
23
device .Format (ftype , self .no_options , dbus_interface = self .iface_prefix + '.Block' )
@@ -28,9 +26,7 @@ def _remove_partition(self, part):
28
26
try :
29
27
part .Delete (self .no_options , dbus_interface = self .iface_prefix + '.Partition' )
30
28
except dbus .exceptions .DBusException :
31
- self .udev_settle ()
32
- time .sleep (5 )
33
- part .Delete (self .no_options , dbus_interface = self .iface_prefix + '.Partition' )
29
+ pass
34
30
35
31
def test_create_mbr_partition (self ):
36
32
disk = self .get_object ('/block_devices/' + os .path .basename (self .vdevs [0 ]))
@@ -39,6 +35,7 @@ def test_create_mbr_partition(self):
39
35
# create msdos partition table
40
36
self ._create_format (disk , 'dos' )
41
37
self .addCleanup (self ._remove_format , disk )
38
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
42
39
43
40
pttype = self .get_property (disk , '.PartitionTable' , 'Type' )
44
41
pttype .assertEqual ('dos' )
@@ -55,7 +52,6 @@ def test_create_mbr_partition(self):
55
52
# create partition
56
53
path1 = disk .CreatePartition (dbus .UInt64 (1024 ** 2 ), dbus .UInt64 (100 * 1024 ** 2 ), part_type , '' ,
57
54
self .no_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
58
- self .udev_settle ()
59
55
60
56
part = self .bus .get_object (self .iface_prefix , path1 )
61
57
self .assertIsNotNone (part )
@@ -103,7 +99,6 @@ def test_create_mbr_partition(self):
103
99
# create another partition
104
100
path2 = disk .CreatePartition (dbus .UInt64 (1024 ** 2 + (1024 ** 2 + 100 * 1024 ** 2 )), dbus .UInt64 (100 * 1024 ** 2 ),
105
101
part_type , '' , self .no_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
106
- self .udev_settle ()
107
102
108
103
part = self .bus .get_object (self .iface_prefix , path2 )
109
104
self .assertIsNotNone (part )
@@ -113,7 +108,6 @@ def test_create_mbr_partition(self):
113
108
# create yet another partition
114
109
path3 = disk .CreatePartition (dbus .UInt64 (1024 ** 2 + 2 * (1024 ** 2 + 100 * 1024 ** 2 )), dbus .UInt64 (100 * 1024 ** 2 ),
115
110
part_type , '' , self .no_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
116
- self .udev_settle ()
117
111
118
112
part = self .bus .get_object (self .iface_prefix , path3 )
119
113
self .assertIsNotNone (part )
@@ -136,11 +130,11 @@ def create_extended_partition(self, ext_options, log_options, part_type=''):
136
130
# create msdos partition table
137
131
self ._create_format (disk , 'dos' )
138
132
self .addCleanup (self ._remove_format , disk )
133
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
139
134
140
135
# create extended partition
141
136
ext_path = disk .CreatePartition (dbus .UInt64 (1024 ** 2 ), dbus .UInt64 (150 * 1024 ** 2 ), part_type , '' ,
142
137
ext_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
143
- self .udev_settle ()
144
138
145
139
ext_part = self .bus .get_object (self .iface_prefix , ext_path )
146
140
self .assertIsNotNone (ext_part )
@@ -163,7 +157,6 @@ def create_extended_partition(self, ext_options, log_options, part_type=''):
163
157
# create logical partition
164
158
log_path = disk .CreatePartition (dbus .UInt64 (1024 ** 2 ), dbus .UInt64 (50 * 1024 ** 2 ), '' , '' ,
165
159
log_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
166
- self .udev_settle ()
167
160
168
161
log_part = self .bus .get_object (self .iface_prefix , log_path )
169
162
self .assertIsNotNone (log_part )
@@ -180,7 +173,6 @@ def create_extended_partition(self, ext_options, log_options, part_type=''):
180
173
# create one more logical partition
181
174
log_path2 = disk .CreatePartition (dbus .UInt64 (dbus_offset .value + dbus_size .value ), dbus .UInt64 (50 * 1024 ** 2 ), '' , '' ,
182
175
log_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
183
- self .udev_settle ()
184
176
185
177
log_part2 = self .bus .get_object (self .iface_prefix , log_path2 )
186
178
self .assertIsNotNone (log_part2 )
@@ -202,6 +194,7 @@ def test_fill_with_primary_partitions(self):
202
194
# create msdos partition table
203
195
self ._create_format (disk , 'dos' )
204
196
self .addCleanup (self ._remove_format , disk )
197
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
205
198
206
199
options = dbus .Dictionary ({'partition-type' : 'primary' }, signature = 'sv' )
207
200
offset = 1024 ** 2
@@ -210,7 +203,6 @@ def test_fill_with_primary_partitions(self):
210
203
# create primary partition
211
204
path = disk .CreatePartition (dbus .UInt64 (offset + i * (offset + size )), dbus .UInt64 (size ), '' , '' ,
212
205
options , dbus_interface = self .iface_prefix + '.PartitionTable' )
213
- self .udev_settle ()
214
206
215
207
part = self .bus .get_object (self .iface_prefix , path )
216
208
self .assertIsNotNone (part )
@@ -232,6 +224,7 @@ def test_create_gpt_partition(self):
232
224
pttype .assertEqual ('gpt' )
233
225
234
226
self .addCleanup (self ._remove_format , disk )
227
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
235
228
236
229
gpt_name = 'home'
237
230
gpt_type = '933ac7e1-2eb4-4f13-b844-0e14e2aef915'
@@ -241,7 +234,6 @@ def test_create_gpt_partition(self):
241
234
gpt_type , gpt_name ,
242
235
self .no_options , dbus_interface = self .iface_prefix + '.PartitionTable' )
243
236
244
- self .udev_settle ()
245
237
part = self .bus .get_object (self .iface_prefix , path )
246
238
self .assertIsNotNone (part )
247
239
@@ -290,6 +282,7 @@ def test_create_with_format(self):
290
282
self ._create_format (disk , 'dos' )
291
283
292
284
self .addCleanup (self ._remove_format , disk )
285
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
293
286
294
287
# create partition with xfs format
295
288
path = disk .CreatePartitionAndFormat (dbus .UInt64 (1024 ** 2 ), dbus .UInt64 (100 * 1024 ** 2 ), '' , '' ,
@@ -345,6 +338,7 @@ def test_create_with_format_auto_type_mbr(self):
345
338
self ._create_format (disk , 'dos' )
346
339
347
340
self .addCleanup (self ._remove_format , disk )
341
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
348
342
349
343
# create partition with udf format and automatically set partition type
350
344
# it should be 0x07
@@ -376,10 +370,11 @@ def test_create_with_format_auto_type_gpt(self):
376
370
disk = self .get_object ('/block_devices/' + os .path .basename (self .vdevs [0 ]))
377
371
self .assertIsNotNone (disk )
378
372
379
- # create msdos partition table
373
+ # create gpt partition table
380
374
self ._create_format (disk , 'gpt' )
381
375
382
376
self .addCleanup (self ._remove_format , disk )
377
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
383
378
384
379
# create partition with udf format and automatically set partition type
385
380
# it should be ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
@@ -414,9 +409,7 @@ def _remove_format(self, device):
414
409
try :
415
410
device .Format ('empty' , d , dbus_interface = self .iface_prefix + '.Block' )
416
411
except dbus .exceptions .DBusException :
417
- self .udev_settle ()
418
- time .sleep (5 )
419
- device .Format ('empty' , d , dbus_interface = self .iface_prefix + '.Block' )
412
+ pass
420
413
421
414
def _create_format (self , device , ftype ):
422
415
device .Format (ftype , self .no_options , dbus_interface = self .iface_prefix + '.Block' )
@@ -425,9 +418,7 @@ def _remove_partition(self, part):
425
418
try :
426
419
part .Delete (self .no_options , dbus_interface = self .iface_prefix + '.Partition' )
427
420
except dbus .exceptions .DBusException :
428
- self .udev_settle ()
429
- time .sleep (5 )
430
- part .Delete (self .no_options , dbus_interface = self .iface_prefix + '.Partition' )
421
+ pass
431
422
432
423
def _create_partition (self , disk , start = 1024 ** 2 , size = 100 * 1024 ** 2 , fmt = 'xfs' , type = '' ):
433
424
if fmt :
@@ -439,7 +430,6 @@ def _create_partition(self, disk, start=1024**2, size=100 * 1024**2, fmt='xfs',
439
430
self .no_options ,
440
431
dbus_interface = self .iface_prefix + '.PartitionTable' )
441
432
442
- self .udev_settle ()
443
433
part = self .bus .get_object (self .iface_prefix , path )
444
434
self .assertIsNotNone (part )
445
435
@@ -451,14 +441,13 @@ def test_delete(self):
451
441
452
442
self ._create_format (disk , 'dos' )
453
443
self .addCleanup (self ._remove_format , disk )
444
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
454
445
455
446
part = self ._create_partition (disk )
456
447
path = str (part .object_path )
457
448
458
449
part .Delete (self .no_options , dbus_interface = self .iface_prefix + '.Partition' )
459
450
460
- self .udev_settle ()
461
-
462
451
part_name = path .split ('/' )[- 1 ]
463
452
disk_name = os .path .basename (self .vdevs [0 ])
464
453
part_syspath = '/sys/block/%s/%s' % (disk_name , part_name )
@@ -481,6 +470,7 @@ def test_dos_flags(self):
481
470
482
471
self ._create_format (disk , 'dos' )
483
472
self .addCleanup (self ._remove_format , disk )
473
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
484
474
485
475
part = self ._create_partition (disk )
486
476
self .addCleanup (self ._remove_partition , part )
@@ -491,7 +481,6 @@ def test_dos_flags(self):
491
481
# set boot flag (10000000(2), 128(10), 0x80(16))
492
482
part .SetFlags (dbus .UInt64 (128 ), self .no_options ,
493
483
dbus_interface = self .iface_prefix + '.Partition' )
494
- self .udev_settle ()
495
484
496
485
# test flags value on types
497
486
dbus_flags = self .get_property (part , '.Partition' , 'Flags' )
@@ -510,6 +499,7 @@ def test_gpt_flags(self):
510
499
511
500
self ._create_format (disk , 'gpt' )
512
501
self .addCleanup (self ._remove_format , disk )
502
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
513
503
514
504
part = self ._create_partition (disk , fmt = False , type = esp_guid )
515
505
self .addCleanup (self ._remove_partition , part )
@@ -531,7 +521,6 @@ def test_gpt_flags(self):
531
521
# set legacy BIOS bootable flag (100(2), 4(10), 0x4(16))
532
522
part .SetFlags (dbus .UInt64 (4 ), self .no_options ,
533
523
dbus_interface = self .iface_prefix + '.Partition' )
534
- self .udev_settle ()
535
524
536
525
# test flags value on types
537
526
dbus_flags = self .get_property (part , '.Partition' , 'Flags' )
@@ -555,6 +544,7 @@ def test_gpt_type(self):
555
544
556
545
self ._create_format (disk , 'gpt' )
557
546
self .addCleanup (self ._remove_format , disk )
547
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
558
548
559
549
part = self ._create_partition (disk )
560
550
self .addCleanup (self ._remove_partition , part )
@@ -572,7 +562,6 @@ def test_gpt_type(self):
572
562
home_guid = '933ac7e1-2eb4-4f13-b844-0e14e2aef915'
573
563
part .SetType (home_guid , self .no_options ,
574
564
dbus_interface = self .iface_prefix + '.Partition' )
575
- self .udev_settle ()
576
565
577
566
# test flags value on types
578
567
dbus_type = self .get_property (part , '.Partition' , 'Type' )
@@ -589,6 +578,7 @@ def test_dos_type(self):
589
578
590
579
self ._create_format (disk , 'dos' )
591
580
self .addCleanup (self ._remove_format , disk )
581
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
592
582
593
583
part = self ._create_partition (disk )
594
584
self .addCleanup (self ._remove_partition , part )
@@ -606,7 +596,6 @@ def test_dos_type(self):
606
596
part_type = '0x8e' # 'Linux LVM' type, see https://en.wikipedia.org/wiki/Partition_type#PID_8Eh
607
597
part .SetType (part_type , self .no_options ,
608
598
dbus_interface = self .iface_prefix + '.Partition' )
609
- self .udev_settle ()
610
599
611
600
# test flags value on types
612
601
dbus_type = self .get_property (part , '.Partition' , 'Type' )
@@ -624,6 +613,7 @@ def test_resize(self):
624
613
625
614
self ._create_format (disk , 'gpt' )
626
615
self .addCleanup (self ._remove_format , disk )
616
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
627
617
628
618
disk_size = self .get_property (disk , '.Block' , 'Size' )
629
619
@@ -649,8 +639,6 @@ def test_resize(self):
649
639
part .Resize (0 , self .no_options ,
650
640
dbus_interface = self .iface_prefix + '.Partition' )
651
641
652
- self .udev_settle ()
653
-
654
642
part_offset .assertEqual (initial_offset )
655
643
max_size = part_size .value
656
644
part_size .assertGreater (initial_size )
@@ -660,8 +648,6 @@ def test_resize(self):
660
648
part .Resize (new_size , self .no_options ,
661
649
dbus_interface = self .iface_prefix + '.Partition' )
662
650
663
- self .udev_settle ()
664
-
665
651
part_offset .assertEqual (initial_offset )
666
652
# resize should guarantee at least the requested size
667
653
part_size .assertGreater (new_size - 1 )
@@ -671,8 +657,6 @@ def test_resize(self):
671
657
part .Resize (max_size , self .no_options ,
672
658
dbus_interface = self .iface_prefix + '.Partition' )
673
659
674
- self .udev_settle ()
675
-
676
660
part_offset .assertEqual (initial_offset )
677
661
part_size .assertGreater (max_size - 1 )
678
662
part_size .assertLess (disk_size .value )
@@ -683,6 +667,7 @@ def test_name(self):
683
667
684
668
self ._create_format (disk , 'gpt' )
685
669
self .addCleanup (self ._remove_format , disk )
670
+ self .addCleanup (self .wipe_fs , self .vdevs [0 ])
686
671
687
672
part = self ._create_partition (disk )
688
673
self .addCleanup (self ._remove_partition , part )
@@ -700,8 +685,6 @@ def test_name(self):
700
685
part .SetName ('test' , self .no_options ,
701
686
dbus_interface = self .iface_prefix + '.Partition' )
702
687
703
- self .udev_settle ()
704
-
705
688
# test flags value on types
706
689
dbus_name = self .get_property (part , '.Partition' , 'Name' )
707
690
dbus_name .assertEqual ('test' )
0 commit comments