Beispiel #1
0
    def is_efi_test(self):
        """Test IsEFI."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.IsEFI()

        storage = Mock()
        self.bootloader_module.on_storage_changed(storage)

        storage.bootloader = GRUB2()
        self.assertEqual(self.bootloader_interface.IsEFI(), False)

        storage.bootloader = EFIGRUB()
        self.assertEqual(self.bootloader_interface.IsEFI(), True)
Beispiel #2
0
    def test_is_efi(self):
        """Test IsEFI."""
        with pytest.raises(UnavailableStorageError):
            self.bootloader_interface.IsEFI()

        storage = Mock()
        self.bootloader_module.on_storage_changed(storage)

        storage.bootloader = GRUB2()
        assert self.bootloader_interface.IsEFI() is False

        storage.bootloader = EFIGRUB()
        assert self.bootloader_interface.IsEFI() is True
Beispiel #3
0
    def create_bls_entries_test(self, exec_mock):
        """Test the installation task that creates BLS entries."""
        version = "4.17.7-200.fc28.x86_64"
        storage = Mock()

        with tempfile.TemporaryDirectory() as root:
            task = CreateBLSEntriesTask(storage=storage,
                                        sysroot=root,
                                        payload_type=PAYLOAD_TYPE_RPM_OSTREE,
                                        kernel_versions=[version])
            task.run()
            exec_mock.assert_not_called()

        exec_mock.reset_mock()

        with tempfile.TemporaryDirectory() as root:
            os.makedirs(root + "/usr/sbin/", exist_ok=True)
            open(root + "/usr/sbin/new-kernel-pkg", 'wb').close()

            task = CreateBLSEntriesTask(storage=storage,
                                        sysroot=root,
                                        payload_type=PAYLOAD_TYPE_LIVE_IMAGE,
                                        kernel_versions=[version])
            task.run()
            exec_mock.assert_not_called()

        exec_mock.reset_mock()
        exec_mock.return_value = 0

        with tempfile.TemporaryDirectory() as root:
            os.makedirs(root + "/boot/loader/entries/", exist_ok=True)
            open(root + "/boot/loader/entries/fake.conf", 'wb').close()

            task = CreateBLSEntriesTask(storage=storage,
                                        sysroot=root,
                                        payload_type=PAYLOAD_TYPE_LIVE_IMAGE,
                                        kernel_versions=[version])
            task.run()

            exec_mock.assert_has_calls([
                mock.call("kernel-install", [
                    "add", "4.17.7-200.fc28.x86_64",
                    "/lib/modules/4.17.7-200.fc28.x86_64/vmlinuz"
                ],
                          root=root),
                mock.call("grub2-mkconfig", ["-o", "/etc/grub2.cfg"],
                          root=root)
            ])
            self.assertFalse(
                os.path.exists(root + "/boot/loader/entries/fake.conf"))

        exec_mock.reset_mock()
        exec_mock.return_value = 0
        storage = Mock(bootloader=EFIGRUB())

        with tempfile.TemporaryDirectory() as root:
            task = CreateBLSEntriesTask(storage=storage,
                                        sysroot=root,
                                        payload_type=PAYLOAD_TYPE_LIVE_IMAGE,
                                        kernel_versions=[version])
            task.run()
            exec_mock.assert_has_calls([
                mock.call("kernel-install", [
                    "add", "4.17.7-200.fc28.x86_64",
                    "/lib/modules/4.17.7-200.fc28.x86_64/vmlinuz"
                ],
                          root=root),
                mock.call("grub2-mkconfig", ["-o", "/etc/grub2-efi.cfg"],
                          root=root)
            ])