#!/usr/bin/env bash # Combined augment and if-feature # See https://github.com/clicon/clixon/issues/555 # # 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/shelf-slot-test.yang cat < $cfg $cfg $dir ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/run/$APPNAME.sock /usr/local/var/run/$APPNAME.pidfile /usr/local/var/$APPNAME true EOF cat < $fyang module shelf-slot-test { namespace "urn:example:shelf-slot-test"; prefix shelf-slot-test; revision 2024-09-17 { description "test"; } container config { } augment /config { container system { } } feature enable-shelf { description "enable shelf"; } augment /config/system { list shelf { // This breaks clixon! if-feature shelf-slot-test:enable-shelf; key location; description "location of the shelf"; leaf location { type string; } } list slot { key location; description "location of the slot"; leaf location { type string; } } } augment '/config/system/slot' { leaf v1 { type int32; } } } 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 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