Browse Source

test/unit: update unit test 60

- make sipsak use localhost to avoid name lookup error
- kill Kamailio by using pid file
- do not pass -L to sipsak in order to have proper (CR LF) line ending
Mikko Lehto 8 years ago
parent
commit
3690bce25e
3 changed files with 15 additions and 8 deletions
  1. 9 8
      test/unit/60.sh
  2. 2 0
      test/unit/include/common
  3. 4 0
      test/unit/include/require.sh

+ 9 - 8
test/unit/60.sh

@@ -20,26 +20,27 @@
 . include/common
 . include/require.sh
 
-CFG=60.cfg
+CFGFILE=60.cfg
 TMPFILE=$(mktemp -t kamailio-test.XXXXXXXXXX)
+SIPSAKOPTS="-H localhost -s sip:127.0.0.1 -v"
 
 if ! (check_sipsak && check_kamailio && check_module "sdpops"); then
 	exit 0
 fi
 
-${BIN} -w . -f ${CFG} > /dev/null
+${BIN} -w ${RUN_DIR} -Y ${RUN_DIR} -P ${PIDFILE} -f ${CFGFILE} > /dev/null
 ret=$?
 
 sleep 1
 if [ "${ret}" -ne 0 ] ; then
 	echo "start fail"
-	${KILL}
+	kill_kamailio
 	exit ${ret}
 fi
 
 # Borken SDP should give 500 response
 FILE="60-message-sdp0.sip"
-sipsak -f ${FILE} -L -s sip:127.0.0.1 -v > ${TMPFILE}
+sipsak ${SIPSAKOPTS} -f ${FILE} > ${TMPFILE}
 ret=$?
 if [ "${ret}" -eq 1 ] ; then
 	ret=0
@@ -55,7 +56,7 @@ for i in 1 2 3 4 5 6 7; do
 	TOTALBEFORE=$(awk '/^v=0/,/^$/ {total++; if ($0 ~ /^a=X-cap/ ) { prefix++;} else { other++} } END {if (prefix) {print other " + " prefix} else { print other " + 0"} }' ${FILE})
 	OTHERBEFORE=$(echo ${TOTALBEFORE}|cut -d+ -f1)
 
-	sipsak -f ${FILE} -L -s sip:127.0.0.1 -v > ${TMPFILE}
+	sipsak ${SIPSAKOPTS} -f ${FILE} > ${TMPFILE}
 	ret=$?
 	if [ "${ret}" -eq 0 ] ; then
 		TOTALAFTER=$(awk '/^v=0/,/^$/ {total++; if ($0 ~ /^a=X-cap/ ) { prefix++;} else { other++} } END {if (prefix) {print other " + " prefix} else { print other " + 0"} }' ${TMPFILE})
@@ -74,7 +75,7 @@ done
 
 # Empty body should get 500 response
 FILE="60-message-sdp8.sip"
-sipsak -f ${FILE} -L -s sip:127.0.0.1 -v > ${TMPFILE}
+sipsak ${SIPSAKOPTS} -f ${FILE} > ${TMPFILE}
 ret=$?
 if [ "${ret}" -eq 1 ] ; then
 	ret=0
@@ -84,7 +85,7 @@ else
 	exit ${ret}
 fi
 
-${KILL}
-
+kill_kamailio
+rm ${TMPFILE}
 exit ${ret}
 

+ 2 - 0
test/unit/include/common

@@ -1,6 +1,7 @@
 # all database modules
 DB_ALL_MOD="acc|alias_db|auth_db|avpops|dialog|dialplan|dispatcher|domain|domainpolicy|group|imc|lcr|msilo|siptrace|speeddial|uri_db|usrloc|permissions|pdt|userblacklist"
 # root directory relative to tests
+RUN_DIR="."
 SRC_DIR="../.."
 CTL_DIR="$SRC_DIR/utils/kamctl"
 CTLRC="$CTL_DIR/kamctlrc"
@@ -19,5 +20,6 @@ else
     fi
 fi
 KILL="killall -15 $BNAME"
+PIDFILE="${RUN_DIR}/kamailio.pid"
 # test directory relative to root
 TEST_DIR="test/unit"

+ 4 - 0
test/unit/include/require.sh

@@ -63,3 +63,7 @@ check_sipsak() {
 	fi;
 	return 0
 }
+
+kill_kamailio() {
+	kill $(cat ${PIDFILE})
+}