Module: kamailio Branch: master Commit: 3690bce25ee7ca01bb9d36ec253e727c2c10bc9f URL: https://github.com/kamailio/kamailio/commit/3690bce25ee7ca01bb9d36ec253e727c...
Author: Mikko Lehto mslehto@iki.fi Committer: Mikko Lehto mslehto@iki.fi Date: 2016-11-16T23:45:21+02:00
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
---
Modified: test/unit/60.sh Modified: test/unit/include/common Modified: test/unit/include/require.sh
---
Diff: https://github.com/kamailio/kamailio/commit/3690bce25ee7ca01bb9d36ec253e727c... Patch: https://github.com/kamailio/kamailio/commit/3690bce25ee7ca01bb9d36ec253e727c...
---
diff --git a/test/unit/60.sh b/test/unit/60.sh index c487136..e3f0b02 100755 --- a/test/unit/60.sh +++ b/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}
diff --git a/test/unit/include/common b/test/unit/include/common index 2459843..ba8aa71 100644 --- a/test/unit/include/common +++ b/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" diff --git a/test/unit/include/require.sh b/test/unit/include/require.sh index 85cfc84..c7642bb 100644 --- a/test/unit/include/require.sh +++ b/test/unit/include/require.sh @@ -63,3 +63,7 @@ check_sipsak() { fi; return 0 } + +kill_kamailio() { + kill $(cat ${PIDFILE}) +}