From a31c600a9c820cdded191a0ce935e14b0a3e3b61 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 11 Aug 2017 15:06:17 -0700 Subject: [PATCH] test/bdev: remove partition table after GPT test Make sure later tests don't fail due to a GPT partition table created on an NVMe device. Change-Id: I623e4fd0a84588a85f9d1ced6daf539d48267f50 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/374007 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- scripts/autotest_common.sh | 18 ++++++++++++++---- test/lib/bdev/blockdev.sh | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) 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