42{
43#define CONTEXT_NAME "tests_test_gosub_virtual_context"
47 struct testplan {
50 const char *expected_value;
51 } testplan[] = {
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" },
67 { "StackPop", "" },
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" },
89 { "StackPop", "" },
90 {
NULL,
"${foo}",
"" },
91 { "Return", "7" },
92 {
NULL,
"${GOSUB_RETVAL}",
"7" },
93 {
NULL,
"$[0${GOSUB_RETVAL} + 0${ARG1}]",
"9" },
94 };
95
96 switch (cmd) {
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";
105 break;
106 }
107
111 }
112
117 }
118
119
125 }
126
128
129 for (i = 0; i <
ARRAY_LEN(testplan); i++) {
131
137 }
138 } else {
139
140 intptr_t exec_res;
145 break;
146 }
147
148 if ((exec_res =
pbx_exec(chan,
app, testplan[i].
args)) && ((
const char *) exec_res != testplan[i].expected_value)) {
151 break;
152 }
153 }
154 }
155
160
161 return res;
162}
#define ast_strdup(str)
A wrapper for strdup()
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
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.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
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.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
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_app * pbx_findapp(const char *app)
Look up an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
ast_app: A registered application
Main Channel structure associated with a channel.
Support for dynamic strings.
#define ast_test_status_update(a, b, c...)