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 /include | |
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 'include')
-rw-r--r-- | include/asterisk/manager.h | 1 | ||||
-rw-r--r-- | include/asterisk/test.h | 56 |
2 files changed, 57 insertions, 0 deletions
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index 08d68e931..12da11b44 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -84,6 +84,7 @@ #define EVENT_FLAG_HOOKRESPONSE (1 << 14) /* Hook Response */ #define EVENT_FLAG_CC (1 << 15) /* Call Completion events */ #define EVENT_FLAG_AOC (1 << 16) /* Advice Of Charge events */ +#define EVENT_FLAG_TEST (1 << 17) /* Test event used to signal the Asterisk Test Suite */ /*@} */ /*! \brief Export manager structures */ diff --git a/include/asterisk/test.h b/include/asterisk/test.h index 57e05b471..27ec3cfa8 100644 --- a/include/asterisk/test.h +++ b/include/asterisk/test.h @@ -130,6 +130,62 @@ #endif +/*! Macros used for the Asterisk Test Suite AMI events */ +#ifdef TEST_FRAMEWORK + +/*! + * \brief Notifies the test suite of a change in application state + * + * \details + * Raises a TestEvent manager event with a subtype of StateChange. Additional parameters + * The fmt parameter allows additional parameters to be added to the manager event using + * printf style statement formatting. + * + * \param state The state the application has changed to + * \param fmt The message with format parameters to add to the manager event + * + * \returns 0 on success + * \returns any other value on failure + */ +int __ast_test_suite_event_notify(const char *file, const char *func, int line, + const char *state, const char *fmt, ...) + __attribute__((format(printf, 5, 6))); + +/*! + * \brief Notifies the test suite of a failed assert on an expression + * + * \details + * If the expression provided evaluates to true, no action is taken. If the expression + * evaluates to a false, a TestEvent manager event is raised with a subtype of Assert, notifying + * the test suite that the expression failed to evaluate to true. + * + * \param exp The expression to evaluate + * + * \returns 0 on success + * \returns any other value on failure + */ +int __ast_test_suite_assert_notify(const char *file, const char *func, int line, + const char *exp); + +/*! + * \ref __ast_test_suite_event_notify() + */ +#define ast_test_suite_event_notify(s, f, ...) \ + __ast_test_suite_event_notify(__FILE__, __PRETTY_FUNCTION__, __LINE__, (s), (f), ## __VA_ARGS__) + +/*! + * \ref __ast_test_suite_assert_notify() + */ +#define ast_test_suite_assert(exp) \ + ( (exp) ? (void)0 : __ast_test_suite_assert_notify(__FILE__, __PRETTY_FUNCTION__, __LINE__, #exp)) + +#else + +#define ast_test_suite_event_notify(s, f, ...) (void)0; +#define ast_test_suite_assert(exp) (void)0; + +#endif + enum ast_test_result_state { AST_TEST_NOT_RUN, AST_TEST_PASS, |