#!/bin/bash # Yang list / leaf-list operations. min/max-elements # 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/test.yang cat < $cfg $cfg /usr/local/share/clixon $IETFRFC $fyang /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 /usr/local/lib/xmldb/text.so EOF cat < $fyang module $APPNAME{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; container c{ presence true; list a0{ key k; leaf k { type string; } min-elements 0; max-elements "unbounded"; } list a1{ key k; leaf k { type string; } description "There must be at least one of these"; min-elements 1; max-elements 2; } leaf-list b0{ type string; min-elements 0; max-elements "unbounded"; } leaf-list b1{ description "There must be at least one of these"; type string; min-elements 1; max-elements 2; } } } EOF new "test params: -f $cfg" 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" # start new backend sudo $clixon_backend -s init -f $cfg -D $DBG if [ $? -ne 0 ]; then err fi fi new "minmax: minimal" expecteof "$clixon_netconf -qf $cfg" 0 'replace00]]>]]>' "^]]>]]>$" new "minmax: minimal validate ok" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: maximal" expecteof "$clixon_netconf -qf $cfg" 0 'replace01unbounded0101unbounded01]]>]]>' '^]]>]]>$' new "minmax: validate ok" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: empty" expecteof "$clixon_netconf -qf $cfg" 0 'replace]]>]]>' '^]]>]]>$' # NYI if false; then # nyi new "minmax: validate should fail" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: no list" expecteof "$clixon_netconf -qf $cfg" 0 'replace0]]>]]>' '^]]>]]>$' new "minmax: validate should fail" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: no leaf-list" expecteof "$clixon_netconf -qf $cfg" 0 'replace0]]>]]>' '^]]>]]>$' new "minmax: validate should fail" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: Too large list" expecteof "$clixon_netconf -qf $cfg" 0 'replace0120]]>]]>' '^]]>]]>$' new "minmax: validate should fail" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: Too large leaf-list" expecteof "$clixon_netconf -qf $cfg" 0 'replace0012]]>]]>' '^]]>]]>$' new "minmax: validate should fail" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" fi # NYI 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 sudo clixon_backend -z -f $cfg if [ $? -ne 0 ]; then err "kill backend" fi rm -rf $dir