Переглянути джерело

test/unit: update unit test 60

- Kamailio sdpops manipulates SDP in MESSAGE request
- count certain SDP lines before and after sdp_remove_line_by_prefix()
- only m=video is to be manipulated
- verify by counting prefix line count vs. other lines
Mikko Lehto 8 роки тому
батько
коміт
8d4c2e4190
3 змінених файлів з 59 додано та 0 видалено
  1. 31 0
      test/unit/60-message-sdp9.sip
  2. 7 0
      test/unit/60.cfg
  3. 21 0
      test/unit/60.sh

+ 31 - 0
test/unit/60-message-sdp9.sip

@@ -0,0 +1,31 @@
+MESSAGE sip:[email protected] SIP/2.0
+From: sip:[email protected];tag=45dfdf49
+To: sip:[email protected]
+Call-ID: 1172299593a
+CSeq: 1 MESSAGE
+Content-Type: application/sdp
+Max-Forwards: 2
+X-Case: 60-test9
+X-Info: sdpops remove_line_by_prefix test9 - filter video attribute
+
+v=0
+o=FreeSWITCH 1447318678 1447318679 IN IP4 10.0.0.145
+s=FreeSWITCH
+c=IN IP4 10.0.0.145
+t=0 0
+m=audio 28504 RTP/AVP 96 101
+a=rtpmap:96 opus/48000/2
+a=fmtp:96 useinbandfec=1; maxaveragebitrate=14400; maxplaybackrate=8000
+a=rtpmap:101 telephone-event/48000
+a=fmtp:101 0-16
+a=ptime:20
+a=sendrecv
+a=rtcp:28505 IN IP4 10.0.0.145
+a=rtcp-fb:101 nack
+m=video 21992 RTP/SAVPF 100
+a=rtpmap:100 VP8/90000
+a=rtcp:21992 IN IP4 10.0.0.150
+a=rtcp-fb:100 ccm fir
+a=rtcp-fb:100 nack
+a=rtcp-fb:100 nack pli
+

+ 7 - 0
test/unit/60.cfg

@@ -26,6 +26,13 @@ route {
 			sl_send_reply(200,"OK");
 			exit;
 		}
+		if ($hdr(X-Case) == '60-test9') {
+			sdp_remove_line_by_prefix("a=rtcp","video");
+			msg_apply_changes();
+			set_reply_body($rb,"application/sdp");
+			sl_send_reply(200,"OK");
+			exit;
+		}
 		sl_send_reply(500,"Unknown test case");
 		exit;
 

+ 21 - 0
test/unit/60.sh

@@ -85,6 +85,27 @@ else
 	exit ${ret}
 fi
 
+# Filter only video stream attributes
+FILE="60-message-sdp9.sip"
+TOTALBEFORE=$(awk '/^v=0/,/^$/ {total++; if ($0 ~ /^a=rtcp/ ) { prefix++;} else { other++} } END {if (prefix) {print other " + " prefix} else { print other " + 0"} }' ${FILE})
+OTHERBEFORE=$(echo ${TOTALBEFORE}|cut -d+ -f1)
+PREFIXBEFORE=$(echo ${TOTALBEFORE}|cut -d+ -f2)
+sipsak ${SIPSAKOPTS} -f ${FILE} > ${TMPFILE}
+ret=$?
+if [ "${ret}" -eq 0 ] ; then
+	TOTALAFTER=$(awk '/^v=0/,/^$/ {total++; if ($0 ~ /^a=rtcp:/ ) { prefix++;} else { other++} } END {if (prefix) {print other " + " prefix} else { print other " + 0"} }' ${TMPFILE})
+	OTHERAFTER=$(echo ${TOTALBEFORE}|cut -d+ -f1)
+	PREFIXAFTER=$(echo ${TOTALAFTER}|cut -d+ -f2)
+	if [ ${PREFIXAFTER} -eq 1 ] && [ ${OTHERBEFORE} -eq ${OTHERAFTER} ]; then
+		ret=0
+	else
+		ret=1
+		echo "found ${PREFIXAFTER} lines with prefix \"a=rtcp\", was expecting 1 (in m=audio)(${FILE})"
+	fi
+	else
+		echo "invalid sipsak return: ${ret}"
+fi
+
 kill_kamailio
 rm ${TMPFILE}
 exit ${ret}