[asterisk-commits] rmudgett: testsuite/asterisk/trunk r3400 - in /asterisk/trunk/tests: ./ hangu...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Aug 3 10:21:46 CDT 2012
Author: rmudgett
Date: Fri Aug 3 10:21:40 2012
New Revision: 3400
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3400
Log:
Hangup handler testsuite test (endbeforehexten=no).
Exercises the h-exten and hangup handler subroutines with
endbeforehexten=no.
Tests to test hangup handlers:
1) Tests relative hangup handler location resolution.
2) Tests hangup_handler_pop and hangup_handler_wipe
3) Tests hangup handler stack execution order
4) Tests hangup handler execution on both sides of a single call with and
without an h-exten.
5) Tests hangup handler execution on a forked call with and without an
h-exten.
6) CDR endbeforehexten test.
(closes issue SWP-4207)
Reported by: Matt Jordan
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/2062/
Added:
asterisk/trunk/tests/hangup/
asterisk/trunk/tests/hangup/handlers/
asterisk/trunk/tests/hangup/handlers/configs/
asterisk/trunk/tests/hangup/handlers/configs/ast1/
asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf (with props)
asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/hangup/handlers/run-test (with props)
asterisk/trunk/tests/hangup/handlers/test-config.yaml (with props)
asterisk/trunk/tests/hangup/tests.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf?view=auto&rev=3400
==============================================================================
--- asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf (added)
+++ asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf Fri Aug 3 10:21:40 2012
@@ -1,0 +1,2 @@
+[general]
+endbeforehexten=no
Propchange: asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/hangup/handlers/configs/ast1/cdr.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf?view=auto&rev=3400
==============================================================================
--- asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf Fri Aug 3 10:21:40 2012
@@ -1,0 +1,280 @@
+[hhandler]
+exten => xtn,1,Return()
+exten => xtn,2,UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => xtn,3,Return()
+exten => xtn,n(c1_cdr),Gosub(check_cdr,xtn,1(hhandler-${ARG2}))
+exten => xtn,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => xtn,n,Return()
+exten => xtn,n(c2_cdr),Gosub(check_cdr,xtn,1(hhandler-${ARG2}))
+exten => xtn,n(c2),UserEvent(U_HHandler,test: ${ARG1},which: callee,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => xtn,n,Return()
+
+
+[check_cdr]
+exten => xtn,1,GotoIf($["${CDR(end,u)}"="0.000000"]?done)
+exten => xtn,n,UserEvent(U_Failed,test: ${TEST_EXTEN},status: CDR(end,u)=${CDR(end,u)} was not as expected for ${ARG1}.)
+exten => xtn,n(done),Return()
+
+
+[predial]
+exten => xtn,1,Return
+exten => xtn,n(c1),Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1(${ARG1},CALLER,xtn,1))
+exten => xtn,n,Return
+exten => xtn,n(c1_cdr),Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1_cdr(${ARG1},CALLER,xtn,1))
+exten => xtn,n,Return
+exten => xtn,n(c2),Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c2(${ARG1},callee,xtn,1))
+exten => xtn,n,Return
+exten => xtn,n(c2_cdr),Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c2_cdr(${ARG1},callee,xtn,1))
+exten => xtn,n,Return
+
+
+[caller_context]
+exten => ans,1,Answer()
+exten => ans,n,Wait(120)
+exten => ans,n,Hangup()
+
+
+[called_context]
+exten => busy1,1,Busy()
+
+exten => ans,1,Answer()
+exten => ans,n,Wait(1)
+exten => ans,n,UserEvent(U_Connected,test: ${TEST_EXTEN},to: ${EXTEN})
+exten => ans,n,Hangup()
+
+
+[test_context]
+exten => hhandler,1,Return()
+exten => hhandler,2,UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => hhandler,3,Return()
+exten => hhandler,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => hhandler,n,Return()
+
+
+exten => no_call0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call0,2,Set(CHANNEL(hangup_handler_push)=4(${EXTEN},CALLER,${EXTEN},1))
+exten => no_call0,3,Hangup()
+exten => no_call0,4,UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => no_call0,5,Return()
+
+exten => no_call1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call1,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,${EXTEN},1))
+exten => no_call1,n,Hangup()
+exten => no_call1,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => no_call1,n,Return()
+
+exten => no_call2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call2,n,Set(CHANNEL(hangup_handler_push)=hhandler,2(${EXTEN},CALLER,hhandler,1))
+exten => no_call2,n,Hangup()
+
+exten => no_call3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call3,n,Set(CHANNEL(hangup_handler_push)=hhandler,c1(${EXTEN},CALLER,hhandler,1))
+exten => no_call3,n,Hangup()
+
+exten => no_call4,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call4,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,2(${EXTEN},CALLER,xtn,1))
+exten => no_call4,n,Hangup()
+
+exten => no_call5,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call5,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1(${EXTEN},CALLER,xtn,1))
+exten => no_call5,n,Hangup()
+
+
+exten => no_call_w_h0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call_w_h0,2,Set(CHANNEL(hangup_handler_push)=4(${EXTEN},CALLER,${EXTEN},1))
+exten => no_call_w_h0,3,Goto(test_context_h,do_hangup,1)
+exten => no_call_w_h0,4,UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => no_call_w_h0,5,Return()
+
+exten => no_call_w_h1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call_w_h1,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,${EXTEN},1))
+exten => no_call_w_h1,n,Goto(test_context_h,do_hangup,1)
+exten => no_call_w_h1,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => no_call_w_h1,n,Return()
+
+exten => no_call_w_h2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call_w_h2,n,Set(CHANNEL(hangup_handler_push)=hhandler,2(${EXTEN},CALLER,hhandler,1))
+exten => no_call_w_h2,n,Goto(test_context_h,do_hangup,1)
+
+exten => no_call_w_h3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call_w_h3,n,Set(CHANNEL(hangup_handler_push)=hhandler,c1(${EXTEN},CALLER,hhandler,1))
+exten => no_call_w_h3,n,Goto(test_context_h,do_hangup,1)
+
+exten => no_call_w_h4,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call_w_h4,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,2(${EXTEN},CALLER,xtn,1))
+exten => no_call_w_h4,n,Goto(test_context_h,do_hangup,1)
+
+exten => no_call_w_h5,1,Set(__TEST_EXTEN=${EXTEN})
+exten => no_call_w_h5,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1(${EXTEN},CALLER,xtn,1))
+exten => no_call_w_h5,n,Goto(test_context_h,do_hangup,1)
+
+
+exten => test_pop0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => test_pop0,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,${EXTEN},1))
+exten => test_pop0,n,Set(CHANNEL(hangup_handler_push)=hhandler,c1(${EXTEN},CALLER,to_be_destroyed,1))
+exten => test_pop0,n,Set(CHANNEL(hangup_handler_pop)=)
+exten => test_pop0,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1(${EXTEN},CALLER,xtn,2))
+exten => test_pop0,n,Hangup()
+exten => test_pop0,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => test_pop0,n,Return()
+
+exten => test_pop1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => test_pop1,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,${EXTEN},1))
+exten => test_pop1,n,Set(CHANNEL(hangup_handler_push)=hhandler,c1(${EXTEN},CALLER,to_be_destroyed,1))
+exten => test_pop1,n,Set(CHANNEL(hangup_handler_pop)=hhandler,xtn,c1(${EXTEN},CALLER,xtn,2))
+exten => test_pop1,n,Hangup()
+exten => test_pop1,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => test_pop1,n,Return()
+
+
+exten => test_wipe0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => test_wipe0,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,to_be_destroyed,2))
+exten => test_wipe0,n,Set(CHANNEL(hangup_handler_push)=hhandler,c1(${EXTEN},CALLER,to_be_destroyed,1))
+exten => test_wipe0,n,Set(CHANNEL(hangup_handler_wipe)=)
+exten => test_wipe0,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,${EXTEN},1))
+exten => test_wipe0,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1(${EXTEN},CALLER,xtn,2))
+exten => test_wipe0,n,Hangup()
+exten => test_wipe0,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => test_wipe0,n,Return()
+
+exten => test_wipe1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => test_wipe1,n,Set(CHANNEL(hangup_handler_push)=c1(${EXTEN},CALLER,to_be_destroyed,2))
+exten => test_wipe1,n,Set(CHANNEL(hangup_handler_push)=hhandler,c1(${EXTEN},CALLER,to_be_destroyed,1))
+exten => test_wipe1,n,Set(CHANNEL(hangup_handler_wipe)=c1(${EXTEN},CALLER,${EXTEN},1))
+exten => test_wipe1,n,Set(CHANNEL(hangup_handler_push)=hhandler,xtn,c1(${EXTEN},CALLER,xtn,2))
+exten => test_wipe1,n,Hangup()
+exten => test_wipe1,n(c1),UserEvent(U_HHandler,test: ${ARG1},which: CALLER,who: ${ARG2},exten: ${EXTEN},expected: ${ARG3},order: ${ARG4})
+exten => test_wipe1,n,Return()
+
+
+exten => single_test0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test0,n,Dial(Local/ans at called_context)
+exten => single_test0,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => single_test0,n,Hangup()
+
+exten => single_test1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test1,n,Dial(Local/ans at called_context,,b(predial^xtn^c2(${EXTEN})))
+exten => single_test1,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => single_test1,n,Hangup()
+
+exten => single_test2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test2,n,Dial(Local/ans at called_context,,B(predial^xtn^c1(${EXTEN})))
+exten => single_test2,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => single_test2,n,Hangup()
+
+exten => single_test3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test3,n,Dial(Local/ans at called_context,,B(predial^xtn^c1(${EXTEN}))b(predial^xtn^c2(${EXTEN})))
+exten => single_test3,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => single_test3,n,Hangup()
+
+
+exten => single_test_w_h0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test_w_h0,n,Set(DIAL_PARMS=Local/ans at called_context)
+exten => single_test_w_h0,n,Goto(test_context_h,dial_test,1)
+
+exten => single_test_w_h1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test_w_h1,n,Set(DIAL_PARMS=Local/ans at called_context,,b(predial^xtn^c2(${EXTEN})))
+exten => single_test_w_h1,n,Goto(test_context_h,dial_test,1)
+
+exten => single_test_w_h2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test_w_h2,n,Set(DIAL_PARMS=Local/ans at called_context,,B(predial^xtn^c1(${EXTEN})))
+exten => single_test_w_h2,n,Goto(test_context_h,dial_test,1)
+
+exten => single_test_w_h3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => single_test_w_h3,n,Set(DIAL_PARMS=Local/ans at called_context,,B(predial^xtn^c1(${EXTEN}))b(predial^xtn^c2(${EXTEN})))
+exten => single_test_w_h3,n,Goto(test_context_h,dial_test,1)
+
+
+exten => forked_test0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test0,n,Dial(Local/busy1 at called_context&Local/ans at called_context)
+exten => forked_test0,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => forked_test0,n,Hangup()
+
+exten => forked_test1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test1,n,Dial(Local/busy1 at called_context&Local/ans at called_context,,b(predial^xtn^c2(${EXTEN})))
+exten => forked_test1,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => forked_test1,n,Hangup()
+
+exten => forked_test2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test2,n,Dial(Local/busy1 at called_context&Local/ans at called_context,,B(predial^xtn^c1(${EXTEN})))
+exten => forked_test2,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => forked_test2,n,Hangup()
+
+exten => forked_test3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test3,n,Dial(Local/busy1 at called_context&Local/ans at called_context,,B(predial^xtn^c1(${EXTEN}))b(predial^xtn^c2(${EXTEN})))
+exten => forked_test3,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => forked_test3,n,Hangup()
+
+
+exten => forked_test_w_h0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test_w_h0,n,Set(DIAL_PARMS=Local/busy1 at called_context&Local/ans at called_context)
+exten => forked_test_w_h0,n,Goto(test_context_h,dial_test,1)
+
+exten => forked_test_w_h1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test_w_h1,n,Set(DIAL_PARMS=Local/busy1 at called_context&Local/ans at called_context,,b(predial^xtn^c2(${EXTEN})))
+exten => forked_test_w_h1,n,Goto(test_context_h,dial_test,1)
+
+exten => forked_test_w_h2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test_w_h2,n,Set(DIAL_PARMS=Local/busy1 at called_context&Local/ans at called_context,,B(predial^xtn^c1(${EXTEN})))
+exten => forked_test_w_h2,n,Goto(test_context_h,dial_test,1)
+
+exten => forked_test_w_h3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => forked_test_w_h3,n,Set(DIAL_PARMS=Local/busy1 at called_context&Local/ans at called_context,,B(predial^xtn^c1(${EXTEN}))b(predial^xtn^c2(${EXTEN})))
+exten => forked_test_w_h3,n,Goto(test_context_h,dial_test,1)
+
+
+exten => cdr_test0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test0,n,Dial(Local/ans at called_context)
+exten => cdr_test0,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => cdr_test0,n,Hangup()
+
+exten => cdr_test1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test1,n,Dial(Local/ans at called_context,,b(predial^xtn^c2_cdr(${EXTEN})))
+exten => cdr_test1,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => cdr_test1,n,Hangup()
+
+exten => cdr_test2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test2,n,Dial(Local/ans at called_context,,B(predial^xtn^c1_cdr(${EXTEN})))
+exten => cdr_test2,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => cdr_test2,n,Hangup()
+
+exten => cdr_test3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test3,n,Dial(Local/ans at called_context,,B(predial^xtn^c1_cdr(${EXTEN}))b(predial^xtn^c2_cdr(${EXTEN})))
+exten => cdr_test3,n,UserEvent(U_Failed,test: ${EXTEN},status: Dial continued in dialplan for ${EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => cdr_test3,n,Hangup()
+
+
+exten => cdr_test_w_h0,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test_w_h0,n,Set(DIAL_PARMS=Local/ans at called_context)
+exten => cdr_test_w_h0,n,Goto(test_context_h_cdr,dial_test,1)
+
+exten => cdr_test_w_h1,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test_w_h1,n,Set(DIAL_PARMS=Local/ans at called_context,,b(predial^xtn^c2_cdr(${EXTEN})))
+exten => cdr_test_w_h1,n,Goto(test_context_h_cdr,dial_test,1)
+
+exten => cdr_test_w_h2,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test_w_h2,n,Set(DIAL_PARMS=Local/ans at called_context,,B(predial^xtn^c1_cdr(${EXTEN})))
+exten => cdr_test_w_h2,n,Goto(test_context_h_cdr,dial_test,1)
+
+exten => cdr_test_w_h3,1,Set(__TEST_EXTEN=${EXTEN})
+exten => cdr_test_w_h3,n,Set(DIAL_PARMS=Local/ans at called_context,,B(predial^xtn^c1_cdr(${EXTEN}))b(predial^xtn^c2_cdr(${EXTEN})))
+exten => cdr_test_w_h3,n,Goto(test_context_h_cdr,dial_test,1)
+
+
+[test_context_h]
+exten => h,1,UserEvent(U_HExten,test: ${TEST_EXTEN},channel: ${CHANNEL(name)})
+
+exten => do_hangup,1,Hangup
+
+exten => dial_test,1,Dial(${DIAL_PARMS})
+exten => dial_test,n,UserEvent(U_Failed,test: ${TEST_EXTEN},status: Dial continued in dialplan for ${TEST_EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => dial_test,n,Hangup()
+
+
+[test_context_h_cdr]
+exten => h,1,Gosub(check_cdr,xtn,1(h-exten))
+exten => h,n,UserEvent(U_HExten,test: ${TEST_EXTEN},channel: ${CHANNEL(name)})
+
+exten => dial_test,1,Dial(${DIAL_PARMS})
+exten => dial_test,n,UserEvent(U_Failed,test: ${TEST_EXTEN},status: Dial continued in dialplan for ${TEST_EXTEN}. DIALSTATUS=${DIALSTATUS})
+exten => dial_test,n,Hangup()
Propchange: asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/hangup/handlers/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/hangup/handlers/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/hangup/handlers/run-test?view=auto&rev=3400
==============================================================================
--- asterisk/trunk/tests/hangup/handlers/run-test (added)
+++ asterisk/trunk/tests/hangup/handlers/run-test Fri Aug 3 10:21:40 2012
@@ -1,0 +1,408 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Richard Mudgett <rmudgett at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.TestCase import TestCase
+
+logger = logging.getLogger(__name__)
+
+
+class HHandlerTest(TestCase):
+ def __init__(self):
+ TestCase.__init__(self)
+
+ self.test_complete = False
+
+ # Total number of subtests run
+ self.test_count = 0
+ # Number of subtests that passed
+ self.pass_count = 0
+
+ self.tests = []
+ self.tests.append(self.series_no_call)
+ self.tests.append(self.series_no_call_w_h)
+ self.tests.append(self.series_test_pop)
+ self.tests.append(self.series_test_wipe)
+ self.tests.append(self.series_single_test)
+ self.tests.append(self.series_single_test_w_h)
+ self.tests.append(self.series_forked_test)
+ self.tests.append(self.series_forked_test_w_h)
+ self.tests.append(self.series_cdr_test)
+ self.tests.append(self.series_cdr_test_w_h)
+
+ self.subtests = []
+
+ # Create an Asterisk instance ...
+ self.create_asterisk()
+
+ def results_reset(self):
+ results = dict(hangup_count = 0,
+ hexten_count = 0,
+ hhandler_in_count = 0,
+ hhandler_out_count = 0,
+ connected_count = 0,
+ saw_failed = False)
+ return results
+
+ def subtest_default(self):
+ subtest = dict(name = "idiot",
+ hangup_count = 0,
+ hexten_count = 0,
+ hhandler_in_count = 0,
+ hhandler_out_count = 0,
+ connected_count = 0,
+ check_order = False)
+ return subtest
+
+ # Create no_call subtest series
+ def series_no_call(self):
+ series = []
+ test_number = 0
+ while test_number < 6:
+ subtest = self.subtest_default()
+ subtest['name'] = "no_call%d" % test_number
+ subtest['hangup_count'] = 2
+ subtest['hhandler_in_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create no_call_w_h subtest series
+ def series_no_call_w_h(self):
+ series = []
+ test_number = 0
+ while test_number < 6:
+ subtest = self.subtest_default()
+ subtest['name'] = "no_call_w_h%d" % test_number
+ subtest['hangup_count'] = 2
+ subtest['hexten_count'] = 1
+ subtest['hhandler_in_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create test_pop subtest series
+ def series_test_pop(self):
+ series = []
+ test_number = 0
+ while test_number < 2:
+ subtest = self.subtest_default()
+ subtest['name'] = "test_pop%d" % test_number
+ subtest['hangup_count'] = 2
+ subtest['hhandler_in_count'] = 2
+
+ subtest['check_order'] = True
+ subtest['order'] = subtest['hhandler_in_count']
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create test_wipe subtest series
+ def series_test_wipe(self):
+ series = []
+ test_number = 0
+ while test_number < 2:
+ subtest = self.subtest_default()
+ subtest['name'] = "test_wipe%d" % test_number
+ subtest['hangup_count'] = 2
+ subtest['hhandler_in_count'] = 2
+
+ subtest['check_order'] = True
+ subtest['order'] = subtest['hhandler_in_count']
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create single_test subtest series
+ def series_single_test(self):
+ series = []
+ test_number = 0
+ while test_number < 4:
+ subtest = self.subtest_default()
+ subtest['name'] = "single_test%d" % test_number
+ subtest['hangup_count'] = 4
+ if test_number & 0x02:
+ subtest['hhandler_in_count'] = 1
+ if test_number & 0x01:
+ subtest['hhandler_out_count'] = 1
+ subtest['connected_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create single_test_w_h subtest series
+ def series_single_test_w_h(self):
+ series = []
+ test_number = 0
+ while test_number < 4:
+ subtest = self.subtest_default()
+ subtest['name'] = "single_test_w_h%d" % test_number
+ subtest['hangup_count'] = 4
+ subtest['hexten_count'] = 1
+ if test_number & 0x02:
+ subtest['hhandler_in_count'] = 1
+ if test_number & 0x01:
+ subtest['hhandler_out_count'] = 1
+ subtest['connected_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create forked_test subtest series
+ def series_forked_test(self):
+ series = []
+ test_number = 0
+ while test_number < 4:
+ subtest = self.subtest_default()
+ subtest['name'] = "forked_test%d" % test_number
+ subtest['hangup_count'] = 6
+ if test_number & 0x02:
+ subtest['hhandler_in_count'] = 1
+ if test_number & 0x01:
+ subtest['hhandler_out_count'] = 2
+ subtest['connected_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create forked_test_w_h subtest series
+ def series_forked_test_w_h(self):
+ series = []
+ test_number = 0
+ while test_number < 4:
+ subtest = self.subtest_default()
+ subtest['name'] = "forked_test_w_h%d" % test_number
+ subtest['hangup_count'] = 6
+ subtest['hexten_count'] = 1
+ if test_number & 0x02:
+ subtest['hhandler_in_count'] = 1
+ if test_number & 0x01:
+ subtest['hhandler_out_count'] = 2
+ subtest['connected_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create cdr_test subtest series
+ def series_cdr_test(self):
+ series = []
+ test_number = 0
+ while test_number < 4:
+ subtest = self.subtest_default()
+ subtest['name'] = "cdr_test%d" % test_number
+ subtest['hangup_count'] = 4
+ if test_number & 0x02:
+ subtest['hhandler_in_count'] = 1
+ if test_number & 0x01:
+ subtest['hhandler_out_count'] = 1
+ subtest['connected_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Create cdr_test_w_h subtest series
+ def series_cdr_test_w_h(self):
+ series = []
+ test_number = 0
+ while test_number < 4:
+ subtest = self.subtest_default()
+ subtest['name'] = "cdr_test_w_h%d" % test_number
+ subtest['hangup_count'] = 4
+ subtest['hexten_count'] = 1
+ if test_number & 0x02:
+ subtest['hhandler_in_count'] = 1
+ if test_number & 0x01:
+ subtest['hhandler_out_count'] = 1
+ subtest['connected_count'] = 1
+
+ series.append(subtest)
+ test_number += 1
+
+ return series
+
+ # Initiate next test call.
+ def initiate_next_test(self, ami):
+ if not len(self.subtests):
+ # Current subtest series is complete.
+ if not len(self.tests):
+ # Evaluate overall test result and end test.
+ if self.test_count == self.pass_count:
+ self.passed = True
+ self.stop_reactor()
+ return
+
+ # Generate the next series of subtests.
+ self.subtests = self.tests.pop(0)()
+
+ # Setup the next test to run.
+ self.expected = self.subtests.pop(0)
+
+ # Reset UserEvent counts and flags.
+ self.results = self.results_reset()
+
+ self.test_count += 1
+
+ # Originate the test call.
+ logger.info("Starting Test %s" % self.expected['name'])
+ df = ami.originate(channel = "Local/ans at caller_context", exten = self.expected['name'], context = "test_context", priority = 1)
+ df.addErrback(self.handleOriginateFailure)
+
+ # Called when got UserEvent event from the Asterisk instance
+ def evt_userevent(self, ami, event):
+ if self.test_complete:
+ return
+ # We want the AMI UserEvent header but the headers put
+ # in as dictionary keys are lowercased.
+ hdr_event = event.get("userevent")
+ hdr_test = event.get("test")
+
+ if hdr_test != self.expected['name']:
+ logger.debug("Stale Test: " + hdr_test + " UserEvent: " + hdr_event + " Expected-test: " + self.expected['name'])
+ return
+
+ if hdr_event == "U_HHandler":
+ hdr_which = event.get("which")
+ hdr_who = event.get("who")
+ hdr_exten = event.get("exten")
+ hdr_expected = event.get("expected")
+ hdr_order = event.get("order")
+ logger.debug("Test: " + hdr_test + " UserEvent: " + hdr_event \
+ + " which: " + hdr_which + " who: " + hdr_who + " exten: " + hdr_exten \
+ + " expected: " + hdr_expected + " order: " + hdr_order)
+ if hdr_exten != hdr_expected:
+ logger.warning("Test: " + hdr_test + " UserEvent: " + hdr_event \
+ + " exten: " + hdr_exten + " expected: " + hdr_expected + " Does not match!")
+ return
+ if hdr_exten != "hhandler" and hdr_exten != "xtn" and hdr_exten != hdr_test:
+ logger.warning("Test: " + hdr_test + " UserEvent: " + hdr_event \
+ + " exten: " + hdr_exten + " is unknown")
+ return
+ if hdr_which != hdr_who:
+ logger.warning("Test: " + hdr_test + " UserEvent: " + hdr_event \
+ + " which: " + hdr_which + " who: " + hdr_who + " Does not match!")
+ return
+ if self.expected['check_order']:
+ if self.expected['order'] != int(hdr_order):
+ logger.warning("Test: " + hdr_test + " UserEvent: " + hdr_event \
+ + " order: " + hdr_order \
+ + " Expected order: " + str(self.expected['order']))
+ return
+ self.expected['order'] -= 1
+ if hdr_which == "CALLER":
+ self.results['hhandler_in_count'] += 1
+ elif hdr_which == "callee":
+ self.results['hhandler_out_count'] += 1
+ else:
+ logger.warning("Test: " + hdr_test + " UserEvent: " + hdr_event + " which: " + hdr_which + " is unknown")
+ return
+ if hdr_event == "U_Connected":
+ hdr_to = event.get("to")
+ logger.debug("Test: " + hdr_test + " UserEvent: " + hdr_event + " to: " + hdr_to)
+ self.results['connected_count'] += 1
+ return
+ if hdr_event == "U_Failed":
+ hdr_status = event.get("status")
+ logger.warning("Test: " + hdr_test + " Fail status: " + hdr_status)
+ self.results['saw_failed'] = True
+ return
+ if hdr_event == "U_HExten":
+ hdr_channel = event.get("channel")
+ logger.debug("Test: " + hdr_test + " UserEvent: " + hdr_event + " channel: " + hdr_channel)
+ if self.results['hhandler_in_count'] != 0:
+ logger.warning("Test: " + hdr_test + " UserEvent: " + hdr_event + " h exten after hangup handler.")
+ return
+ self.results['hexten_count'] += 1
+ return
+ logger.debug("Test: " + hdr_test + " UserEvent: " + hdr_event + " Unknown UserEvent")
+
+ # Called when got Hangup event from the Asterisk instance
+ def evt_hangup(self, ami, event):
+ if self.test_complete:
+ return
+ self.results['hangup_count'] += 1
+ if self.results['hangup_count'] != self.expected['hangup_count']:
+ return
+
+ # Evaluate subtest result
+ if not self.results['saw_failed'] \
+ and self.results['connected_count'] == self.expected['connected_count'] \
+ and self.results['hexten_count'] == self.expected['hexten_count'] \
+ and self.results['hhandler_in_count'] == self.expected['hhandler_in_count'] \
+ and self.results['hhandler_out_count'] == self.expected['hhandler_out_count']:
+ self.pass_count += 1
+ else:
+ logger.warning("Test " + self.expected['name'] \
+ + " connected:" + str(self.results['connected_count']) \
+ + " h-exten:" + str(self.results['hexten_count']) \
+ + " hhandler in:" + str(self.results['hhandler_in_count']) \
+ + " out:" + str(self.results['hhandler_out_count']) \
+ )
+ logger.warning("Test " + self.expected['name'] + " failed")
+
+ # Give each subtest the full time
+ self.reset_timeout()
+
+ self.initiate_next_test(ami)
+
+ # This is called for each AMI connection established.
+ def ami_connect(self, ami):
+ # Add AMI event triggers
+ # Ast1 events to handle
+ self.ami[ami.id].registerEvent("UserEvent", self.evt_userevent)
+ self.ami[ami.id].registerEvent("Hangup", self.evt_hangup)
+ self.initiate_next_test(ami)
+
+ # This is called when the reactor has started running.
+ def run(self):
+ TestCase.run(self)
+ self.create_ami_factory()
+
+ # This is called when we stop the reactor.
+ def stop_reactor(self):
+ self.test_complete = True
+
+ TestCase.stop_reactor(self)
+
+
+def main():
+ # Run Hangup Handler Test
+ test = HHandlerTest()
+ reactor.run()
+ if test.passed:
+ logger.info("Test passed")
+ return 0
+ return 1
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
Propchange: asterisk/trunk/tests/hangup/handlers/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/hangup/handlers/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/hangup/handlers/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/hangup/handlers/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/hangup/handlers/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/hangup/handlers/test-config.yaml?view=auto&rev=3400
==============================================================================
--- asterisk/trunk/tests/hangup/handlers/test-config.yaml (added)
+++ asterisk/trunk/tests/hangup/handlers/test-config.yaml Fri Aug 3 10:21:40 2012
@@ -1,0 +1,14 @@
+testinfo:
+ summary: 'Test hangup handler subroutines (endbeforehexten=no)'
+ description: |
+ 'When a call is terminated, the user has the option of running an h exten
+ and/or hangup handler dialplan subroutines. This test verifies that the
+ expected dialplan hangup locations are executed.
+ Tests run with endbeforehexten=no'
+
+properties:
+ minversion: '11.0.0'
+ dependencies:
+ - asterisk: 'app_dial'
+ tags:
+ - hangup
Propchange: asterisk/trunk/tests/hangup/handlers/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/hangup/handlers/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/hangup/handlers/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/hangup/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/hangup/tests.yaml?view=auto&rev=3400
==============================================================================
--- asterisk/trunk/tests/hangup/tests.yaml (added)
+++ asterisk/trunk/tests/hangup/tests.yaml Fri Aug 3 10:21:40 2012
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - test: 'handlers'
Propchange: asterisk/trunk/tests/hangup/tests.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/hangup/tests.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/hangup/tests.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=3400&r1=3399&r2=3400
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Fri Aug 3 10:21:40 2012
@@ -19,6 +19,7 @@
- dir: 'agi'
- dir: 'pbx'
- test: 'predial'
+ - dir: 'hangup'
- dir: 'fax'
- dir: 'apps'
- dir: 'funcs'
More information about the asterisk-commits
mailing list