[asterisk-commits] rmudgett: testsuite/asterisk/trunk r3545 - in /asterisk/trunk/tests/dialplan:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 27 18:58:50 CST 2012
Author: rmudgett
Date: Tue Nov 27 18:58:44 2012
New Revision: 3545
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3545
Log:
Update testsuite dialplan pattern matching test.
Add tests to check for failing patterns reported in ASTERISK-19205.
(issue ASTERISK-19205)
Review: https://reviewboard.asterisk.org/r/2203/
Modified:
asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf
asterisk/trunk/tests/dialplan/run-test
asterisk/trunk/tests/dialplan/test-config.yaml
Modified: asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf?view=diff&rev=3545&r1=3544&r2=3545
==============================================================================
--- asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf Tue Nov 27 18:58:44 2012
@@ -10,8 +10,8 @@
[DialContext]
exten => s,1,NoOp()
- same => n,Answer()
- same => n,Echo()
+ same => n,Answer()
+ same => n,Echo()
; ------------------------------------------------------------------
; The main test context
@@ -28,8 +28,8 @@
same => n(top),NoOp()
same => n,GotoIf($[${Result} != OK]?result_fail,1)
same => n,Set(TestCounter=${INC(TestCounter)})
- same => n,UserEvent(TestStatus, message: Starting test ${TestCounter})
- same => n,Verbose(Starting test ${TestCounter})
+ same => n,UserEvent(TestStatus,message: Starting test ${TestCounter})
+ same => n,NoOp(Starting test ${TestCounter})
; test numerical extensions
same => n,ExecIf($[${TestCounter} = 1]?Goto(patterns,100,1))
@@ -46,6 +46,21 @@
same => n,ExecIf($[${TestCounter} = 8]?Goto(patterns,cbaz,1))
same => n,ExecIf($[${TestCounter} = 9]?Goto(patterns,cbazy,1))
+ ; test ignoring dash (Added as a result of ASTERISK-19205)
+ same => n,ExecIf($[${TestCounter} = 15]?Goto(patterns,RG-10111-9999,1))
+ same => n,ExecIf($[${TestCounter} = 16]?Goto(patterns,RG-20111-9999,1))
+ same => n,ExecIf($[${TestCounter} = 17]?Goto(patterns,foo-1,1))
+ same => n,ExecIf($[${TestCounter} = 18]?Goto(patterns,foo-2,1))
+ same => n,ExecIf($[${TestCounter} = 19]?Goto(patterns,foo-,1))
+ same => n,ExecIf($[${TestCounter} = 20]?Goto(patterns,bar-1,1))
+ same => n,ExecIf($[${TestCounter} = 21]?Goto(patterns,bar-2,1))
+
+ ; test subtle matching order of sets of the same size starting with the same char.
+ same => n,ExecIf($[${TestCounter} = 22]?Goto(patterns,Set-2,1))
+
+ ; test ignoring empty set
+ same => n,ExecIf($[${TestCounter} = 23]?Goto(patterns,955,1))
+
; end of pattern match testing
; test dialplan functions
@@ -61,74 +76,137 @@
same => n,Goto(result_pass,1)
exten => result_pass,1,NoOp()
- same => n,Set(TestResult=True)
+ same => n,UserEvent(TestResult,result: Success)
+ same => n,Set(ResultSent=OK)
same => n,Hangup()
exten => result_fail,1,NoOp()
- same => n,Set(TestResult=False)
- same => n,UserEvent(TestStatus, message: ${TestCounter} failed!)
+ same => n,UserEvent(TestResult,result: Fail,message: Test ${TestCounter} failed.)
+ same => n,Set(ResultSent=OK)
same => n,Hangup()
-exten => h,1,UserEvent(TestResult, result: ${TestResult})
+exten => h,1,NoOp()
+ same => n,GotoIf($[${ResultSent} = OK]?done)
+ same => n,UserEvent(TestResult,result: Fail,message: Unexpected hangup on test ${TestCounter}.)
+ same => n(done),NoOp()
; ---------------------------------------------------------------
; Pattern matching tests
; ---------------------------------------------------------------
[patterns]
+exten => i,1,NoOp(Invalid exten)
+ same => n,Set(Result=Fail)
+ same => n,Goto(test,start,top)
+
; *** Patterns to match
exten => 100,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '100')
+ same => n,NoOp(Extension '${EXTEN}' matched on '100')
same => n,Set(Result=${IF($[${TestCounter} = 1]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _1X[0-5],1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_1X[0-5]')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_1X[0-5]')
same => n,Set(Result=${IF($[${TestCounter} = 2]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _1XX,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_1XX')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_1XX')
same => n,Set(Result=${IF($[${TestCounter} = 3]?OK:Fail)})
same => n,Goto(test,start,top)
exten => abc,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on 'abc')
+ same => n,NoOp(Extension '${EXTEN}' matched on 'abc')
same => n,Set(Result=${IF($[${TestCounter} = 4]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _[a][b][c]X,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_[a][b][c]X')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_[a][b][c]X')
same => n,Set(Result=${IF($[${TestCounter} = 5]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _[a][b][c]N,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_[a][b][c]N')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_[a][b][c]N')
same => n,Set(Result=${IF($[${TestCounter} = 6]?OK:Fail)})
same => n,Goto(test,start,top)
exten => cba,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on 'cba')
+ same => n,NoOp(Extension '${EXTEN}' matched on 'cba')
same => n,Set(Result=${IF($[${TestCounter} = 7]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _[c][b][a]!,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_[c][b][a]!')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_[c][b][a]!')
same => n,Set(Result=${IF($[${TestCounter} = 8]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _[c][b][a][z].,1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_[c][b][a][z].')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_[c][b][a][z].')
same => n,Set(Result=${IF($[${TestCounter} = 9]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _1[5][0-5],1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_1[5][0-5]')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_1[5][0-5]')
same => n,Set(Result=${IF($[${TestCounter} = 10]?OK:Fail)})
same => n,Goto(test,start,top)
exten => _[1-2][5][0-5],1,NoOp()
- same => n,Set(2,Extension '${EXTEN}' matched on '_[1-2][5][0-5]')
+ same => n,NoOp(Extension '${EXTEN}' matched on '_[1-2][5][0-5]')
same => n,Set(Result=${IF($[${TestCounter} = 11]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => _RG-101-.,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_RG-101-.')
+ same => n,Set(Result=Fail)
+ same => n,Goto(test,start,top)
+
+exten => _RG-10111-.,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_RG-10111-.')
+ same => n,Set(Result=${IF($[${TestCounter} = 15]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => _RG-201.,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_RG-201.')
+ same => n,Set(Result=Fail)
+ same => n,Goto(test,start,top)
+
+exten => _RG-20111.,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_RG-20111.')
+ same => n,Set(Result=${IF($[${TestCounter} = 16]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => foo-1,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on 'foo-1')
+ same => n,Set(Result=${IF($[${TestCounter} = 17]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => _foo-!,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_foo-!')
+ same => n,Set(Result=${IF($[${TestCounter} = 18 | ${TestCounter} = 19]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => bar-1,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on 'bar-1')
+ same => n,Set(Result=${IF($[${TestCounter} = 20]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => _bar.,1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_bar.')
+ same => n,Set(Result=${IF($[${TestCounter} = 21]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => _Set-[0-9],1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_Set-[0-9]')
+ same => n,Set(Result=${IF($[${TestCounter} = 22]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+exten => _Set-[02-9a],1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_Set-[02-9a]')
+ same => n,Set(Result=Fail)
+ same => n,Goto(test,start,top)
+
+exten => _9[]5[0-5],1,NoOp()
+ same => n,NoOp(Extension '${EXTEN}' matched on '_9[]5[0-5]')
+ same => n,Set(Result=${IF($[${TestCounter} = 23]?OK:Fail)})
same => n,Goto(test,start,top)
; ---------------------------------------------------------------
@@ -139,11 +217,11 @@
same => n,Set(Encoded=YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODk=)
same => n,Set(Decoded=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789)
same => n,Set(EncodingResult=${BASE64_ENCODE(${Decoded})})
- same => n,Set(TestResult=${IF($["${EncodingResult}" = "${Encoded}"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${EncodingResult}" = "${Encoded}"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(DecodingResult=${BASE64_DECODE(${Encoded})})
- same => n,Set(TestResult=${IF($["${DecodingResult}" = "${Decoded}"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${DecodingResult}" = "${Decoded}"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Goto(test,start,top)
[aes]
@@ -152,11 +230,11 @@
same => n,Set(Encoded=KfAgilzmckUn1bH3NNLFHKfHA36w2EAHJvJvWqEQSSwdLroipj/Cp+dVt2FtjxBXT30cQcQiM0Plgb20pTqPAw==)
same => n,Set(Decoded=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789)
same => n,Set(EncodingResult=${AES_ENCRYPT(${Key},${Decoded})})
- same => n,Set(TestResult=${IF($["${EncodingResult}" = "${Encoded}"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${EncodingResult}" = "${Encoded}"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(DecodingResult=${AES_DECRYPT(${Key},${Encoded})})
- same => n,Set(TestResult=${IF($["${DecodingResult}" = "${Decoded}"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${DecodingResult}" = "${Decoded}"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Goto(test,start,top)
; ------------------------------------------------------------------
@@ -168,16 +246,16 @@
; note that the \ here gets removed by the config parser
same => n,Set(MyStr=\;)
same => n,Set(LenResult=${LEN(${MyStr})})
- same => n,Set(TestResult=${IF($["${LenResult}" = "1"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${LenResult}" = "1"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(MyStr=)
same => n,Set(LenResult=${LEN(${MyStr})})
- same => n,Set(TestResult=${IF($["${LenResult}" = "0"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${LenResult}" = "0"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(MyStr=asdf)
same => n,Set(LenResult=${LEN(${MyStr})})
- same => n,Set(TestResult=${IF($["${LenResult}" = "4"]?OK:Fail)})
- same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Set(Result=${IF($["${LenResult}" = "4"]?OK:Fail)})
+ same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Goto(test,start,top)
; ------------------------------------------------------------------
Modified: asterisk/trunk/tests/dialplan/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/dialplan/run-test?view=diff&rev=3545&r1=3544&r2=3545
==============================================================================
--- asterisk/trunk/tests/dialplan/run-test (original)
+++ asterisk/trunk/tests/dialplan/run-test Tue Nov 27 18:58:44 2012
@@ -9,7 +9,6 @@
import sys
import logging
-
from twisted.internet import reactor
sys.path.append("lib/python")
@@ -17,8 +16,8 @@
logger = logging.getLogger(__name__)
+
class DialPlanTest(TestCase):
-
def __init__(self):
super(DialPlanTest, self).__init__()
self.create_asterisk()
@@ -28,15 +27,12 @@
self.create_ami_factory()
def ami_connect(self, ami):
- super(DialPlanTest, self).ami_connect(ami)
-
ami.registerEvent("UserEvent", self.ami_UserEvent)
ami.originate(
- channel = "Local/s at DialContext",
- exten = "s",
- priority = "1",
- context = "test"
- )
+ channel = "Local/s at DialContext",
+ exten = "s",
+ priority = "1",
+ context = "test")
def ami_UserEvent(self, ami, event):
event_type = event.get("userevent")
@@ -45,25 +41,23 @@
if event_type == "TestResult":
result = event.get("result")
- if result == "True":
+ if result == "Success":
self.passed = True
- logger.info('Test passed!')
else:
- self.passed = False
- logger.warn('Test failed!')
+ message = event.get("message")
+ logger.warning("Failure: " + str(message))
self.stop_reactor()
elif event_type == "TestStatus":
message = event.get("message")
logger.debug(message)
else:
- logger.warn("Unknown event type %s received" % event_type)
+ logger.warning("Unknown event type %s received" % event_type)
-def main(argv=None):
+def main():
test = DialPlanTest()
- test.start_asterisk()
reactor.run()
- test.stop_asterisk()
if test.passed:
+ logger.info("Test passed")
return 0
return 1
Modified: asterisk/trunk/tests/dialplan/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/dialplan/test-config.yaml?view=diff&rev=3545&r1=3544&r2=3545
==============================================================================
--- asterisk/trunk/tests/dialplan/test-config.yaml (original)
+++ asterisk/trunk/tests/dialplan/test-config.yaml Tue Nov 27 18:58:44 2012
@@ -6,7 +6,7 @@
looping, etc.
properties:
- minversion: '1.8.0.0'
+ minversion: '1.8.20.0'
dependencies:
- python : 'twisted'
- python : 'starpy'
More information about the asterisk-commits
mailing list