#!/usr/bin/env bash # Test for RFC8528 YANG Schema Mount # Only if compiled with YANG_SCHEMA_MOUNT # 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_mount.xml fyang=$dir/clixon-example.yang cat < $cfg $cfg ${YANG_INSTALLDIR} ${dir} $fyang true /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir true true true true EOF cat < $fyang module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; import ietf-yang-schema-mount { prefix yangmnt; } container top{ list mylist{ key name; leaf name{ type string; } container root{ presence "Otherwise root is not visible"; yangmnt:mount-point "myroot"{ description "Root for other yang models"; } } } } } 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_backend -s init -f $cfg fi new "wait backend" wait_backend new "Add two mountpoints: x and y" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xy" "" "" new "netconf commit" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Retrieve schema-mounts with Operation" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "clixon-exampletrue" new "get yang-lib at mountpoint" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" ">" "xmountclixon-example2022-11-01urn:example:urnymountclixon-example2022-11-01urn:example:urn" 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 rm -rf $dir new "endtest" endtest