summaryrefslogtreecommitdiffstats
path: root/kud/tests/_functions.sh
diff options
context:
space:
mode:
authormarvinYu <weifei.yu@intel.com>2020-03-19 22:16:30 +0800
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-05-26 00:34:11 +0000
commit2f86e8e5364339b539313931d7faaf9f9c3896a4 (patch)
tree94c0df766f48ead3d31dfb48bd730cb2fd45de0b /kud/tests/_functions.sh
parentcb00c733fc29c715f1f30cbf50534a0811575d7f (diff)
Updating multus, SRIOV and nfd test cases
Updating some AddOn test cases and add README.md file. Issue-ID: MULTICLOUD-1037 Signed-off-by: marvinYu <weifei.yu@intel.com> Change-Id: Iee2c31207cf2cd37fb8119bceef286aa887079f9
Diffstat (limited to 'kud/tests/_functions.sh')
-rwxr-xr-xkud/tests/_functions.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/kud/tests/_functions.sh b/kud/tests/_functions.sh
index 34c22569..7687f3fa 100755
--- a/kud/tests/_functions.sh
+++ b/kud/tests/_functions.sh
@@ -15,6 +15,7 @@ set -o pipefail
FUNCTIONS_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
source /etc/environment
+source $FUNCTIONS_DIR/_common_test.sh
function print_msg {
local msg=$1
@@ -236,4 +237,33 @@ function teardown {
destroy_deployment $deployment_name
done
}
+
+# check_ip_range() - Verifying IP address in address range
+function check_ip_range {
+ local IP=$1
+ local MASK=$2
+
+ install_ipcalc
+
+ if [[ ! -e /usr/bin/ipcalc ]]; then
+ echo -e "Command 'ipcalc' not found"
+ return 0
+ fi
+
+ if [[ -z ${IP} ]] || [[ -z ${MASK} ]]; then
+ return 1
+ fi
+ min=`/usr/bin/ipcalc $MASK|awk '/HostMin:/{print $2}'`
+ max=`/usr/bin/ipcalc $MASK|awk '/HostMax:/{print $2}'`
+ MIN=`echo $min|awk -F"." '{printf"%.0f\n",$1*256*256*256+$2*256*256+$3*256+$4}'`
+ MAX=`echo $max|awk -F"." '{printf"%.0f\n",$1*256*256*256+$2*256*256+$3*256+$4}'`
+ IPvalue=`echo $IP|awk -F"." '{printf"%.0f\n",$1*256*256*256+$2*256*256+$3*256+$4}'`
+ if [[ "$IPvalue" -gt "$MIN" ]] && [[ "$IPvalue" -lt "$MAX" ]]; then
+ echo -e "$IP in ipset $MASK"
+ return 0
+ fi
+ echo -e "$IP not in ipset $MASK"
+ return 1
+}
+
test_folder=${FUNCTIONS_DIR}