diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index b5fd63702..871e78c44 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 074abf1f4..cd4d210ab 100755 --- a/test/lib/bdev/blockdev.sh +++ b/test/lib/bdev/blockdev.sh @@ -42,5 +42,9 @@ if [ $RUN_NIGHTLY -eq 1 ]; then timing_exit unmap fi +if grep -q Nvme0 $testdir/bdev.conf; then + part_dev_by_gpt $testdir/bdev.conf Nvme0n1 $rootdir reset +fi + rm -f $testdir/bdev.conf timing_exit blockdev