@@ -319,13 +319,17 @@ def test__uefi_bootloader_with_entry_removal(
319
319
mock_partition .return_value = self .fake_dev
320
320
mock_utils_efi_part .return_value = '1'
321
321
mock_efi_bl .return_value = ['EFI/BOOT/BOOTX64.EFI' ]
322
- stdeer_msg = """
323
- efibootmgr: ** Warning ** : Boot0004 has same label ironic1\n
324
- efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
325
- """
322
+ stdout_msg = """
323
+ BootCurrent: 0001
324
+ Timeout: 0 seconds
325
+ BootOrder: 0000,00001
326
+ Boot0000: ironic1 HD(1, GPT,4f3c6294-bf9b-4208-9808-be45dfc34b5c)File(\EFI\Boot\BOOTX64.EFI)
327
+ Boot0001: ironic2 HD(1, GPT,4f3c6294-bf9b-4208-9808-111111111112)File(\EFI\Boot\BOOTX64.EFI)
328
+ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51)
329
+ """ # noqa This is a giant literal string for testing.
326
330
mock_execute .side_effect = iter ([('' , '' ), ('' , '' ),
327
331
('' , '' ), ('' , '' ),
328
- ('' , '' ), ('' , stdeer_msg ),
332
+ (stdout_msg , '' ), ('' , '' ),
329
333
('' , '' ), ('' , '' ),
330
334
('' , '' ), ('' , '' )])
331
335
@@ -336,12 +340,11 @@ def test__uefi_bootloader_with_entry_removal(
336
340
mock .call ('mount' , self .fake_efi_system_part ,
337
341
self .fake_dir + '/boot/efi' ),
338
342
mock .call ('efibootmgr' , '-v' ),
343
+ mock .call ('efibootmgr' , '-b' , '0000' , '-B' ),
339
344
mock .call ('efibootmgr' , '-v' , '-c' , '-d' , self .fake_dev ,
340
345
'-p' , '1' , '-w' ,
341
346
'-L' , 'ironic1' , '-l' ,
342
347
'\\ EFI\\ BOOT\\ BOOTX64.EFI' ),
343
- mock .call ('efibootmgr' , '-b' , '0004' , '-B' ),
344
- mock .call ('efibootmgr' , '-b' , '0005' , '-B' ),
345
348
mock .call ('umount' , self .fake_dir + '/boot/efi' ,
346
349
attempts = 3 , delay_on_retry = True ),
347
350
mock .call ('sync' )]
@@ -356,7 +359,7 @@ def test__uefi_bootloader_with_entry_removal(
356
359
mock_efi_bl .assert_called_once_with (self .fake_dir + '/boot/efi' )
357
360
mock_execute .assert_has_calls (expected )
358
361
mock_utils_efi_part .assert_called_once_with (self .fake_dev )
359
- self .assertEqual (10 , mock_execute .call_count )
362
+ self .assertEqual (9 , mock_execute .call_count )
360
363
361
364
@mock .patch .object (hardware , 'is_md_device' , lambda * _ : False )
362
365
@mock .patch .object (os .path , 'exists' , lambda * _ : False )
@@ -2259,8 +2262,19 @@ def test__manage_uefi_found_csv(self, mkdir_mock, mock_utils_efi_part,
2259
2262
# Mild difference, Ubuntu ships a file without a 0xFEFF delimiter
2260
2263
# at the start of the file, where as Red Hat *does*
2261
2264
csv_file_data = u'shimx64.efi,Vendor String,,Grub2MadeUSDoThis\n '
2265
+ # This test also handles deleting a pre-existing matching vendor
2266
+ # string in advance.
2267
+ dupe_entry = """
2268
+ BootCurrent: 0001
2269
+ Timeout: 0 seconds
2270
+ BootOrder: 0000,00001
2271
+ Boot0000: Vendor String HD(1, GPT,4f3c6294-bf9b-4208-9808-be45dfc34b5c)File(\EFI\Boot\BOOTX64.EFI)
2272
+ Boot0001: Vendor String HD(2, GPT,4f3c6294-bf9b-4208-9808-be45dfc34b5c)File(\EFI\Boot\BOOTX64.EFI)
2273
+ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51)
2274
+ """ # noqa This is a giant literal string for testing.
2262
2275
2263
2276
mock_execute .side_effect = iter ([('' , '' ), ('' , '' ),
2277
+ ('' , '' ), (dupe_entry , '' ),
2264
2278
('' , '' ), ('' , '' ),
2265
2279
('' , '' ), ('' , '' ),
2266
2280
('' , '' )])
@@ -2271,6 +2285,8 @@ def test__manage_uefi_found_csv(self, mkdir_mock, mock_utils_efi_part,
2271
2285
mock .call ('mount' , self .fake_efi_system_part ,
2272
2286
self .fake_dir + '/boot/efi' ),
2273
2287
mock .call ('efibootmgr' , '-v' ),
2288
+ mock .call ('efibootmgr' , '-b' , '0000' , '-B' ),
2289
+ mock .call ('efibootmgr' , '-b' , '0001' , '-B' ),
2274
2290
mock .call ('efibootmgr' , '-v' , '-c' , '-d' , self .fake_dev ,
2275
2291
'-p' , '1' , '-w' ,
2276
2292
'-L' , 'Vendor String' , '-l' ,
@@ -2285,7 +2301,7 @@ def test__manage_uefi_found_csv(self, mkdir_mock, mock_utils_efi_part,
2285
2301
mkdir_mock .assert_called_once_with (self .fake_dir + '/boot/efi' )
2286
2302
mock_efi_bl .assert_called_once_with (self .fake_dir + '/boot/efi' )
2287
2303
mock_execute .assert_has_calls (expected )
2288
- self .assertEqual (7 , mock_execute .call_count )
2304
+ self .assertEqual (9 , mock_execute .call_count )
2289
2305
2290
2306
@mock .patch .object (os .path , 'exists' , lambda * _ : False )
2291
2307
@mock .patch .object (image , '_get_efi_bootloaders' , autospec = True )
@@ -2453,6 +2469,7 @@ def test__run_efibootmgr_no_bootloaders(self, mock_execute, mock_dispatch):
2453
2469
mock_execute .assert_has_calls (expected )
2454
2470
2455
2471
def test__run_efibootmgr (self , mock_execute , mock_dispatch ):
2472
+ mock_execute .return_value = ('' , '' )
2456
2473
result = image ._run_efibootmgr (['EFI/BOOT/BOOTX64.EFI' ],
2457
2474
self .fake_dev ,
2458
2475
self .fake_efi_system_part ,
0 commit comments