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

Channel features unit tests. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/channel.h"
#include "asterisk/time.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_basic.h"
#include "asterisk/features.h"
#include "asterisk/format_cache.h"
Include dependency graph for test_channel_feature_hooks.c:

Go to the source code of this file.

Macros

#define CHANNEL_TECH_NAME   "FeaturesTestChannel"
 
#define HANGUP_CHANNEL(channel)
 Hang up a test channel safely. More...
 
#define START_ALICE(channel)   START_CHANNEL(channel, "Alice", "100")
 Create a test_features_chan_tech for Alice. More...
 
#define START_BOB(channel)   START_CHANNEL(channel, "Bob", "200")
 Create a test_features_chan_tech for Bob. More...
 
#define START_CHANNEL(channel, name, number)
 
#define TEST_BACKEND_NAME   "Features Test Logging"
 
#define TEST_CATEGORY   "/channels/features/"
 
#define TEST_CHANNEL_FORMAT   ast_format_slin
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
 AST_TEST_DEFINE (test_features_channel_dtmf)
 
 AST_TEST_DEFINE (test_features_channel_interval)
 
static int feature_callback (struct ast_bridge_channel *bridge_channel, void *obj)
 
static int load_module (void)
 
static void safe_bridge_destroy (struct ast_bridge *bridge)
 
static void safe_channel_release (struct ast_channel *chan)
 
static void stream_periodic_frames (struct ast_channel *chan, int ms, int interval_ms)
 
static void test_nanosleep (int secs, long nanosecs)
 
static int unload_module (void)
 
static void wait_for_bridged (struct ast_channel *channel)
 Wait until a channel is bridged. More...
 
static void wait_for_unbridged (struct ast_channel *channel)
 Wait until a channel is not bridged. More...
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Bridge Features Unit Tests" , .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 struct ast_channel_tech test_features_chan_tech
 A channel technology used for the unit tests. More...
 

Detailed Description

Channel features unit tests.

Author
Kinsey Moore kmoor.nosp@m.e@di.nosp@m.gium..nosp@m.com

Definition in file test_channel_feature_hooks.c.

Macro Definition Documentation

◆ CHANNEL_TECH_NAME

#define CHANNEL_TECH_NAME   "FeaturesTestChannel"

Definition at line 45 of file test_channel_feature_hooks.c.

◆ HANGUP_CHANNEL

#define HANGUP_CHANNEL (   channel)

Hang up a test channel safely.

Definition at line 107 of file test_channel_feature_hooks.c.

Referenced by AST_TEST_DEFINE().

◆ START_ALICE

#define START_ALICE (   channel)    START_CHANNEL(channel, "Alice", "100")

Create a test_features_chan_tech for Alice.

Definition at line 90 of file test_channel_feature_hooks.c.

Referenced by AST_TEST_DEFINE().

◆ START_BOB

#define START_BOB (   channel)    START_CHANNEL(channel, "Bob", "200")

Create a test_features_chan_tech for Bob.

Definition at line 93 of file test_channel_feature_hooks.c.

Referenced by AST_TEST_DEFINE().

◆ START_CHANNEL

#define START_CHANNEL (   channel,
  name,
  number 
)

Definition at line 95 of file test_channel_feature_hooks.c.

◆ TEST_BACKEND_NAME

#define TEST_BACKEND_NAME   "Features Test Logging"

Definition at line 47 of file test_channel_feature_hooks.c.

◆ TEST_CATEGORY

#define TEST_CATEGORY   "/channels/features/"

Definition at line 43 of file test_channel_feature_hooks.c.

Referenced by AST_TEST_DEFINE().

◆ TEST_CHANNEL_FORMAT

#define TEST_CHANNEL_FORMAT   ast_format_slin

Definition at line 49 of file test_channel_feature_hooks.c.

Referenced by load_module().

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 358 of file test_channel_feature_hooks.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 358 of file test_channel_feature_hooks.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 358 of file test_channel_feature_hooks.c.

◆ AST_TEST_DEFINE() [1/2]

AST_TEST_DEFINE ( test_features_channel_dtmf  )

Definition at line 160 of file test_channel_feature_hooks.c.

References ast_bridge_basic_new(), ast_bridge_depart(), ast_bridge_dtmf_hook(), ast_bridge_features_cleanup(), ast_bridge_features_init(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_DEPARTABLE, ast_channel_feature_hooks_append(), AST_FRAME_DTMF, ast_queue_frame(), AST_TEST_NOT_RUN, AST_TEST_PASS, feature_callback(), HANGUP_CHANNEL, sip_to_pjsip::info(), ast_frame_subclass::integer, ast_frame::len, NULL, RAII_VAR, safe_bridge_destroy(), safe_channel_release(), START_ALICE, START_BOB, stream_periodic_frames(), ast_frame::subclass, TEST_CATEGORY, TEST_EXECUTE, TEST_INIT, wait_for_bridged(), and wait_for_unbridged().

161 {
162  RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
163  RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
164  RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
165  RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
166  struct ast_bridge_features features;
167  int callback_executed = 0;
168  struct ast_frame f = { AST_FRAME_DTMF, };
169 
170  switch (cmd) {
171  case TEST_INIT:
172  info->name = __func__;
173  info->category = TEST_CATEGORY;
174  info->summary = "Test running DTMF hooks on a channel via the feature hooks mechanism";
175  info->description =
176  "This test creates two channels, adds a DTMF hook to one, places them into\n"
177  "a bridge, and verifies that the DTMF hook added to the channel feature\n"
178  "hooks can be triggered once the channel is bridged.";
179  return AST_TEST_NOT_RUN;
180  case TEST_EXECUTE:
181  break;
182  }
183 
184  /* Create the bridges */
185  bridge1 = ast_bridge_basic_new();
186  ast_test_validate(test, bridge1 != NULL);
187  bridge2 = ast_bridge_basic_new();
188  ast_test_validate(test, bridge2 != NULL);
189 
190  /* Create channels that will go into the bridge */
191  START_ALICE(chan_alice);
192  START_BOB(chan_bob);
193 
194  /* Setup the features and add them to alice */
195  ast_bridge_features_init(&features);
196  ast_test_validate(test, !ast_bridge_dtmf_hook(&features, "##**", feature_callback, &callback_executed, NULL, 0));
197  ast_test_validate(test, !ast_channel_feature_hooks_append(chan_alice, &features));
198  ast_bridge_features_cleanup(&features);
199 
200  /* Bridge the channels */
201  ast_test_validate(test, !ast_bridge_impart(bridge1, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
202  ast_test_validate(test, !ast_bridge_impart(bridge1, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
203 
204  wait_for_bridged(chan_alice);
205 
206  /* Execute the feature */
207  f.len = 100;
208  f.subclass.integer = '#';
209  ast_queue_frame(chan_alice, &f);
210  ast_queue_frame(chan_alice, &f);
211  f.subclass.integer = '*';
212  ast_queue_frame(chan_alice, &f);
213  ast_queue_frame(chan_alice, &f);
214 
215  stream_periodic_frames(chan_alice, 1000, 20);
216 
217  /* Remove the channels from the bridge */
218  ast_test_validate(test, !ast_bridge_depart(chan_alice));
219  ast_test_validate(test, !ast_bridge_depart(chan_bob));
220 
221  wait_for_unbridged(chan_alice);
222 
223  /* Bridge the channels again to ensure that the feature hook remains on the channel */
224  ast_test_validate(test, !ast_bridge_impart(bridge2, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
225  ast_test_validate(test, !ast_bridge_impart(bridge2, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
226 
227  wait_for_bridged(chan_alice);
228 
229  /* Execute the feature */
230  f.len = 100;
231  f.subclass.integer = '#';
232  ast_queue_frame(chan_alice, &f);
233  ast_queue_frame(chan_alice, &f);
234  f.subclass.integer = '*';
235  ast_queue_frame(chan_alice, &f);
236  ast_queue_frame(chan_alice, &f);
237 
238  stream_periodic_frames(chan_alice, 1000, 20);
239 
240  /* Remove the channels from the bridge */
241  ast_test_validate(test, !ast_bridge_depart(chan_alice));
242  ast_test_validate(test, !ast_bridge_depart(chan_bob));
243 
244  /* Hangup the channels */
245  HANGUP_CHANNEL(chan_alice);
246  HANGUP_CHANNEL(chan_bob);
247 
248  ast_test_validate(test, callback_executed == 2);
249 
250  return AST_TEST_PASS;
251 }
Main Channel structure associated with a channel.
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition: bridge.c:3720
static void safe_channel_release(struct ast_channel *chan)
static int feature_callback(struct ast_bridge_channel *bridge_channel, void *obj)
Structure that contains features information.
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition: bridge.c:3687
static void wait_for_bridged(struct ast_channel *channel)
Wait until a channel is bridged.
#define NULL
Definition: resample.c:96
#define AST_FRAME_DTMF
struct ast_frame_subclass subclass
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
Definition: bridge.c:1924
#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
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
Structure that contains information about a bridge.
Definition: bridge.h:357
def info(msg)
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
Definition: bridge.c:1952
static void safe_bridge_destroy(struct ast_bridge *bridge)
static void wait_for_unbridged(struct ast_channel *channel)
Wait until a channel is not bridged.
int ast_bridge_dtmf_hook(struct ast_bridge_features *features, const char *dtmf, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a DTMF hook to a bridge features structure.
Definition: bridge.c:3245
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
#define START_BOB(channel)
Create a test_features_chan_tech for Bob.
Data structure associated with a single frame of data.
#define TEST_CATEGORY
int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features)
Appends to the channel-attached features a channel has access to upon being bridged.
Definition: channel.c:11152
#define START_ALICE(channel)
Create a test_features_chan_tech for Alice.
#define HANGUP_CHANNEL(channel)
Hang up a test channel safely.
static void stream_periodic_frames(struct ast_channel *chan, int ms, int interval_ms)

◆ AST_TEST_DEFINE() [2/2]

AST_TEST_DEFINE ( test_features_channel_interval  )

Definition at line 253 of file test_channel_feature_hooks.c.

References ast_bridge_basic_new(), ast_bridge_depart(), ast_bridge_features_cleanup(), ast_bridge_features_init(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_DEPARTABLE, ast_bridge_interval_hook(), ast_channel_feature_hooks_append(), AST_TEST_NOT_RUN, AST_TEST_PASS, feature_callback(), HANGUP_CHANNEL, sip_to_pjsip::info(), NULL, RAII_VAR, safe_bridge_destroy(), safe_channel_release(), START_ALICE, START_BOB, TEST_CATEGORY, TEST_EXECUTE, TEST_INIT, test_nanosleep(), wait_for_bridged(), and wait_for_unbridged().

254 {
255  RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
256  RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
257  RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
258  RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
259  struct ast_bridge_features features;
260  int callback_executed = 0;
261 
262  switch (cmd) {
263  case TEST_INIT:
264  info->name = __func__;
265  info->category = TEST_CATEGORY;
266  info->summary = "Test running interval hooks on a channel via the feature hooks mechanism";
267  info->description =
268  "This test creates two channels, adds an interval hook to one, places them\n"
269  "into a bridge, and verifies that the interval hook added to the channel\n"
270  "feature hooks is triggered once the channel is bridged.";
271  return AST_TEST_NOT_RUN;
272  case TEST_EXECUTE:
273  break;
274  }
275 
276  /* Create the bridges */
277  bridge1 = ast_bridge_basic_new();
278  ast_test_validate(test, bridge1 != NULL);
279  bridge2 = ast_bridge_basic_new();
280  ast_test_validate(test, bridge2 != NULL);
281 
282  /* Create channels that will go into the bridge */
283  START_ALICE(chan_alice);
284  START_BOB(chan_bob);
285 
286  /* Setup the features and add them to alice */
287  ast_bridge_features_init(&features);
288  ast_test_validate(test, !ast_bridge_interval_hook(&features, 0, 1000, feature_callback, &callback_executed, NULL, 0));
289  ast_test_validate(test, !ast_channel_feature_hooks_append(chan_alice, &features));
290  ast_bridge_features_cleanup(&features);
291 
292  /* Bridge the channels */
293  ast_test_validate(test, !ast_bridge_impart(bridge1, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
294  ast_test_validate(test, !ast_bridge_impart(bridge1, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
295 
296  wait_for_bridged(chan_alice);
297 
298  /* Let the interval hook execute once */
299  test_nanosleep(1, 500000000);
300 
301  /* Remove the channels from the bridge */
302  ast_test_validate(test, !ast_bridge_depart(chan_alice));
303  ast_test_validate(test, !ast_bridge_depart(chan_bob));
304 
305  wait_for_unbridged(chan_alice);
306 
307  ast_test_validate(test, callback_executed >= 1);
308  callback_executed = 0;
309 
310  /* Bridge the channels again to ensure that the feature hook remains on the channel */
311  ast_test_validate(test, !ast_bridge_impart(bridge2, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
312  ast_test_validate(test, !ast_bridge_impart(bridge2, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
313 
314  wait_for_bridged(chan_alice);
315 
316  /* Let the interval hook execute once */
317  test_nanosleep(1, 500000000);
318 
319  /* Remove the channels from the bridge */
320  ast_test_validate(test, !ast_bridge_depart(chan_alice));
321  ast_test_validate(test, !ast_bridge_depart(chan_bob));
322 
323  /* Hangup the channels */
324  HANGUP_CHANNEL(chan_alice);
325  HANGUP_CHANNEL(chan_bob);
326 
327  ast_test_validate(test, callback_executed >= 1);
328 
329  return AST_TEST_PASS;
330 }
Main Channel structure associated with a channel.
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition: bridge.c:3720
static void safe_channel_release(struct ast_channel *chan)
static int feature_callback(struct ast_bridge_channel *bridge_channel, void *obj)
Structure that contains features information.
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition: bridge.c:3687
static void wait_for_bridged(struct ast_channel *channel)
Wait until a channel is bridged.
#define NULL
Definition: resample.c:96
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
Definition: bridge.c:1924
static void test_nanosleep(int secs, long nanosecs)
#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
int ast_bridge_interval_hook(struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach an interval hook to a bridge features structure.
Definition: bridge.c:3382
Structure that contains information about a bridge.
Definition: bridge.h:357
def info(msg)
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
Definition: bridge.c:1952
static void safe_bridge_destroy(struct ast_bridge *bridge)
static void wait_for_unbridged(struct ast_channel *channel)
Wait until a channel is not bridged.
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
#define START_BOB(channel)
Create a test_features_chan_tech for Bob.
#define TEST_CATEGORY
int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features)
Appends to the channel-attached features a channel has access to upon being bridged.
Definition: channel.c:11152
#define START_ALICE(channel)
Create a test_features_chan_tech for Alice.
#define HANGUP_CHANNEL(channel)
Hang up a test channel safely.

◆ feature_callback()

static int feature_callback ( struct ast_bridge_channel bridge_channel,
void *  obj 
)
static

Definition at line 130 of file test_channel_feature_hooks.c.

Referenced by AST_TEST_DEFINE().

131 {
132  int *callback_executed = obj;
133  (*callback_executed)++;
134  return 0;
135 }

◆ load_module()

static int load_module ( void  )
static

Definition at line 344 of file test_channel_feature_hooks.c.

References ast_channel_register(), ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_TEST_REGISTER, ast_channel_tech::capabilities, and TEST_CHANNEL_FORMAT.

345 {
349  }
352 
353  AST_TEST_REGISTER(test_features_channel_dtmf);
354  AST_TEST_REGISTER(test_features_channel_interval);
356 }
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:539
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
struct ast_format_cap * capabilities
Definition: channel.h:633
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static struct ast_channel_tech test_features_chan_tech
A channel technology used for the unit tests.
#define TEST_CHANNEL_FORMAT

◆ safe_bridge_destroy()

static void safe_bridge_destroy ( struct ast_bridge bridge)
static

Definition at line 122 of file test_channel_feature_hooks.c.

References ast_bridge_destroy().

Referenced by AST_TEST_DEFINE().

123 {
124  if (!bridge) {
125  return;
126  }
127  ast_bridge_destroy(bridge, 0);
128 }
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
Definition: bridge.c:970

◆ safe_channel_release()

static void safe_channel_release ( struct ast_channel chan)
static

Definition at line 114 of file test_channel_feature_hooks.c.

References ast_channel_release().

Referenced by AST_TEST_DEFINE().

115 {
116  if (!chan) {
117  return;
118  }
119  ast_channel_release(chan);
120 }
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1584

◆ stream_periodic_frames()

static void stream_periodic_frames ( struct ast_channel chan,
int  ms,
int  interval_ms 
)
static

Definition at line 138 of file test_channel_feature_hooks.c.

References ast_assert, ast_null_frame, ast_queue_frame(), NULL, and test_nanosleep().

Referenced by AST_TEST_DEFINE().

139 {
140  long nanosecs;
141 
142  ast_assert(chan != NULL);
143  ast_assert(0 < ms);
144  ast_assert(0 < interval_ms);
145 
146  nanosecs = interval_ms * 1000000L;
147  while (0 < ms) {
149 
150  if (interval_ms < ms) {
151  ms -= interval_ms;
152  } else {
153  nanosecs = ms * 1000000L;
154  ms = 0;
155  }
156  test_nanosleep(0, nanosecs);
157  }
158 }
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
static void test_nanosleep(int secs, long nanosecs)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
struct ast_frame ast_null_frame
Definition: main/frame.c:79

◆ test_nanosleep()

static void test_nanosleep ( int  secs,
long  nanosecs 
)
static

Definition at line 57 of file test_channel_feature_hooks.c.

References errno.

Referenced by AST_TEST_DEFINE(), stream_periodic_frames(), wait_for_bridged(), and wait_for_unbridged().

58 {
59  struct timespec sleep_time = {secs, nanosecs};
60 
61  while ((nanosleep(&sleep_time, &sleep_time) == -1) && (errno == EINTR)) {
62  }
63 }
int errno

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 332 of file test_channel_feature_hooks.c.

References ao2_cleanup, ast_channel_unregister(), AST_TEST_UNREGISTER, ast_channel_tech::capabilities, and NULL.

333 {
334  AST_TEST_UNREGISTER(test_features_channel_dtmf);
335  AST_TEST_UNREGISTER(test_features_channel_interval);
336 
340 
341  return 0;
342 }
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:570
#define NULL
Definition: resample.c:96
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128
struct ast_format_cap * capabilities
Definition: channel.h:633
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct ast_channel_tech test_features_chan_tech
A channel technology used for the unit tests.

◆ wait_for_bridged()

static void wait_for_bridged ( struct ast_channel channel)
static

Wait until a channel is bridged.

Definition at line 66 of file test_channel_feature_hooks.c.

References ast_channel_is_bridged(), ast_channel_lock, ast_channel_unlock, and test_nanosleep().

Referenced by AST_TEST_DEFINE().

67 {
68  ast_channel_lock(channel);
69  while (!ast_channel_is_bridged(channel)) {
70  ast_channel_unlock(channel);
71  test_nanosleep(0, 1000000);
72  ast_channel_lock(channel);
73  }
74  ast_channel_unlock(channel);
75 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
static void test_nanosleep(int secs, long nanosecs)
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition: channel.c:10746
#define ast_channel_unlock(chan)
Definition: channel.h:2946

◆ wait_for_unbridged()

static void wait_for_unbridged ( struct ast_channel channel)
static

Wait until a channel is not bridged.

Definition at line 78 of file test_channel_feature_hooks.c.

References ast_channel_is_bridged(), ast_channel_lock, ast_channel_unlock, and test_nanosleep().

Referenced by AST_TEST_DEFINE().

79 {
80  ast_channel_lock(channel);
81  while (ast_channel_is_bridged(channel)) {
82  ast_channel_unlock(channel);
83  test_nanosleep(0, 1000000);
84  ast_channel_lock(channel);
85  }
86  ast_channel_unlock(channel);
87 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
static void test_nanosleep(int secs, long nanosecs)
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition: channel.c:10746
#define ast_channel_unlock(chan)
Definition: channel.h:2946

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Bridge Features Unit Tests" , .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

Definition at line 358 of file test_channel_feature_hooks.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 358 of file test_channel_feature_hooks.c.

◆ test_features_chan_tech

struct ast_channel_tech test_features_chan_tech
static
Initial value:
= {
.description = "Mock channel technology for Features tests",
}
#define CHANNEL_TECH_NAME

A channel technology used for the unit tests.

Definition at line 52 of file test_channel_feature_hooks.c.