summaryrefslogtreecommitdiff
path: root/tests/test_gosub.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2012-03-13 08:06:20 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2012-03-13 08:06:20 +0000
commit9af5c769c360b655abbda2fef63beffd5f9d91e4 (patch)
treedf3fde61046e8316f2e10b97bb6ab070f311a203 /tests/test_gosub.c
parentc369a4416b1fba9f685184b6b4dadf8eaffd2406 (diff)
Enable macros in 1.8 to find the next highest "h" extension in a context, like in 1.4.
This change restores functionality that was present in 1.4, when AEL macros were implemented with the Macro dialplan application. Macros are fraught with functionality issues, because they consume a large portion of the underlying application stack. This limits the ability of AEL users to call many layers of subroutines, an issue which Gosub does not have (originally tested to 100,000 levels deep). Therefore, starting in 1.6.0, AEL macros were implemented with Gosub. However, there were some implicit behaviors of Macro, which were not replicated at the same time as with the transition to Gosub, one of which is documented in the related issue. In particular, the "h" extension is designed to execute not in the Macro context, but in the topmost calling context. Due to legacy issues with a misapplied bugfix many years ago, when a macro exited in 1.4, it looks in all calling contexts, bubbling up from the deepest level until it finds an "h" extension. Since AEL hides the complexity of the underlying dialplan logic from the AEL programmer, it's reasonable to assume that this behavior should not change in the transition from Asterisk 1.4 LTS to Asterisk 1.8 LTS, lest we break working AEL configurations in the transition to Asterisk 1.8 LTS. This fix is the result, which implements a search for the "h" extension in all calling Gosub contexts. Fixes ASTERISK-19336 Patch: 20120308__ael_bugfix_for_trunk__2.diff (License #5003) by Tilghman Lesher (with slight modifications for 1.8) Tested by: Johan Wilfer Review: https://reviewboard.asterisk.org/r/1776/ ........ Merged revisions 358810 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 358811 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@358812 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_gosub.c')
-rw-r--r--tests/test_gosub.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_gosub.c b/tests/test_gosub.c
index e65ebbcbb..36573faf2 100644
--- a/tests/test_gosub.c
+++ b/tests/test_gosub.c
@@ -51,12 +51,24 @@ AST_TEST_DEFINE(test_gosub)
const char *args;
const char *expected_value;
} testplan[] = {
+ { NULL, "${STACK_PEEK(1,e,1)}", "" }, /* Stack is empty */
{ "Gosub", "tests_test_gosub_virtual_context,s,1" },
+ { NULL, "${PRIORITY}", "1" },
{ NULL, "${EXTEN}", "s" },
+ { NULL, "${STACK_PEEK(1,e,1)}", "" }, /* No extension originally */
{ "Gosub", "test,dne,1", (const char *) -1 }, /* This is the only invocation that should fail. */
+ { NULL, "${PRIORITY}", "1" },
{ NULL, "${EXTEN}", "s" },
{ "Gosub", "tests_test_gosub_virtual_context,s,1(5,5,5,5,5)" },
+ { NULL, "${PRIORITY}", "1" },
{ NULL, "$[0${ARG1} + 0${ARG5}]", "10" },
+ { NULL, "${STACK_PEEK(1,e)}", "s" },
+ { NULL, "${STACK_PEEK(1,c)}", "tests_test_gosub_virtual_context" },
+ { NULL, "${STACK_PEEK(1,p)}", "1" },
+ { NULL, "${STACK_PEEK(1,l)}", "tests_test_gosub_virtual_context,s,1" },
+ { "StackPop", "" },
+ { NULL, "${STACK_PEEK(1,e,1)}", "" }, /* Only 1 frame deep, my caller is top-level */
+ { "Gosub", "tests_test_gosub_virtual_context,s,1(5,5,5,5,5)" },
{ "Gosub", "tests_test_gosub_virtual_context,s,1(4,4,4,4)" },
{ NULL, "$[0${ARG1} + 0${ARG5}]", "4" },
{ NULL, "$[0${ARG1} + 0${ARG4}]", "8" },