SDP: Make process possible multiple fmtp attributes per rtpmap.
[asterisk/asterisk.git] / tests / test_gosub.c
index b10e73e..0a702cf 100644 (file)
  * \file
  * \brief Gosub tests
  *
- * \author\verbatim Tilghman Lesher <tlesher AT digium DOT com> \endverbatim
+ * \author Tilghman Lesher \verbatim <tlesher AT digium DOT com> \endverbatim
  *
  * \ingroup tests
  */
 
 /*** MODULEINFO
        <depend>TEST_FRAMEWORK</depend>
+       <support_level>core</support_level>
  ***/
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
 #include "asterisk/utils.h"
 #include "asterisk/module.h"
 #include "asterisk/test.h"
 #include "asterisk/pbx.h"
-
-#if SIZEOF_INT == SIZEOF_CHAR_P
-#define        compat_int      int
-#elif SIZEOF_LONG == SIZEOF_CHAR_P
-#define        compat_int      long
-#elif SIZEOF_LONG_LONG == SIZEOF_CHAR_P
-#define        compat_int      long long
-#else
-#error "Cannot find an integer type the same size as a pointer"
-#endif
+#include "asterisk/channel.h"
 
 AST_TEST_DEFINE(test_gosub)
 {
+#define CONTEXT_NAME "tests_test_gosub_virtual_context"
        int res = AST_TEST_PASS, i;
        struct ast_channel *chan;
        struct ast_str *str;
-       struct ast_context *con;
        struct testplan {
                const char *app;
                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" },
@@ -94,7 +96,7 @@ AST_TEST_DEFINE(test_gosub)
        switch (cmd) {
        case TEST_INIT:
                info->name = "gosub application";
-               info->category = "apps/app_gosub/";
+               info->category = "/apps/app_gosub/";
                info->summary = "Verify functionality of gosub application";
                info->description =
                        "Verify functionality of gosub application";
@@ -110,19 +112,19 @@ AST_TEST_DEFINE(test_gosub)
 
        if (!(str = ast_str_create(16))) {
                ast_test_status_update(test, "Unable to allocate dynamic string buffer\n");
-               ast_channel_release(chan);
+               ast_channel_unref(chan);
                return AST_TEST_FAIL;
        }
 
        /* Create our test dialplan */
-       if (!(con = ast_context_find_or_create(NULL, NULL, "tests_test_gosub_virtual_context", "test_gosub"))) {
+       if (!ast_context_find_or_create(NULL, NULL, CONTEXT_NAME, "test_gosub")) {
                ast_test_status_update(test, "Unable to create test dialplan context");
                ast_free(str);
-               ast_channel_release(chan);
+               ast_channel_unref(chan);
                return AST_TEST_FAIL;
        }
 
-       ast_add_extension2(con, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "test_gosub");
+       ast_add_extension(CONTEXT_NAME, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "test_gosub");
 
        for (i = 0; i < ARRAY_LEN(testplan); i++) {
                if (testplan[i].app == NULL) {
@@ -135,7 +137,7 @@ AST_TEST_DEFINE(test_gosub)
                        }
                } else {
                        /* Run application */
-                       compat_int exec_res;
+                       intptr_t exec_res;
                        struct ast_app *app = pbx_findapp(testplan[i].app);
                        if (!app) {
                                ast_test_status_update(test, "Could not find '%s' in application listing!\n", testplan[i].app);
@@ -152,9 +154,9 @@ AST_TEST_DEFINE(test_gosub)
        }
 
        ast_free(str);
-       ast_channel_release(chan);
-       ast_context_remove_extension2(con, "s", 1, NULL, 0);
-       ast_context_destroy(con, "test_gosub");
+       ast_channel_unref(chan);
+       ast_context_remove_extension(CONTEXT_NAME, "s", 1, NULL);
+       ast_context_destroy(NULL, "test_gosub");
 
        return res;
 }