test/vhost: Make sure block devices are cleaned up after the test

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Icdfa78572e5cbf1ed14e559b450e7d9ba98c585b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7321
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Michal Berger 2021-04-12 12:20:36 +02:00 committed by Jim Harris
parent c5cba2c16a
commit c6eda94181
2 changed files with 15 additions and 4 deletions

View File

@ -1,6 +1,16 @@
#!/usr/bin/env bash
set -xe
err_wipe() {
[[ -n $devs ]] || return 0
local _devs
_devs=($devs) _devs=("${devs[@]/#//dev/}")
umount "${_devs[@]}" || :
wipefs --all "${_devs[@]}" || :
}
MAKE="make -j$(($(nproc) * 2))"
if [[ $1 == "spdk_vhost_scsi" ]]; then
@ -19,7 +29,7 @@ fi
fs=$2
trap "exit 1" SIGINT SIGTERM EXIT
trap "err_wipe; exit 1" SIGINT SIGTERM EXIT
for fs in $fs; do
for dev in $devs; do
@ -65,9 +75,9 @@ for fs in $fs; do
for dev in $devs; do
umount /mnt/${dev}dir
rm -rf /mnt/${dev}dir
parted -s /dev/${dev} rm 1
stats=($(cat /sys/block/$dev/stat))
wipefs --all "/dev/$dev"
echo ""
echo "$dev stats"
printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \

View File

@ -39,4 +39,5 @@ umount "$test_folder_name"
rm -rf "${testdir:?}/${test_folder_name:?}"
echo "INFO: Deleting partition"
echo -e "d\n1\nw" | fdisk /dev/$disk_name
# Zap the entire drive to make sure the partition table is removed as well
wipefs --all "/dev/$disk_name"