From 41e23865a1eba909cfc9f769875af7ec5e4d2194 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 29 Dec 2020 13:49:49 +0100 Subject: [PATCH] revise testing: change expectfn -> extectpart etc --- test/config.sh.in | 3 + test/lib.sh | 60 +---------------- test/test_cli.sh | 6 +- test/test_cli_apipath.sh | 12 ++-- test/test_cli_multikey.sh | 24 +++---- test/test_cli_submodes.sh | 8 +-- test/test_cli_translate.sh | 4 +- test/test_datastore.sh | 56 ++++++++-------- test/test_feature.sh | 8 +-- test/test_identity.sh | 20 +++--- test/test_leafref.sh | 8 +-- test/test_nacm_ext.sh | 6 +- test/test_netconf.sh | 2 +- test/test_openconfig.sh | 2 +- test/test_pattern.sh | 40 +++++------ test/test_perf_state_only.sh | 2 +- test/test_restconf.sh | 6 +- test/test_sock.sh | 2 +- test/test_submodule.sh | 12 ++-- test/test_type.sh | 124 +++++++++++++++++------------------ test/test_type_range.sh | 8 +-- test/test_union.sh | 6 +- test/test_yang.sh | 8 +-- 23 files changed, 186 insertions(+), 241 deletions(-) diff --git a/test/config.sh.in b/test/config.sh.in index fdd987d2..6d9a7932 100755 --- a/test/config.sh.in +++ b/test/config.sh.in @@ -55,3 +55,6 @@ wwwuser=@wwwuser@ # Home dir for web user, by default /www-data WWWDIR=@wwwdir@ + +# Top src dir +TOP_SRCDIR=@top_srcdir@ diff --git a/test/lib.sh b/test/lib.sh index d746e220..e467ece8 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -6,11 +6,10 @@ # # Create working dir as variable "dir" # The functions are somewhat wildgrown, a little too many: -# - expectfn # - expectpart # - expecteof -# - expecteofeq # - expecteofx +# - expecteofeq # - expecteof_file # - expectwait # - expectmatch @@ -371,63 +370,6 @@ new(){ >&2 echo "Test $testi($testnr) [$1]" } -# clixon command tester. -# Arguments: -# - command, -# - expected command return value (0 if OK) -# - expected* stdout outcome, (can be many) -# Example: expectfn "$clixon_cli -1 -f $cfg show conf cli" 0 "line1" "line2" -# XXX: for some reason some curl commands dont work here, eg -# curl -H 'Accept: application/xrd+xml' -# NOTE: Please us expectpart instead!! -expectfn(){ - cmd=$1 - retval=$2 - expect="$3" - - if [ $# = 4 ]; then - expect2=$4 - else - expect2= - fi - ret=$($cmd) - r=$? -# echo "cmd:\"$cmd\"" -# echo "retval:\"$retval\"" -# echo "expect:\"$expect\"" -# echo "ret:\"$ret\"" -# echo "r:\"$r\"" - if [ $r != $retval ]; then - echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:" - echo -e "\e[0m:" - exit -1 - fi - # if [ $ret -ne $retval ]; then - # echo -e "\e[31m\nError in Test$testnr [$testname]:" - # echo -e "\e[0m:" - # exit -1 - # fi - # Match if both are empty string (special case) - if [ -z "$ret" -a -z "$expect" ]; then - return - fi - if [ -z "$ret" -a "$expect" = "^$" ]; then - return - fi - # Loop over all variable args expect strings - let i=0; - for exp in "$@"; do - if [ $i -gt 1 ]; then - match=`echo $ret | grep --null -Eo "$exp"` - if [ -z "$match" ]; then - err "$exp" "$ret" - fi - fi - let i++; - - done -} - # Evaluate and return # Example: expectpart $(fn arg) 0 "my return" -- "foo" # - evaluated expression diff --git a/test/test_cli.sh b/test/test_cli.sh index 52d41609..77d4b78c 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -68,10 +68,10 @@ expectpart "$($clixon_cli -1 -f $cfg show conf cli)" 0 "^set interfaces interfac new "cli configure using encoded chars data <&" # problems in changing to expectpart with escapes -expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 description \"foo<&bar\"" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set interfaces interface eth/0/0 description "\"foo<&bar\"")" 0 "" new "cli configure using encoded chars name <&" -expectfn "$clixon_cli -1 -f $cfg set interfaces interface fddi&< type ianaift:ethernetCsmacd" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set interfaces interface "fddi&<" type ianaift:ethernetCsmacd)" 0 "" new "cli failed validate" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application missing-element Mandatory variable of interface in module ietf-interfaces type" @@ -120,7 +120,7 @@ expectpart "$($clixon_cli -1 -f $cfg -l o debug level 1)" 0 "^$" # How to test this? new "cli debug reset" -expectfn "$clixon_cli -1 -f $cfg -l o debug level 0" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o debug level 0)" 0 "^$" new "cli rpc" # We dont know which message-id the cli app uses diff --git a/test/test_cli_apipath.sh b/test/test_cli_apipath.sh index f546b1ad..8699224a 100755 --- a/test/test_cli_apipath.sh +++ b/test/test_cli_apipath.sh @@ -94,23 +94,23 @@ fi # Positive tests new "set x" -expectfn "$clixon_cli -1 -f $cfg set x" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set x)" 0 "" new "set x a b" -expectfn "$clixon_cli -1 -f $cfg set x a 99 b 22" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set x a 99 b 22)" 0 "" new "set x a b c" -expectfn "$clixon_cli -1 -f $cfg set x a 22 b 33 c 55" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set x a 22 b 33 c 55)" 0 "" new "show conf x" -expectfn "$clixon_cli -1 -f $cfg show conf x" 0 "x m1 a 22 b 33" +expectpart "$($clixon_cli -1 -f $cfg show conf x)" 0 "x m1 a 22 b 33" # Negative tests new "err x" -expectfn "$clixon_cli -1 -f $cfg err x" 255 "Config error: api-path syntax error \"/example2:x\": application unknown-element No such yang module prefix example2: Invalid argument" +expectpart "$($clixon_cli -1 -f $cfg err x)" 255 "Config error: api-path syntax error \"/example2:x\": application unknown-element No such yang module prefix example2: Invalid argument" new "err x a" -expectfn "$clixon_cli -1 -f $cfg err x a 99" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument" +expectpart "$($clixon_cli -1 -f $cfg err x a 99)" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument" endtest diff --git a/test/test_cli_multikey.sh b/test/test_cli_multikey.sh index 2c517c8f..ae03da63 100755 --- a/test/test_cli_multikey.sh +++ b/test/test_cli_multikey.sh @@ -83,44 +83,44 @@ if [ $BE -ne 0 ]; then fi new "set 1 v1" -expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v1" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 1 b v1)" 0 "" new "set 1 v2" -expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v2" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 1 b v2)" 0 "" new "set 1 v3" -expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v3" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 1 b v3)" 0 "" new "set 2 v1" -expectfn "$clixon_cli -1 -f $cfg set ex x a 2 b v1" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 2 b v1)" 0 "" new "set 2 v2" -expectfn "$clixon_cli -1 -f $cfg set ex x a 2 b v2" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 2 b v2)" 0 "" new "set 2 v3" -expectfn "$clixon_cli -1 -f $cfg set ex x a 2 b v3" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 2 b v3)" 0 "" new "set 1 v2 again" -expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v2" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex x a 1 b v2)" 0 "" new "show conf" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1v11v21v32v12v22v3]]>]]>$" # ordered-by user new "set 1 v1" -expectfn "$clixon_cli -1 -f $cfg set ex y a 1 b v1" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex y a 1 b v1)" 0 "" new "set 2 v1" -expectfn "$clixon_cli -1 -f $cfg set ex y a 2 b v1" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex y a 2 b v1)" 0 "" new "set 1 v2" -expectfn "$clixon_cli -1 -f $cfg set ex y a 1 b v2" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex y a 1 b v2)" 0 "" new "set 1 v3" -expectfn "$clixon_cli -1 -f $cfg set ex y a 1 b v3" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex y a 1 b v3)" 0 "" new "set 2 v2" -expectfn "$clixon_cli -1 -f $cfg set ex y a 2 b v2" 0 "" +expectpart "$($clixon_cli -1 -f $cfg set ex y a 2 b v2)" 0 "" new "show conf" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1v11v21v32v12v22v31v12v11v21v32v2]]>]]>$" diff --git a/test/test_cli_submodes.sh b/test/test_cli_submodes.sh index af77d92e..32cb1efc 100755 --- a/test/test_cli_submodes.sh +++ b/test/test_cli_submodes.sh @@ -89,24 +89,24 @@ m=AAA # Tests using mode AAA that should pass for c in 1 2 5; do new "cli mode $m 1 cmd$c OK" - expectfn "$clixon_cli -1 -m $m -f $cfg cmd$c" 0 "^$" + expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 0 "^$" done # Tests using mode AAA that should fail for c in 3 4 6; do new "cli mode $m 1 cmd$c Not OK" - expectfn "$clixon_cli -1 -m $m -f $cfg cmd$c" 255 "^$" + expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 255 "^$" done m=BBB # Tests using mode BBB that should pass for c in 1 3 5 6; do new "cli mode $m 1 cmd$c OK" - expectfn "$clixon_cli -1 -m $m -f $cfg cmd$c" 0 "^$" + expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 0 "^$" done # Tests using mode BBB that should fail for c in 2 4; do new "cli mode $m 1 cmd$c Not OK" - expectfn "$clixon_cli -1 -m $m -f $cfg cmd$c" 255 "^$" + expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 255 "^$" done if [ $BE -eq 0 ]; then diff --git a/test/test_cli_translate.sh b/test/test_cli_translate.sh index 57a4cc6e..78833fed 100755 --- a/test/test_cli_translate.sh +++ b/test/test_cli_translate.sh @@ -62,12 +62,12 @@ if [ $BE -ne 0 ]; then fi new "translate abc -> table/parameter=translate/value = bcd" -expectfn "$clixon_cli -1 -f $cfg translate abc" 0 "" +expectpart "$($clixon_cli -1 -f $cfg translate abc)" 0 "" new "show config" expectpart "$($clixon_cli -1 -f $cfg show config)" 0 "translatebcd
" -if [ $BE -new 0 ]; then +if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill pid=$(pgrep -u root -f clixon_backend) diff --git a/test/test_datastore.sh b/test/test_datastore.sh index d104fe69..f5913767 100755 --- a/test/test_datastore.sh +++ b/test/test_datastore.sh @@ -61,103 +61,103 @@ rm -rf $mydir/* conf="-d candidate -b $mydir -y $dir/ietf-ip.yang" new "datastore init" -expectfn "$clixon_util_datastore $conf init" 0 "" +expectpart "$($clixon_util_datastore $conf init)" 0 "" new "datastore put all replace" ret=$($clixon_util_datastore $conf put replace "$xml") expectmatch "$ret" $? "0" "" new "datastore get" -expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$" +expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$" new "datastore put all remove" -expectfn "$clixon_util_datastore $conf put remove " 0 "" +expectpart "$($clixon_util_datastore $conf put remove "")" 0 "" new "datastore get" -expectfn "$clixon_util_datastore $conf get /" 0 "^$" +expectpart "$($clixon_util_datastore $conf get /)" 0 "^$" new "datastore put all merge" ret=$($clixon_util_datastore $conf put merge "$xml") expectmatch "$ret" $? "0" "" -# expectfn "$clixon_util_datastore $conf put merge $xml" 0 "" +# expectpart "$($clixon_util_datastore $conf put merge $xml)" 0 "" new "datastore get" -expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$" +expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$" new "datastore put all delete" -expectfn "$clixon_util_datastore $conf put remove " 0 "" +expectpart "$($clixon_util_datastore $conf put remove "")" 0 "" new "datastore get" -expectfn "$clixon_util_datastore $conf get /" 0 "^$" +expectpart "$($clixon_util_datastore $conf get /)" 0 "^$" new "datastore put all create" ret=$($clixon_util_datastore $conf put create "$xml") expectmatch "$ret" $? "0" "" new "datastore get" -expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$" +expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$" new "datastore put top create" -expectfn "$clixon_util_datastore $conf put create " 0 "" # error +expectpart "$($clixon_util_datastore $conf put create "")" 0 "" # error # Single key operations # leaf new "datastore put all delete" -expectfn "$clixon_util_datastore $conf delete" 0 "" +expectpart "$($clixon_util_datastore $conf delete)" 0 "" new "datastore init" -expectfn "$clixon_util_datastore $conf init" 0 "" +expectpart "$($clixon_util_datastore $conf init)" 0 "" new "datastore create leaf" -expectfn "$clixon_util_datastore $conf put create 13newentry" 0 "" +expectpart "$($clixon_util_datastore $conf put create "13newentry")" 0 "" new "datastore create leaf" -expectfn "$clixon_util_datastore $conf put create 13newentry" 0 "" +expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 "" new "datastore delete leaf" -expectfn "$clixon_util_datastore $conf put delete 13" 0 "" +expectpart "$($clixon_util_datastore $conf put delete '13')" 0 "" new "datastore replace leaf" -expectfn "$clixon_util_datastore $conf put create 13newentry" 0 "" +expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 "" new "datastore remove leaf" -expectfn "$clixon_util_datastore $conf put remove " 0 "" +expectpart "$($clixon_util_datastore $conf put remove '')" 0 "" new "datastore remove leaf" -expectfn "$clixon_util_datastore $conf put remove 13" 0 "" +expectpart "$($clixon_util_datastore $conf put remove '13')" 0 "" new "datastore delete leaf" -expectfn "$clixon_util_datastore $conf put delete " 0 "" +expectpart "$($clixon_util_datastore $conf put delete '')" 0 "" new "datastore merge leaf" -expectfn "$clixon_util_datastore $conf put merge nalle" 0 "" +expectpart "$($clixon_util_datastore $conf put merge 'nalle')" 0 "" new "datastore replace leaf" -expectfn "$clixon_util_datastore $conf put replace nalle" 0 "" +expectpart "$($clixon_util_datastore $conf put replace 'nalle')" 0 "" new "datastore merge leaf" -expectfn "$clixon_util_datastore $conf put merge 13newentry" 0 "" +expectpart "$($clixon_util_datastore $conf put merge '13newentry')" 0 "" new "datastore replace leaf" -expectfn "$clixon_util_datastore $conf put replace 13newentry" 0 "" +expectpart "$($clixon_util_datastore $conf put replace '13newentry')" 0 "" new "datastore create leaf" -expectfn "$clixon_util_datastore $conf put create aaa" 0 "" +expectpart "$($clixon_util_datastore $conf put create 'aaa')" 0 "" new "datastore create leaf" -expectfn "$clixon_util_datastore $conf put create 13newentry" 0 "" +expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 "" new "datastore other db init" -expectfn "$clixon_util_datastore -d kalle -b $mydir -y $dir/ietf-ip.yang init" 0 "" +expectpart "$($clixon_util_datastore -d kalle -b $mydir -y $dir/ietf-ip.yang init)" 0 "" new "datastore other db copy" -expectfn "$clixon_util_datastore $conf copy kalle" 0 "" +expectpart "$($clixon_util_datastore $conf copy kalle)" 0 "" diff $mydir/kalle_db $mydir/candidate_db new "datastore lock" -expectfn "$clixon_util_datastore $conf lock 756" 0 "" +expectpart "$($clixon_util_datastore $conf lock 756)" 0 "" # unset conditional parameters unset clixon_util_datastore diff --git a/test/test_feature.sh b/test/test_feature.sh index fa18053e..1b000bc9 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -159,16 +159,16 @@ if [ $BE -ne 0 ]; then fi new "cli enabled feature" -expectfn "$clixon_cli -1f $cfg set x foo" 0 "" +expectpart "$($clixon_cli -1f $cfg set x foo)" 0 "" new "cli disabled feature" -expectfn "$clixon_cli -1f $cfg -l o set y foo" 255 "CLI syntax error: \"set y foo\": Unknown command" +expectpart "$($clixon_cli -1f $cfg -l o set y foo)" 255 "CLI syntax error: \"set y foo\": Unknown command" new "cli enabled feature in other module" -expectfn "$clixon_cli -1f $cfg set routing router-id 1.2.3.4" 0 "" +expectpart "$($clixon_cli -1f $cfg set routing router-id 1.2.3.4)" 0 "" new "cli disabled feature in other module" -expectfn "$clixon_cli -1f $cfg -l o set routing ribs rib default-rib false" 255 "CLI syntax error: \"set routing ribs rib default-rib false\": Unknown command" +expectpart "$($clixon_cli -1f $cfg -l o set routing ribs rib default-rib false)" 255 "CLI syntax error: \"set routing ribs rib default-rib false\": Unknown command" new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/test_identity.sh b/test/test_identity.sh index 66273b60..f23e6bb2 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -212,22 +212,22 @@ new "netconf validate (expect fail)" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorIdentityref validation failed, foo:bar not derived from crypto-alg]]>]]>$" new "cli set crypto to mc:aes" -expectfn "$clixon_cli -1 -f $cfg -l o set crypto mc:aes" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o set crypto mc:aes)" 0 "^$" new "cli validate" -expectfn "$clixon_cli -1 -f $cfg -l o validate" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 0 "^$" new "cli set crypto to aes" -expectfn "$clixon_cli -1 -f $cfg -l o set crypto aes" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o set crypto aes)" 0 "^$" new "cli validate" -expectfn "$clixon_cli -1 -f $cfg -l o validate" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 0 "^$" new "cli set crypto to des:des3" -expectfn "$clixon_cli -1 -f $cfg -l o set crypto des:des3" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o set crypto des:des3)" 0 "^$" new "cli validate" -expectfn "$clixon_cli -1 -f $cfg -l o validate" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 0 "^$" new "Netconf set acl-type" expecteof "$clixon_netconf -qf $cfg" 0 "xmc:ipv4-acl-type]]>]]>" "^]]>]]>$" @@ -245,20 +245,20 @@ new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "CLI set acl-type" -expectfn "$clixon_cli -1 -f $cfg -l o set acls acl x type mc:ipv4-acl-type" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o set acls acl x type mc:ipv4-acl-type)" 0 "^$" new "cli validate" -expectfn "$clixon_cli -1 -f $cfg -l o validate" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 0 "^$" new "CLI set wrong acl-type" -expectfn "$clixon_cli -1 -f $cfg -l o set acls acl x type undefined" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o set acls acl x type undefined)" 0 "^$" new "cli validate acl-type" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" # test empty identityref list new "cli set empty" -expectfn "$clixon_cli -1 -f $cfg -l o set e undefined" 0 "^$" +expectpart "$($clixon_cli -1 -f $cfg -l o set e undefined)" 0 "^$" new "cli validate empty" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" diff --git a/test/test_leafref.sh b/test/test_leafref.sh index 9c22dff8..7668426b 100755 --- a/test/test_leafref.sh +++ b/test/test_leafref.sh @@ -176,16 +176,16 @@ new "leafref discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "cli leafref lo" -expectfn "$clixon_cli -1f $cfg -l o set default-address absname lo" 0 "^$" +expectpart "$($clixon_cli -1f $cfg -l o set default-address absname lo)" 0 "^$" new "cli leafref validate" -expectfn "$clixon_cli -1f $cfg -l o validate" 0 "^$" +expectpart "$($clixon_cli -1f $cfg -l o validate)" 0 "^$" new "cli sender" -expectfn "$clixon_cli -1f $cfg -l o set sender a" 0 "^$" +expectpart "$($clixon_cli -1f $cfg -l o set sender a)" 0 "^$" new "cli sender template" -expectfn "$clixon_cli -1f $cfg -l o set sender b template a" 0 "^$" +expectpart "$($clixon_cli -1f $cfg -l o set sender b template a)" 0 "^$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index 50403eee..b3125006 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -201,13 +201,13 @@ new "cli show conf as guest" expectpart "$($clixon_cli -1 -U guest -l o -f $cfg show conf)" 255 "application access-denied" new "cli rpc as admin" -expectfn "$clixon_cli -1 -U andy -l o -f $cfg rpc ipv4" 0 'ipv442' +expectpart "$($clixon_cli -1 -U andy -l o -f $cfg rpc ipv4)" 0 'ipv442' new "cli rpc as limited" -expectfn "$clixon_cli -1 -U wilma -l o -f $cfg rpc ipv4" 255 "access-denied default deny" +expectpart "$($clixon_cli -1 -U wilma -l o -f $cfg rpc ipv4)" 255 "access-denied default deny" new "cli rpc as guest" -expectfn "$clixon_cli -1 -U guest -l o -f $cfg rpc ipv4" 255 "access-denied access denied" +expectpart "$($clixon_cli -1 -U guest -l o -f $cfg rpc ipv4)" 255 "access-denied access denied" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_netconf.sh b/test/test_netconf.sh index a58b8e1b..6c1ae11a 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -200,7 +200,7 @@ new "netconf get replaced config" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth&t<>trueeth1ex:ethtrueeth2ex:ethtrue]]>]]>$" new "cli show configuration eth& - encoding tests" -expectfn "$clixon_cli -1 -f $cfg show conf cli" 0 "interfaces interface eth& type t<> +expectpart "$($clixon_cli -1 -f $cfg show conf cli)" 0 "interfaces interface eth& type t<> interfaces interface eth& enabled true" new "netconf edit CDATA" diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh index 25815c29..e966550e 100755 --- a/test/test_openconfig.sh +++ b/test/test_openconfig.sh @@ -99,7 +99,7 @@ new "Openconfig test: $clixon_cli -1f $cfg -y $f show version ($m modules)" for f in $files; do if [ -n "$(head -1 $f|grep '^module')" ]; then new "$clixon_cli -D $DBG -1f $cfg -y $f show version" - expectfn "$clixon_cli -D $DBG -1f $cfg -y $f show version" 0 "$version." + expectpart "$($clixon_cli -D $DBG -1f $cfg -y $f show version)" 0 "$version." fi done diff --git a/test/test_pattern.sh b/test/test_pattern.sh index 80ada1dc..cd2f89d8 100755 --- a/test/test_pattern.sh +++ b/test/test_pattern.sh @@ -743,68 +743,68 @@ testrun "p$pnr" false '248:197.7.89/8' # CLI tests new "CLI tests for RFC7950 Sec 9.4.7 ex 2 AB" -expectfn "$clixon_cli -1f $cfg -l o set c rfc2 AB" 0 '^$' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc2 AB)" 0 '^$' new "CLI tests for RFC7950 Sec 9.4.7 ex 2 9A00" -expectfn "$clixon_cli -1f $cfg -l o set c rfc2 9A00" 0 '^$' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc2 9A00)" 0 '^$' new "CLI tests for RFC7950 Sec 9.4.7 ex 2 00ABAB (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c rfc2 00ABAB" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc2 00ABAB)" 255 '^CLI syntax error:' new "CLI tests for RFC7950 Sec 9.4.7 ex 2 xx00 (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c rfc2 xx00" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc2 xx00)" 255 '^CLI syntax error:' new "CLI tests for RFC7950 Sec 9.4.7 ex 3 enabled" -expectfn "$clixon_cli -1f $cfg -l o set c rfc3 enabled" 0 '^$' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc3 enabled)" 0 '^$' new "CLI tests for RFC7950 Sec 9.4.7 ex 3 10-mbit (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c rfc3 10-mbit" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc3 10-mbit)" 255 '^CLI syntax error:' new "CLI tests for RFC7950 Sec 9.4.7 ex 3 xml-element (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c rfc3 xml-element" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c rfc3 xml-element)" 255 '^CLI syntax error:' new "CLI tests for two patterns gksdhfsakjhdks" -expectfn "$clixon_cli -1f $cfg -l o set c twomatch gksdhfsakjhdks" 0 '^$' +expectpart "$($clixon_cli -1f $cfg -l o set c twomatch gksdhfsakjhdks)" 0 '^$' new "CLI tests for two patterns xabcde (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c twomatch xabcde" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c twomatch xabcde)" 255 '^CLI syntax error:' new "CLI tests for two patterns gabcdefg (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c twomatch gabcdefg" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c twomatch gabcdefg)" 255 '^CLI syntax error:' # NOTE if the following two are swapped, it fails, the reason being: # valid "gks" is selected as a valid (expand) match although gk is not. # this may be a CLIgen error but ignored for now new "CLI tests for three patterns gk (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c threematch gk" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c threematch gk)" 255 '^CLI syntax error:' new "CLI tests for three patterns gks" -expectfn "$clixon_cli -1f $cfg -l o set c threematch gks" 0 '^$' +expectpart "$($clixon_cli -1f $cfg -l o set c threematch gks)" 0 '^$' new "CLI tests for three patterns abcg (should fail)" -expectfn "$clixon_cli -1f $cfg -l o set c threematch abcg" 255 '^CLI syntax error:' +expectpart "$($clixon_cli -1f $cfg -l o set c threematch abcg)" 255 '^CLI syntax error:' # Need to have failures first so there are no matches with existing entries new "CLI tests for CDATA, should fail" -expectfn "$clixon_cli -1f $cfg -l o set c p45 " 255 'CLI syntax error' +expectpart "$($clixon_cli -1f $cfg -l o set c p45 "")" 255 'CLI syntax error' new "CLI tests for CDATA, should fail" -expectfn "$clixon_cli -1f $cfg -l o set c p45 " 255 'CLI syntax error' +expectpart "$($clixon_cli -1f $cfg -l o set c p45 "")" 255 'CLI syntax error' new "CLI tests for CDATA, should fail" -expectfn "$clixon_cli -1f $cfg -l o set c p45 ![CDATA[foo]]>" 255 'CLI syntax error' +expectpart "$($clixon_cli -1f $cfg -l o set c p45 "![CDATA[foo]]>")" 255 'CLI syntax error' new "CLI tests for CDATA, should fail" -expectfn "$clixon_cli -1f $cfg -l o set c p45 " 0 '^$' +expectpart "$($clixon_cli -1f $cfg -l o set c p45 "")" 0 '^$' if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_perf_state_only.sh b/test/test_perf_state_only.sh index 2f010a78..45255a5a 100755 --- a/test/test_perf_state_only.sh +++ b/test/test_perf_state_only.sh @@ -157,7 +157,7 @@ done } 2>&1 | awk '/real/ {print $2}' if false; then # CLI get new "cli get test single req" -expectfn "$clixon_cli -1 -1f $cfg -l o show state xml interfaces a foo b interface e1" 0 '^ +expectpart "$($clixon_cli -1 -1f $cfg -l o show state xml interfaces a foo b interface e1)" 0 '^ e1 eth up diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 38f6c228..1bbb07ec 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -22,9 +22,9 @@ APPNAME=example cfg=$dir/conf.xml -# clixon-example and clixon-restconf is used, copy here -cp /usr/local/share/clixon/clixon-example@2020-12-01.yang $dir/ -cp /usr/local/share/clixon/clixon-restconf@2020-10-30.yang $dir/ +# clixon-example and clixon-restconf is used in the test, need local copy +cp ${TOP_SRCDIR}/example/main/clixon-example@2020-12-01.yang $dir/ +cp ${TOP_SRCDIR}/yang/clixon/clixon-restconf@2020-10-30.yang $dir/ cat < $cfg diff --git a/test/test_sock.sh b/test/test_sock.sh index 578bcd9b..cb46261e 100755 --- a/test/test_sock.sh +++ b/test/test_sock.sh @@ -61,7 +61,7 @@ EOF fi new "$clixon_cli -1f $cfg show version" - expectfn "$clixon_cli -1f $cfg show version" 0 "$version." + expectpart "$($clixon_cli -1f $cfg show version)" 0 "$version." new "hello session-id 2" expecteof "$clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "3" diff --git a/test/test_submodule.sh b/test/test_submodule.sh index 2badc9e7..29bf9c85 100755 --- a/test/test_submodule.sh +++ b/test/test_submodule.sh @@ -177,28 +177,28 @@ new "netconfig edit main module" expecteof "$clixon_netconf -qf $cfg" 0 "
foofoo
]]>]]>" "^]]>]]>$" new "cli edit main" -expectfn "$clixon_cli -1f $cfg set main x bar" 0 "" +expectpart "$($clixon_cli -1f $cfg set main x bar)" 0 "" new "cli edit main ext" -expectfn "$clixon_cli -1f $cfg set main ext bar" 0 "" +expectpart "$($clixon_cli -1f $cfg set main ext bar)" 0 "" new "netconfig edit sub1" expecteof "$clixon_netconf -qf $cfg" 0 "foofoo]]>]]>" "^]]>]]>$" new "cli edit sub1" -expectfn "$clixon_cli -1f $cfg set sub1 x bar" 0 "" +expectpart "$($clixon_cli -1f $cfg set sub1 x bar)" 0 "" new "cli edit sub1 ext" -expectfn "$clixon_cli -1f $cfg set sub1 ext1 bar" 0 "" +expectpart "$($clixon_cli -1f $cfg set sub1 ext1 bar)" 0 "" new "netconfig edit sub2 module" expecteof "$clixon_netconf -qf $cfg" 0 "foofoo]]>]]>" "^]]>]]>$" new "cli edit sub2" -expectfn "$clixon_cli -1f $cfg set sub2 x fum" 0 "" +expectpart "$($clixon_cli -1f $cfg set sub2 x fum)" 0 "" new "cli edit sub2 ext" -expectfn "$clixon_cli -1f $cfg set sub2 ext2 fum" 0 "" +expectpart "$($clixon_cli -1f $cfg set sub2 ext2 fum)" 0 "" new "netconf submodule validate" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/test_type.sh b/test/test_type.sh index 8f70b5e5..fb89889b 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -246,10 +246,10 @@ EOF fi new "cli set transitive string. type is alpha followed by number and is defined in three levels of modules" - expectfn "$clixon_cli -1f $cfg -l o set c talle x99" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set c talle x99)" 0 '^$' new "cli set transitive string error. Wrong type" - expectfn "$clixon_cli -1f $cfg -l o set c talle 9xx" 255 '^CLI syntax error: "set c talle 9xx": regexp match fail: 9xx does not match \[a-z\]\[0-9\]\*$' + expectpart "$($clixon_cli -1f $cfg -l o set c talle 9xx)" 255 '^CLI syntax error: "set c talle 9xx": regexp match fail: 9xx does not match \[a-z\]\[0-9\]\*$' new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -264,22 +264,22 @@ EOF expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" - expectfn "$clixon_cli -1f $cfg -l o set c ulle 33" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set c ulle 33)" 0 '^$' new "cli validate" - expectfn "$clixon_cli -1f $cfg -l o -l o validate" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o -l o validate)" 0 '^$' new "cli set transitive union string (and space)" - expectfn "$clixon_cli -1f $cfg -l o set c ulle un\ bounded" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set c ulle "un\ bounded")" 0 '^$' new "cli validate" - expectfn "$clixon_cli -1f $cfg -l o -l o validate" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o -l o validate)" 0 '^$' new "cli set transitive union error. should fail" - expectfn "$clixon_cli -1f $cfg -l o set c ulle kalle" 255 "^CLI syntax error: \"set c ulle kalle\": 'kalle' is not a number$" + expectpart "$($clixon_cli -1f $cfg -l o set c ulle kalle)" 255 "^CLI syntax error: \"set c ulle kalle\": 'kalle' is not a number$" new "cli set transitive union error int" - expectfn "$clixon_cli -1f $cfg -l o set c ulle 55" 255 '^CLI syntax error: "set c ulle 55": Number 55 out of range: 4 - 44$' + expectpart "$($clixon_cli -1f $cfg -l o set c ulle 55)" 255 '^CLI syntax error: "set c ulle 55": Number 55 out of range: 4 - 44$' new "netconf set transitive union error int" expecteof "$clixon_netconf -qf $cfg" 0 "55]]>]]>" "^]]>]]>" @@ -293,25 +293,25 @@ EOF #----------- new "cli set ab" - expectfn "$clixon_cli -1f $cfg -l o set list a.b.a.b" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set list a.b.a.b)" 0 '^$' new "cli set cd" - expectfn "$clixon_cli -1f $cfg -l o set list c.d.c.d" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set list c.d.c.d)" 0 '^$' new "cli set ef" - expectfn "$clixon_cli -1f $cfg -l o set list e.f.e.f" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set list e.f.e.f)" 0 '^$' new "cli set ab fail" - expectfn "$clixon_cli -1f $cfg -l o set list a&b&a&b" 255 "^CLI syntax error" + expectpart "$($clixon_cli -1f $cfg -l o set list "a&b&a&b")" 255 "^CLI syntax error" new "cli set ad fail" - expectfn "$clixon_cli -1f $cfg -l o set list a.b.c.d" 255 "^CLI syntax error" + expectpart "$($clixon_cli -1f $cfg -l o set list a.b.c.d)" 255 "^CLI syntax error" new "cli validate" - expectfn "$clixon_cli -1f $cfg -l o -l o validate" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o -l o validate)" 0 '^$' new "cli commit" - expectfn "$clixon_cli -1f $cfg -l o -l o commit" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o -l o commit)" 0 '^$' new "netconf validate ok" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -329,20 +329,20 @@ EOF expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "cli enum value" - expectfn "$clixon_cli -1f $cfg -l o set status down" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set status down)" 0 '^$' new "cli bits value" - expectfn "$clixon_cli -1f $cfg -l o set mbits create" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set mbits create)" 0 '^$' #XXX No, cli cant assign two bit values #new "cli bits two values" - #expectfn "$clixon_cli -1f $cfg -l o set mbits \"create read\"" 0 '^$' + #expectpart "$($clixon_cli -1f $cfg -l o set mbits \)"create read\"" 0 '^$' new "netconf bits two values" expecteof "$clixon_netconf -qf $cfg" 0 "create read]]>]]>" "^]]>]]>$" new "cli bits validate" - expectfn "$clixon_cli -1f $cfg -l o validate" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o validate)" 0 '^$' #-------- num0 empty value @@ -358,13 +358,13 @@ EOF #-------- num1 single range (1) new "cli range test num1 1 OK" - expectfn "$clixon_cli -1f $cfg -l o set num1 1" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set num1 1)" 0 '^$' #new "cli range test num1 -100 ok" # XXX -/minus cant be given as argv - #expectfn "$clixon_cli -1f $cfg -l o set num1 \-100" 0 '^$' + #expectpart "$($clixon_cli -1f $cfg -l o set num1 \-100)" 0 '^$' new "cli range test num1 2 error" - expectfn "$clixon_cli -1f $cfg -l o set num1 2" 255 '^CLI syntax error: "set num1 2": Number 2 out of range: 1 - 1$' + expectpart "$($clixon_cli -1f $cfg -l o set num1 2)" 255 '^CLI syntax error: "set num1 2": Number 2 out of range: 1 - 1$' new "netconf range set num1 -1" expecteof "$clixon_netconf -qf $cfg" 0 "-1]]>]]>" "^]]>]]>$" @@ -378,13 +378,13 @@ EOF #-------- num2 range and blanks new "cli range test num2 3 error" - expectfn "$clixon_cli -1f $cfg -l o set num2 3" 255 '^CLI syntax error: "set num2 3": Number 3 out of range: 4 - 4000$' + expectpart "$($clixon_cli -1f $cfg -l o set num2 3)" 255 '^CLI syntax error: "set num2 3": Number 3 out of range: 4 - 4000$' new "cli range test num2 1000 ok" - expectfn "$clixon_cli -1f $cfg -l o set num2 1000" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set num2 1000)" 0 '^$' new "cli range test num2 5000 error" - expectfn "$clixon_cli -1f $cfg -l o set num2 5000" 255 '^CLI syntax error: "set num2 5000": Number 5000 out of range: 4 - 4000$' + expectpart "$($clixon_cli -1f $cfg -l o set num2 5000)" 255 '^CLI syntax error: "set num2 5000": Number 5000 out of range: 4 - 4000$' new "netconf range set num2 3 fail" expecteof "$clixon_netconf -qf $cfg" 0 "3]]>]]>" "^]]>]]>$" @@ -410,13 +410,13 @@ EOF #-------- num3 min max range new "cli range test num3 42 ok" - expectfn "$clixon_cli -1f $cfg -l o set num3 42" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set num3 42)" 0 '^$' new "cli range test num3 260 fail" - expectfn "$clixon_cli -1f $cfg -l o set num3 260" 255 '^CLI syntax error: "set num3 260": Number 260 out of range: 0 - 255$' + expectpart "$($clixon_cli -1f $cfg -l o set num3 260)" 255 '^CLI syntax error: "set num3 260": Number 260 out of range: 0 - 255$' new "cli range test num3 -1 fail" - expectfn "$clixon_cli -1f $cfg -l o set num3 -1" 255 "CLI syntax error:" + expectpart "$($clixon_cli -1f $cfg -l o set num3 -1)" 255 "CLI syntax error:" new "netconf range set num3 260 fail" expecteof "$clixon_netconf -qf $cfg" 0 "260]]>]]>" "^]]>]]>$" @@ -430,19 +430,19 @@ EOF #-------- num4 multiple ranges 1..2 | 42..50 new "cli range test num4 multiple 0 fail" - expectfn "$clixon_cli -1f $cfg -l o set num4 0" 255 '^CLI syntax error: "set num4 0": Number 0 out of range: 1 - 2, 42 - 50$' + expectpart "$($clixon_cli -1f $cfg -l o set num4 0)" 255 '^CLI syntax error: "set num4 0": Number 0 out of range: 1 - 2, 42 - 50$' new "cli range test num4 multiple 2 ok" - expectfn "$clixon_cli -1f $cfg -l e set num4 2" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l e set num4 2)" 0 '^$' new "cli range test num4 multiple 20 fail" - expectfn "$clixon_cli -1f $cfg -l o set num4 20" 255 '^CLI syntax error: "set num4 20": Number 20 out of range: 1 - 2, 42 - 50$' + expectpart "$($clixon_cli -1f $cfg -l o set num4 20)" 255 '^CLI syntax error: "set num4 20": Number 20 out of range: 1 - 2, 42 - 50$' new "cli range test num4 multiple 42 ok" - expectfn "$clixon_cli -1f $cfg -l o set num4 42" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set num4 42)" 0 '^$' new "cli range test num4 multiple 99 fail" - expectfn "$clixon_cli -1f $cfg -l o set num4 99" 255 '^CLI syntax error: "set num4 99": Number 99 out of range: 1 - 2, 42 - 50$' + expectpart "$($clixon_cli -1f $cfg -l o set num4 99)" 255 '^CLI syntax error: "set num4 99": Number 99 out of range: 1 - 2, 42 - 50$' new "netconf range set num4 multiple 2" expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^]]>]]>$" @@ -468,16 +468,16 @@ EOF #-------- dec64 multiple ranges -3.5..-2.5 | 0.0 | 10.0..20.0 # XXX how to enter negative numbers in bash string and cli -1? new "cli range dec64 multiple 0 ok" - expectfn "$clixon_cli -1f $cfg -l o set dec 0" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set dec 0)" 0 '^$' new "cli range dec64 multiple 0.1 fail" - expectfn "$clixon_cli -1f $cfg -l o set num4 0.1" 255 '^CLI syntax error: "set num4 0.1": '"'"'0.1'"'"' is not a number$' + expectpart "$($clixon_cli -1f $cfg -l o set num4 0.1)" 255 '^CLI syntax error: "set num4 0.1": '"'"'0.1'"'"' is not a number$' new "cli range dec64 multiple 15.0 ok" - expectfn "$clixon_cli -1f $cfg -l o set dec 15.0" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set dec 15.0)" 0 '^$' new "cli range dec64 multiple 30.0 fail" - expectfn "$clixon_cli -1f $cfg -l o set dec 30.0" 255 '^CLI syntax error: "set dec 30.0": Number 30.000 out of range: -3.500 - -2.500, 0.000 - 0.000, 10.000 - 20.000$' + expectpart "$($clixon_cli -1f $cfg -l o set dec 30.0)" 255 '^CLI syntax error: "set dec 30.0": Number 30.000 out of range: -3.500 - -2.500, 0.000 - 0.000, 10.000 - 20.000$' new "dec64 discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -522,13 +522,13 @@ EOF #----------------string ranges--------------------- #-------- len1 single range (2) new "cli length test len1 1 fail" - expectfn "$clixon_cli -1f $cfg -l o set len1 x" 255 '^CLI syntax error: "set len1 x": String length 1 out of range: 2 - 2$' + expectpart "$($clixon_cli -1f $cfg -l o set len1 x)" 255 '^CLI syntax error: "set len1 x": String length 1 out of range: 2 - 2$' new "cli length test len1 2 OK" - expectfn "$clixon_cli -1f $cfg -l o set len1 xy" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set len1 xy)" 0 '^$' new "cli length test len1 3 error" - expectfn "$clixon_cli -1f $cfg -l o set len1 hej" 255 '^CLI syntax error: "set len1 hej": String length 3 out of range: 2 - 2$' + expectpart "$($clixon_cli -1f $cfg -l o set len1 hej)" 255 '^CLI syntax error: "set len1 hej": String length 3 out of range: 2 - 2$' new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -542,10 +542,10 @@ EOF #-------- len2 range and blanks new "cli length test len2 3 error" - expectfn "$clixon_cli -1f $cfg -l o set len2 ab" 255 '^CLI syntax error: "set len2 ab": String length 2 out of range: 4 - 4000$' + expectpart "$($clixon_cli -1f $cfg -l o set len2 ab)" 255 '^CLI syntax error: "set len2 ab": String length 2 out of range: 4 - 4000$' new "cli length test len2 42 ok" - expectfn "$clixon_cli -1f $cfg -l o set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set len2 hejhophdsakjhkjsadhkjsahdkjsad)" 0 '^$' new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -553,36 +553,36 @@ EOF #-------- len3 min max range new "cli range ptest len3 42 ok" - expectfn "$clixon_cli -1f $cfg -l o set len3 hsakjdhkjsahdkjsahdksahdksajdhsakjhd" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set len3 hsakjdhkjsahdkjsahdksahdksajdhsakjhd)" 0 '^$' #-------- len4 multiple ranges 2..3 | 20-29 new "cli length test len4 1 error" - expectfn "$clixon_cli -1f $cfg -l o set len4 a" 255 '^CLI syntax error: "set len4 a": String length 1 out of range: 2 - 3, 20 - 29$' + expectpart "$($clixon_cli -1f $cfg -l o set len4 a)" 255 '^CLI syntax error: "set len4 a": String length 1 out of range: 2 - 3, 20 - 29$' new "cli length test len4 2 ok" - expectfn "$clixon_cli -1f $cfg -l o set len4 ab" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set len4 ab)" 0 '^$' new "cli length test len4 10 error" - expectfn "$clixon_cli -1f $cfg -l o set len4 abcdefghij" 255 '^CLI syntax error: "set len4 abcdefghij": String length 10 out of range: 2 - 3, 20 - 29$' + expectpart "$($clixon_cli -1f $cfg -l o set len4 abcdefghij)" 255 '^CLI syntax error: "set len4 abcdefghij": String length 10 out of range: 2 - 3, 20 - 29$' new "cli length test len4 20 ok" - expectfn "$clixon_cli -1f $cfg -l o set len4 abcdefghijabcdefghija" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set len4 abcdefghijabcdefghija)" 0 '^$' new "cli length test len4 30 error" - expectfn "$clixon_cli -1f $cfg -l o set len4 abcdefghijabcdefghijabcdefghij" 255 '^CLI syntax error: "set len4 abcdefghijabcdefghijabcdefghij": String length 30 out of range: 2 - 3, 20 - 29$' + expectpart "$($clixon_cli -1f $cfg -l o set len4 abcdefghijabcdefghijabcdefghij)" 255 '^CLI syntax error: "set len4 abcdefghijabcdefghijabcdefghij": String length 30 out of range: 2 - 3, 20 - 29$' # XSD schema -> POSIX ECE translation new "cli yang pattern \d ok" - expectfn "$clixon_cli -1f $cfg -l o set digit4 0123" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set digit4 0123)" 0 '^$' new "cli yang pattern \d error" - expectfn "$clixon_cli -1f $cfg -l o set digit4 01b2" 255 '^CLI syntax error: "set digit4 01b2": regexp match fail: 01b2 does not match' + expectpart "$($clixon_cli -1f $cfg -l o set digit4 01b2)" 255 '^CLI syntax error: "set digit4 01b2": regexp match fail: 01b2 does not match' new "cli yang pattern \w ok" - expectfn "$clixon_cli -1f $cfg -l o set word4 abc9" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set word4 abc9)" 0 '^$' new "cli yang pattern \w error" - expectfn "$clixon_cli -1f $cfg -l o set word4 ab%3" 255 '^CLI syntax error: "set word4 ab%3": regexp match fail: ab%3 does not match' + expectpart "$($clixon_cli -1f $cfg -l o set word4 ab%3)" 255 '^CLI syntax error: "set word4 ab%3": regexp match fail: ab%3 does not match' new "netconf pattern \w" expecteof "$clixon_netconf -qf $cfg" 0 "aXG9]]>]]>" "^]]>]]>$" @@ -634,28 +634,28 @@ EOF expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #new "cli type with minus" - #expectfn "$clixon_cli -1f $cfg -l o set name my-name" 0 "^$" + #expectpart "$($clixon_cli -1f $cfg -l o set name my-name)" 0 "^$" #------ cli truth-values: true/on/enable false/off/disable new "cli truth: true" - expectfn "$clixon_cli -1f $cfg -l o set bool true" 0 "^$" + expectpart "$($clixon_cli -1f $cfg -l o set bool true)" 0 "^$" new "cli truth: false" - expectfn "$clixon_cli -1f $cfg -l o set bool false" 0 "^$" + expectpart "$($clixon_cli -1f $cfg -l o set bool false)" 0 "^$" new "cli truth: on" - expectfn "$clixon_cli -1f $cfg -l o set bool on" 0 "^$" + expectpart "$($clixon_cli -1f $cfg -l o set bool on)" 0 "^$" new "cli verify on translates to true" - expectfn "$clixon_cli -1f $cfg -l o show conf" 0 "bool true;" + expectpart "$($clixon_cli -1f $cfg -l o show conf)" 0 "bool true;" new "cli truth: off" - expectfn "$clixon_cli -1f $cfg -l o set bool off" 0 "^$" + expectpart "$($clixon_cli -1f $cfg -l o set bool off)" 0 "^$" new "cli verify off translates to false" - expectfn "$clixon_cli -1f $cfg -l o show conf" 0 "bool false;" + expectpart "$($clixon_cli -1f $cfg -l o show conf)" 0 "bool false;" new "cli truth: enable" - expectfn "$clixon_cli -1f $cfg -l o set bool enable" 0 "^$" + expectpart "$($clixon_cli -1f $cfg -l o set bool enable)" 0 "^$" new "cli truth: disable" - expectfn "$clixon_cli -1f $cfg -l o set bool disable" 0 "^$" + expectpart "$($clixon_cli -1f $cfg -l o set bool disable)" 0 "^$" new "cli truth: wrong" - expectfn "$clixon_cli -1f $cfg -l o set bool wrong" 255 "'wrong' is not a boolean value" + expectpart "$($clixon_cli -1f $cfg -l o set bool wrong)" 255 "'wrong' is not a boolean value" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_type_range.sh b/test/test_type_range.sh index e530b2c9..c1f29b60 100755 --- a/test/test_type_range.sh +++ b/test/test_type_range.sh @@ -235,7 +235,7 @@ testrange(){ expectpart "$($clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg" new "generated cli set $t leaf OK" - expectfn "$clixon_cli -1f $cfg -l o set l$t $val" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o set l$t $val)" 0 '^$' # XXX Error in cligen order: Unknown command vs Number out of range # olof@vandal> set luint8 0 @@ -245,14 +245,14 @@ testrange(){ # CLI syntax error: "set luint8 0": Unknown command # (SAME AS FIRST ^) new "generated cli set $t leaf invalid" - expectfn "$clixon_cli -1f $cfg -l o set l$t $eval" 255 "$errmsg" + expectpart "$($clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg" new "manual cli set $t leaf OK" - expectfn "$clixon_cli -1f $cfg -l o man h$t $val" 0 '^$' + expectpart "$($clixon_cli -1f $cfg -l o man h$t $val)" 0 '^$' new "manual cli set $t leaf invalid" echo "$clixon_cli -1f $cfg -l o set h$t $eval" - expectfn "$clixon_cli -1f $cfg -l o set l$t $eval" 255 "$errmsg" + expectpart "$($clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg" new "discard" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/test_union.sh b/test/test_union.sh index ce0c754e..b1db3745 100755 --- a/test/test_union.sh +++ b/test/test_union.sh @@ -92,13 +92,13 @@ if [ $BE -ne 0 ]; then fi new "cli set transitive string" -expectfn "$clixon_cli -1f $cfg -l o set c talle x" 0 "^$" +expectpart "$($clixon_cli -1f $cfg -l o set c talle x)" 0 "^$" new "cli set transitive union" -expectfn "$clixon_cli -1f $cfg -l o set c ulle 33" 0 "^$" +expectpart "$($clixon_cli -1f $cfg -l o set c ulle 33)" 0 "^$" new "cli set transitive union error" -expectfn "$clixon_cli -1f $cfg -l o set c ulle kalle" 255 "^CLI syntax error: \"set c ulle kalle\": 'kalle' is not a number$" +expectpart "$($clixon_cli -1f $cfg -l o set c ulle kalle)" 255 "^CLI syntax error: \"set c ulle kalle\": 'kalle' is not a number$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_yang.sh b/test/test_yang.sh index 3a1d41c5..14f23f34 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -157,7 +157,7 @@ if [ "$BE" -ne 0 ]; then fi new "cli defined extension" -expectfn "$clixon_cli -1f $cfg show version" 0 "$version." +expectpart "$($clixon_cli -1f $cfg show version)" 0 "$version." new "empty values in leaf-list" expecteof "$clixon_netconf -qf $cfg" 0 "a]]>]]>" "^]]>]]>$" @@ -175,7 +175,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 " #new "netconf not defined extension" #expecteof "$clixon_netconf -qf $cfg -l o" 0 "$YANG" "Extension ex:not-defined not found" # This text yields an error, but the test cannot detect the error message yet -#expectfn "$clixon_cli -1f $cfg -y $fyangerr show version" 0 "Yang error: Extension ex:not-defined not found" +#expectpart "$($clixon_cli -1f $cfg -y $fyangerr show version)" 0 "Yang error: Extension ex:not-defined not found" new "netconf schema resource, RFC 7895" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesimplement" @@ -206,10 +206,10 @@ new "netconf get (should be some)" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^125one" new "cli set leaf-list" -expectfn "$clixon_cli -1f $cfg set x f e foo" 0 "" +expectpart "$($clixon_cli -1f $cfg set x f e foo)" 0 "" new "cli show leaf-list" -expectfn "$clixon_cli -1f $cfg show xpath /x/f/e urn:example:clixon" 0 "foo" +expectpart "$($clixon_cli -1f $cfg show xpath /x/f/e urn:example:clixon)" 0 "foo" new "netconf set state data (not allowed)" expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^applicationinvalid-valueerrorstate in module example: state data node unexpected]]>]]>$"