This commit is contained in:
Olof Hagsand 2017-03-06 19:40:39 +01:00
parent c3af59b2d8
commit f5250b136c
3 changed files with 83 additions and 4 deletions

View file

@ -30,6 +30,7 @@ expectfn(){
if [ -z "$ret" -a -z "$expect" ]; then
return
fi
# grep extended grep
match=`echo "$ret" | grep -Eo "$expect"`
# echo "ret:$ret"
# echo "expect:$expect"
@ -39,3 +40,24 @@ expectfn(){
fi
}
# clicon_cli tester. First arg is command and second is expected outcome
expecteof(){
cmd=$1
input=$2
expect=$3
# Do while read stuff
ret=$($cmd<<EOF
$input
EOF
)
# Match if both are empty string
if [ -z "$ret" -a -z "$expect" ]; then
return
fi
match=`echo "$ret" | grep -Eo "$expect"`
if [ -z "$match" ]; then
err "\nExpected:\t\"$expect\"\nGot:\t\"$ret\""
fi
}