51 const char *
name = data;
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));
218 int channel_index = -1;
219 int endpoint_index = -1;
223 info->name = __func__;
225 info->summary =
"Test channel messages on an endpoint topic";
227 "Test channel messages on an endpoint topic";
234 ast_test_validate(
test,
NULL != uut);
237 ast_test_validate(
test,
NULL != sink);
244 "100",
"default",
NULL,
NULL, 0,
"TEST/test_res");
245 ast_test_validate(
test,
NULL != chan);
251 ast_test_validate(
test, 1 == actual_count);
253 msg = sink->messages[0];
265 ast_test_validate(
test, expected_count == actual_count);
267 for (i = 0; i < expected_count; i++) {
268 msg = sink->messages[i];
277 ast_test_validate(
test, channel_index >= 0 && endpoint_index >= 0);
304 .
requires =
"res_stasis_test",
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
void ast_endpoint_set_max_channels(struct ast_endpoint *endpoint, int max_channels)
Updates the maximum number of channels an endpoint supports.
int ast_endpoint_add_channel(struct ast_endpoint *endpoint, struct ast_channel *chan)
Adds a channel to the given endpoint.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
struct stasis_message_type * stasis_cache_update_type(void)
Message type for cache update messages.
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
struct stasis_forward * sub
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
#define stasis_subscribe(topic, callback, data)
Test infrastructure for dealing with Stasis.
#define STASIS_SINK_DEFAULT_WAIT
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.
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 stasis_message_sink * stasis_message_sink_create(void)
Create a message sink.
stasis_subscription_cb stasis_message_sink_cb(void)
Topic callback to receive messages.
Main Channel structure associated with a channel.
A snapshot of an endpoint's state.
const ast_string_field tech
enum ast_endpoint_state state
const ast_string_field resource
Structure that collects messages from a topic.
The state change queue. State changes are queued for processing by a separate thread.
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
static int cache_update(struct stasis_message *msg, const void *data)
Message matcher looking for cache update messages.
static int load_module(void)
static int unload_module(void)
static const char * test_category
AST_TEST_DEFINE(state_changes)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.