43 #define CONTEXT_NAME "tests_test_gosub_virtual_context" 50 const char *expected_value;
52 {
NULL,
"${STACK_PEEK(1,e,1)}",
"" },
53 {
"Gosub",
"tests_test_gosub_virtual_context,s,1" },
54 {
NULL,
"${PRIORITY}",
"1" },
55 {
NULL,
"${EXTEN}",
"s" },
56 {
NULL,
"${STACK_PEEK(1,e,1)}",
"" },
57 {
"Gosub",
"test,dne,1", (
const char *) -1 },
58 {
NULL,
"${PRIORITY}",
"1" },
59 {
NULL,
"${EXTEN}",
"s" },
60 {
"Gosub",
"tests_test_gosub_virtual_context,s,1(5,5,5,5,5)" },
61 {
NULL,
"${PRIORITY}",
"1" },
62 {
NULL,
"$[0${ARG1} + 0${ARG5}]",
"10" },
63 {
NULL,
"${STACK_PEEK(1,e)}",
"s" },
64 {
NULL,
"${STACK_PEEK(1,c)}",
"tests_test_gosub_virtual_context" },
65 {
NULL,
"${STACK_PEEK(1,p)}",
"1" },
66 {
NULL,
"${STACK_PEEK(1,l)}",
"tests_test_gosub_virtual_context,s,1" },
68 {
NULL,
"${STACK_PEEK(1,e,1)}",
"" },
69 {
"Gosub",
"tests_test_gosub_virtual_context,s,1(5,5,5,5,5)" },
70 {
"Gosub",
"tests_test_gosub_virtual_context,s,1(4,4,4,4)" },
71 {
NULL,
"$[0${ARG1} + 0${ARG5}]",
"4" },
72 {
NULL,
"$[0${ARG1} + 0${ARG4}]",
"8" },
73 {
"Gosub",
"tests_test_gosub_virtual_context,s,1(3,3,3)" },
74 {
NULL,
"$[0${ARG1} + 0${ARG4}]",
"3" },
75 {
NULL,
"$[0${ARG1} + 0${ARG3}]",
"6" },
76 {
"Gosub",
"tests_test_gosub_virtual_context,s,1(2,2)" },
77 {
NULL,
"$[0${ARG1} + 0${ARG3}]",
"2" },
78 {
NULL,
"$[0${ARG1} + 0${ARG2}]",
"4" },
79 {
"Gosub",
"tests_test_gosub_virtual_context,s,1(1)" },
80 {
NULL,
"$[0${ARG1} + 0${ARG2}]",
"1" },
81 {
NULL,
"$[0${ARG1} + 0${ARG1}]",
"2" },
82 {
"Gosub",
"tests_test_gosub_virtual_context,s,1" },
83 {
NULL,
"$[0${ARG1} + 0${ARG1}]",
"0" },
84 {
"Set",
"LOCAL(foo)=5" },
85 {
NULL,
"${foo}",
"5" },
86 {
NULL,
"${LOCAL_PEEK(0,ARG1)}",
"" },
87 {
NULL,
"${LOCAL_PEEK(4,ARG1)}",
"4" },
88 {
NULL,
"$[0${LOCAL_PEEK(3,ARG1)} + 0${LOCAL_PEEK(5,ARG1)}]",
"8" },
90 {
NULL,
"${foo}",
"" },
92 {
NULL,
"${GOSUB_RETVAL}",
"7" },
93 {
NULL,
"$[0${GOSUB_RETVAL} + 0${ARG1}]",
"9" },
98 info->name =
"gosub application";
99 info->category =
"/apps/app_gosub/";
100 info->summary =
"Verify functionality of gosub application";
102 "Verify functionality of gosub application";
129 for (i = 0; i <
ARRAY_LEN(testplan); i++) {
135 testplan[i].args,
ast_str_buffer(str), testplan[i].expected_value);
148 if ((exec_res =
pbx_exec(chan, app, testplan[i].
args)) && ((
const char *) exec_res != testplan[i].expected_value)) {
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
#define ast_channel_unref(c)
Decrease channel reference count.
AST_TEST_DEFINE(test_gosub)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
#define AST_TEST_REGISTER(cb)
static int load_module(void)
#define ast_strdup(str)
A wrapper for strdup()
void ast_free_ptr(void *ptr)
free() wrapper
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
General Asterisk PBX channel definitions.
#define ast_test_status_update(a, b, c...)
#define ast_dummy_channel_alloc()
Create a fake channel structure.
Core PBX routines and definitions.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define AST_TEST_UNREGISTER(cb)
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
ast_app: A registered application
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.