예제 #1
0
    def test_get_arguments(self):
        """Test GetArguments."""
        with pytest.raises(UnavailableStorageError):
            self.bootloader_interface.GetArguments()

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

        storage.bootloader = GRUB2()
        storage.bootloader.boot_args.update(["x=1", "y=2"])
        assert self.bootloader_interface.GetArguments() == ["x=1", "y=2"]
예제 #2
0
    def get_arguments_test(self):
        """Test GetArguments."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.GetArguments()

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

        storage.bootloader = GRUB2()
        storage.bootloader.boot_args.update(["x=1", "y=2"])
        self.assertEqual(self.bootloader_interface.GetArguments(), ["x=1", "y=2"])
예제 #3
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)
예제 #4
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
예제 #5
0
    def setUp(self):
        """Create some device objects to test with.

            This sets up two disks (sda, sdb). The first partition of each
            is a biosboot partition. The second partitions comprise a RAID1
            array formatted as /boot.

            sda additionally contains a third partition formatted as ext4.
        """

        super(GRUBRaidSimpleTest, self).setUp()

        # Make some disks
        self.sda = DiskDevice(name="sda", size=Size("100 GiB"))
        self.sda.format = get_format("disklabel")
        self.sdb = DiskDevice(name="sdb", size=Size("100 GiB"))
        self.sdb.format = get_format("disklabel")

        # Set up biosboot partitions, an mdarray for /boot, and a btrfs array on sda + sdb.
        # Start with the partitions
        self.sda1 = PartitionDevice(name="sda1",
                                    parents=[self.sda],
                                    size=Size("1 MiB"))
        self.sda1.format = get_format("biosboot")
        self.sda2 = PartitionDevice(name="sda2",
                                    parents=[self.sda],
                                    size=Size("500 MiB"))
        self.sda2.format = get_format("mdmember")
        self.sda4 = PartitionDevice(name="sda4",
                                    parents=[self.sda],
                                    size=Size("500 MiB"))
        self.sda4.format = get_format("btrfs")

        self.sdb1 = PartitionDevice(name="sdb1",
                                    parents=[self.sdb],
                                    size=Size("1 MiB"))
        self.sdb1.format = get_format("biosboot")
        self.sdb2 = PartitionDevice(name="sdb2",
                                    parents=[self.sdb],
                                    size=Size("500 MiB"))
        self.sdb2.format = get_format("mdmember")
        self.sdb4 = PartitionDevice(name="sdb4",
                                    parents=[self.sdb],
                                    size=Size("4 GiB"))
        self.sdb4.format = get_format("btrfs")

        # Add an extra partition for /boot on not-RAID
        self.sda3 = PartitionDevice(name="sda3",
                                    parents=[self.sda],
                                    size=Size("500 MiB"))
        self.sda3.format = get_format("ext4", mountpoint="/boot")

        # Pretend that the partitions are real with real parent disks
        for part in (self.sda1, self.sda2, self.sda3, self.sda4, self.sdb1,
                     self.sdb2, self.sdb4):
            part.parents = part.req_disks

        self.boot_md = MDRaidArrayDevice(name="md1",
                                         size=Size("500 MiB"),
                                         parents=[self.sda2, self.sdb2],
                                         level=1,
                                         member_devices=2,
                                         total_devices=2)
        self.boot_md.format = get_format("ext4", mountpoint="/boot")

        # Set up the btrfs raid1 volume with a subvolume for /boot
        self.btrfs_volume = BTRFSVolumeDevice(parents=[self.sda4, self.sdb4],
                                              data_level=RAID1)
        self.btrfs_volume.format = get_format("btrfs")

        self.boot_btrfs = BTRFSSubVolumeDevice(parents=[self.btrfs_volume])
        self.boot_btrfs.format = get_format("btrfs", mountpoint="/boot")

        self.grub = GRUB2()