Sanity check in setup_workspace
setup_workspace called with unquoted variables, which could lead to wrong argument moved into wrong variable, when one of the variables was empty string or contained space. This change quotas the parameters for setup_workspace, and also validates the OVERRIDE_ZUUL_BRANCH, GRENADE_OLD_BRANCH, GRENADE_NEW_BRANCH are not empty strings when they are used. Change-Id: I13d1458c9cebd83b0ca700b3153f6645b2931c0d
This commit is contained in:
@@ -343,16 +343,16 @@ tsfilter setup_host &> $WORKSPACE/logs/devstack-gate-setup-host.txt
|
||||
if [ -n "$DEVSTACK_GATE_GRENADE" ]; then
|
||||
echo "Setting up the new (migrate to) workspace"
|
||||
echo "... this takes 3 - 5 minutes (logs at logs/devstack-gate-setup-workspace-new.txt.gz)"
|
||||
tsfilter setup_workspace $GRENADE_NEW_BRANCH $BASE/new copycache &> \
|
||||
tsfilter setup_workspace "$GRENADE_NEW_BRANCH" "$BASE/new" copycache &> \
|
||||
$WORKSPACE/logs/devstack-gate-setup-workspace-new.txt
|
||||
echo "Setting up the old (migrate from) workspace ..."
|
||||
echo "... this takes 3 - 5 minutes (logs at logs/devstack-gate-setup-workspace-old.txt.gz)"
|
||||
tsfilter setup_workspace $GRENADE_OLD_BRANCH $BASE/old &> \
|
||||
tsfilter setup_workspace "$GRENADE_OLD_BRANCH" "$BASE/old" &> \
|
||||
$WORKSPACE/logs/devstack-gate-setup-workspace-old.txt
|
||||
else
|
||||
echo "Setting up the workspace"
|
||||
echo "... this takes 3 - 5 minutes (logs at logs/devstack-gate-setup-workspace-new.txt.gz)"
|
||||
tsfilter setup_workspace $OVERRIDE_ZUUL_BRANCH $BASE/new &> \
|
||||
tsfilter setup_workspace "$OVERRIDE_ZUUL_BRANCH" "$BASE/new" &> \
|
||||
$WORKSPACE/logs/devstack-gate-setup-workspace-new.txt
|
||||
fi
|
||||
|
||||
|
||||
@@ -331,6 +331,11 @@ function setup_workspace {
|
||||
# Enabled detailed logging, since output of this function is redirected
|
||||
set -o xtrace
|
||||
|
||||
if [ -z "$base_branch" ]; then
|
||||
echo "ERROR: setup_workspace: base_branch is an empty string!" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
fix_disk_layout
|
||||
|
||||
sudo mkdir -p $DEST
|
||||
|
||||
@@ -99,6 +99,16 @@ function assert_equal {
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_raises {
|
||||
local lineno=`caller 0 | awk '{print $1}'`
|
||||
local function=`caller 0 | awk '{print $2}'`
|
||||
eval "$@" &>/dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
ERROR=1
|
||||
echo "ERROR: \`\`$@\`\` returned OK instead of error in $function:L$lineno!"
|
||||
fi
|
||||
}
|
||||
|
||||
# Tests follow:
|
||||
function test_one_on_master {
|
||||
# devstack-gate master ZA
|
||||
@@ -386,6 +396,11 @@ function test_periodic {
|
||||
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'stable/havana'
|
||||
}
|
||||
|
||||
# setup_workspace fails without argument
|
||||
function test_workspace_branch_arg {
|
||||
assert_raises setup_workspace
|
||||
}
|
||||
|
||||
# Run tests:
|
||||
#set -o xtrace
|
||||
test_branch_override
|
||||
@@ -397,6 +412,7 @@ test_multi_branch_project_override
|
||||
test_one_on_master
|
||||
test_periodic
|
||||
test_two_on_master
|
||||
test_workspace_branch_arg
|
||||
|
||||
if [[ ! -z "$ERROR" ]]; then
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user