[svn-commits] mjordan: testsuite/asterisk/trunk r2900 - in /asterisk/trunk/tests: ./ dialpl...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Dec 14 17:03:50 CST 2011
Author: mjordan
Date: Wed Dec 14 17:03:46 2011
New Revision: 2900
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2900
Log:
Add basic dialplan tests to the testsuite
This patch adds a dialplan test to the testsuite. The dialplan itself
contains a number of tests that exercise basic dialplna functions and
applications.
This test is meant as a starting point for additional work - not all
dialplan functions/apps are currently tested, but markers for future
additions have been added to the supplied extensions.conf.
(closes issue ASTERISK-18036)
Reported by: Leif Madsen
patch: dialplan-pattern-match-tests.patch.txt (License #4999)
Review: https://reviewboard.asterisk.org/r/1621/
Added:
asterisk/trunk/tests/dialplan/
asterisk/trunk/tests/dialplan/configs/
asterisk/trunk/tests/dialplan/configs/ast1/
asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/dialplan/run-test (with props)
asterisk/trunk/tests/dialplan/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf?view=auto&rev=2900
==============================================================================
--- asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf Wed Dec 14 17:03:46 2011
@@ -1,0 +1,208 @@
+; The run-test script will call into the [test] context and iteratively
+; execute a test within this dialplan. Each test, when finished, should
+; execute a Goto statement to return to test,start,top.
+;
+; Tests are organized by dialplan function and can be added below.
+
+; ------------------------------------------------------------------
+; Context used to connect the local channel with the tests
+; ------------------------------------------------------------------
+[DialContext]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Echo()
+
+; ------------------------------------------------------------------
+; The main test context
+; ------------------------------------------------------------------
+[test]
+exten => s,1,NoOp()
+ same => n,Goto(start,1)
+
+; Start of a test. Each test should begin by starting at the top
+; label in this extension.
+exten => start,1,NoOp()
+ same => n,Set(TestCounter=0)
+ same => n,Set(Result=OK)
+ 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})
+
+ ; test numerical extensions
+ same => n,ExecIf($[${TestCounter} = 1]?Goto(patterns,100,1))
+ same => n,ExecIf($[${TestCounter} = 2]?Goto(patterns,101,1))
+ same => n,ExecIf($[${TestCounter} = 3]?Goto(patterns,106,1))
+ same => n,ExecIf($[${TestCounter} = 10]?Goto(patterns,155,1))
+ same => n,ExecIf($[${TestCounter} = 11]?Goto(patterns,255,1))
+
+ ; test alpha extensions
+ same => n,ExecIf($[${TestCounter} = 4]?Goto(patterns,abc,1))
+ same => n,ExecIf($[${TestCounter} = 5]?Goto(patterns,abc0,1))
+ same => n,ExecIf($[${TestCounter} = 6]?Goto(patterns,abc2,1))
+ same => n,ExecIf($[${TestCounter} = 7]?Goto(patterns,cba,1))
+ same => n,ExecIf($[${TestCounter} = 8]?Goto(patterns,cbaz,1))
+ same => n,ExecIf($[${TestCounter} = 9]?Goto(patterns,cbazy,1))
+
+ ; end of pattern match testing
+
+ ; test dialplan functions
+ same => n,ExecIf($[${TestCounter} = 12]?Goto(base64,start,1))
+ same => n,ExecIf($[${TestCounter} = 13]?Goto(aes,start,1))
+
+ ; ---------------------------------------------------------------
+ ; NOTE: Add additional dialplan tests before the
+ ; Goto(result_pass,1) statement
+ ; ---------------------------------------------------------------
+
+ same => n,Goto(result_pass,1)
+
+exten => result_pass,1,NoOp()
+ same => n,Set(TestResult=True)
+ same => n,Hangup()
+
+exten => result_fail,1,NoOp()
+ same => n,Set(TestResult=False)
+ same => n,UserEvent(TestStatus, message: ${TestCounter} failed!)
+ same => n,Hangup()
+
+exten => h,1,UserEvent(TestResult, result: ${TestResult})
+
+; ---------------------------------------------------------------
+; Pattern matching tests
+; ---------------------------------------------------------------
+[patterns]
+; *** Patterns to match
+exten => 100,1,NoOp()
+ same => n,Set(2,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,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,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,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,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,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,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,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,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,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,Set(Result=${IF($[${TestCounter} = 11]?OK:Fail)})
+ same => n,Goto(test,start,top)
+
+; ---------------------------------------------------------------
+; Encryption
+; ---------------------------------------------------------------
+[base64]
+exten => start,1,NoOp()
+ 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(DecodingResult=${BASE64_DECODE(${Encoded})})
+ same => n,Set(TestResult=${IF($["${DecodingResult}" = "${Decoded}"]?OK:Fail)})
+ same => n,GotoIf($[${TestResult} = Fail]?test,result_fail,1)
+ same => n,Goto(test,start,top)
+
+[aes]
+exten => start,1,NoOp()
+ same => n,Set(Key=1qaz2wsx3edc4rfv)
+ 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(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,Goto(test,start,top)
+
+; ------------------------------------------------------------------
+; STRING (LEN, CUT, ISNULL, EXISTS)
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; REPLACE()
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; IF
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; DIGESTS (MD5, SHA1)
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; DEC / INC
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; SHELL
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; FIELDNUM / FIELDQTY
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; AstDB functions
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; POP, PUSH, SHIFT, UNSHIFT
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; URIENCODE, URIDECODE
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; VALID_EXTEN
+; ------------------------------------------------------------------
+
+; ------------------------------------------------------------------
+; While / ExitWhile
+; ------------------------------------------------------------------
+
Propchange: asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/dialplan/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/dialplan/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/dialplan/run-test?view=auto&rev=2900
==============================================================================
--- asterisk/trunk/tests/dialplan/run-test (added)
+++ asterisk/trunk/tests/dialplan/run-test Wed Dec 14 17:03:46 2011
@@ -1,0 +1,74 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2011, Digium, Inc.
+Paul Belanger <pabelanger 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 DialPlanTest(TestCase):
+
+ def __init__(self):
+ super(DialPlanTest, self).__init__()
+ self.create_asterisk()
+
+ def run(self):
+ super(DialPlanTest, self).run()
+ 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"
+ )
+
+ def ami_UserEvent(self, ami, event):
+ event_type = event.get("userevent")
+ if event_type != "TestResult" and event_type != "TestStatus":
+ return
+
+ if event_type == "TestResult":
+ result = event.get("result")
+ if result == "True":
+ self.passed = True
+ logger.info('Test passed!')
+ else:
+ self.passed = False
+ logger.warn('Test failed!')
+ self.stop_reactor()
+ elif event_type == "TestStatus":
+ message = event.get("message")
+ logger.debug(message)
+ else:
+ logger.warn("Unknown event type %s received" % event_type)
+
+def main(argv=None):
+ test = DialPlanTest()
+ test.start_asterisk()
+ reactor.run()
+ test.stop_asterisk()
+ if 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/dialplan/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/dialplan/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/dialplan/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/dialplan/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/dialplan/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/dialplan/test-config.yaml?view=auto&rev=2900
==============================================================================
--- asterisk/trunk/tests/dialplan/test-config.yaml (added)
+++ asterisk/trunk/tests/dialplan/test-config.yaml Wed Dec 14 17:03:46 2011
@@ -1,0 +1,12 @@
+testinfo:
+ summary: 'Test a variety of dialplan functions and features'
+ description: |
+ This test verifies a number of dialplan specific functions and features. This includes,
+ but is not limited to, pattern matching, Goto, GotoIf, math functions, string functions,
+ looping, etc.
+
+properties:
+ minversion: '1.6.2'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
Propchange: asterisk/trunk/tests/dialplan/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/dialplan/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/dialplan/test-config.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=2900&r1=2899&r2=2900
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Wed Dec 14 17:03:46 2011
@@ -7,6 +7,7 @@
- dir: 'iax2'
- dir: 'cdr'
- test: 'directed_pickup'
+ - test: 'dialplan'
- test: 'func_srv'
- dir: 'channels'
- test: 'udptl'
More information about the svn-commits
mailing list