From 4fea8d11199e6bdebd6863dce190fedf387c67f4 Mon Sep 17 00:00:00 2001 From: Luke Yang Date: Tue, 28 Nov 2023 15:56:38 -0500 Subject: [PATCH] Change to use sfdisk Use sfdisk instead of lsblk to get the partition table. This requires some changes in how the size of partitions are checked since sfdisk records disk size in sectors, not MiB. --- tests/kola/disks/partition-scheme | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/kola/disks/partition-scheme b/tests/kola/disks/partition-scheme index cbcf35bdb0..440d870d8d 100755 --- a/tests/kola/disks/partition-scheme +++ b/tests/kola/disks/partition-scheme @@ -11,10 +11,10 @@ set -xeuo pipefail root_part=$(findmnt -n -o SOURCE /sysroot) disk_name=$(lsblk --json -o PKNAME --path "$root_part" | jq --raw-output '.blockdevices[].pkname') -diskData=$(lsblk --json --bytes -o NAME,FSTYPE,START,SIZE,MOUNTPOINT,PARTLABEL,PARTTYPENAME,LOG-SEC "$disk_name" | jq '.blockdevices[]' ) -partitionData=$(echo $diskData | jq '.children[]') -totalPartitions=$(echo $diskData | jq '.children | length') -sector_size=$(echo $diskData | jq '.["log-sec"]') +diskData=$(sfdisk --json "$disk_name" | jq '.partitiontable' ) +partitionData=$(echo $diskData | jq '.partitions[]') +totalPartitions=$(echo $diskData | jq '.partitions | length') +sector_size=$(echo $diskData | jq .sectorsize) if [[ $totalPartitions -ne 4 ]]; then fatal "Expected 4 partitions, got $totalPartitions" @@ -37,12 +37,12 @@ declare -A expected=( # There is a 1MiB gap at the beginning of the disks expected_start=$(( 1 * $ONE_MiB / $sector_size )) -# Iterate over the partitions and check their +# Iterate over the partitions and check their start and size for key in ${!expected[@]}; do - echo "${key}, ${expected[${key}]}" size_MiB="${expected[${key}]}" - start=$(echo "$partitionData" | jq "select ( .partlabel == \"$key\") | .start") - size=$(echo "$partitionData" | jq "select ( .partlabel == \"$key\") | .size") + start=$(echo "$partitionData" | jq "select ( .name == \"$key\") | .start") + sectors=$(echo "$partitionData" | jq "select ( .name == \"$key\") | .size") + size=$(( $sectors * $sector_size )) if [[ "$start" -ne "$expected_start" ]]; then fatal "Expected $key partition start sector of $expected_start, got $start" fi