[asterisk-dev] Test Suite advise needed

Mark Michelson mmichelson at digium.com
Thu Sep 19 12:08:37 CDT 2013


On 09/19/2013 10:48 AM, George Joseph wrote:
> I'm trying to get a test going for the PJSIP_HEADER, PJSIPAddHeader
> and PJSIPRemoveHeader stuff I just added (even though it may change).
> I understand the basic layout of the tests but I'm having a hard time
> figuring out how to signal pass/fail.  The 2 scenarios are ...
>
> I send a specific header on an invite from SIPp and I call
> PJSIP_HEADER from a dialplan.  How do I signal that I did or didn't
> get the header?

A common method of indicating pass/failure in the dialplan is to use the 
AMI event "UserEvent". You can do something like this (the exact syntax 
may be incorrect. Sorry if it is):

exten => blah,n,UserEvent(MyEvent, Result: ${IF($[${MYVAR} = 
ExpectedValue]?success:failure)})

This line of dialplan will send an AMI UserEvent with the Event: header 
set to "MyEvent" and the Result: header set to "success" if MYVAR is as 
expected or "failure" if MYVAR is not what is expected.

The testsuite can then listen for UserEvents. When the specific 
UserEvent you care about arrives, you can determine pass or fail based 
on the Result: header.

>
> I send a specific header from a dialplan using PJSIPAddHeader.  How do
> I signal from SIPp that I did or didn't get the header?

SIPp has the ability to apply regular expressions to incoming 
requests/responses as necessary.

The best way to explain this is through an example. At semi-random, I've 
chosen tests/channels/pjsip/diversion/diversion_caller_id/sipp/user3.xml 
from the testsuite.

The first INVITE received looks like this:

<recv request="INVITE" crlf="true">
     <action>
         <ereg regexp="user2" search_in="hdr" header="Diversion:" 
check_it="true" assign_to="1" />
         <log message="Received INVITE with Diversion header: [$1]." />
     </action>
</recv>

The ereg action looks for the regular expression "user2" in the header 
"Diversion:" and assigns it to a variable called "1". The log message is 
optional but can help to debug. The "check_it" attribute means to check 
that the value is there as expected. You can also use "check_it_inverse" 
in order for the scenario to succeed if the regex check does *not* succeed.

>
> Any hints or could someone point me to one or more of the existing
> tests that I can adapt?
>
> george
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>     http://lists.digium.com/mailman/listinfo/asterisk-dev




More information about the asterisk-dev mailing list