test
This commit is contained in:
parent
c3af59b2d8
commit
f5250b136c
3 changed files with 83 additions and 4 deletions
22
test/lib.sh
22
test/lib.sh
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue