[Unit-tests] Fix build of various unit-tests.

This commit is contained in:
Andrey Volk 2021-10-23 01:24:17 +03:00
parent f31c73a11d
commit 24ff01518f
4 changed files with 21 additions and 17 deletions

View File

@ -48,10 +48,11 @@ FST_CORE_BEGIN("./conf")
FST_SESSION_BEGIN(session_external_id)
{
switch_core_session_t *session;
fst_check(switch_core_session_set_external_id(fst_session, switch_core_session_get_uuid(fst_session)) == SWITCH_STATUS_SUCCESS);
fst_check_string_equals(switch_core_session_get_external_id(fst_session), switch_core_session_get_uuid(fst_session));
fst_check(switch_core_session_set_external_id(fst_session, "foo") == SWITCH_STATUS_SUCCESS);
switch_core_session_t *session = switch_core_session_locate("foo");
session = switch_core_session_locate("foo");
fst_requires(session);
fst_check_string_equals(switch_core_session_get_uuid(session), switch_core_session_get_uuid(fst_session));
fst_check_string_equals(switch_core_session_get_external_id(session), "foo");

View File

@ -43,6 +43,7 @@ static switch_status_t partial_play_and_collect_input_callback(switch_core_sessi
if (event->event_id == SWITCH_EVENT_DETECTED_SPEECH) {
const char *speech_type = switch_event_get_header(event, "Speech-Type");
char *body;
if (zstr(speech_type) || strcmp(speech_type, "detected-partial-speech")) {
return status;
@ -51,7 +52,7 @@ static switch_status_t partial_play_and_collect_input_callback(switch_core_sessi
(*count)++;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "partial events count: %d\n", *count);
char *body = switch_event_get_body(event);
body = switch_event_get_body(event);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "body=[%s]\n", body);
}
} else if (input_type == SWITCH_INPUT_TYPE_DTMF) {
@ -67,6 +68,9 @@ FST_CORE_BEGIN("./conf_async")
{
FST_SETUP_BEGIN()
{
if (0) {
partial_play_and_collect_input_callback(NULL, NULL, 0, NULL, 0);
}
fst_requires_module("mod_tone_stream");
fst_requires_module("mod_sndfile");
fst_requires_module("mod_dptools");
@ -82,7 +86,8 @@ FST_CORE_BEGIN("./conf_async")
FST_SESSION_BEGIN(session_record_pause)
{
const char *record_filename = switch_core_session_sprintf(fst_session, "%s%s%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(fst_session));
const char *duration_ms_str;
int duration_ms;
switch_status_t status;
status = switch_ivr_record_session_event(fst_session, record_filename, 0, NULL, NULL);
fst_xcheck(status == SWITCH_STATUS_SUCCESS, "Expect switch_ivr_record_session() to return SWITCH_STATUS_SUCCESS");
@ -110,9 +115,9 @@ FST_CORE_BEGIN("./conf_async")
unlink(record_filename);
const char *duration_ms_str = switch_channel_get_variable(fst_channel, "record_ms");
duration_ms_str = switch_channel_get_variable(fst_channel, "record_ms");
fst_requires(duration_ms_str != NULL);
int duration_ms = atoi(duration_ms_str);
duration_ms = atoi(duration_ms_str);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fst_session), SWITCH_LOG_NOTICE, "Recording duration is %s ms\n", duration_ms_str);
fst_xcheck(duration_ms > 3500 && duration_ms < 3700, "Expect recording to be between 3500 and 3700 ms");
}

View File

@ -36,10 +36,10 @@
static void on_record_start(switch_event_t *event)
{
char *str = NULL;
const char *uuid = switch_event_get_header(event, "Unique-ID");
switch_event_serialize(event, &str, SWITCH_FALSE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s", str);
switch_safe_free(str);
const char *uuid = switch_event_get_header(event, "Unique-ID");
if (uuid) {
switch_core_session_t *session = switch_core_session_locate(uuid);
if (session) {
@ -56,10 +56,10 @@ static void on_record_start(switch_event_t *event)
static void on_record_stop(switch_event_t *event)
{
char *str = NULL;
const char *uuid = switch_event_get_header(event, "Unique-ID");
switch_event_serialize(event, &str, SWITCH_FALSE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s", str);
switch_safe_free(str);
const char *uuid = switch_event_get_header(event, "Unique-ID");
if (uuid) {
switch_core_session_t *session = switch_core_session_locate(uuid);
if (session) {
@ -83,6 +83,7 @@ static switch_status_t partial_play_and_collect_input_callback(switch_core_sessi
if (event->event_id == SWITCH_EVENT_DETECTED_SPEECH) {
const char *speech_type = switch_event_get_header(event, "Speech-Type");
char *body = switch_event_get_body(event);
if (zstr(speech_type) || strcmp(speech_type, "detected-partial-speech")) {
return status;
@ -90,8 +91,6 @@ static switch_status_t partial_play_and_collect_input_callback(switch_core_sessi
(*count)++;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "partial events count: %d\n", *count);
char *body = switch_event_get_body(event);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "body=[%s]\n", body);
}
} else if (input_type == SWITCH_INPUT_TYPE_DTMF) {
@ -354,6 +353,9 @@ FST_CORE_BEGIN("./conf_playsay")
char *speech_grammar_args = switch_core_session_sprintf(fst_session, "{start-input-timers=false,no-input-timeout=%d,vad-silence-ms=%d,speech-timeout=%d,language=en-US,partial=true}default",
no_input_timeout, speech_complete_timeout, speech_recognition_timeout);
switch_status_t status;
switch_input_args_t collect_input_args = { 0 };
switch_input_args_t *args = NULL;
int count = 0;
switch_ivr_displace_session(fst_session, "file_string://silence_stream://500,0!tone_stream://%%(2000,0,350,440)", 0, "r");
terminator_collected = 0;
@ -377,10 +379,6 @@ FST_CORE_BEGIN("./conf_playsay")
if (recognition_result) cJSON_Delete(recognition_result);
recognition_result = NULL;
switch_input_args_t collect_input_args = { 0 };
switch_input_args_t *args = NULL;
int count = 0;
args = &collect_input_args;
args->input_callback = partial_play_and_collect_input_callback;
args->buf = &count;

View File

@ -90,12 +90,12 @@ static char *wait_for_log(switch_interval_time_t timeout_ms)
FST_CORE_BEGIN("./conf")
{
FST_SUITE_BEGIN(switch_log)
{
switch_core_new_memory_pool(&pool);
switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, pool);
switch_thread_cond_create(&cond, pool);
FST_SUITE_BEGIN(switch_log)
{
FST_SETUP_BEGIN()
{
json_format.custom_field_prefix = NULL;