diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-06-17 03:00:38 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-06-17 03:00:38 +0000 |
commit | 6258bbe7bd1885ac5dec095ed0c4490c83a99f44 (patch) | |
tree | ff2794f730ca55903a09b9fe7f73f45169a71386 /main/test.c | |
parent | 67e35c7b4748c3cef954820a2b182e2a5edf8d98 (diff) |
Update Asterisk's CDRs for the new bridging framework
This patch is the initial push to update Asterisk's CDR engine for the new
bridging framework. This patch guts the existing CDR engine and builds the new
on top of messages coming across Stasis. As changes in channel state and bridge
state are detected, CDRs are built and dispatched accordingly. This
fundamentally changes CDRs in a few ways.
(1) CDRs are now *very* reflective of the actual state of channels and bridges.
This means CDRs track well with what an actual channel is doing - which
is useful in transfer scenarios (which were previously difficult to pin
down). It does, however, mean that CDRs cannot be 'fooled'. Previous
behavior in Asterisk allowed for CDR applications, channels, and other
properties to be spoofed in parts of the code - this no longer works.
(2) CDRs have defined behavior in multi-party scenarios. This behavior will not
be what everyone wants, but it is a defined behavior and as such, it is
predictable.
(3) The CDR manipulation functions and applications have been overhauled. Major
changes have been made to ResetCDR and ForkCDR in particular. Many of the
options for these two applications no longer made any sense with the new
framework and the (slightly) more immutable nature of CDRs.
There are a plethora of other changes. For a full description of CDR behavior,
see the CDR specification on the Asterisk wiki.
(closes issue ASTERISK-21196)
Review: https://reviewboard.asterisk.org/r/2486/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/test.c')
-rw-r--r-- | main/test.c | 66 |
1 files changed, 62 insertions, 4 deletions
diff --git a/main/test.c b/main/test.c index 2109c9478..fdc4916e1 100644 --- a/main/test.c +++ b/main/test.c @@ -48,6 +48,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); #include "asterisk/stasis.h" #include "asterisk/json.h" #include "asterisk/astobj2.h" +#include "asterisk/stasis.h" +#include "asterisk/json.h" /*! \since 12 * \brief The topic for test suite messages @@ -80,9 +82,11 @@ struct ast_test { * CLI in addition to being saved off in status_str. */ struct ast_cli_args *cli; - enum ast_test_result_state state; /*!< current test state */ - unsigned int time; /*!< time in ms test took */ - ast_test_cb_t *cb; /*!< test callback function */ + enum ast_test_result_state state; /*!< current test state */ + unsigned int time; /*!< time in ms test took */ + ast_test_cb_t *cb; /*!< test callback function */ + ast_test_init_cb_t *init_cb; /*!< test init function */ + ast_test_cleanup_cb_t *cleanup_cb; /*!< test cleanup function */ AST_LIST_ENTRY(ast_test) entry; }; @@ -159,6 +163,40 @@ int __ast_test_status_update(const char *file, const char *func, int line, struc return 0; } +int ast_test_register_init(const char *category, ast_test_init_cb_t *cb) +{ + struct ast_test *test; + int registered = 1; + + AST_LIST_LOCK(&tests); + AST_LIST_TRAVERSE(&tests, test, entry) { + if (!(test_cat_cmp(test->info.category, category))) { + test->init_cb = cb; + registered = 0; + } + } + AST_LIST_UNLOCK(&tests); + + return registered; +} + +int ast_test_register_cleanup(const char *category, ast_test_cleanup_cb_t *cb) +{ + struct ast_test *test; + int registered = 1; + + AST_LIST_LOCK(&tests); + AST_LIST_TRAVERSE(&tests, test, entry) { + if (!(test_cat_cmp(test->info.category, category))) { + test->cleanup_cb = cb; + registered = 0; + } + } + AST_LIST_UNLOCK(&tests); + + return registered; +} + int ast_test_register(ast_test_cb_t *cb) { struct ast_test *test; @@ -203,14 +241,34 @@ int ast_test_unregister(ast_test_cb_t *cb) static void test_execute(struct ast_test *test) { struct timeval begin; + enum ast_test_result_state result; ast_str_reset(test->status_str); begin = ast_tvnow(); - test->state = test->cb(&test->info, TEST_EXECUTE, test); + if (test->init_cb && test->init_cb(&test->info, test)) { + test->state = AST_TEST_FAIL; + goto exit; + } + result = test->cb(&test->info, TEST_EXECUTE, test); + if (test->state != AST_TEST_FAIL) { + test->state = result; + } + if (test->cleanup_cb && test->cleanup_cb(&test->info, test)) { + test->state = AST_TEST_FAIL; + } +exit: test->time = ast_tvdiff_ms(ast_tvnow(), begin); } +void ast_test_set_result(struct ast_test *test, enum ast_test_result_state state) +{ + if (test->state == AST_TEST_FAIL || state == AST_TEST_NOT_RUN) { + return; + } + test->state = state; +} + static void test_xml_entry(struct ast_test *test, FILE *f) { if (!f || !test || test->state == AST_TEST_NOT_RUN) { |