summaryrefslogtreecommitdiff
path: root/main/test.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2011-08-22 19:19:44 +0000
committerMatthew Jordan <mjordan@digium.com>2011-08-22 19:19:44 +0000
commit3b53a9cdb302417e42928225266a763bf826b9be (patch)
tree7ee015d81a6e8c0f0984817f979f5f1d0816fa47 /main/test.c
parentbac5a51e2121a63549941f3a9ce7f7a4c50454ca (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/test.c')
-rw-r--r--main/test.c43
1 files changed, 43 insertions, 0 deletions
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()