#!/usr/bin/env bash # Yang features. if-feature. # The test has a example module with FEATURES A and B, where A is enabled and # Ignore dont throw error, see https://github.com/clicon/clixon/issues/322 # 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 # Note ietf-routing@2018-03-13 assumed cat < $cfg ietf-netconf:startup $cfg ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir EOF cat < $fyang module example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; feature A{ description "This test feature is enabled"; } grouping mytop { container mycontainer { if-feature A; leaf myleaf { type string; } } } uses mytop; } EOF cat< $dir/startup_db <${DATASTORE_TOP}> boo EOF # testrun() { opt=$1 new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -s startup -f $cfg" start_backend -s startup ${opt} -f $cfg new "wait backend" wait_backend } new "test params: -f $cfg" new "enable feature A" testrun "-o CLICON_FEATURE=example:A" new "enable feature B, expect fail" testrun "-o CLICON_FEATURE=example:B" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi # kill backend stop_backend -f $cfg fi unset ret endtest rm -rf $dir