autotest: only look up SPDK_GPT_GUID where needed

Getting SPDK_GPT_GUID is only necessary inside the part_dev_by_gpt()
function where it is used; this shortens the log and saves some build
time.

Additionally, $rootdir is not necessarily defined by all scripts
sourcing scripts/autotest_common.sh, so this fixes several (harmless but
annoying) error messages:

  grep: /lib/bdev/gpt/gpt.h: No such file or directory

Change-Id: Iea7a46273437ee54a15097e63700487f7bcd324f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/389608
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-11-29 09:18:30 -07:00 committed by Jim Harris
parent f386909cd8
commit 3dd4d63940

View File

@ -47,10 +47,6 @@ config_params='--enable-debug --enable-werror'
export UBSAN_OPTIONS='halt_on_error=1:print_stacktrace=1:abort_on_error=1'
export SPDK_GPT_GUID=`grep SPDK_GPT_PART_TYPE_GUID $rootdir/lib/bdev/gpt/gpt.h \
| awk -F "(" '{ print $2}' | sed 's/)//g' \
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g'`
# Override the default HUGEMEM in scripts/setup.sh
export HUGEMEM=8192
@ -394,7 +390,11 @@ function part_dev_by_gpt () {
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
SPDK_GPT_GUID=`grep SPDK_GPT_PART_TYPE_GUID $rootdir/lib/bdev/gpt/gpt.h \
| awk -F "(" '{ print $2}' | sed 's/)//g' \
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g'`
sgdisk -t 1:$SPDK_GPT_GUID /dev/nbd0
sgdisk -t 2:$SPDK_GPT_GUID /dev/nbd0
elif [ "$operation" = reset ]; then