aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash/function
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/bash/function')
-rw-r--r--resources/libraries/bash/function/common.sh33
1 files changed, 33 insertions, 0 deletions
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.