diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index 1430685f6..a6e435d66 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -315,11 +315,16 @@ function part_dev_by_gpt () { conf=$1 devname=$2 rootdir=$3 + operation=$4 if [ ! -e $conf ]; then return 1 fi + if [ -z "$operation" ]; then + operation="create" + fi + cp $conf ${conf}.gpt echo "[Gpt]" >> ${conf}.gpt echo " Disable Yes" >> ${conf}.gpt @@ -332,10 +337,15 @@ function part_dev_by_gpt () { waitforbdev $devname "python $rootdir/scripts/rpc.py" if [ -e /dev/nbd0 ]; then - parted -s /dev/nbd0 mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%' - # change the GUID to SPDK GUID value - sgdisk -t 1:$SPDK_GPT_GUID /dev/nbd0 - sgdisk -t 2:$SPDK_GPT_GUID /dev/nbd0 + if [ "$operation" = create ]; then + parted -s /dev/nbd0 mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%' + # change the GUID to SPDK GUID value + sgdisk -t 1:$SPDK_GPT_GUID /dev/nbd0 + sgdisk -t 2:$SPDK_GPT_GUID /dev/nbd0 + elif [ "$operation" = reset ]; then + # clear the partition table + dd if=/dev/zero of=/dev/nbd0 bs=4096 count=8 oflag=direct + fi fi killprocess $nbd_pid rm -f ${conf}.gpt diff --git a/test/lib/bdev/blockdev.sh b/test/lib/bdev/blockdev.sh index 7fdc06d1d..1f3e8b0e6 100755 --- a/test/lib/bdev/blockdev.sh +++ b/test/lib/bdev/blockdev.sh @@ -81,6 +81,11 @@ if [ $RUN_NIGHTLY -eq 1 ]; then timing_exit reset fi + +if grep -q Nvme0 $testdir/bdev.conf; then + part_dev_by_gpt $testdir/bdev.conf Nvme0n1 $rootdir reset +fi + rm -f /tmp/aiofile rm -f $testdir/bdev.conf timing_exit bdev