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 /tmp
|
||||
cd /var/tmp
|
||||
if [ $# -ne 0 ]; then
|
||||
err "usage: $0" 0
|
||||
fi
|
||||
rm -rf cligen
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
err "git clone" 1
|
||||
err "git clone clixon" 1
|
||||
fi
|
||||
cd clixon
|
||||
CFLAGS=-Werror ./configure
|
||||
CFLAGS=-Werror ./configure --with-cligen=../cligen
|
||||
if [ $? -ne 0 ]; then
|
||||
err "configure" 2
|
||||
fi
|
||||
|
|
@ -54,5 +69,5 @@ if [ $errcode -ne 0 ]; then
|
|||
err "test" $errcode
|
||||
fi
|
||||
cd ../..
|
||||
rm -rf clixon
|
||||
rm -rf clixon cligen
|
||||
logger "CLIXON: tests OK"
|
||||
|
|
|
|||
22
test/lib.sh
22
test/lib.sh
|
|
@ -30,6 +30,7 @@ expectfn(){
|
|||
if [ -z "$ret" -a -z "$expect" ]; then
|
||||
return
|
||||
fi
|
||||
# grep extended grep
|
||||
match=`echo "$ret" | grep -Eo "$expect"`
|
||||
# echo "ret:$ret"
|
||||
# echo "expect:$expect"
|
||||
|
|
@ -39,3 +40,24 @@ expectfn(){
|
|||
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