Skip to content

Commit 37849bf

Browse files
disk: Add a test case for creating UKIBoot protocol partition types
Add a test for the creation of UKIBoot and UKIBoot control partitions as required by the UKIBoot protocol. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 parent e781848 commit 37849bf

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

pkg/disk/partition_table_test.go

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,106 @@ func TestNewCustomPartitionTable(t *testing.T) {
27102710
},
27112711
},
27122712
},
2713+
"ukiboot": {
2714+
customizations: &blueprint.DiskCustomization{
2715+
Type: "gpt",
2716+
Partitions: []blueprint.PartitionCustomization{
2717+
{
2718+
MinSize: 64 * datasizes.MiB,
2719+
PartType: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2720+
PartLabel: "ukiboot_a",
2721+
FilesystemTypedCustomization: blueprint.FilesystemTypedCustomization{
2722+
FSType: "none",
2723+
},
2724+
},
2725+
{
2726+
MinSize: 64 * datasizes.MiB,
2727+
PartType: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2728+
PartLabel: "ukiboot_b",
2729+
FilesystemTypedCustomization: blueprint.FilesystemTypedCustomization{
2730+
FSType: "none",
2731+
},
2732+
},
2733+
{
2734+
MinSize: 1 * datasizes.MiB,
2735+
PartType: "FEFD9070-346F-4C9A-85E6-17F07F922773",
2736+
PartLabel: "ukibootctl",
2737+
FilesystemTypedCustomization: blueprint.FilesystemTypedCustomization{
2738+
FSType: "none",
2739+
},
2740+
},
2741+
},
2742+
},
2743+
options: &disk.CustomPartitionTableOptions{
2744+
BootMode: platform.BOOT_UEFI,
2745+
PartitionTableType: disk.PT_GPT,
2746+
DefaultFSType: disk.FS_XFS,
2747+
Architecture: arch.ARCH_X86_64,
2748+
},
2749+
expected: &disk.PartitionTable{
2750+
Type: disk.PT_GPT,
2751+
Size: (1 + 200 + 64 + 64 + 1 + 1) * datasizes.MiB,
2752+
UUID: "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
2753+
Partitions: []disk.Partition{
2754+
// ESP created by BOOT_UEFI option
2755+
{
2756+
Start: 1 * datasizes.MiB,
2757+
Size: 200 * datasizes.MiB,
2758+
Type: disk.EFISystemPartitionGUID,
2759+
UUID: disk.EFISystemPartitionUUID,
2760+
Payload: &disk.Filesystem{
2761+
Type: "vfat",
2762+
UUID: disk.EFIFilesystemUUID,
2763+
Mountpoint: "/boot/efi",
2764+
Label: "ESP",
2765+
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
2766+
FSTabFreq: 0,
2767+
FSTabPassNo: 2,
2768+
},
2769+
},
2770+
// Raw UKI partitions from customizations
2771+
{
2772+
Start: 201 * datasizes.MiB,
2773+
Size: 64 * datasizes.MiB,
2774+
Type: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2775+
Label: "ukiboot_a",
2776+
UUID: "fb180daf-48a7-4ee0-b10d-394651850fd4",
2777+
Payload: nil,
2778+
},
2779+
{
2780+
Start: 265 * datasizes.MiB,
2781+
Size: 64 * datasizes.MiB,
2782+
Type: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2783+
Label: "ukiboot_b",
2784+
UUID: "a178892e-e285-4ce1-9114-55780875d64e",
2785+
Payload: nil,
2786+
},
2787+
{
2788+
Start: 329 * datasizes.MiB,
2789+
Size: 1 * datasizes.MiB,
2790+
Type: "FEFD9070-346F-4C9A-85E6-17F07F922773",
2791+
Label: "ukibootctl",
2792+
UUID: "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
2793+
Payload: nil,
2794+
},
2795+
{
2796+
Start: 330 * datasizes.MiB,
2797+
Size: 1*datasizes.MiB - (disk.DefaultSectorSize + (128 * 128)), // grows by 1 grain size (1 MiB) minus the unaligned size of the header to fit the gpt footer
2798+
Type: disk.RootPartitionX86_64GUID,
2799+
UUID: "f83b8e88-3bbf-457a-ab99-c5b252c7429c",
2800+
Payload: &disk.Filesystem{
2801+
Type: "xfs",
2802+
Label: "root",
2803+
Mountpoint: "/",
2804+
UUID: "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
2805+
FSTabOptions: "defaults",
2806+
FSTabFreq: 0,
2807+
FSTabPassNo: 0,
2808+
},
2809+
},
2810+
},
2811+
},
2812+
},
27132813
}
27142814

27152815
for name := range testCases {

0 commit comments

Comments
 (0)