Skip to content

Commit ab2add2

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 e4fcfe3 commit ab2add2

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

pkg/disk/partition_table_test.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,112 @@ 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+
// Partition type used for raw UKI UEFI binaries, more info at:
2720+
// https://gitlab.com/CentOS/automotive/src/ukiboot/-/blob/main/README.md
2721+
PartType: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2722+
PartLabel: "ukiboot_a",
2723+
FilesystemTypedCustomization: blueprint.FilesystemTypedCustomization{
2724+
FSType: "none",
2725+
},
2726+
},
2727+
{
2728+
MinSize: 64 * datasizes.MiB,
2729+
// Partition type used for raw UKI UEFI binaries, more info at:
2730+
// https://gitlab.com/CentOS/automotive/src/ukiboot/-/blob/main/README.md
2731+
PartType: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2732+
PartLabel: "ukiboot_b",
2733+
FilesystemTypedCustomization: blueprint.FilesystemTypedCustomization{
2734+
FSType: "none",
2735+
},
2736+
},
2737+
{
2738+
MinSize: 1 * datasizes.MiB,
2739+
// Partition type used for UKIBoot control data, more info at:
2740+
// https://gitlab.com/CentOS/automotive/src/ukiboot/-/blob/main/README.md
2741+
PartType: "FEFD9070-346F-4C9A-85E6-17F07F922773",
2742+
PartLabel: "ukibootctl",
2743+
FilesystemTypedCustomization: blueprint.FilesystemTypedCustomization{
2744+
FSType: "none",
2745+
},
2746+
},
2747+
},
2748+
},
2749+
options: &disk.CustomPartitionTableOptions{
2750+
BootMode: platform.BOOT_UEFI,
2751+
PartitionTableType: disk.PT_GPT,
2752+
DefaultFSType: disk.FS_XFS,
2753+
Architecture: arch.ARCH_X86_64,
2754+
},
2755+
expected: &disk.PartitionTable{
2756+
Type: disk.PT_GPT,
2757+
Size: (1 + 200 + 64 + 64 + 1 + 1) * datasizes.MiB,
2758+
UUID: "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
2759+
Partitions: []disk.Partition{
2760+
// ESP created by BOOT_UEFI option
2761+
{
2762+
Start: 1 * datasizes.MiB,
2763+
Size: 200 * datasizes.MiB,
2764+
Type: disk.EFISystemPartitionGUID,
2765+
UUID: disk.EFISystemPartitionUUID,
2766+
Payload: &disk.Filesystem{
2767+
Type: "vfat",
2768+
UUID: disk.EFIFilesystemUUID,
2769+
Mountpoint: "/boot/efi",
2770+
Label: "ESP",
2771+
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
2772+
FSTabFreq: 0,
2773+
FSTabPassNo: 2,
2774+
},
2775+
},
2776+
// Raw UKI partitions from customizations
2777+
{
2778+
Start: 201 * datasizes.MiB,
2779+
Size: 64 * datasizes.MiB,
2780+
Type: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2781+
Label: "ukiboot_a",
2782+
UUID: "fb180daf-48a7-4ee0-b10d-394651850fd4",
2783+
Payload: nil,
2784+
},
2785+
{
2786+
Start: 265 * datasizes.MiB,
2787+
Size: 64 * datasizes.MiB,
2788+
Type: "DF331E4D-BE00-463F-B4A7-8B43E18FB53A",
2789+
Label: "ukiboot_b",
2790+
UUID: "a178892e-e285-4ce1-9114-55780875d64e",
2791+
Payload: nil,
2792+
},
2793+
{
2794+
Start: 329 * datasizes.MiB,
2795+
Size: 1 * datasizes.MiB,
2796+
Type: "FEFD9070-346F-4C9A-85E6-17F07F922773",
2797+
Label: "ukibootctl",
2798+
UUID: "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
2799+
Payload: nil,
2800+
},
2801+
{
2802+
Start: 330 * datasizes.MiB,
2803+
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
2804+
Type: disk.RootPartitionX86_64GUID,
2805+
UUID: "f83b8e88-3bbf-457a-ab99-c5b252c7429c",
2806+
Payload: &disk.Filesystem{
2807+
Type: "xfs",
2808+
Label: "root",
2809+
Mountpoint: "/",
2810+
UUID: "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
2811+
FSTabOptions: "defaults",
2812+
FSTabFreq: 0,
2813+
FSTabPassNo: 0,
2814+
},
2815+
},
2816+
},
2817+
},
2818+
},
27132819
}
27142820

27152821
for name := range testCases {

0 commit comments

Comments
 (0)