Skip to content

Commit

Permalink
Fixed grub2 unit test
Browse files Browse the repository at this point in the history
Fixed bootloader/config/grub2_test.py due to the changes regarding
linuxefi vs. linux one test is obsolete and another needs to be
updated because the variable substitution done in the dropped
fix_ method does no longer happen.
  • Loading branch information
schaefi committed Jan 15, 2024
1 parent 5e13b64 commit 19fc943
Showing 1 changed file with 5 additions and 51 deletions.
56 changes: 5 additions & 51 deletions test/unit/bootloader/config/grub2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,20 +991,11 @@ def open_file(filename, mode=None):
mock_copy_grub_config_to_efi_path.assert_called_once_with(
'efi_mount_point', 'earlyboot.cfg'
)
assert file_handle_grub.write.call_args_list == [
# first write of grub.cfg, adapting to linux/initrd as variables
call(
'root=rootdev nomodeset console=ttyS0 console=tty0'
'\n'
'root=PARTUUID=xx'
),
# second write of grub.cfg, setting overlay root
call(
'root=overlay:UUID=ID nomodeset console=ttyS0 console=tty0'
'\n'
'root=overlay:UUID=ID'
)
]
file_handle_grub.write.assert_called_once_with == (
'root=overlay:UUID=ID nomodeset console=ttyS0 console=tty0'
'\n'
'root=overlay:UUID=ID'
)
file_handle_grubenv.write.assert_called_once_with(
'root=overlay:UUID=ID'
)
Expand All @@ -1029,43 +1020,6 @@ def open_file(filename, mode=None):
assert 'initrd /initrd' in \
file_handle_menu.write.call_args_list[1][0][0].split(os.linesep)

@patch.object(BootLoaderConfigGrub2, '_mount_system')
@patch.object(BootLoaderConfigGrub2, '_copy_grub_config_to_efi_path')
@patch('kiwi.bootloader.config.grub2.Command.run')
@patch('kiwi.bootloader.config.grub2.Path.which')
def test_setup_disk_image_config_validate_linuxefi(
self, mock_Path_which, mock_Command_run,
mock_copy_grub_config_to_efi_path, mock_mount_system
):
mock_Path_which.return_value = '/path/to/grub2-mkconfig'
self.firmware.efi_mode = Mock(
return_value='uefi'
)
self.bootloader.root_mount = Mock()
self.bootloader.root_mount.mountpoint = 'root_mount_point'
self.bootloader.efi_mount = Mock()
self.bootloader.efi_mount.mountpoint = 'efi_mount_point'
with patch('builtins.open', create=True) as mock_open:
mock_open.return_value = MagicMock(spec=io.IOBase)
file_handle = mock_open.return_value.__enter__.return_value
file_handle.read.return_value = os.linesep.join(
[
'\tlinux ${rel_dirname}/${basename} ...',
'\tinitrd ${rel_dirname}/${initrd}',
]
)
self.bootloader.setup_disk_image_config(
boot_options={
'root_device': 'rootdev', 'boot_device': 'bootdev'
}
)
assert file_handle.write.call_args_list == [
call(
'\tlinux ${rel_dirname}/${basename} ...\n'
'\tinitrd ${rel_dirname}/${initrd}\n'
)
]

@patch.object(BootLoaderConfigGrub2, '_copy_grub_config_to_efi_path')
def test_setup_install_image_config_standard(
self, mock_copy_grub_config_to_efi_path
Expand Down

0 comments on commit 19fc943

Please sign in to comment.