[asterisk-commits] kmoore: trunk r337063 - in /trunk: ./ main/pbx.c tests/test_pbx.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 20 16:05:44 CDT 2011
Author: kmoore
Date: Tue Sep 20 16:05:42 2011
New Revision: 337063
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=337063
Log:
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/
........
................
Modified:
trunk/ (props changed)
trunk/main/pbx.c
trunk/tests/test_pbx.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.
Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=337063&r1=337062&r2=337063
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Tue Sep 20 16:05:42 2011
@@ -1873,7 +1873,7 @@
return; /* the first match is all we need */ \
} \
} \
- } else if (p->next_char && !*(str + 1)) { \
+ } else if ((p->next_char || action == E_CANMATCH) && !*(str + 1)) { \
score->canmatch = 1; \
score->canmatch_exten = get_canmatch_exten(p); \
if (action == E_CANMATCH || action == E_MATCHMORE) { \
Modified: trunk/tests/test_pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_pbx.c?view=diff&rev=337063&r1=337062&r2=337063
==============================================================================
--- trunk/tests/test_pbx.c (original)
+++ trunk/tests/test_pbx.c Tue Sep 20 16:05:42 2011
@@ -153,29 +153,35 @@
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 @@
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 @@
/* At this stage, the dialplan is built. Now we iterate over
* the tests array to attempt to find each of the specified
- * extensions.
- */
- for (i = 0; i < ARRAY_LEN(tests); ++i) {
- if (test_exten(&tests[i], test)) {
- res = AST_TEST_FAIL;
- break;
+ * extensions with the old and new pattern matching engines.
+ */
+ 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;
+ }
}
}
More information about the asterisk-commits
mailing list