test/setup: Make sure big enough drive is selected for the tests

Look for drives with 2GB of space at minimum.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Ic326229120ffc5d839bbf465855d8be857ab4f73
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7377
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Michal Berger 2021-04-14 18:02:48 +02:00 committed by Tomasz Zawadzki
parent 9c7f460f55
commit 0c78378a63
2 changed files with 12 additions and 1 deletions

View File

@ -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))
}

View File

@ -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