* Proper RFC 6241 Netconf error handling

* New functions added in clixon_netconf_lib.[ch]
  * Datastore code modified for RFC 6241
  * Remaining: validate, generic restconf and netconf code
This commit is contained in:
Olof hagsand 2018-03-18 18:06:02 +00:00
parent 52e510cfdf
commit efa72e9e6f
26 changed files with 1196 additions and 475 deletions

View file

@ -56,9 +56,9 @@ expectfn(){
expect2=
fi
ret=`$cmd`
if [ $? -ne 0 ]; then
err "wrong args"
fi
# if [ $? -ne 0 ]; then
# err "wrong args"
# fi
# Match if both are empty string
if [ -z "$ret" -a -z "$expect" ]; then
return
@ -68,9 +68,7 @@ expectfn(){
fi
# grep extended grep
match=`echo $ret | grep -EZo "$expect"`
# echo "ret:\"$ret\""
# echo "expect:\"$expect\""
# echo "match:\"$match\""
if [ -z "$match" ]; then
err "$expect" "$ret"
fi
@ -82,6 +80,37 @@ expectfn(){
fi
}
# Similar to expectfn, but checks for equality and not only match
expecteq2(){
ret=$1
expect=$2
# Match if both are empty string
if [ -z "$ret" -a -z "$expect" ]; then
return
fi
if [ "$ret" != "$expect" ]; then
err "$expect" "$ret"
fi
}
# Similar to expectfn, but checks for equality and not only match
expecteq(){
cmd=$1
expect=$2
ret=$($cmd)
if [ $? -ne 0 ]; then
err "wrong args"
fi
# Match if both are empty string
if [ -z "$ret" -a -z "$expect" ]; then
return
fi
if [ "$ret" != "$expect" ]; then
err "$expect" "$ret"
fi
}
# clixon tester. First arg is command second is stdin and
# third is expected outcome
expecteof(){