aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--resources/libraries/bash/entry/bootstrap_verify_perf.sh1
-rwxr-xr-xresources/libraries/bash/entry/bootstrap_vpp_device.sh1
-rw-r--r--resources/libraries/bash/entry/per_patch_device.sh1
-rw-r--r--resources/libraries/bash/entry/per_patch_perf.sh1
-rw-r--r--resources/libraries/bash/function/common.sh33
5 files changed, 37 insertions, 0 deletions
diff --git a/resources/libraries/bash/entry/bootstrap_verify_perf.sh b/resources/libraries/bash/entry/bootstrap_verify_perf.sh
index bf7fa3519c..2329beba70 100644
--- a/resources/libraries/bash/entry/bootstrap_verify_perf.sh
+++ b/resources/libraries/bash/entry/bootstrap_verify_perf.sh
@@ -33,6 +33,7 @@ source "${BASH_FUNCTION_DIR}/common.sh" || {
source "${BASH_FUNCTION_DIR}/gather.sh" || die "Source failed."
source "${BASH_FUNCTION_DIR}/ansible.sh" || die "Source failed."
common_dirs || die
+check_prerequisites || die
get_test_code "${1-}" || die
get_test_tag_string || die
select_topology || die
diff --git a/resources/libraries/bash/entry/bootstrap_vpp_device.sh b/resources/libraries/bash/entry/bootstrap_vpp_device.sh
index 4ac73e777f..ce887f4b5b 100755
--- a/resources/libraries/bash/entry/bootstrap_vpp_device.sh
+++ b/resources/libraries/bash/entry/bootstrap_vpp_device.sh
@@ -32,6 +32,7 @@ source "${BASH_FUNCTION_DIR}/common.sh" || {
}
source "${BASH_FUNCTION_DIR}/gather.sh" || die "Source failed."
common_dirs || die
+check_prerequisites || die
get_test_code "${1-}" || die
get_test_tag_string || die
select_topology || die
diff --git a/resources/libraries/bash/entry/per_patch_device.sh b/resources/libraries/bash/entry/per_patch_device.sh
index 6624047862..65577c2909 100644
--- a/resources/libraries/bash/entry/per_patch_device.sh
+++ b/resources/libraries/bash/entry/per_patch_device.sh
@@ -37,6 +37,7 @@ source "${BASH_FUNCTION_DIR}/common.sh" || {
}
source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed."
common_dirs || die
+check_prerequisites || die
set_perpatch_vpp_dir || die
build_vpp_ubuntu_amd64 "CURRENT" || die
set_aside_commit_build_artifacts || die
diff --git a/resources/libraries/bash/entry/per_patch_perf.sh b/resources/libraries/bash/entry/per_patch_perf.sh
index ef75ea90ce..afe5f97575 100644
--- a/resources/libraries/bash/entry/per_patch_perf.sh
+++ b/resources/libraries/bash/entry/per_patch_perf.sh
@@ -40,6 +40,7 @@ source "${BASH_FUNCTION_DIR}/common.sh" || {
}
source "${BASH_FUNCTION_DIR}/per_patch.sh" || die "Source failed."
common_dirs || die
+check_prerequisites || die
set_perpatch_vpp_dir || die
build_vpp_ubuntu_amd64 "CURRENT" || die
set_aside_commit_build_artifacts || die
diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh
index f7a7a004df..751d994c09 100644
--- a/resources/libraries/bash/function/common.sh
+++ b/resources/libraries/bash/function/common.sh
@@ -167,6 +167,21 @@ function check_download_dir () {
}
+function check_prerequisites () {
+
+ # Fail if prerequisites are not met.
+ #
+ # Functions called:
+ # - installed - Check if application is installed/present in system.
+ # - die - Print to stderr and exit.
+
+ set -exuo pipefail
+
+ if ! installed sshpass; then
+ die "Please install sshpass before continue!"
+ fi
+}
+
function cleanup_topo () {
# Variables read:
@@ -520,6 +535,24 @@ function get_test_tag_string () {
}
+function installed () {
+
+ # Check if the given utility is installed. Fail if not installed.
+ #
+ # Duplicate of common.sh function, as this file is also used standalone.
+ #
+ # Arguments:
+ # - ${1} - Utility to check.
+ # Returns:
+ # - 0 - If command is installed.
+ # - 1 - If command is not installed.
+
+ set -exuo pipefail
+
+ command -v "${1}"
+}
+
+
function reserve_and_cleanup_testbed () {
# Reserve physical testbed, perform cleanup, register trap to unreserve.