[asterisk-dev] [Code Review] Unit test for diaplan pattern matching
Mark Michelson
mmichelson at digium.com
Sun Feb 14 19:56:16 CST 2010
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/504/
-----------------------------------------------------------
(Updated 2010-02-14 19:56:16.769120)
Review request for Asterisk Developers, Jared Smith and lmadsen.
Changes
-------
Uploaded new diff with shorter line lengths.
Summary
-------
Here I present a test module for testing pattern matching in the dialplan.
This is a unit test that runs within Asterisk, so all of the test inputs come from the test code itself. The test is based on a series of arrays that define contexts to create, extensions to place into those contexts, and finally test patterns to run against the dialplan that gets built. The test is designed such that adding new contexts, extensions, or test patterns to the test is as simple as adding new rows of information to arrays. The comments in the test code should be clear enough to show how this is done.
Currently, the test does not do very much. Only two contexts and three extensions are registered, and four test patterns are attempted to be matched. Right now though, I'm more concerned with the validity of the design of the test itself, as well as its current method of execution. By placing a test with a solid foundation into subversion, even with few actual test cases, people will have easier access to add new test cases as necessary.
I have placed this test in a new module called tests/test_pbx.c. Within this module, I expect other tests to be implemented which pertain to the PBX core as well. Other suggestions that have arisen during discussions are tests that actually run a PBX on a channel so that it can be ensured that the priorities execute in the proper order and so that statements such as Goto go to the proper place depending on data at the time of its use.
This addresses bug 16809.
https://issues.asterisk.org/view.php?id=16809
Diffs (updated)
-----
/trunk/tests/test_pbx.c PRE-CREATION
Diff: https://reviewboard.asterisk.org/r/504/diff
Testing
-------
Currently, the test builds the following dialplan (comments added for easy explanation of test pattern matching):
[test_pattern]
include => test_pattern_include
exten => _2.,1,Noop(_2.) ; line 1
exten => 2000,1,Noop(2000) ; line 2
[test_pattern_include]
exten => 2000,2,Noop(2000) ; line 3
The following test patterns exist:
1. exten: 200, context: test_pattern, priority: 1 ; matches line 1 as expected
2. exten: 2000, context: test_pattern, priority: 1 ; matches line 2 as expected
3. exten: 2000, context: test_pattern, priority: 2 ; matches line 3 as expected
4. exten: 2000, context: test_pattern_include, priority: 2 ; matches line 3 as expected
As stated earlier, this is by no means exhaustive. It is, however, a good starting point and should demonstrate what the test code is capable of. The only capability of the test code that is not demonstrated here is the use of CID matching.
Thanks,
Mark
More information about the asterisk-dev
mailing list