Making the tests self-contained wrt config file and lib.sh creating test scratch dir.

This commit is contained in:
Olof hagsand 2018-01-07 17:56:33 +01:00
parent b5b96cde0c
commit cefaf4717f
12 changed files with 256 additions and 78 deletions

View file

@ -1,7 +1,16 @@
#!/bin/bash #!/bin/bash
# Define test functions.
# Create working dir as variable "dir"
testnr=0 testnr=0
testname= testname=
dir=/var/tmp/$0
if [ ! -d $dir ]; then
mkdir $dir
fi
rm -rf $dir/*
# error and exit, arg is optional extra errmsg # error and exit, arg is optional extra errmsg
err(){ err(){
echo "Error in Test$testnr [$testname]:" echo "Error in Test$testnr [$testname]:"

View file

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# Test1: backend and cli basic functionality # Test1: backend and cli basic functionality
# Start backend server # Start backend server
# Add an ethernet interface and an address # Add an ethernet interface and an address
@ -7,9 +8,25 @@
# Set the mandatory type # Set the mandatory type
# Commit # Commit
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/usr/local/etc/routing.xml cfg=$dir/conf_yang.xml
cat <<EOF > $cfg
<config>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/routing/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLISPEC_DIR>/usr/local/lib/routing/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/routing/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>routing</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/routing/routing.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/routing/routing.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/routing</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
</config>
EOF
# For memcheck # For memcheck
#clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli" #clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli"
@ -104,3 +121,4 @@ if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -2,12 +2,13 @@
# Test5: datastore tests. # Test5: datastore tests.
# Just run a binary direct to datastore. No clixon. # Just run a binary direct to datastore. No clixon.
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
fyang=$dir/ietf-ip.yang
datastore=datastore_client datastore=datastore_client
cat <<EOF > /tmp/ietf-ip.yang cat <<EOF > $fyang
module ietf-ip{ module ietf-ip{
container x { container x {
list y { list y {
@ -46,14 +47,14 @@ db='<config><x><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>se
run(){ run(){
name=$1 name=$1
dir=/tmp/$name mydir=$dir/$name
if [ ! -d $dir ]; then if [ ! -d $mydir ]; then
mkdir $dir mkdir $mydir
fi fi
rm -rf $dir/* rm -rf $mydir/*
conf="-d candidate -b $dir -p ../datastore/$name/$name.so -y /tmp -m ietf-ip" conf="-d candidate -b $mydir -p ../datastore/$name/$name.so -y $dir -m ietf-ip"
echo "conf:$conf" echo "conf:$conf"
new "datastore $name init" new "datastore $name init"
expectfn "$datastore $conf init" "" expectfn "$datastore $conf init" ""
@ -140,21 +141,23 @@ run(){
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>"
new "datastore other db init" new "datastore other db init"
expectfn "$datastore -d kalle -b $dir -p ../datastore/$name/$name.so -y /tmp -m ietf-ip init" expectfn "$datastore -d kalle -b $mydir -p ../datastore/$name/$name.so -y $dir -m ietf-ip init"
new "datastore other db copy" new "datastore other db copy"
expectfn "$datastore $conf copy kalle" "" expectfn "$datastore $conf copy kalle" ""
diff $dir/kalle_db $dir/candidate_db diff $mydir/kalle_db $mydir/candidate_db
new "datastore lock" new "datastore lock"
expectfn "$datastore $conf lock 756" "" expectfn "$datastore $conf lock 756" ""
#leaf-list #leaf-list
rm -rf $dir rm -rf $mydir
} }
#run keyvalue # cant get the put to work #run keyvalue # cant get the put to work
run text run text
rm -rf $dir

View file

@ -1,64 +1,60 @@
#!/bin/bash #!/bin/bash
# Install test # Install test
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
DIR=/tmp/clixoninstall new "Set up installdir $dir"
new "Set up installdir $DIR"
rm -rf $DIR
mkdir $DIR
new "Make DESTDIR install" new "Make DESTDIR install"
(cd ..; make DESTDIR=$DIR install) (cd ..; make DESTDIR=$dir install)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
new "Check installed files" new "Check installed files"
if [ ! -d $DIR/usr ]; then if [ ! -d $dir/usr ]; then
err $DIR/usr err $dir/usr
fi fi
if [ ! -d $DIR/www-data ]; then if [ ! -d $dir/www-data ]; then
err $DIR/www-data err $dir/www-data
fi fi
if [ ! -f $DIR/usr/local/share/clixon/clixon.mk ]; then if [ ! -f $dir/usr/local/share/clixon/clixon.mk ]; then
err $DIR/usr/local/share/clixon/clixon.mk err $dir/usr/local/share/clixon/clixon.mk
fi fi
if [ ! -f $DIR/usr/local/share/clixon/clixon-config* ]; then if [ ! -f $dir/usr/local/share/clixon/clixon-config* ]; then
err $DIR/usr/local/share/clixon/clixon-config* err $dir/usr/local/share/clixon/clixon-config*
fi fi
if [ ! -h $DIR/usr/local/lib/libclixon.so ]; then if [ ! -h $dir/usr/local/lib/libclixon.so ]; then
err $DIR/usr/local/lib/libclixon.so err $dir/usr/local/lib/libclixon.so
fi fi
if [ ! -h $DIR/usr/local/lib/libclixon_backend.so ]; then if [ ! -h $dir/usr/local/lib/libclixon_backend.so ]; then
err $DIR/usr/local/lib/libclixon_backend.so err $dir/usr/local/lib/libclixon_backend.so
fi fi
new "Make DESTDIR install include" new "Make DESTDIR install include"
(cd ..; make DESTDIR=$DIR install-include) (cd ..; make DESTDIR=$dir install-include)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
new "Check installed includes" new "Check installed includes"
if [ ! -f $DIR/usr/local/include/clixon/clixon.h ]; then if [ ! -f $dir/usr/local/include/clixon/clixon.h ]; then
err $DIR/usr/local/include/clixon/clixon.h err $dir/usr/local/include/clixon/clixon.h
fi fi
new "Make DESTDIR uninstall" new "Make DESTDIR uninstall"
(cd ..; make DESTDIR=$DIR uninstall) (cd ..; make DESTDIR=$dir uninstall)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
new "Check remaining files" new "Check remaining files"
f=$(find $DIR -type f) f=$(find $dir -type f)
if [ -n "$f" ]; then if [ -n "$f" ]; then
err "$f" err "$f"
fi fi
new "Check remaining symlinks" new "Check remaining symlinks"
l=$(find $DIR -type l) l=$(find $dir -type l)
if [ -n "$l" ]; then if [ -n "$l" ]; then
err "$l" err "$l"
fi fi

View file

@ -1,10 +1,26 @@
#!/bin/bash #!/bin/bash
# Test7: Yang specifics: leafref # Test7: Yang specifics: leafref
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/usr/local/etc/routing.xml cfg=$dir/conf_yang.xml
fyang=/tmp/leafref.yang fyang=$dir/leafref.yang
cat <<EOF > $cfg
<config>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/routing/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLISPEC_DIR>/usr/local/lib/routing/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/routing/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>routing</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/routing/routing.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/routing/routing.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/routing</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
</config>
EOF
# For memcheck # For memcheck
# clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
@ -126,3 +142,5 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -1,9 +1,30 @@
#!/bin/bash #!/bin/bash
# Test2: backend and netconf basic functionality # Test2: backend and netconf basic functionality
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/usr/local/etc/routing.xml
cfg=$dir/conf_yang.xml
cat <<EOF > $cfg
<config>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/routing/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLISPEC_DIR>/usr/local/lib/routing/clispec</CLICON_CLISPEC_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/routing/backend</CLICON_BACKEND_DIR>
<CLICON_NETCONF_DIR>/usr/local/lib/routing/netconf</CLICON_NETCONF_DIR>
<CLICON_RESTCONF_DIR>/usr/local/lib/routing/restconf</CLICON_RESTCONF_DIR>
<CLICON_CLI_DIR>/usr/local/lib/routing/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>routing</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/routing/routing.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/routing/routing.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/routing</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
</config>
EOF
# For memcheck # For memcheck
#clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" #clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
@ -146,3 +167,5 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -6,20 +6,22 @@
# No test of ordered-by system is done yet # No test of ordered-by system is done yet
# (we may want to sort them alphabetically for better performance). # (we may want to sort them alphabetically for better performance).
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/tmp/conf_yang.xml cfg=$dir/conf_yang.xml
fyang=/tmp/order.yang fyang=$dir/order.yang
# For memcheck # For memcheck
# clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
clixon_netconf=clixon_netconf clixon_netconf=clixon_netconf
clixon_cli=clixon_cli clixon_cli=clixon_cli
dbdir=/tmp/order dbdir=$dir/order
new "Set up $dbdir" new "Set up $dbdir"
rm -rf $dbdir rm -rf $dbdir
mkdir $dbdir if [ ! -d $dbdir ]; then
mkdir $dbdir
fi
cat <<EOF > $cfg cat <<EOF > $cfg
<config> <config>
@ -175,3 +177,5 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -14,13 +14,14 @@ else
echo "Usage: $0 [<number> [<requests>]]" echo "Usage: $0 [<number> [<requests>]]"
exit 1 exit 1
fi fi
cfg=/tmp/scaling-conf.xml
fyang=/tmp/scaling.yang
fconfig=/tmp/config
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=$dir/scaling-conf.xml
fyang=$dir/scaling.yang
fconfig=$dir/config
# For memcheck # For memcheck
# clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
@ -153,3 +154,5 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -2,11 +2,46 @@
# Restconf basic functionality # Restconf basic functionality
# Assume http server setup, such as nginx described in apps/restconf/README.md # Assume http server setup, such as nginx described in apps/restconf/README.md
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/usr/local/etc/routing.xml cfg=$dir/conf.xml
fyang=$dir/restconf.yang
# This is a fixed 'state' implemented in routing_backend. It is always there cat <<EOF > $cfg
<config>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/routing/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLISPEC_DIR>/usr/local/lib/routing/clispec</CLICON_CLISPEC_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/routing/backend</CLICON_BACKEND_DIR>
<CLICON_RESTCONF_DIR>/usr/local/lib/routing/restconf</CLICON_RESTCONF_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_CLI_DIR>/usr/local/lib/routing/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>routing</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/routing/routing.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/routing/routing.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/routing</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
</config>
EOF
cat <<EOF > $fyang
module example{
import ietf-ip {
prefix ip;
}
import ietf-routing {
prefix rt;
}
import ietf-inet-types {
prefix "inet";
revision-date "2013-07-15";
}
}
EOF
# This is a fixed 'state' implemented in routing_backend. It is assumed to be always there
state='{"interfaces-state": {"interface": {"name": "eth0","type": "eth","if-index": "42"}}}' state='{"interfaces-state": {"interface": {"name": "eth0","type": "eth","if-index": "42"}}}'
# kill old backend (if any) # kill old backend (if any)
@ -15,8 +50,8 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg -y $fyang"
sudo clixon_backend -s init -f $cfg sudo clixon_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
@ -25,7 +60,7 @@ new "kill old restconf daemon"
sudo pkill -u www-data clixon_restconf sudo pkill -u www-data clixon_restconf
new "start restconf daemon" new "start restconf daemon"
sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -Df /usr/local/etc/routing.xml # -D sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -Df $cfg # -D
sleep 1 sleep 1
@ -38,11 +73,51 @@ new "restconf head"
expectfn "curl -sS -I http://localhost/restconf/data" "HTTP/1.1 200 OK" expectfn "curl -sS -I http://localhost/restconf/data" "HTTP/1.1 200 OK"
#Content-Type: application/yang-data+json" #Content-Type: application/yang-data+json"
new "restconf get empty config + state" new "restconf root discovery"
expectfn "curl -sSG http://localhost/restconf/data" $state expectfn "curl -sS -X GET http://localhost/.well-known/host-meta" "<Link rel='restconf' href='/restconf'/>"
new "restconf get state operation" #new "restconf get restconf json XXX"
expectfn "curl -sS -G http://localhost/restconf/data/interfaces-state" $state #expectfn "curl -sSG http://localhost/restconf" "{\"restconf\" : $state }"
#new "restconf get restconf/yang-library-version json XXX"
#expectfn "curl -sSG http://localhost/restconf/yang-library-version" "{\"restconf\" : $state }"
new "restconf get empty config + state json"
expectfn "curl -sSG http://localhost/restconf/data" "{\"data\": $state}"
new "restconf get empty config + state xml"
ret=$(curl -sS -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data)
expect="<data><interfaces-state><interface><name>eth0</name><type>eth</type><if-index>42</if-index></interface></interfaces-state></data>"
match=`echo $ret | grep -EZo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
fi
new "restconf get data/interfaces-state/interface=eth0 json"
expectfn "curl -sS -G http://localhost/restconf/data/interfaces-state/interface=eth0" '{"interface": {"name": "eth0","type": "eth","if-index": "42"}}'
new "restconf get state operation eth0 xml"
# Cant get shell macros to work, inline matching from lib.sh
ret=$(curl -sS -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/interfaces-state/interface=eth0)
expect="<interface><name>eth0</name><type>eth</type><if-index>42</if-index></interface>"
match=`echo $ret | grep -EZo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
fi
new "restconf get state operation eth0 type json"
expectfn "curl -sS -G http://localhost/restconf/data/interfaces-state/interface=eth0/type" '{"type": "eth"}
$'
new "restconf get state operation eth0 type xml"
# Cant get shell macros to work, inline matching from lib.sh
ret=$(curl -sS -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/interfaces-state/interface=eth0/type)
expect="<type>eth</type>"
match=`echo $ret | grep -EZo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
fi
new "restconf Add subtree to datastore using POST" new "restconf Add subtree to datastore using POST"
expectfn 'curl -sS -X POST -d {"interfaces":{"interface":{"name":"eth/0/0","type":"eth","enabled":"true"}}} http://localhost/restconf/data' "" expectfn 'curl -sS -X POST -d {"interfaces":{"interface":{"name":"eth/0/0","type":"eth","enabled":"true"}}} http://localhost/restconf/data' ""
@ -93,12 +168,16 @@ $'
new "restconf operation rpc using POST json" new "restconf operation rpc using POST json"
expectfn 'curl -sS -X POST -d {"input":{"routing-instance-name":"ipv4"}} http://localhost/restconf/operations/rt:fib-route' '{ "output": { "route": { "address-family": "ipv4", "next-hop": { "next-hop-list": "2.3.4.5" } } } } ' expectfn 'curl -sS -X POST -d {"input":{"routing-instance-name":"ipv4"}} http://localhost/restconf/operations/rt:fib-route' '{ "output": { "route": { "address-family": "ipv4", "next-hop": { "next-hop-list": "2.3.4.5" } } } } '
exit # XXX
new "restconf rpc using POST xml" new "restconf rpc using POST xml"
# Cant get shell macros to work, inline matching from lib.sh
ret=$(curl -sS -X POST -H "Accept: application/yang-data+xml" -d '{"input":{"routing-instance-name":"ipv4"}}' http://localhost/restconf/operations/rt:fib-route) ret=$(curl -sS -X POST -H "Accept: application/yang-data+xml" -d '{"input":{"routing-instance-name":"ipv4"}}' http://localhost/restconf/operations/rt:fib-route)
expect="<output> <route> <address-family>ipv4</address-family> <next-hop> <next-hop-list>2.3.4.5</next-hop-li t> </next-hop> </route> </output> " expect="<output> <route> <address-family>ipv4</address-family> <next-hop> <next-hop-list>2.3.4.5</next-hop-li t> </next-hop> </route> </output> "
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep -EZo "$expect"`
echo -n "ret: " if [ -z "$match" ]; then
echo $ret err "$expect" "$ret"
fi
new "Kill restconf daemon" new "Kill restconf daemon"
sudo pkill -u www-data clixon_restconf sudo pkill -u www-data clixon_restconf
@ -114,3 +193,5 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -6,9 +6,9 @@
# - running db starts with a "run" interface # - running db starts with a "run" interface
# - startup db starts with a "start" interface # - startup db starts with a "start" interface
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/tmp/conf_startup.xml cfg=$dir/conf_startup.xml
# For memcheck # For memcheck
# clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
@ -42,7 +42,8 @@ run(){
mode=$1 mode=$1
expect=$2 expect=$2
cat <<EOF > /tmp/db dbdir=$dir/db
cat <<EOF > $dbdir
<config> <config>
<interfaces> <interfaces>
<interface> <interface>
@ -52,9 +53,9 @@ run(){
</interfaces> </interfaces>
</config> </config>
EOF EOF
sudo mv /tmp/db /usr/local/var/routing/running_db sudo mv $dbdir /usr/local/var/routing/running_db
cat <<EOF > /tmp/db cat <<EOF > $dbdir
<config> <config>
<interfaces> <interfaces>
<interface> <interface>
@ -64,9 +65,9 @@ EOF
</interfaces> </interfaces>
</config> </config>
EOF EOF
sudo mv /tmp/db /usr/local/var/routing/startup_db sudo mv $dbdir /usr/local/var/routing/startup_db
cat <<EOF > /tmp/config cat <<EOF > $dir/config
<config> <config>
<interfaces> <interfaces>
<interface> <interface>
@ -84,8 +85,8 @@ EOF
err err
fi fi
new "start backend -f $cfg -s $mode -c /tmp/config" new "start backend -f $cfg -s $mode -c $dir/config"
sudo clixon_backend -f $cfg -s $mode -c /tmp/config sudo clixon_backend -f $cfg -s $mode -c $dir/config
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
@ -111,3 +112,4 @@ run none '<data><interfaces><interface><name>run</name><type>eth</type><enabl
run running '<data><interfaces><interface><name>extra</name><type>eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>local</type><enabled>true</enabled></interface><interface><name>run</name><type>eth</type><enabled>true</enabled></interface></interfaces></data>' run running '<data><interfaces><interface><name>extra</name><type>eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>local</type><enabled>true</enabled></interface><interface><name>run</name><type>eth</type><enabled>true</enabled></interface></interfaces></data>'
run startup '<data><interfaces><interface><name>extra</name><type>eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>local</type><enabled>true</enabled></interface><interface><name>startup</name><type>eth</type><enabled>true</enabled></interface></interfaces></data>' run startup '<data><interfaces><interface><name>extra</name><type>eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>local</type><enabled>true</enabled></interface><interface><name>startup</name><type>eth</type><enabled>true</enabled></interface></interfaces></data>'
rm -rf $dir

View file

@ -2,10 +2,27 @@
# Advanced union types and generated code # Advanced union types and generated code
# and enum w values # and enum w values
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/usr/local/etc/routing.xml fyang=$dir/type.yang
fyang=/tmp/type.yang cfg=$dir/conf_yang.xml
cat <<EOF > $cfg
<config>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/routing/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLISPEC_DIR>/usr/local/lib/routing/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/routing/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>routing</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/routing/routing.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/routing/routing.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/routing</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
</config>
EOF
# For memcheck # For memcheck
#clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli" #clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli"
@ -126,3 +143,4 @@ if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir

View file

@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# Test4: Yang specifics: multi-keys and empty type # Test4: Yang specifics: multi-keys and empty type
# include err() and new() functions # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=/tmp/conf_yang.xml
fyang=/tmp/test.yang cfg=$dir/conf_yang.xml
fyang=$dir/test.yang
# For memcheck # For memcheck
# clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf" # clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
@ -151,3 +152,5 @@ sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "kill backend" err "kill backend"
fi fi
rm -rf $dir