diff --git a/test/unit/60.sh b/test/unit/60.sh index c4871362d03..e3f0b0254ba 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 245984368fd..ba8aa71632f 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 85cfc8435bf..c7642bbbbb0 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}) +}