Ejemplo n.º 1
0
 def test_grub_install_raise_exception_on_arm64_no_uefi(self):
     self.m_distro_get_architecture.return_value = 'arm64'
     self.m_platform_machine.return_value = 'aarch64'
     uefi = False
     devices = ['foobar']
     with self.assertRaises(RuntimeError):
         install_grub.install_grub(devices, self.target, uefi, {})
Ejemplo n.º 2
0
    def test_uefi_grub_install_ubuntu(self):
        devices = ['/dev/disk-a-part1']
        uefi = True
        update_nvram = True
        grubcfg = {'update_nvram': update_nvram}
        grub_conf = self.tmp_path('grubconf')
        new_params = []
        grub_name = 'grub-efi-amd64'
        grub_target = 'x86_64-efi'
        grub_cmd = 'grub-install'
        self.m_get_grub_package_name.return_value = (grub_name, grub_target)
        self.m_get_grub_config_file.return_value = grub_conf
        self.m_get_carryover_params.return_value = new_params
        self.m_get_grub_install_command.return_value = grub_cmd
        self.m_gen_uefi_install_commands.return_value = ([['/bin/true']],
                                                         [['/bin/false']])

        install_grub.install_grub(devices, self.target, uefi, grubcfg)

        self.m_distro_get_distroinfo.assert_called_with(target=self.target)
        self.m_distro_get_architecture.assert_called_with(target=self.target)
        self.assertEqual(0, self.m_distro_rpm_get_dist_id.call_count)
        self.m_get_grub_package_name.assert_called_with('amd64', uefi, None)
        self.m_get_grub_config_file.assert_called_with(self.target,
                                                       self.distroinfo.family)
        self.m_get_carryover_params.assert_called_with(self.distroinfo)
        self.m_prepare_grub_dir.assert_called_with(self.target, grub_conf)
        self.m_write_grub_config.assert_called_with(self.target, grubcfg,
                                                    grub_conf, new_params)
        self.m_get_grub_install_command.assert_called_with(
            uefi, self.distroinfo, self.target)
        self.m_gen_uefi_install_commands.assert_called_with(
            grub_name, grub_target, grub_cmd, update_nvram, self.distroinfo,
            devices, self.target)

        self.m_subp.assert_has_calls([
            mock.call(['/bin/true'],
                      env=self.env,
                      capture=True,
                      target=self.target),
            mock.call(['/bin/false'],
                      env=self.env,
                      capture=True,
                      target=self.target),
        ])
Ejemplo n.º 3
0
 def test_grub_install_raise_exception_on_no_target(self):
     devices = ['foobar']
     with self.assertRaises(ValueError):
         install_grub.install_grub(devices, None, False, {})
Ejemplo n.º 4
0
 def test_grub_install_raise_exception_on_armv7(self):
     self.m_distro_get_architecture.return_value = 'armhf'
     self.m_platform_machine.return_value = 'armv7l'
     devices = ['foobar']
     with self.assertRaises(RuntimeError):
         install_grub.install_grub(devices, self.target, False, {})
Ejemplo n.º 5
0
 def test_grub_install_raise_exception_on_no_devices(self):
     devices = []
     with self.assertRaises(ValueError):
         install_grub.install_grub(devices, self.target, False, {})