Asterisk - The Open Source Telephony Project
18.5.0
|
Device State Test Module. More...
#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/devicestate.h"
#include "asterisk/pbx.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/vector.h"
Go to the source code of this file.
Data Structures | |
struct | consumer |
Macros | |
#define | DEVICE_STATE_CHANNEL_TYPE "TestDeviceState" |
#define | DEVSTATE_PROVIDER "TestDevState" |
#define | DEVSTATE_PROVIDER_LC "testdevstate" |
#define | DEVSTATE_PROVIDER_LEN 12 |
#define | UNIT_TEST_DEVICE_IDENTIFIER "unit_test_device_identifier" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (device2extenstate_test) | |
AST_TEST_DEFINE (device_state_aggregation_test) | |
AST_TEST_DEFINE (devstate_prov_add) | |
AST_TEST_DEFINE (devstate_prov_del) | |
AST_TEST_DEFINE (devstate_changed) | |
AST_TEST_DEFINE (devstate_conversions) | |
AST_TEST_DEFINE (devstate_channels) | |
static | AST_VECTOR (, enum ast_device_state) result_states |
The resulting device state updates caused by some function call. More... | |
static void | cache_cleanup (int unused) |
static int | chan_test_devicestate_cb (const char *device_number) |
static void | clear_result_states (void) |
Clear out all recorded device states in result_states. More... | |
static struct consumer * | consumer_create (void) |
static void | consumer_dtor (void *obj) |
static void | consumer_exec (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | consumer_finalize (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | consumer_reset (struct consumer *consumer) |
static void | consumer_wait_for (struct consumer *consumer) |
static void | device_state_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
Stasis subscription callback for device state updates. More... | |
static enum ast_device_state | devstate_prov_cb (const char *data) |
static int | load_module (void) |
static int | remove_device_states_cb (void *obj, void *arg, int flags) |
static void | safe_hangup (void *object) |
static int | unload_module (void) |
static int | wait_for_channel_callback (struct ast_test *test) |
Wait until the test channel driver's devicestate callback is called. More... | |
static int | wait_for_device_state_updates (struct ast_test *test, int expected_updates) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Device State Test" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .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 int | chan_callback_called |
Whether or not the channel device state callback was called. More... | |
static unsigned int | chan_idx |
Used to assign an increasing integer to channel name. More... | |
struct ast_channel_tech | chan_test_devicestate |
static ast_cond_t | channel_cb_cond |
Condition wait variable for channel tech device state cb. More... | |
static ast_mutex_t | channel_cb_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
Mutext for channel_cb_cond . More... | |
static int | combined_results [] |
static enum ast_device_state | current_device_state |
The current device state for our device state provider. More... | |
static int | exten_results [] |
static ast_cond_t | update_cond |
Condition wait variable for device state updates. More... | |
static ast_mutex_t | update_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
Mutex for update_cond . More... | |
Device State Test Module.
Definition in file test_devicestate.c.
#define DEVICE_STATE_CHANNEL_TYPE "TestDeviceState" |
Definition at line 45 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE().
#define DEVSTATE_PROVIDER "TestDevState" |
Definition at line 47 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE(), and device_state_cb().
#define DEVSTATE_PROVIDER_LC "testdevstate" |
Definition at line 49 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE().
#define DEVSTATE_PROVIDER_LEN 12 |
Definition at line 51 of file test_devicestate.c.
Referenced by device_state_cb().
#define UNIT_TEST_DEVICE_IDENTIFIER "unit_test_device_identifier" |
Definition at line 43 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE(), consumer_exec(), and remove_device_states_cb().
|
static |
Definition at line 969 of file test_devicestate.c.
|
static |
Definition at line 969 of file test_devicestate.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 969 of file test_devicestate.c.
AST_TEST_DEFINE | ( | device2extenstate_test | ) |
Definition at line 312 of file test_devicestate.c.
References ARRAY_LEN, AST_DEVICE_TOTAL, ast_devstate2str(), ast_devstate_aggregate_add(), ast_devstate_aggregate_init(), ast_devstate_aggregate_result(), ast_devstate_to_extenstate(), ast_extension_state2str(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, combined_results, exten, exten_results, sip_to_pjsip::info(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | device_state_aggregation_test | ) |
Definition at line 511 of file test_devicestate.c.
References consumer::aggregate_state, ao2_cleanup, ao2_ref, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, ast_device_state_cache(), ast_device_state_message_type(), ast_device_state_topic_cached(), AST_DEVICE_TOTAL, AST_DEVSTATE_CACHABLE, ast_free, ast_malloc, ast_publish_device_state, ast_publish_device_state_full(), AST_TEST_NOT_RUN, AST_TEST_PASS, cache_cleanup(), consumer_create(), consumer_exec(), consumer_finalize(), consumer_reset(), consumer_wait_for(), consumer::event_count, sip_to_pjsip::info(), NULL, RAII_VAR, consumer::sig_on_non_aggregate_state, stasis_cache_get_by_eid(), stasis_cache_update_type(), stasis_message_data(), stasis_message_router_add(), stasis_message_router_create, stasis_message_router_unsubscribe(), stasis_subscription_change_type(), ast_device_state_message::state, consumer::state, TEST_EXECUTE, TEST_INIT, and UNIT_TEST_DEVICE_IDENTIFIER.
AST_TEST_DEFINE | ( | devstate_prov_add | ) |
Definition at line 622 of file test_devicestate.c.
References ast_devstate_prov_add(), ast_devstate_prov_del(), AST_TEST_NOT_RUN, AST_TEST_PASS, devstate_prov_cb(), DEVSTATE_PROVIDER, sip_to_pjsip::info(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | devstate_prov_del | ) |
Definition at line 644 of file test_devicestate.c.
References ast_devstate_prov_add(), ast_devstate_prov_del(), AST_TEST_NOT_RUN, AST_TEST_PASS, devstate_prov_cb(), DEVSTATE_PROVIDER, sip_to_pjsip::info(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | devstate_changed | ) |
Definition at line 666 of file test_devicestate.c.
References ao2_cleanup, AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, ast_device_state_topic_all(), AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, ast_devstate_prov_add(), ast_devstate_prov_del(), AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, AST_VECTOR_GET, AST_VECTOR_SIZE, clear_result_states(), current_device_state, device_state_cb(), devstate_prov_cb(), DEVSTATE_PROVIDER, DEVSTATE_PROVIDER_LC, sip_to_pjsip::info(), NULL, RAII_VAR, stasis_subscribe, stasis_unsubscribe_and_join(), sub, TEST_EXECUTE, TEST_INIT, and wait_for_device_state_updates().
AST_TEST_DEFINE | ( | devstate_conversions | ) |
Definition at line 788 of file test_devicestate.c.
References AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, ast_devstate_str(), ast_devstate_val(), AST_STATE_BUSY, ast_state_chan2dev(), AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_OFFHOOK, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | devstate_channels | ) |
Definition at line 871 of file test_devicestate.c.
References ast_atomic_fetchadd_int(), ast_channel_alloc, AST_DEVICE_INUSE, AST_DEVICE_RINGING, AST_DEVICE_UNKNOWN, ast_parse_device_state(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, AST_TEST_NOT_RUN, AST_TEST_PASS, chan_callback_called, chan_idx, DEVICE_STATE_CHANNEL_TYPE, sip_to_pjsip::info(), NULL, RAII_VAR, safe_hangup(), TEST_EXECUTE, TEST_INIT, and wait_for_channel_callback().
|
static |
The resulting device state updates caused by some function call.
|
static |
Definition at line 498 of file test_devicestate.c.
References ao2_callback, ao2_cleanup, ast_device_state_cache(), NULL, remove_device_states_cb(), and stasis_cache_dump_all().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 907 of file test_devicestate.c.
References ast_cond_signal, AST_DEVICE_INUSE, ast_mutex_lock, ast_mutex_unlock, chan_callback_called, channel_cb_cond, and channel_cb_lock.
|
static |
Clear out all recorded device states in result_states.
Definition at line 244 of file test_devicestate.c.
References ast_mutex_lock, ast_mutex_unlock, AST_VECTOR_REMOVE_UNORDERED, AST_VECTOR_SIZE, and update_lock.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 400 of file test_devicestate.c.
References ao2_alloc, ast_cond_init, consumer_dtor(), consumer_reset(), NULL, and consumer::out.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 385 of file test_devicestate.c.
References ast_cond_destroy, and consumer::out.
Referenced by consumer_create().
|
static |
Definition at line 415 of file test_devicestate.c.
References consumer::aggregate_state, consumer::already_out, ast_cond_signal, cache_update(), ast_device_state_message::device, ast_device_state_message::eid, consumer::event_count, lock, stasis_cache_update::new_snapshot, consumer::out, SCOPED_AO2LOCK, consumer::sig_on_non_aggregate_state, stasis_message_data(), ast_device_state_message::state, consumer::state, and UNIT_TEST_DEVICE_IDENTIFIER.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 451 of file test_devicestate.c.
References ao2_cleanup, and stasis_subscription_final_message().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 392 of file test_devicestate.c.
References consumer::aggregate_state, consumer::already_out, AST_DEVICE_TOTAL, consumer::event_count, and consumer::state.
Referenced by AST_TEST_DEFINE(), and consumer_create().
|
static |
Definition at line 460 of file test_devicestate.c.
References consumer::already_out, ao2_object_get_lockaddr(), ast_cond_timedwait, ast_tvnow(), lock, consumer::out, and SCOPED_AO2LOCK.
Referenced by AST_TEST_DEFINE().
|
static |
Stasis subscription callback for device state updates.
Definition at line 254 of file test_devicestate.c.
References ast_cond_signal, ast_device_state_message_type(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero, AST_VECTOR_APPEND, ast_device_state_message::device, DEVSTATE_PROVIDER, DEVSTATE_PROVIDER_LEN, ast_device_state_message::eid, stasis_message_data(), stasis_message_type(), ast_device_state_message::state, state, update_cond, and update_lock.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 287 of file test_devicestate.c.
References current_device_state.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 944 of file test_devicestate.c.
References ast_channel_register(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_TEST_REGISTER, AST_VECTOR_FREE, and AST_VECTOR_INIT.
|
static |
Definition at line 479 of file test_devicestate.c.
References ao2_cleanup, ast_device_state_topic(), ast_device_state_message::device, stasis_cache_clear_create(), stasis_message_data(), stasis_publish(), and UNIT_TEST_DEVICE_IDENTIFIER.
Referenced by cache_cleanup().
|
static |
Definition at line 861 of file test_devicestate.c.
References ast_hangup().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 925 of file test_devicestate.c.
References ast_channel_unregister(), AST_TEST_UNREGISTER, and AST_VECTOR_FREE.
|
static |
Wait until the test channel driver's devicestate callback is called.
Definition at line 842 of file test_devicestate.c.
References ast_cond_timedwait, ast_mutex_lock, ast_mutex_unlock, ast_test_status_update, ast_tvnow(), chan_callback_called, channel_cb_cond, channel_cb_lock, and error().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 292 of file test_devicestate.c.
References ast_cond_timedwait, ast_mutex_lock, ast_mutex_unlock, ast_test_status_update, ast_tvnow(), AST_VECTOR_SIZE, error(), update_cond, and update_lock.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 969 of file test_devicestate.c.
|
static |
Definition at line 969 of file test_devicestate.c.
|
static |
Whether or not the channel device state callback was called.
Definition at line 839 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE(), chan_test_devicestate_cb(), and wait_for_channel_callback().
|
static |
Used to assign an increasing integer to channel name.
Definition at line 54 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE().
struct ast_channel_tech chan_test_devicestate |
Definition at line 919 of file test_devicestate.c.
|
static |
Condition wait variable for channel tech device state cb.
Definition at line 235 of file test_devicestate.c.
Referenced by chan_test_devicestate_cb(), and wait_for_channel_callback().
|
static |
Mutext for channel_cb_cond
.
Definition at line 232 of file test_devicestate.c.
Referenced by chan_test_devicestate_cb(), and wait_for_channel_callback().
|
static |
Definition at line 57 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE().
|
static |
The current device state for our device state provider.
Definition at line 241 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE(), and devstate_prov_cb().
|
static |
Definition at line 141 of file test_devicestate.c.
Referenced by AST_TEST_DEFINE().
|
static |
Condition wait variable for device state updates.
Definition at line 229 of file test_devicestate.c.
Referenced by device_state_cb(), and wait_for_device_state_updates().
|
static |
Mutex for update_cond
.
Definition at line 226 of file test_devicestate.c.
Referenced by clear_result_states(), device_state_cb(), and wait_for_device_state_updates().