Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
test_devicestate.c File Reference

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_moduleAST_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 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.
 
static struct consumerconsumer_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.
 
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.
 
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_infoast_module_info = &__mod_info
 
static int chan_callback_called
 Whether or not the channel device state callback was called.
 
static unsigned int chan_idx
 Used to assign an increasing integer to channel name.
 
struct ast_channel_tech chan_test_devicestate
 
static ast_cond_t channel_cb_cond
 Condition wait variable for channel tech device state cb.
 
static ast_mutex_t channel_cb_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 Mutext for channel_cb_cond.
 
static int combined_results []
 
static enum ast_device_state current_device_state
 The current device state for our device state provider.
 
static int exten_results []
 
struct {
   size_t   current
 
   enum ast_device_state *   elems
 
   size_t   max
 
result_states
 The resulting device state updates caused by some function call.
 
static ast_cond_t update_cond
 Condition wait variable for device state updates.
 
static ast_mutex_t update_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 Mutex for update_cond.
 

Detailed Description

Device State Test Module.

Author
David Vossel dvoss.nosp@m.el@d.nosp@m.igium.nosp@m..com

Definition in file test_devicestate.c.

Variable Documentation

struct ast_channel_tech chan_test_devicestate
Initial value:
= {
.type = DEVICE_STATE_CHANNEL_TYPE,
.description = "Device State Unit Test Channel Driver",
.devicestate = chan_test_devicestate_cb,
}

Definition at line 919 of file test_devicestate.c.