diff options
author | Matthew Jordan <mjordan@digium.com> | 2011-08-22 19:19:44 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2011-08-22 19:19:44 +0000 |
commit | 3b53a9cdb302417e42928225266a763bf826b9be (patch) | |
tree | 7ee015d81a6e8c0f0984817f979f5f1d0816fa47 /main | |
parent | bac5a51e2121a63549941f3a9ce7f7a4c50454ca (diff) |
Merged revisions 332817 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r332817 | mjordan | 2011-08-22 13:15:51 -0500 (Mon, 22 Aug 2011) | 4 lines
Review: https://reviewboard.asterisk.org/r/1364/
This update adds a new AMI event, TestEvent, which is enabled when the TEST_FRAMEWORK compiler flag is defined. It also adds initial usage of this event to app_voicemail. The TestEvent AMI event is used extensively by the voicemail tests in the Asterisk Test Suite.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@332844 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 2 | ||||
-rw-r--r-- | main/file.c | 1 | ||||
-rw-r--r-- | main/manager.c | 1 | ||||
-rw-r--r-- | main/test.c | 43 |
4 files changed, 47 insertions, 0 deletions
diff --git a/main/app.c b/main/app.c index eef527c56..a48935e8f 100644 --- a/main/app.c +++ b/main/app.c @@ -54,6 +54,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/indications.h" #include "asterisk/linkedlists.h" #include "asterisk/threadstorage.h" +#include "asterisk/test.h" AST_THREADSTORAGE_PUBLIC(ast_str_thread_global_buf); @@ -698,6 +699,7 @@ int ast_play_and_wait(struct ast_channel *chan, const char *fn) { int d = 0; + ast_test_suite_event_notify("PLAYBACK", "Message: %s", fn); if ((d = ast_streamfile(chan, fn, chan->language))) { return d; } diff --git a/main/file.c b/main/file.c index 6912a37bc..f1e590385 100644 --- a/main/file.c +++ b/main/file.c @@ -1410,6 +1410,7 @@ int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char * { int res = 0; if (!ast_strlen_zero(file)) { + ast_test_suite_event_notify("PLAYBACK", "Message: %s", file); res = ast_streamfile(chan, file, chan->language); if (!res) { res = ast_waitstream(chan, digits); diff --git a/main/manager.c b/main/manager.c index 319b5ba86..8e0119d99 100644 --- a/main/manager.c +++ b/main/manager.c @@ -1178,6 +1178,7 @@ static const struct permalias { { EVENT_FLAG_AGI, "agi" }, { EVENT_FLAG_CC, "cc" }, { EVENT_FLAG_AOC, "aoc" }, + { EVENT_FLAG_TEST, "test" }, { INT_MAX, "all" }, { 0, "none" }, }; diff --git a/main/test.c b/main/test.c index ad5c16f5b..741c0f540 100644 --- a/main/test.c +++ b/main/test.c @@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); #include "asterisk/version.h" #include "asterisk/paths.h" #include "asterisk/time.h" +#include "asterisk/manager.h" /*! This array corresponds to the values defined in the ast_test_state enum */ static const char * const test_result2str[] = { @@ -884,6 +885,48 @@ static struct ast_cli_entry test_cli[] = { AST_CLI_DEFINE(test_cli_show_results, "show last test results"), AST_CLI_DEFINE(test_cli_generate_results, "generate test results to file"), }; + +int __ast_test_suite_event_notify(const char *file, const char *func, int line, + const char *state, const char *fmt, ...) +{ + struct ast_str *buf = NULL; + va_list ap; + + if (!(buf = ast_str_create(128))) { + return -1; + } + + va_start(ap, fmt); + ast_str_set_va(&buf, 0, fmt, ap); + va_end(ap); + + manager_event(EVENT_FLAG_TEST, "TestEvent", + "Type: StateChange\r\n" + "State: %s\r\n" + "AppFile: %s\r\n" + "AppFunction: %s\r\n" + "AppLine: %d\r\n%s\r\n", + state, file, func, line, ast_str_buffer(buf)); + + ast_free(buf); + + return 0; +} + +int __ast_test_suite_assert_notify(const char *file, const char *func, int line, + const char *exp) +{ + manager_event(EVENT_FLAG_TEST, "TestEvent", + "Type: Assert\r\n" + "AppFile: %s\r\n" + "AppFunction: %s\r\n" + "AppLine: %d\r\n" + "Expression: %s\r\n", + file, func, line, exp); + + return 0; +} + #endif /* TEST_FRAMEWORK */ int ast_test_init() |