Very large commit for upcoming 4.4 release

Major New features

* New and updated search functions using xpath, api-path and instance-id
  * New search functions using api-path and instance_id:
    * C search functions: `clixon_find_instance_id()` and `clixon_find_api_path()`
  * Binary search optimization in lists for indexed leafs in all three formats.
    * This improves search performance to O(logN) which is drastical improvements for large lists.
  * You can also register explicit indexes for making binary search (not only list keys)
  * For more info, see docs at [paths](https://clixon-docs.readthedocs.io/en/latest/paths.html) and
[search](https://clixon-docs.readthedocs.io/en/latest/xml.html#searching-in-xml)

API changes on existing features (you may need to change your code)
* On failed validation of leafrefs, error message changed from: `No such leaf` to `No leaf <name> matching path <path>`.
* CLI Error message (clicon_rpc_generate_error()) changed when backend returns netconf error to be more descriptive:
  * Original: `Config error: Validate failed. Edit and try again or discard changes: Invalid argument`
  * New (example): `Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes"

Minor changes

* Test framework
  * Added `-- -S <file>` command-line to main example to be able to return any state to main example.
  * Added `test/cicd` test scripts for running on a set of other hosts
* C-code restructuring
  * clixon_yang.c partitioned and moved code into clixon_yang_parse_lib.c and clixon_yang_module.c and move back some code from clixon_yang_type.c.
    * partly to reduce size, but most important to limit code that accesses internal yang structures, only clixon_yang.c does this now.
This commit is contained in:
Olof hagsand 2020-02-02 15:52:30 +01:00
parent e8ae628d06
commit 19e21be0bc
132 changed files with 6241 additions and 2332 deletions

View file

@ -1,7 +1,7 @@
#
# ***** BEGIN LICENSE BLOCK *****
#
# Copyright (C) 2009-2019 Olof Hagsand and Benny Holmgren
# Copyright (C) 2009-2020 Olof Hagsand
#
# This file is part of CLIXON
#
@ -33,12 +33,6 @@
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
CC = @CC@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
SHELL = /bin/sh
.PHONY: all clean distclean depend install uninstall

View file

@ -17,6 +17,8 @@ In the CI process, the system is built and configured and then the
[clixon test container](../docker/system) is built and the tests in
this directory is executed.
There are also [manual cicd scripts here](cicd/README.md)
## Getting started
You need to build and install the clixon utility programs before running the tests as some of the tests rely on them:

74
test/cicd/Makefile.in Normal file
View file

@ -0,0 +1,74 @@
#
# ***** BEGIN LICENSE BLOCK *****
#
# Copyright (C) 2009-2020 Olof Hagsand
1#
# This file is part of CLIXON
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Alternatively, the contents of this file may be used under the terms of
# the GNU General Public License Version 3 or later (the "GPL"),
# in which case the provisions of the GPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of the GPL, and not to allow others to
# use your version of this file under the terms of Apache License version 2,
# indicate your decision by deleting the provisions above and replace them with
# the notice and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the Apache License version 2 or the GPL.
#
# ***** END LICENSE BLOCK *****
#
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
SHELL = /bin/sh
.PHONY: all clean distclean depend install uninstall
HOSTS = vandal.hagsand.com # i86_32 ubuntu
HOSTS += clixon.dogwood.com # FreeBSD x86_64
#HOSTS += nuc1.hagsand.com # x86_64 ubuntu
#HOSTS += pi2.hagsand.com # arm Raspian
SCRIPTS = cligen-mk.sh
SCRIPTS += clixon-mk.sh
SCRIPTS += clixon-config.sh
.PHONY: all clean distclean depend install uninstall $(HOSTS)
all: $(HOSTS)
$(HOSTS):
for s in $(SCRIPTS); do \
(scp $$s $@:/tmp/ ; ssh $@ chmod 750 /tmp/$$s || exit 1) \
done;
./cicd.sh $@ 2>&1 | tee $@.log
clean:
rm -f *.log
distclean: clean
rm -f Makefile *~ .depend
depend:
install-include:
install:
uninstall:

14
test/cicd/README.md Normal file
View file

@ -0,0 +1,14 @@
CICD scripts
============
Manual scripts for running committed code on a set of hosts.
The script then uses a Makefile and logs in to each host, pulls from
git, configure, makes and runs through the tests. Make is used to get
concurrency - non-trivial with bash, eg with `make -j 10`
Note there are other cicd scripts than this, such as the the "travis" scrips.
The Makefile contains a configurable HOSTS variable, please edit.
Logs appear in : <hostname>.log.

39
test/cicd/cicd.sh Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# CI/CD script complementing trevor github
# Login in to a number of hosts and fo the following:
# 0. Create and transfer sub-scripts used in main script: cligen-mk.sh clixon-mk.sh clixon-config.sh
# 1. pull latest version
# 2. Run configure
# 3. Compile and install (assume mk.sh)
# 4. Run tests
# Assume:
# - subscripts SCRIPTS exists locally where this script is executed
# - A test/site.sh file is handmade on each host
# - some commands are passwordless using
# sudo visudo -f /etc/sudoers.d/clixonci
# <user> ALL = (root)NOPASSWD : ALL
# <user> ALL = (www-data)NOPASSWD : ALL
# <user> ALL = (clicon)NOPASSWD : /usr/local/sbin/clixon_backend
# Experiment in identifying all commands: /usr/bin/make,/usr/local/sbin/clixon_backend,/usr/bin/pkill,/usr/local/bin/clixon_util_socket,/usr/bin/tee,/bin/rm,/usr/bin/touch,/bin/chmod
#
# Typical run: ./cicd.sh 2>&1 | tee cilog
set -eux # x
if [ $# -ne 1 ]; then
echo "usage: $0 <host>"
exit -1
fi
h=$1
ssh -t $h "test -d src/cligen || (cd src;git clone https://github.com/olofhagsand/cligen.git)"
ssh -t $h "(cd src/cligen;git pull)"
ssh -t $h "(cd src/cligen;./configure)"
ssh -t $h "(cd src/cligen; /tmp/cligen-mk.sh)"
ssh -t $h "test -d src/clixon || (cd src;git clone https://github.com/clicon/clixon.git)"
ssh -t $h "(cd src/clixon;git pull)"
ssh -t $h "(cd src/clixon; /tmp/clixon-config.sh)"
ssh -t $h "(cd src/clixon; /tmp/clixon-mk.sh)"
ssh -t $h sudo ldconfig
ssh -t $h "(cd src/clixon/test; ./sum.sh)"

11
test/cicd/cligen-mk.sh Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
# A top-level maker for cligen
set -eux
if [ $(uname) = "FreeBSD" ]; then
MAKE=$(which gmake)
else
MAKE=$(which make)
fi
$MAKE clean
$MAKE -j10
sudo $MAKE install

View file

@ -0,0 +1,8 @@
#!/bin/sh
# A top-level configurer for clixon
set -eux
if [ $(uname) = "FreeBSD" ]; then
./configure --with-cligen=/usr/local --with-wwwuser=www --enable-optyangs
else
./configure --enable-optyangs
fi

16
test/cicd/clixon-mk.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# A top-level maker for clixon
set -eux
if [ $(uname) = "FreeBSD" ]; then
MAKE=$(which gmake)
else
MAKE=$(which make)
fi
$MAKE clean
$MAKE -j10
sudo $MAKE install
sudo $MAKE install-include
(cd example; $MAKE)
(cd util; $MAKE)
(cd example; sudo $MAKE install)
(cd util; sudo $MAKE install)

View file

@ -339,7 +339,7 @@ expecteq(){
# Evaluate and return
# like expecteq but partial match is OK
# Example: expecteq $(fn arg) 0 "my return"
# Example: expectpart $(fn arg) 0 "my return"
# - evaluated expression
# - expected command return value (0 if OK)
# - expected stdout outcome*
@ -364,15 +364,15 @@ expectpart(){
let i=0;
for exp in "$@"; do
if [ $i -gt 1 ]; then
# echo "exp:$exp"
match=`echo $ret | grep --null -o "$exp"` # XXX -EZo: -E cant handle {}
if [ -z "$match" ]; then
err "$exp" "$ret"
fi
fi
let i++;
done
# echo "echo \"$ret\" | grep --null -o \"$exp"\"
match=$(echo "$ret" | grep --null -o "$exp") # XXX -EZo: -E cant handle {}
r=$?
if [ $r != 0 ]; then
err "$exp" "$ret"
fi
fi
let i++;
done
# if [[ "$ret" != "$expect" ]]; then
# err "$expect" "$ret"
# fi

View file

@ -98,9 +98,9 @@ done
# Then actual run
testnr=0
for cmd in $cmds; do
for cmd1 in $cmds; do
if [ $testnr != 0 ]; then echo; fi
println "Mem test $cmd begin"
memonce $cmd
println "Mem test $cmd done"
println "Mem test $cmd1 begin"
memonce $cmd1
println "Mem test $cmd1 done"
done

265
test/test_api.sh Executable file
View file

@ -0,0 +1,265 @@
#!/bin/bash
# Advanced API XML test. Compile a backend plugin and start the backend, and then send an RPC to
# trigger that plugin
# The plugin looks in an XML tree using three different methods:
# 1. xml_each and xml_find
# 2. xpath_first
# 3. binary_search
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Which format to use as datastore format internally
: ${format:=xml}
APPNAME=example
cfg=$dir/conf_yang.xml
fyang=$dir/example-api.yang
cfile=$dir/example-api.c
pdir=$dir/plugin
sofile=$pdir/example-api.so
if [ ! -d $pdir ]; then
mkdir $pdir
fi
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>/tmp/conf_yang.xml</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_BACKEND_DIR>$pdir</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>
</clixon-config>
EOF
cat <<EOF > $fyang
module example-api{
yang-version 1.1;
namespace "urn:example:api";
prefix ex;
container c {
leaf-list y0 {
ordered-by user;
type string;
}
leaf-list y1 {
ordered-by system;
type string;
}
list y2 {
ordered-by user;
key "k";
leaf k {
type int32;
}
leaf val {
type string;
}
}
list y3 {
ordered-by system;
key "k";
leaf k {
type int32;
}
leaf val {
type string;
}
}
}
rpc trigger {
description "trigger an action in the backend";
}
}
EOF
cat<<EOF > $cfile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/syslog.h>
/* clicon */
#include <cligen/cligen.h>
/* Clicon library functions. */
#include <clixon/clixon.h>
/* These include signatures for plugin and transaction callbacks. */
#include <clixon/clixon_backend.h>
static int
trigger_rpc(clicon_handle h, /* Clicon handle */
cxobj *xe, /* Request: <rpc><xn></rpc> */
cbuf *cbret, /* Reply eg <rpc-reply>... */
void *arg, /* client_entry */
void *regarg) /* Argument given at register */
{
int retval = -1;
cxobj *xret = NULL;
cxobj *xc = NULL;
cxobj *x = NULL;
char *k;
char *val;
cvec *cvk = NULL;
cg_var *cv;
cxobj **xvec = NULL;
size_t xlen = 0;
if (xmldb_get(h, "running", NULL, "/c", &xret) < 0)
goto done;
clicon_debug(1, "%s xret:%s", __FUNCTION__, xml_name(xret));
xc = xpath_first(xret, NULL, "/c");
clicon_debug(1, "%s xc:%s", __FUNCTION__, xml_name(xc));
/* Method 1 loop */
x = NULL;
val = NULL;
while ((x = xml_child_each(xc, x, -1)) != NULL) {
if (strcmp(xml_name(x), "y3") != 0)
continue;
if ((k = xml_find_body(x, "k")) != NULL &&
strcmp(k, "5") == 0){
val = xml_find_body(x, "val");
break;
}
}
clicon_debug(1, "%s Method 1: val:%s", __FUNCTION__, val?val:"null");
/* Method 2 xpath */
val = NULL;
if ((x = xpath_first(xc, NULL, "y3[k=5]")) != NULL)
val = xml_find_body(x, "val");
clicon_debug(1, "%s Method 2: val:%s", __FUNCTION__, val?val:"null");
/* Method 3 binsearch */
val = NULL;
/* Add key/value vector */
if ((cvk = cvec_new(0)) == NULL){
clicon_err(OE_YANG, errno, "cvec_new");
goto done;
}
if ((cv = cvec_add(cvk, CGV_STRING)) == NULL)
goto done;
cv_name_set(cv, "k");
cv_string_set(cv, "5");
/* Use form 2c use spec of xc + name */
if (clixon_xml_find_index(xc, NULL, NULL, "y3", cvk, &xvec, &xlen) < 0)
goto done;
if (xlen)
val = xml_find_body(xvec[0], "val");
else
val = NULL;
clicon_debug(1, "%s Method 3: val:%s", __FUNCTION__, val?val:"null");
cprintf(cbret, "<rpc-reply><ok/></rpc-reply>");
retval = 0;
done:
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
if (cvk)
cvec_free(cvk);
if (xret)
xml_free(xret);
if (xvec)
free(xvec);
return retval;
}
clixon_plugin_api *clixon_plugin_init(clicon_handle h);
static clixon_plugin_api api = {
"order", /* name */ /*--- Common fields. ---*/
clixon_plugin_init, /* init */
};
/*! Backend plugin initialization
* @param[in] h Clixon handle
* @retval NULL Error with clicon_err set
* @retval api Pointer to API struct
*/
clixon_plugin_api *
clixon_plugin_init(clicon_handle h)
{
clicon_debug(1, "%s test-order", __FUNCTION__);
/* From example.yang (clicon) */
if (rpc_callback_register(h, trigger_rpc,
NULL,
"urn:example:api",
"trigger"/* Xml tag when callback is made */
) < 0)
return NULL;
return &api;
}
EOF
new "compile $cfile"
gcc -g -Wall -rdynamic -fPIC -shared $cfile -o $sofile
new "test params: -s running -f $cfg"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend"
start_backend -s running -f $cfg
fi
new "kill old restconf daemon"
sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon"
start_restconf -f $cfg
new "waiting"
wait_backend
wait_restconf
XML='<c xmlns="urn:example:api"><y3><k>2</k></y3><y3><k>3</k></y3><y3><k>5</k><val>zorro</val></y3><y3><k>7</k></y3></c>'
# Add a set of entries using restconf
new "PUT a set of entries"
expectpart "$(curl -si -X PUT -H 'Content-Type: application/yang-data+xml' http://localhost/restconf/data/example-api:c -d "$XML")" 0 "HTTP/1.1 201 Created"
new "Check entries"
expectpart "$(curl -si -X GET http://localhost/restconf/data/example-api:c -H 'Accept: application/yang-data+xml')" 0 'HTTP/1.1 200 OK' "$XML"
new "Send a trigger"
expectpart "$(curl -si -X POST http://localhost/restconf/operations/example-api:trigger -H 'Accept: application/yang-data+json')" 0 'HTTP/1.1 204 No Content'
if [ $BE -eq 0 ]; then
exit # BE
fi
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
# unset conditional parameters
unset format
rm -rf $dir

260
test/test_api_path.sh Executable file
View file

@ -0,0 +1,260 @@
#!/usr/bin/env bash
# API-PATH tests
# Most tests are: generate lists, then access
# Tests include single and double indexes.
# string and int indexes
# Lists and leaf-lists
# Augmented yang where two lists are inside each other (depth)
# Multiple matches
# 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_path:=clixon_util_path -a -D $DBG}
# Number of list/leaf-list entries
: ${nr:=100}
# XML file (alt provide it in stdin after xpath)
for (( i=1; i<7; i++ )); do
eval xml$i=$dir/xml$i.xml
done
ydir=$dir/yang
if [ ! -d $ydir ]; then
mkdir $ydir
fi
# XPATH binary search in ordered-by system lists
cat <<EOF > $ydir/moda.yang
module moda{
namespace "urn:example:a";
prefix a;
container x1{
description "list with single string key";
list y{
ordered-by system;
key k1;
leaf k1{
type string;
}
leaf z{
type string;
}
}
}
container x2{
description "list with single int key";
list y{
ordered-by system;
key k1;
leaf k1{
type uint32;
}
leaf z{
type string;
}
}
}
container x3{
description "list with double string keys";
list y{
ordered-by system;
key "k1 k2";
leaf k1{
type string;
}
leaf k2{
type string;
}
leaf z{
type string;
}
}
}
container x4{
description "leaf-list with int key";
leaf-list y{
type string;
}
}
list x5{
ordered-by system;
description "Direct under root";
key "k1";
leaf k1{
type string;
}
leaf z{
type string;
}
}
augment "/b:x6/b:yy" {
list y{
ordered-by system;
key "k1 k2";
leaf k1{
type string;
}
leaf k2{
type string;
}
leaf-list z{
type string;
}
}
}
}
EOF
# This is for augment usecase
cat <<EOF > $ydir/modb.yang
module modb{
namespace "urn:example:b";
prefix b;
container x6{
description "deep tree and augment";
list yy{
ordered-by system;
key "kk1 kk2";
leaf kk1{
type string;
}
leaf kk2{
type string;
}
leaf-list zz{
type string;
}
}
}
}
EOF
rnd=$(( ( RANDOM % $nr ) ))
# Single string key
new "generate list with $nr single string key to $xml1"
echo -n '<x1 xmlns="urn:example:a">' > $xml1
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>a$i</k1><z>foo$i</z></y>" >> $xml1
done
echo -n '</x1>' >> $xml1
new "api-path single string key k1=a$rnd"
echo "$clixon_util_path -f $xml1 -y $ydir -p /moda:x1/y=a$rnd"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:x1/y=a$rnd)" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "api-path single string key /x1"
echo "$clixon_util_path -f $xml1 -y $ydir -p /moda:x1"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:x1)" 0 "0: <x1 xmlns=\"urn:example:a\"><y><k1>a0</k1><z>foo0</z></y><y><k1>a1</k1><z>foo1</z></y>" # Assume at least two elements
new "api-path single string key omit key"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:x1/y)" 0 '^0: <y><k1>a0</k1><z>foo0</z></y>
1: <y><k1>a0</k1><z>foo0</z></y>'
new "api-path single string wrong module, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /modxxx:x1/y=a$rnd 2> /dev/null)" 255 '^$'
new "api-path single string no module, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /x1/y=a$rnd 2> /dev/null)" 255 '^$'
new "api-path single string wrong top-symbol, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:xxx/y=a$rnd 2> /dev/null)" 255 '^$'
new "api-path single string wrong list-symbol, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:x1/xxx=a$rnd 2> /dev/null)" 255 '^$'
new "api-path single string two keys, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:x1/y=a$rnd,a$rnd 2> /dev/null)" 255 '^$'
new "api-path single string sub-element, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /moda:x1/y=a$rnd/xxx 2> /dev/null)" 255 '^$'
# Single int key
new "generate list with $nr single int key to $xml2"
echo -n '<x2 xmlns="urn:example:a">' > $xml2
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>$i</k1><z>foo$i</z></y>" >> $xml2
done
echo -n '</x2>' >> $xml2
new "api-path single int key k1=$rnd"
echo "$clixon_util_path -f $xml2 -y $ydir -p /moda:x2/y=$rnd"
expectpart "$($clixon_util_path -f $xml2 -y $ydir -p /moda:x2/y=$rnd)" 0 "^0: <y><k1>$rnd</k1><z>foo$rnd</z></y>$"
# Double string key
new "generate list with $nr double string keys to $xml3 (two k2 entries per k1 key)"
echo -n '<x3 xmlns="urn:example:a">' > $xml3
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>a$i</k1><k2>a$i</k2><z>foo$i</z></y>" >> $xml3
echo -n "<y><k1>a$i</k1><k2>b$i</k2><z>foob$i</z></y>" >> $xml3
done
# Add two rules with empty k2 string
echo -n "<y><k1>a0</k1><k2></k2><z>foo0</z></y>" >> $xml3
echo -n "<y><k1>a1</k1><k2></k2><z>foo1</z></y>" >> $xml3
echo -n '</x3>' >> $xml3
new "api-path double string key k1=a$rnd,b$rnd"
echo "$clixon_util_path -f $xml3 -y $ydir -p /moda:x3/y=a$rnd,b$rnd"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /moda:x3/y=a$rnd,b$rnd)" 0 "0: <y><k1>a$rnd</k1><k2>b$rnd</k2><z>foob$rnd</z></y>"
new "api-path double string key k1=a$rnd, - empty k2 string"
echo "$clixon_util_path -f $xml3 -y $ydir -p /moda:x3/y=a1,"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /moda:x3/y=a1,)" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>"
new "api-path double string key k1=a$rnd, - no k2 string - three matches"
echo "$clixon_util_path -f $xml3 -y $ydir -p /moda:x3/y=a1"
expecteq "$($clixon_util_path -f $xml3 -y $ydir -p /moda:x3/y=a1)" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>
1: <y><k1>a1</k1><k2>a1</k2><z>foo1</z></y>
2: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>"
# Leaf-list
new "generate leaf-list int keys to $xml4"
echo -n '<x4 xmlns="urn:example:a">' > $xml4
for (( i=0; i<$nr; i++ )); do
echo -n "<y>a$i</y>" >> $xml4
done
echo -n '</x4>' >> $xml4
new "api-path leaf-list k1=a$rnd"
echo "$clixon_util_path -f $xml4 -y $ydir -p /moda:x4/y=a$rnd"
expectpart "$($clixon_util_path -f $xml4 -y $ydir -p /moda:x4/y=a$rnd)" 0 "^0: <y>a$rnd</y>$"
# Single string key direct under root
new "generate list with $nr single string key to $xml5"
echo -n '' > $xml5
for (( i=0; i<$nr; i++ )); do
echo -n "<x5 xmlns=\"urn:example:a\"><k1>a$i</k1><z>foo$i</z></x5>" >> $xml5
done
new "api-path direct under root single string key k1=a$rnd"
echo "$clixon_util_path -f $xml5 -y $ydir -p /moda:x5=a$rnd"
expectpart "$($clixon_util_path -f $xml5 -y $ydir -p /moda:x5=a$rnd)" 0 "^0: <x5 xmlns=\"urn:example:a\"><k1>a$rnd</k1><z>foo$rnd</z></x5>$"
# Depth and augment
# Deep augmented xml path
new "generate deep list with augment"
echo -n '<x6 xmlns="urn:example:b">' > $xml6
for (( i=0; i<$nr; i++ )); do
echo -n "<yy><kk1>b$i</kk1><kk2>b$i</kk2><zz>foo$i</zz>" >> $xml6
for (( j=0; j<3; j++ )); do
echo -n "<y xmlns=\"urn:example:a\"><k1>a$j</k1><k2>a$j</k2><z>foo$j</z></y>" >> $xml6
done
echo -n "</yy>" >> $xml6
done
echo -n '</x6>' >> $xml6
new "api-path double string key k1=b$rnd,b$rnd in modb"
echo "$clixon_util_path -f $xml6 -y $ydir -p /modb:x6/yy=b$rnd,b$rnd"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /modb:x6/yy=b$rnd,b$rnd)" 0 "0: <yy><kk1>b$rnd</kk1><kk2>b$rnd</kk2><zz>foo$rnd</zz><y xmlns=\"urn:example:a\"><k1>a0</k1><k2>a0</k2><z>foo0</z></y><y xmlns=\"urn:example:a\"><k1>a1</k1><k2>a1</k2><z>foo1</z></y><y xmlns=\"urn:example:a\"><k1>a2</k1><k2>a2</k2><z>foo2</z></y></yy>"
new "api-path double string key k1=a$rnd,b$rnd in modb + augmented in moda"
echo "$clixon_util_path -f $xml6 -y $ydir -p /modb:x6/yy=b$rnd,b$rnd/moda:y=a1,a1"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /modb:x6/yy=b$rnd,b$rnd/moda:y=a1,a1/z=foo1)" 0 "0: <z>foo1</z>"
# unset conditional parameters
unset nr
unset clixon_util_path
rm -rf $dir

View file

@ -36,7 +36,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -27,7 +27,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -73,7 +73,7 @@ new "cli configure using encoded chars name <&"
expectfn "$clixon_cli -1 -f $cfg set interfaces interface fddi&< type ianaift:ethernetCsmacd" 0 ""
new "cli failed validate"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Validate failed. Edit and try again or discard changes: application missing-element Mandatory variable <bad-element>type</bad-element>"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Netconf error: application missing-element Mandatory variable <bad-element>type</bad-element>. Validate failed. Edit and try again or discard changes"
new "cli configure ip addr"
expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 ipv4 address 1.2.3.4 prefix-length 24" 0 "^$"

View file

@ -27,7 +27,6 @@ cat <<EOF > $cfg
<CLICON_CLI_HIST_SIZE>10</CLICON_CLI_HIST_SIZE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF
@ -125,5 +124,5 @@ fi
# kill backend
stop_backend -f $cfg
unset nr
rm -rf $dir

View file

@ -46,7 +46,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -161,7 +161,8 @@ diff $mydir/kalle_db $mydir/candidate_db
new "datastore lock"
expectfn "$clixon_util_datastore $conf lock 756" 0 ""
#leaf-list
# unset conditional parameters
unset clixon_util_datastore
rm -rf $mydir

View file

@ -39,7 +39,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -250,15 +250,15 @@ expectfn "$clixon_cli -1 -f $cfg -l o validate" 0 "^$"
new "CLI set wrong acl-type"
expectfn "$clixon_cli -1 -f $cfg -l o set acls acl x type undefined" 0 "^$"
new "cli validate"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Identityref validation failed"
new "cli validate acl-type"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes"
# test empty identityref list
new "cli set empty"
expectfn "$clixon_cli -1 -f $cfg -l o set e undefined" 0 "^$"
new "cli validate"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Identityref validation failed"
new "cli validate empty"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"

View file

@ -211,3 +211,6 @@ new "adv list add leaf-list"
testrun "$x0" "<e>32</e>"
rm -rf $dir
# unset conditional parameters
unset clixon_util_insert

View file

@ -63,3 +63,6 @@ if [ -n "$l" ]; then
fi
rm -rf $dir
# unset conditional parameters
unset make

318
test/test_instance_id.sh Executable file
View file

@ -0,0 +1,318 @@
#!/usr/bin/env bash
# INSTANCE-ID tests
# 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_path:=clixon_util_path -D $DBG}
# Number of list/leaf-list entries
: ${nr:=100}
# XML file (alt provide it in stdin after xpath)
for (( i=1; i<9; i++ )); do
eval xml$i=$dir/xml$i.xml
done
ydir=$dir/yang
if [ ! -d $ydir ]; then
mkdir $ydir
fi
# XPATH binary search in ordered-by system lists
cat <<EOF > $ydir/moda.yang
module moda{
namespace "urn:example:a";
prefix a;
container x1{
description "list with single string key";
list y{
ordered-by system;
key k1;
leaf k1{
type string;
}
leaf z{
type string;
}
}
}
container x2{
description "list with single int key";
list y{
ordered-by system;
key k1;
leaf k1{
type uint32;
}
leaf z{
type string;
}
}
}
container x3{
description "list with double string keys";
list y{
ordered-by system;
key "k1 k2";
leaf k1{
type string;
}
leaf k2{
type string;
}
leaf z{
type string;
}
}
}
container x4{
description "leaf-list with int key";
leaf-list y{
type string;
}
}
list x5{
ordered-by system;
description "Direct under root";
key "k1";
leaf k1{
type string;
}
leaf z{
type string;
}
}
augment "/b:x6/b:yy" {
list y{
ordered-by system;
key "k1 k2";
leaf k1{
type string;
}
leaf k2{
type string;
}
leaf-list z{
type string;
}
}
}
container x7{
description "Single list, ordered by user";
list y{
ordered-by user;
key k1;
leaf k1{
type string;
}
leaf z{
type string;
}
}
}
container x8{
description "Single list state data";
config false;
list y{
key k1;
leaf k1{
type string;
}
leaf z{
type string;
}
}
}
}
EOF
# This is for augment usecase
cat <<EOF > $ydir/modb.yang
module modb{
namespace "urn:example:b";
prefix b;
container x6{
description "deep tree and augment";
list yy{
ordered-by system;
key "kk1 kk2";
leaf kk1{
type string;
}
leaf kk2{
type string;
}
leaf-list zz{
type string;
}
}
}
}
EOF
rnd=$(( ( RANDOM % $nr ) ))
# Single string key
new "generate list with $nr single string key to $xml1"
echo -n '<x1 xmlns="urn:example:a">' > $xml1
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>a$i</k1><z>foo$i</z></y>" >> $xml1
done
echo -n '</x1>' >> $xml1
new "instance-id single string key k1=a$rnd"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"]"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string key /x1"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1)" 0 "0: <x1 xmlns=\"urn:example:a\"><y><k1>a0</k1><z>foo0</z></y><y><k1>a1</k1><z>foo1</z></y>" # Assume at least two elements
new "instance-id position specific position 5"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[5]"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[5])" 0 "0: <y><k1>a13</k1><z>foo13</z>" # sort alphanumerivc wrong 1,10,2
new "instance-id single string key omit key"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y)" 0 '^0: <y><k1>a0</k1><z>foo0</z></y>
1: <y><k1>a0</k1><z>foo0</z></y>'
# Fails and error handling
new "instance-id single string search non-index"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"]"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string search non-index (two variables, index first)"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"][a:z=\"foo$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string search non-index (two variables, index last)"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"][a:k1=\"a$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string wrong module, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /xxx:x1/a:y[a:k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
new "instance-id single string no module, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /x1/a:y[a:k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
new "instance-id single string no sub-prefixes, notfound"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/y[k1=\"a$rnd\"]"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/y[k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
new "instance-id single string two keys, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=a$rnd][a:k2=a$rnd] 2> /dev/null)" 255 '^$'
# Single int key
new "generate list with $nr single int key to $xml2"
echo -n '<x2 xmlns="urn:example:a">' > $xml2
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>$i</k1><z>foo$i</z></y>" >> $xml2
done
echo -n '</x2>' >> $xml2
new "instance-id single int key k1=$rnd"
echo "$clixon_util_path -f $xml2 -y $ydir -p /a:x2/a:y[a:k1=\"$rnd\"]"
expectpart "$($clixon_util_path -f $xml2 -y $ydir -p /a:x2/a:y[a:k1=\"$rnd\"])" 0 "^0: <y><k1>$rnd</k1><z>foo$rnd</z></y>$"
# Double string key
new "generate list with $nr double string keys to $xml3 (two k2 entries per k1 key)"
echo -n '<x3 xmlns="urn:example:a">' > $xml3
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>a$i</k1><k2>a$i</k2><z>foo$i</z></y>" >> $xml3
echo -n "<y><k1>a$i</k1><k2>b$i</k2><z>foob$i</z></y>" >> $xml3
done
# Add two rules with empty k2 string
echo -n "<y><k1>a0</k1><k2></k2><z>foo0</z></y>" >> $xml3
echo -n "<y><k1>a1</k1><k2></k2><z>foo1</z></y>" >> $xml3
echo -n '</x3>' >> $xml3
new "instance-id double string key k1=a$rnd k2=b$rnd"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a$rnd\"][k2=\"b$rnd\"]"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a$rnd\"][k2=\"b$rnd\"])" 0 "0: <y><k1>a$rnd</k1><k2>b$rnd</k2><z>foob$rnd</z></y>"
new "instance-id double string key k1=a$rnd, - empty k2 string"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"][k2=\"\"]"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"][k2=\"\"])" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>"
new "instance-id double string key k1=a$rnd, - no k2 string - three matches"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"]"
expecteq "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"])" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>
1: <y><k1>a1</k1><k2>a1</k2><z>foo1</z></y>
2: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>"
new "instance-id double string specific position 5"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[5]"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[5])" 0 "0: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>" # sort alphanumerivc wrong 1,10,2
# Leaf-list
new "generate leaf-list int keys to $xml4"
echo -n '<x4 xmlns="urn:example:a">' > $xml4
for (( i=0; i<$nr; i++ )); do
echo -n "<y>a$i</y>" >> $xml4
done
echo -n '</x4>' >> $xml4
new "instance-id leaf-list k1=a$rnd"
echo "$clixon_util_path -f $xml4 -y $ydir -p /a:x4/a:y[.=\"a$rnd\"]"
expectpart "$($clixon_util_path -f $xml4 -y $ydir -p /a:x4/a:y[.=\"a$rnd\"])" 0 "^0: <y>a$rnd</y>$"
# Single string key direct under root
new "generate list with $nr single string key to $xml5"
echo -n '' > $xml5
for (( i=0; i<$nr; i++ )); do
echo -n "<x5 xmlns=\"urn:example:a\"><k1>a$i</k1><z>foo$i</z></x5>" >> $xml5
done
new "instance-id direct under root single string key k1=a$rnd"
echo ""
expectpart "$($clixon_util_path -f $xml5 -y $ydir -p /a:x5[k1=\"a$rnd\"])" 0 "^0: <x5 xmlns=\"urn:example:a\"><k1>a$rnd</k1><z>foo$rnd</z></x5>$"
# Depth and augment
# Deep augmented xml path
new "generate deep list with augment"
echo -n '<x6 xmlns="urn:example:b">' > $xml6
for (( i=0; i<$nr; i++ )); do
echo -n "<yy><kk1>b$i</kk1><kk2>b$i</kk2><zz>foo$i</zz>" >> $xml6
for (( j=0; j<3; j++ )); do
echo -n "<y xmlns=\"urn:example:a\"><k1>a$j</k1><k2>a$j</k2><z>foo$j</z></y>" >> $xml6
done
echo -n "</yy>" >> $xml6
done
echo -n '</x6>' >> $xml6
new "instance-id double string key b$rnd,b$rnd in mod b"
echo "$clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"]"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"])" 0 "0: <yy><kk1>b$rnd</kk1><kk2>b$rnd</kk2><zz>foo$rnd</zz><y xmlns=\"urn:example:a\"><k1>a0</k1><k2>a0</k2><z>foo0</z></y><y xmlns=\"urn:example:a\"><k1>a1</k1><k2>a1</k2><z>foo1</z></y><y xmlns=\"urn:example:a\"><k1>a2</k1><k2>a2</k2><z>foo2</z></y></yy>"
new "instance-id double string key a$rnd,b$rnd in modb + augmented in moda"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"]/a:y[k1=\"a1\"][k2=\"a1\"]/a:z[.=\"foo1\"])" 0 "0: <z>foo1</z>"
# Single list ordered by user
new "generate list with $nr single string key to $xml7"
echo -n '<x7 xmlns="urn:example:a">' > $xml7
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>a$i</k1><z>foo$i</z></y>" >> $xml7
done
echo -n '</x7>' >> $xml7
new "instance-id single string key k1=a$rnd ordered by user"
echo "$clixon_util_path -f $xml7 -y $ydir -p /a:x7/a:y[a:k1=\"a$rnd\"]"
expectpart "$($clixon_util_path -f $xml7 -y $ydir -p /a:x7/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
# Single list state data (non-config)
new "generate list with $nr single string key to $xml8"
echo -n '<x8 xmlns="urn:example:a">' > $xml8
for (( i=0; i<$nr; i++ )); do
echo -n "<y><k1>a$i</k1><z>foo$i</z></y>" >> $xml8
done
echo -n '</x8>' >> $xml8
new "instance-id single string key k1=a$rnd ordered by user"
expectpart "$($clixon_util_path -f $xml8 -y $ydir -p /a:x8/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
rm -rf $dir
unset nr
unset clixon_util_path # for other script reusing it

View file

@ -129,3 +129,7 @@ expecteofx "$clixon_util_json -j -y $fyang" 0 "$JSON" "$JSON"
fi
rm -rf $dir
# unset conditional parameters
unset clixon_util_json
unset clixon_util_xml

View file

@ -21,7 +21,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF
@ -141,7 +140,7 @@ new "leafref add non-existing ref"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><default-address xmlns="urn:example:clixon"><absname>eth3</absname><address>10.0.4.6</address></default-address></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "leafref validate"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>eth3</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No such leaf</error-message></rpc-error></rpc-reply>]]>]]>$'
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>eth3</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No leaf eth3 matching path /if:interfaces/if:interface/if:name</error-message></rpc-error></rpc-reply>]]>]]>$'
#new "leafref wrong ref"
#expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><default-address xmlns="urn:example:clixon"><wrong>eth3</wrong><address>10.0.4.6</address></default-address></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -171,7 +170,7 @@ new "leafref delete leaf"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><interface nc:operation="delete"><name>eth0</name></interface></interfaces></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>'
new "leafref validate (should fail)"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>eth0</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No such leaf</error-message></rpc-error></rpc-reply>]]>]]>$'
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>eth0</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No leaf eth0 matching path /if:interfaces/if:interface/if:name</error-message></rpc-error></rpc-reply>]]>]]>$'
new "leafref discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"

282
test/test_leafref_augment.sh Executable file
View file

@ -0,0 +1,282 @@
#!/usr/bin/env bash
# Yang leafref + augment + grouping taking from a more complex netgate errorcase
# A main yang spec: leafref
# and a secondary yang spec: augment
# module leafref has a primary construct (sender) and a leafref typedef
# module augment has an augment and a grouping from where it uses the leafref typedef
# Which means that you should first have xml such as:
# <sender>
# <name>x</name>
# </sender>
# and you can then track it via for example (extra levels for debugging):
# <sender>
# <name>y</name>
# <stub> # original
# <extra> # augment
# <track> # grouping
# <sender>
# <name>x</name> <----
# </sender>
# </track>
# </extra>
# </stub>
# </sender>
#
# There is also test for using prefixes or not, as well as swithcing prefix between the main module and
# it import statement.
# 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/leafref.yang
fyang2=$dir/augment.yang
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang2</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF
# NOTE prefix "example" used in module different from "ex" used in mport of that module
cat <<EOF > $fyang1
module leafref{
yang-version 1.1;
namespace "urn:example:example";
prefix example;
typedef sender-ref {
description "For testing leafref across augment and grouping";
type leafref {
path "/ex:sender/ex:name";
}
}
typedef sender-ref-local {
description "For testing leafref local";
type leafref {
path "/example:sender/example:name";
}
}
list sender{
key name;
leaf name{
type string;
}
container stub{
description "Here is where augmentation is done";
}
leaf ref{
description "top-level ref (wrong prefix)";
type sender-ref;
}
leaf ref-local{
description "top-level ref (right prefix)";
type sender-ref-local;
}
}
}
EOF
cat <<EOF > $fyang2
module augment{
yang-version 1.1;
namespace "urn:example:augment";
prefix aug;
import leafref {
description "Note different from canonical (leafref module own prefix is 'example'";
prefix "ex";
}
grouping attributes {
container track{
description "replicates original structure but only references original";
list sender{
description "reference using path in typedef";
key name;
leaf name{
type ex:sender-ref;
}
}
list senderdata{
description "reference using path inline in data (not typedef)";
key name;
leaf name{
type leafref {
path "/ex:sender/ex:name";
}
}
}
}
}
augment "/ex:sender/ex:stub" {
description "Main leafref/sender stub.";
container extra{
presence "ensuring it is there";
uses attributes;
}
}
}
EOF
new "test params: -f $cfg"
if [ $BE -ne 0 ]; then
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
new "waiting"
wait_backend
fi
# Test top-level, default prefix, wring leafref prefix and typedef path
XML=$(cat <<EOF
<sender xmlns="urn:example:example">
<name>x</name>
</sender>
<sender xmlns="urn:example:example">
<name>y</name>
<ref>x</ref>
</sender>
EOF
)
new "leafref augment+leafref config top-level"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config>$XML</config></edit-config></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "leafref augment+leafref validate top-level wrong prefix"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>x</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No leaf x matching path /ex:sender/ex:name</error-message></rpc-error></rpc-reply>]]>]]>$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Test top-level, default prefix, correct leafref and typedef path
XML=$(cat <<EOF
<sender xmlns="urn:example:example">
<name>x</name>
</sender>
<sender xmlns="urn:example:example">
<name>y</name>
<ref-local>x</ref-local>
</sender>
EOF
)
# Use augment + explicit prefixes, correct leafref and typedef path
XML=$(cat <<EOF
<sender xmlns="urn:example:example">
<name>x</name>
</sender>
<sender xmlns="urn:example:example">
<name>y</name>
<stub>
<aug:extra xmlns:aug="urn:example:augment">
<aug:track>
<aug:sender>
<aug:name>x</aug:name>
</aug:sender>
</aug:track>
</aug:extra>
</stub>
</sender>
EOF
)
new "leafref augment+leafref config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config>$XML</config></edit-config></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "leafref augment+leafref validate"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Use augment, default prefixes, wrong leafref and typedef path
XML=$(cat <<EOF
<sender xmlns="urn:example:example">
<name>x</name>
</sender>
<sender xmlns="urn:example:example">
<name>y</name>
<stub>
<extra xmlns="urn:example:augment">
<track>
<sender>
<name>xxx</name>
</sender>
</track>
</extra>
</stub>
</sender>
EOF
)
new "leafref augment+leafref config wrong ref"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config>$XML</config></edit-config></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "leafref augment+leafref validate wrong ref"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>xxx</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No leaf xxx matching path /ex:sender/ex:name</error-message></rpc-error></rpc-reply>]]>]]>$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Use augment, default prefixes, correct leafref and in-data path
XML=$(cat <<EOF
<sender xmlns="urn:example:example">
<name>x</name>
</sender>
<sender xmlns="urn:example:example">
<name>y</name>
<stub>
<extra xmlns="urn:example:augment">
<track>
<senderdata>
<name>x</name>
</senderdata>
</track>
</extra>
</stub>
</sender>
EOF
)
new "leafref augment+leafref config in-data"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config>$XML</config></edit-config></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "leafref augment+leafref validate in-data"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
if [ $BE -eq 0 ]; then
exit # BE
fi
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
rm -rf $dir

171
test/test_leafref_state.sh Executable file
View file

@ -0,0 +1,171 @@
#!/usr/bin/env bash
# Yang leafref + state tests
# The difficulty here is a "leafref" in state data that references config-data.
# Problem being that config-data from running needs to be mergedwith state data and filtered/cropped
# correctly
#
# The YANG has two parts, one config part (sender-config) and one state part (sender-state)
# The leafref in the sender-state part references a leaf in the sender-config part
# Netconf tests are made to get state, state+config, using content attribute config/nonconfig/all
# with different paths.
# Using the -sS <file> state capability of the main example, that is why CLICON_BACKEND_DIR is
# /usr/local/lib/$APPNAME/backend so that the main backend plugins is included.
# 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
fstate=$dir/state.xml
fyang=$dir/leafref.yang
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF
# NOTE prefix "example" used in module different from "ex" used in mport of that module
cat <<EOF > $fyang
module leafref{
yang-version 1.1;
namespace "urn:example:example";
prefix ex;
list sender-config{
description "Main config of senders";
key name;
leaf name{
type string;
}
}
list sender-state{
description "State referencing configured senders";
config false;
key ref;
leaf ref{
type leafref {
path "/ex:sender-config/ex:name";
}
}
}
}
EOF
cat <<EOF > $fstate
<sender-state xmlns="urn:example:example">
<ref>x</ref>
</sender-state>
EOF
new "test params: -f $cfg -- -sS $fstate"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
start_backend -s init -f $cfg -- -sS $fstate
new "waiting"
wait_backend
fi
# Test top-level, default prefix, wring leafref prefix and typedef path
XML=$(cat <<EOF
<sender-config xmlns="urn:example:example">
<name>x</name>
</sender-config>
EOF
)
new "leafref config sender x"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config>$XML</config></edit-config></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "netconf commit"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Get path=/, state vs config
new "netconf get / config+state"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="all"><filter type="xpath" select="/"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-config xmlns="urn:example:example"><name>x</name></sender-config><sender-state xmlns="urn:example:example"><ref>x</ref></sender-state></data></rpc-reply>]]>]]>$'
new "netconf get / state-only"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="nonconfig"><filter type="xpath" select="/"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-state xmlns="urn:example:example"><ref>x</ref></sender-state></data></rpc-reply>]]>]]>$'
new "netconf get / config-only"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="config"><filter type="xpath" select="/"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-config xmlns="urn:example:example"><name>x</name></sender-config></data></rpc-reply>]]>]]>$'
# Get path=/sender-state, state vs config
new "netconf get /sender-state config+state"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="all"><filter type="xpath" select="/sender-state" xmlns="urn:example:example"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-state xmlns="urn:example:example"><ref>x</ref></sender-state></data></rpc-reply>]]>]]>$'
new "netconf get /sender-state state-only"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="nonconfig"><filter type="xpath" select="/sender-state" xmlns="urn:example:example"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-state xmlns="urn:example:example"><ref>x</ref></sender-state></data></rpc-reply>]]>]]>$'
new "netconf get /sender-state config-only"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="config"><filter type="xpath" select="/sender-state" xmlns="urn:example:example"/></get></rpc>]]>]]>' '^<rpc-reply><data/></rpc-reply>]]>]]>$'
# Get path=/sender-config, state vs config
new "netconf get /sender-config config+state"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="all"><filter type="xpath" select="/sender-config" xmlns="urn:example:example"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-config xmlns="urn:example:example"><name>x</name></sender-config></data></rpc-reply>]]>]]>$'
new "netconf get /sender-config state-only"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="nonconfig"><filter type="xpath" select="/sender-config" xmlns="urn:example:example"/></get></rpc>]]>]]>' '^<rpc-reply><data/></rpc-reply>]]>]]>$'
new "netconf get /sender-config config-only"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="config"><filter type="xpath" select="/sender-config" xmlns="urn:example:example"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-config xmlns="urn:example:example"><name>x</name></sender-config></data></rpc-reply>]]>]]>$'
# delete x, add y
XML=$(cat <<EOF
<sender-config xmlns="urn:example:example" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete">
<name>x</name>
</sender-config>
<sender-config xmlns="urn:example:example">
<name>y</name>
</sender-config>
EOF
)
# Negative tests, start with remove x and and add y instead
new "leafref config delete sender x add y"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config>$XML</config></edit-config></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
new "netconf commit"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Leafref wrong
new "netconf get / config+state should fail"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="all"><filter type="xpath" select="/"/></get></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-info><bad-element>x</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No leaf x matching path /ex:sender-config/ex:name Internal error, state callback returned invalid XML</error-message></rpc-error></rpc-reply>]]>]]>$'
new "netconf get / state-only should fail"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="nonconfig"><filter type="xpath" select="/"/></get></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-info><bad-element>x</bad-element></error-info><error-severity>error</error-severity><error-message>Leafref validation failed: No leaf x matching path /ex:sender-config/ex:name Internal error, state callback returned invalid XML</error-message></rpc-error></rpc-reply>]]>]]>$'
new "netconf get / config-only ok"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get content="config"><filter type="xpath" select="/"/></get></rpc>]]>]]>' '^<rpc-reply><data><sender-config xmlns="urn:example:example"><name>y</name></sender-config></data></rpc-reply>]]>]]>$'
if [ $BE -eq 0 ]; then
exit # BE
fi
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
rm -rf $dir

View file

@ -20,7 +20,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -28,7 +28,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>

View file

@ -227,3 +227,6 @@ new "Credentials: mode=except, fam=UNIX user=admin sudo"
testrun except $USER IPv4 127.0.0.1 "$ERROR" ""
rm -rf $dir
# unset conditional parameters
unset clixon_util_socket

View file

@ -27,7 +27,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
@ -197,3 +196,6 @@ new "nacm enabled, exec default permit, write permit (expect fail)"
testrun true deny permit permit 2 0 2
rm -rf $dir
# unset conditional parameters
unset format

View file

@ -31,7 +31,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_NACM_MODE>external</CLICON_NACM_MODE>

View file

@ -42,7 +42,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>

View file

@ -48,7 +48,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>

View file

@ -28,7 +28,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -70,7 +70,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -403,3 +403,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
# unset conditional parameters
unset format

View file

@ -37,7 +37,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>
@ -753,3 +752,6 @@ if [ $BE -ne 0 ]; then
fi
rm -rf $dir
# unset conditional parameters
unset regex

View file

@ -60,8 +60,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>example</CLICON_CLI_MODE>
<CLICON_CLI_DIR>/usr/local/lib/example/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
</clixon-config>
@ -246,5 +244,9 @@ fi
# kill backend
stop_backend -f $cfg
rm -rf $dir
# unset conditional parameters
unset format
unset perfnr
unset perfreg

View file

@ -48,8 +48,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>example</CLICON_CLI_MODE>
<CLICON_CLI_DIR>/usr/local/lib/example/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
</clixon-config>
@ -119,3 +117,6 @@ for mode in startup running; do
done
rm -rf $dir
# unset conditional parameters
unset perfnr

View file

@ -38,8 +38,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>example</CLICON_CLI_MODE>
<CLICON_CLI_DIR>/usr/local/lib/example/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
</clixon-config>
@ -154,5 +152,11 @@ fi
# kill backend
stop_backend -f $cfg
rm -rf $dir
# unset conditional parameters
unset format
unset perfnr
unset perfreg

View file

@ -26,3 +26,7 @@ expecteof_file "time $clixon_util_xml" 0 "$fxml"
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
unset perfnr

View file

@ -27,7 +27,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -27,7 +27,6 @@ cat <<EOF > $cfg
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -91,3 +91,6 @@ testrun IPv4 127.0.0.1
#testrun IPv6 ::1 7878
rm -rf $dir
# unset conditional parameters
unset clixon_util_socket

View file

@ -189,3 +189,6 @@ if [ $valgrindtest -ne 2 ]; then
fi
rm -rf $dir
# unset conditional parameters
unset format

View file

@ -302,3 +302,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
# unset conditional parameters
unset clixon_util_stream

View file

@ -41,7 +41,6 @@ cat <<EOF > $cfg
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -76,7 +76,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>
</clixon-config>
@ -319,3 +318,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
# unset conditional parameters
unset format

View file

@ -226,7 +226,6 @@ testrun(){
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_DATASTORE_CACHE>$dbcache</CLICON_DATASTORE_CACHE>
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>

View file

@ -180,13 +180,40 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>
</clixon-config>
EOF
# Type range tests.
# Test invalid numbers or out of range errors for each type. Check error message on validation.
# These are the built-in ranges, typed ranges are checked in testrange
# Parameters: 1: type (eg uint8)
# 2: value to test
# 3: min value (for errmsg)
# 4: max value (for errmsg)
# 5: post (eg .000 - special for decimal64, others should have "") (NYI)
testbuiltin(){
t=$1
val=$2
rmin=$3
rmax=$4
post=$5
errmsg="Number $val$post out of range: $rmin$post - $rmax$post"
new "Netconf set invalid $t leaf"
echo "$clixon_netconf -qf $cfg"
echo "<rpc><edit-config><target><candidate/></target><config><r$t xmlns=\"urn:example:clixon\">$val</r$t></config></edit-config></rpc>]]>]]>"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config><r$t xmlns=\"urn:example:clixon\">$val</r$t></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf validate invalid range"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>r$t</bad-element></error-info><error-severity>error</error-severity><error-message>$errmsg</error-message></rpc-error></rpc-reply>]]>]]>$"
new "discard"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
}
# Type explicit typed range tests.
# Parameters: 1: type (eg uint8)
# 2: val OK
# 3: eval Invalid value
@ -205,7 +232,7 @@ testrange(){
fi
new "generated cli set $t leaf invalid"
expectpart "$(clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg"
expectpart "$($clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg"
new "generated cli set $t leaf OK"
expectfn "$clixon_cli -1f $cfg -l o set l$t $val" 0 '^$'
@ -243,28 +270,6 @@ testrange(){
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
}
# Type unlimited value range test. Only test invalid number out of range of type
# Parameters: 1: type (eg uint8)
# 2: val
# 3: post (eg .000 - special for decimal64, others should have "")
testunlimit(){
t=$1
val=$2
rmin=$3
rmax=$4
post=$5
errmsg="Number $val$post out of range: $rmin$post - $rmax$post"
new "Netconf set invalid $t leaf"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><edit-config><target><candidate/></target><config><r$t xmlns=\"urn:example:clixon\">$val</r$t></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf validate invalid range"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>r$t</bad-element></error-info><error-severity>error</error-severity><error-message>$errmsg</error-message></rpc-error></rpc-reply>]]>]]>$"
new "discard"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
}
if [ $BE -ne 0 ]; then
new "kill old backend"
@ -282,15 +287,28 @@ fi
new "test params: -f $cfg"
# Test all int types
testunlimit int8 300 -128 127 ""
testunlimit int16 73000 -32768 32767 ""
testunlimit int32 4900000000 -2147483648 2147483647 ""
testunlimit int64 49739274983274983274983274 -9223372036854775808 9223372036854775807 ""
testunlimit uint8 300 0 255 ""
testunlimit uint16 73000 0 65535 ""
testunlimit uint32 4900000000 0 4294967295 ""
testunlimit uint64 49739274983274983274983274 0 18446744073709551615 ""
#testunlimit decimal64 49739274983274983274983274 -9223372036854775808 9223372036854775807 ".000"
testbuiltin int8 300 -128 127 ""
testbuiltin int8 -300 -128 127 ""
testbuiltin int16 73000 -32768 32767 ""
testbuiltin int16 -73000 -32768 32767 ""
testbuiltin int32 4900000000 -2147483648 2147483647 ""
testbuiltin int32 -4900000000 -2147483648 2147483647 ""
testbuiltin int64 49739274983274983274983274 -9223372036854775808 9223372036854775807 ""
testbuiltin int64 -49739274983274983274983274 -9223372036854775808 9223372036854775807 ""
testbuiltin uint8 300 0 255 ""
testbuiltin uint8 -300 0 255 ""
testbuiltin uint8 -1 0 255 ""
testbuiltin uint16 73000 0 65535 ""
testbuiltin uint16 -73000 0 65535 ""
testbuiltin uint16 -1 0 65535 ""
testbuiltin uint32 4900000000 0 4294967295 ""
testbuiltin uint32 -4900000000 0 4294967295 ""
testbuiltin uint32 -1 0 4294967295 ""
testbuiltin uint64 49739274983274983274983274 0 18446744073709551615 ""
testbuiltin uint64 -49739274983274983274983274 0 18446744073709551615 ""
testbuiltin uint64 -1 0 18446744073709551615 ""
#testbuiltin decimal64 49739274983274983274983274 -9223372036854775808 9223372036854775807 ".000"
# Test all int types
for t in int8 int16 int32 int64 uint8 uint16 uint32 uint64; do
@ -315,3 +333,6 @@ if [ $BE -ne 0 ]; then
fi
rm -rf $dir
# unset conditional parameters
unset format

View file

@ -24,7 +24,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -25,7 +25,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -21,7 +21,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -34,7 +34,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF

View file

@ -180,3 +180,5 @@ expecteof "$clixon_util_xml -o" 0 "$XML" "$XML"
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml

View file

@ -10,11 +10,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
xml=$dir/xml.xml
xml2=$dir/xml2.xml
xml3=$dir/xml3.xml
ydir=$dir/yang
if [ ! -d $ydir ]; then
mkdir $ydir
fi
cat <<EOF > $xml
<aaa>
@ -81,7 +76,6 @@ cat <<EOF > $xml3
EOF
new "xpath /"
echo "$clixon_util_xpath -f $xml -p /"
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"
@ -209,3 +203,6 @@ new "xpath derived-from-or-self"
expecteof "$clixon_util_xpath -f $xml3 -p 'derived-from-or-self(../../change-operation,modify)'" 0 "" "derived-from-or-self"
rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath

View file

@ -63,3 +63,6 @@ new "xpath canonical form (wrong namespace should fail)"
expectpart "$($clixon_util_xpath -c -y $ydir -p /i:x/j:y -n i:urn:example:c -n j:urn:example:b)" 255
rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath

View file

@ -37,7 +37,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -70,7 +70,6 @@ cat <<EOF > $cfg
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
</clixon-config>
EOF
@ -124,7 +123,6 @@ cat <<EOF > $cfg
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
</clixon-config>
EOF

View file

@ -45,8 +45,6 @@ cat <<EOF > $cfg
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL>1</CLICON_CLI_GENMODEL>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>

View file

@ -25,7 +25,6 @@ cat <<EOF > $cfg
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>