|
Asterisk - The Open Source Telephony Project GIT-master-35be64c
|
Extension state legacy callback tests. More...
#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/test.h"#include "asterisk/pbx.h"#include "asterisk/devicestate.h"#include "asterisk/astobj2.h"#include "asterisk/lock.h"#include "asterisk/time.h"#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
| struct | test_watcher |
| Tracking for a single extension state callback. More... | |
Macros | |
| #define | TEST_CATEGORY "/main/extension_state/" |
| #define | TEST_CONTEXT "test_extension_state" |
| #define | TEST_DEVICE_PREFIX "Custom:test_extension_state_" |
| Prefix for the devices used by the test hints. | |
| #define | TEST_REGISTRAR "test_extension_state" |
| #define | TEST_TIMEOUT 5 |
| How long to wait for asynchronous events, in seconds. | |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| struct ast_module * | AST_MODULE_SELF_SYM (void) |
| AST_TEST_DEFINE (add_failure_ownership) | |
| AST_TEST_DEFINE (dash_spelling_dashed_first) | |
| AST_TEST_DEFINE (dash_spelling_dashless_first) | |
| static enum ast_test_result_state | dash_spelling_check (struct ast_test *test, const char *base, const char *suffix, int dashed_first) |
| Watch two spellings of an extension that differ only by dashes. | |
| static void | dialplan_cleanup (void) |
| static int | dialplan_setup (void) |
| static int | load_module (void) |
| static int | state_changed (const char *context, const char *exten, struct ast_state_cb_info *info, void *data) |
| static void | state_destroyed (int id, void *data) |
| static int | test_watcher_add (struct ast_test *test, const char *context, struct test_watcher *watcher) |
| Add an extension state callback for a watcher. | |
| static struct test_watcher * | test_watcher_alloc (const char *exten) |
| static int | test_watcher_remove (struct ast_test *test, struct test_watcher *watcher) |
| Remove an extension state callback and wait for it to be destroyed. | |
| static int | test_watcher_wait_for_state (struct test_watcher *watcher, enum ast_extension_states state) |
| Wait until a watcher has received the given extension state. | |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Extension state tests" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static ast_cond_t | test_cond |
| static ast_mutex_t | test_lock = AST_MUTEX_INIT_VALUE |
| Protects watcher state and test_run. | |
| static unsigned int | test_run |
| Used to make the extensions, and so the devices, differ between test runs. | |
Extension state legacy callback tests.
Definition in file test_extension_state.c.
| #define TEST_CATEGORY "/main/extension_state/" |
Definition at line 42 of file test_extension_state.c.
| #define TEST_CONTEXT "test_extension_state" |
Definition at line 43 of file test_extension_state.c.
| #define TEST_DEVICE_PREFIX "Custom:test_extension_state_" |
Prefix for the devices used by the test hints.
Device state is global, so the hints use device names reserved for this test to avoid affecting, or being affected by, any other hint.
Definition at line 52 of file test_extension_state.c.
| #define TEST_REGISTRAR "test_extension_state" |
Definition at line 44 of file test_extension_state.c.
| #define TEST_TIMEOUT 5 |
How long to wait for asynchronous events, in seconds.
Definition at line 55 of file test_extension_state.c.
|
static |
Definition at line 449 of file test_extension_state.c.
|
static |
Definition at line 449 of file test_extension_state.c.
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 449 of file test_extension_state.c.
| AST_TEST_DEFINE | ( | add_failure_ownership | ) |
Definition at line 381 of file test_extension_state.c.
References ao2_ref, ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, test_watcher::destroyed, TEST_CATEGORY, TEST_EXECUTE, TEST_INIT, test_lock, test_watcher_add(), test_watcher_alloc(), and test_watcher_remove().
| AST_TEST_DEFINE | ( | dash_spelling_dashed_first | ) |
Definition at line 362 of file test_extension_state.c.
References AST_TEST_NOT_RUN, dash_spelling_check(), TEST_CATEGORY, TEST_EXECUTE, and TEST_INIT.
| AST_TEST_DEFINE | ( | dash_spelling_dashless_first | ) |
Definition at line 341 of file test_extension_state.c.
References AST_TEST_NOT_RUN, dash_spelling_check(), TEST_CATEGORY, TEST_EXECUTE, and TEST_INIT.
|
static |
Watch two spellings of an extension that differ only by dashes.
This mirrors two phones with BLF keys for the same extension, one configured with a dash and one without. The first spelling creates the hint from the pattern. Both watchers must be added, both must be notified when the device of the hint changes state, and both must be destroyed exactly once.
| test | The test |
| base | The leading digits of the extension |
| suffix | The trailing part of the extension, joined by a dash when dashed |
| dashed_first | Whether the dashed spelling is watched first, naming the device |
The test run number is added to the extension, so that runs use different devices and a run is not affected by state left behind by an earlier one.
Definition at line 261 of file test_extension_state.c.
References ao2_cleanup, ao2_ref, ARRAY_LEN, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, ast_device_state_clear_cache(), AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_EXTENSION_INUSE, AST_EXTENSION_NOT_INUSE, AST_MAX_EXTENSION, ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, cleanup(), dialplan_cleanup(), dialplan_setup(), test_watcher::exten, first, NULL, TEST_CONTEXT, TEST_DEVICE_PREFIX, test_lock, test_run, test_watcher_add(), test_watcher_alloc(), test_watcher_remove(), and test_watcher_wait_for_state().
Referenced by AST_TEST_DEFINE(), and AST_TEST_DEFINE().
|
static |
Definition at line 240 of file test_extension_state.c.
References ast_context_destroy_by_name(), TEST_CONTEXT, and TEST_REGISTRAR.
Referenced by dash_spelling_check().
|
static |
Definition at line 222 of file test_extension_state.c.
References ast_add_extension(), ast_context_find_or_create(), NULL, PRIORITY_HINT, TEST_CONTEXT, TEST_DEVICE_PREFIX, and TEST_REGISTRAR.
Referenced by dash_spelling_check().
|
static |
Definition at line 435 of file test_extension_state.c.
References ast_cond_init, AST_MODULE_LOAD_SUCCESS, ast_random(), AST_TEST_REGISTER, NULL, test_cond, and test_run.
|
static |
Definition at line 98 of file test_extension_state.c.
References ast_cond_broadcast, ast_mutex_lock, ast_mutex_unlock, test_watcher::last_state, test_cond, and test_lock.
Referenced by test_watcher_add(), and test_watcher_remove().
|
static |
Definition at line 110 of file test_extension_state.c.
References ao2_ref, ast_cond_broadcast, ast_mutex_lock, ast_mutex_unlock, test_watcher::destroyed, test_cond, and test_lock.
Referenced by test_watcher_add().
|
static |
Add an extension state callback for a watcher.
| 0 | on success |
| -1 | on failure, in which case the destroy callback must not have been invoked as the caller retains ownership of the callback data |
Definition at line 130 of file test_extension_state.c.
References ao2_ref, ast_extension_state_add_destroy_extended(), ast_mutex_lock, ast_mutex_unlock, ast_test_status_update, test_watcher::destroyed, test_watcher::exten, test_watcher::id, state_changed(), state_destroyed(), and test_lock.
Referenced by AST_TEST_DEFINE(), and dash_spelling_check().
|
static |
Definition at line 82 of file test_extension_state.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ast_copy_string(), AST_EXTENSION_REMOVED, test_watcher::exten, test_watcher::id, test_watcher::last_state, and NULL.
Referenced by AST_TEST_DEFINE(), and dash_spelling_check().
|
static |
Remove an extension state callback and wait for it to be destroyed.
| 0 | if the destroy callback was invoked exactly once |
| -1 | otherwise |
Definition at line 171 of file test_extension_state.c.
References ast_cond_timedwait, ast_extension_state_del(), ast_mutex_lock, ast_mutex_unlock, ast_test_status_update, ast_tvnow(), test_watcher::destroyed, test_watcher::exten, test_watcher::id, state_changed(), test_cond, test_lock, and TEST_TIMEOUT.
Referenced by AST_TEST_DEFINE(), and dash_spelling_check().
|
static |
Wait until a watcher has received the given extension state.
Definition at line 201 of file test_extension_state.c.
References ast_cond_timedwait, ast_mutex_lock, ast_mutex_unlock, ast_tvnow(), test_watcher::last_state, test_cond, test_lock, and TEST_TIMEOUT.
Referenced by dash_spelling_check().
|
static |
Definition at line 425 of file test_extension_state.c.
References ast_cond_destroy, AST_TEST_UNREGISTER, and test_cond.
|
static |
Definition at line 449 of file test_extension_state.c.
|
static |
Definition at line 449 of file test_extension_state.c.
|
static |
Definition at line 77 of file test_extension_state.c.
Referenced by load_module(), state_changed(), state_destroyed(), test_watcher_remove(), test_watcher_wait_for_state(), and unload_module().
|
static |
Protects watcher state and test_run.
Definition at line 76 of file test_extension_state.c.
Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), dash_spelling_check(), state_changed(), state_destroyed(), test_watcher_add(), test_watcher_remove(), and test_watcher_wait_for_state().
|
static |
Used to make the extensions, and so the devices, differ between test runs.
Definition at line 80 of file test_extension_state.c.
Referenced by dash_spelling_check(), and load_module().