truncate helptext

This commit is contained in:
Olof hagsand 2016-03-09 21:01:57 +01:00
parent 4b19798b58
commit 6d8acdea9f
9 changed files with 102 additions and 44 deletions

View file

@ -3,7 +3,7 @@
testnr=0
testnname=
clixon_cf=/usr/local/etc/routing.conf
# error and exit
# error and exit, arg is optional extra errmsg
err(){
echo "Error in Test$testnr [$testname] $1"
exit $testnr
@ -18,14 +18,23 @@ new(){
}
# clicon_cli tester. First arg is command and second is expected outcome
clifn(){
expectfn(){
cmd=$1
expect=$2
ret=`$cmd`
if [ $? -ne 0 ]; then
err
fi
if [ "$ret" != "$expect" ]; then
# Match if both are empty string
if [ -z "$ret" -a -z "$expect" ]; then
return
fi
match=`echo "$ret" | grep -Eo "$expect"`
# echo "ret:$ret"
# echo "expect:$expect"
# echo "match:$match"
if [ -z "$match" ]; then
err "\nExpected:\t\"$expect\"\nGot:\t\"$ret\""
fi
}

View file

@ -1,4 +1,11 @@
#!/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
@ -6,27 +13,41 @@
# 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
sudo clixon_backend -If $clixon_cf -x 0 # -x 1 with xmldb proxy
if [ $? -ne 0 ]; then
err
fi
new "cli configure"
clifn "clixon_cli -1f $clixon_cf set interfaces interface eth0" ""
expectfn "clixon_cli -1f $clixon_cf set interfaces interface eth0" ""
new "cli show configuration"
clifn "clixon_cli -1f $clixon_cf show conf cli" "interfaces interface name eth0
interfaces interface enabled true"
expectfn "clixon_cli -1f $clixon_cf show conf cli" "^interfaces interface name eth0
interfaces interface enabled true$"
new "cli failed validate"
expectfn "clixon_cli -1f $clixon_cf -l o validate" "Validate failed"
new "cli configure more"
expectfn "clixon_cli -1f $clixon_cf set interfaces interface eth0 ipv4 address 1.2.3.4 prefix-length 24" ""
expectfn "clixon_cli -1f $clixon_cf set interfaces interface eth0 type bgp" ""
new "cli commit"
expectfn "clixon_cli -1f $clixon_cf -l o commit" ""
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
err "kill backend"
fi