Skip to content

Commit

Permalink
Merge pull request #912 from mslehto/unittest
Browse files Browse the repository at this point in the history
unittest updates
  • Loading branch information
miconda committed Jan 5, 2017
2 parents 0857fdd + 31923e5 commit 6f98237
Show file tree
Hide file tree
Showing 77 changed files with 323 additions and 287 deletions.
8 changes: 4 additions & 4 deletions test/unit/1.sh
Expand Up @@ -19,18 +19,18 @@
# 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
. include/common

CFG=1.cfg

# setup config
echo -e "debug=2\nrequest_route {\n ; \n}" > $CFG
printf "debug=2\nrequest_route {\n ; \n}" > $CFG

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

sleep 1
$KILL
kill_kamailio

rm -f $CFG

Expand Down
2 changes: 1 addition & 1 deletion test/unit/10.sh
Expand Up @@ -19,7 +19,7 @@
# 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
. include/common

cd $CTL_DIR

Expand Down
3 changes: 0 additions & 3 deletions test/unit/11.cfg
Expand Up @@ -7,9 +7,6 @@ disable_tcp=yes

alias=localhost

# ------------------ module loading ----------------------------------
loadpath "../../modules/"

#!trydef DBMOD "db_mysql"
loadmodule DBMOD

Expand Down
14 changes: 7 additions & 7 deletions test/unit/11.sh
Expand Up @@ -19,9 +19,9 @@
# 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
source include/database
. include/common
. include/require.sh
. include/database.sh

CFG=11.cfg

Expand All @@ -31,7 +31,7 @@ fi ;

SIPDOMAIN=127.0.0.1

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

sleep 1
Expand Down Expand Up @@ -155,10 +155,10 @@ if [ "$ret" -eq 0 ]; then
ret=$?
fi;

$KILL
kill_kamailio

# restart to test preload_udomain functionality
$BIN -w . -f $CFG -a no> /dev/null
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no> /dev/null
ret=$?

sleep 1
Expand All @@ -178,6 +178,6 @@ fi;
# cleanup
$MYSQL "delete from location where username like '49721123456789%';"

$KILL
kill_kamailio

exit $ret
5 changes: 2 additions & 3 deletions test/unit/12.cfg
@@ -1,8 +1,7 @@
log_stderror=yes
listen=127.0.0.1
loadpath "../../modules/"
loadmodule "../../modules/db_mysql/db_mysql.so"
loadmodule "../../modules/tm/tm.so"
loadmodule "db_mysql/db_mysql.so"
loadmodule "tm/tm.so"
loadmodule "sl"
loadmodule "rr"
loadmodule "maxfwd"
Expand Down
10 changes: 5 additions & 5 deletions test/unit/12.sh
Expand Up @@ -19,8 +19,8 @@
# 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

CFG=12.cfg
TMPFILE=`mktemp -t kamailio-test.XXXXXXXXXX`
Expand All @@ -29,7 +29,7 @@ if ! (check_netcat && check_kamailio); then
exit 0
fi ;

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

sleep 1
Expand Down Expand Up @@ -84,7 +84,7 @@ if [ "$ret" -eq 0 ] ; then
fi ;
fi ;
cat $TMPFILE
$KILL
kill_kamailio
rm $TMPFILE

exit $ret
exit $ret
1 change: 0 additions & 1 deletion test/unit/13.cfg
@@ -1,5 +1,4 @@
debug=2
loadpath "../../modules/"
loadmodule "db_mysql"
loadmodule "corex"
loadmodule "tm"
Expand Down
10 changes: 5 additions & 5 deletions test/unit/13.sh
Expand Up @@ -19,9 +19,9 @@
# 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
source include/database
. include/common
. include/require.sh
. include/database.sh

CFG=13.cfg

Expand Down Expand Up @@ -61,7 +61,7 @@ mask, next_domain) values ('3', '2', '1', '49', 'host1.local', '503', '0', '0',
$MYSQL "insert into carrierfailureroute(id, carrier, domain, scan_prefix, host_name, reply_code, flags,
mask, next_domain) values ('4', '2', '2', '49', 'host1.local', '5..', '0', '0', '3');"

$BIN -w . -f $CFG -a no > /dev/null
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null

ret=$?

Expand Down Expand Up @@ -105,7 +105,7 @@ Printing tree for domain 'domain1' (10)
fi ;
fi ;

$KILL
kill_kamailio

# cleanup database
$MYSQL "delete from carrier_name where id = 1;"
Expand Down
1 change: 0 additions & 1 deletion test/unit/14.cfg
@@ -1,4 +1,3 @@
loadpath "../../modules/"
loadmodule "sl"
loadmodule "xlog"
loadmodule "maxfwd"
Expand Down
8 changes: 4 additions & 4 deletions test/unit/14.sh
Expand Up @@ -19,8 +19,8 @@
# 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

CFG=14.cfg

Expand All @@ -30,7 +30,7 @@ fi ;

cp $CFG $CFG.bak

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

sleep 1
Expand Down Expand Up @@ -71,7 +71,7 @@ Printing tree for domain 'other' (3)
fi ;
fi ;

$KILL
kill_kamailio

mv $CFG.bak $CFG
rm -f $TMPFILE
Expand Down
14 changes: 7 additions & 7 deletions test/unit/15.sh
Expand Up @@ -19,25 +19,25 @@
# 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

CFG=15.cfg

if ! (check_kamailio); then
exit 0
fi ;

echo "loadmodule \"../../modules/db_text/db_text.so\"" > $CFG
printf "loadmodule \"db_text/db_text.so\"" > $CFG
cat 2.cfg >> $CFG
echo "modparam(\"$DB_ALL_MOD\", \"db_url\", \"text://`pwd`/../../utils/kamctl/dbtext/kamailio\")" >> $CFG
echo -e "\nrequest_route {\n ;\n}" >> $CFG
printf "modparam(\"$DB_ALL_MOD\", \"db_url\", \"text://`pwd`/../../utils/kamctl/dbtext/kamailio\")" >> $CFG
printf "\nrequest_route {\n ;\n}" >> $CFG

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

sleep 1
$KILL
kill_kamailio

rm $CFG

Expand Down
14 changes: 7 additions & 7 deletions test/unit/16.sh
Expand Up @@ -19,8 +19,8 @@
# 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

# Needs a default kamailio database setup for postgres

Expand All @@ -31,16 +31,16 @@ fi ;
CFG=16.cfg

cp 2.cfg $CFG
echo "loadmodule \"../../modules/db_postgres/db_postgres.so\"" >> $CFG
echo "modparam(\"$DB_ALL_MOD\", \"db_url\", \"postgres://kamailioro:kamailioro@localhost/kamailio\")" >> $CFG
echo -e "\nrequest_route {\n ;\n}" >> $CFG
printf "loadmodule \"db_postgres/db_postgres.so\"" >> $CFG
printf "modparam(\"$DB_ALL_MOD\", \"db_url\", \"postgres://kamailioro:kamailioro@localhost/kamailio\")" >> $CFG
printf "\nrequest_route {\n ;\n}" >> $CFG

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

sleep 1
$KILL
kill_kamailio

rm $CFG

Expand Down
14 changes: 7 additions & 7 deletions test/unit/17.sh
Expand Up @@ -19,8 +19,8 @@
# 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_kamailio && check_module "db_berkeley" ); then
exit 0
Expand All @@ -30,10 +30,10 @@ CFG=17.cfg

tmp_name=""$RANDOM"_kamailiodb_tmp"

echo "loadmodule \"../../modules/db_berkeley/db_berkeley.so\"" > $CFG
printf "loadmodule \"db_berkeley/db_berkeley.so\"" > $CFG
cat 2.cfg >> $CFG
echo "modparam(\"$DB_ALL_MOD\", \"db_url\", \"berkeley://`pwd`/$CTL_DIR/$tmp_name\")" >> $CFG
echo -e "\nrequest_route {\n ;\n}" >> $CFG
printf "modparam(\"$DB_ALL_MOD\", \"db_url\", \"berkeley://`pwd`/$CTL_DIR/$tmp_name\")" >> $CFG
printf "\nrequest_route {\n ;\n}" >> $CFG

# setup config file
cp $CTLRC $CTLRC.bak
Expand All @@ -53,12 +53,12 @@ ret=$?
cd $CRT_DIR

if [ "$ret" -eq 0 ] ; then
$BIN -w . -f $CFG -a no > /dev/null
$BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null
ret=$?
fi ;

sleep 1
$KILL
kill_kamailio

# cleanup
cd $CTL_DIR
Expand Down
10 changes: 5 additions & 5 deletions test/unit/18.sh
Expand Up @@ -20,8 +20,8 @@
# 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_kamailio); then
exit 0
Expand All @@ -31,17 +31,17 @@ fi ;
CFG=18.cfg

# setup config
echo -e "debug=3\nrequest_route {\n ;\n}" > $CFG
printf "debug=3\nrequest_route {\n ;\n}" > $CFG

# start:
$BIN -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) -P ./pid.out -G ./pgid.out -a no -A TESTDEF > /dev/null 2>&1

ret=$?

sleep 1

# clean up:
$KILL
kill_kamailio

rm $CFG
rm -f ./pid.out
Expand Down
1 change: 0 additions & 1 deletion test/unit/19.cfg
Expand Up @@ -10,7 +10,6 @@ dns=no
rev_dns=no

#-----------------------Loading Modules-------------------------------------
loadpath "../../modules/:../../modules_k/"
loadmodule "tm"
loadmodule "db_mysql"
loadmodule "usrloc"
Expand Down
10 changes: 5 additions & 5 deletions test/unit/19.sh
Expand Up @@ -19,9 +19,9 @@
# 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
source include/database
. include/common
. include/require.sh
. include/database.sh

if ! (check_sipp && check_kamailio && check_module "db_mysql" && check_mysql); then
exit 0
Expand All @@ -36,15 +36,15 @@ 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 -w . -f $CFG > /dev/null
$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

ret=$?

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

$MYSQL "DELETE FROM location WHERE ((contact = \"sip:foo@localhost:$UAS\") and (user_agent = \"kamailio_test\"));"
exit $ret;

0 comments on commit 6f98237

Please sign in to comment.