#!/bin/bash # Test4: Yang specifics: multi-keys and empty type # include err() and new() functions . ./lib.sh clixon_cf=/tmp/conf_yang.xml # For memcheck # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" clixon_netconf=clixon_netconf clixon_cli=clixon_cli cat < /tmp/conf_yang.xml /tmp/test_yang.xml /usr/local/share/routing/yang example /usr/local/lib/routing/clispec /usr/local/lib/routing/cli routing /usr/local/var/routing/routing.sock /usr/local/var/routing/routing.pidfile 1 /usr/local/var/routing /usr/local/lib/xmldb/text.so EOF cat < /tmp/test.yang module example{ container x { list y { key "a b"; leaf a { type string; } leaf b { type string; } leaf c { type string; } } leaf d { type empty; } container f { leaf-list e { type string; } } leaf g { type string; } container nopresence { description "No presence should be removed if no children"; leaf j { type string; } } container presence { description "Presence should not be removed even if no children"; presence "even if empty should remain"; leaf j { type string; } } anyxml any{ description "testing of anyxml"; } } container state { config false; leaf-list op { type string; } } } EOF # kill old backend (if any) new "kill old backend" sudo clixon_backend -zf $clixon_cf -y /tmp/test.yang if [ $? -ne 0 ]; then err fi new "start backend" # start new backend sudo clixon_backend -s init -f $clixon_cf -y /tmp/test.yang if [ $? -ne 0 ]; then err fi new "netconf edit config" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "125]]>]]>" "^]]>]]>$" new "netconf commit" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^]]>]]>$" # text empty type in running new "netconf commit 2nd" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^]]>]]>$" new "netconf get config xpath" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^125]]>]]>$" new "netconf edit leaf-list" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "hejhopp]]>]]>" "^]]>]]>$" new "netconf get leaf-list" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^hejhopp]]>]]>$" new "netconf get leaf-list path" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^hejhopp]]>]]>$" new "netconf get (should be some)" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^125]]>]]>$" new "cli set leaf-list" expectfn "$clixon_cli -1f $clixon_cf -y /tmp/test.yang set x f e foo" "" new "cli show leaf-list" expectfn "$clixon_cli -1f $clixon_cf -y /tmp/test.yang show xpath /x/f/e" "foo" new "netconf set state data (not allowed)" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "42]]>]]>" "^invalid-value" new "netconf set presence and not present" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^]]>]]>$" new "netconf get" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^]]>]]>$" new "netconf discard-changes" expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$" new "netconf anyxml" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^]]>]]>$" new "netconf validate anyxml" expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/test.yang" "]]>]]>" "^]]>]]>$" new "Kill backend" # Check if still alive pid=`pgrep clixon_backend` if [ -z "$pid" ]; then err "backend already dead" fi # kill backend sudo clixon_backend -zf $clixon_cf if [ $? -ne 0 ]; then err "kill backend" fi