From 0a951899c88da92cbdb5756388187650ca807e84 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 11 Apr 2019 13:22:37 +0200 Subject: [PATCH] test_type run twice with/without dbcache --- test/test_type.sh | 571 ++++++++++++++++++------------------ test/test_type_nocache.sh | 602 -------------------------------------- 2 files changed, 292 insertions(+), 881 deletions(-) delete mode 100755 test/test_type_nocache.sh diff --git a/test/test_type.sh b/test/test_type.sh index 381bc0a7..1b01d7e8 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -1,6 +1,8 @@ #!/bin/bash # Advanced union types and generated code # and enum w values +# The test is run twice, first with dbcache turned on, then turned off. +# It is the only test with dbcache off. # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi @@ -12,22 +14,6 @@ fyang=$dir/type.yang fyang2=$dir/example2.yang fyang3=$dir/example3.yang -cat < $cfg - - $cfg - $dir - /usr/local/share/clixon - $IETFRFC - /usr/local/lib/$APPNAME/clispec - /usr/local/lib/$APPNAME/cli - $APPNAME - /usr/local/var/$APPNAME/$APPNAME.sock - /usr/local/var/$APPNAME/$APPNAME.pidfile - 1 - /usr/local/var/$APPNAME - true - -EOF # transitive type, exists in fyang3, referenced from fyang2, but not declared in fyang cat < $fyang3 @@ -207,395 +193,422 @@ module example{ } EOF -new "test params: -f $cfg -y $fyang" +# Type tests. +# Parameters: +# 1: dbcache true/false +testrun(){ + dbcache=$1 + new "test params: -f $cfg -y $fyang # dbcache: $dbcache" -if [ $BE -ne 0 ]; then - new "kill old backend" - sudo clixon_backend -zf $cfg - if [ $? -ne 0 ]; then - err + cat < $cfg + + $cfg + $dir + /usr/local/share/clixon + $IETFRFC + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/cli + $APPNAME + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/var/$APPNAME/$APPNAME.pidfile + 1 + /usr/local/var/$APPNAME + $dbcache + +EOF + + if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend -s init -f $cfg -y $fyang" + start_backend -s init -f $cfg -y $fyang + + new "waiting" + sleep $RCWAIT fi - new "start backend -s init -f $cfg -y $fyang" - start_backend -s init -f $cfg -y $fyang - new "waiting" - sleep $RCWAIT -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 -y $fyang set c talle x99" 0 '^$' -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 -y $fyang set c talle x99" 0 '^$' + new "cli set transitive string error. Wrong type" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c talle 9xx" 255 '^CLI syntax error: "set c talle 9xx": Unknown command$' -new "cli set transitive string error. Wrong type" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c talle 9xx" 255 '^CLI syntax error: "set c talle 9xx": Unknown command$' + new "netconf set transitive string error" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '9xx]]>]]>' "^]]>]]>" -new "netconf set transitive string error" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '9xx]]>]]>' "^]]>]]>" + new "netconf validate should fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementtalleerrorregexp match fail: "9xx" does not match \[a-z\]\[0-9\]\*]]>]]>$' -new "netconf validate should fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementtalleerrorregexp match fail: "9xx" does not match \[a-z\]\[0-9\]\*]]>]]>$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 33" 0 '^$' -new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 33" 0 '^$' + new "cli validate" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' -new "cli validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' + new "cli set transitive union string" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle unbounded" 0 '^$' -new "cli set transitive union string" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle unbounded" 0 '^$' + new "cli validate" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' -new "cli validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' + new "cli set transitive union error. should fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle kalle" 255 '^CLI syntax error: "set c ulle kalle": Unknown command$' -new "cli set transitive union error. should fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle kalle" 255 '^CLI syntax error: "set c ulle kalle": Unknown command$' + new "cli set transitive union error int" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 55" 255 '^CLI syntax error: "set c ulle 55": Unknown command$' -new "cli set transitive union error int" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 55" 255 '^CLI syntax error: "set c ulle 55": Unknown command$' + new "netconf set transitive union error int" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '55]]>]]>' "^]]>]]>" -new "netconf set transitive union error int" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '55]]>]]>' "^]]>]]>" + new "netconf validate should fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" -new "netconf validate should fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #----------- -#----------- + new "cli set ab" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.a.b" 0 '^$' -new "cli set ab" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.a.b" 0 '^$' + new "cli set cd" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list c.d.c.d" 0 '^$' -new "cli set cd" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list c.d.c.d" 0 '^$' + new "cli set ef" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list e.f.e.f" 0 '^$' -new "cli set ef" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list e.f.e.f" 0 '^$' + new "cli set ab fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a&b&a&b" 255 "^CLI syntax error" -new "cli set ab fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a&b&a&b" 255 "^CLI syntax error" + new "cli set ad fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.c.d" 255 "^CLI syntax error" -new "cli set ad fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.c.d" 255 "^CLI syntax error" + new "cli validate" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' -new "cli validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' + new "cli commit" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o commit" 0 '^$' -new "cli commit" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o commit" 0 '^$' + new "netconf validate ok" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + new "netconf set ab wrong" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'a.b& c.d]]>]]>' "^]]>]]>$" -new "netconf set ab wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'a.b& c.d]]>]]>' "^]]>]]>$" + new "netconf validate" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^" -new "netconf validate" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^" + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + new "netconf commit" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf commit" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + new "cli enum value" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set status down" 0 '^$' -new "cli enum value" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set status down" 0 '^$' + new "cli bits value" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits create" 0 '^$' -new "cli bits value" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits create" 0 '^$' + #XXX No, cli cant assign two bit values + #new "cli bits two values" + #expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits \"create read\"" 0 '^$' -#XXX No, cli cant assign two bit values -#new "cli bits two values" -#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits \"create read\"" 0 '^$' + new "netconf bits two values" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'create read]]>]]>' "^]]>]]>$" -new "netconf bits two values" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'create read]]>]]>' "^]]>]]>$" + new "cli bits validate" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 '^$' -new "cli bits validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 '^$' + #-------- num0 empty value -#-------- num0 empty value + new "netconf num0 no value" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" -new "netconf num0 no value" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" + new "netconf validate no value wrong" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementnum0errorInvalid NULL value]]>]]>' -new "netconf validate no value wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementnum0errorInvalid NULL value]]>]]>' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #-------- num1 single range (1) -#-------- num1 single range (1) + new "cli range test num1 1 OK" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 1" 0 '^$' -new "cli range test num1 1 OK" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang 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 -y $fyang set num1 \-100" 0 '^$' -#new "cli range test num1 -100 ok" # XXX -/minus cant be given as argv -#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 \-100" 0 '^$' + new "cli range test num1 2 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 2" 255 '^CLI syntax error: "set num1 2": Unknown command$' -new "cli range test num1 2 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 2" 255 '^CLI syntax error: "set num1 2": Unknown command$' + new "netconf range set num1 -1" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-1]]>]]>' "^]]>]]>$" -new "netconf range set num1 -1" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-1]]>]]>' "^]]>]]>$" + new "netconf validate num1 -1 wrong" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum1errorNumber out of range: -1]]>]]>$' -new "netconf validate num1 -1 wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum1errorNumber out of range: -1]]>]]>$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #-------- num2 range and blanks -#-------- num2 range and blanks + new "cli range test num2 3 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 3" 255 '^CLI syntax error: "set num2 3": Number out of range: 3$' -new "cli range test num2 3 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 3" 255 '^CLI syntax error: "set num2 3": Number out of range: 3$' + new "cli range test num2 1000 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 1000" 0 '^$' -new "cli range test num2 1000 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 1000" 0 '^$' + new "cli range test num2 5000 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 5000" 255 '^CLI syntax error: "set num2 5000": Unknown command$' -new "cli range test num2 5000 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 5000" 255 '^CLI syntax error: "set num2 5000": Unknown command$' + new "netconf range set num2 3 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '3]]>]]>' "^]]>]]>$" -new "netconf range set num2 3 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '3]]>]]>' "^]]>]]>$" + new "netconf validate num2 3 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 3]]>]]>$' -new "netconf validate num2 3 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 3]]>]]>$' + new "netconf range set num2 1000 ok" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '1000]]>]]>' "^]]>]]>$" -new "netconf range set num2 1000 ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '1000]]>]]>' "^]]>]]>$" + new "netconf validate num2 1000 ok" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' -new "netconf validate num2 1000 ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + new "netconf range set num2 5000 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '5000]]>]]>' "^]]>]]>$" -new "netconf range set num2 5000 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '5000]]>]]>' "^]]>]]>$" + new "netconf validate num2 5000 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 5000]]>]]>$' -new "netconf validate num2 5000 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 5000]]>]]>$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #-------- num3 min max range -#-------- num3 min max range + new "cli range test num3 42 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 42" 0 '^$' -new "cli range test num3 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 42" 0 '^$' + new "cli range test num3 260 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 260" 255 '^CLI syntax error: "set num3 260": Unknown command$' -new "cli range test num3 260 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 260" 255 '^CLI syntax error: "set num3 260": Unknown command$' + new "cli range test num3 -1 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 -1" 255 "CLI syntax error:" -new "cli range test num3 -1 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 -1" 255 '^CLI syntax error: "set num3": Incomplete command$' + new "netconf range set num3 260 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '260]]>]]>' "^]]>]]>$" -new "netconf range set num3 260 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '260]]>]]>' "^]]>]]>$" + new "netconf validate num3 260 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum3error260 is out of range(type is uint8)]]>]]>$' -new "netconf validate num3 260 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum3error260 is out of range(type is uint8)]]>]]>$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #-------- num4 multiple ranges 1..2 | 42..50 -#-------- num4 multiple ranges 1..2 | 42..50 + new "cli range test num4 multiple 0 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 0" 255 '^CLI syntax error: "set num4 0": Number out of range: 0$' -new "cli range test num4 multiple 0 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 0" 255 '^CLI syntax error: "set num4 0": Number out of range: 0$' + new "cli range test num4 multiple 2 ok" + expectfn "$clixon_cli -1f $cfg -l e -y $fyang set num4 2" 0 '^$' -new "cli range test num4 multiple 2 ok" -expectfn "$clixon_cli -1f $cfg -l e -y $fyang set num4 2" 0 '^$' + new "cli range test num4 multiple 20 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 20" 255 '^CLI syntax error: "set num4 20": Unknown command$' -new "cli range test num4 multiple 20 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 20" 255 '^CLI syntax error: "set num4 20": Unknown command$' + new "cli range test num4 multiple 42 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 42" 0 '^$' -new "cli range test num4 multiple 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 42" 0 '^$' + new "cli range test num4 multiple 99 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 99" 255 '^CLI syntax error: "set num4 99": Unknown command$' -new "cli range test num4 multiple 99 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 99" 255 '^CLI syntax error: "set num4 99": Unknown command$' + new "netconf range set num4 multiple 2" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" -new "netconf range set num4 multiple 2" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" + new "netconf validate num4 OK" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' -new "netconf validate num4 OK" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + new "netconf range set num4 multiple 20" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" -new "netconf range set num4 multiple 20" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" + new "netconf validate num4 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' -new "netconf validate num4 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + new "netconf range set num4 multiple 42" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" -new "netconf range set num4 multiple 42" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" + new "netconf validate num4 fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' -new "netconf validate num4 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #-------- 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 -y $fyang set dec 0" 0 '^$' -#-------- 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 -y $fyang set dec 0" 0 '^$' + new "cli range dec64 multiple 0.1 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 0.1" 255 '^CLI syntax error: "set num4 0.1": '"'"'0.1'"'"' is not a number$' -new "cli range dec64 multiple 0.1 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang 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 -y $fyang set dec 15.0" 0 '^$' -new "cli range dec64 multiple 15.0 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 15.0" 0 '^$' + new "cli range dec64 multiple 30.0 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 30.0" 255 '^CLI syntax error: "set dec 30.0": Unknown command$' -new "cli range dec64 multiple 30.0 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 30.0" 255 '^CLI syntax error: "set dec 30.0": Unknown command$' + new "dec64 discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "dec64 discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + # Same with netconf + new "netconf range dec64 -3.59" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.59]]>]]>' "^]]>]]>$" -# Same with netconf -new "netconf range dec64 -3.59" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.59]]>]]>' "^]]>]]>$" + new "netconf range dec64 -3.59 validate fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' -new "netconf range dec64 -3.59 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + new "netconf range dec64 -3.5" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.500]]>]]>' "^]]>]]>$" -new "netconf range dec64 -3.5" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.500]]>]]>' "^]]>]]>$" + new "netconf range dec64 -3.5 validate ok" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' -new "netconf range dec64 -3.5 validate ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + new "netconf range dec64 -2" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-2]]>]]>' "^]]>]]>$" -new "netconf range dec64 -2" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-2]]>]]>' "^]]>]]>$" + new "netconf range dec64 -2 validate fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' -new "netconf range dec64 -2 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + new "netconf range dec64 -0.001" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-0.001]]>]]>' "^]]>]]>$" -new "netconf range dec64 -0.001" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-0.001]]>]]>' "^]]>]]>$" + new "netconf range dec64 -0.001 validate fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' -new "netconf range dec64 -0.001 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + new "netconf range dec64 0.0" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '0.0]]>]]>' "^]]>]]>$" -new "netconf range dec64 0.0" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '0.0]]>]]>' "^]]>]]>$" + new "netconf range dec64 0.0 validate ok" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' -new "netconf range dec64 0.0 validate ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' + new "netconf range dec64 +0.001" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '+0.001]]>]]>' "^]]>]]>$" -new "netconf range dec64 +0.001" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '+0.001]]>]]>' "^]]>]]>$" + new "netconf range dec64 +0.001 validate fail" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' -new "netconf range dec64 +0.001 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' + #----------------string ranges--------------------- + #-------- len1 single range (2) + new "cli length test len1 1 fail" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 x" 255 '^CLI syntax error: "set len1 x": String length not within limits: 1$' -#----------------string ranges--------------------- -#-------- len1 single range (2) -new "cli length test len1 1 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 x" 255 '^CLI syntax error: "set len1 x": String length not within limits: 1$' + new "cli length test len1 2 OK" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 xy" 0 '^$' -new "cli length test len1 2 OK" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 xy" 0 '^$' + new "cli length test len1 3 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 hej" 255 '^CLI syntax error: "set len1 hej": Unknown command$' -new "cli length test len1 3 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 hej" 255 '^CLI syntax error: "set len1 hej": Unknown command$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + new "netconf length set len1 1" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$" -new "netconf length set len1 1" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$" + new "netconf validate len1 1 wrong" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementlen1errorstring length out of range: 1]]>]]>$' -new "netconf validate len1 1 wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementlen1errorstring length out of range: 1]]>]]>$' + #-------- len2 range and blanks -#-------- len2 range and blanks + new "cli length test len2 3 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 ab" 255 '^CLI syntax error: "set len2 ab": String length not within limits: 2$' -new "cli length test len2 3 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 ab" 255 '^CLI syntax error: "set len2 ab": String length not within limits: 2$' + new "cli length test len2 42 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 '^$' -new "cli length test len2 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 '^$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #-------- len3 min max range -#-------- len3 min max range + new "cli range ptest len3 42 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len3 hsakjdhkjsahdkjsahdksahdksajdhsakjhd" 0 '^$' -new "cli range ptest len3 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang 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 -y $fyang set len4 a" 255 '^CLI syntax error: "set len4 a": String length not within limits: 1$' -#-------- len4 multiple ranges 2..3 | 20-29 -new "cli length test len4 1 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 a" 255 '^CLI syntax error: "set len4 a": String length not within limits: 1$' + new "cli length test len4 2 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 ab" 0 '^$' -new "cli length test len4 2 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 ab" 0 '^$' + new "cli length test len4 10 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghij" 255 '^CLI syntax error: "set len4 abcdefghij": Unknown command$' -new "cli length test len4 10 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghij" 255 '^CLI syntax error: "set len4 abcdefghij": Unknown command$' + new "cli length test len4 20 ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghija" 0 '^$' -new "cli length test len4 20 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghija" 0 '^$' + new "cli length test len4 30 error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghijabcdefghij" 255 '^CLI syntax error: "set len4 abcdefghijabcdefghijabcdefghij": Unknown command$' -new "cli length test len4 30 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghijabcdefghij" 255 '^CLI syntax error: "set len4 abcdefghijabcdefghijabcdefghij": Unknown command$' + # XSD schema -> POSIX ECE translation + new "cli yang pattern \d ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 0123" 0 '^$' -# XSD schema -> POSIX ECE translation -new "cli yang pattern \d ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 0123" 0 '^$' + new "cli yang pattern \d error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 01b2" 255 '^CLI syntax error: "set digit4 01b2": Unknown command$' -new "cli yang pattern \d error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 01b2" 255 '^CLI syntax error: "set digit4 01b2": Unknown command$' + new "cli yang pattern \w ok" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 abc9" 0 '^$' -new "cli yang pattern \w ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 abc9" 0 '^$' + new "cli yang pattern \w error" + expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 ab%3" 255 '^CLI syntax error: "set word4 ab%3": Unknown command$' -new "cli yang pattern \w error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 ab%3" 255 '^CLI syntax error: "set word4 ab%3": Unknown command$' + new "netconf pattern \w" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'aXG9]]>]]>' "^]]>]]>$" -new "netconf pattern \w" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'aXG9]]>]]>' "^]]>]]>$" + new "netconf pattern \w valid" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" -new "netconf pattern \w valid" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" + new "netconf pattern \w error" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'ab%d3]]>]]>' "^]]>]]>$" -new "netconf pattern \w error" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'ab%d3]]>]]>' "^]]>]]>$" + new "netconf pattern \w valid" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' '^applicationbad-elementword4errorregexp match fail: "ab%d3" does not match \\w{4}]]>]]>$' -new "netconf pattern \w valid" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' '^applicationbad-elementword4errorregexp match fail: "ab%d3" does not match \\w{4}]]>]]>$' + new "netconf discard-changes" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #------ minus -#------ minus + new "type with minus" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'my-name]]>]]>' "^]]>]]>$" -new "type with minus" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'my-name]]>]]>' "^]]>]]>$" + new "validate minus" + expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" -new "validate minus" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" + #new "cli type with minus" + #expectfn "$clixon_cli -1f $cfg -l o -y $fyang set name my-name" 0 '^$' -#new "cli type with minus" -#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set name my-name" 0 '^$' + if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=`pgrep -u root -f clixon_backend` + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg + fi +} -if [ $BE -eq 0 ]; then - exit # BE -fi +# Run with db cache +testrun true -new "Kill backend" -# Check if premature kill -pid=`pgrep -u root -f clixon_backend` -if [ -z "$pid" ]; then - err "backend already dead" -fi -# kill backend -stop_backend -f $cfg +# Run without db cache +testrun false rm -rf $dir diff --git a/test/test_type_nocache.sh b/test/test_type_nocache.sh deleted file mode 100755 index bedff56d..00000000 --- a/test/test_type_nocache.sh +++ /dev/null @@ -1,602 +0,0 @@ -#!/bin/bash -# Advanced union types and generated code -# and enum w values -# @see test_type.sh ONLY DIFFERENCE IS db-cache is OFF here - -# Magic line must be first in script (see README.md) -s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi - -APPNAME=example - -cfg=$dir/conf_yang.xml -fyang=$dir/type.yang -fyang2=$dir/example2.yang -fyang3=$dir/example3.yang - -cat < $cfg - - $cfg - $dir - /usr/local/share/clixon - $IETFRFC - /usr/local/lib/$APPNAME/clispec - /usr/local/lib/$APPNAME/cli - $APPNAME - /usr/local/var/$APPNAME/$APPNAME.sock - /usr/local/var/$APPNAME/$APPNAME.pidfile - 1 - /usr/local/var/$APPNAME - false - -EOF - -# transitive type, exists in fyang3, referenced from fyang2, but not declared in fyang -cat < $fyang3 -module example3{ - prefix ex3; - namespace "urn:example:example3"; - typedef w{ - type union{ - type int32{ - range "4..44"; - } - } - } - typedef u{ - type union { - type w; - type enumeration { - enum "bounded"; - enum "unbounded"; - } - } - } - typedef t{ - type string{ - pattern '[a-z][0-9]*'; - } - } -} -EOF -cat < $fyang2 -module example2{ - import example3 { prefix ex3; } - namespace "urn:example:example2"; - prefix ex2; - grouping gr2 { - leaf talle{ - type ex3:t; - } - leaf ulle{ - type ex3:u; - } - } -} -EOF -cat < $fyang -module example{ - yang-version 1.1; - namespace "urn:example:clixon"; - prefix ex; - import example2 { prefix ex2; } - typedef ab { - type string { - pattern - '(([a-b])\.){3}[a-b]'; - } - } - typedef cd { - type string { - pattern - '(([c-d])\.){3}[c-d]'; - } - } - typedef ef { - type string { - pattern - '(([e-f])\.){3}[e-f]'; - length "1..253"; - } - } - typedef ad { - type union { - type ab; - type cd; - } - } - typedef af { - type union { - type ad; - type ef; - } - } - list list { - key ip; - leaf ip { - type af; - } - } - leaf status { - type enumeration { - enum up { - value 1; - } - enum down; - } - } - leaf num0 { - type int32; - } - leaf num1 { - type int32 { - range "1"; - } - } - leaf num2 { /* range and blanks */ - type int32 { - range " 4 .. 4000 "; - } - } - leaf num3 { - type uint8 { - range "min..max"; - } - } - leaf num4 { - type uint8 { - range "1..2 | 42..50"; - } - } - leaf dec { - /* For test of multiple ranges with decimal64. More than 2, single range*/ - type decimal64 { - fraction-digits 3; - range "-3.5..-2.5 | 0.0 | 10.0..20.0"; - } - } - leaf len1 { - type string { - length "2"; - } - } - leaf len2 { - type string { - length " 4 .. 4000 "; - } - } - leaf len3 { - type string { - length "min..max"; - } - } - leaf len4 { - type string { - length "2 .. 3 | 20..29"; - } - } - typedef mybits { - description "Test adding several bits"; - type bits { - bit create; - bit read; - bit write; - } - } - leaf mbits{ - type mybits; - } - container c{ - description "transitive type- exists in ex3"; - uses ex2:gr2; - } - leaf digit4{ - type string { - pattern '\d{4}'; - } - } - leaf word4{ - type string { - pattern '\w{4}'; - } - } - leaf minus{ - description "Problem with minus"; - type string{ - pattern '[a-zA-Z_][a-zA-Z0-9_\-.]*'; - } - } -} -EOF - -new "test params: -f $cfg -y $fyang" - -if [ $BE -ne 0 ]; then - new "kill old backend" - sudo clixon_backend -zf $cfg - if [ $? -ne 0 ]; then - err - fi - new "start backend -s init -f $cfg -y $fyang" - start_backend -s init -f $cfg -y $fyang - - new "waiting" - sleep $RCWAIT -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 -y $fyang set c talle x99" 0 '^$' - -new "cli set transitive string error. Wrong type" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c talle 9xx" 255 '^CLI syntax error: "set c talle 9xx": Unknown command$' - -new "netconf set transitive string error" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '9xx]]>]]>' "^]]>]]>" - -new "netconf validate should fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementtalleerrorregexp match fail: "9xx" does not match \[a-z\]\[0-9\]\*]]>]]>$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 33" 0 '^$' - -new "cli validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' - -new "cli set transitive union string" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle unbounded" 0 '^$' - -new "cli validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' - -new "cli set transitive union error. should fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle kalle" 255 '^CLI syntax error: "set c ulle kalle": Unknown command$' - -new "cli set transitive union error int" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set c ulle 55" 255 '^CLI syntax error: "set c ulle 55": Unknown command$' - -new "netconf set transitive union error int" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '55]]>]]>' "^]]>]]>" - -new "netconf validate should fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#----------- - -new "cli set ab" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.a.b" 0 '^$' - -new "cli set cd" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list c.d.c.d" 0 '^$' - -new "cli set ef" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list e.f.e.f" 0 '^$' - -new "cli set ab fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a&b&a&b" 255 "^CLI syntax error" - -new "cli set ad fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set list a.b.c.d" 255 "^CLI syntax error" - -new "cli validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o validate" 0 '^$' - -new "cli commit" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang -l o commit" 0 '^$' - -new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -new "netconf set ab wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'a.b& c.d]]>]]>' "^]]>]]>$" - -new "netconf validate" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^" - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -new "netconf commit" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -new "cli enum value" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set status down" 0 '^$' - -new "cli bits value" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits create" 0 '^$' - -#XXX No, cli cant assign two bit values -#new "cli bits two values" -#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits \"create read\"" 0 '^$' - -new "netconf bits two values" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'create read]]>]]>' "^]]>]]>$" - -new "cli bits validate" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 '^$' - -#-------- num0 empty value - -new "netconf num0 no value" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" - -new "netconf validate no value wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" 'applicationbad-elementnum0errorInvalid NULL value]]>]]>' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#-------- num1 single range (1) - -new "cli range test num1 1 OK" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang 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 -y $fyang set num1 \-100" 0 '^$' - -new "cli range test num1 2 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 2" 255 '^CLI syntax error: "set num1 2": Unknown command$' - -new "netconf range set num1 -1" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-1]]>]]>' "^]]>]]>$" - -new "netconf validate num1 -1 wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum1errorNumber out of range: -1]]>]]>$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#-------- num2 range and blanks - -new "cli range test num2 3 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 3" 255 '^CLI syntax error: "set num2 3": Number out of range: 3$' - -new "cli range test num2 1000 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 1000" 0 '^$' - -new "cli range test num2 5000 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 5000" 255 '^CLI syntax error: "set num2 5000": Unknown command$' - -new "netconf range set num2 3 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '3]]>]]>' "^]]>]]>$" - -new "netconf validate num2 3 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 3]]>]]>$' - -new "netconf range set num2 1000 ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '1000]]>]]>' "^]]>]]>$" - -new "netconf validate num2 1000 ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' - -new "netconf range set num2 5000 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '5000]]>]]>' "^]]>]]>$" - -new "netconf validate num2 5000 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber out of range: 5000]]>]]>$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#-------- num3 min max range - -new "cli range test num3 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 42" 0 '^$' - -new "cli range test num3 260 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 260" 255 '^CLI syntax error: "set num3 260": Unknown command$' - -new "cli range test num3 -1 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 -1" 255 '^CLI syntax error: "set num3": Incomplete command$' - -new "netconf range set num3 260 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '260]]>]]>' "^]]>]]>$" - -new "netconf validate num3 260 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementnum3error260 is out of range(type is uint8)]]>]]>$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#-------- num4 multiple ranges 1..2 | 42..50 - -new "cli range test num4 multiple 0 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 0" 255 '^CLI syntax error: "set num4 0": Number out of range: 0$' - -new "cli range test num4 multiple 2 ok" -expectfn "$clixon_cli -1f $cfg -l e -y $fyang set num4 2" 0 '^$' - -new "cli range test num4 multiple 20 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 20" 255 '^CLI syntax error: "set num4 20": Unknown command$' - -new "cli range test num4 multiple 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 42" 0 '^$' - -new "cli range test num4 multiple 99 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num4 99" 255 '^CLI syntax error: "set num4 99": Unknown command$' - -new "netconf range set num4 multiple 2" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" - -new "netconf validate num4 OK" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' - -new "netconf range set num4 multiple 20" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" - -new "netconf validate num4 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' - -new "netconf range set num4 multiple 42" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '42]]>]]>' "^]]>]]>$" - -new "netconf validate num4 fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#-------- 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 -y $fyang set dec 0" 0 '^$' - -new "cli range dec64 multiple 0.1 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang 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 -y $fyang set dec 15.0" 0 '^$' - -new "cli range dec64 multiple 30.0 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set dec 30.0" 255 '^CLI syntax error: "set dec 30.0": Unknown command$' - -new "dec64 discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -# Same with netconf -new "netconf range dec64 -3.59" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.59]]>]]>' "^]]>]]>$" - -new "netconf range dec64 -3.59 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' - -new "netconf range dec64 -3.5" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-3.500]]>]]>' "^]]>]]>$" - -new "netconf range dec64 -3.5 validate ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' - -new "netconf range dec64 -2" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-2]]>]]>' "^]]>]]>$" - -new "netconf range dec64 -2 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' - -new "netconf range dec64 -0.001" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '-0.001]]>]]>' "^]]>]]>$" - -new "netconf range dec64 -0.001 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' - -new "netconf range dec64 0.0" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '0.0]]>]]>' "^]]>]]>$" - -new "netconf range dec64 0.0 validate ok" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^]]>]]>$' - -new "netconf range dec64 +0.001" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '+0.001]]>]]>' "^]]>]]>$" - -new "netconf range dec64 +0.001 validate fail" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber out of range' - -#----------------string ranges--------------------- -#-------- len1 single range (2) -new "cli length test len1 1 fail" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 x" 255 '^CLI syntax error: "set len1 x": String length not within limits: 1$' - -new "cli length test len1 2 OK" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 xy" 0 '^$' - -new "cli length test len1 3 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 hej" 255 '^CLI syntax error: "set len1 hej": Unknown command$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -new "netconf length set len1 1" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$" - -new "netconf validate len1 1 wrong" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^applicationbad-elementlen1errorstring length out of range: 1]]>]]>$' - -#-------- len2 range and blanks - -new "cli length test len2 3 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 ab" 255 '^CLI syntax error: "set len2 ab": String length not within limits: 2$' - -new "cli length test len2 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 '^$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#-------- len3 min max range - -new "cli range ptest len3 42 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang 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 -y $fyang set len4 a" 255 '^CLI syntax error: "set len4 a": String length not within limits: 1$' - -new "cli length test len4 2 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 ab" 0 '^$' - -new "cli length test len4 10 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghij" 255 '^CLI syntax error: "set len4 abcdefghij": Unknown command$' - -new "cli length test len4 20 ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghija" 0 '^$' - -new "cli length test len4 30 error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len4 abcdefghijabcdefghijabcdefghij" 255 '^CLI syntax error: "set len4 abcdefghijabcdefghijabcdefghij": Unknown command$' - -# XSD schema -> POSIX ECE translation -new "cli yang pattern \d ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 0123" 0 '^$' - -new "cli yang pattern \d error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set digit4 01b2" 255 '^CLI syntax error: "set digit4 01b2": Unknown command$' - -new "cli yang pattern \w ok" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 abc9" 0 '^$' - -new "cli yang pattern \w error" -expectfn "$clixon_cli -1f $cfg -l o -y $fyang set word4 ab%3" 255 '^CLI syntax error: "set word4 ab%3": Unknown command$' - -new "netconf pattern \w" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'aXG9]]>]]>' "^]]>]]>$" - -new "netconf pattern \w valid" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' "^]]>]]>$" - -new "netconf pattern \w error" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'ab%d3]]>]]>' "^]]>]]>$" - -new "netconf pattern \w valid" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' '^applicationbad-elementword4errorregexp match fail: "ab%d3" does not match \\w{4}]]>]]>$' - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - - -#------ minus - -new "type with minus" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'my-name]]>]]>' "^]]>]]>$" - -new "validate minus" -expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" - -#new "cli type with minus" -#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set name my-name" 0 '^$' - -if [ $BE -eq 0 ]; then - exit # BE -fi - -new "Kill backend" -# Check if premature kill -pid=`pgrep -u root -f clixon_backend` -if [ -z "$pid" ]; then - err "backend already dead" -fi -# kill backend -stop_backend -f $cfg - -rm -rf $dir