Skip to content

Commit

Permalink
disk: add a test partition table with swap
Browse files Browse the repository at this point in the history
Add a new partition table to the TestPartitionTables that includes a
swap partition.  These partition tables are used in multiple tests in
disk_test.go.
  • Loading branch information
achilleas-k committed Nov 27, 2024
1 parent 22ef622 commit 3ec3269
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/disk/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func TestCreatePartitionTable(t *testing.T) {
// /boot and subdirectories is exempt from this rule
return nil
}

// go up the path and check every sizeable
for idx, ent := range path {
if sz, ok := ent.(disk.Sizeable); ok {
Expand Down
61 changes: 61 additions & 0 deletions pkg/disk/partition_table_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,66 @@ var TestPartitionTables = map[string]PartitionTable{
},
},

"plain-swap": {
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
Type: PT_GPT,
Partitions: []Partition{
{
Size: 1 * MiB,
Bootable: true,
Type: BIOSBootPartitionGUID,
UUID: BIOSBootPartitionUUID,
},
{
Size: 200 * MiB,
Type: EFISystemPartitionGUID,
UUID: EFISystemPartitionUUID,
Payload: &Filesystem{
Type: "vfat",
UUID: EFIFilesystemUUID,
Mountpoint: "/boot/efi",
Label: "EFI-SYSTEM",
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
FSTabFreq: 0,
FSTabPassNo: 2,
},
},
{
Size: 500 * MiB,
Type: FilesystemDataGUID,
UUID: FilesystemDataUUID,
Payload: &Filesystem{
Type: "xfs",
Mountpoint: "/boot",
Label: "boot",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
{
Size: 512 * MiB,
Type: SwapPartitionGUID,
Payload: &Swap{
Label: "swap",
FSTabOptions: "defaults",
},
},
{
Type: FilesystemDataGUID,
UUID: RootPartitionUUID,
Payload: &Filesystem{
Type: "xfs",
Label: "root",
Mountpoint: "/",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
},
},

"plain-noboot": {
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
Type: PT_GPT,
Expand Down Expand Up @@ -306,6 +366,7 @@ func TestPartitionTableFeatures(t *testing.T) {
}
testCases := []testCase{
{"plain", partitionTableFeatures{XFS: true, FAT: true}},
{"plain-swap", partitionTableFeatures{XFS: true, FAT: true}},
{"luks", partitionTableFeatures{XFS: true, FAT: true, LUKS: true}},
{"luks+lvm", partitionTableFeatures{XFS: true, FAT: true, LUKS: true, LVM: true}},
{"btrfs", partitionTableFeatures{XFS: true, FAT: true, Btrfs: true}},
Expand Down

0 comments on commit 3ec3269

Please sign in to comment.