#!/usr/bin/env bash # Test netconf / xml whitespaces # Insignicant and significant # See https://www.w3.org/TR/xml-c14n # where "clean", "dirty" and "mixed" whitespaces are defined # # A B # # A # # B # A B # C # # 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/whitespace.yang cat < $cfg $cfg ietf-netconf:startup ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir EOF cat < $fyang module whitespace{ yang-version 1.1; namespace "urn:example:whitespace"; prefix fi; container x{ presence true; list y { key a; leaf a{ type string; } container b{ presence true; } } } } EOF new "test params: -f $cfg -s startup" # Keep the following as is (whitespace) echo "<${DATASTORE_TOP}> foo\n " > $dir/startup_db if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg -s startup if [ $? -ne 0 ]; then err fi new "start backend -s startup -f $cfg" start_backend -s startup -f $cfg fi new "wait backend" wait_backend new "get startup" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "remove" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "commit" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add insignificant 'dirty' whitespaces" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " \t \ foo\n " "" "" new "get stripped whitespace" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "validate" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add insignificant 'dirty' whitespaces with prefixes" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " \t \ foo\n " "" "" new "get stripped whitespace" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "validate" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add insignificant 'clean' whitespaces" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " \n \t " "" "" new "add more insignificant 'clean' whitespaces" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foo " "" "" new "get stripped whitespace" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "validate" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add significant whitespaces" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " foo bar " "" "" new "get significant whitespace" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" " foo bar " new "validate" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" 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