def test_grub1efi():
    config = Grub1EFIConfig(context_wrap(GRUB1_EFI_CFG))
    result = GrubConf(None, None, None, config)
    assert config
    assert result.kernel_initrds['grub_kernels'][0] == 'vmlinuz-2.6.32-71.el6.x86_64'
    assert result.kernel_initrds['grub_initrds'][0] == 'initramfs-2.6.32-71.el6.x86_64.img'
    assert result.is_kdump_iommu_enabled is False
    assert result.get_grub_cmdlines() == result.get_grub_cmdlines('/vmlinuz')
    assert len(result.get_grub_cmdlines()) == 1
    assert result.version == 1
    assert result.is_efi is True
Exemple #2
0
def test_grub2_efi_cmdline():
    grub1 = Grub1Config(context_wrap(GRUB1_TEMPLATE))
    grub2 = Grub2Config(context_wrap(GRUB2_TEMPLATE))
    grub1e = Grub1EFIConfig(context_wrap(GRUB1_EFI_CFG))
    grub2e = Grub2EFIConfig(context_wrap(GRUB2_EFI_CFG))
    cmdline = CmdLine(context_wrap(CMDLINE_V2))
    sys_firmware = LsSysFirmware(context_wrap(SYS_FIRMWARE_DIR_EFI))
    result = GrubConf(grub1, grub2, grub1e, grub2e, None, None, None, cmdline,
                      sys_firmware, None)
    assert result.get_grub_cmdlines() == result.get_grub_cmdlines('/vmlinuz')
    assert result.get_grub_cmdlines('rescue')[0].name.startswith(
        "'Red Hat Enterprise Linux Server (0-rescue")
    assert len(result.get_grub_cmdlines()) == 4
    assert result.version == 2
    assert result.is_efi is True
Exemple #3
0
def test_grub1_efi_cmdline():
    grub1 = Grub1Config(context_wrap(GRUB1_TEMPLATE))
    grub2 = Grub2Config(context_wrap(GRUB2_TEMPLATE))
    grub1e = Grub1EFIConfig(context_wrap(GRUB1_EFI_CFG))
    grub2e = Grub2EFIConfig(context_wrap(GRUB2_EFI_CFG))
    cmdline = CmdLine(context_wrap(CMDLINE_V1))
    sys_firmware = LsSysFirmware(context_wrap(SYS_FIRMWARE_DIR_EFI))
    result = GrubConf(grub1, grub2, grub1e, grub2e, None, None, None, cmdline,
                      sys_firmware, None)
    assert result.kernel_initrds['grub_kernels'][
        0] == 'vmlinuz-2.6.32-71.el6.x86_64'
    assert result.kernel_initrds['grub_initrds'][
        0] == 'initramfs-2.6.32-71.el6.x86_64.img'
    assert result.is_kdump_iommu_enabled is False
    assert len(result.get_grub_cmdlines()) == 1
    assert result.version == 1
    assert result.is_efi is True
Exemple #4
0
def test_grub2_efi_rpms():
    grub1 = Grub1Config(context_wrap(GRUB1_TEMPLATE))
    grub2 = Grub2Config(context_wrap(GRUB2_TEMPLATE))
    grub1e = Grub1EFIConfig(context_wrap(GRUB1_EFI_CFG))
    grub2e = Grub2EFIConfig(context_wrap(GRUB2_EFI_CFG))
    rpms = InstalledRpms(context_wrap(INSTALLED_RPMS_V2))
    cmdline = CmdLine(context_wrap(CMDLINE_V1))
    sys_firmware = LsSysFirmware(context_wrap(SYS_FIRMWARE_DIR_EFI))
    result = GrubConf(grub1, grub2, grub1e, grub2e, None, None, rpms, cmdline,
                      sys_firmware, None)
    assert result.kernel_initrds['grub_initrds'][
        0] == 'initramfs-3.10.0-514.16.1.el7.x86_64.img'
    assert result.get_grub_cmdlines() == result.get_grub_cmdlines('/vmlinuz')
    assert result.get_grub_cmdlines('rescue')[0].name.startswith(
        "'Red Hat Enterprise Linux Server (0-rescue")
    assert len(result.get_grub_cmdlines()) == 4
    assert result.version == 2
    assert result.is_efi is True
def test_grub1_rpms():
    grub1 = Grub1Config(context_wrap(GRUB1_TEMPLATE))
    grub2 = Grub2Config(context_wrap(GRUB2_TEMPLATE))
    grub1e = Grub1EFIConfig(context_wrap(GRUB1_EFI_CFG))
    grub2e = Grub2EFIConfig(context_wrap(GRUB2_EFI_CFG))
    rpms = InstalledRpms(context_wrap(INSTALLED_RPMS_V1))
    cmdline = CmdLine(context_wrap(CMDLINE_V2))
    sys_firmware = LsSysFirmware(context_wrap(SYS_FIRMWARE_DIR_NOEFI))
    result = GrubConf(grub1, grub2, grub1e, grub2e, rpms, cmdline,
                      sys_firmware)
    assert result.kernel_initrds['grub_kernels'][
        0] == 'vmlinuz-2.6.32-642.el6.x86_64'
    assert result.kernel_initrds['grub_initrds'][
        0] == 'initramfs-2.6.32-642.el6.x86_64.img'
    assert result.is_kdump_iommu_enabled is True
    assert result.get_grub_cmdlines() == result.get_grub_cmdlines('/vmlinuz')
    assert len(result.get_grub_cmdlines()) == 3
    assert result.version == 1
    assert result.is_efi is False
def test_get_grub_cmdlines_none():
    grub1 = Grub1Config(context_wrap(GRUB1_TEMPLATE))
    grub2 = Grub2Config(context_wrap(GRUB2_TEMPLATE))
    cmdline = CmdLine(context_wrap(CMDLINE_V2))
    sys_firmware = LsSysFirmware(context_wrap(SYS_FIRMWARE_DIR_EFI))
    with pytest.raises(ParseException) as pe:
        GrubConf(grub1, grub2, None, None, None, cmdline, sys_firmware)
    assert "No valid grub configuration is found." in str(pe)

    grub1e = Grub1EFIConfig(context_wrap(GRUB1_TEMPLATE))
    grub2e = Grub2EFIConfig(context_wrap(GRUB2_TEMPLATE))
    rpms = InstalledRpms(context_wrap(INSTALLED_RPMS_V2))
    with pytest.raises(ParseException) as pe:
        GrubConf(None, None, grub1e, grub2e, rpms, None, None)
    assert "No valid grub configuration is found." in str(pe)

    grub2e = Grub2EFIConfig(context_wrap(GRUB2_EFI_CFG))
    rpms = InstalledRpms(context_wrap(INSTALLED_RPMS_V2))
    with pytest.raises(ParseException) as pe:
        GrubConf(grub1, None, grub1e, None, rpms, None, None)
    assert "No valid grub configuration is found." in str(pe)
def test_grub2_rpms():
    grub1 = Grub1Config(context_wrap(GRUB1_TEMPLATE))
    grub2 = Grub2Config(context_wrap(GRUB2_TEMPLATE))
    grub1e = Grub1EFIConfig(context_wrap(GRUB1_EFI_CFG))
    grub2e = Grub2EFIConfig(context_wrap(GRUB2_EFI_CFG))
    rpms = InstalledRpms(context_wrap(INSTALLED_RPMS_V2))
    cmdline = CmdLine(context_wrap(CMDLINE_V1))
    result = GrubConf(grub1, grub2, grub1e, grub2e, rpms, cmdline, None)
    assert result.kernel_initrds['grub_kernels'][
        0] == 'vmlinuz-3.10.0-327.el7.x86_64'
    assert result.kernel_initrds['grub_initrds'][
        0] == 'initramfs-3.10.0-327.el7.x86_64.img'
    assert result.is_kdump_iommu_enabled is False
    assert result.get_grub_cmdlines(
        '/vmlinuz-3.10.0'
    )[0].name == "'Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-4f80b3d4-90ba-4545-869c-febdecc586ce'"
    assert result.get_grub_cmdlines('test') == []
    assert result.get_grub_cmdlines('') == []
    assert len(result.get_grub_cmdlines()) == 2
    assert result.version == 2
    assert result.is_efi is False
Exemple #8
0
def test_grub_conf():
    expected_result = {'grub_kernels': ["vmlinuz-2.6.18-194.8.1.el5", "vmlinuz-2.6.18-194.17.1.el5"],
                       'grub_initrds': ["initrd-2.6.18-194.8.1.el5.img", "initramfs-2.6.18-194.8.1.el5.img"]}
    assert expected_result == Grub1Config(context_wrap(GRUB1_CONF_3)).kernel_initrds

    expected_result = {'grub_kernels': ["vmlinuz-2.6.18-194.8.1.el5"],
                       'grub_initrds': []}

    grub1 = Grub1Config(context_wrap(GRUB1_CONF_4))
    assert grub1.is_kdump_iommu_enabled is False
    assert expected_result == grub1.kernel_initrds
    assert grub1.get_current_title() is None

    grub1 = Grub1Config(context_wrap(GRUB1_CONF_5))
    assert grub1.is_kdump_iommu_enabled is False
    assert grub1.get_current_title() == [
        ('title_name', '(2.6.18-194.8.1.el5)'),
        ('kernel', None), ('module', '/2.6.18-194.8.1.el5.img')]

    grub1 = Grub1Config(context_wrap(GRUB1_CONF_6))
    assert grub1.is_kdump_iommu_enabled is False
    assert grub1.get_current_title() == [
        ('title_name', 'Red Hat Enterprise Linux Server'),
        ('kernel', 'test'), ('module', '/2.6.18-194.8.1.el5.img')]

    grub1 = Grub1Config(context_wrap(GRUB1_CONF_7))
    assert grub1.is_kdump_iommu_enabled is False
    assert grub1.get_current_title() is None

    grub1 = Grub1Config(context_wrap(GRUB1_CONF_8))
    assert grub1.is_kdump_iommu_enabled is False

    grub1efi = Grub1EFIConfig(context_wrap(GRUB1_CONF_4))
    assert grub1efi.get_current_title() is None

    grub1efi = Grub1EFIConfig(context_wrap(GRUB1_CONF_5))
    assert grub1efi.get_current_title() == [
        ('title_name', '(2.6.18-194.8.1.el5)'),
        ('kernel', None), ('module', '/2.6.18-194.8.1.el5.img')]

    grub1efi = Grub1EFIConfig(context_wrap(GRUB1_CONF_6))
    assert grub1efi.get_current_title() == [
        ('title_name', 'Red Hat Enterprise Linux Server'),
        ('kernel', 'test'), ('module', '/2.6.18-194.8.1.el5.img')]

    grub1efi = Grub1EFIConfig(context_wrap(GRUB1_CONF_7))
    assert grub1efi.get_current_title() is None

    grub_conf = Grub2Config(context_wrap(GRUB2_CFG_1))['menuentry']
    assert ('load_video', None) in grub_conf[0]
    assert ('load_env', None) not in grub_conf[0]
    assert ('insmod', 'gzio') in grub_conf[0]

    expected_result = {'grub_kernels': ["vmlinuz-3.10.0-229.el7.x86_64", "vmlinuz-3.10.0-123.13.2.el7.x86_64",
                                        "vmlinuz-3.10.0-123.el7.x86_64", "vmlinuz-0-rescue-13798ffcbc1ed4374f3f2e0fa6c923ad"],
                       'grub_initrds': ["initramfs-3.10.0-229.el7.x86_64.img", "initramfs-3.10.0-123.13.2.el7.x86_64.img",
                                        "initramfs-3.10.0-123.el7.x86_64.img", "initramfs-0-rescue-13798ffcbc1ed4374f3f2e0fa6c923ad.img"]}
    assert expected_result == Grub2Config(context_wrap(GRUB2_CFG_2)).kernel_initrds

    grub_conf = Grub2Config(context_wrap(GRUB2_CFG_3))
    assert ('load_video', None) in grub_conf['menuentry'][0]
    assert grub_conf.is_kdump_iommu_enabled is False