48 #define MAX_PRIORITIES 10 164 "Test failed.\n", test_pattern->
test_exten, test_pattern->
context, (new_engine ?
"new" :
"old"));
168 ast_test_status_update(test,
"Expected extension %s but got extension %s instead with the %s pattern match engine. " 173 ast_test_status_update(test,
"Expected CID match %s but got CID match %s instead with the %s pattern match engine. " 179 ast_test_status_update(test,
"Partial match failed for extension %s in context %s with the %s pattern match engine. " 180 "Test failed.\n", test_pattern->
test_exten, test_pattern->
context, (new_engine ?
"new" :
"old"));
183 ast_test_status_update(test,
"Successfully matched %s to exten %s in context %s with the %s pattern match engine\n",
190 static const char registrar[] =
"test_pbx";
192 static const char TEST_PATTERN[] =
"test_pattern";
193 static const char TEST_PATTERN_INCLUDE[] =
"test_pattern_include";
200 const char * context_string;
203 { TEST_PATTERN_INCLUDE, },
214 const char *outer_context;
215 const char *inner_context;
216 } context_includes[] = {
217 { TEST_PATTERN, TEST_PATTERN_INCLUDE },
229 [0] = { TEST_PATTERN,
"_2.",
NULL, 1, { 1 } },
230 [1] = { TEST_PATTERN,
"2000",
NULL, 1, { 1 } },
231 [2] = { TEST_PATTERN_INCLUDE,
"2000",
NULL, 1, { 2 } },
242 { TEST_PATTERN,
"200",
NULL, 1, &extens[0] },
243 { TEST_PATTERN,
"2000",
NULL, 1, &extens[1] },
244 { TEST_PATTERN,
"2000",
NULL, 2, &extens[2] },
245 { TEST_PATTERN_INCLUDE,
"2000",
NULL, 2, &extens[2] },
250 info->name =
"pattern_match_test";
251 info->category =
"/main/pbx/";
252 info->summary =
"Test pattern matching";
253 info->description =
"Create a context with a bunch of extensions within. Then attempt\n" 254 "to match some strings to the extensions.";
276 for (i = 0; i <
ARRAY_LEN(context_includes); ++i) {
278 context_includes[i].inner_context, registrar)) {
280 context_includes[i].inner_context, context_includes[i].outer_context);
286 for (i = 0; i <
ARRAY_LEN(extens); ++i) {
290 "Max is %d, but we requested %d. Test failed\n",
297 NULL, extens[i].
cid,
"Noop", (
void *) extens[i].exten,
NULL, registrar)) {
299 "Test failed\n", extens[i].exten, extens[i].
priorities[priority], extens[i].context);
310 for (j = 0; j < 2; j++) {
330 info->name =
"RAISE_SEGV";
331 info->category =
"/DO_NOT_RUN/";
332 info->summary =
"RAISES SEGV!!! (will only be run if explicitly called)";
333 info->description =
"RAISES SEGV!!! (will only be run if explicitly called). " 334 "This test is mainly used for testing CI and tool failure scenarios.";
335 info->explicit_only = 1;
350 info->name =
"CALL_ASSERT";
351 info->category =
"/DO_NOT_RUN/";
352 info->summary =
"Calls ast_asert()!!! (will only be run if explicitly called)";
353 info->description =
"Calls ast_asert()!!! (will only be run if explicitly called). " 354 "This test is mainly used for testing CI and tool failure scenarios.";
355 info->explicit_only = 1;
370 info->name =
"CALL_BACKTRACE";
371 info->category =
"/DO_NOT_RUN/";
372 info->summary =
"Calls ast_log_backtrace()!!! (will only be run if explicitly called)";
373 info->description =
"Calls ast_log_backtrace()!!! (will only be run if explicitly called). " 374 "This test is mainly used for testing CI and tool failure scenarios.";
375 info->explicit_only = 1;
const struct exten_info * exten
Expected extension match.
static int unload_module(void)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
const char * cid
CID match.
const char * test_cid
Test CID match.
const char * context
Context.
#define AST_TEST_REGISTER(cb)
static int load_module(void)
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
AST_TEST_DEFINE(pattern_match_test)
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
void ast_log_backtrace(void)
Log a backtrace of the current thread's execution stack to the Asterisk log.
#define ast_test_status_update(a, b, c...)
const int priorities[MAX_PRIORITIES]
The priorities to register.
int pbx_set_extenpatternmatchnew(int newval)
const char * ast_get_extension_cidmatch(struct ast_exten *e)
Core PBX routines and definitions.
const char * test_exten
Test extension number.
#define AST_TEST_UNREGISTER(cb)
const char * ast_get_extension_name(struct ast_exten *exten)
struct ast_context * contexts
const int num_priorities
Number of priorities.
static void * cleanup(void *unused)
an extension to add to our context
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.
const char * context
Test context.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
const char * exten
Extension pattern.
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.
static int test_exten(const struct pbx_test_pattern *test_pattern, struct ast_test *test, int new_engine)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
const int priority
The priority to find.