FS-11453 [mod_rayo] convert to fst testing
This commit is contained in:
parent
e0b5df10d6
commit
2226c3c621
|
@ -1929,6 +1929,7 @@ AC_CONFIG_FILES([Makefile
|
|||
src/mod/event_handlers/mod_radius_cdr/Makefile
|
||||
src/mod/event_handlers/mod_odbc_cdr/Makefile
|
||||
src/mod/event_handlers/mod_rayo/Makefile
|
||||
src/mod/event_handlers/mod_rayo/test/Makefile
|
||||
src/mod/event_handlers/mod_smpp/Makefile
|
||||
src/mod/event_handlers/mod_snmp/Makefile
|
||||
src/mod/event_handlers/mod_event_zmq/Makefile
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
/**
|
||||
* Get environment variable and save to var
|
||||
( )
|
||||
*/
|
||||
static char *fst_getenv_default(const char *env, char *default_value, switch_bool_t required)
|
||||
{
|
||||
|
@ -171,7 +170,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
*/
|
||||
#define fst_check_int_range(actual, expected, precision) \
|
||||
fct_xchk( \
|
||||
abs((val - expected)) <= precision, \
|
||||
abs((actual - expected)) <= precision, \
|
||||
"fst_check_int_range: %d != %d +/- %d", \
|
||||
(actual), \
|
||||
(expected), \
|
||||
|
@ -183,13 +182,39 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
*/
|
||||
#define fst_check_double_range(actual, expected, precision) \
|
||||
fct_xchk( \
|
||||
fabs((val - expected)) <= precision, \
|
||||
fabs((actual - expected)) <= precision, \
|
||||
"fst_check_double_range: %f != %f +/- %f", \
|
||||
(actual), \
|
||||
(expected), \
|
||||
(precision) \
|
||||
);
|
||||
|
||||
/**
|
||||
* Run test without loading FS core
|
||||
*/
|
||||
#define FST_BEGIN() \
|
||||
FCT_BGN() \
|
||||
{ \
|
||||
int fst_core = 0; \
|
||||
switch_time_t fst_time_start = 0; \
|
||||
switch_timer_t fst_timer = { 0 }; \
|
||||
switch_memory_pool_t *fst_pool = NULL; \
|
||||
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
|
||||
if (fst_core) { \
|
||||
fst_init_core_and_modload(NULL, NULL); /* shuts up compiler */ \
|
||||
} \
|
||||
{ \
|
||||
|
||||
|
||||
#define FST_END() \
|
||||
} \
|
||||
if (fst_time_start) { \
|
||||
/* shut up compiler */ \
|
||||
fst_time_start = 0; \
|
||||
} \
|
||||
} \
|
||||
FCT_END()
|
||||
|
||||
/**
|
||||
* Define the beginning of a freeswitch core test driver. Only one per test application allowed.
|
||||
* @param confdir directory containing freeswitch.xml configuration
|
||||
|
@ -197,12 +222,13 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
#define FST_CORE_BEGIN(confdir) \
|
||||
FCT_BGN() \
|
||||
{ \
|
||||
int fst_core = 1; \
|
||||
switch_time_t fst_time_start = 0; \
|
||||
switch_timer_t fst_timer = { 0 }; \
|
||||
switch_memory_pool_t *fst_pool = NULL; \
|
||||
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
|
||||
fst_init_core_and_modload(confdir, NULL); \
|
||||
{ \
|
||||
{
|
||||
|
||||
/**
|
||||
* Define the end of a freeswitch core test driver.
|
||||
|
@ -210,6 +236,10 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
#define FST_CORE_END() \
|
||||
/*switch_core_destroy();*/ \
|
||||
} \
|
||||
if (fst_time_start) { \
|
||||
/* shut up compiler */ \
|
||||
fst_time_start = 0; \
|
||||
} \
|
||||
} \
|
||||
FCT_END()
|
||||
|
||||
|
@ -222,6 +252,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
#define FST_MODULE_BEGIN(modname,suite) \
|
||||
{ \
|
||||
const char *fst_test_module = #modname; \
|
||||
fst_requires(fst_core); \
|
||||
if (!zstr(fst_test_module)) { \
|
||||
const char *err; \
|
||||
switch_loadable_module_load_module((char *)"../.libs", (char *)fst_test_module, SWITCH_FALSE, &err); \
|
||||
|
@ -259,10 +290,12 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
*/
|
||||
#define FST_SETUP_BEGIN() \
|
||||
FCT_SETUP_BGN() \
|
||||
switch_core_new_memory_pool(&fst_pool); \
|
||||
fst_requires(fst_pool != NULL); \
|
||||
fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \
|
||||
fst_time_mark();
|
||||
if (fst_core) { \
|
||||
switch_core_new_memory_pool(&fst_pool); \
|
||||
fst_requires(fst_pool != NULL); \
|
||||
fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \
|
||||
fst_time_mark(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the end of test suite setup.
|
||||
|
@ -275,8 +308,10 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
*/
|
||||
#define FST_TEARDOWN_BEGIN() \
|
||||
FCT_TEARDOWN_BGN() \
|
||||
switch_core_destroy_memory_pool(&fst_pool); \
|
||||
switch_core_timer_destroy(&fst_timer);
|
||||
if (fst_core) { \
|
||||
switch_core_destroy_memory_pool(&fst_pool); \
|
||||
switch_core_timer_destroy(&fst_timer); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the test suite teardown end.
|
||||
|
@ -323,6 +358,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
switch_core_session_t *fst_session = NULL; \
|
||||
switch_event_t *fst_originate_vars = NULL; \
|
||||
switch_call_cause_t fst_cause = SWITCH_CAUSE_NORMAL_CLEARING; \
|
||||
fst_requires(fst_core); \
|
||||
if (fst_test_module) { \
|
||||
fst_requires_module(fst_test_module); \
|
||||
} \
|
||||
|
@ -387,6 +423,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
char *fst_asr_result = NULL; \
|
||||
switch_asr_handle_t ah = { 0 }; \
|
||||
switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; \
|
||||
fst_requires(fst_core); \
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Open recognizer: %s\n", recognizer); \
|
||||
/* open ASR interface and feed recorded audio into it and collect result */ \
|
||||
fst_requires(switch_core_asr_open(&ah, recognizer, "L16", 8000, "", &flags, fst_pool) == SWITCH_STATUS_SUCCESS); \
|
||||
|
@ -419,6 +456,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
fst_asr_result = NULL; \
|
||||
file_handle.channels = 1; \
|
||||
file_handle.native_rate = 8000; \
|
||||
fst_requires(fst_core); \
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Test recognizer: input = %s\n", input_filename); \
|
||||
fst_requires(switch_core_asr_load_grammar(&ah, grammar, "") == SWITCH_STATUS_SUCCESS); \
|
||||
fst_requires(switch_core_file_open(&file_handle, input_filename, file_handle.channels, 8000, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS); \
|
||||
|
@ -461,6 +499,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
* switch_core_asr_pause(&ah) == SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
#define fst_test_core_asr_pause() \
|
||||
fst_requires(fst_core); \
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Pause recognizer\n"); \
|
||||
flags = SWITCH_ASR_FLAG_NONE; \
|
||||
fst_requires(switch_core_asr_pause(&ah) == SWITCH_STATUS_SUCCESS);
|
||||
|
@ -472,6 +511,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
* switch_core_asr_resume(&ah) == SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
#define fst_test_core_asr_resume() \
|
||||
fst_requires(fst_core); \
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Resume recognizer\n"); \
|
||||
flags = SWITCH_ASR_FLAG_NONE; \
|
||||
fst_requires(switch_core_asr_resume(&ah) == SWITCH_STATUS_SUCCESS);
|
||||
|
@ -483,6 +523,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
* switch_core_asr_close(&ah, flags) == SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
#define fst_test_core_asr_close() \
|
||||
fst_requires(fst_core); \
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Close recognizer\n"); \
|
||||
flags = SWITCH_ASR_FLAG_NONE; \
|
||||
fst_requires(switch_core_asr_close(&ah, &flags) == SWITCH_STATUS_SUCCESS); \
|
||||
|
@ -500,7 +541,8 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
*/
|
||||
#define fst_play_and_detect_speech_test_begin() \
|
||||
{ \
|
||||
const char *fst_asr_result = NULL;
|
||||
const char *fst_asr_result = NULL; \
|
||||
fst_requires(fst_core);
|
||||
|
||||
/**
|
||||
* Use play_and_detect_speech APP to test recognizer
|
||||
|
@ -524,6 +566,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
#define fst_play_and_detect_speech_app_test(recognizer, grammar, prompt_filename, input_filename) \
|
||||
{ \
|
||||
char *args = NULL; \
|
||||
fst_requires(fst_core); \
|
||||
fst_requires_module("mod_dptools"); \
|
||||
switch_channel_set_variable(fst_channel, "detect_speech_result", ""); \
|
||||
fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \
|
||||
|
@ -555,6 +598,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
{ \
|
||||
char *args = NULL; \
|
||||
fst_asr_result = NULL; \
|
||||
fst_requires(fst_core); \
|
||||
fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \
|
||||
switch_status_t status = switch_ivr_play_and_detect_speech(fst_session, prompt_filename, recognizer, grammar, (char **)&fst_asr_result, 0, input_args); \
|
||||
fst_check(fst_asr_result != NULL); \
|
||||
|
@ -580,6 +624,7 @@ static void fst_init_core_and_modload(const char *confdir, const char *basedir)
|
|||
{ \
|
||||
switch_stream_handle_t stream = { 0 }; \
|
||||
SWITCH_STANDARD_STREAM(stream); \
|
||||
fst_requires(fst_core); \
|
||||
fst_requires_module("mod_commands"); \
|
||||
switch_status_t api_result = switch_api_execute("sched_api", switch_core_session_sprintf(fst_session, "%s none uuid_recv_dtmf %s %s", when, switch_core_session_get_uuid(fst_session), digits), NULL, &stream); \
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fst_session), SWITCH_LOG_INFO, "Injecting DTMF %s at %s\n", digits, when); \
|
||||
|
|
|
@ -17,3 +17,5 @@ BUILT_SOURCES=$(IKS_LA)
|
|||
$(IKS_LA): $(IKS_BUILDDIR) $(IKS_DIR) $(IKS_DIR)/.update
|
||||
@cd $(IKS_BUILDDIR) && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
SUBDIRS=. test
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013, Grasshopper
|
||||
* Copyright (C) 2013-2018, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -51,50 +51,50 @@ struct xmpp_error {
|
|||
|
||||
#undef XMPP_ERROR
|
||||
#define XMPP_ERROR(def_name, name, type) \
|
||||
extern const struct xmpp_error def_name##_val; \
|
||||
extern const struct xmpp_error *def_name;
|
||||
SWITCH_DECLARE(const struct xmpp_error) def_name##_val; \
|
||||
SWITCH_DECLARE(const struct xmpp_error *) def_name;
|
||||
#include "xmpp_errors.def"
|
||||
|
||||
/* See RFC-3920 XMPP core for error definitions */
|
||||
extern iks *iks_new_presence(const char *name, const char *namespace, const char *from, const char *to);
|
||||
extern iks *iks_new_error(iks *iq, const struct xmpp_error *err);
|
||||
extern iks *iks_new_error_detailed(iks *iq, const struct xmpp_error *err, const char *detail_text);
|
||||
extern iks *iks_new_error_detailed_printf(iks *iq, const struct xmpp_error *err, const char *detail_text_format, ...);
|
||||
extern iks *iks_new_iq_result(iks *iq);
|
||||
extern const char *iks_find_attrib_soft(iks *xml, const char *attrib);
|
||||
extern const char *iks_find_attrib_default(iks *xml, const char *attrib, const char *def);
|
||||
extern int iks_find_bool_attrib(iks *xml, const char *attrib);
|
||||
extern int iks_find_int_attrib(iks *xml, const char *attrib);
|
||||
extern char iks_find_char_attrib(iks *xml, const char *attrib);
|
||||
extern double iks_find_decimal_attrib(iks *xml, const char *attrib);
|
||||
extern const char *iks_node_type_to_string(int type);
|
||||
extern const char *iks_net_error_to_string(int err);
|
||||
extern iks *iks_insert_attrib_printf(iks *xml, const char *name, const char *fmt, ...);
|
||||
SWITCH_DECLARE(iks *) iks_new_presence(const char *name, const char *namespace, const char *from, const char *to);
|
||||
SWITCH_DECLARE(iks *) iks_new_error(iks *iq, const struct xmpp_error *err);
|
||||
SWITCH_DECLARE(iks *) iks_new_error_detailed(iks *iq, const struct xmpp_error *err, const char *detail_text);
|
||||
SWITCH_DECLARE(iks *) iks_new_error_detailed_printf(iks *iq, const struct xmpp_error *err, const char *detail_text_format, ...);
|
||||
SWITCH_DECLARE(iks *) iks_new_iq_result(iks *iq);
|
||||
SWITCH_DECLARE(const char *) iks_find_attrib_soft(iks *xml, const char *attrib);
|
||||
SWITCH_DECLARE(const char *) iks_find_attrib_default(iks *xml, const char *attrib, const char *def);
|
||||
SWITCH_DECLARE(int) iks_find_bool_attrib(iks *xml, const char *attrib);
|
||||
SWITCH_DECLARE(int) iks_find_int_attrib(iks *xml, const char *attrib);
|
||||
SWITCH_DECLARE(char) iks_find_char_attrib(iks *xml, const char *attrib);
|
||||
SWITCH_DECLARE(double) iks_find_decimal_attrib(iks *xml, const char *attrib);
|
||||
SWITCH_DECLARE(const char *) iks_node_type_to_string(int type);
|
||||
SWITCH_DECLARE(const char *) iks_net_error_to_string(int err);
|
||||
SWITCH_DECLARE(iks *) iks_insert_attrib_printf(iks *xml, const char *name, const char *fmt, ...);
|
||||
|
||||
extern char *iks_server_dialback_key(const char *secret, const char *receiving_server, const char *originating_server, const char *stream_id);
|
||||
extern void iks_sha_print_base64(iksha *sha, char *buf);
|
||||
SWITCH_DECLARE(char *) iks_server_dialback_key(const char *secret, const char *receiving_server, const char *originating_server, const char *stream_id);
|
||||
SWITCH_DECLARE(void) iks_sha_print_base64(iksha *sha, char *buf);
|
||||
|
||||
/** A function to validate attribute value */
|
||||
typedef int (*iks_attrib_validation_function)(const char *);
|
||||
|
||||
extern int validate_optional_attrib(iks_attrib_validation_function fn, const char *attrib);
|
||||
SWITCH_DECLARE(int) validate_optional_attrib(iks_attrib_validation_function fn, const char *attrib);
|
||||
|
||||
#define ELEMENT_DECL(name) extern int VALIDATE_##name(iks *node);
|
||||
#define ELEMENT_DECL(name) SWITCH_DECLARE(int) VALIDATE_##name(iks *node);
|
||||
#define ELEMENT(name) int VALIDATE_##name(iks *node) { int result = 1; if (!node) return 0;
|
||||
#define ATTRIB(name, def, rule) result &= iks_attrib_is_##rule(iks_find_attrib_default(node, #name, #def));
|
||||
#define OPTIONAL_ATTRIB(name, def, rule) result &= validate_optional_attrib(iks_attrib_is_##rule, iks_find_attrib_default(node, #name, #def));
|
||||
#define STRING_ATTRIB(name, def, rule) result &= value_matches(iks_find_attrib_default(node, #name, #def), rule);
|
||||
#define ELEMENT_END return result; }
|
||||
|
||||
extern int value_matches(const char *value, const char *rule);
|
||||
SWITCH_DECLARE(int) value_matches(const char *value, const char *rule);
|
||||
|
||||
extern int iks_attrib_is_bool(const char *value);
|
||||
extern int iks_attrib_is_not_negative(const char *value);
|
||||
extern int iks_attrib_is_positive(const char *value);
|
||||
extern int iks_attrib_is_positive_or_neg_one(const char *value);
|
||||
extern int iks_attrib_is_any(const char *value);
|
||||
extern int iks_attrib_is_decimal_between_zero_and_one(const char *value);
|
||||
extern int iks_attrib_is_dtmf_digit(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_bool(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_not_negative(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_positive(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_positive_or_neg_one(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_any(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_decimal_between_zero_and_one(const char *value);
|
||||
SWITCH_DECLARE(int) iks_attrib_is_dtmf_digit(const char *value);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013, Grasshopper
|
||||
* Copyright (C) 2013-2018, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -129,20 +129,20 @@ struct rayo_component {
|
|||
#define RAYO_CALL(x) ((struct rayo_call *)x)
|
||||
#define RAYO_MIXER(x) ((struct rayo_mixer *)x)
|
||||
|
||||
extern void rayo_message_send(struct rayo_actor *from, const char *to, iks *payload, int dup, int reply, const char *file, int line);
|
||||
extern void rayo_message_destroy(struct rayo_message *msg);
|
||||
extern iks *rayo_message_remove_payload(struct rayo_message *msg);
|
||||
SWITCH_DECLARE(void) rayo_message_send(struct rayo_actor *from, const char *to, iks *payload, int dup, int reply, const char *file, int line);
|
||||
SWITCH_DECLARE(void) rayo_message_destroy(struct rayo_message *msg);
|
||||
SWITCH_DECLARE(iks *) rayo_message_remove_payload(struct rayo_message *msg);
|
||||
#define RAYO_SEND_MESSAGE(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 0, 0, __FILE__, __LINE__)
|
||||
#define RAYO_SEND_MESSAGE_DUP(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 1, 0, __FILE__, __LINE__)
|
||||
#define RAYO_SEND_REPLY(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 0, 1, __FILE__, __LINE__)
|
||||
#define RAYO_SEND_REPLY_DUP(from, to, payload) rayo_message_send(RAYO_ACTOR(from), to, payload, 1, 1, __FILE__, __LINE__)
|
||||
|
||||
extern struct rayo_actor *rayo_actor_locate(const char *jid, const char *file, int line);
|
||||
extern struct rayo_actor *rayo_actor_locate_by_id(const char *id, const char *file, int line);
|
||||
extern int rayo_actor_seq_next(struct rayo_actor *actor);
|
||||
extern void rayo_actor_retain(struct rayo_actor *actor, const char *file, int line);
|
||||
extern void rayo_actor_release(struct rayo_actor *actor, const char *file, int line);
|
||||
extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line);
|
||||
SWITCH_DECLARE(struct rayo_actor *) rayo_actor_locate(const char *jid, const char *file, int line);
|
||||
SWITCH_DECLARE(struct rayo_actor *) rayo_actor_locate_by_id(const char *id, const char *file, int line);
|
||||
SWITCH_DECLARE(int) rayo_actor_seq_next(struct rayo_actor *actor);
|
||||
SWITCH_DECLARE(void) rayo_actor_retain(struct rayo_actor *actor, const char *file, int line);
|
||||
SWITCH_DECLARE(void) rayo_actor_release(struct rayo_actor *actor, const char *file, int line);
|
||||
SWITCH_DECLARE(void) rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line);
|
||||
|
||||
#define RAYO_LOCATE(jid) rayo_actor_locate(jid, __FILE__, __LINE__)
|
||||
#define RAYO_LOCATE_BY_ID(id) rayo_actor_locate_by_id(id, __FILE__, __LINE__)
|
||||
|
@ -156,21 +156,21 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
|
|||
#define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__)
|
||||
#define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x))
|
||||
|
||||
extern int rayo_call_is_joined(struct rayo_call *call);
|
||||
extern int rayo_call_is_faxing(struct rayo_call *call);
|
||||
extern void rayo_call_set_faxing(struct rayo_call *call, int faxing);
|
||||
extern const char *rayo_call_get_dcp_jid(struct rayo_call *call);
|
||||
SWITCH_DECLARE(int) rayo_call_is_joined(struct rayo_call *call);
|
||||
SWITCH_DECLARE(int) rayo_call_is_faxing(struct rayo_call *call);
|
||||
SWITCH_DECLARE(void) rayo_call_set_faxing(struct rayo_call *call, int faxing);
|
||||
SWITCH_DECLARE(const char *) rayo_call_get_dcp_jid(struct rayo_call *call);
|
||||
|
||||
#define rayo_mixer_get_name(mixer) RAYO_ID(mixer)
|
||||
|
||||
#define rayo_component_init(component, pool, type, subtype, id, parent, client_jid) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, NULL, __FILE__, __LINE__)
|
||||
#define rayo_component_init_cleanup(component, pool, type, subtype, id, parent, client_jid, cleanup) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, cleanup, __FILE__, __LINE__)
|
||||
extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, rayo_actor_cleanup_fn cleanup, const char *file, int line);
|
||||
extern switch_bool_t is_component_actor(struct rayo_actor *);
|
||||
SWITCH_DECLARE(struct rayo_component *) _rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, rayo_actor_cleanup_fn cleanup, const char *file, int line);
|
||||
SWITCH_DECLARE(switch_bool_t) is_component_actor(struct rayo_actor *);
|
||||
|
||||
typedef iks *(*rayo_actor_xmpp_handler)(struct rayo_actor *, struct rayo_message *, void *);
|
||||
extern void rayo_actor_command_handler_add(const char *type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn);
|
||||
extern void rayo_actor_event_handler_add(const char *from_type, const char *from_subtype, const char *to_type, const char *to_subtype, const char *name, rayo_actor_xmpp_handler fn);
|
||||
SWITCH_DECLARE(void) rayo_actor_command_handler_add(const char *type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn);
|
||||
SWITCH_DECLARE(void) rayo_actor_event_handler_add(const char *from_type, const char *from_subtype, const char *to_type, const char *to_subtype, const char *name, rayo_actor_xmpp_handler fn);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013-2014, Grasshopper
|
||||
* Copyright (C) 2013-2018, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -39,12 +39,12 @@ enum nlsml_match_type {
|
|||
NMT_NOMATCH
|
||||
};
|
||||
|
||||
extern int nlsml_init(void);
|
||||
extern void nlsml_destroy(void);
|
||||
enum nlsml_match_type nlsml_parse(const char *result, const char *uuid);
|
||||
iks *nlsml_normalize(const char *result);
|
||||
extern iks *nlsml_create_dtmf_match(const char *digits, const char *interpretation);
|
||||
extern iks *nlsml_create_match(const char *digits, const char *interpretation, const char *mode, int confidence);
|
||||
SWITCH_DECLARE(int) nlsml_init(void);
|
||||
SWITCH_DECLARE(void) nlsml_destroy(void);
|
||||
SWITCH_DECLARE(enum nlsml_match_type) nlsml_parse(const char *result, const char *uuid);
|
||||
SWITCH_DECLARE(iks *) nlsml_normalize(const char *result);
|
||||
SWITCH_DECLARE(iks *) nlsml_create_dtmf_match(const char *digits, const char *interpretation);
|
||||
SWITCH_DECLARE(iks *) nlsml_create_match(const char *digits, const char *interpretation, const char *mode, int confidence);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -60,37 +60,37 @@
|
|||
#define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS
|
||||
#define COMPONENT_COMPLETE_DONE "done", RAYO_EXT_COMPLETE_NS
|
||||
|
||||
extern switch_status_t rayo_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern switch_status_t rayo_input_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern switch_status_t rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern switch_status_t rayo_exec_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_input_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_exec_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
|
||||
extern switch_status_t rayo_components_shutdown(void);
|
||||
extern switch_status_t rayo_input_component_shutdown(void);
|
||||
extern switch_status_t rayo_output_component_shutdown(void);
|
||||
extern switch_status_t rayo_prompt_component_shutdown(void);
|
||||
extern switch_status_t rayo_record_component_shutdown(void);
|
||||
extern switch_status_t rayo_fax_components_shutdown(void);
|
||||
extern switch_status_t rayo_exec_component_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_components_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_input_component_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_output_component_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_prompt_component_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_record_component_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_fax_components_shutdown(void);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_exec_component_shutdown(void);
|
||||
|
||||
extern void rayo_component_send_start(struct rayo_component *component, iks *iq);
|
||||
extern void rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type);
|
||||
extern void rayo_component_send_iq_error_detailed(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type, const char *detail);
|
||||
extern void rayo_component_send_complete(struct rayo_component *component, const char *reason, const char *reason_namespace);
|
||||
extern void rayo_component_send_complete_event(struct rayo_component *component, iks *response);
|
||||
extern void rayo_component_send_complete_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
|
||||
extern void rayo_component_send_complete_with_metadata_string(struct rayo_component *component, const char *reason, const char *reason_namespace, const char *meta, int child_of_complete);
|
||||
SWITCH_DECLARE(void) rayo_component_send_start(struct rayo_component *component, iks *iq);
|
||||
SWITCH_DECLARE(void) rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type);
|
||||
SWITCH_DECLARE(void) rayo_component_send_iq_error_detailed(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type, const char *detail);
|
||||
SWITCH_DECLARE(void) rayo_component_send_complete(struct rayo_component *component, const char *reason, const char *reason_namespace);
|
||||
SWITCH_DECLARE(void) rayo_component_send_complete_event(struct rayo_component *component, iks *response);
|
||||
SWITCH_DECLARE(void) rayo_component_send_complete_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
|
||||
SWITCH_DECLARE(void) rayo_component_send_complete_with_metadata_string(struct rayo_component *component, const char *reason, const char *reason_namespace, const char *meta, int child_of_complete);
|
||||
|
||||
extern iks *rayo_component_create_complete_event(struct rayo_component *component, const char *reason, const char *reason_namespace);
|
||||
extern iks *rayo_component_create_complete_event_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
|
||||
SWITCH_DECLARE(iks *) rayo_component_create_complete_event(struct rayo_component *component, const char *reason, const char *reason_namespace);
|
||||
SWITCH_DECLARE(iks *) rayo_component_create_complete_event_with_metadata(struct rayo_component *component, const char *reason, const char *reason_namespace, iks *meta, int child_of_complete);
|
||||
|
||||
extern void rayo_component_api_execute_async(struct rayo_component *component, const char *cmd, const char *args);
|
||||
SWITCH_DECLARE(void) rayo_component_api_execute_async(struct rayo_component *component, const char *cmd, const char *args);
|
||||
|
||||
#define RAYO_COMPONENT_LOCATE(id) rayo_component_locate(id, __FILE__, __LINE__)
|
||||
extern struct rayo_component *rayo_component_locate(const char *id, const char *file, int line);
|
||||
SWITCH_DECLARE(struct rayo_component *) rayo_component_locate(const char *id, const char *file, int line);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
|
||||
#include "mod_rayo.h"
|
||||
|
||||
extern switch_status_t rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern void rayo_cpa_component_shutdown(void);
|
||||
extern iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_cpa_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(void) rayo_cpa_component_shutdown(void);
|
||||
SWITCH_DECLARE(iks *) rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
|
||||
#include "mod_rayo.h"
|
||||
|
||||
extern switch_status_t rayo_cpa_detector_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
extern void rayo_cpa_detector_shutdown(void);
|
||||
extern int rayo_cpa_detector_start(const char *call_uuid, const char *signal_ns, const char **error_detail);
|
||||
extern void rayo_cpa_detector_stop(const char *call_uuid, const char *signal_ns);
|
||||
SWITCH_DECLARE(switch_status_t) rayo_cpa_detector_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file);
|
||||
SWITCH_DECLARE(void) rayo_cpa_detector_shutdown(void);
|
||||
SWITCH_DECLARE(int) rayo_cpa_detector_start(const char *call_uuid, const char *signal_ns, const char **error_detail);
|
||||
SWITCH_DECLARE(void) rayo_cpa_detector_stop(const char *call_uuid, const char *signal_ns);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013, Grasshopper
|
||||
* Copyright (C) 2013-2018, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
|||
#ifndef SASL_H
|
||||
#define SASL_H
|
||||
|
||||
extern void parse_plain_auth_message(const char *message, char **authzid, char **authcid, char **password);
|
||||
SWITCH_DECLARE(void) parse_plain_auth_message(const char *message, char **authzid, char **authcid, char **password);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013-2014, Grasshopper
|
||||
* Copyright (C) 2013-2018, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -45,15 +45,15 @@ enum srgs_match_type {
|
|||
SMT_MATCH_END
|
||||
};
|
||||
|
||||
extern int srgs_init(void);
|
||||
extern void srgs_destroy(void);
|
||||
extern struct srgs_parser *srgs_parser_new(const char *uuid);
|
||||
extern struct srgs_grammar *srgs_parse(struct srgs_parser *parser, const char *document);
|
||||
extern const char *srgs_grammar_to_regex(struct srgs_grammar *grammar);
|
||||
extern const char *srgs_grammar_to_jsgf(struct srgs_grammar *grammar);
|
||||
extern const char *srgs_grammar_to_jsgf_file(struct srgs_grammar *grammar, const char *basedir, const char *ext);
|
||||
extern enum srgs_match_type srgs_grammar_match(struct srgs_grammar *grammar, const char *input, const char **interpretation);
|
||||
extern void srgs_parser_destroy(struct srgs_parser *parser);
|
||||
SWITCH_DECLARE(int) srgs_init(void);
|
||||
SWITCH_DECLARE(void) srgs_destroy(void);
|
||||
SWITCH_DECLARE(struct srgs_parser *) srgs_parser_new(const char *uuid);
|
||||
SWITCH_DECLARE(struct srgs_grammar *) srgs_parse(struct srgs_parser *parser, const char *document);
|
||||
SWITCH_DECLARE(const char *) srgs_grammar_to_regex(struct srgs_grammar *grammar);
|
||||
SWITCH_DECLARE(const char *) srgs_grammar_to_jsgf(struct srgs_grammar *grammar);
|
||||
SWITCH_DECLARE(const char *) srgs_grammar_to_jsgf_file(struct srgs_grammar *grammar, const char *basedir, const char *ext);
|
||||
SWITCH_DECLARE(enum srgs_match_type) srgs_grammar_match(struct srgs_grammar *grammar, const char *input, const char **interpretation);
|
||||
SWITCH_DECLARE(void) srgs_parser_destroy(struct srgs_parser *parser);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is Grasshopper
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Rienzo <chris.rienzo@grasshopper.com>
|
||||
*
|
||||
* test.h -- simple unit testing macros
|
||||
*
|
||||
*/
|
||||
#ifndef TEST_H
|
||||
#define TEST_H
|
||||
|
||||
#define assert_equals(test, expected_str, expected, actual, file, line) \
|
||||
{ \
|
||||
int actual_val = actual; \
|
||||
if (expected != actual_val) { \
|
||||
printf("TEST\t%s\tFAIL\t%s\t%i\t!=\t%i\t%s:%i\n", test, expected_str, expected, actual_val, file, line); \
|
||||
exit(1); \
|
||||
} else { \
|
||||
printf("TEST\t%s\tPASS\n", test); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define assert_string_equals(test, expected, actual, file, line) \
|
||||
{ \
|
||||
const char *actual_str = actual; \
|
||||
if (!actual_str || strcmp(expected, actual_str)) { \
|
||||
printf("TEST\t%s\tFAIL\t\t%s\t!=\t%s\t%s:%i\n", test, expected, actual_str, file, line); \
|
||||
exit(1); \
|
||||
} else { \
|
||||
printf("TEST\t%s\tPASS\n", test); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define assert_not_null(test, actual, file, line) \
|
||||
{ \
|
||||
const void *actual_val = actual; \
|
||||
if (!actual_val) { \
|
||||
printf("TEST\t%s\tFAIL\t\t\t\t\t%s:%i\n", test, file, line); \
|
||||
exit(1); \
|
||||
} else { \
|
||||
printf("TEST\t%s\tPASS\n", test); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define assert_null(test, actual, file, line) \
|
||||
{ \
|
||||
const void *actual_val = actual; \
|
||||
if (actual_val) { \
|
||||
printf("TEST\t%s\tFAIL\t\t\t\t\t%s:%i\n", test, file, line); \
|
||||
exit(1); \
|
||||
} else { \
|
||||
printf("TEST\t%s\tPASS\n", test); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ASSERT_EQUALS(expected, actual) assert_equals(#actual, #expected, expected, actual, __FILE__, __LINE__)
|
||||
#define ASSERT_STRING_EQUALS(expected, actual) assert_string_equals(#actual, expected, actual, __FILE__, __LINE__)
|
||||
#define ASSERT_NOT_NULL(actual) assert_not_null(#actual " not null", actual, __FILE__, __LINE__)
|
||||
#define ASSERT_NULL(actual) assert_null(#actual " is null", actual, __FILE__, __LINE__)
|
||||
|
||||
#define SKIP_ASSERT_EQUALS(expected, actual) if (0) { ASSERT_EQUALS(expected, actual); }
|
||||
|
||||
#define TEST(name) printf("TEST BEGIN\t" #name "\n"); name(); printf("TEST END\t"#name "\tPASS\n");
|
||||
|
||||
#define SKIP_TEST(name) if (0) { TEST(name) };
|
||||
|
||||
#define TEST_INIT switch_core_init(0, SWITCH_TRUE, &err);
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet
|
||||
*/
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
include $(top_srcdir)/build/modmake.rulesam
|
||||
bin_PROGRAMS = test_iks test_nlsml test_srgs
|
||||
|
||||
test_iks_CFLAGS = $(AM_CFLAGS) -I../ -I$(switch_builddir)/libs/iksemel/include $(PCRE_CFLAGS)
|
||||
test_iks_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_rayo.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
|
||||
|
||||
test_nlsml_CFLAGS = $(AM_CFLAGS) -I../ -I$(switch_builddir)/libs/iksemel/include $(PCRE_CFLAGS)
|
||||
test_nlsml_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_rayo.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
|
||||
|
||||
test_srgs_CFLAGS = $(AM_CFLAGS) -I../ -I$(switch_builddir)/libs/iksemel/include $(PCRE_CFLAGS)
|
||||
test_srgs_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_rayo.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
|
||||
|
||||
TESTS = $(bin_PROGRAMS)
|
|
@ -0,0 +1,204 @@
|
|||
|
||||
|
||||
#include <switch.h>
|
||||
#include <iksemel.h>
|
||||
#include <test/switch_test.h>
|
||||
#include <iks_helpers.h>
|
||||
|
||||
static const char *voxeo_grammar =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]]]></grammar></input></iq>";
|
||||
|
||||
|
||||
static const char *repeating_bracket =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]>]]]]]]]]] ]] ]]></grammar></input></iq>";
|
||||
|
||||
|
||||
static const char *normal_cdata =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[1 DIGITS]]></grammar></input></iq>";
|
||||
|
||||
|
||||
static const char *empty_cdata =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[]]></grammar></input></iq>";
|
||||
|
||||
static const char *rayo_test_srgs =
|
||||
"<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" root=\"MAINRULE\">\n"
|
||||
" <rule id=\"MAINRULE\">\n"
|
||||
" <one-of>\n"
|
||||
" <item>\n"
|
||||
" <item repeat=\"0-1\"> need a</item>\n"
|
||||
" <item repeat=\"0-1\"> i need a</item>\n"
|
||||
" <one-of>\n"
|
||||
" <item> clue </item>\n"
|
||||
" </one-of>\n"
|
||||
" <tag> out.concept = \"clue\";</tag>\n"
|
||||
" </item>\n"
|
||||
" <item>\n"
|
||||
" <item repeat=\"0-1\"> have an</item>\n"
|
||||
" <item repeat=\"0-1\"> i have an</item>\n"
|
||||
" <one-of>\n"
|
||||
" <item> answer </item>\n"
|
||||
" </one-of>\n"
|
||||
" <tag> out.concept = \"answer\";</tag>\n"
|
||||
" </item>\n"
|
||||
" </one-of>\n"
|
||||
" </rule>\n"
|
||||
"</grammar>";
|
||||
|
||||
|
||||
#define MATCH 1
|
||||
#define NO_MATCH 0
|
||||
|
||||
|
||||
/**
|
||||
* main program
|
||||
*/
|
||||
FST_BEGIN()
|
||||
|
||||
FST_SUITE_BEGIN(iks)
|
||||
|
||||
FST_SETUP_BEGIN()
|
||||
{
|
||||
}
|
||||
FST_SETUP_END()
|
||||
|
||||
FST_TEARDOWN_BEGIN()
|
||||
{
|
||||
}
|
||||
FST_TEARDOWN_END()
|
||||
|
||||
|
||||
FST_TEST_BEGIN(iks_cdata_bug)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
fst_check(IKS_OK == iks_parse(p, voxeo_grammar, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
fst_check((input = iks_find(iq, "input")));
|
||||
fst_check((cdata = iks_find_cdata(input, "grammar")));
|
||||
fst_check_string_equals("[1 DIGITS]", cdata);
|
||||
iks_delete(iq);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(repeating_bracket)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
fst_check(IKS_OK == iks_parse(p, repeating_bracket, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
fst_check((input = iks_find(iq, "input")));
|
||||
fst_check((cdata = iks_find_cdata(input, "grammar")));
|
||||
fst_check_string_equals("[1 DIGITS]>]]]]]]]]] ]] ", cdata);
|
||||
iks_delete(iq);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(normal_cdata)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
fst_check(IKS_OK == iks_parse(p, normal_cdata, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
fst_check((input = iks_find(iq, "input")));
|
||||
fst_check((cdata = iks_find_cdata(input, "grammar")));
|
||||
fst_check_string_equals("1 DIGITS", cdata);
|
||||
iks_delete(iq);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(empty_cdata)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
fst_check(IKS_OK == iks_parse(p, empty_cdata, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
fst_check((input = iks_find(iq, "input")));
|
||||
fst_check(NULL == (cdata = iks_find_cdata(input, "grammar")));
|
||||
iks_delete(iq);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
|
||||
FST_TEST_BEGIN(rayo_test_srgs)
|
||||
{
|
||||
iks *grammar = NULL;
|
||||
iksparser *p = iks_dom_new(&grammar);
|
||||
fst_check(IKS_OK == iks_parse(p, rayo_test_srgs, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
iks_delete(grammar);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(iks_helper_value_matches)
|
||||
{
|
||||
fst_check(MATCH == value_matches("1", "1,2,3"));
|
||||
fst_check(MATCH == value_matches("2", "1,2,3"));
|
||||
fst_check(MATCH == value_matches("3", "1,2,3"));
|
||||
fst_check(NO_MATCH == value_matches("4", "1,2,3"));
|
||||
fst_check(NO_MATCH == value_matches("1,2", "1,2,3"));
|
||||
fst_check(NO_MATCH == value_matches(NULL, "1,2,3"));
|
||||
fst_check(NO_MATCH == value_matches(NULL, NULL));
|
||||
fst_check(NO_MATCH == value_matches("1", NULL));
|
||||
fst_check(NO_MATCH == value_matches("", "1,2,3"));
|
||||
fst_check(NO_MATCH == value_matches("", ""));
|
||||
fst_check(NO_MATCH == value_matches("1", ""));
|
||||
fst_check(MATCH == value_matches("duplex", "duplex,send,recv"));
|
||||
fst_check(MATCH == value_matches("send", "duplex,send,recv"));
|
||||
fst_check(MATCH == value_matches("recv", "duplex,send,recv"));
|
||||
fst_check(NO_MATCH == value_matches("sendrecv", "duplex,send,recv"));
|
||||
fst_check(MATCH == value_matches("duplex1", "duplex1,duplex2,duplex3"));
|
||||
fst_check(MATCH == value_matches("duplex2", "duplex1,duplex2,duplex3"));
|
||||
fst_check(MATCH == value_matches("duplex3", "duplex1,duplex2,duplex3"));
|
||||
fst_check(NO_MATCH == value_matches("duplex4", "duplex1,duplex2,duplex3"));
|
||||
fst_check(NO_MATCH == value_matches("duplex", "duplex1,duplex2,duplex3"));
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(dialback_key)
|
||||
{
|
||||
fst_check_string_equals("37c69b1cf07a3f67c04a5ef5902fa5114f2c76fe4a2686482ba5b89323075643", iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("", "xmpp.example.com", "example.org", "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "", "example.org", "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "", "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", ""));
|
||||
fst_check(NULL == iks_server_dialback_key(NULL, "xmpp.example.com", "example.org", "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", NULL, "example.org", "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", NULL, "D60000229F"));
|
||||
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL));
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(validate_dtmf)
|
||||
{
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("1"));
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("A"));
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("a"));
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("D"));
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("d"));
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("*"));
|
||||
fst_check(SWITCH_TRUE == iks_attrib_is_dtmf_digit("#"));
|
||||
fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit("E"));
|
||||
fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit(NULL));
|
||||
fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit(""));
|
||||
fst_check(SWITCH_FALSE == iks_attrib_is_dtmf_digit("11"));
|
||||
fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "A"));
|
||||
fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "1"));
|
||||
fst_check(SWITCH_FALSE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "Z"));
|
||||
fst_check(SWITCH_FALSE == validate_optional_attrib(iks_attrib_is_dtmf_digit, "11"));
|
||||
fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, NULL));
|
||||
fst_check(SWITCH_TRUE == validate_optional_attrib(iks_attrib_is_dtmf_digit, ""));
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
|
||||
FST_SUITE_END()
|
||||
|
||||
FST_END()
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
|
||||
#include <switch.h>
|
||||
#include "test.h"
|
||||
#include "nlsml.h"
|
||||
#include <test/switch_test.h>
|
||||
#include <nlsml.h>
|
||||
|
||||
static const char *nlsml_good =
|
||||
"<result x-model=\"http://theYesNoModel\""
|
||||
|
@ -224,22 +224,6 @@ static const char *nlsml_no_match =
|
|||
" </interpretation>\n"
|
||||
"</result>\n";
|
||||
|
||||
/**
|
||||
* Test parsing NLSML example results
|
||||
*/
|
||||
static void test_parse_nlsml_examples(void)
|
||||
{
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_good, "1234"));
|
||||
ASSERT_EQUALS(NMT_BAD_XML, nlsml_parse(nlsml_bad, "1234"));
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_match_with_model_instance, "1234"));
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_multi_input, "1234"));
|
||||
ASSERT_EQUALS(NMT_NOINPUT, nlsml_parse(nlsml_no_input, "1234"));
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_multi_input_dtmf, "1234"));
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_meta, "1234"));
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_simple_ambiguity, "1234"));
|
||||
ASSERT_EQUALS(NMT_MATCH, nlsml_parse(nlsml_mixed_initiative, "1234"));
|
||||
ASSERT_EQUALS(NMT_NOMATCH, nlsml_parse(nlsml_no_match, "1234"));
|
||||
}
|
||||
|
||||
static const char *nlsml_dtmf_result =
|
||||
"<result xmlns='http://www.ietf.org/xml/ns/mrcpv2' "
|
||||
|
@ -248,38 +232,6 @@ static const char *nlsml_dtmf_result =
|
|||
"<instance>1 2 3 4</instance>"
|
||||
"</interpretation></result>";
|
||||
|
||||
/**
|
||||
* Test creating DTMF match result
|
||||
*/
|
||||
static void test_create_dtmf_match(void)
|
||||
{
|
||||
iks *result = nlsml_create_dtmf_match("1234", NULL);
|
||||
char *result_str;
|
||||
ASSERT_NOT_NULL(result);
|
||||
result_str = iks_string(NULL, result);
|
||||
ASSERT_STRING_EQUALS(nlsml_dtmf_result, result_str);
|
||||
iks_free(result_str);
|
||||
}
|
||||
|
||||
static const char *nlsml_dtmf_instance_result =
|
||||
"<result xmlns='http://www.ietf.org/xml/ns/mrcpv2' "
|
||||
"xmlns:xf='http://www.w3.org/2000/xforms'><interpretation>"
|
||||
"<input mode='dtmf' confidence='100'>1</input>"
|
||||
"<instance>foo</instance>"
|
||||
"</interpretation></result>";
|
||||
|
||||
/**
|
||||
* Test creating DTMF match result with instance interpretation
|
||||
*/
|
||||
static void test_create_dtmf_instance(void)
|
||||
{
|
||||
iks *result = nlsml_create_dtmf_match("1", "foo");
|
||||
char *result_str;
|
||||
ASSERT_NOT_NULL(result);
|
||||
result_str = iks_string(NULL, result);
|
||||
ASSERT_STRING_EQUALS(nlsml_dtmf_instance_result, result_str);
|
||||
iks_free(result_str);
|
||||
}
|
||||
|
||||
static const char *nlsml_good_normalized =
|
||||
"<result x-model='http://theYesNoModel'"
|
||||
|
@ -296,28 +248,89 @@ static const char *nlsml_good_normalized =
|
|||
"</interpretation>"
|
||||
"</result>";
|
||||
|
||||
|
||||
static const char *nlsml_dtmf_instance_result =
|
||||
"<result xmlns='http://www.ietf.org/xml/ns/mrcpv2' "
|
||||
"xmlns:xf='http://www.w3.org/2000/xforms'><interpretation>"
|
||||
"<input mode='dtmf' confidence='100'>1</input>"
|
||||
"<instance>foo</instance>"
|
||||
"</interpretation></result>";
|
||||
|
||||
|
||||
FST_BEGIN()
|
||||
|
||||
FST_SUITE_BEGIN(nlsml)
|
||||
|
||||
FST_SETUP_BEGIN()
|
||||
{
|
||||
fst_requires(nlsml_init());
|
||||
}
|
||||
FST_SETUP_END()
|
||||
|
||||
FST_TEARDOWN_BEGIN()
|
||||
{
|
||||
}
|
||||
FST_TEARDOWN_END()
|
||||
|
||||
/**
|
||||
* Test parsing NLSML example results
|
||||
*/
|
||||
FST_TEST_BEGIN(parse_nlsml_examples)
|
||||
{
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_good, "1234"));
|
||||
fst_check(NMT_BAD_XML == nlsml_parse(nlsml_bad, "1234"));
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_match_with_model_instance, "1234"));
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_multi_input, "1234"));
|
||||
fst_check(NMT_NOINPUT == nlsml_parse(nlsml_no_input, "1234"));
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_multi_input_dtmf, "1234"));
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_meta, "1234"));
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_simple_ambiguity, "1234"));
|
||||
fst_check(NMT_MATCH == nlsml_parse(nlsml_mixed_initiative, "1234"));
|
||||
fst_check(NMT_NOMATCH == nlsml_parse(nlsml_no_match, "1234"));
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
/**
|
||||
* Test creating DTMF match result
|
||||
*/
|
||||
FST_TEST_BEGIN(create_dtmf_match)
|
||||
{
|
||||
iks *result = nlsml_create_dtmf_match("1234", NULL);
|
||||
char *result_str;
|
||||
fst_requires(result);
|
||||
result_str = iks_string(NULL, result);
|
||||
fst_check_string_equals(nlsml_dtmf_result, result_str);
|
||||
iks_free(result_str);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
|
||||
/**
|
||||
* Test creating DTMF match result with instance interpretation
|
||||
*/
|
||||
FST_TEST_BEGIN(create_dtmf_instance)
|
||||
{
|
||||
iks *result = nlsml_create_dtmf_match("1", "foo");
|
||||
char *result_str;
|
||||
fst_requires(result);
|
||||
result_str = iks_string(NULL, result);
|
||||
fst_check_string_equals(nlsml_dtmf_instance_result, result_str);
|
||||
iks_free(result_str);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
/**
|
||||
* Test NLSML normalization
|
||||
*/
|
||||
static void test_normalize(void)
|
||||
FST_TEST_BEGIN(normalize)
|
||||
{
|
||||
iks *result = nlsml_normalize(nlsml_good);
|
||||
ASSERT_NOT_NULL(result);
|
||||
ASSERT_STRING_EQUALS(nlsml_good_normalized, iks_string(NULL, result));
|
||||
fst_requires(result);
|
||||
fst_check_string_equals(nlsml_good_normalized, iks_string(NULL, result));
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
/**
|
||||
* main program
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *err;
|
||||
TEST_INIT
|
||||
nlsml_init();
|
||||
TEST(test_parse_nlsml_examples);
|
||||
TEST(test_create_dtmf_match);
|
||||
TEST(test_create_dtmf_instance);
|
||||
TEST(test_normalize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FST_SUITE_END()
|
||||
|
||||
FST_END()
|
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +0,0 @@
|
|||
BASE=../../../../..
|
||||
|
||||
IKS_DIR=$(BASE)/libs/iksemel
|
||||
IKS_LA=$(IKS_DIR)/src/libiksemel.la
|
||||
LOCAL_CFLAGS += -I../ -I$(BASE)/libs/iksemel/include
|
||||
LOCAL_OBJS= $(PCRE_LA) $(IKS_LA) main.o ../iks_helpers.o
|
||||
LOCAL_SOURCES= main.c
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
$(IKS_LA): $(IKS_DIR) $(IKS_DIR)/.update
|
||||
@cd $(IKS_DIR) && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
local_all:
|
||||
libtool --mode=link gcc main.o ../iks_helpers.o -o test test_iks.la
|
||||
|
||||
local_clean:
|
||||
-rm test
|
|
@ -1,185 +0,0 @@
|
|||
|
||||
|
||||
#include <switch.h>
|
||||
#include <iksemel.h>
|
||||
#include "test.h"
|
||||
#include "iks_helpers.h"
|
||||
|
||||
static const char *voxeo_grammar =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]]]></grammar></input></iq>";
|
||||
|
||||
static void test_iks_cdata_bug(void)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
ASSERT_EQUALS(IKS_OK, iks_parse(p, voxeo_grammar, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
ASSERT_NOT_NULL((input = iks_find(iq, "input")));
|
||||
ASSERT_NOT_NULL((cdata = iks_find_cdata(input, "grammar")));
|
||||
ASSERT_STRING_EQUALS("[1 DIGITS]", cdata);
|
||||
iks_delete(iq);
|
||||
}
|
||||
|
||||
static const char *repeating_bracket =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[[1 DIGITS]>]]]]]]]]] ]] ]]></grammar></input></iq>";
|
||||
|
||||
static void test_repeating_bracket(void)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
ASSERT_EQUALS(IKS_OK, iks_parse(p, repeating_bracket, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
ASSERT_NOT_NULL((input = iks_find(iq, "input")));
|
||||
ASSERT_NOT_NULL((cdata = iks_find_cdata(input, "grammar")));
|
||||
ASSERT_STRING_EQUALS("[1 DIGITS]>]]]]]]]]] ]] ", cdata);
|
||||
iks_delete(iq);
|
||||
}
|
||||
|
||||
static const char *normal_cdata =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[1 DIGITS]]></grammar></input></iq>";
|
||||
|
||||
static void test_normal_cdata(void)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
ASSERT_EQUALS(IKS_OK, iks_parse(p, normal_cdata, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
ASSERT_NOT_NULL((input = iks_find(iq, "input")));
|
||||
ASSERT_NOT_NULL((cdata = iks_find_cdata(input, "grammar")));
|
||||
ASSERT_STRING_EQUALS("1 DIGITS", cdata);
|
||||
iks_delete(iq);
|
||||
}
|
||||
|
||||
static const char *empty_cdata =
|
||||
"<iq id='8847' type='set' from='usera@192.168.1.10/voxeo3' to='e7632f74-8c55-11e2-84b0-e538fa88a1ef@192.168.1.10'><input xmlns='urn:xmpp:rayo:input:1' min-confidence='0.3' mode='DTMF' sensitivity='0.5'><grammar content-type='application/grammar+voxeo'><![CDATA[]]></grammar></input></iq>";
|
||||
|
||||
static void test_empty_cdata(void)
|
||||
{
|
||||
iks *iq = NULL;
|
||||
iks *input = NULL;
|
||||
iksparser *p = iks_dom_new(&iq);
|
||||
const char *cdata;
|
||||
ASSERT_EQUALS(IKS_OK, iks_parse(p, empty_cdata, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
ASSERT_NOT_NULL((input = iks_find(iq, "input")));
|
||||
ASSERT_NULL((cdata = iks_find_cdata(input, "grammar")));
|
||||
iks_delete(iq);
|
||||
}
|
||||
|
||||
static const char *rayo_test_srgs =
|
||||
"<grammar xmlns=\"http://www.w3.org/2001/06/grammar\" root=\"MAINRULE\">\n"
|
||||
" <rule id=\"MAINRULE\">\n"
|
||||
" <one-of>\n"
|
||||
" <item>\n"
|
||||
" <item repeat=\"0-1\"> need a</item>\n"
|
||||
" <item repeat=\"0-1\"> i need a</item>\n"
|
||||
" <one-of>\n"
|
||||
" <item> clue </item>\n"
|
||||
" </one-of>\n"
|
||||
" <tag> out.concept = \"clue\";</tag>\n"
|
||||
" </item>\n"
|
||||
" <item>\n"
|
||||
" <item repeat=\"0-1\"> have an</item>\n"
|
||||
" <item repeat=\"0-1\"> i have an</item>\n"
|
||||
" <one-of>\n"
|
||||
" <item> answer </item>\n"
|
||||
" </one-of>\n"
|
||||
" <tag> out.concept = \"answer\";</tag>\n"
|
||||
" </item>\n"
|
||||
" </one-of>\n"
|
||||
" </rule>\n"
|
||||
"</grammar>";
|
||||
|
||||
static void test_rayo_test_srgs(void)
|
||||
{
|
||||
iks *grammar = NULL;
|
||||
iksparser *p = iks_dom_new(&grammar);
|
||||
ASSERT_EQUALS(IKS_OK, iks_parse(p, rayo_test_srgs, 0, 1));
|
||||
iks_parser_delete(p);
|
||||
iks_delete(grammar);
|
||||
}
|
||||
|
||||
#define MATCH 1
|
||||
#define NO_MATCH 0
|
||||
|
||||
static void test_iks_helper_value_matches(void)
|
||||
{
|
||||
ASSERT_EQUALS(MATCH, value_matches("1", "1,2,3"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("2", "1,2,3"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("3", "1,2,3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("4", "1,2,3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("1,2", "1,2,3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches(NULL, "1,2,3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches(NULL, NULL));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("1", NULL));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("", "1,2,3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("", ""));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("1", ""));
|
||||
ASSERT_EQUALS(MATCH, value_matches("duplex", "duplex,send,recv"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("send", "duplex,send,recv"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("recv", "duplex,send,recv"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("sendrecv", "duplex,send,recv"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("duplex1", "duplex1,duplex2,duplex3"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("duplex2", "duplex1,duplex2,duplex3"));
|
||||
ASSERT_EQUALS(MATCH, value_matches("duplex3", "duplex1,duplex2,duplex3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("duplex4", "duplex1,duplex2,duplex3"));
|
||||
ASSERT_EQUALS(NO_MATCH, value_matches("duplex", "duplex1,duplex2,duplex3"));
|
||||
}
|
||||
|
||||
static void test_dialback_key(void)
|
||||
{
|
||||
ASSERT_STRING_EQUALS("37c69b1cf07a3f67c04a5ef5902fa5114f2c76fe4a2686482ba5b89323075643", iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("", "xmpp.example.com", "example.org", "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "", "example.org", "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "", "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", ""));
|
||||
ASSERT_NULL(iks_server_dialback_key(NULL, "xmpp.example.com", "example.org", "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", NULL, "example.org", "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", NULL, "D60000229F"));
|
||||
ASSERT_NULL(iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL));
|
||||
}
|
||||
|
||||
static void test_validate_dtmf(void)
|
||||
{
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("1"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("A"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("a"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("D"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("d"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("*"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, iks_attrib_is_dtmf_digit("#"));
|
||||
ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("E"));
|
||||
ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit(NULL));
|
||||
ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit(""));
|
||||
ASSERT_EQUALS(SWITCH_FALSE, iks_attrib_is_dtmf_digit("11"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "A"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "1"));
|
||||
ASSERT_EQUALS(SWITCH_FALSE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "Z"));
|
||||
ASSERT_EQUALS(SWITCH_FALSE, validate_optional_attrib(iks_attrib_is_dtmf_digit, "11"));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, NULL));
|
||||
ASSERT_EQUALS(SWITCH_TRUE, validate_optional_attrib(iks_attrib_is_dtmf_digit, ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* main program
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *err;
|
||||
TEST_INIT
|
||||
TEST(test_iks_cdata_bug);
|
||||
TEST(test_repeating_bracket);
|
||||
TEST(test_normal_cdata);
|
||||
TEST(test_empty_cdata);
|
||||
TEST(test_rayo_test_srgs);
|
||||
TEST(test_iks_helper_value_matches);
|
||||
TEST(test_dialback_key);
|
||||
TEST(test_validate_dtmf);
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
int dummy(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
BASE=../../../../..
|
||||
|
||||
IKS_DIR=$(BASE)/libs/iksemel
|
||||
IKS_LA=$(IKS_DIR)/src/libiksemel.la
|
||||
LOCAL_CFLAGS += -I../ -I$(BASE)/libs/iksemel/include
|
||||
LOCAL_OBJS= $(PCRE_LA) $(IKS_LA) main.o ../nlsml.o ../iks_helpers.o
|
||||
LOCAL_SOURCES= main.c
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
$(IKS_LA): $(IKS_DIR) $(IKS_DIR)/.update
|
||||
@cd $(IKS_DIR) && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
local_all:
|
||||
libtool --mode=link gcc main.o ../nlsml.o ../iks_helpers.o test_nlsml.la ../../../../../.libs/libfreeswitch.la ../../../../../libs/iksemel/src/.libs/libiksemel.a -lpcre -lssl -lcrypto -g -ggdb -O2 -pthread -o test
|
||||
|
||||
local_clean:
|
||||
-rm test
|
|
@ -1,6 +0,0 @@
|
|||
int dummy(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
BASE=../../../../..
|
||||
|
||||
IKS_DIR=$(BASE)/libs/iksemel
|
||||
IKS_LA=$(IKS_DIR)/src/libiksemel.la
|
||||
LOCAL_CFLAGS += -I../ -I$(BASE)/libs/iksemel/include
|
||||
LOCAL_OBJS= $(PCRE_LA) $(IKS_LA) main.o ../srgs.o
|
||||
LOCAL_SOURCES= main.c
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
$(IKS_LA): $(IKS_DIR) $(IKS_DIR)/.update
|
||||
@cd $(IKS_DIR) && $(MAKE)
|
||||
@$(TOUCH_TARGET)
|
||||
|
||||
local_all:
|
||||
libtool --mode=link gcc main.o ../srgs.o -o test test_srgs.la
|
||||
|
||||
local_clean:
|
||||
-rm test
|
|
@ -1,6 +0,0 @@
|
|||
int dummy(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2013-2015, Grasshopper
|
||||
* Copyright (C) 2013-2018, Grasshopper
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -37,22 +37,22 @@ typedef int (* xmpp_stream_ready_callback)(struct xmpp_stream *stream);
|
|||
typedef void (* xmpp_stream_recv_callback)(struct xmpp_stream *stream, iks *stanza);
|
||||
typedef void (* xmpp_stream_destroy_callback)(struct xmpp_stream *stream);
|
||||
|
||||
extern struct xmpp_stream_context *xmpp_stream_context_create(const char *domain, const char *domain_secret, xmpp_stream_bind_callback bind_cb, xmpp_stream_ready_callback ready, xmpp_stream_recv_callback recv, xmpp_stream_destroy_callback destroy);
|
||||
extern void xmpp_stream_context_add_cert(struct xmpp_stream_context *context, const char *cert_pem_file);
|
||||
extern void xmpp_stream_context_add_key(struct xmpp_stream_context *context, const char *key_pem_file);
|
||||
extern void xmpp_stream_context_add_user(struct xmpp_stream_context *context, const char *user, const char *password);
|
||||
extern void xmpp_stream_context_dump(struct xmpp_stream_context *context, switch_stream_handle_t *stream);
|
||||
extern void xmpp_stream_context_destroy(struct xmpp_stream_context *context);
|
||||
extern void xmpp_stream_context_send(struct xmpp_stream_context *context, const char *jid, iks *stanza);
|
||||
SWITCH_DECLARE(struct xmpp_stream_context *) xmpp_stream_context_create(const char *domain, const char *domain_secret, xmpp_stream_bind_callback bind_cb, xmpp_stream_ready_callback ready, xmpp_stream_recv_callback recv, xmpp_stream_destroy_callback destroy);
|
||||
SWITCH_DECLARE(void) xmpp_stream_context_add_cert(struct xmpp_stream_context *context, const char *cert_pem_file);
|
||||
SWITCH_DECLARE(void) xmpp_stream_context_add_key(struct xmpp_stream_context *context, const char *key_pem_file);
|
||||
SWITCH_DECLARE(void) xmpp_stream_context_add_user(struct xmpp_stream_context *context, const char *user, const char *password);
|
||||
SWITCH_DECLARE(void) xmpp_stream_context_dump(struct xmpp_stream_context *context, switch_stream_handle_t *stream);
|
||||
SWITCH_DECLARE(void) xmpp_stream_context_destroy(struct xmpp_stream_context *context);
|
||||
SWITCH_DECLARE(void) xmpp_stream_context_send(struct xmpp_stream_context *context, const char *jid, iks *stanza);
|
||||
|
||||
extern switch_status_t xmpp_stream_context_listen(struct xmpp_stream_context *context, const char *addr, int port, int is_s2s, const char *acl);
|
||||
extern switch_status_t xmpp_stream_context_connect(struct xmpp_stream_context *context, const char *peer_domain, const char *peer_address, int peer_port);
|
||||
SWITCH_DECLARE(switch_status_t) xmpp_stream_context_listen(struct xmpp_stream_context *context, const char *addr, int port, int is_s2s, const char *acl);
|
||||
SWITCH_DECLARE(switch_status_t) xmpp_stream_context_connect(struct xmpp_stream_context *context, const char *peer_domain, const char *peer_address, int peer_port);
|
||||
|
||||
extern int xmpp_stream_is_s2s(struct xmpp_stream *stream);
|
||||
extern int xmpp_stream_is_incoming(struct xmpp_stream *stream);
|
||||
extern const char *xmpp_stream_get_jid(struct xmpp_stream *stream);
|
||||
extern void xmpp_stream_set_private(struct xmpp_stream *stream, void *user_private);
|
||||
extern void *xmpp_stream_get_private(struct xmpp_stream *stream);
|
||||
SWITCH_DECLARE(int) xmpp_stream_is_s2s(struct xmpp_stream *stream);
|
||||
SWITCH_DECLARE(int) xmpp_stream_is_incoming(struct xmpp_stream *stream);
|
||||
SWITCH_DECLARE(const char *) xmpp_stream_get_jid(struct xmpp_stream *stream);
|
||||
SWITCH_DECLARE(void) xmpp_stream_set_private(struct xmpp_stream *stream, void *user_private);
|
||||
SWITCH_DECLARE(void *) xmpp_stream_get_private(struct xmpp_stream *stream);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue