bdev,test: move common gpt partition code to autotest_common.sh
Change-Id: I261e6ed578335ab091973f7546035e63a00dbbf4 Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/369735 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
f03f5e7de8
commit
8b6f5d54db
@ -310,5 +310,39 @@ function print_backtrace() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function part_dev_by_gpt () {
|
||||||
|
if [ $(uname -s) = Linux ] && hash sgdisk; then
|
||||||
|
conf=$1
|
||||||
|
devname=$2
|
||||||
|
rootdir=$3
|
||||||
|
|
||||||
|
if [ ! -e $conf ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp $conf ${conf}.gpt
|
||||||
|
echo "[Gpt]" >> ${conf}.gpt
|
||||||
|
echo " Disable Yes" >> ${conf}.gpt
|
||||||
|
|
||||||
|
modprobe nbd
|
||||||
|
$rootdir/test/lib/bdev/nbd/nbd -c ${conf}.gpt -b $devname -n /dev/nbd0 &
|
||||||
|
nbd_pid=$!
|
||||||
|
echo "Process nbd pid: $nbd_pid"
|
||||||
|
waitforlisten $nbd_pid 5260
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
killprocess $nbd_pid
|
||||||
|
rm -f ${conf}.gpt
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
set -o errtrace
|
set -o errtrace
|
||||||
trap "trap - ERR; print_backtrace >&2" ERR
|
trap "trap - ERR; print_backtrace >&2" ERR
|
||||||
|
@ -15,3 +15,6 @@
|
|||||||
|
|
||||||
[AIO]
|
[AIO]
|
||||||
AIO /dev/ram0 AIO0
|
AIO /dev/ram0 AIO0
|
||||||
|
|
||||||
|
[Rpc]
|
||||||
|
Enable Yes
|
||||||
|
@ -17,39 +17,8 @@ timing_enter bounds
|
|||||||
$testdir/bdevio/bdevio $testdir/bdev.conf
|
$testdir/bdevio/bdevio $testdir/bdev.conf
|
||||||
timing_exit bounds
|
timing_exit bounds
|
||||||
|
|
||||||
if [ $(uname -s) = Linux ] && hash sgdisk; then
|
if grep -q Nvme0 $testdir/bdev.conf; then
|
||||||
echo "[Rpc]" >> $testdir/bdev.conf
|
part_dev_by_gpt $testdir/bdev.conf Nvme0n1 $rootdir
|
||||||
echo " Enable Yes" >> $testdir/bdev.conf
|
|
||||||
echo "[Gpt]" >> $testdir/bdev.conf
|
|
||||||
echo " Disable Yes" >> $testdir/bdev.conf
|
|
||||||
|
|
||||||
if grep -q Nvme0 $testdir/bdev.conf; then
|
|
||||||
modprobe nbd
|
|
||||||
$testdir/nbd/nbd -c $testdir/bdev.conf -b Nvme0n1 -n /dev/nbd0 &
|
|
||||||
nbd_pid=$!
|
|
||||||
echo "Process nbd pid: $nbd_pid"
|
|
||||||
waitforlisten $nbd_pid 5260
|
|
||||||
#if return 1, it will trap, so do not need to consider this case
|
|
||||||
waitforbdev Nvme0n1 $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 partition type GUID to SPDK GUID value
|
|
||||||
sgdisk -t 1:$SPDK_GPT_GUID /dev/nbd0
|
|
||||||
sgdisk -t 2:$SPDK_GPT_GUID /dev/nbd0
|
|
||||||
fi
|
|
||||||
killprocess $nbd_pid
|
|
||||||
|
|
||||||
# enable the gpt module and run nbd again to test get_bdevs and
|
|
||||||
# bind nbd to the new gpt partition bdev
|
|
||||||
sed -i'' '/Disable/d' $testdir/bdev.conf
|
|
||||||
$testdir/nbd/nbd -c $testdir/bdev.conf -b Nvme0n1p1 -n /dev/nbd0 &
|
|
||||||
nbd_pid=$!
|
|
||||||
waitforlisten $nbd_pid 5260
|
|
||||||
waitforbdev Nvme0n1p1 $rootdir/scripts/rpc.py
|
|
||||||
$rpc_py get_bdevs
|
|
||||||
killprocess $nbd_pid
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
timing_enter verify
|
timing_enter verify
|
||||||
|
Loading…
Reference in New Issue
Block a user