Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
test_stasis_channels.c File Reference

Test Stasis Channel messages and objects. More...

#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/test.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/channel.h"
Include dependency graph for test_stasis_channels.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
 AST_TEST_DEFINE (channel_blob_create)
 
 AST_TEST_DEFINE (null_blob)
 
 AST_TEST_DEFINE (multi_channel_blob_create)
 
 AST_TEST_DEFINE (multi_channel_blob_snapshots)
 
 AST_TEST_DEFINE (channel_snapshot_json)
 
static int load_module (void)
 
static void safe_channel_release (struct ast_channel *chan)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = 0 , .description = "Stasis Channel Testing" , .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, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const char * test_category = "/stasis/channels/"
 

Detailed Description

Test Stasis Channel messages and objects.

Author
Matt Jordan <[email protected]> 

Definition in file test_stasis_channels.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 335 of file test_stasis_channels.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 335 of file test_stasis_channels.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 335 of file test_stasis_channels.c.

◆ AST_TEST_DEFINE() [1/5]

AST_TEST_DEFINE ( channel_blob_create  )

Definition at line 53 of file test_stasis_channels.c.

References ao2_cleanup, ao2_ref, ast_channel_alloc, ast_channel_blob_create(), ast_channel_lock, ast_channel_unlock, ast_json_pack(), ast_json_unref(), AST_STATE_DOWN, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_channel_blob::blob, sip_to_pjsip::info(), NULL, RAII_VAR, safe_channel_release(), ast_channel_blob::snapshot, stasis_message_data(), stasis_message_type(), stasis_message_type_create(), STASIS_MESSAGE_TYPE_SUCCESS, test_category, TEST_EXECUTE, TEST_INIT, and type.

54 {
55  struct ast_channel_blob *blob;
57  RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
59  RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
60  RAII_VAR(struct ast_json *, bad_json, NULL, ast_json_unref);
61 
62  switch (cmd) {
63  case TEST_INIT:
64  info->name = __func__;
65  info->category = test_category;
66  info->summary = "Test creation of ast_channel_blob objects";
67  info->description = "Test creation of ast_channel_blob objects";
68  return AST_TEST_NOT_RUN;
69  case TEST_EXECUTE:
70  break;
71  }
72 
73  ast_test_validate(test, stasis_message_type_create("test-type", NULL, &type) == STASIS_MESSAGE_TYPE_SUCCESS);
74  chan = ast_channel_alloc(0, AST_STATE_DOWN, "100", "Alice", "100", "100", "default", NULL, NULL, 0, "TEST/Alice");
75  ast_channel_unlock(chan);
76  json = ast_json_pack("{s: s}",
77  "foo", "bar");
78 
79  /* Off nominal creation */
80  ast_channel_lock(chan);
81  ast_test_validate(test, NULL == ast_channel_blob_create(chan, NULL, json));
82 
83  /* Test for single channel */
84  msg = ast_channel_blob_create(chan, type, json);
85  ast_channel_unlock(chan);
86  ast_test_validate(test, NULL != msg);
87  blob = stasis_message_data(msg);
88  ast_test_validate(test, NULL != blob);
89  ast_test_validate(test, NULL != blob->snapshot);
90  ast_test_validate(test, NULL != blob->blob);
91  ast_test_validate(test, type == stasis_message_type(msg));
92 
93  ast_test_validate(test, 1 == ao2_ref(msg, 0));
94  ao2_cleanup(msg);
95 
96  /* Test for global channels */
97  msg = ast_channel_blob_create(NULL, type, json);
98  ast_test_validate(test, NULL != msg);
99  blob = stasis_message_data(msg);
100  ast_test_validate(test, NULL != blob);
101  ast_test_validate(test, NULL == blob->snapshot);
102  ast_test_validate(test, NULL != blob->blob);
103  ast_test_validate(test, type == stasis_message_type(msg));
104 
105  return AST_TEST_PASS;
106 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * blob
struct ast_channel_snapshot * snapshot
static void safe_channel_release(struct ast_channel *chan)
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
enum stasis_message_type_result stasis_message_type_create(const char *name, struct stasis_message_vtable *vtable, struct stasis_message_type **result)
Create a new message type.
#define NULL
Definition: resample.c:96
Blob of data associated with a channel.
static const char * test_category
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
def info(msg)
struct stasis_message * ast_channel_blob_create(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Creates a ast_channel_blob message.
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Abstract JSON element (object, array, string, int, ...).
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1259

◆ AST_TEST_DEFINE() [2/5]

AST_TEST_DEFINE ( null_blob  )

Definition at line 108 of file test_stasis_channels.c.

References ao2_cleanup, ast_channel_alloc, ast_channel_blob_create(), ast_channel_lock, ast_channel_unlock, ast_json_null(), ast_json_pack(), ast_json_unref(), AST_STATE_DOWN, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_channel_blob::blob, sip_to_pjsip::info(), NULL, RAII_VAR, safe_channel_release(), ast_channel_blob::snapshot, stasis_message_data(), stasis_message_type(), stasis_message_type_create(), STASIS_MESSAGE_TYPE_SUCCESS, test_category, TEST_EXECUTE, TEST_INIT, and type.

109 {
110  struct ast_channel_blob *blob;
112  RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
113  RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
114  RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
115  RAII_VAR(struct ast_json *, bad_json, NULL, ast_json_unref);
116 
117  switch (cmd) {
118  case TEST_INIT:
119  info->name = __func__;
120  info->category = test_category;
121  info->summary = "Test creation of ast_channel_blob objects";
122  info->description = "Test creation of ast_channel_blob objects";
123  return AST_TEST_NOT_RUN;
124  case TEST_EXECUTE:
125  break;
126  }
127 
128  ast_test_validate(test, stasis_message_type_create("test-type", NULL, &type) == STASIS_MESSAGE_TYPE_SUCCESS);
129  chan = ast_channel_alloc(0, AST_STATE_DOWN, "100", "Alice", "100", "100", "default", NULL, NULL, 0, "TEST/Alice");
130  ast_channel_unlock(chan);
131  json = ast_json_pack("{s: s}",
132  "foo", "bar");
133 
134  /* Test for single channel */
135  ast_channel_lock(chan);
136  msg = ast_channel_blob_create(chan, type, NULL);
137  ast_channel_unlock(chan);
138  ast_test_validate(test, NULL != msg);
139  blob = stasis_message_data(msg);
140  ast_test_validate(test, NULL != blob);
141  ast_test_validate(test, NULL != blob->snapshot);
142  ast_test_validate(test, ast_json_null() == blob->blob);
143  ast_test_validate(test, type == stasis_message_type(msg));
144 
145  return AST_TEST_PASS;
146 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * blob
struct ast_channel_snapshot * snapshot
static void safe_channel_release(struct ast_channel *chan)
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
enum stasis_message_type_result stasis_message_type_create(const char *name, struct stasis_message_vtable *vtable, struct stasis_message_type **result)
Create a new message type.
#define NULL
Definition: resample.c:96
Blob of data associated with a channel.
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
static const char * test_category
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
def info(msg)
struct stasis_message * ast_channel_blob_create(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Creates a ast_channel_blob message.
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Abstract JSON element (object, array, string, int, ...).
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1259

◆ AST_TEST_DEFINE() [3/5]

AST_TEST_DEFINE ( multi_channel_blob_create  )

Definition at line 148 of file test_stasis_channels.c.

References ao2_cleanup, ast_json_pack(), ast_json_unref(), ast_multi_channel_blob_create(), ast_multi_channel_blob_get_json(), AST_TEST_NOT_RUN, AST_TEST_PASS, ast_channel_blob::blob, sip_to_pjsip::info(), NULL, RAII_VAR, test_category, TEST_EXECUTE, and TEST_INIT.

149 {
151  RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
152  RAII_VAR(struct ast_json *, bad_json, NULL, ast_json_unref);
153 
154  switch (cmd) {
155  case TEST_INIT:
156  info->name = __func__;
157  info->category = test_category;
158  info->summary = "Test creation of ast_multi_channel_blob objects";
159  info->description = "Test creation of ast_multi_channel_blob objects";
160  return AST_TEST_NOT_RUN;
161  case TEST_EXECUTE:
162  break;
163  }
164 
165  json = ast_json_pack("{s: s}",
166  "foo", "bar");
167 
168  /* Test for single channel */
170  ast_test_validate(test, NULL != blob);
171  ast_test_validate(test, NULL != ast_multi_channel_blob_get_json(blob));
172 
173  return AST_TEST_PASS;
174 }
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * blob
#define NULL
Definition: resample.c:96
struct ast_json * ast_multi_channel_blob_get_json(struct ast_multi_channel_blob *obj)
Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj...
static const char * test_category
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
def info(msg)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
A multi channel blob data structure for multi_channel_blob stasis messages.
Abstract JSON element (object, array, string, int, ...).
struct ast_multi_channel_blob * ast_multi_channel_blob_create(struct ast_json *blob)
Create a ast_multi_channel_blob suitable for a stasis_message.

◆ AST_TEST_DEFINE() [4/5]

AST_TEST_DEFINE ( multi_channel_blob_snapshots  )

Definition at line 176 of file test_stasis_channels.c.

References ao2_cleanup, ao2_container_count(), ao2_find, ao2_ref, ast_channel_alloc, ast_channel_lock, ast_channel_snapshot_create(), ast_channel_unlock, ast_json_pack(), ast_json_unref(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_create(), ast_multi_channel_blob_get_channel(), ast_multi_channel_blob_get_channels(), AST_STATE_DOWN, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_channel_snapshot::base, ast_channel_blob::blob, sip_to_pjsip::info(), ast_channel_snapshot_base::name, NULL, OBJ_KEY, RAII_VAR, safe_channel_release(), test_category, TEST_EXECUTE, and TEST_INIT.

177 {
179  RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
180  RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
181  RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
182  RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
183  struct ast_channel_snapshot *snapshot;
184  struct ao2_container *matches;
185 
186  switch (cmd) {
187  case TEST_INIT:
188  info->name = __func__;
189  info->category = test_category;
190  info->summary = "Test creation of ast_multi_channel_blob objects";
191  info->description = "Test creation of ast_multi_channel_blob objects";
192  return AST_TEST_NOT_RUN;
193  case TEST_EXECUTE:
194  break;
195  }
196 
197  json = ast_json_pack("{s: s}",
198  "type", "test");
199  chan_alice = ast_channel_alloc(0, AST_STATE_DOWN, "100", "Alice", "100", "100", "default", NULL, NULL, 0, "TEST/Alice");
200  ast_channel_unlock(chan_alice);
201  chan_bob = ast_channel_alloc(0, AST_STATE_DOWN, "200", "Bob", "200", "200", "default", NULL, NULL, 0, "TEST/Bob");
202  ast_channel_unlock(chan_bob);
203  chan_charlie = ast_channel_alloc(0, AST_STATE_DOWN, "300", "Bob", "300", "300", "default", NULL, NULL, 0, "TEST/Charlie");
204  ast_channel_unlock(chan_charlie);
205 
206  blob = ast_multi_channel_blob_create(json);
207  ast_channel_lock(chan_alice);
209  ast_channel_unlock(chan_alice);
210  ast_channel_lock(chan_bob);
212  ast_channel_unlock(chan_bob);
213  ast_channel_lock(chan_charlie);
215  ast_channel_unlock(chan_charlie);
216 
217  /* Test for unknown role */
218  ast_test_validate(test, NULL == ast_multi_channel_blob_get_channel(blob, "Foobar"));
219 
220  /* Test for single match */
221  snapshot = ast_multi_channel_blob_get_channel(blob, "Caller");
222  ast_test_validate(test, NULL != snapshot);
223  ast_test_validate(test, 0 == strcmp("TEST/Alice", snapshot->base->name));
224 
225  /* Test for single match, multiple possibilities */
226  snapshot = ast_multi_channel_blob_get_channel(blob, "Peer");
227  ast_test_validate(test, NULL != snapshot);
228  ast_test_validate(test, 0 != strcmp("TEST/Alice", snapshot->base->name));
229 
230  /* Multi-match */
231  matches = ast_multi_channel_blob_get_channels(blob, "Peer");
232  ast_test_validate(test, NULL != matches);
233  ast_test_validate(test, 2 == ao2_container_count(matches));
234  snapshot = ao2_find(matches, "TEST/Bob", OBJ_KEY);
235  ast_test_validate(test, NULL != snapshot);
236  ao2_cleanup(snapshot);
237  snapshot = ao2_find(matches, "TEST/Charlie", OBJ_KEY);
238  ast_test_validate(test, NULL != snapshot);
239  ao2_cleanup(snapshot);
240  ast_test_validate(test, 1 == ao2_ref(matches, 0));
241  ao2_cleanup(matches);
242 
243  return AST_TEST_PASS;
244 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_channel_snapshot_base * base
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
#define OBJ_KEY
Definition: astobj2.h:1155
struct ast_json * blob
Structure representing a snapshot of channel state.
static void safe_channel_release(struct ast_channel *chan)
#define NULL
Definition: resample.c:96
struct ast_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate...
static const char * test_category
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
void ast_multi_channel_blob_add_channel(struct ast_multi_channel_blob *obj, const char *role, struct ast_channel_snapshot *snapshot)
Add a ast_channel_snapshot to a ast_multi_channel_blob object.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ao2_container * ast_multi_channel_blob_get_channels(struct ast_multi_channel_blob *obj, const char *role)
Retrieve all channel snapshots associated with a specific role from a ast_multi_channel_blob.
def info(msg)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct ast_channel_snapshot * ast_multi_channel_blob_get_channel(struct ast_multi_channel_blob *obj, const char *role)
Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob.
A multi channel blob data structure for multi_channel_blob stasis messages.
Abstract JSON element (object, array, string, int, ...).
Generic container type.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1259
struct ast_multi_channel_blob * ast_multi_channel_blob_create(struct ast_json *blob)
Create a ast_multi_channel_blob suitable for a stasis_message.
const ast_string_field name

◆ AST_TEST_DEFINE() [5/5]

AST_TEST_DEFINE ( channel_snapshot_json  )

Definition at line 246 of file test_stasis_channels.c.

References ao2_cleanup, ast_channel_alloc, ast_channel_creationtime(), ast_channel_lock, ast_channel_snapshot_create(), ast_channel_snapshot_to_json(), ast_channel_uniqueid(), ast_channel_unlock, ast_json_equal(), ast_json_pack(), ast_json_timeval(), ast_json_unref(), AST_STATE_DOWN, AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), NULL, RAII_VAR, safe_channel_release(), test_category, TEST_EXECUTE, and TEST_INIT.

247 {
248  RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
249  RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
250  RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
251  RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
252  RAII_VAR(struct ast_json *, actual, NULL, ast_json_unref);
253 
254  switch (cmd) {
255  case TEST_INIT:
256  info->name = __func__;
257  info->category = test_category;
258  info->summary = "Test creation of ast_channel_blob objects";
259  info->description = "Test creation of ast_channel_blob objects";
260  return AST_TEST_NOT_RUN;
261  case TEST_EXECUTE:
262  break;
263  }
264 
265  ast_test_validate(test, NULL == ast_channel_snapshot_to_json(NULL, NULL));
266 
267  chan = ast_channel_alloc(0, AST_STATE_DOWN, "cid_num", "cid_name", "acctcode", "exten", "context", NULL, NULL, 0, "TEST/name");
268  ast_channel_unlock(chan);
269  ast_test_validate(test, NULL != chan);
270  ast_channel_lock(chan);
271  snapshot = ast_channel_snapshot_create(chan);
272  ast_channel_unlock(chan);
273  ast_test_validate(test, NULL != snapshot);
274 
275  actual = ast_channel_snapshot_to_json(snapshot, NULL);
276  expected = ast_json_pack("{ s: s, s: s, s: s, s: s,"
277  " s: { s: s, s: s, s: i, s: s, s: s },"
278  " s: { s: s, s: s },"
279  " s: { s: s, s: s },"
280  " s: s"
281  " s: o"
282  "}",
283  "name", "TEST/name",
284  "state", "Down",
285  "accountcode", "acctcode",
286  "id", ast_channel_uniqueid(chan),
287  "dialplan",
288  "context", "context",
289  "exten", "exten",
290  "priority", 1,
291  "app_name", "",
292  "app_data", "",
293  "caller",
294  "name", "cid_name",
295  "number", "cid_num",
296  "connected",
297  "name", "",
298  "number", "",
299  "language", "en",
300  "creationtime",
303 
304  ast_test_validate(test, ast_json_equal(expected, actual));
305 
306  return AST_TEST_PASS;
307 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
Structure representing a snapshot of channel state.
static void safe_channel_release(struct ast_channel *chan)
#define NULL
Definition: resample.c:96
struct ast_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate...
static const char * test_category
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
Definition: json.c:649
const char * ast_channel_uniqueid(const struct ast_channel *chan)
def info(msg)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_json * ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_channel_snapshot.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
int ast_json_equal(const struct ast_json *lhs, const struct ast_json *rhs)
Compare two JSON objects.
Definition: json.c:347
Abstract JSON element (object, array, string, int, ...).
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1259

◆ load_module()

static int load_module ( void  )
static

Definition at line 320 of file test_stasis_channels.c.

References AST_MODULE_INFO(), AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, AST_TEST_REGISTER, ASTERISK_GPL_KEY, and unload_module().

321 {
322  AST_TEST_REGISTER(channel_blob_create);
323  AST_TEST_REGISTER(null_blob);
324  AST_TEST_REGISTER(multi_channel_blob_create);
325  AST_TEST_REGISTER(multi_channel_blob_snapshots);
326  AST_TEST_REGISTER(channel_snapshot_json);
327 
329 }
#define AST_TEST_REGISTER(cb)
Definition: test.h:127

◆ safe_channel_release()

static void safe_channel_release ( struct ast_channel chan)
static

Definition at line 45 of file test_stasis_channels.c.

References ast_channel_release().

Referenced by AST_TEST_DEFINE().

46 {
47  if (!chan) {
48  return;
49  }
50  ast_channel_release(chan);
51 }
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1584

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 309 of file test_stasis_channels.c.

References AST_TEST_UNREGISTER.

Referenced by load_module().

310 {
311  AST_TEST_UNREGISTER(channel_blob_create);
312  AST_TEST_UNREGISTER(null_blob);
313  AST_TEST_UNREGISTER(multi_channel_blob_create);
314  AST_TEST_UNREGISTER(multi_channel_blob_snapshots);
315  AST_TEST_UNREGISTER(channel_snapshot_json);
316 
317  return 0;
318 }
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = 0 , .description = "Stasis Channel Testing" , .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, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module }
static

Definition at line 335 of file test_stasis_channels.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 335 of file test_stasis_channels.c.

◆ test_category

const char* test_category = "/stasis/channels/"
static

Definition at line 43 of file test_stasis_channels.c.

Referenced by AST_TEST_DEFINE().