test/unit/28.sh
8ce63282
 #!/bin/bash
a999de70
 # tests simple cpl-c script operations with mysql
8ce63282
 
07080c8a
 # Copyright (C) 2008 1&1 Internet AG
8ce63282
 #
0f6b26be
 # This file is part of Kamailio, a free SIP server.
8ce63282
 #
0f6b26be
 # Kamailio is free software; you can redistribute it and/or modify
8ce63282
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version
 #
0f6b26be
 # Kamailio is distributed in the hope that it will be useful,
8ce63282
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
915efd3b
 . include/common
 . include/require.sh
 . include/database.sh
8ce63282
 
6ed7e3f7
 if ! (check_sipp && check_kamailio && check_module "db_mysql" && check_module "cpl-c" && check_mysql); then
8ce63282
 	exit 0
 fi ;
 
07080c8a
 CFG=28.cfg
 CPL=cpl_ignore.xml
6ed7e3f7
 TMPFILE=`mktemp -t kamailio-test.XXXXXXXXXX`
07080c8a
 
8ce63282
 
2f58816d
 $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no >/dev/null
8ce63282
 ret=$?
 sleep 1
 
4d898e93
 $CTL mi LOAD_CPL sip:alice@127.0.0.1 $CPL
07080c8a
 
8ce63282
 if [ "$ret" -eq 0 ] ; then
4d898e93
 	sipp -m 1 -f 1 127.0.0.1:5060 -sf cpl_test.xml >/dev/null 2>&1 &
07080c8a
 	ret=$?
4d898e93
 fi
8ce63282
 
07080c8a
 if [ "$ret" -eq 0 ] ; then
8262c28e
   $CTL fifo GET_CPL sip:alice@127.0.0.1 > $TMPFILE 
07080c8a
   diff $TMPFILE $CPL 
   ret=$?
4d898e93
 fi 
8ce63282
 
 if [ "$ret" -eq 0 ] ; then
8262c28e
   $CTL fifo REMOVE_CPL sip:alice@127.0.0.1
   $CTL fifo GET_CPL sip:alice@127.0.0.1 > $TMPFILE
4d898e93
 fi
8ce63282
 
4d898e93
 diff $TMPFILE $CPL >/dev/null
07080c8a
 ret=$?
 
 if [ ! "$ret" -eq 0 ] ; then
   ret=0
 fi;
8ce63282
 
4d898e93
 sleep 1
 
8ce63282
 #cleanup:
31923e56
 kill_kamailio
4d898e93
 killall -9 sipp >/dev/null 2>&1
07080c8a
 rm $TMPFILE
8ce63282
 
4d898e93
 exit $ret