489bd2a62b
* Test returns and exit codes on most command invocations * Add start and end banners to make output easier to find in long log files * Adds die_if_error(), die_if_not_set() and is_set() to functions * Add some function tests Fixes bug 944593 Change-Id: I55e2962c5fec9aad237b674732b1e922ad37a62e
55 lines
1.1 KiB
Bash
Executable File
55 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Tests for DevStack functions
|
|
|
|
TOP=$(cd $(dirname "$0")/.. && pwd)
|
|
|
|
# Import common functions
|
|
source $TOP/functions
|
|
|
|
# Import configuration
|
|
source $TOP/openrc
|
|
|
|
|
|
echo "Testing die_if_error()"
|
|
|
|
bash -c "source $TOP/functions; true; die_if_error 'not OK'"
|
|
if [[ $? != 0 ]]; then
|
|
echo "die_if_error [true] Failed"
|
|
fi
|
|
|
|
bash -c "source $TOP/functions; false; die_if_error 'OK'"
|
|
if [[ $? = 0 ]]; then
|
|
echo "die_if_error [false] Failed"
|
|
else
|
|
echo 'OK'
|
|
fi
|
|
|
|
|
|
echo "Testing die_if_not_set()"
|
|
|
|
bash -c "source $TOP/functions; X=`echo Y && true`; die_if_not_set X 'not OK'"
|
|
if [[ $? != 0 ]]; then
|
|
echo "die_if_not_set [X='Y' true] Failed"
|
|
else
|
|
echo 'OK'
|
|
fi
|
|
|
|
bash -c "source $TOP/functions; X=`true`; die_if_not_set X 'OK'"
|
|
if [[ $? = 0 ]]; then
|
|
echo "die_if_not_set [X='' true] Failed"
|
|
fi
|
|
|
|
bash -c "source $TOP/functions; X=`echo Y && false`; die_if_not_set X 'not OK'"
|
|
if [[ $? != 0 ]]; then
|
|
echo "die_if_not_set [X='Y' false] Failed"
|
|
else
|
|
echo 'OK'
|
|
fi
|
|
|
|
bash -c "source $TOP/functions; X=`false`; die_if_not_set X 'OK'"
|
|
if [[ $? = 0 ]]; then
|
|
echo "die_if_not_set [X='' false] Failed"
|
|
fi
|
|
|