2013-07-02 14:01:53 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013, Digium, Inc.
|
|
|
|
*
|
|
|
|
* Kinsey Moore <kmoore@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \file
|
|
|
|
* \brief CEL unit tests
|
|
|
|
*
|
|
|
|
* \author Kinsey Moore <kmoore@digium.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*** MODULEINFO
|
|
|
|
<depend>TEST_FRAMEWORK</depend>
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/test.h"
|
|
|
|
#include "asterisk/cel.h"
|
|
|
|
#include "asterisk/channel.h"
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
#include "asterisk/format_cache.h"
|
2013-07-02 14:01:53 +00:00
|
|
|
#include "asterisk/linkedlists.h"
|
|
|
|
#include "asterisk/chanvars.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/causes.h"
|
|
|
|
#include "asterisk/time.h"
|
2013-07-25 04:06:32 +00:00
|
|
|
#include "asterisk/bridge.h"
|
2013-08-02 03:12:38 +00:00
|
|
|
#include "asterisk/bridge_basic.h"
|
|
|
|
#include "asterisk/pickup.h"
|
2013-07-02 14:01:53 +00:00
|
|
|
#include "asterisk/stasis_channels.h"
|
2013-07-25 04:18:05 +00:00
|
|
|
#include "asterisk/stasis_bridges.h"
|
2013-07-20 13:10:22 +00:00
|
|
|
#include "asterisk/json.h"
|
|
|
|
#include "asterisk/features.h"
|
2013-07-20 13:25:05 +00:00
|
|
|
#include "asterisk/core_local.h"
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
#define TEST_CATEGORY "/main/cel/"
|
|
|
|
|
|
|
|
#define CHANNEL_TECH_NAME "CELTestChannel"
|
|
|
|
|
2013-08-17 14:46:44 +00:00
|
|
|
#define TEST_BACKEND_NAME "CEL Test Logging"
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/*! \brief A placeholder for Asterisk's 'real' CEL configuration */
|
|
|
|
static struct ast_cel_general_config *saved_config;
|
|
|
|
|
|
|
|
/*! \brief The CEL config used for CEL unit tests */
|
|
|
|
static struct ast_cel_general_config *cel_test_config;
|
|
|
|
|
2013-07-31 03:49:44 +00:00
|
|
|
/*! \brief Lock used for synchronizing test execution stages with received events */
|
|
|
|
ast_mutex_t mid_test_sync_lock;
|
|
|
|
|
|
|
|
/*! \brief Lock used with sync_out for checking the end of test execution */
|
|
|
|
ast_mutex_t sync_lock;
|
|
|
|
|
|
|
|
/*! \brief Condition used for checking the end of test execution */
|
|
|
|
ast_cond_t sync_out;
|
|
|
|
|
|
|
|
/*! \brief Flag used to trigger a mid-test synchronization, access controlled by mid_test_sync_lock */
|
|
|
|
int do_mid_test_sync = 0;
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/*! \brief A channel technology used for the unit tests */
|
|
|
|
static struct ast_channel_tech test_cel_chan_tech = {
|
|
|
|
.type = CHANNEL_TECH_NAME,
|
|
|
|
.description = "Mock channel technology for CEL tests",
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! \brief A 1 second sleep */
|
|
|
|
static struct timespec to_sleep = {1, 0};
|
|
|
|
|
|
|
|
static void do_sleep(void)
|
|
|
|
{
|
2014-01-28 00:20:46 +00:00
|
|
|
while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
|
|
|
|
}
|
2013-07-02 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#define APPEND_EVENT(chan, ev_type, userevent, extra) do { \
|
2013-09-27 14:08:23 +00:00
|
|
|
if (append_expected_event(chan, ev_type, userevent, extra, NULL)) { \
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
#define APPEND_EVENT_PEER(chan, ev_type, userevent, extra, peer) do { \
|
|
|
|
if (append_expected_event(chan, ev_type, userevent, extra, peer)) { \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define APPEND_EVENT_SNAPSHOT(snapshot, ev_type, userevent, extra, peer) do { \
|
|
|
|
if (append_expected_event_snapshot(snapshot, ev_type, userevent, extra, peer)) { \
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define APPEND_DUMMY_EVENT() do { \
|
|
|
|
if (append_dummy_event()) { \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#define BRIDGE_EXIT(channel, bridge) do { \
|
2013-09-13 22:19:23 +00:00
|
|
|
ast_test_validate(test, !ast_bridge_depart(channel)); \
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT_EVENT(channel, bridge); \
|
2013-07-31 03:49:44 +00:00
|
|
|
mid_test_sync(); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#define BRIDGE_EXIT_EVENT(channel, bridge) do { \
|
2013-09-27 14:08:23 +00:00
|
|
|
RAII_VAR(struct ast_str *, peer_str, NULL, ast_free); \
|
|
|
|
peer_str = test_cel_generate_peer_str(channel, bridge); \
|
|
|
|
ast_test_validate(test, peer_str != NULL); \
|
|
|
|
BRIDGE_EXIT_EVENT_PEER(channel, bridge, ast_str_buffer(peer_str)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BRIDGE_EXIT_EVENT_PEER(channel, bridge, peer) do { \
|
2013-07-20 13:10:22 +00:00
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
|
2014-06-27 02:04:50 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s}", "bridge_id", bridge->uniqueid, "bridge_technology", bridge->technology->name); \
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, extra != NULL); \
|
2013-09-27 14:08:23 +00:00
|
|
|
APPEND_EVENT_PEER(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, peer); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#define BRIDGE_EXIT_SNAPSHOT(channel, bridge) do { \
|
2013-07-20 13:10:22 +00:00
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
|
2013-09-27 14:08:23 +00:00
|
|
|
RAII_VAR(struct ast_str *, peer_str, NULL, ast_free); \
|
|
|
|
peer_str = test_cel_generate_peer_str_snapshot(channel, bridge); \
|
|
|
|
ast_test_validate(test, peer_str != NULL); \
|
2014-06-27 02:04:50 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s}", "bridge_id", bridge->uniqueid, "bridge_technology", bridge->technology->name); \
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, extra != NULL); \
|
2013-09-27 14:08:23 +00:00
|
|
|
APPEND_EVENT_SNAPSHOT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, ast_str_buffer(peer_str)); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#define BRIDGE_ENTER(channel, bridge) do { \
|
2013-09-13 22:19:23 +00:00
|
|
|
ast_test_validate(test, !ast_bridge_impart(bridge, channel, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE)); \
|
2013-08-22 17:13:16 +00:00
|
|
|
do_sleep(); \
|
|
|
|
BRIDGE_ENTER_EVENT(channel, bridge); \
|
|
|
|
mid_test_sync(); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#define BRIDGE_ENTER_EVENT(channel, bridge) do { \
|
2013-09-27 14:08:23 +00:00
|
|
|
RAII_VAR(struct ast_str *, peer_str, NULL, ast_free); \
|
|
|
|
peer_str = test_cel_generate_peer_str(channel, bridge); \
|
|
|
|
ast_test_validate(test, peer_str != NULL); \
|
|
|
|
BRIDGE_ENTER_EVENT_PEER(channel, bridge, ast_str_buffer(peer_str)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BRIDGE_ENTER_EVENT_PEER(channel, bridge, peer) do { \
|
2013-07-20 13:10:22 +00:00
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
|
2014-06-27 02:04:50 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s}", "bridge_id", bridge->uniqueid, "bridge_technology", bridge->technology->name); \
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, extra != NULL); \
|
2013-09-27 14:08:23 +00:00
|
|
|
APPEND_EVENT_PEER(channel, AST_CEL_BRIDGE_ENTER, NULL, extra, peer); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BLINDTRANSFER_EVENT(channel, bridge, extension, context) do { \
|
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
|
2014-08-14 19:21:51 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s, s: s, s: s, s: s}", \
|
2013-07-20 13:10:22 +00:00
|
|
|
"extension", extension, \
|
|
|
|
"context", context, \
|
2014-08-14 19:21:51 +00:00
|
|
|
"bridge_id", bridge->uniqueid, \
|
|
|
|
"transferee_channel_name", "N/A", \
|
|
|
|
"transferee_channel_uniqueid", "N/A"); \
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, extra != NULL); \
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel, AST_CEL_BLINDTRANSFER, NULL, extra); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-08-08 03:07:41 +00:00
|
|
|
#define ATTENDEDTRANSFER_BRIDGE(channel1, bridge1, channel2, bridge2, channel3, channel4) do { \
|
2013-07-20 13:10:22 +00:00
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
|
2014-08-14 19:21:51 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: s, s: s}", \
|
2013-07-20 13:10:22 +00:00
|
|
|
"bridge1_id", bridge1->uniqueid, \
|
|
|
|
"channel2_name", ast_channel_name(channel2), \
|
2014-08-14 19:21:51 +00:00
|
|
|
"channel2_uniqueid", ast_channel_uniqueid(channel2), \
|
2014-08-08 03:07:41 +00:00
|
|
|
"bridge2_id", bridge2->uniqueid, \
|
|
|
|
"transferee_channel_name", ast_channel_name(channel4), \
|
2014-08-14 19:21:51 +00:00
|
|
|
"transferee_channel_uniqueid", ast_channel_uniqueid(channel4), \
|
|
|
|
"transfer_target_channel_name", ast_channel_name(channel3), \
|
|
|
|
"transfer_target_channel_uniqueid", ast_channel_uniqueid(channel3)); \
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, extra != NULL); \
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/*! \brief Alice's Caller ID */
|
|
|
|
#define ALICE_CALLERID { .id.name.str = "Alice", .id.name.valid = 1, .id.number.str = "100", .id.number.valid = 1, }
|
|
|
|
|
|
|
|
/*! \brief Bob's Caller ID */
|
|
|
|
#define BOB_CALLERID { .id.name.str = "Bob", .id.name.valid = 1, .id.number.str = "200", .id.number.valid = 1, }
|
|
|
|
|
|
|
|
/*! \brief Charlie's Caller ID */
|
|
|
|
#define CHARLIE_CALLERID { .id.name.str = "Charlie", .id.name.valid = 1, .id.number.str = "300", .id.number.valid = 1, }
|
|
|
|
|
|
|
|
/*! \brief David's Caller ID */
|
|
|
|
#define DAVID_CALLERID { .id.name.str = "David", .id.name.valid = 1, .id.number.str = "400", .id.number.valid = 1, }
|
|
|
|
|
2014-09-23 14:36:00 +00:00
|
|
|
/*! \brief Set ulaw format on channel */
|
|
|
|
#define SET_FORMATS(chan) do {\
|
|
|
|
struct ast_format_cap *caps;\
|
|
|
|
caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);\
|
|
|
|
ast_format_cap_append(caps, ast_format_ulaw, 0);\
|
|
|
|
ast_channel_nativeformats_set((chan), caps);\
|
|
|
|
ast_channel_set_writeformat((chan), ast_format_ulaw);\
|
|
|
|
ast_channel_set_rawwriteformat((chan), ast_format_ulaw);\
|
|
|
|
ast_channel_set_readformat((chan), ast_format_ulaw);\
|
|
|
|
ast_channel_set_rawreadformat((chan), ast_format_ulaw);\
|
|
|
|
ao2_ref(caps, -1);\
|
|
|
|
} while (0)
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/*! \brief Create a \ref test_cel_chan_tech for Alice. */
|
|
|
|
#define CREATE_ALICE_CHANNEL(channel_var, caller_id) do { \
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "100", "100", "default", NULL, NULL, 0, CHANNEL_TECH_NAME "/Alice"); \
|
2014-09-23 14:36:00 +00:00
|
|
|
SET_FORMATS((channel_var));\
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
|
2013-12-18 19:28:05 +00:00
|
|
|
ast_channel_unlock((channel_var)); \
|
2013-07-02 14:01:53 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*! \brief Create a \ref test_cel_chan_tech for Bob. */
|
|
|
|
#define CREATE_BOB_CHANNEL(channel_var, caller_id) do { \
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "200", "200", "default", NULL, NULL, 0, CHANNEL_TECH_NAME "/Bob"); \
|
2014-09-23 14:36:00 +00:00
|
|
|
SET_FORMATS((channel_var));\
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
|
2013-12-18 19:28:05 +00:00
|
|
|
ast_channel_unlock((channel_var)); \
|
2013-07-02 14:01:53 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*! \brief Create a \ref test_cel_chan_tech for Charlie. */
|
|
|
|
#define CREATE_CHARLIE_CHANNEL(channel_var, caller_id) do { \
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "300", "300", "default", NULL, NULL, 0, CHANNEL_TECH_NAME "/Charlie"); \
|
2014-09-23 14:36:00 +00:00
|
|
|
SET_FORMATS((channel_var));\
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
|
2013-12-18 19:28:05 +00:00
|
|
|
ast_channel_unlock((channel_var)); \
|
2013-07-02 14:01:53 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
/*! \brief Create a \ref test_cel_chan_tech for David. */
|
2013-07-02 14:01:53 +00:00
|
|
|
#define CREATE_DAVID_CHANNEL(channel_var, caller_id) do { \
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "400", "400", "default", NULL, NULL, 0, CHANNEL_TECH_NAME "/David"); \
|
2014-09-23 14:36:00 +00:00
|
|
|
SET_FORMATS((channel_var));\
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
|
2013-12-18 19:28:05 +00:00
|
|
|
ast_channel_unlock((channel_var)); \
|
2013-07-20 13:10:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/*! \brief Emulate a channel entering into an application */
|
|
|
|
#define EMULATE_APP_DATA(channel, priority, application, data) do { \
|
|
|
|
if ((priority) > 0) { \
|
|
|
|
ast_channel_priority_set((channel), (priority)); \
|
|
|
|
} \
|
|
|
|
ast_channel_appl_set((channel), (application)); \
|
|
|
|
ast_channel_data_set((channel), (data)); \
|
|
|
|
ast_channel_publish_snapshot((channel)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ANSWER_CHANNEL(chan) do { \
|
|
|
|
EMULATE_APP_DATA(chan, 1, "Answer", ""); \
|
|
|
|
ANSWER_NO_APP(chan); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ANSWER_NO_APP(chan) do { \
|
|
|
|
ast_setstate(chan, AST_STATE_UP); \
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(chan, AST_CEL_ANSWER, NULL, NULL); \
|
2013-07-02 14:01:53 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*! \brief Hang up a test channel safely */
|
2013-07-20 13:10:22 +00:00
|
|
|
#define HANGUP_CHANNEL(channel, cause, dialstatus) do { \
|
|
|
|
ast_channel_hangupcause_set((channel), (cause)); \
|
|
|
|
ao2_ref(channel, +1); \
|
|
|
|
ast_hangup((channel)); \
|
|
|
|
HANGUP_EVENT(channel, cause, dialstatus); \
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel, AST_CEL_CHANNEL_END, NULL, NULL); \
|
2018-10-10 14:28:18 +00:00
|
|
|
ao2_cleanup(ast_channel_snapshot_get_latest(ast_channel_uniqueid(channel))); \
|
2013-07-20 13:10:22 +00:00
|
|
|
ao2_cleanup(channel); \
|
|
|
|
channel = NULL; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define HANGUP_EVENT(channel, cause, dialstatus) do { \
|
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
|
|
|
|
extra = ast_json_pack("{s: i, s: s, s: s}", \
|
|
|
|
"hangupcause", cause, \
|
|
|
|
"hangupsource", "", \
|
|
|
|
"dialstatus", dialstatus); \
|
|
|
|
ast_test_validate(test, extra != NULL); \
|
2013-08-22 17:13:16 +00:00
|
|
|
APPEND_EVENT(channel, AST_CEL_HANGUP, NULL, extra); \
|
2013-07-02 14:01:53 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-07-31 03:49:44 +00:00
|
|
|
static void mid_test_sync(void);
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
static int append_expected_event(
|
|
|
|
struct ast_channel *chan,
|
|
|
|
enum ast_cel_event_type type,
|
|
|
|
const char *userdefevname,
|
2013-09-27 14:08:23 +00:00
|
|
|
struct ast_json *extra,
|
|
|
|
const char *peer);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
static int append_expected_event_snapshot(
|
|
|
|
struct ast_channel_snapshot *snapshot,
|
|
|
|
enum ast_cel_event_type type,
|
|
|
|
const char *userdefevname,
|
2013-09-27 14:08:23 +00:00
|
|
|
struct ast_json *extra,
|
|
|
|
const char *peer);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2014-12-03 20:59:01 +00:00
|
|
|
#ifdef RACEY_TESTS
|
2013-07-20 13:10:22 +00:00
|
|
|
static int append_dummy_event(void);
|
2014-12-03 20:59:01 +00:00
|
|
|
#endif
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
static struct ast_str *__test_cel_generate_peer_str(struct ast_channel_snapshot *chan, struct ast_bridge_snapshot *bridge)
|
|
|
|
{
|
|
|
|
struct ast_str *peer_str = ast_str_create(32);
|
|
|
|
struct ao2_iterator i;
|
|
|
|
char *current_chan = NULL;
|
|
|
|
|
|
|
|
if (!peer_str) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = ao2_iterator_init(bridge->channels, 0);
|
|
|
|
(current_chan = ao2_iterator_next(&i));
|
|
|
|
ao2_cleanup(current_chan)) {
|
|
|
|
RAII_VAR(struct ast_channel_snapshot *, current_snapshot,
|
|
|
|
NULL,
|
|
|
|
ao2_cleanup);
|
|
|
|
|
|
|
|
/* Don't add the channel for which this message is being generated */
|
2018-11-07 17:18:34 +00:00
|
|
|
if (!strcmp(current_chan, chan->base->uniqueid)) {
|
2013-09-27 14:08:23 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_snapshot = ast_channel_snapshot_get_latest(current_chan);
|
|
|
|
if (!current_snapshot) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_str_append(&peer_str, 0, "%s,", current_snapshot->base->name);
|
2013-09-27 14:08:23 +00:00
|
|
|
}
|
|
|
|
ao2_iterator_destroy(&i);
|
|
|
|
|
|
|
|
/* Rip off the trailing comma */
|
|
|
|
ast_str_truncate(peer_str, -1);
|
|
|
|
|
|
|
|
return peer_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_str *test_cel_generate_peer_str_snapshot(struct ast_channel_snapshot *chan, struct ast_bridge *bridge)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_bridge_snapshot *, snapshot,
|
2018-09-19 19:34:41 +00:00
|
|
|
ast_bridge_get_snapshot(bridge),
|
2013-09-27 14:08:23 +00:00
|
|
|
ao2_cleanup);
|
|
|
|
|
|
|
|
if (!snapshot) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return __test_cel_generate_peer_str(chan, snapshot);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_str *test_cel_generate_peer_str(struct ast_channel *chan, struct ast_bridge *bridge)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel_snapshot *, snapshot,
|
|
|
|
ast_channel_snapshot_get_latest(ast_channel_uniqueid(chan)),
|
|
|
|
ao2_cleanup);
|
|
|
|
|
|
|
|
if (!snapshot) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return test_cel_generate_peer_str_snapshot(snapshot, bridge);
|
|
|
|
}
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
static void safe_channel_release(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
if (!chan) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ast_channel_release(chan);
|
|
|
|
}
|
|
|
|
|
2014-01-28 00:20:46 +00:00
|
|
|
static void safe_bridge_destroy(struct ast_bridge *bridge)
|
|
|
|
{
|
|
|
|
if (!bridge) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ast_bridge_destroy(bridge, 0);
|
|
|
|
}
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_channel_creation)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test the CEL records created when a channel is created";
|
|
|
|
info->description =
|
|
|
|
"Test the CEL records created when a channel is created";
|
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan, (&caller));
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_unanswered_inbound_call)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test inbound unanswered calls";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
|
|
|
"inbound to Asterisk, executes some dialplan, but\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"is never answered.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan, &caller);
|
|
|
|
|
|
|
|
EMULATE_APP_DATA(chan, 1, "Wait", "1");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_unanswered_outbound_call)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = {
|
|
|
|
.id.name.str = "",
|
|
|
|
.id.name.valid = 1,
|
|
|
|
.id.number.str = "",
|
|
|
|
.id.number.valid = 1, };
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test outbound unanswered calls";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"outbound to Asterisk but is never answered.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan, &caller);
|
|
|
|
|
|
|
|
ast_channel_exten_set(chan, "s");
|
|
|
|
ast_channel_context_set(chan, "default");
|
|
|
|
ast_set_flag(ast_channel_flags(chan), AST_FLAG_ORIGINATED);
|
|
|
|
EMULATE_APP_DATA(chan, 0, "AppDial", "(Outgoing Line)");
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_single_party)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a single party";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"answered, but only involves a single channel";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
CREATE_ALICE_CHANNEL(chan, &caller);
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan);
|
|
|
|
EMULATE_APP_DATA(chan, 2, "VoiceMailMain", "1");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_single_bridge)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a single party entering/leaving a bridge";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"answered, enters a bridge, and leaves it.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan, &caller);
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan);
|
|
|
|
EMULATE_APP_DATA(chan, 2, "Bridge", "");
|
|
|
|
|
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
do_sleep();
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_single_bridge_continue)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a single party entering/leaving a bridge";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"answered, enters a bridge, and leaves it.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan, &caller);
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan);
|
|
|
|
EMULATE_APP_DATA(chan, 2, "Bridge", "");
|
|
|
|
|
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
do_sleep();
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
EMULATE_APP_DATA(chan, 3, "Wait", "");
|
|
|
|
|
|
|
|
/* And then it hangs up */
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_single_twoparty_bridge_a)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller caller_alice = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller caller_bob = BOB_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a single party entering/leaving a bridge";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
|
|
|
"answered, enters a bridge, and leaves it. In this scenario, the\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"Party A should answer the bridge first.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &caller_alice);
|
|
|
|
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &caller_bob);
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_alice);
|
|
|
|
EMULATE_APP_DATA(chan_alice, 2, "Bridge", "");
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_alice, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
do_sleep();
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_bob);
|
|
|
|
EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_alice, bridge);
|
|
|
|
BRIDGE_EXIT(chan_bob, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_single_twoparty_bridge_b)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller caller_alice = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller caller_bob = BOB_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a single party entering/leaving a bridge";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
|
|
|
"answered, enters a bridge, and leaves it. In this scenario, the\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"Party B should answer the bridge first.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &caller_alice);
|
|
|
|
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &caller_bob);
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_alice);
|
|
|
|
EMULATE_APP_DATA(chan_alice, 2, "Bridge", "");
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_bob);
|
|
|
|
EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
|
|
|
|
do_sleep();
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_alice, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_alice, bridge);
|
|
|
|
BRIDGE_EXIT(chan_bob, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2013-07-31 15:27:29 +00:00
|
|
|
/* XXX Validation needs to be reworked on a per-channel basis before
|
|
|
|
* test_cel_single_multiparty_bridge and test_cel_dial_answer_multiparty
|
|
|
|
* can operate properly. */
|
2013-08-22 17:13:16 +00:00
|
|
|
#ifdef RACEY_TESTS
|
2013-07-02 14:01:53 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_single_multiparty_bridge)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller caller_alice = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller caller_bob = BOB_CALLERID;
|
|
|
|
struct ast_party_caller caller_charlie = CHARLIE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a single party entering/leaving a multi-party bridge";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
|
|
|
"answered, enters a bridge, and leaves it. A total of three\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"parties perform this action.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &caller_alice);
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &caller_bob);
|
|
|
|
CREATE_CHARLIE_CHANNEL(chan_charlie, &caller_charlie);
|
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_alice);
|
|
|
|
EMULATE_APP_DATA(chan_alice, 2, "Bridge", "");
|
|
|
|
|
|
|
|
do_sleep();
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_alice, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_bob);
|
|
|
|
EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
|
|
|
|
do_sleep();
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
ANSWER_CHANNEL(chan_charlie);
|
|
|
|
EMULATE_APP_DATA(chan_charlie, 2, "Bridge", "");
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_charlie, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_alice, bridge);
|
|
|
|
BRIDGE_EXIT(chan_bob, bridge);
|
|
|
|
BRIDGE_EXIT(chan_charlie, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
2013-07-31 15:27:29 +00:00
|
|
|
#endif
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
#define EMULATE_DIAL(channel, dialstring) do { \
|
|
|
|
EMULATE_APP_DATA(channel, 1, "Dial", dialstring); \
|
2013-09-27 14:08:23 +00:00
|
|
|
if (append_expected_event(channel, AST_CEL_APP_START, NULL, NULL, NULL)) { \
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define START_DIALED(caller, callee) \
|
|
|
|
START_DIALED_FULL(caller, callee, "200", "Bob")
|
|
|
|
|
|
|
|
#define START_DIALED_FULL(caller, callee, number, name) do { \
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
callee = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, number, NULL, NULL, NULL, caller, 0, CHANNEL_TECH_NAME "/" name); \
|
2014-09-23 14:36:00 +00:00
|
|
|
SET_FORMATS(callee);\
|
2013-12-18 19:28:05 +00:00
|
|
|
ast_channel_unlock(callee); \
|
2013-09-27 14:08:23 +00:00
|
|
|
if (append_expected_event(callee, AST_CEL_CHANNEL_START, NULL, NULL, NULL)) { \
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
ast_set_flag(ast_channel_flags(callee), AST_FLAG_OUTGOING); \
|
|
|
|
EMULATE_APP_DATA(callee, 0, "AppDial", "(Outgoing Line)"); \
|
|
|
|
ast_channel_publish_dial(caller, callee, name, NULL); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_unanswered)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a dial that isn't answered";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a channel that\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"performs a dial operation that isn't answered";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "NOANSWER");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ANSWER, "NOANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ANSWER, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2014-07-07 01:22:44 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_dial_unanswered_filter)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a dial that isn't answered";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a channel that\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"performs a dial operation that isn't answered";
|
2014-07-07 01:22:44 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "NOT A VALID DIAL STATUS");
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "NOANSWER");
|
|
|
|
|
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ANSWER, "NOANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ANSWER, "");
|
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_busy)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a dial that results in a busy";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a channel that\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"performs a dial operation to an endpoint that's busy";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "BUSY");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_BUSY, "BUSY");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_BUSY, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_congestion)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a dial that results in congestion";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a channel that\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"performs a dial operation to an endpoint that's congested";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "CONGESTION");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_CONGESTION, "CONGESTION");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_CONGESTION, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_unavailable)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a dial that results in unavailable";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a channel that\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"performs a dial operation to an endpoint that's unavailable";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "CHANUNAVAIL");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NO_ROUTE_DESTINATION, "CHANUNAVAIL");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NO_ROUTE_DESTINATION, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_caller_cancel)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test CEL for a dial where the caller cancels";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a channel that\n"
|
|
|
|
"performs a dial operation to an endpoint but then decides\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"to hang up, cancelling the dial";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "CANCEL");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "CANCEL");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_parallel_failed)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test a parallel dial where all channels fail to answer";
|
|
|
|
info->description =
|
|
|
|
"This tests dialing three parties: Bob, Charlie, David. Charlie\n"
|
|
|
|
"returns BUSY; David returns CONGESTION; Bob fails to answer and\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"Alice hangs up. Three records are created for Alice as a result.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
/* Channel enters Dial app */
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob&" CHANNEL_TECH_NAME "/Charlie&" CHANNEL_TECH_NAME "/David");
|
|
|
|
|
|
|
|
/* Outbound channels are created */
|
|
|
|
START_DIALED_FULL(chan_caller, chan_bob, "200", "Bob");
|
|
|
|
START_DIALED_FULL(chan_caller, chan_charlie, "300", "Charlie");
|
|
|
|
START_DIALED_FULL(chan_caller, chan_david, "400", "David");
|
|
|
|
|
|
|
|
/* Dial starts */
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
|
|
|
|
/* Charlie is busy */
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_charlie, NULL, "BUSY");
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_BUSY, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
/* David is congested */
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_david, NULL, "CONGESTION");
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_david, AST_CAUSE_CONGESTION, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
/* Bob is canceled */
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_bob, NULL, "CANCEL");
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
/* Alice hangs up */
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "BUSY");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_answer_no_bridge)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test dialing, answering, and not going into a bridge.";
|
|
|
|
info->description =
|
|
|
|
"This is a weird one, but theoretically possible. You can perform\n"
|
|
|
|
"a dial, then bounce both channels to different priorities and\n"
|
|
|
|
"never have them enter a bridge together. Ew. This makes sure that\n"
|
|
|
|
"when we answer, we get a CEL, it gets ended at that point, and\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"that it gets finalized appropriately.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "ANSWER");
|
|
|
|
|
|
|
|
ANSWER_NO_APP(chan_caller);
|
|
|
|
ast_clear_flag(ast_channel_flags(chan_callee), AST_FLAG_OUTGOING);
|
|
|
|
ANSWER_NO_APP(chan_callee);
|
|
|
|
|
|
|
|
EMULATE_APP_DATA(chan_caller, 2, "Wait", "1");
|
|
|
|
EMULATE_APP_DATA(chan_callee, 1, "Wait", "1");
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_answer_twoparty_bridge_a)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test dialing, answering, and going into a 2-party bridge";
|
|
|
|
info->description =
|
2015-06-24 19:39:01 +00:00
|
|
|
"The most 'basic' of scenarios";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "ANSWER");
|
|
|
|
|
|
|
|
ANSWER_NO_APP(chan_caller);
|
|
|
|
ANSWER_NO_APP(chan_callee);
|
|
|
|
|
|
|
|
do_sleep();
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_caller, bridge);
|
|
|
|
BRIDGE_ENTER(chan_callee, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_caller, bridge);
|
|
|
|
BRIDGE_EXIT(chan_callee, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_answer_twoparty_bridge_b)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test dialing, answering, and going into a 2-party bridge";
|
|
|
|
info->description =
|
2015-06-24 19:39:01 +00:00
|
|
|
"The most 'basic' of scenarios";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "ANSWER");
|
|
|
|
|
|
|
|
ANSWER_NO_APP(chan_caller);
|
|
|
|
ANSWER_NO_APP(chan_callee);
|
|
|
|
|
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_callee, bridge);
|
|
|
|
BRIDGE_ENTER(chan_caller, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_caller, bridge);
|
|
|
|
BRIDGE_EXIT(chan_callee, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
#ifdef RACEY_TESTS
|
2013-07-02 14:01:53 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_dial_answer_multiparty)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
2013-07-02 14:01:53 +00:00
|
|
|
struct ast_party_caller alice_caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test dialing, answering, and going into a multi-party bridge";
|
|
|
|
info->description =
|
2015-06-24 19:39:01 +00:00
|
|
|
"A little tricky to get to do, but possible with some redirects.";
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
|
|
|
|
|
|
|
|
EMULATE_DIAL(chan_alice, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_alice, chan_bob);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
EMULATE_DIAL(chan_charlie, CHANNEL_TECH_NAME "/Bob");
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
START_DIALED_FULL(chan_charlie, chan_david, "400", "David");
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_alice, AST_STATE_RINGING);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_channel_state_set(chan_charlie, AST_STATE_RINGING);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_channel_publish_dial(chan_alice, chan_bob, NULL, "ANSWER");
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_channel_publish_dial(chan_charlie, chan_david, NULL, "ANSWER");
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
ANSWER_NO_APP(chan_alice);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
ANSWER_NO_APP(chan_bob);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
ANSWER_NO_APP(chan_charlie);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
ANSWER_NO_APP(chan_david);
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_charlie, bridge);
|
|
|
|
BRIDGE_ENTER(chan_david, bridge);
|
|
|
|
BRIDGE_ENTER(chan_bob, bridge);
|
|
|
|
BRIDGE_ENTER(chan_alice, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_alice, bridge);
|
|
|
|
BRIDGE_EXIT(chan_bob, bridge);
|
|
|
|
BRIDGE_EXIT(chan_charlie, bridge);
|
|
|
|
BRIDGE_EXIT(chan_david, bridge);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "ANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "ANSWER");
|
|
|
|
HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
|
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
2013-07-31 15:27:29 +00:00
|
|
|
#endif
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_blind_transfer)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
|
Fix race condition that could result in ARI transfer messages not being sent.
From reviewboard:
"During blind transfer testing, it was noticed that tests were failing
occasionally because the ARI blind transfer event was not being sent.
After investigating, I detected a race condition in the blind transfer
code. When blind transferring a single channel, the actual transfer
operation (i.e. removing the transferee from the bridge and directing
them to the proper dialplan location) is queued onto the transferee
bridge channel. After queuing the transfer operation, the blind transfer
Stasis message is published. At the time of publication, snapshots of
the channels and bridge involved are created. The ARI subscriber to the
blind transfer Stasis message then attempts to determine if the bridge
or any of the involved channels are subscribed to by ARI applications.
If so, then the blind transfer message is sent to the applications. The
way that the ARI blind transfer message handler works is to first see
if the transferer channel is subscribed to. If not, then iterate over
all the channel IDs in the bridge snapshot and determine if any of
those are subscribed to. In the test we were running, the lone
transferee channel was subscribed to, so an ARI event should have been
sent to our application. Occasionally, though, the bridge snapshot did
not have any channels IDs on it at all. Why?
The problem is that since the blind transfer operation is handled by a
separate thread, it is possible that the transfer will have completed and
the channels removed from the bridge before we publish the blind transfer
Stasis message. Since the blind transfer has completed, the bridge on
which the transfer occurred no longer has any channels on it, so the
resulting bridge snapshot has no channels on it. Through investigation of
the code, I found that attended transfers can have this issue too for the
case where a transferee is transferred to an application."
The fix employed here is to decouple the creation of snapshots for the transfer
messages from the publication of the transfer messages. This way, snapshots
can be created to reflect what they are at the time of the transfer operation.
Review: https://reviewboard.asterisk.org/r/4135
........
Merged revisions 427848 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 427870 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-14 15:28:42 +00:00
|
|
|
RAII_VAR(struct ast_blind_transfer_message *, transfer_msg, NULL, ao2_cleanup);
|
2013-07-20 13:10:22 +00:00
|
|
|
struct ast_party_caller alice_caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller bob_caller = BOB_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test blind transfers to an extension";
|
|
|
|
info->description =
|
|
|
|
"This test creates two channels, bridges them, and then"
|
2015-06-24 19:39:01 +00:00
|
|
|
" blind transfers the bridge to an extension.";
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &bob_caller);
|
|
|
|
|
|
|
|
ANSWER_NO_APP(chan_alice);
|
|
|
|
ANSWER_NO_APP(chan_bob);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge);
|
|
|
|
BRIDGE_ENTER(chan_alice, bridge);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2014-04-11 12:43:34 +00:00
|
|
|
ast_bridge_lock(bridge);
|
Fix race condition that could result in ARI transfer messages not being sent.
From reviewboard:
"During blind transfer testing, it was noticed that tests were failing
occasionally because the ARI blind transfer event was not being sent.
After investigating, I detected a race condition in the blind transfer
code. When blind transferring a single channel, the actual transfer
operation (i.e. removing the transferee from the bridge and directing
them to the proper dialplan location) is queued onto the transferee
bridge channel. After queuing the transfer operation, the blind transfer
Stasis message is published. At the time of publication, snapshots of
the channels and bridge involved are created. The ARI subscriber to the
blind transfer Stasis message then attempts to determine if the bridge
or any of the involved channels are subscribed to by ARI applications.
If so, then the blind transfer message is sent to the applications. The
way that the ARI blind transfer message handler works is to first see
if the transferer channel is subscribed to. If not, then iterate over
all the channel IDs in the bridge snapshot and determine if any of
those are subscribed to. In the test we were running, the lone
transferee channel was subscribed to, so an ARI event should have been
sent to our application. Occasionally, though, the bridge snapshot did
not have any channels IDs on it at all. Why?
The problem is that since the blind transfer operation is handled by a
separate thread, it is possible that the transfer will have completed and
the channels removed from the bridge before we publish the blind transfer
Stasis message. Since the blind transfer has completed, the bridge on
which the transfer occurred no longer has any channels on it, so the
resulting bridge snapshot has no channels on it. Through investigation of
the code, I found that attended transfers can have this issue too for the
case where a transferee is transferred to an application."
The fix employed here is to decouple the creation of snapshots for the transfer
messages from the publication of the transfer messages. This way, snapshots
can be created to reflect what they are at the time of the transfer operation.
Review: https://reviewboard.asterisk.org/r/4135
........
Merged revisions 427848 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 427870 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-14 15:28:42 +00:00
|
|
|
transfer_msg = ast_blind_transfer_message_create(1, chan_alice,
|
|
|
|
"transfer_extension", "transfer_context");
|
|
|
|
if (!transfer_msg) {
|
2014-11-14 21:51:22 +00:00
|
|
|
ast_bridge_unlock(bridge);
|
Fix race condition that could result in ARI transfer messages not being sent.
From reviewboard:
"During blind transfer testing, it was noticed that tests were failing
occasionally because the ARI blind transfer event was not being sent.
After investigating, I detected a race condition in the blind transfer
code. When blind transferring a single channel, the actual transfer
operation (i.e. removing the transferee from the bridge and directing
them to the proper dialplan location) is queued onto the transferee
bridge channel. After queuing the transfer operation, the blind transfer
Stasis message is published. At the time of publication, snapshots of
the channels and bridge involved are created. The ARI subscriber to the
blind transfer Stasis message then attempts to determine if the bridge
or any of the involved channels are subscribed to by ARI applications.
If so, then the blind transfer message is sent to the applications. The
way that the ARI blind transfer message handler works is to first see
if the transferer channel is subscribed to. If not, then iterate over
all the channel IDs in the bridge snapshot and determine if any of
those are subscribed to. In the test we were running, the lone
transferee channel was subscribed to, so an ARI event should have been
sent to our application. Occasionally, though, the bridge snapshot did
not have any channels IDs on it at all. Why?
The problem is that since the blind transfer operation is handled by a
separate thread, it is possible that the transfer will have completed and
the channels removed from the bridge before we publish the blind transfer
Stasis message. Since the blind transfer has completed, the bridge on
which the transfer occurred no longer has any channels on it, so the
resulting bridge snapshot has no channels on it. Through investigation of
the code, I found that attended transfers can have this issue too for the
case where a transferee is transferred to an application."
The fix employed here is to decouple the creation of snapshots for the transfer
messages from the publication of the transfer messages. This way, snapshots
can be created to reflect what they are at the time of the transfer operation.
Review: https://reviewboard.asterisk.org/r/4135
........
Merged revisions 427848 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 427870 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-14 15:28:42 +00:00
|
|
|
ast_test_status_update(test, "Failed to create transfer Stasis message\n");
|
|
|
|
return AST_TEST_FAIL;
|
|
|
|
}
|
|
|
|
transfer_msg->bridge = ast_bridge_snapshot_create(bridge);
|
|
|
|
if (!transfer_msg->bridge) {
|
2014-11-14 21:51:22 +00:00
|
|
|
ast_bridge_unlock(bridge);
|
Fix race condition that could result in ARI transfer messages not being sent.
From reviewboard:
"During blind transfer testing, it was noticed that tests were failing
occasionally because the ARI blind transfer event was not being sent.
After investigating, I detected a race condition in the blind transfer
code. When blind transferring a single channel, the actual transfer
operation (i.e. removing the transferee from the bridge and directing
them to the proper dialplan location) is queued onto the transferee
bridge channel. After queuing the transfer operation, the blind transfer
Stasis message is published. At the time of publication, snapshots of
the channels and bridge involved are created. The ARI subscriber to the
blind transfer Stasis message then attempts to determine if the bridge
or any of the involved channels are subscribed to by ARI applications.
If so, then the blind transfer message is sent to the applications. The
way that the ARI blind transfer message handler works is to first see
if the transferer channel is subscribed to. If not, then iterate over
all the channel IDs in the bridge snapshot and determine if any of
those are subscribed to. In the test we were running, the lone
transferee channel was subscribed to, so an ARI event should have been
sent to our application. Occasionally, though, the bridge snapshot did
not have any channels IDs on it at all. Why?
The problem is that since the blind transfer operation is handled by a
separate thread, it is possible that the transfer will have completed and
the channels removed from the bridge before we publish the blind transfer
Stasis message. Since the blind transfer has completed, the bridge on
which the transfer occurred no longer has any channels on it, so the
resulting bridge snapshot has no channels on it. Through investigation of
the code, I found that attended transfers can have this issue too for the
case where a transferee is transferred to an application."
The fix employed here is to decouple the creation of snapshots for the transfer
messages from the publication of the transfer messages. This way, snapshots
can be created to reflect what they are at the time of the transfer operation.
Review: https://reviewboard.asterisk.org/r/4135
........
Merged revisions 427848 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 427870 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-14 15:28:42 +00:00
|
|
|
ast_test_status_update(test, "Failed to create bridge snapshot\n");
|
|
|
|
return AST_TEST_FAIL;
|
|
|
|
}
|
2014-04-11 12:43:34 +00:00
|
|
|
ast_bridge_unlock(bridge);
|
Fix race condition that could result in ARI transfer messages not being sent.
From reviewboard:
"During blind transfer testing, it was noticed that tests were failing
occasionally because the ARI blind transfer event was not being sent.
After investigating, I detected a race condition in the blind transfer
code. When blind transferring a single channel, the actual transfer
operation (i.e. removing the transferee from the bridge and directing
them to the proper dialplan location) is queued onto the transferee
bridge channel. After queuing the transfer operation, the blind transfer
Stasis message is published. At the time of publication, snapshots of
the channels and bridge involved are created. The ARI subscriber to the
blind transfer Stasis message then attempts to determine if the bridge
or any of the involved channels are subscribed to by ARI applications.
If so, then the blind transfer message is sent to the applications. The
way that the ARI blind transfer message handler works is to first see
if the transferer channel is subscribed to. If not, then iterate over
all the channel IDs in the bridge snapshot and determine if any of
those are subscribed to. In the test we were running, the lone
transferee channel was subscribed to, so an ARI event should have been
sent to our application. Occasionally, though, the bridge snapshot did
not have any channels IDs on it at all. Why?
The problem is that since the blind transfer operation is handled by a
separate thread, it is possible that the transfer will have completed and
the channels removed from the bridge before we publish the blind transfer
Stasis message. Since the blind transfer has completed, the bridge on
which the transfer occurred no longer has any channels on it, so the
resulting bridge snapshot has no channels on it. Through investigation of
the code, I found that attended transfers can have this issue too for the
case where a transferee is transferred to an application."
The fix employed here is to decouple the creation of snapshots for the transfer
messages from the publication of the transfer messages. This way, snapshots
can be created to reflect what they are at the time of the transfer operation.
Review: https://reviewboard.asterisk.org/r/4135
........
Merged revisions 427848 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 427870 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-14 15:28:42 +00:00
|
|
|
transfer_msg->result = AST_BRIDGE_TRANSFER_SUCCESS;
|
|
|
|
ast_bridge_publish_blind_transfer(transfer_msg);
|
2013-07-20 13:10:22 +00:00
|
|
|
BLINDTRANSFER_EVENT(chan_alice, bridge, "transfer_extension", "transfer_context");
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_alice, bridge);
|
|
|
|
BRIDGE_EXIT(chan_bob, bridge);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2014-12-03 19:49:38 +00:00
|
|
|
/* XXX Validation needs to take into account the BRIDGE_EXIT for Alice and the
|
|
|
|
* ATTENDEDTRANSFER message are not guaranteed to be ordered
|
|
|
|
*/
|
|
|
|
#ifdef RACEY_TESTS
|
2013-07-20 13:10:22 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_attended_transfer_bridges_swap)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
2013-07-29 14:51:00 +00:00
|
|
|
RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
|
|
|
|
RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
|
2013-07-20 13:10:22 +00:00
|
|
|
struct ast_party_caller alice_caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller bob_caller = BOB_CALLERID;
|
|
|
|
struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
|
2013-07-29 14:51:00 +00:00
|
|
|
struct ast_party_caller david_caller = ALICE_CALLERID;
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test attended transfers between two pairs of bridged parties";
|
|
|
|
info->description =
|
|
|
|
"This test creates four channels, places each pair in"
|
|
|
|
" a bridge, and then attended transfers the bridges"
|
2015-06-24 19:39:01 +00:00
|
|
|
" together.";
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Create first set of bridged parties */
|
|
|
|
bridge1 = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge1 != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &bob_caller);
|
|
|
|
ANSWER_NO_APP(chan_alice);
|
|
|
|
ANSWER_NO_APP(chan_bob);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge1);
|
|
|
|
BRIDGE_ENTER(chan_alice, bridge1);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
/* Create second set of bridged parties */
|
|
|
|
bridge2 = ast_bridge_basic_new();
|
|
|
|
ast_test_validate(test, bridge2 != NULL);
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
CREATE_DAVID_CHANNEL(chan_david, &david_caller);
|
2013-07-20 13:10:22 +00:00
|
|
|
CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
|
2013-07-29 14:51:00 +00:00
|
|
|
ANSWER_NO_APP(chan_david);
|
2013-07-20 13:10:22 +00:00
|
|
|
ANSWER_NO_APP(chan_charlie);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_charlie, bridge2);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_david, bridge2);
|
|
|
|
BRIDGE_EXIT_EVENT(chan_bob, bridge1);
|
2013-07-20 13:10:22 +00:00
|
|
|
do_sleep();
|
|
|
|
|
|
|
|
/* Perform attended transfer */
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
if (ast_bridge_transfer_attended(chan_alice, chan_david)) {
|
|
|
|
ast_test_status_update(test, "Attended transfer failed!\n");
|
|
|
|
return AST_TEST_FAIL;
|
|
|
|
}
|
2013-07-20 13:10:22 +00:00
|
|
|
do_sleep();
|
2013-09-27 14:08:23 +00:00
|
|
|
BRIDGE_ENTER_EVENT_PEER(chan_bob, bridge2, "CELTestChannel/David,CELTestChannel/Charlie");
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT_EVENT(chan_david, bridge2);
|
|
|
|
BRIDGE_EXIT_EVENT(chan_alice, bridge1);
|
2014-12-03 19:49:38 +00:00
|
|
|
ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_david, bridge2, chan_charlie, chan_bob);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_bob, bridge2);
|
|
|
|
BRIDGE_EXIT(chan_charlie, bridge2);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-29 14:51:00 +00:00
|
|
|
HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
|
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
2014-12-03 19:49:38 +00:00
|
|
|
#endif
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_attended_transfer_bridges_merge)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
|
|
|
|
RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
|
2013-07-20 13:10:22 +00:00
|
|
|
struct ast_party_caller alice_caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller bob_caller = BOB_CALLERID;
|
|
|
|
struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
|
2013-07-29 14:51:00 +00:00
|
|
|
struct ast_party_caller david_caller = ALICE_CALLERID;
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test attended transfers between two pairs of"
|
|
|
|
" bridged parties that results in a bridge merge";
|
|
|
|
info->description =
|
2013-07-29 14:51:00 +00:00
|
|
|
"This test creates four channels, places each pair"
|
2013-07-20 13:10:22 +00:00
|
|
|
" in a bridge, and then attended transfers the bridges"
|
2015-06-24 19:39:01 +00:00
|
|
|
" together causing a bridge merge.";
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Create first set of bridged parties */
|
2013-07-29 14:51:00 +00:00
|
|
|
bridge1 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
|
2013-12-17 23:57:52 +00:00
|
|
|
AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM | AST_BRIDGE_FLAG_TRANSFER_PROHIBITED | AST_BRIDGE_FLAG_SMART,
|
2014-03-07 19:19:04 +00:00
|
|
|
"test_cel", "test_cel_atxfer_bridges_merge_1", NULL);
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, bridge1 != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &bob_caller);
|
|
|
|
ANSWER_NO_APP(chan_alice);
|
|
|
|
ANSWER_NO_APP(chan_bob);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge1);
|
|
|
|
BRIDGE_ENTER(chan_alice, bridge1);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
/* Create second set of bridged parties */
|
2013-07-29 14:51:00 +00:00
|
|
|
bridge2 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
|
2013-12-17 23:57:52 +00:00
|
|
|
AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM | AST_BRIDGE_FLAG_TRANSFER_PROHIBITED | AST_BRIDGE_FLAG_SMART,
|
2014-03-07 19:19:04 +00:00
|
|
|
"test_cel", "test_cel_atxfer_bridges_merge_2", NULL);
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, bridge2 != NULL);
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
CREATE_DAVID_CHANNEL(chan_david, &david_caller);
|
2013-07-20 13:10:22 +00:00
|
|
|
CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
|
2013-07-29 14:51:00 +00:00
|
|
|
ANSWER_NO_APP(chan_david);
|
2013-07-20 13:10:22 +00:00
|
|
|
ANSWER_NO_APP(chan_charlie);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_charlie, bridge2);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_david, bridge2);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
/* Perform attended transfer */
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
if (ast_bridge_transfer_attended(chan_alice, chan_david)) {
|
|
|
|
ast_test_status_update(test, "Attended transfer failed!\n");
|
|
|
|
return AST_TEST_FAIL;
|
|
|
|
}
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-09-27 14:08:23 +00:00
|
|
|
BRIDGE_EXIT_EVENT_PEER(chan_charlie, bridge2, "CELTestChannel/David");
|
|
|
|
BRIDGE_ENTER_EVENT_PEER(chan_charlie, bridge1, "CELTestChannel/Bob,CELTestChannel/Alice");
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT_EVENT(chan_david, bridge2);
|
|
|
|
BRIDGE_EXIT_EVENT(chan_alice, bridge1);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2014-08-08 03:07:41 +00:00
|
|
|
ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_david, bridge2, chan_charlie, chan_bob);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_bob, bridge1);
|
|
|
|
BRIDGE_EXIT(chan_charlie, bridge1);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-29 14:51:00 +00:00
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2014-12-03 20:59:01 +00:00
|
|
|
/* XXX Validation needs to take into account the BRIDGE_EXIT for David and the
|
|
|
|
* ATTENDEDTRANSFER message are not guaranteed to be ordered
|
|
|
|
*/
|
|
|
|
#ifdef RACEY_TESTS
|
2013-07-20 13:10:22 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_attended_transfer_bridges_link)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
|
2014-01-28 00:20:46 +00:00
|
|
|
RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
|
|
|
|
RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
|
2013-07-20 13:10:22 +00:00
|
|
|
struct ast_party_caller alice_caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller bob_caller = BOB_CALLERID;
|
|
|
|
struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
|
2013-07-29 14:51:00 +00:00
|
|
|
struct ast_party_caller david_caller = ALICE_CALLERID;
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test attended transfers between two pairs of"
|
|
|
|
" bridged parties that results in a bridge merge";
|
|
|
|
info->description =
|
2013-07-29 14:51:00 +00:00
|
|
|
"This test creates four channels, places each pair"
|
2013-07-20 13:10:22 +00:00
|
|
|
" in a bridge, and then attended transfers the bridges"
|
2015-06-24 19:39:01 +00:00
|
|
|
" together causing a bridge link.";
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Create first set of bridged parties */
|
|
|
|
bridge1 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
|
|
|
|
AST_BRIDGE_FLAG_MERGE_INHIBIT_TO | AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM
|
2013-07-29 14:51:00 +00:00
|
|
|
| AST_BRIDGE_FLAG_SWAP_INHIBIT_TO | AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM
|
2013-12-17 23:57:52 +00:00
|
|
|
| AST_BRIDGE_FLAG_TRANSFER_PROHIBITED | AST_BRIDGE_FLAG_SMART,
|
2014-03-07 19:19:04 +00:00
|
|
|
"test_cel", "test_cel_atxfer_bridges_link_1", NULL);
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, bridge1 != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &bob_caller);
|
|
|
|
ANSWER_NO_APP(chan_alice);
|
|
|
|
ANSWER_NO_APP(chan_bob);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_bob, bridge1);
|
|
|
|
BRIDGE_ENTER(chan_alice, bridge1);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
/* Create second set of bridged parties */
|
2013-07-29 14:51:00 +00:00
|
|
|
bridge2 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
|
|
|
|
AST_BRIDGE_FLAG_MERGE_INHIBIT_TO | AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM
|
|
|
|
| AST_BRIDGE_FLAG_SWAP_INHIBIT_TO | AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM
|
2013-12-17 23:57:52 +00:00
|
|
|
| AST_BRIDGE_FLAG_TRANSFER_PROHIBITED | AST_BRIDGE_FLAG_SMART,
|
2014-03-07 19:19:04 +00:00
|
|
|
"test_cel", "test_cel_atxfer_bridges_link_2", NULL);
|
2013-07-20 13:10:22 +00:00
|
|
|
ast_test_validate(test, bridge2 != NULL);
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
CREATE_DAVID_CHANNEL(chan_david, &david_caller);
|
2013-07-20 13:10:22 +00:00
|
|
|
CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
|
2013-07-29 14:51:00 +00:00
|
|
|
ANSWER_NO_APP(chan_david);
|
2013-07-20 13:10:22 +00:00
|
|
|
ANSWER_NO_APP(chan_charlie);
|
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_ENTER(chan_charlie, bridge2);
|
|
|
|
BRIDGE_ENTER(chan_david, bridge2);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
/* Perform attended transfer */
|
2014-08-08 03:07:41 +00:00
|
|
|
ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_david, bridge2, chan_charlie, chan_bob);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_bridge_transfer_attended(chan_alice, chan_david);
|
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
|
2013-08-22 17:13:16 +00:00
|
|
|
/* BRIDGE_EXIT alice and david */
|
|
|
|
APPEND_DUMMY_EVENT();
|
2013-07-20 13:10:22 +00:00
|
|
|
APPEND_DUMMY_EVENT();
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
do_sleep();
|
2013-08-22 17:13:16 +00:00
|
|
|
BRIDGE_EXIT(chan_bob, bridge1);
|
|
|
|
BRIDGE_EXIT(chan_charlie, bridge2);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
|
2013-07-27 04:05:03 +00:00
|
|
|
do_sleep();
|
2013-07-29 14:51:00 +00:00
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
|
2014-01-28 00:20:46 +00:00
|
|
|
do_sleep();
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
2014-12-03 20:59:01 +00:00
|
|
|
#endif
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
AST_TEST_DEFINE(test_cel_dial_pickup)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test call pickup";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for a call that is\n"
|
|
|
|
"inbound to Asterisk, executes some dialplan, and\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"is picked up.";
|
2013-07-20 13:10:22 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_caller, &caller);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
EMULATE_DIAL(chan_caller, CHANNEL_TECH_NAME "/Bob");
|
|
|
|
|
|
|
|
START_DIALED(chan_caller, chan_callee);
|
|
|
|
|
|
|
|
ast_channel_state_set(chan_caller, AST_STATE_RINGING);
|
|
|
|
|
|
|
|
CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
|
|
|
|
|
|
|
|
{
|
2013-08-22 17:13:16 +00:00
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
|
2013-07-20 13:10:22 +00:00
|
|
|
SCOPED_CHANNELLOCK(lock, chan_callee);
|
2013-08-22 17:13:16 +00:00
|
|
|
|
2014-08-14 19:21:51 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s}", "pickup_channel", ast_channel_name(chan_charlie),
|
|
|
|
"pickup_channel_uniqueid", ast_channel_uniqueid(chan_charlie));
|
2013-08-22 17:13:16 +00:00
|
|
|
ast_test_validate(test, extra != NULL);
|
|
|
|
|
|
|
|
APPEND_EVENT(chan_callee, AST_CEL_PICKUP, NULL, extra);
|
2013-09-13 22:19:23 +00:00
|
|
|
ast_test_validate(test, !ast_do_pickup(chan_charlie, chan_callee));
|
2013-07-20 13:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Hang up the masqueraded zombie */
|
|
|
|
HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
|
|
|
|
|
|
|
|
ast_channel_publish_dial(chan_caller, chan_callee, NULL, "ANSWER");
|
|
|
|
|
2016-06-07 23:45:37 +00:00
|
|
|
HANGUP_CHANNEL(chan_caller, AST_CAUSE_NORMAL, "ANSWER");
|
2013-07-20 13:10:22 +00:00
|
|
|
HANGUP_CHANNEL(chan_callee, AST_CAUSE_NORMAL, "");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2013-07-20 13:25:05 +00:00
|
|
|
AST_TEST_DEFINE(test_cel_local_optimize)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
|
|
|
RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
|
|
|
|
struct ast_party_caller alice_caller = ALICE_CALLERID;
|
|
|
|
struct ast_party_caller bob_caller = BOB_CALLERID;
|
|
|
|
RAII_VAR(struct ast_multi_channel_blob *, mc_blob, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_channel_snapshot *, alice_snapshot, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_channel_snapshot *, bob_snapshot, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct stasis_message *, local_opt_begin, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct stasis_message *, local_opt_end, NULL, ao2_cleanup);
|
2013-08-22 17:13:16 +00:00
|
|
|
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
|
2013-07-20 13:25:05 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TEST_INIT:
|
|
|
|
info->name = __func__;
|
|
|
|
info->category = TEST_CATEGORY;
|
|
|
|
info->summary = "Test local channel optimization record generation";
|
|
|
|
info->description =
|
|
|
|
"Test CEL records for two local channels being optimized\n"
|
|
|
|
"out by sending a messages indicating local optimization\n"
|
2015-06-24 19:39:01 +00:00
|
|
|
"begin and end";
|
2013-07-20 13:25:05 +00:00
|
|
|
return AST_TEST_NOT_RUN;
|
|
|
|
case TEST_EXECUTE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mc_blob = ast_multi_channel_blob_create(ast_json_null());
|
|
|
|
ast_test_validate(test, mc_blob != NULL);
|
|
|
|
|
|
|
|
CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
|
|
|
|
CREATE_BOB_CHANNEL(chan_bob, &bob_caller);
|
|
|
|
|
2013-12-18 20:33:37 +00:00
|
|
|
ast_channel_lock(chan_alice);
|
2013-07-20 13:25:05 +00:00
|
|
|
alice_snapshot = ast_channel_snapshot_create(chan_alice);
|
2013-12-18 20:33:37 +00:00
|
|
|
ast_channel_unlock(chan_alice);
|
2013-07-20 13:25:05 +00:00
|
|
|
ast_test_validate(test, alice_snapshot != NULL);
|
|
|
|
|
2013-12-18 20:33:37 +00:00
|
|
|
ast_channel_lock(chan_bob);
|
2013-07-20 13:25:05 +00:00
|
|
|
bob_snapshot = ast_channel_snapshot_create(chan_bob);
|
2013-12-18 20:33:37 +00:00
|
|
|
ast_channel_unlock(chan_bob);
|
2013-07-20 13:25:05 +00:00
|
|
|
ast_test_validate(test, bob_snapshot != NULL);
|
|
|
|
|
|
|
|
ast_multi_channel_blob_add_channel(mc_blob, "1", alice_snapshot);
|
|
|
|
ast_multi_channel_blob_add_channel(mc_blob, "2", bob_snapshot);
|
|
|
|
|
|
|
|
local_opt_begin = stasis_message_create(ast_local_optimization_begin_type(), mc_blob);
|
|
|
|
ast_test_validate(test, local_opt_begin != NULL);
|
|
|
|
|
|
|
|
local_opt_end = stasis_message_create(ast_local_optimization_end_type(), mc_blob);
|
|
|
|
ast_test_validate(test, local_opt_end != NULL);
|
|
|
|
|
|
|
|
stasis_publish(ast_channel_topic(chan_alice), local_opt_begin);
|
|
|
|
stasis_publish(ast_channel_topic(chan_alice), local_opt_end);
|
2013-08-22 17:13:16 +00:00
|
|
|
|
2018-11-07 17:18:34 +00:00
|
|
|
extra = ast_json_pack("{s: s, s: s}", "local_two", bob_snapshot->base->name,
|
|
|
|
"local_two_uniqueid", bob_snapshot->base->uniqueid);
|
2013-08-22 17:13:16 +00:00
|
|
|
ast_test_validate(test, extra != NULL);
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
APPEND_EVENT_SNAPSHOT(alice_snapshot, AST_CEL_LOCAL_OPTIMIZE, NULL, extra, NULL);
|
2013-07-20 13:25:05 +00:00
|
|
|
|
|
|
|
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
|
|
|
|
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
|
|
|
|
|
|
|
|
return AST_TEST_PASS;
|
|
|
|
}
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/*! Container for astobj2 duplicated ast_events */
|
|
|
|
static struct ao2_container *cel_received_events = NULL;
|
|
|
|
|
|
|
|
/*! Container for expected CEL events */
|
|
|
|
static struct ao2_container *cel_expected_events = NULL;
|
|
|
|
|
|
|
|
static struct ast_event *ao2_dup_event(const struct ast_event *event)
|
|
|
|
{
|
|
|
|
struct ast_event *event_dup;
|
|
|
|
uint16_t event_len;
|
|
|
|
|
|
|
|
event_len = ast_event_get_size(event);
|
|
|
|
|
|
|
|
event_dup = ao2_alloc(event_len, NULL);
|
|
|
|
if (!event_dup) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(event_dup, event, event_len);
|
|
|
|
|
|
|
|
return event_dup;
|
|
|
|
}
|
|
|
|
|
2013-07-31 03:49:44 +00:00
|
|
|
static void mid_test_sync(void)
|
|
|
|
{
|
|
|
|
ast_mutex_lock(&mid_test_sync_lock);
|
|
|
|
if (ao2_container_count(cel_expected_events) <= ao2_container_count(cel_received_events)) {
|
|
|
|
ast_mutex_unlock(&mid_test_sync_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_mid_test_sync = 1;
|
|
|
|
ast_mutex_unlock(&mid_test_sync_lock);
|
|
|
|
|
|
|
|
{
|
|
|
|
struct timeval start = ast_tvnow();
|
|
|
|
struct timespec end = {
|
|
|
|
.tv_sec = start.tv_sec + 15,
|
|
|
|
.tv_nsec = start.tv_usec * 1000
|
|
|
|
};
|
|
|
|
|
|
|
|
SCOPED_MUTEX(lock, &sync_lock);
|
|
|
|
ast_cond_timedwait(&sync_out, &sync_lock, &end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
static int append_event(struct ast_event *ev)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_event *, ao2_ev, NULL, ao2_cleanup);
|
|
|
|
ao2_ev = ao2_dup_event(ev);
|
|
|
|
if (!ao2_ev) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ao2_link(cel_expected_events, ao2_ev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-03 20:59:01 +00:00
|
|
|
#ifdef RACEY_TESTS
|
2013-07-20 13:10:22 +00:00
|
|
|
static int append_dummy_event(void)
|
2013-07-02 14:01:53 +00:00
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_event *, ev, NULL, ast_free);
|
|
|
|
RAII_VAR(struct ast_event *, ao2_ev, NULL, ao2_cleanup);
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
ev = ast_event_new(AST_EVENT_CUSTOM, AST_EVENT_IE_END);
|
|
|
|
if (!ev) {
|
2013-07-02 14:01:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
return append_event(ev);
|
|
|
|
}
|
2014-12-03 20:59:01 +00:00
|
|
|
#endif
|
2013-07-20 13:10:22 +00:00
|
|
|
|
|
|
|
static int append_expected_event_snapshot(
|
|
|
|
struct ast_channel_snapshot *snapshot,
|
|
|
|
enum ast_cel_event_type type,
|
|
|
|
const char *userdefevname,
|
2013-09-27 14:08:23 +00:00
|
|
|
struct ast_json *extra,
|
|
|
|
const char *peer)
|
2013-07-20 13:10:22 +00:00
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_event *, ev, NULL, ast_free);
|
2013-09-27 14:08:23 +00:00
|
|
|
ev = ast_cel_create_event(snapshot, type, userdefevname, extra, peer);
|
2013-07-02 14:01:53 +00:00
|
|
|
if (!ev) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
return append_event(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int append_expected_event(
|
|
|
|
struct ast_channel *chan,
|
|
|
|
enum ast_cel_event_type type,
|
|
|
|
const char *userdefevname,
|
2013-09-27 14:08:23 +00:00
|
|
|
struct ast_json *extra,
|
|
|
|
const char *peer)
|
2013-07-20 13:10:22 +00:00
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
|
2013-12-18 20:33:37 +00:00
|
|
|
ast_channel_lock(chan);
|
2013-07-20 13:10:22 +00:00
|
|
|
snapshot = ast_channel_snapshot_create(chan);
|
2013-12-18 20:33:37 +00:00
|
|
|
ast_channel_unlock(chan);
|
2013-07-20 13:10:22 +00:00
|
|
|
if (!snapshot) {
|
2013-07-02 14:01:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
return append_expected_event_snapshot(snapshot, type, userdefevname, extra, peer);
|
2013-07-02 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 14:46:44 +00:00
|
|
|
static void test_sub(struct ast_event *event)
|
2013-07-02 14:01:53 +00:00
|
|
|
{
|
2018-11-26 22:18:00 +00:00
|
|
|
RAII_VAR(struct ast_event *, event_dup, ao2_dup_event(event), ao2_cleanup);
|
2014-12-03 19:49:38 +00:00
|
|
|
const char *chan_name;
|
2013-07-31 03:49:44 +00:00
|
|
|
SCOPED_MUTEX(mid_test_lock, &mid_test_sync_lock);
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
if (!event_dup) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-03 19:49:38 +00:00
|
|
|
chan_name = ast_event_get_ie_str(event_dup, AST_EVENT_IE_CEL_CHANNAME);
|
|
|
|
if (chan_name && strncmp(chan_name, CHANNEL_TECH_NAME, 14)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/* save the event for later processing */
|
|
|
|
ao2_link(cel_received_events, event_dup);
|
2013-07-31 03:49:44 +00:00
|
|
|
|
|
|
|
if (do_mid_test_sync) {
|
|
|
|
int expected = ao2_container_count(cel_expected_events);
|
|
|
|
int received = ao2_container_count(cel_received_events);
|
|
|
|
if (expected <= received) {
|
|
|
|
{
|
|
|
|
SCOPED_MUTEX(lock, &sync_lock);
|
|
|
|
ast_cond_signal(&sync_out);
|
|
|
|
do_mid_test_sync = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-02 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2013-08-16 17:33:21 +00:00
|
|
|
* \internal
|
|
|
|
* \brief Callback function called before each test executes
|
2013-07-02 14:01:53 +00:00
|
|
|
*/
|
|
|
|
static int test_cel_init_cb(struct ast_test_info *info, struct ast_test *test)
|
|
|
|
{
|
|
|
|
ast_assert(cel_received_events == NULL);
|
|
|
|
ast_assert(cel_expected_events == NULL);
|
|
|
|
|
2013-07-31 03:49:44 +00:00
|
|
|
ast_mutex_init(&mid_test_sync_lock);
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_mutex_init(&sync_lock);
|
|
|
|
ast_cond_init(&sync_out, NULL);
|
|
|
|
|
|
|
|
/* Back up the real CEL config and insert the test's config */
|
|
|
|
saved_config = ast_cel_get_config();
|
|
|
|
ast_cel_set_config(cel_test_config);
|
|
|
|
|
|
|
|
/* init CEL event storage (degenerate hash table becomes a linked list) */
|
2018-11-19 20:10:02 +00:00
|
|
|
cel_received_events = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL);
|
|
|
|
cel_expected_events = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
/* start the CEL event callback */
|
2013-08-17 14:46:44 +00:00
|
|
|
if (ast_cel_backend_register(TEST_BACKEND_NAME, test_sub)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-07-02 14:01:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
/*!
|
|
|
|
* \brief Check two peer strings for equality
|
|
|
|
*
|
|
|
|
* \retval zero if the peer strings do not match
|
|
|
|
* \retval non-zero if the peer strings match
|
|
|
|
*/
|
|
|
|
static int test_cel_peer_strings_match(const char *str1, const char *str2)
|
|
|
|
{
|
2018-11-26 22:18:00 +00:00
|
|
|
RAII_VAR(struct ao2_container *, intersection, ast_str_container_alloc(11), ao2_cleanup);
|
2013-09-27 14:08:23 +00:00
|
|
|
RAII_VAR(char *, str1_dup, ast_strdup(str1), ast_free);
|
|
|
|
RAII_VAR(char *, str2_dup, ast_strdup(str2), ast_free);
|
|
|
|
char *chan;
|
|
|
|
|
2018-11-26 22:18:00 +00:00
|
|
|
if (!intersection) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
while ((chan = strsep(&str1_dup, ","))) {
|
|
|
|
ast_str_container_add(intersection, chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((chan = strsep(&str2_dup, ","))) {
|
|
|
|
RAII_VAR(char *, ao2_chan, ao2_find(intersection, chan, OBJ_SEARCH_KEY), ao2_cleanup);
|
|
|
|
|
|
|
|
/* item in str2 not in str1 */
|
|
|
|
if (!ao2_chan) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_str_container_remove(intersection, chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* item in str1 not in str2 */
|
|
|
|
if (ao2_container_count(intersection)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Check an IE value from two events
|
|
|
|
*
|
|
|
|
* \retval zero if the IEs in the events of the specified type do not match
|
|
|
|
* \retval non-zero if the IEs in the events of the specified type match
|
|
|
|
*/
|
2013-07-02 14:01:53 +00:00
|
|
|
static int match_ie_val(
|
|
|
|
const struct ast_event *event1,
|
|
|
|
const struct ast_event *event2,
|
|
|
|
enum ast_event_ie_type type)
|
|
|
|
{
|
|
|
|
enum ast_event_ie_pltype pltype = ast_event_get_ie_pltype(type);
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
/* XXX ignore sec/usec for now */
|
|
|
|
if (type == AST_EVENT_IE_CEL_EVENT_TIME_USEC) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == AST_EVENT_IE_CEL_EVENT_TIME) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
switch (pltype) {
|
|
|
|
case AST_EVENT_IE_PLTYPE_UINT:
|
|
|
|
{
|
|
|
|
uint32_t val = ast_event_get_ie_uint(event2, type);
|
|
|
|
|
|
|
|
return (val == ast_event_get_ie_uint(event1, type)) ? 1 : 0;
|
|
|
|
}
|
|
|
|
case AST_EVENT_IE_PLTYPE_STR:
|
|
|
|
{
|
2013-09-27 14:08:23 +00:00
|
|
|
const char *str1 = ast_event_get_ie_str(event1, type);
|
|
|
|
const char *str2 = ast_event_get_ie_str(event2, type);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
if (!str1 && !str2) {
|
|
|
|
return 1;
|
|
|
|
} else if (!str1) {
|
|
|
|
return 0;
|
|
|
|
} else if (!str2) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
/* use special matching for CEL PEER field */
|
|
|
|
if (type == AST_EVENT_IE_CEL_PEER) {
|
|
|
|
return test_cel_peer_strings_match(str1, str2);
|
2013-07-02 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 14:08:23 +00:00
|
|
|
return !strcmp(str1, str2);
|
2013-07-02 14:01:53 +00:00
|
|
|
}
|
2014-05-23 17:36:35 +00:00
|
|
|
case AST_EVENT_IE_PLTYPE_RAW:
|
|
|
|
case AST_EVENT_IE_PLTYPE_BITFLAGS:
|
|
|
|
/* Fall through: just pass on these types */
|
|
|
|
return 1;
|
2013-07-02 14:01:53 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
static int events_are_equal(struct ast_test *test, struct ast_event *received, struct ast_event *expected)
|
2013-07-02 14:01:53 +00:00
|
|
|
{
|
|
|
|
struct ast_event_iterator iterator;
|
|
|
|
int res;
|
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
if (ast_event_get_type(expected) == AST_EVENT_CUSTOM) {
|
|
|
|
/* this event is flagged as a wildcard match */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (res = ast_event_iterator_init(&iterator, received); !res; res = ast_event_iterator_next(&iterator)) {
|
2013-07-02 14:01:53 +00:00
|
|
|
int ie_type = ast_event_iterator_get_ie_type(&iterator);
|
2013-09-27 14:08:23 +00:00
|
|
|
if (!match_ie_val(received, expected, ie_type)) {
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "Failed matching on field %s\n", ast_event_get_ie_type_name(ie_type));
|
2013-07-02 14:01:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
static int dump_event(struct ast_test *test, struct ast_event *event)
|
2013-07-02 14:01:53 +00:00
|
|
|
{
|
|
|
|
struct ast_event_iterator i;
|
|
|
|
|
|
|
|
if (ast_event_iterator_init(&i, event)) {
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "Failed to initialize event iterator. :-(\n");
|
2013-07-02 14:01:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-17 14:39:27 +00:00
|
|
|
ast_test_status_update(test, "Event: %s\n",
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_cel_get_type_name(ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE)));
|
|
|
|
|
|
|
|
do {
|
|
|
|
enum ast_event_ie_type ie_type;
|
|
|
|
enum ast_event_ie_pltype ie_pltype;
|
|
|
|
const char *ie_type_name;
|
|
|
|
|
|
|
|
ie_type = ast_event_iterator_get_ie_type(&i);
|
|
|
|
ie_type_name = ast_event_get_ie_type_name(ie_type);
|
|
|
|
ie_pltype = ast_event_get_ie_pltype(ie_type);
|
|
|
|
|
|
|
|
switch (ie_pltype) {
|
|
|
|
case AST_EVENT_IE_PLTYPE_UNKNOWN:
|
|
|
|
case AST_EVENT_IE_PLTYPE_STR:
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "%.30s: %s\n", ie_type_name,
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_event_iterator_get_ie_str(&i));
|
|
|
|
break;
|
|
|
|
case AST_EVENT_IE_PLTYPE_UINT:
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "%.30s: %u\n", ie_type_name,
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_event_iterator_get_ie_uint(&i));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!ast_event_iterator_next(&i));
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "\n");
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-29 14:51:00 +00:00
|
|
|
static int check_events(struct ast_test *test, struct ao2_container *local_expected, struct ao2_container *local_received)
|
2013-07-02 14:01:53 +00:00
|
|
|
{
|
2013-12-20 20:00:50 +00:00
|
|
|
struct ao2_iterator received_it;
|
|
|
|
struct ao2_iterator expected_it;
|
|
|
|
RAII_VAR(struct ast_event *, rx_event, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_event *, ex_event, NULL, ao2_cleanup);
|
2013-07-02 14:01:53 +00:00
|
|
|
int debug = 0;
|
|
|
|
|
|
|
|
if (ao2_container_count(local_expected) != ao2_container_count(local_received)) {
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "Increasing verbosity since the number of expected events (%d)"
|
2013-07-02 14:01:53 +00:00
|
|
|
" did not match number of received events (%d).\n",
|
|
|
|
ao2_container_count(local_expected),
|
|
|
|
ao2_container_count(local_received));
|
|
|
|
debug = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
received_it = ao2_iterator_init(local_received, 0);
|
2013-12-20 20:00:50 +00:00
|
|
|
expected_it = ao2_iterator_init(local_expected, 0);
|
2013-07-02 14:01:53 +00:00
|
|
|
rx_event = ao2_iterator_next(&received_it);
|
|
|
|
ex_event = ao2_iterator_next(&expected_it);
|
|
|
|
while (rx_event && ex_event) {
|
2013-07-29 14:51:00 +00:00
|
|
|
if (!events_are_equal(test, rx_event, ex_event)) {
|
2013-12-20 20:00:50 +00:00
|
|
|
ao2_iterator_destroy(&received_it);
|
|
|
|
ao2_iterator_destroy(&expected_it);
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "Received event:\n");
|
|
|
|
dump_event(test, rx_event);
|
|
|
|
ast_test_status_update(test, "Expected event:\n");
|
|
|
|
dump_event(test, ex_event);
|
2013-07-02 14:01:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (debug) {
|
2013-12-20 20:00:50 +00:00
|
|
|
ast_test_status_update(test, "Compared events successfully%s\n",
|
|
|
|
ast_event_get_type(ex_event) == AST_EVENT_CUSTOM
|
|
|
|
? " (wildcard match)" : "");
|
2013-07-29 14:51:00 +00:00
|
|
|
dump_event(test, rx_event);
|
2013-07-02 14:01:53 +00:00
|
|
|
}
|
|
|
|
ao2_cleanup(rx_event);
|
|
|
|
ao2_cleanup(ex_event);
|
|
|
|
rx_event = ao2_iterator_next(&received_it);
|
|
|
|
ex_event = ao2_iterator_next(&expected_it);
|
|
|
|
}
|
2013-12-20 20:00:50 +00:00
|
|
|
ao2_iterator_destroy(&received_it);
|
|
|
|
ao2_iterator_destroy(&expected_it);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
if (rx_event) {
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "Received event:\n");
|
|
|
|
dump_event(test, rx_event);
|
2013-07-02 14:01:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ex_event) {
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_status_update(test, "Expected event:\n");
|
|
|
|
dump_event(test, ex_event);
|
2013-07-02 14:01:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2013-08-16 17:33:21 +00:00
|
|
|
* \internal
|
|
|
|
* \brief Callback function called after each test executes.
|
|
|
|
*
|
|
|
|
* \details
|
2013-07-02 14:01:53 +00:00
|
|
|
* In addition to cleanup, this function also performs verification
|
|
|
|
* that the events received during a test match the events that were
|
|
|
|
* expected to have been generated during the test.
|
|
|
|
*/
|
|
|
|
static int cel_verify_and_cleanup_cb(struct ast_test_info *info, struct ast_test *test)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ao2_container *, local_expected, cel_expected_events, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ao2_container *, local_received, cel_received_events, ao2_cleanup);
|
|
|
|
ast_assert(cel_received_events != NULL);
|
|
|
|
ast_assert(cel_expected_events != NULL);
|
|
|
|
|
|
|
|
do_sleep();
|
|
|
|
|
|
|
|
/* stop the CEL event callback and clean up storage structures*/
|
2013-08-17 14:46:44 +00:00
|
|
|
ast_cel_backend_unregister(TEST_BACKEND_NAME);
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-11 15:37:51 +00:00
|
|
|
/* cleaned up by RAII_VAR's */
|
|
|
|
cel_expected_events = NULL;
|
|
|
|
cel_received_events = NULL;
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
/* check events */
|
2013-07-29 14:51:00 +00:00
|
|
|
ast_test_validate(test, !check_events(test, local_expected, local_received));
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
/* Restore the real CEL config */
|
|
|
|
ast_cel_set_config(saved_config);
|
|
|
|
ao2_cleanup(saved_config);
|
|
|
|
saved_config = NULL;
|
|
|
|
|
2013-07-11 15:37:51 +00:00
|
|
|
/* clean up the locks */
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_mutex_destroy(&sync_lock);
|
2013-07-31 03:49:44 +00:00
|
|
|
ast_mutex_destroy(&mid_test_sync_lock);
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_cond_destroy(&sync_out);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int unload_module(void)
|
|
|
|
{
|
|
|
|
AST_TEST_UNREGISTER(test_cel_channel_creation);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_unanswered_inbound_call);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_unanswered_outbound_call);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_single_party);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_single_bridge);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_single_bridge_continue);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_single_twoparty_bridge_a);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_single_twoparty_bridge_b);
|
2013-08-22 17:13:16 +00:00
|
|
|
#ifdef RACEY_TESTS
|
|
|
|
AST_TEST_UNREGISTER(test_cel_single_multiparty_bridge);
|
|
|
|
#endif
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_unanswered);
|
2014-07-07 01:22:44 +00:00
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_unanswered_filter);
|
2013-07-02 14:01:53 +00:00
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_congestion);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_busy);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_unavailable);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_caller_cancel);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_parallel_failed);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_answer_no_bridge);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_answer_twoparty_bridge_a);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_answer_twoparty_bridge_b);
|
2013-08-22 17:13:16 +00:00
|
|
|
#ifdef RACEY_TESTS
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_answer_multiparty);
|
2014-12-03 19:49:38 +00:00
|
|
|
AST_TEST_UNREGISTER(test_cel_attended_transfer_bridges_swap);
|
2014-12-03 20:59:01 +00:00
|
|
|
AST_TEST_UNREGISTER(test_cel_attended_transfer_bridges_link);
|
2013-08-22 17:13:16 +00:00
|
|
|
#endif
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
AST_TEST_UNREGISTER(test_cel_blind_transfer);
|
|
|
|
AST_TEST_UNREGISTER(test_cel_attended_transfer_bridges_merge);
|
|
|
|
|
|
|
|
AST_TEST_UNREGISTER(test_cel_dial_pickup);
|
|
|
|
|
2013-07-20 13:25:05 +00:00
|
|
|
AST_TEST_UNREGISTER(test_cel_local_optimize);
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
ast_channel_unregister(&test_cel_chan_tech);
|
|
|
|
|
2018-11-26 22:18:00 +00:00
|
|
|
ao2_cleanup(cel_expected_events);
|
|
|
|
cel_expected_events = NULL;
|
|
|
|
ao2_cleanup(cel_received_events);
|
|
|
|
cel_received_events = NULL;
|
2013-07-02 14:01:53 +00:00
|
|
|
ao2_cleanup(cel_test_config);
|
|
|
|
cel_test_config = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int load_module(void)
|
|
|
|
{
|
|
|
|
/* build the test config */
|
|
|
|
cel_test_config = ast_cel_general_config_alloc();
|
|
|
|
if (!cel_test_config) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cel_test_config->enable = 1;
|
|
|
|
if (ast_str_container_add(cel_test_config->apps, "dial")) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ast_str_container_add(cel_test_config->apps, "park")) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ast_str_container_add(cel_test_config->apps, "queue")) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_APP_START;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_CHANNEL_START;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_CHANNEL_END;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_ANSWER;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_HANGUP;
|
2013-08-22 17:13:16 +00:00
|
|
|
cel_test_config->events |= 1<<AST_CEL_BRIDGE_ENTER;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_BRIDGE_EXIT;
|
2013-07-20 13:10:22 +00:00
|
|
|
cel_test_config->events |= 1<<AST_CEL_BLINDTRANSFER;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_ATTENDEDTRANSFER;
|
|
|
|
cel_test_config->events |= 1<<AST_CEL_PICKUP;
|
2013-07-20 13:25:05 +00:00
|
|
|
cel_test_config->events |= 1<<AST_CEL_LOCAL_OPTIMIZE;
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
ast_channel_register(&test_cel_chan_tech);
|
|
|
|
|
|
|
|
AST_TEST_REGISTER(test_cel_channel_creation);
|
|
|
|
AST_TEST_REGISTER(test_cel_unanswered_inbound_call);
|
|
|
|
AST_TEST_REGISTER(test_cel_unanswered_outbound_call);
|
|
|
|
|
|
|
|
AST_TEST_REGISTER(test_cel_single_party);
|
|
|
|
AST_TEST_REGISTER(test_cel_single_bridge);
|
|
|
|
AST_TEST_REGISTER(test_cel_single_bridge_continue);
|
|
|
|
AST_TEST_REGISTER(test_cel_single_twoparty_bridge_a);
|
|
|
|
AST_TEST_REGISTER(test_cel_single_twoparty_bridge_b);
|
2013-08-22 17:13:16 +00:00
|
|
|
#ifdef RACEY_TESTS
|
|
|
|
AST_TEST_REGISTER(test_cel_single_multiparty_bridge);
|
|
|
|
#endif
|
2013-07-02 14:01:53 +00:00
|
|
|
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_unanswered);
|
2014-07-07 01:22:44 +00:00
|
|
|
AST_TEST_REGISTER(test_cel_dial_unanswered_filter);
|
2013-07-02 14:01:53 +00:00
|
|
|
AST_TEST_REGISTER(test_cel_dial_congestion);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_busy);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_unavailable);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_caller_cancel);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_parallel_failed);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_answer_no_bridge);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_answer_twoparty_bridge_a);
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_answer_twoparty_bridge_b);
|
2013-08-22 17:13:16 +00:00
|
|
|
#ifdef RACEY_TESTS
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_answer_multiparty);
|
2014-12-03 19:49:38 +00:00
|
|
|
AST_TEST_REGISTER(test_cel_attended_transfer_bridges_swap);
|
2014-12-03 20:59:01 +00:00
|
|
|
AST_TEST_REGISTER(test_cel_attended_transfer_bridges_link);
|
2013-08-22 17:13:16 +00:00
|
|
|
#endif
|
2013-07-02 14:01:53 +00:00
|
|
|
|
2013-07-20 13:10:22 +00:00
|
|
|
AST_TEST_REGISTER(test_cel_blind_transfer);
|
|
|
|
AST_TEST_REGISTER(test_cel_attended_transfer_bridges_merge);
|
|
|
|
|
|
|
|
AST_TEST_REGISTER(test_cel_dial_pickup);
|
|
|
|
|
2013-07-20 13:25:05 +00:00
|
|
|
AST_TEST_REGISTER(test_cel_local_optimize);
|
|
|
|
|
2013-07-11 02:02:48 +00:00
|
|
|
/* ast_test_register_* has to happen after AST_TEST_REGISTER */
|
|
|
|
/* Verify received vs expected events and clean things up after every test */
|
|
|
|
ast_test_register_init(TEST_CATEGORY, test_cel_init_cb);
|
|
|
|
ast_test_register_cleanup(TEST_CATEGORY, cel_verify_and_cleanup_cb);
|
|
|
|
|
2013-07-02 14:01:53 +00:00
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "CEL unit tests");
|