From 9f4ef6d93bcc0b17d26b970d11fd90209e383d7a Mon Sep 17 00:00:00 2001 From: Luke Yang Date: Wed, 1 Nov 2023 11:33:47 -0400 Subject: [PATCH] tests: create partition scheme test Create a test to verify partition numbers and sizes. This is to ensure that the partition scheme is valid during the transition to using OSBuild in the FCOS pipeline. --- tests/kola/disks/partition-scheme | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 tests/kola/disks/partition-scheme diff --git a/tests/kola/disks/partition-scheme b/tests/kola/disks/partition-scheme new file mode 100755 index 0000000000..7a26f3b278 --- /dev/null +++ b/tests/kola/disks/partition-scheme @@ -0,0 +1,41 @@ +#!/bin/bash +## kola: +## exclusive: false +## description: Verify the partition scheme is correct. + +set -xeuo pipefail + +# shellcheck disable=SC1091 +. "$KOLA_EXT_DATA/commonlib.sh" + +# check for 4 partitions +totalPartitions=$(grep -c 'vda[0-9]' /proc/partitions) +if [[ $totalPartitions -ne 4 ]]; then + fatal "Expected 4 partitions, got $totalPartitions" +fi + +# get partition sizes +partitionData=$(sudo lsblk --json -ba -o NAME,FSTYPE,SIZE,MOUNTPOINT,PARTLABEL,PARTTYPENAME | jq .blockdevices[].children[] ) +biosBootSize=$( echo "$partitionData" | jq 'select ( .partlabel == "BIOS-BOOT" or .parttypename == "BIOS boot") | .size ' ) +efiSystemSize=$( echo "$partitionData" | jq 'select ( .partlabel == "EFI-SYSTEM" or .parttypename == "EFI System") | .size ' ) +bootSize=$( echo "$partitionData" | jq 'select ( .partlabel == "boot" or .mountpoint == "/boot") | .size ' ) +rootSize=$( echo "$partitionData" | jq 'select ( .partlabel == "root" or .mountpoint == "/sysroot") | .size ' ) + +# check sizes of each parition +if [[ $biosBootSize -ne 1048576 ]]; then + fatal "Expected BIOS-BOOT partition of size 1048576, got $biosBootSize" +fi + +if [[ $efiSystemSize -ne 133169152 ]]; then + fatal "Expected EFI-SYSTEM partition of size 133169152, got $efiSystemSize" +fi + +if [[ $bootSize -ne 402653184 ]]; then + fatal "Expected boot partition of size 402653184, got $bootSize" +fi + +if [[ $rootSize -ne 10199481856 ]]; then + fatal "Expected root partition of size 10199481856, got $rootSize" +fi + +ok partition scheme \ No newline at end of file