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
This commit is contained in:
Matthew Jordan
2011-08-22 19:19:44 +00:00
parent bac5a51e21
commit 3b53a9cdb3
8 changed files with 230 additions and 39 deletions

View File

@@ -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()