summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2011-09-20 21:05:42 +0000
committerKinsey Moore <kmoore@digium.com>2011-09-20 21:05:42 +0000
commit486b6042f39664bd8f325e8a0b035f80b2a9765d (patch)
treed53f4ea1fd51c5a8d84cebaae378a046420e3d4a /tests
parent7fe331fd59936d7993572ff40e1c79859f795c6b (diff)
Merged revisions 337062 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r337062 | kmoore | 2011-09-20 16:05:01 -0500 (Tue, 20 Sep 2011) | 18 lines Merged revisions 337061 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r337061 | kmoore | 2011-09-20 16:04:11 -0500 (Tue, 20 Sep 2011) | 11 lines Make CANMATCH with the new pattern match engine behave more like the old one When checking an extension for E_CANMATCH using the new extension matching algorithm, an exact match was not returned as a possible match resulting in the queue failing to allow a caller to exit on DTMF. This removes the requirement that an extension be longer than acquired digits for an E_CANMATCH operation to succeed. (closes issue ASTERISK-18044) Review: https://reviewboard.asterisk.org/r/1367/ ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337063 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pbx.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/tests/test_pbx.c b/tests/test_pbx.c
index 1bcce1770..5e2e232ed 100644
--- a/tests/test_pbx.c
+++ b/tests/test_pbx.c
@@ -153,29 +153,35 @@ struct pbx_test_pattern {
const struct exten_info *exten;
};
-static int test_exten(const struct pbx_test_pattern *test_pattern, struct ast_test *test)
+static int test_exten(const struct pbx_test_pattern *test_pattern, struct ast_test *test, int new_engine)
{
struct pbx_find_info pfi = { { 0 }, };
struct ast_exten *exten;
if (!(exten = pbx_find_extension(NULL, NULL, &pfi, test_pattern->context,
test_pattern->test_exten, test_pattern->priority, NULL,
test_pattern->test_cid, E_MATCH))) {
- ast_test_status_update(test, "Cannot find extension %s in context %s."
- "Test failed.\n", test_pattern->test_exten, test_pattern->context);
+ ast_test_status_update(test, "Cannot find extension %s in context %s with the %s pattern match engine. "
+ "Test failed.\n", test_pattern->test_exten, test_pattern->context, (new_engine ? "new" : "old"));
return -1;
}
if (strcmp(ast_get_extension_name(exten), test_pattern->exten->exten)) {
- ast_test_status_update(test, "Expected extension %s but got extension %s instead."
- "Test failed.\n", test_pattern->exten->exten, ast_get_extension_name(exten));
+ ast_test_status_update(test, "Expected extension %s but got extension %s instead with the %s pattern match engine. "
+ "Test failed.\n", test_pattern->exten->exten, ast_get_extension_name(exten), (new_engine ? "new" : "old"));
return -1;
}
if (test_pattern->test_cid && strcmp(ast_get_extension_cidmatch(exten), test_pattern->test_cid)) {
- ast_test_status_update(test, "Expected CID match %s but got CID match %s instead."
- "Test failed.\n", test_pattern->exten->cid, ast_get_extension_cidmatch(exten));
+ ast_test_status_update(test, "Expected CID match %s but got CID match %s instead with the %s pattern match engine. "
+ "Test failed.\n", test_pattern->exten->cid, ast_get_extension_cidmatch(exten), (new_engine ? "new" : "old"));
return -1;
}
- ast_test_status_update(test, "Successfully matched %s to exten %s in context %s\n",
- test_pattern->test_exten, test_pattern->exten->exten, test_pattern->context);
+ if (!ast_canmatch_extension(NULL, test_pattern->context, test_pattern->test_exten,
+ test_pattern->priority, test_pattern->test_cid)) {
+ ast_test_status_update(test, "Partial match failed for extension %s in context %s with the %s pattern match engine. "
+ "Test failed.\n", test_pattern->test_exten, test_pattern->context, (new_engine ? "new" : "old"));
+ return -1;
+ }
+ ast_test_status_update(test, "Successfully matched %s to exten %s in context %s with the %s pattern match engine\n",
+ test_pattern->test_exten, test_pattern->exten->exten, test_pattern->context, (new_engine ? "new" : "old"));
return 0;
}
@@ -185,7 +191,7 @@ AST_TEST_DEFINE(pattern_match_test)
enum ast_test_result_state res = AST_TEST_PASS;
static const char TEST_PATTERN[] = "test_pattern";
static const char TEST_PATTERN_INCLUDE[] = "test_pattern_include";
- int i;
+ int i, j;
/* The array of contexts to register for our test.
* To add more contexts, just add more rows to this array.
@@ -300,12 +306,15 @@ AST_TEST_DEFINE(pattern_match_test)
/* At this stage, the dialplan is built. Now we iterate over
* the tests array to attempt to find each of the specified
- * extensions.
+ * extensions with the old and new pattern matching engines.
*/
- for (i = 0; i < ARRAY_LEN(tests); ++i) {
- if (test_exten(&tests[i], test)) {
- res = AST_TEST_FAIL;
- break;
+ for (j = 0; j < 2; j++) {
+ pbx_set_extenpatternmatchnew(j);
+ for (i = 0; i < ARRAY_LEN(tests); ++i) {
+ if (test_exten(&tests[i], test, j)) {
+ res = AST_TEST_FAIL;
+ break;
+ }
}
}