test
This commit is contained in:
parent
c3af59b2d8
commit
f5250b136c
3 changed files with 83 additions and 4 deletions
23
test/clixon
23
test/clixon
|
|
@ -10,17 +10,32 @@ err(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# cd to working dir
|
# cd to working dir
|
||||||
cd /tmp
|
cd /var/tmp
|
||||||
if [ $# -ne 0 ]; then
|
if [ $# -ne 0 ]; then
|
||||||
err "usage: $0" 0
|
err "usage: $0" 0
|
||||||
fi
|
fi
|
||||||
|
rm -rf cligen
|
||||||
rm -rf clixon
|
rm -rf clixon
|
||||||
|
git clone https://github.com/olofhagsand/cligen.git
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err "git clone cligen" 1
|
||||||
|
fi
|
||||||
|
cd cligen
|
||||||
|
CFLAGS=-Werror ./configure
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err "configure" 2
|
||||||
|
fi
|
||||||
|
make
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err "make" 3
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
git clone https://github.com/clicon/clixon.git
|
git clone https://github.com/clicon/clixon.git
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "git clone" 1
|
err "git clone clixon" 1
|
||||||
fi
|
fi
|
||||||
cd clixon
|
cd clixon
|
||||||
CFLAGS=-Werror ./configure
|
CFLAGS=-Werror ./configure --with-cligen=../cligen
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "configure" 2
|
err "configure" 2
|
||||||
fi
|
fi
|
||||||
|
|
@ -54,5 +69,5 @@ if [ $errcode -ne 0 ]; then
|
||||||
err "test" $errcode
|
err "test" $errcode
|
||||||
fi
|
fi
|
||||||
cd ../..
|
cd ../..
|
||||||
rm -rf clixon
|
rm -rf clixon cligen
|
||||||
logger "CLIXON: tests OK"
|
logger "CLIXON: tests OK"
|
||||||
|
|
|
||||||
22
test/lib.sh
22
test/lib.sh
|
|
@ -30,6 +30,7 @@ expectfn(){
|
||||||
if [ -z "$ret" -a -z "$expect" ]; then
|
if [ -z "$ret" -a -z "$expect" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
# grep extended grep
|
||||||
match=`echo "$ret" | grep -Eo "$expect"`
|
match=`echo "$ret" | grep -Eo "$expect"`
|
||||||
# echo "ret:$ret"
|
# echo "ret:$ret"
|
||||||
# echo "expect:$expect"
|
# echo "expect:$expect"
|
||||||
|
|
@ -39,3 +40,24 @@ expectfn(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# clicon_cli tester. First arg is command and second is expected outcome
|
||||||
|
expecteof(){
|
||||||
|
cmd=$1
|
||||||
|
input=$2
|
||||||
|
expect=$3
|
||||||
|
|
||||||
|
# Do while read stuff
|
||||||
|
ret=$($cmd<<EOF
|
||||||
|
$input
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
# Match if both are empty string
|
||||||
|
if [ -z "$ret" -a -z "$expect" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
match=`echo "$ret" | grep -Eo "$expect"`
|
||||||
|
if [ -z "$match" ]; then
|
||||||
|
err "\nExpected:\t\"$expect\"\nGot:\t\"$ret\""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
42
test/test2.sh
Executable file
42
test/test2.sh
Executable file
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Test1: backend and cli basic functionality
|
||||||
|
# Start backend server
|
||||||
|
# Add an ethernet interface and an address
|
||||||
|
# Show configuration
|
||||||
|
# Validate without a mandatory type
|
||||||
|
# Set the mandatory type
|
||||||
|
# Commit
|
||||||
|
|
||||||
|
# include err() and new() functions
|
||||||
|
. ./lib.sh
|
||||||
|
|
||||||
|
# kill old backend (if any)
|
||||||
|
new "kill old backend"
|
||||||
|
sudo clixon_backend -zf $clixon_cf
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err
|
||||||
|
fi
|
||||||
|
new "start backend"
|
||||||
|
# start new backend
|
||||||
|
sudo clixon_backend -If $clixon_cf -x 0 # -x 1 with xmldb proxy
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err
|
||||||
|
fi
|
||||||
|
new "netconf show config"
|
||||||
|
expecteof "clixon_netconf -qf $clixon_cf" "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "<rpc-reply><data></data></rpc-reply>]]>]]>"
|
||||||
|
|
||||||
|
new "netconf lock"
|
||||||
|
expecteof "clixon_netconf -qf $clixon_cf" "<rpc><lock><target><candidate/></target></lock></rpc>]]>]]>" "<rpc-reply><ok/></rpc-reply>]]>]]>"
|
||||||
|
|
||||||
|
new "Kill backend"
|
||||||
|
# Check if still alive
|
||||||
|
pid=`pgrep clixon_backend`
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
sudo clixon_backend -zf $clixon_cf
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err "kill backend"
|
||||||
|
fi
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue