Merge branch 'develop' of https://github.com/clicon/clixon into develop
This commit is contained in:
commit
055b1df80c
58 changed files with 579 additions and 538 deletions
|
|
@ -21,7 +21,22 @@ application. Assumes setup of http daemon as describe under apps/restonf
|
|||
- test_datastore.sh Datastore tests
|
||||
- and many more...
|
||||
|
||||
Tests called 'test*.sh' and placed in this directory will be automatically run as part of the all.sh, sum.sh tests etc.
|
||||
Tests called 'test_*.sh' and placed in this directory will be
|
||||
automatically run as part of the all.sh, sum.sh tests etc. The scripts need to follow some rules to work properly, such as add this magic line as the first command line in the script, which ensures it works well when started from `all.sh`:
|
||||
```
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
```
|
||||
|
||||
You need to build and install the clixon utility programs before running the tests as some of the tests rely on them:
|
||||
```
|
||||
cd util
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
You need to start nginx for some of the text. There are instructions in
|
||||
* If you run systemd: `sudo systemctl start nginx.service`
|
||||
* The [example](../example/README.md) has instructions
|
||||
|
||||
You can prefix a test with `BE=0` if you want to run your own backend.
|
||||
|
||||
|
|
@ -37,14 +52,16 @@ Run all tests but continue after errors and only print a summary test output ide
|
|||
all.sh summary
|
||||
```
|
||||
|
||||
You need to start nginx. There are instructions in [the example](../example/README.md)
|
||||
|
||||
Example site.sh file:
|
||||
```
|
||||
# Add your local site specific env variables (or tests) here.
|
||||
# Add test to this list that you dont want run
|
||||
SKIPLIST="test_openconfig.sh test_yangmodels.sh"
|
||||
# Parse yang openconfig models from https://github.com/openconfig/public
|
||||
OPENCONFIG=/home/olof/src/clixon/test/public
|
||||
# Parse yangmodels from https://github.com/YangModels/yang
|
||||
YANGMODELS=/usr/local/share/yangmodels
|
||||
# Standard IETF RFC yang files.
|
||||
IETFRFC=$YANGMODELS/standard/ietf/RFC
|
||||
```
|
||||
|
||||
#!/bin/bash
|
||||
# Add your local site specific env variables (or tests) here.
|
||||
# get from: https://github.com/openconfig/public
|
||||
OPENCONFIG=/home/olof/src/clixon/test/public
|
||||
# get from: https://github.com/YangModels/yang
|
||||
YANGMODELS=/usr/local/share/yangmodels
|
||||
IETFRFC=$YANGMODELS/standard/ietf/RFC
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@ if [ $# -gt 0 ]; then
|
|||
exit -1
|
||||
fi
|
||||
|
||||
# include err() and new() functions
|
||||
. ./lib.sh
|
||||
err=0
|
||||
testnr=0
|
||||
for test in test*.sh; do
|
||||
echo "Running $test"
|
||||
./$test
|
||||
testfile=$test
|
||||
. ./$test
|
||||
errcode=$?
|
||||
if [ $errcode -ne 0 ]; then
|
||||
err=1
|
||||
|
|
|
|||
33
test/lib.sh
33
test/lib.sh
|
|
@ -12,18 +12,34 @@
|
|||
|
||||
#set -e
|
||||
|
||||
# Probe nginx
|
||||
#sudo systemctl status nginx.service > /dev/null
|
||||
#if [ $? -ne 0 ]; then
|
||||
# sudo systemctl start nginx.service
|
||||
#fi
|
||||
# Testfile (not including path)
|
||||
: ${testfile:=$(basename $0)}
|
||||
|
||||
# Add test to this list that you dont want run
|
||||
# Typically add them in your site file
|
||||
: ${SKIPLIST:=""}
|
||||
|
||||
>&2 echo "Running $testfile"
|
||||
|
||||
# Site file, an example of this file in README.md
|
||||
if [ -x ./site.sh ]; then
|
||||
|
||||
. ./site.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
return -1 # skip
|
||||
fi
|
||||
# test skiplist.
|
||||
for f in $SKIPLIST; do
|
||||
if [ "$testfile" = "$f" ]; then
|
||||
return -1 # skip
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
testnr=0
|
||||
# Running test number
|
||||
: ${testnr:=0}
|
||||
|
||||
# Single test. Set by "new"
|
||||
testname=
|
||||
|
||||
# If set to 0, override starting of clixon_backend in test (you bring your own)
|
||||
|
|
@ -36,11 +52,6 @@ testname=
|
|||
# eg logging to a file: RCLOG="-l f/www-data/restconf.log"
|
||||
: ${RCLOG:=}
|
||||
|
||||
# If reset, do NOT run tests with external yang models.
|
||||
# This involves downloading
|
||||
# https://github.com/openconfig/public and https://github.com/YangModels/yang
|
||||
: ${MODELS:=1}
|
||||
|
||||
# Parse yangmodels from https://github.com/YangModels/yang
|
||||
# Recommended: checkout yangmodels elsewhere in the tree and set the env
|
||||
# to that
|
||||
|
|
|
|||
10
test/sum.sh
10
test/sum.sh
|
|
@ -7,16 +7,14 @@ if [ $# -gt 0 ]; then
|
|||
exit -1
|
||||
fi
|
||||
|
||||
# include err() and new() functions
|
||||
. ./lib.sh
|
||||
err=0
|
||||
for test in test*.sh; do
|
||||
echo "Running $test"
|
||||
./$test > /dev/null 2>&1
|
||||
for testfile in test*.sh; do # For lib.sh the variable must be called testfile
|
||||
echo "Running $testfile"
|
||||
./$testfile > /dev/null 2>&1
|
||||
errcode=$?
|
||||
if [ $errcode -ne 0 ]; then
|
||||
err=1
|
||||
echo -e "\e[31mError in $test errcode=$errcode"
|
||||
echo -e "\e[31mError in $testfile errcode=$errcode"
|
||||
echo -ne "\e[0m"
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
# Use-case: The ietf-netconf edit-config has a shorthand version of choice w mandatory:
|
||||
# container { choice target { mandatory; leaf candidate; leaf running; }}
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/choice.xml
|
||||
fyang=$dir/type.yang
|
||||
|
|
@ -95,7 +96,7 @@ if [ $BE -ne 0 ]; then
|
|||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
pkill clixon_backend # to be sure
|
||||
sudo pkill clixon_backend # to be sure
|
||||
|
||||
new "start backend -s init -f $cfg -y $fyang"
|
||||
sudo $clixon_backend -s init -f $cfg -y $fyang
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Test1: backend and cli basic functionality
|
||||
# Start backend server
|
||||
# Add an ethernet interface and an address
|
||||
|
|
@ -8,9 +7,13 @@
|
|||
# Set the mandatory type
|
||||
# Commit
|
||||
|
||||
# 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
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
# 1) Load <3.9 startup/running/extra files without namespaces - ensure it returns namespaces
|
||||
#
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_startup.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
@ -29,7 +31,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
||||
<CLICON_XML_SORT>true</CLICON_XML_SORT>
|
||||
</config>
|
||||
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
#!/bin/bash
|
||||
# Test5: datastore tests.
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# datastore tests.
|
||||
# Just run a binary direct to datastore. No clixon.
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
fyang=$dir/ietf-ip.yang
|
||||
|
||||
datastore=../datastore/datastore_client
|
||||
# If set, enable debugging (of backend)
|
||||
: ${clixon_util_datastore:=clixon_util_datastore}
|
||||
: ${clixon_datastore_lib:=/usr/local/lib/xmldb/text.so}
|
||||
|
||||
cat <<EOF > $fyang
|
||||
module ietf-ip{
|
||||
|
|
@ -46,126 +49,124 @@ module ietf-ip{
|
|||
}
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
xml='<config><x xmlns="urn:example:clixon"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x></config>'
|
||||
|
||||
run(){
|
||||
name=$1
|
||||
mydir=$dir/$name
|
||||
|
||||
if [ ! -d $mydir ]; then
|
||||
mkdir $mydir
|
||||
fi
|
||||
rm -rf $mydir/*
|
||||
name=text
|
||||
|
||||
conf="-d candidate -b $mydir -p ../datastore/$name/$name.so -y $dir/ietf-ip.yang"
|
||||
|
||||
new "datastore $name init"
|
||||
expectfn "$datastore $conf init" 0 ""
|
||||
|
||||
new "datastore $name put all replace"
|
||||
ret=$($datastore $conf put replace "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
mydir=$dir/$name
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^$xml$"
|
||||
if [ ! -d $mydir ]; then
|
||||
mkdir $mydir
|
||||
fi
|
||||
rm -rf $mydir/*
|
||||
|
||||
new "datastore $name put all remove"
|
||||
expectfn "$datastore $conf put remove <config/>" 0 ""
|
||||
# XXX static link
|
||||
conf="-d candidate -b $mydir -p $clixon_datastore_lib -y $dir/ietf-ip.yang"
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^<config/>$"
|
||||
new "datastore init"
|
||||
expectfn "$clixon_util_datastore $conf init" 0 ""
|
||||
|
||||
new "datastore $name put all merge"
|
||||
ret=$($datastore $conf put merge "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
# expectfn "$datastore $conf put merge $xml" 0 ""
|
||||
new "datastore put all replace"
|
||||
ret=$($clixon_util_datastore $conf put replace "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^$xml$"
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$"
|
||||
|
||||
new "datastore $name put all delete"
|
||||
expectfn "$datastore $conf put remove <config/>" 0 ""
|
||||
new "datastore put all remove"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config/>" 0 ""
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^<config/>$"
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^<config/>$"
|
||||
|
||||
new "datastore $name put all create"
|
||||
ret=$($datastore $conf put create "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
new "datastore put all merge"
|
||||
ret=$($clixon_util_datastore $conf put merge "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^$xml$"
|
||||
# expectfn "$clixon_util_datastore $conf put merge $xml" 0 ""
|
||||
|
||||
new "datastore $name put top create"
|
||||
expectfn "$datastore $conf put create <config><x/></config>" 0 "" # error
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$"
|
||||
|
||||
# Single key operations
|
||||
# leaf
|
||||
new "datastore $name put all delete"
|
||||
expectfn "$datastore $conf delete" 0 ""
|
||||
new "datastore put all delete"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config/>" 0 ""
|
||||
|
||||
new "datastore $name init"
|
||||
expectfn "$datastore $conf init" 0 ""
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^<config/>$"
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore put all create"
|
||||
ret=$($clixon_util_datastore $conf put create "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$"
|
||||
|
||||
new "datastore $name delete leaf"
|
||||
expectfn "$datastore $conf put delete <config><x><y><a>1</a><b>3</b></y></x></config>" 0 ""
|
||||
new "datastore put top create"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x/></config>" 0 "" # error
|
||||
|
||||
new "datastore $name replace leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
# Single key operations
|
||||
# leaf
|
||||
new "datastore put all delete"
|
||||
expectfn "$clixon_util_datastore $conf delete" 0 ""
|
||||
|
||||
new "datastore $name remove leaf"
|
||||
expectfn "$datastore $conf put remove <config><x><g/></x></config>" 0 ""
|
||||
new "datastore init"
|
||||
expectfn "$clixon_util_datastore $conf init" 0 ""
|
||||
|
||||
new "datastore $name remove leaf"
|
||||
expectfn "$datastore $conf put remove <config><x><y><a>1</a><b>3</b><c/></y></x></config>" 0 ""
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name delete leaf"
|
||||
expectfn "$datastore $conf put delete <config><x><g/></x></config>" 0 ""
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name merge leaf"
|
||||
expectfn "$datastore $conf put merge <config><x><g>nalle</g></x></config>" 0 ""
|
||||
new "datastore delete leaf"
|
||||
expectfn "$clixon_util_datastore $conf put delete <config><x><y><a>1</a><b>3</b></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name replace leaf"
|
||||
expectfn "$datastore $conf put replace <config><x><g>nalle</g></x></config>" 0 ""
|
||||
new "datastore replace leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name merge leaf"
|
||||
expectfn "$datastore $conf put merge <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore remove leaf"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config><x><g/></x></config>" 0 ""
|
||||
|
||||
new "datastore $name replace leaf"
|
||||
expectfn "$datastore $conf put replace <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore remove leaf"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config><x><y><a>1</a><b>3</b><c/></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><h><j>aaa</j></h></x></config>" 0 ""
|
||||
new "datastore delete leaf"
|
||||
expectfn "$clixon_util_datastore $conf put delete <config><x><g/></x></config>" 0 ""
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore merge leaf"
|
||||
expectfn "$clixon_util_datastore $conf put merge <config><x><g>nalle</g></x></config>" 0 ""
|
||||
|
||||
new "datastore other db init"
|
||||
expectfn "$datastore -d kalle -b $mydir -p ../datastore/$name/$name.so -y $dir/ietf-ip.yang init" 0 ""
|
||||
new "datastore replace leaf"
|
||||
expectfn "$clixon_util_datastore $conf put replace <config><x><g>nalle</g></x></config>" 0 ""
|
||||
|
||||
new "datastore other db copy"
|
||||
expectfn "$datastore $conf copy kalle" 0 ""
|
||||
new "datastore merge leaf"
|
||||
expectfn "$clixon_util_datastore $conf put merge <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
diff $mydir/kalle_db $mydir/candidate_db
|
||||
new "datastore replace leaf"
|
||||
expectfn "$clixon_util_datastore $conf put replace <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore lock"
|
||||
expectfn "$datastore $conf lock 756" 0 ""
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><h><j>aaa</j></h></x></config>" 0 ""
|
||||
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore other db init"
|
||||
expectfn "$clixon_util_datastore -d kalle -b $mydir -p $clixon_datastore_lib -y $dir/ietf-ip.yang init" 0 ""
|
||||
|
||||
new "datastore other db copy"
|
||||
expectfn "$clixon_util_datastore $conf copy kalle" 0 ""
|
||||
|
||||
diff $mydir/kalle_db $mydir/candidate_db
|
||||
|
||||
new "datastore lock"
|
||||
expectfn "$clixon_util_datastore $conf lock 756" 0 ""
|
||||
|
||||
#leaf-list
|
||||
|
||||
rm -rf $mydir
|
||||
}
|
||||
|
||||
run text
|
||||
rm -rf $mydir
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Yang features. if-feature. and schema resources according to RFC7895
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Identity and identityref 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/example-my-crypto.yang
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
# Install test
|
||||
# Install system test
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
new "Set up installdir $dir"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,21 +2,21 @@
|
|||
# Test: JSON parser tests
|
||||
# Note that nmbers shouldnot be quoted. See test_restconf2.sh for typed
|
||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_json"
|
||||
PROG=../util/clixon_util_json
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
: ${clixon_util_json:=clixon_util_json}
|
||||
|
||||
new "json parse to xml"
|
||||
expecteofx "$PROG" 0 '{"foo": -23}' "<foo>-23</foo>"
|
||||
expecteofx "$clixon_util_json" 0 '{"foo": -23}' "<foo>-23</foo>"
|
||||
|
||||
new "json parse to json" # should be {"foo": -23}
|
||||
expecteofx "$PROG -j" 0 '{"foo": -23}' '{"foo": "-23"}'
|
||||
expecteofx "$clixon_util_json -j" 0 '{"foo": -23}' '{"foo": "-23"}'
|
||||
|
||||
new "json parse list xml"
|
||||
expecteofx "$PROG" 0 '{"a":[0,1,2,3]}' "<a>0</a><a>1</a><a>2</a><a>3</a>"
|
||||
expecteofx "$clixon_util_json" 0 '{"a":[0,1,2,3]}' "<a>0</a><a>1</a><a>2</a><a>3</a>"
|
||||
|
||||
new "json parse list json" # should be {"a":[0,1,2,3]}
|
||||
expecteofx "$PROG -j" 0 '{"a":[0,1,2,3]}' '{"a": "0"}{"a": "1"}{"a": "2"}{"a": "3"}'
|
||||
expecteofx "$clixon_util_json -j" 0 '{"a":[0,1,2,3]}' '{"a": "0"}{"a": "1"}{"a": "2"}{"a": "3"}'
|
||||
|
||||
rm -rf $dir
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#!/bin/bash
|
||||
# Test7: Yang specifics: leafref
|
||||
# Yang leafref test
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/leafref.yang
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Yang list / leaf-list operations. min/max-elements
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@
|
|||
# See RFC 8341 A.2
|
||||
# But replaced ietf-netconf-monitoring with *
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
# See RFC 8341 A.2
|
||||
# But replaced ietf-netconf-monitoring with *
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -18,9 +18,12 @@
|
|||
# all content in the server. No subsequent rule will match for the
|
||||
# "admin" group because of this module rule
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -20,9 +20,12 @@
|
|||
# update | p/d | p/d | p/d
|
||||
# delete | p/d | p/d | p/d
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@
|
|||
# Which means that restconf -X DELETE /data translates to edit-config + commit
|
||||
# which is allowed.
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Test2: backend and netconf basic functionality
|
||||
# Basic Netconf functionality
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
tmp=$dir/tmp.x
|
||||
|
|
|
|||
|
|
@ -7,15 +7,11 @@
|
|||
# - Env-var MODELS should be 1
|
||||
# - Env-var OPENCONFIG should point to checkout place. (define it in site.sh for example)
|
||||
|
||||
# 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
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
if [ $MODELS -eq 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
||||
|
|
@ -104,7 +100,7 @@ for f in $files; do
|
|||
exit
|
||||
fi
|
||||
done
|
||||
echo "m:$ms s:$ss"
|
||||
|
||||
new "Openconfig test: $clixon_cli -1f $cfg -y $f show version ($m modules)"
|
||||
for f in $files; do
|
||||
if [ -n "$(head -1 $f|grep '^module')" ]; then
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
# The ordered-by user MUST be the order it is entered.
|
||||
# No test of ordered-by system is done yet
|
||||
# (we may want to sort them alphabetically for better performance).
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/order.yang
|
||||
tmp=$dir/tmp.x
|
||||
|
|
@ -36,7 +39,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
|
||||
<CLICON_XMLDB_DIR>$dbdir</CLICON_XMLDB_DIR>
|
||||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_XML_SORT>true</CLICON_XML_SORT>
|
||||
</config>
|
||||
EOF
|
||||
|
||||
|
|
@ -152,7 +154,7 @@ EOF
|
|||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "$(cat $tmp)" '<rpc-reply><data><state xmlns="urn:example:clixon"><op>42</op><op>41</op><op>43</op></state></data></rpc-reply>]]>]]>'
|
||||
|
||||
# Check as file
|
||||
new "verify running from start, should be: c,l,y0,y1,y2,y3; y1 and y3 sorted. Note this fails if CLICON_XML_SORT set to false"
|
||||
new "verify running from start, should be: c,l,y0,y1,y2,y3; y1 and y3 sorted."
|
||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' '^<rpc-reply><data><c xmlns="urn:example:order"><d>hej</d></c><l xmlns="urn:example:order">hopp</l><y0 xmlns="urn:example:order">d</y0><y0 xmlns="urn:example:order">b</y0><y0 xmlns="urn:example:order">c</y0><y0 xmlns="urn:example:order">a</y0><y1 xmlns="urn:example:order">a</y1><y1 xmlns="urn:example:order">b</y1><y1 xmlns="urn:example:order">c</y1><y1 xmlns="urn:example:order">d</y1><y2 xmlns="urn:example:order"><k>d</k><a>bar</a></y2><y2 xmlns="urn:example:order"><k>a</k><a>bar</a></y2><y2 xmlns="urn:example:order"><k>c</k><a>bar</a></y2><y2 xmlns="urn:example:order"><k>b</k><a>bar</a></y2><y3 xmlns="urn:example:order"><k>a</k><a>bar</a></y3><y3 xmlns="urn:example:order"><k>b</k><a>bar</a></y3><y3 xmlns="urn:example:order"><k>c</k><a>bar</a></y3><y3 xmlns="urn:example:order"><k>d</k><a>bar</a></y3><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface></interfaces></data></rpc-reply>]]>]]>$'
|
||||
|
||||
new "get each ordered-by user leaf-list"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
# Scaling test
|
||||
# Scaling/ performance tests
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
number=5000
|
||||
req=100
|
||||
|
|
@ -15,8 +18,6 @@ else
|
|||
exit 1 # Scaling
|
||||
fi
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/scaling-conf.xml
|
||||
fyang=$dir/scaling.yang
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
#!/bin/bash
|
||||
# Restconf basic functionality
|
||||
# Assume http server setup, such as nginx described in apps/restconf/README.md
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
#!/bin/bash
|
||||
# Restconf basic functionality
|
||||
# Assume http server setup, such as nginx described in apps/restconf/README.md
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
fyang=$dir/restconf.yang
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
# Use the example application that has one mandatory input arg,
|
||||
# At the end is an alternative Yang without mandatory arg for
|
||||
# valid empty input and output.
|
||||
|
||||
# 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
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
cfg=$dir/conf.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
# - An extra xml configuration file starts with an "extra" interface
|
||||
# - running db starts with a "run" interface
|
||||
# - startup db starts with a "start" interface
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_startup.xml
|
||||
|
||||
cat <<EOF > $cfg
|
||||
|
|
@ -29,7 +32,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
||||
<CLICON_XML_SORT>true</CLICON_XML_SORT>
|
||||
</config>
|
||||
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -20,16 +20,15 @@
|
|||
# 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications
|
||||
# Note the sleeps are mainly for valgrind usage
|
||||
|
||||
# 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
|
||||
UTIL=../util/clixon_util_stream
|
||||
: ${clixon_util_stream:=clixon_util_stream}
|
||||
NCWAIT=5 # Wait (netconf valgrind may need more time)
|
||||
|
||||
if [ ! -x $UTIL ]; then
|
||||
(cd ../util; make clixon_util_stream)
|
||||
fi
|
||||
DATE=$(date +"%Y-%m-%d")
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
fyang=$dir/stream.yang
|
||||
xml=$dir/xml.xml
|
||||
|
|
@ -181,7 +180,7 @@ expectwait 'curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-
|
|||
|
||||
# 2a) start subscription 8s - expect 1-2 notifications
|
||||
new "2a) start subscriptions 8s - expect 1-2 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
|
|
@ -197,7 +196,7 @@ sleep 2
|
|||
|
||||
# 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications
|
||||
new "2b) start subscriptions 8s - stoptime after 5s - expect 1-2 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8 -e +10)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8 -e +10)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -210,7 +209,7 @@ fi
|
|||
|
||||
# 2c
|
||||
new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 10 -s -8)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -8)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -223,7 +222,7 @@ fi
|
|||
|
||||
# 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications
|
||||
new "2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 10 -s -30 -e +4)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -30 -e +4)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -236,7 +235,7 @@ fi
|
|||
|
||||
# 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications
|
||||
new "2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 10 -s -90 -e +0)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -90 -e +0)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -254,7 +253,7 @@ curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "
|
|||
PID=$!
|
||||
|
||||
new "Start subscriptions in parallell"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
# Advanced union types and generated code
|
||||
# and enum w values
|
||||
# XXX NO SUPPORT FOR lists of ranges and lengths !!!
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
|
||||
. ./lib.sh
|
||||
# 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/type.yang
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#!/bin/bash
|
||||
# Advanced union types and generated code
|
||||
# and enum w values
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/type.yang
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
# Yang when and must conditional xpath specification
|
||||
# Testing of validation phase.
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
|
|
|||
|
|
@ -3,43 +3,42 @@
|
|||
# @see https://www.w3.org/TR/2008/REC-xml-20081126
|
||||
# https://www.w3.org/TR/2009/REC-xml-names-20091208
|
||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xml"
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
PROG="../util/clixon_util_xml -D $DBG"
|
||||
: ${clixon_util_xml:=clixon_util_xml}
|
||||
|
||||
new "xml parse"
|
||||
expecteof "$PROG" 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
expecteof "$clixon_util_xml" 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
|
||||
new "xml parse to json"
|
||||
expecteof "$PROG -j" 0 "<a><b/></a>" '{"a": {"b": null}}'
|
||||
expecteof "$clixon_util_xml -j" 0 "<a><b/></a>" '{"a": {"b": null}}'
|
||||
|
||||
new "xml parse strange names"
|
||||
expecteof "$PROG" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
|
||||
expecteof "$clixon_util_xml" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$PROG" 255 "<-a/>" ""
|
||||
expecteof "$clixon_util_xml" 255 "<-a/>" ""
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$PROG" 255 "<9/>" ""
|
||||
expecteof "$clixon_util_xml" 255 "<9/>" ""
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$PROG" 255 "<a%/>" ""
|
||||
expecteof "$clixon_util_xml" 255 "<a%/>" ""
|
||||
|
||||
LF='
|
||||
'
|
||||
new "xml parse content with CR LF -> LF, CR->LF (see https://www.w3.org/TR/REC-xml/#sec-line-ends)"
|
||||
ret=$(echo "<x>a
b${LF}c
${LF}d</x>" | $PROG)
|
||||
ret=$(echo "<x>a
b${LF}c
${LF}d</x>" | $clixon_util_xml)
|
||||
if [ "$ret" != "<x>a${LF}b${LF}c${LF}d</x>" ]; then
|
||||
err '<x>a$LFb$LFc</x>' "$ret"
|
||||
fi
|
||||
|
||||
new "xml simple CDATA"
|
||||
expecteofx "$PROG" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
|
||||
expecteofx "$clixon_util_xml" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
|
||||
|
||||
new "xml simple CDATA to json"
|
||||
expecteofx "$PROG -j" 0 '<a><![CDATA[a text]]></a>' '{"a": "a text"}'
|
||||
expecteofx "$clixon_util_xml -j" 0 '<a><![CDATA[a text]]></a>' '{"a": "a text"}'
|
||||
|
||||
new "xml complex CDATA"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -56,7 +55,7 @@ XML=$(cat <<EOF
|
|||
EOF
|
||||
)
|
||||
|
||||
expecteof "$PROG" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
<![CDATA[ They're saying \"x < y\" & that \"z > y\" so I guess that means that z > x ]]>
|
||||
</sometext><data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data><alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative></a>$"
|
||||
|
||||
|
|
@ -65,89 +64,89 @@ JSON=$(cat <<EOF
|
|||
EOF
|
||||
)
|
||||
new "xml complex CDATA to json"
|
||||
expecteofx "$PROG -j" 0 "$XML" "$JSON"
|
||||
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON"
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>Less than: < , greater than: > ampersand: & </message>
|
||||
EOF
|
||||
)
|
||||
new "xml encode <>&"
|
||||
expecteof "$PROG" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
|
||||
new "xml encode <>& to json"
|
||||
expecteof "$PROG -j" 0 "$XML" '{"message": "Less than: < , greater than: > ampersand: & "}'
|
||||
expecteof "$clixon_util_xml -j" 0 "$XML" '{"message": "Less than: < , greater than: > ampersand: & "}'
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>single-quote character ' represented as ' and double-quote character as "</message>
|
||||
EOF
|
||||
)
|
||||
new "xml single and double quote"
|
||||
expecteof "$PROG" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
|
||||
|
||||
JSON=$(cat <<EOF
|
||||
{"message": "single-quote character ' represented as ' and double-quote character as \""}
|
||||
EOF
|
||||
)
|
||||
new "xml single and double quotes to json"
|
||||
expecteofx "$PROG -j" 0 "$XML" "$JSON"
|
||||
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON"
|
||||
|
||||
new "xml backspace"
|
||||
expecteofx "$PROG" 0 "<a>a\b</a>" "<a>a\b</a>"
|
||||
expecteofx "$clixon_util_xml" 0 "<a>a\b</a>" "<a>a\b</a>"
|
||||
|
||||
new "xml backspace to json"
|
||||
expecteofx "$PROG -j" 0 "<a>a\b</a>" '{"a": "a\\b"}'
|
||||
expecteofx "$clixon_util_xml -j" 0 "<a>a\b</a>" '{"a": "a\\b"}'
|
||||
|
||||
new "Double quotes for attributes"
|
||||
expecteof "$PROG" 0 '<x a="t"/>' '<x a="t"/>'
|
||||
expecteof "$clixon_util_xml" 0 '<x a="t"/>' '<x a="t"/>'
|
||||
|
||||
new "Single quotes for attributes (returns double quotes but at least parses right)"
|
||||
expecteof "$PROG" 0 "<x a='t'/>" '<x a="t"/>'
|
||||
expecteof "$clixon_util_xml" 0 "<x a='t'/>" '<x a="t"/>'
|
||||
|
||||
new "Mixed quotes"
|
||||
expecteof "$PROG" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
|
||||
expecteof "$clixon_util_xml" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
|
||||
|
||||
new "XMLdecl version"
|
||||
expecteof "$PROG" 0 '<?xml version="1.0"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0"?><a/>' '<a/>'
|
||||
|
||||
new "XMLdecl version, single quotes"
|
||||
expecteof "$PROG" 0 "<?xml version='1.0'?><a/>" '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 "<?xml version='1.0'?><a/>" '<a/>'
|
||||
|
||||
new "XMLdecl version no element"
|
||||
expecteof "$PROG" 255 '<?xml version="1.0"?>' ''
|
||||
expecteof "$clixon_util_xml" 255 '<?xml version="1.0"?>' ''
|
||||
|
||||
new "XMLdecl no version"
|
||||
expecteof "$PROG" 255 '<?xml ?><a/>' ''
|
||||
expecteof "$clixon_util_xml" 255 '<?xml ?><a/>' ''
|
||||
|
||||
new "XMLdecl misspelled version"
|
||||
expecteof "$PROG -l o" 255 '<?xml verion="1.0"?><a/>' ''
|
||||
expecteof "$clixon_util_xml -l o" 255 '<?xml verion="1.0"?><a/>' ''
|
||||
|
||||
new "XMLdecl version + encoding"
|
||||
expecteof "$PROG" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
|
||||
|
||||
new "XMLdecl version + misspelled encoding"
|
||||
expecteof "$PROG -l o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
|
||||
expecteof "$clixon_util_xml -l o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
|
||||
|
||||
new "XMLdecl version + standalone"
|
||||
expecteof "$PROG" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
|
||||
|
||||
new "PI - Processing instruction empty"
|
||||
expecteof "$PROG" 0 '<?foo ?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?foo ?><a/>' '<a/>'
|
||||
|
||||
new "PI some content"
|
||||
expecteof "$PROG" 0 '<?foo something else ?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?foo something else ?><a/>' '<a/>'
|
||||
|
||||
new "prolog element misc*"
|
||||
expecteof "$PROG" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
|
||||
|
||||
# We allow it as an internal necessity for parsing of xml fragments
|
||||
#new "double element error"
|
||||
#expecteof "$PROG" 255 '<a/><b/>' ''
|
||||
#expecteof "$clixon_util_xml" 255 '<a/><b/>' ''
|
||||
|
||||
new "namespace: DefaultAttName"
|
||||
expecteof "$PROG" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
|
||||
expecteof "$clixon_util_xml" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
|
||||
|
||||
new "namespace: PrefixedAttName"
|
||||
expecteof "$PROG" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
|
||||
expecteof "$clixon_util_xml" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
|
||||
|
||||
new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -161,7 +160,7 @@ XML=$(cat <<EOF
|
|||
</html:html>
|
||||
EOF
|
||||
)
|
||||
expecteof "$PROG" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
|
||||
new "Second example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -174,7 +173,7 @@ XML=$(cat <<EOF
|
|||
</bk:book>
|
||||
EOF
|
||||
)
|
||||
expecteof "$PROG" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash
|
||||
# Test: XPATH tests
|
||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xpath"
|
||||
PROG=../util/clixon_util_xpath
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
: ${clixon_util_xpath:=clixon_util_xpath}
|
||||
|
||||
# XML file (alt provide it in stdin after xpath)
|
||||
xml=$dir/xml.xml
|
||||
|
|
@ -76,117 +77,117 @@ cat <<EOF > $xml3
|
|||
EOF
|
||||
|
||||
new "xpath /"
|
||||
expecteof "$PROG -f $xml -p /" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p /" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
|
||||
new "xpath /aaa"
|
||||
expecteof "$PROG -f $xml -p /aaa" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p /aaa" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
|
||||
new "xpath /bbb"
|
||||
expecteof "$PROG -f $xml -p /bbb" 0 "" "^nodeset:$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p /bbb" 0 "" "^nodeset:$"
|
||||
|
||||
new "xpath /aaa/bbb"
|
||||
expecteof "$PROG -f $xml -p /aaa/bbb" 0 "" "^0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
expecteof "$clixon_util_xpath -f $xml -p /aaa/bbb" 0 "" "^0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||
|
||||
new "xpath //bbb"
|
||||
expecteof "$PROG -f $xml -p //bbb" 0 "" "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
expecteof "$clixon_util_xpath -f $xml -p //bbb" 0 "" "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>"
|
||||
|
||||
new "xpath //b?b"
|
||||
#expecteof "$PROG -f $xml" 0 "//b?b" ""
|
||||
#expecteof "$clixon_util_xpath -f $xml" 0 "//b?b" ""
|
||||
|
||||
new "xpath //b*"
|
||||
#expecteof "$PROG -f $xml" 0 "//b*" ""
|
||||
#expecteof "$clixon_util_xpath -f $xml" 0 "//b*" ""
|
||||
|
||||
new "xpath //b*/ccc"
|
||||
#expecteof "$PROG -f $xml" 0 "//b*/ccc" ""
|
||||
#expecteof "$clixon_util_xpath -f $xml" 0 "//b*/ccc" ""
|
||||
|
||||
new "xpath //bbb[0]"
|
||||
expecteof "$PROG -f $xml -p //bbb[0]" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>42</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p //bbb[0]" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>42</ccc></bbb>$"
|
||||
|
||||
new "xpath //bbb[ccc=99]"
|
||||
expecteof "$PROG -f $xml -p //bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p //bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||
|
||||
new "xpath ../connection-type = 'responder-only'"
|
||||
expecteof "$PROG -f $xml2 -p ../connection-type='responder-only' -i /aaa/bbb/here" 0 "" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -p ../connection-type='responder-only' -i /aaa/bbb/here" 0 "" "^bool:true$"
|
||||
|
||||
new "xpath ../connection-type = 'no-responder'"
|
||||
expecteof "$PROG -f $xml2 -p ../connection-type='no-responder' -i /aaa/bbb/here" 0 "" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -p ../connection-type='no-responder' -i /aaa/bbb/here" 0 "" "^bool:false$"
|
||||
|
||||
new "xpath . <= 0.75 * ../max-rtr-adv-interval"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 ". <= 0.75 * ../max-rtr-adv-interval" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 ". <= 0.75 * ../max-rtr-adv-interval" "^bool:true$"
|
||||
|
||||
new "xpath . > 0.75 * ../max-rtr-adv-interval"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 ". > 0.75 * ../max-rtr-adv-interval" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 ". > 0.75 * ../max-rtr-adv-interval" "^bool:false$"
|
||||
|
||||
new "xpath . <= ../valid-lifetime"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 ". <= ../valid-lifetime" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 ". <= ../valid-lifetime" "^bool:true$"
|
||||
|
||||
new "xpath ../../rt:address-family = 'v6ur:ipv6-unicast'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 "../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 "../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
|
||||
new "xpath ../../../rt:address-family = 'v6ur:ipv6-unicast'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here2/here" 0 "../../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here2/here" 0 "../../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
|
||||
new "xpath /if:interfaces/if:interface[if:name=current()/rt:name]/ip:ipv6/ip:enabled='true'"
|
||||
expecteof "$PROG -f $xml2" 0 "/if:interfaces/if:interface[if:name=current()/rt:name]/ip:ipv6/ip:enabled='true'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2" 0 "/if:interfaces/if:interface[if:name=current()/rt:name]/ip:ipv6/ip:enabled='true'" "^bool:true$"
|
||||
|
||||
new "xpath rt:address-family='v6ur:ipv6-unicast'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa" 0 "rt:address-family='v6ur:ipv6-unicast'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa" 0 "rt:address-family='v6ur:ipv6-unicast'" "^bool:true$"
|
||||
|
||||
new "xpath ../type='rt:static'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 "../type='rt:static'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 "../type='rt:static'" "^bool:true$"
|
||||
|
||||
new "xpath rib-name != ../../name"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "rib-name != ../../name" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "rib-name != ../../name" "^bool:true$"
|
||||
|
||||
new "xpath routing/ribs/rib[name=current()/rib-name]/address-family=../../address-family"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "routing/ribs/rib[name=current()/rib-name]/address-family=../../address-family" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "routing/ribs/rib[name=current()/rib-name]/address-family=../../address-family" "^bool:true$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" or ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" or ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" or ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1400" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1400" "^bool:true$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" or ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1400" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1400" "^bool:false$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" and ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1500" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1500" "^bool:true$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" and ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1500" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1500" "^bool:false$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" and ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" and ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
|
||||
new "xpath ifType != \"atm\" or (ifMTU <= 17966 and ifMTU >= 64)"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"atm\" or (ifMTU <= 17966 and ifMTU >= 64)" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"atm\" or (ifMTU <= 17966 and ifMTU >= 64)" "^bool:true$"
|
||||
|
||||
new "xpath .[name='bar']"
|
||||
expecteof "$PROG -f $xml2 -p .[name='bar'] -i /aaa/bbb/routing/ribs/rib" 0 "" "^nodeset:0:<rib><name>bar</name><address-family>myfamily</address-family></rib>$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -p .[name='bar'] -i /aaa/bbb/routing/ribs/rib" 0 "" "^nodeset:0:<rib><name>bar</name><address-family>myfamily</address-family></rib>$"
|
||||
|
||||
new "Multiple entries"
|
||||
new "xpath bbb[ccc='foo']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='foo']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>1:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='foo']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>1:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc='42']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='42']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='42']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc=99] (number w/o quotes)"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc='bar']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='bar']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='bar']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc='fie']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='fie']" 0 "" "^nodeset:$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='fie']" 0 "" "^nodeset:$"
|
||||
|
||||
rm -rf $dir
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Yang specifics: multi-keys and empty type
|
||||
# Yang test: multi-keys and empty type
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/$APPNAME.yang
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
# as well as revisions
|
||||
# Test is made by having different config files and then try to set configure
|
||||
# options available in specific modules
|
||||
|
||||
# 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
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang1=$dir/$APPNAME@2018-12-02.yang
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
APPNAME=example
|
||||
# test two modules example1 and example2 with overlapping statements x.
|
||||
# Test two modules example1 and example2 with overlapping statements x.
|
||||
# x is leaf in example1 and list on example2.
|
||||
# Test netconf and restconf
|
||||
# BTW, this is not supported in generated CLI
|
||||
|
||||
. ./lib.sh
|
||||
# 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
|
||||
fyang1=$dir/example1.yang
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Parse yangmodels from https://github.com/YangModels/yang
|
||||
# Notes:
|
||||
# - Env-var MODELS should be 1
|
||||
# - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example)
|
||||
# - Only cisco/nx/9.2-2 # Many other versions
|
||||
# - Only cisco/xe/1631 # Many other versions
|
||||
|
|
@ -17,16 +16,12 @@
|
|||
#./vendor/cisco/xe/check.sh
|
||||
#./vendor/cisco/nx/check.sh
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# Yang specifics: multi-keys and empty type
|
||||
APPNAME=example
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
if [ $MODELS -eq 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue