diff --git a/test/setup/common.sh b/test/setup/common.sh index 74e339146..c64f2c7b2 100644 --- a/test/setup/common.sh +++ b/test/setup/common.sh @@ -68,3 +68,11 @@ mkfs() { mkfs.ext4 -qF "$dev" $size mount "$dev" "$mount" } + +sec_size_to_bytes() { + local dev=$1 + + [[ -e /sys/block/$dev ]] || return 1 + # /size is always represented in 512B blocks + echo $(($(< "/sys/block/$dev/size") * 512)) +} diff --git a/test/setup/devices.sh b/test/setup/devices.sh index 4f55975f8..e52533cfd 100755 --- a/test/setup/devices.sh +++ b/test/setup/devices.sh @@ -170,6 +170,7 @@ setup reset declare -a blocks=() declare -A blocks_to_pci=() +min_disk_size=$((1024 ** 3 * 2)) # 2GB for block in "/sys/block/nvme"*; do pci=$(readlink -f "$block/device/device") @@ -181,7 +182,9 @@ for block in "/sys/block/nvme"*; do done # Skip devices that are in use - simple blkid it to see if # there's any metadata (pt, fs, etc.) present on the drive. - if ! blkid "/dev/${block##*/}"; then + # If the drive's size is less than 2G, skip it as we need + # something bigger for the tests. + if ! blkid "/dev/${block##*/}" && (($(sec_size_to_bytes "${block##*/}") >= min_disk_size)); then blocks+=("${block##*/}") blocks_to_pci["${block##*/}"]=$pci fi