#!/usr/bin/env bash # Tests multiple level groupings # See https://github.com/clicon/clixon/issues/572 # 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/example.yang # XXX try -E? cat < $cfg $cfg ${YANG_INSTALLDIR} $dir $dir /usr/local/lib/$APPNAME/backend $dir /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/run/$APPNAME.sock /usr/local/var/run/$APPNAME.pidfile $dir false EOF cat < $dir/example.cli CLICON_MODE="example"; CLICON_PROMPT="%U@%H %W> "; # Autocli syntax tree operations edit @datamodel, cli_auto_edit("datamodel"); up, cli_auto_up("datamodel"); top, cli_auto_top("datamodel"); set @datamodel, cli_auto_set(); merge @datamodel, cli_auto_merge(); create @datamodel, cli_auto_create(); commit("Commit the changes"), cli_commit(); validate("Validate changes"), cli_validate(); delete("Delete a configuration item") { @datamodel, cli_auto_del(); all("Delete whole candidate configuration"), delete_all("candidate"); } show("Show a particular state of the system"){ configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false); } EOF # Yang specs must be here first for backend. But then the specs are changed but just for CLI # Annotate original Yang spec example directly # First annotate /table/parameter # Had a problem with unknown in grouping -> test uses uses/grouping cat < $fyang module example { namespace "urn:example:clixon"; prefix ex; grouping L3-top { leaf L3{ type string; } } grouping L2-top { container L2 { uses L3-top { when 'false'; } } } container L1x { /* Does not work */ uses L2-top; } container L1y { /* Works */ container L2 { uses L3-top { when 'false'; } } } } EOF new "test params: -f $cfg" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -z -f $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