Check that generate-subunit exists before using it

If stack.sh fails before os-testr is installed, the generate-subunit
command won't exist.

Change-Id: I7998ed81e419e25d183e5a780df0b4459cca237c
This commit is contained in:
Monty Taylor 2017-09-10 15:00:29 -06:00
parent 7e9ec03af4
commit cbd5f4e0ad
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594

View File

@ -537,14 +537,20 @@ function exit_trap {
if [[ $r -ne 0 ]]; then
echo "Error on exit"
generate-subunit $DEVSTACK_START_TIME $SECONDS 'fail' >> ${SUBUNIT_OUTPUT}
# If we error before we've installed os-testr, which will fail.
if type -p generate-subunit > /dev/null; then
generate-subunit $DEVSTACK_START_TIME $SECONDS 'fail' >> ${SUBUNIT_OUTPUT}
fi
if [[ -z $LOGDIR ]]; then
$TOP_DIR/tools/worlddump.py
else
$TOP_DIR/tools/worlddump.py -d $LOGDIR
fi
else
generate-subunit $DEVSTACK_START_TIME $SECONDS >> ${SUBUNIT_OUTPUT}
# If we error before we've installed os-testr, which will fail.
if type -p generate-subunit > /dev/null; then
generate-subunit $DEVSTACK_START_TIME $SECONDS >> ${SUBUNIT_OUTPUT}
fi
fi
exit $r