Skip to content

Commit

Permalink
Merge pull request #923 from mslehto/unittest
Browse files Browse the repository at this point in the history
unittest updates
  • Loading branch information
miconda committed Jan 11, 2017
2 parents 09f66d6 + 1d5d365 commit 9456bb9
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 74 deletions.
5 changes: 3 additions & 2 deletions test/unit/12.cfg
Expand Up @@ -10,8 +10,9 @@ loadmodule "xlog"
loadmodule "usrloc"
loadmodule "registrar"
loadmodule "pv"
loadmodule "mi_fifo"
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
loadmodule "jsonrpcs"
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")

request_route {
xlog("received by kamailio[$pp] at '$Tf' from $si:$sp, method: $(rm{s.tolower}), transport: $rP:$Ri:$rp, user agent: $ua\n");
Expand Down
22 changes: 13 additions & 9 deletions test/unit/12.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# configuration with pseudo-variables, transformations and xlog output

# Copyright (C) 2007 1&1 Internet AG
Expand Down Expand Up @@ -29,24 +29,28 @@ if ! (check_netcat && check_kamailio); then
exit 0
fi ;

$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG &> $TMPFILE
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > $TMPFILE 2>&1
ret=$?

sleep 1
if ( have_netcat_quit_timer_patch ); then
NCOPTS='-q 1'
else
NCOPTS='-w 1'
fi

sleep 1

if [ "$ret" -eq 0 ] ; then
# register a user
cat register.sip | nc -q 1 -u localhost 5060 > /dev/null
$CTL ul show | grep "AOR:: 1000" > /dev/null
cat register.sip | nc $NCOPTS -u localhost 5060 > /dev/null
$CTL ul show | grep '"AoR":"1000"' > /dev/null
ret=$?
# unregister the user
cat unregister.sip | nc -q 1 -u localhost 5060 > /dev/null
cat unregister.sip | nc $NCOPTS -u localhost 5060 > /dev/null
fi ;


if [ "$ret" -eq 0 ] ; then
$CTL ul show | grep "AOR:: 1000" > /dev/null
$CTL ul show | grep '"AoR":"1000"' > /dev/null
ret=$?
if [ "$ret" -eq 0 ] ; then
ret=1
Expand Down Expand Up @@ -83,7 +87,7 @@ if [ "$ret" -eq 0 ] ; then
fi ;
fi ;
fi ;
cat $TMPFILE

kill_kamailio
rm $TMPFILE

Expand Down
4 changes: 2 additions & 2 deletions test/unit/18.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# runs ../kamailio with all command line arguments.
# ommited options are -h -v -I -c -D -V

Expand Down Expand Up @@ -34,7 +34,7 @@ CFG=18.cfg
printf "debug=3\nrequest_route {\n ;\n}" > $CFG

# start:
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -f ./$CFG -l 127.0.0.1 -n 0 -r -R -E -d -e -K -T -N 0 -b 23 -m 42 -w . -u $(id -u) -g $(id -g) -P ./pid.out -G ./pgid.out -a no -A TESTDEF > /dev/null 2>&1
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -f ./$CFG -l 127.0.0.1 -n 0 -r -R -E -d -e -K -T -N 0 -b 23 -m 42 -w . -u $(id -u) -g $(id -g) -G ./pgid.out -a no -A TESTDEF > /dev/null 2>&1

ret=$?

Expand Down
5 changes: 3 additions & 2 deletions test/unit/19.cfg
Expand Up @@ -18,12 +18,13 @@ loadmodule "sl/sl.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "pv/pv.so"
#for debugging purposes only
loadmodule "mi_fifo/mi_fifo.so"
loadmodule "jsonrpcs"
loadmodule "xlog/xlog.so"


#-----------------------Module parameters-------------------------------------
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")

Expand Down
8 changes: 4 additions & 4 deletions test/unit/19.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# check user lookup for proxy functionality with usrloc and registrar for mysql

# Copyright (C) 2007 1&1 Internet AG
Expand Down Expand Up @@ -36,9 +36,9 @@ UAC=5080
# add an registrar entry to the db;
$MYSQL "INSERT INTO location (ruid,username,contact,socket,user_agent,cseq,q) VALUES (\"kamailio-unit-uid\", \"foo\",\"sip:foo@localhost:$UAS\",\"udp:127.0.0.1:$UAS\",\"kamailio_test\",1,-1);"

$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG > /dev/null
sipp -sn uas -bg -i localhost -m 10 -f 2 -p $UAS &> /dev/null
sipp -sn uac -s foo 127.0.0.1:$SRV -i localhost -m 10 -f 2 -p $UAC &> /dev/null
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null
sipp -sn uas -bg -i 127.0.0.1 -m 10 -f 2 -p $UAS > /dev/null 2>&1
sipp -sn uac -s foo 127.0.0.1:$SRV -i 127.0.0.1 -m 10 -f 2 -p $UAC > /dev/null 2>&1

ret=$?

Expand Down
7 changes: 3 additions & 4 deletions test/unit/2.cfg
Expand Up @@ -20,8 +20,7 @@ loadmodule "group"
loadmodule "htable"
loadmodule "imc"
loadmodule "maxfwd"
loadmodule "mi_datagram"
loadmodule "mi_fifo"
loadmodule "jsonrpcs"
loadmodule "msilo"
loadmodule "nathelper"
##loadmodule "nat_traversal"
Expand Down Expand Up @@ -51,8 +50,8 @@ loadmodule "rtpproxy/rtpproxy.so"
loadmodule "xlog"
loadmodule "pdb/pdb.so"

modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
modparam("mi_datagram", "socket_name", "/tmp/kamailio.sock")
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")
modparam("dialog", "dlg_flag", 10)
modparam("dialog", "db_mode", 2)
##modparam("tm", "fr_inv_timer_avp", "$avp(i:704)")
Expand Down
6 changes: 3 additions & 3 deletions test/unit/2.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# load all modules without external dependencies with mysql

# Copyright (C) 2007 1&1 Internet AG
Expand Down Expand Up @@ -35,8 +35,8 @@ cp $CFG $CFG.bak

touch dispatcher.list

printf "loadmodule \"db_mysql/db_mysql.so\"" >> $CFG
printf "modparam(\"dispatcher\", \"list_file\", \"dispatcher.list\")" >> $CFG
printf "loadmodule \"db_mysql/db_mysql.so\"\n" >> $CFG
printf "modparam(\"dispatcher\", \"list_file\", \"dispatcher.list\")\n" >> $CFG
printf "\nrequest_route {\n ;\n}" >> $CFG

# start
Expand Down
5 changes: 3 additions & 2 deletions test/unit/20.cfg
Expand Up @@ -18,12 +18,13 @@ loadmodule "sl/sl.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "acc/acc.so"
#for debugging purposes only
loadmodule "mi_fifo/mi_fifo.so"
loadmodule "jsonrpcs/jsonrpcs.so"
loadmodule "xlog/xlog.so"


#-----------------------Module parameters-------------------------------------
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "db_url", "mysql://kamailio:kamailiorw@127.0.0.1/kamailio")
modparam("acc", "log_flag", 1)
Expand Down
8 changes: 4 additions & 4 deletions test/unit/20.sh
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/sh
# test basic accounting functionality

# Copyright (C) 2007 1&1 Internet AG
Expand Down Expand Up @@ -33,19 +33,19 @@ TMPFILE=`mktemp -t kamailio-test.XXXXXXXXXX`
# add an registrar entry to the db;
$MYSQL "INSERT INTO location (ruid, username,contact,socket,user_agent,cseq,q) VALUES (\"kamailio-test-uid\",\"foo\",\"sip:foo@127.0.0.1\",\"udp:127.0.0.1:5060\",\"kamailio_test\",1,-1);"

sipp -sn uas -bg -i 127.0.0.1 -m 1 -f 10 -p 5060 &> /dev/null
sipp -sn uas -bg -i 127.0.0.1 -m 1 -f 10 -p 5060 > /dev/null 2>&1

$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG > $TMPFILE 2>&1

sipp -sn uac -s foo 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 10 -p 5061 &> /dev/null
sipp -sn uac -s foo 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 10 -p 5061 > /dev/null 2>&1

egrep 'ACC:[[:space:]]+transaction[[:space:]]+answered:[[:print:]]*code=200;reason=OK$' $TMPFILE > /dev/null
ret=$?

sleep 1

# cleanup
killall -9 sipp &> /dev/null
killall -9 sipp > /dev/null 2>&1
kill_kamailio
rm $TMPFILE

Expand Down
2 changes: 1 addition & 1 deletion test/unit/27.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# test publish and subscribe for presence

# Copyright (C) 2007 1&1 Internet AG
Expand Down
7 changes: 4 additions & 3 deletions test/unit/33.cfg
@@ -1,11 +1,12 @@
debug=3
memlog=2
#memlog=2
loadmodule "cfgutils.so"
loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "mi_fifo/mi_fifo.so"
loadmodule "jsonrpcs.so"

modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")

modparam("cfgutils", "initial_probability", 15)
modparam("cfgutils", "hash_file", "33.cfg")
Expand Down
40 changes: 28 additions & 12 deletions test/unit/33.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# test cfgutils and pv module

# Copyright (C) 2008 1&1 Internet AG
Expand All @@ -19,20 +19,35 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

source include/common
source include/require
. include/common
. include/require.sh

if ! (check_netcat && check_kamailio); then
exit 0
fi;

if [ -e core ] ; then
echo "core file found, not run"
exit 0
if ( have_netcat_quit_timer_patch ); then
NCOPTS='-q 1'
else
NCOPTS='-w 2'
fi;

CFG=33.cfg

CORE=$(sysctl kern.corefile 2> /dev/null)
echo $CORE | grep '^kern.corefile: %N\.core' > /dev/null
ret=$?
if [ $ret -eq 0 ] ; then
CORE='kamailio.core'
else
CORE='core'
fi

if [ -e $CORE ] ; then
echo "core file found, not run"
exit 0
fi;

cp $CFG $CFG.bak

ulimit -c unlimited
Expand All @@ -43,23 +58,24 @@ ret=$?
sleep 1

if [ $ret -eq 0 ] ; then
$CTL mi check_config_hash | grep "The actual config file hash is identical to the stored one." >/dev/null
$CTL rpc cfgutils.check_config_hash | grep '"result":"Identical hash"' > /dev/null
ret=$?
fi;

echo " " >> $CFG

if [ $ret -eq 0 ] ; then
$CTL mi check_config_hash | grep "The actual config file hash is identical to the stored one." >/dev/null
$CTL rpc cfgutils.check_config_hash | grep '"result":"Identical hash"' > /dev/null
ret=$?
fi

if [ ! $ret -eq 0 ] ; then
# send a message
cat register.sip | nc -q 1 -u 127.0.0.1 5060 > /dev/null
cat register.sip | nc $NCOPTS -u 127.0.0.1 5060 > /dev/null
fi

sleep 1
kill_kamailio
kill_kamailio 2> /dev/null
ret=$?

if [ $ret -eq 0 ] ; then
Expand All @@ -68,10 +84,10 @@ else
ret=0
fi

if [ ! -e core ] ; then
if [ ! -e $CORE ] ; then
ret=1
fi
rm -f core
rm -f $CORE
mv $CFG.bak $CFG

exit $ret
5 changes: 3 additions & 2 deletions test/unit/34.cfg
Expand Up @@ -6,7 +6,6 @@ loadmodule "presence_xml.so"
loadmodule "presence_mwi.so"
loadmodule "pua.so"
loadmodule "pua_bla.so"
loadmodule "pua_mi.so"
loadmodule "pua_usrloc.so"
loadmodule "xmpp.so"
loadmodule "pua_xmpp.so"
Expand All @@ -16,10 +15,12 @@ loadmodule "presence_dialoginfo.so"
loadmodule "rr.so"
loadmodule "dialog.so"
loadmodule "pua_dialoginfo.so"
loadmodule "pv.so"

modparam("xmpp", "xmpp_host", "example.invalid");
modparam("rls", "xcap_root", "http://localhost/xcap-root:8000")
modparam("presence_xml", "integrated_xcap_server", 1)
modparam("pua_bla|pua_usrloc", "default_domain", "localhost")
modparam("pua_bla", "header_name", "Sender")
modparam("pua_bla|pua_xmpp", "server_address", "sip:bla@127.0.0.1")
modparam("pua_bla|pua_xmpp|rls", "server_address", "sip:bla@127.0.0.1")
modparam("dialog", "dlg_flag", 10)
12 changes: 6 additions & 6 deletions test/unit/34.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# load all presence related modules with mysql

# Copyright (C) 2008 1&1 Internet AG
Expand All @@ -21,17 +21,17 @@

# Needs a default kamailio database setup for mysql

source include/common
source include/require
source include/database
. include/common
. include/require.sh
. include/database.sh

CFG=34.cfg

if ! (check_kamailio && check_module "db_mysql" && check_module "presence" \
&& check_module "presence_xml" && check_module "pua" \
&& check_module "xcap_client" && check_module "rls" \
&& check_module "presence_mwi" && check_module "pua_bla" \
&& check_module "pua_mi" && check_module "pua_usrloc" \
&& check_module "pua_usrloc" \
&& check_module "pua_xmpp" && check_module "xmpp" \
&& check_module "presence_dialoginfo" && check_module "pua_dialoginfo" \
&& check_mysql); then
Expand All @@ -43,7 +43,7 @@ cp $CFG $CFG.bak
echo "loadmodule \"db_mysql/db_mysql.so\"" >> $CFG

# start
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG > /dev/null
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null
ret=$?

sleep 1
Expand Down
11 changes: 5 additions & 6 deletions test/unit/4.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# test basic fifo functionality

# Copyright (C) 2007 1&1 Internet AG
Expand Down Expand Up @@ -29,18 +29,17 @@ if ! (check_kamailio); then
fi ;

# setup config
printf "loadmodule \"mi_fifo/mi_fifo.so\"" > $CFG
printf "loadmodule \"kex/kex.so\"" >> $CFG
printf "modparam(\"mi_fifo\", \"fifo_name\", \"/tmp/kamailio_fifo\")" >> $CFG
printf "loadmodule \"jsonrpcs.so\"\n" > $CFG
printf "modparam(\"jsonrpcs\", \"transport\", 2)\n" >> $CFG
printf "modparam(\"jsonrpcs\", \"fifo_name\", \"$RPCFIFOPATH\")\n" >> $CFG
printf "\nrequest_route {\n ;\n}" >> $CFG


$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG > /dev/null
ret=$?

if [ "$ret" -eq 0 ] ; then
sleep 1
$CTL version > /dev/null
$CTL rpc core.version > /dev/null
ret=$?
fi ;

Expand Down

0 comments on commit 9456bb9

Please sign in to comment.