51 const char *
name = data;
67 return 0 == strcmp(name, snapshot->
resource);
83 info->name = __func__;
85 info->summary =
"Test endpoint updates as its state changes";
87 "Test endpoint updates as its state changes";
94 ast_test_validate(
test,
NULL != uut);
97 ast_test_validate(
test,
NULL != sink);
106 ast_test_validate(
test, 1 == actual_count);
107 msg = sink->messages[0];
116 ast_test_validate(
test, 2 == actual_count);
117 msg = sink->messages[1];
140 info->name = __func__;
142 info->summary =
"Test endpoint state change messages";
143 info->description =
"Test endpoint state change messages";
151 ast_test_validate(
test,
NULL != sink);
159 ast_test_validate(
test,
NULL != uut);
168 ast_test_validate(
test, 0 <= message_index);
171 msg = sink->messages[message_index];
178 ast_test_validate(
test, 0 == strcmp(
"TEST", actual_snapshot->
tech));
179 ast_test_validate(
test,
180 0 == strcmp(__func__, actual_snapshot->
resource));
189 ast_test_validate(
test, 0 <= message_index);
192 msg = sink->messages[message_index];
198 ast_test_validate(
test, 0 == strcmp(
"TEST", actual_snapshot->
tech));
199 ast_test_validate(
test,
200 0 == strcmp(__func__, actual_snapshot->
resource));
219 info->name = __func__;
221 info->summary =
"Test channel messages on an endpoint topic";
223 "Test channel messages on an endpoint topic";
230 ast_test_validate(
test,
NULL != uut);
233 ast_test_validate(
test,
NULL != sink);
240 "100",
"default",
NULL,
NULL, 0,
"TEST/test_res");
241 ast_test_validate(
test,
NULL != chan);
247 ast_test_validate(
test, 1 == actual_count);
249 msg = sink->messages[0];
260 ast_test_validate(
test, 3 == actual_count);
262 msg = sink->messages[1];
266 msg = sink->messages[2];
296 .requires =
"res_stasis_test",
Structure that collects messages from a topic.
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
struct stasis_message * old_snapshot
Old value from the cache.
int stasis_message_sink_wait_for(struct stasis_message_sink *sink, int start, stasis_wait_cb cmp_cb, const void *data, int timeout_millis)
Wait for a message that matches the given criteria.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
AST_TEST_DEFINE(state_changes)
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
static int load_module(void)
#define AST_TEST_REGISTER(cb)
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
int stasis_message_sink_wait_for_count(struct stasis_message_sink *sink, int num_messages, int timeout_millis)
Wait for a sink's num_messages field to reach a certain level.
struct stasis_message_sink * stasis_message_sink_create(void)
Create a message sink.
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
static int unload_module(void)
General Asterisk PBX channel definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
const ast_string_field resource
struct stasis_message_type * stasis_cache_update_type(void)
Message type for cache update messages.
stasis_subscription_cb stasis_message_sink_cb(void)
Topic callback to receive messages.
int ast_endpoint_add_channel(struct ast_endpoint *endpoint, struct ast_channel *chan)
Adds a channel to the given endpoint.
A snapshot of an endpoint's state.
#define stasis_subscribe(topic, callback, data)
static int cache_update(struct stasis_message *msg, const void *data)
Message matcher looking for cache update messages.
struct stasis_message * new_snapshot
New value.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
#define AST_TEST_UNREGISTER(cb)
const ast_string_field tech
#define STASIS_SINK_DEFAULT_WAIT
struct stasis_message_type * type
Convenience reference to snapshot type.
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
static const char * test_category
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_endpoint_set_max_channels(struct ast_endpoint *endpoint, int max_channels)
Updates the maximum number of channels an endpoint supports.
struct stasis_forward * sub
The state change queue. State changes are queued for processing by a separate thread.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Asterisk module definitions.
enum ast_endpoint_state state
Test infrastructure for dealing with Stasis.