#!/usr/bin/env bash # Netconf with default capability See RFC 6243 # Test what clixon has # These are the modes defined in RFC 6243: # o report-all # (o report-all-tagged) # o trim # o explicit # Clixon supports explicit, but the testcases define the other cases as well # in case others will be supported # See test_yang_with_default for full RFC6243 tests # 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-default.yang cat < $cfg $cfg ietf-netconf:startup 42 ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/backend example_backend.so$ /usr/local/lib/$APPNAME/netconf /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli $APPNAME $dir/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME EOF cat < $fyang module example-default { namespace "urn:example:default"; prefix "ex"; typedef dt { description "Just a base type with a default value of 42"; type int32; default 42; } container c{ list x { key k; leaf k{ type string; } leaf y { /* Three possible values: notset, default(42), other(eg 99) */ type dt; } } } } EOF new "test params: -f $cfg" # Bring your own backend if [ $BE -ne 0 ]; then # kill old backend (if any) 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 # This is the base XML with three values in the server: notset, default, other XML='default42notsetother99' # report-all: does not consider any data node to be default data, # even schema default data. (noset is set to 42) REPORT_ALL='default42notset42other99' # trim: MUST consider any data node set to its schema default value to be # default data (default is not set) TRIM='defaultnotsetother99' # explicit: MUST consider any data node that is not explicitly set data to # be default data. # (SAME AS Input XML) EXPLICIT='default42notsetother99' new "Set defaults" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "Check config (Clixon supports explicit)" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$EXPLICIT" 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