diff --git a/test/test_cli_auto_genmodel.sh b/test/test_cli_auto_genmodel.sh index 9f77fe47..d883b6b6 100755 --- a/test/test_cli_auto_genmodel.sh +++ b/test/test_cli_auto_genmodel.sh @@ -1,6 +1,7 @@ + #!/usr/bin/env bash # Tests for using the auto cli. -# In particular setting a config, displaying as cli commands and reconfigure it +# In particular setting a config, displaying as cli commands and reconfigure it # Tests: # Make a config in CLI. Show output as CLI, save it and ensure it is the same # Try the different GENMODEL settings @@ -25,11 +26,20 @@ fi # Use yang in example +if [ ! -d "$OPENCONFIG" ]; then +# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" + echo "...skipped: OPENCONFIG not set" + if [ "$s" = $0 ]; then exit 0; else return 0; fi +fi + +OCDIR=$OPENCONFIG/release/models + cat < $cfg $cfg /usr/local/share/clixon $dir + $OCDIR/ $fyang /usr/local/lib/$APPNAME/backend $clidir @@ -49,6 +59,7 @@ cat < $fyang module $APPNAME { namespace "urn:example:clixon"; prefix ex; + import openconfig-extensions { prefix oc-ext; } container table{ list parameter{ key name; @@ -69,6 +80,42 @@ module $APPNAME { } } } + container interfaces { + oc-ext:operational; + list interface { + key name; + leaf name { + type string; + } + container config { + leaf enabled { + type boolean; + default false; + description "Whether the interface is enabled or not."; + } + } + container state { + config false; + leaf oper-status { + type enumeration { + enum UP { + value 1; + description "Ready to pass packets."; + } + enum DOWN { + value 2; + description "The interface does not pass any packets."; + } + } + } + } + leaf enabled { + type boolean; + default false; + description "Whether the interface is enabled or not."; + } + } + } } EOF @@ -127,6 +174,9 @@ function testrun() elif [ $mode = HIDE ]; then table= name= + elif [ $mode = OC_COMPRESS ]; then + table= + name= else table=" table" name= @@ -159,7 +209,7 @@ SAVED=$($clixon_cli -1 -o CLICON_CLI_GENMODEL_TYPE=$mode -f $cfg show config) new "delete a x" expectpart "$($clixon_cli -1 -o CLICON_CLI_GENMODEL_TYPE=$mode -f $cfg delete$table parameter$name a value x)" 0 "" - new "show match a & b xml" + new "show match a & b xml" expectpart "$($clixon_cli -1 -o CLICON_CLI_GENMODEL_TYPE=$mode -f $cfg show xml)" 0 "" "" "a" "" "" "b" "z" "" "
" --not-- "x" new "delete a" @@ -190,6 +240,9 @@ testrun HIDE new "keywords=ALL" testrun ALL +new "keywords=OC_COMPRESS" +testrun OC_COMPRESS + new "keywords=VARS" testrun VARS @@ -201,7 +254,7 @@ new "commit" expectpart "$($clixon_cli -1 -f $cfg commit)" 0 "" new "show state" -expectpart "$($clixon_cli -1 -f $cfg show state)" 0 "exstate sender x" "table parameter a" "table parameter a value x" +expectpart "$($clixon_cli -1 -f $cfg show state)" 0 "exstate sender x" "table parameter a" "table parameter a value x" new "show state exstate" expectpart "$($clixon_cli -1 -f $cfg show state exstate)" 0 "state sender x" --not-- "table parameter a" "table parameter a value x"