aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash/function/gather.sh
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-07-10 13:59:50 +0200
committerPeter Mikus <pmikus@cisco.com>2019-07-10 14:23:48 +0000
commit36d56bdb7f9f394047e2df3f29bf47db877b649c (patch)
treede01e08334759f2f41b30dabcbd179b94015b0e0 /resources/libraries/bash/function/gather.sh
parente45404bf7b8cbdb10adf85815c2e005134e463ad (diff)
Bash functions style cleanup
+ Update rst documentation for bash style + Command substitution: + Clarify when to use backticks. + Recommend avoiding nested command substitution. + Do not recommend putting command substitution results into quotes. + Function definition content: + Move "set -exuo pipefail" after comment only blocks. + Other set flags allowed for functions with good reasons. + Apply the new recommendations. - Blank lines unified in code but no written recommendation in rst. + Add missing references to functions called, variables read or set. + Add TODOs to where lists would be long. + Minor improvements to function descriptions. + Make "if" expressions more python-like. + Add missing "|| die" (or "|| true") where spotted. + Downgrade DEFAULT_NIC to a local variable. + Add TODO to list reasons for blacklisted tags. Change-Id: I05dce030a8c2cb1b3a242d8b977e8fe150d8ee20 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/bash/function/gather.sh')
-rw-r--r--resources/libraries/bash/function/gather.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/resources/libraries/bash/function/gather.sh b/resources/libraries/bash/function/gather.sh
index 56b148d1e1..1fc2d3e604 100644
--- a/resources/libraries/bash/function/gather.sh
+++ b/resources/libraries/bash/function/gather.sh
@@ -24,8 +24,6 @@ set -exuo pipefail
function gather_build () {
- set -exuo pipefail
-
# Variables read:
# - TEST_CODE - String affecting test selection, usually jenkins job name.
# - DOWNLOAD_DIR - Path to directory pybot takes the build to test from.
@@ -43,6 +41,8 @@ function gather_build () {
# TODO: Separate DUT-from-TEST_CODE from gather-for-DUT,
# when the first one becomes relevant for per_patch.
+ set -exuo pipefail
+
pushd "${DOWNLOAD_DIR}" || die "Pushd failed."
case "${TEST_CODE}" in
*"hc2vpp"*)
@@ -71,8 +71,6 @@ function gather_build () {
function gather_dpdk () {
- set -exuo pipefail
-
# Ensure latest DPDK archive is downloaded.
#
# Variables read:
@@ -84,6 +82,8 @@ function gather_dpdk () {
# Functions called:
# - die - Print to stderr and exit, defined in common.sh
+ set -exuo pipefail
+
dpdk_repo="https://fast.dpdk.org/rel"
# Use downloaded packages with specific version
if [[ "${TEST_CODE}" == *"daily"* ]] || \
@@ -117,8 +117,6 @@ function gather_dpdk () {
function gather_ligato () {
- set -exuo pipefail
-
# Build docker image (with vpp, ligato and vpp-agent),
# and put it to ${DOWNLOAD_DIR}/.
#
@@ -155,6 +153,8 @@ function gather_ligato () {
# so maybe it is not worth introducing fragments/functions for the blocks.
# TODO: This fragment is too long anyway, split it up.
+ set -exuo pipefail
+
gather_vpp || die "The function should have died on error."
mkdir -p /tmp/vpp && rm -f /tmp/vpp/* || {
@@ -244,8 +244,6 @@ function gather_ligato () {
function gather_vpp () {
- set -exuo pipefail
-
# Variables read:
# - BASH_FUNCTION_DIR - Bash directory with functions.
# - TEST_CODE - The test selection string from environment or argument.
@@ -268,6 +266,8 @@ function gather_vpp () {
# - ${CSIT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh
# - Should download and extract requested files to ./.
+ set -exuo pipefail
+
case "${TEST_CODE}" in
# Not csit-vpp as this code is re-used by ligato gathering.
"csit-"*)