[Unit-tests] Fix previously defined AM_* in tests.

This commit is contained in:
s3rj1k 2021-02-23 19:59:26 +02:00 committed by GitHub
parent 3556119fde
commit 91f12b5920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 30 additions and 54 deletions

View File

@ -811,11 +811,12 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
*/
#define fst_sched_recv_dtmf(when, digits) \
{ \
switch_status_t api_result; \
switch_stream_handle_t stream = { 0 }; \
SWITCH_STANDARD_STREAM(stream); \
fst_requires(fst_core > 1); \
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); \
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); \
fst_requires(api_result == SWITCH_STATUS_SUCCESS); \
switch_safe_free(stream.data); \

View File

@ -2,11 +2,10 @@ include $(top_srcdir)/build/modmake.rulesam
noinst_PROGRAMS = switch_event switch_hash switch_ivr_originate switch_utils switch_core switch_console switch_vpx switch_core_file \
switch_ivr_play_say switch_core_codec switch_rtp switch_xml
noinst_PROGRAMS+= switch_core_video switch_core_db switch_vad switch_core_asr
AM_LDFLAGS = -avoid-version -no-undefined $(SWITCH_AM_LDFLAGS) $(openssl_LIBS)
noinst_PROGRAMS += switch_core_video switch_core_db switch_vad switch_core_asr
AM_LDFLAGS += -avoid-version -no-undefined $(SWITCH_AM_LDFLAGS) $(openssl_LIBS)
AM_LDFLAGS += $(FREESWITCH_LIBS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
AM_CFLAGS = $(SWITCH_AM_CPPFLAGS)
AM_CPPFLAGS = $(SWITCH_AM_CPPFLAGS)
if HAVE_FVAD
AM_CFLAGS += -DSWITCH_HAVE_FVAD

View File

@ -29,7 +29,6 @@
*
*/
#include <stdio.h>
#include <switch.h>
#include <test/switch_test.h>
@ -49,11 +48,10 @@ FST_TEARDOWN_END()
FST_TEST_BEGIN(benchmark)
{
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
char expected_result[] = {'A', 0x00, 0x01, 0x02, 'B'};
char raw_data[] = {0x00, 0x01, 0x02};
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
stream.write_function(&stream, "%s", "A");
stream.raw_write_function(&stream, (uint8_t *) raw_data, sizeof(raw_data));

View File

@ -70,10 +70,10 @@ FST_CORE_DB_BEGIN("./conf")
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) == SWITCH_STATUS_SUCCESS) {
switch_cache_db_execute_sql2str(dbh, "SELECT 1", (char *)&res1, 20, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SELECT 1: %s\n", switch_str_nil(res1));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SELECT 1: %s\n", res1);
switch_cache_db_execute_sql2str(dbh, "SELECT NULL", (char *)&res2, 20, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SELECT NULL: %s\n", switch_str_nil(res2));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SELECT NULL: %s\n", res2);
}

View File

@ -50,13 +50,13 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(data_url_test)
{
char *data_url = NULL;
switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, 120, 60, 1);
switch_image_t *argb_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, 120, 60, 1);
switch_rgb_color_t color = { 0 };
color.r = 255;
// color.g = 255;
// color.b = 255;
char *data_url = NULL;
switch_img_fill(img, 0, 0, img->d_w, img->d_h, &color);
switch_img_add_text(img->planes[0], img->d_w, 10, 10, "-1234567890");

View File

@ -1,4 +1,3 @@
#include <stdio.h>
#include <switch.h>
#include <test/switch_test.h>
@ -21,10 +20,8 @@ FST_TEARDOWN_END()
FST_TEST_BEGIN(benchmark)
{
switch_event_t *event = NULL;
switch_bool_t verbose = SWITCH_TRUE;
const char *err = NULL;
switch_time_t start_ts, end_ts;
int rc = 0, loops = 10, x = 0;
int loops = 10, x = 0;
switch_status_t status = SWITCH_STATUS_SUCCESS;
char **index = NULL;
uint64_t micro_total = 0;

View File

@ -1,4 +1,3 @@
#include <stdio.h>
#include <switch.h>
#include <test/switch_test.h>
@ -20,9 +19,6 @@ FST_TEARDOWN_END()
FST_TEST_BEGIN(benchmark)
{
switch_event_t *event = NULL;
switch_bool_t verbose = SWITCH_TRUE;
const char *err = NULL;
switch_time_t start_ts, end_ts;
uint64_t micro_total = 0;
double micro_per = 0;
@ -33,7 +29,7 @@ FST_TEST_BEGIN(benchmark)
switch_time_t small_start_ts, small_end_ts;
#endif
int rc = 0, loops = 10;
int loops = 10;
switch_status_t status = SWITCH_STATUS_SUCCESS;
char **index = NULL;
switch_hash_t *hash = NULL;

View File

@ -212,7 +212,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_empty_dial_string)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -235,7 +234,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_one_leg)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -261,7 +259,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_no_pre_answer)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -291,7 +288,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_exec_in_pre_answer)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -322,7 +318,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_exec_after_answer_early_ok)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -354,7 +349,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_exec_after_answer_ignore_early_media)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -385,8 +379,8 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_2_legs)
{
const char *name;
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -407,7 +401,7 @@ FST_CORE_BEGIN("./conf")
status = switch_ivr_originate(NULL, &session, &cause, NULL, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, dh);
fst_requires(status == SWITCH_STATUS_SUCCESS);
fst_requires(session);
const char *name = switch_core_session_get_name(session);
name = switch_core_session_get_name(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "channel %s\n", name);
fst_check_string_equals(name, "null/test2");
switch_core_session_rwunlock(session);
@ -418,8 +412,8 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_global_var)
{
const char *name;
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
const char *dialstring = "{group_confirm_file='playback silence_stream://1000',group_confirm_key=exec}null/test";
@ -427,7 +421,7 @@ FST_CORE_BEGIN("./conf")
status = switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
fst_requires(status == SWITCH_STATUS_SUCCESS);
fst_requires(session);
const char *name = switch_core_session_get_name(session);
name = switch_core_session_get_name(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "channel %s\n", name);
fst_check_string_equals(name, "null/test");
switch_core_session_rwunlock(session);
@ -436,8 +430,8 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_local_var)
{
const char *name;
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
const char *dialstring = "[group_confirm_file='playback silence_stream://1000',group_confirm_key=exec]null/test1,"
@ -446,7 +440,7 @@ FST_CORE_BEGIN("./conf")
status = switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
fst_requires(status == SWITCH_STATUS_SUCCESS);
fst_requires(session);
const char *name = switch_core_session_get_name(session);
name = switch_core_session_get_name(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "channel %s\n", name);
fst_check_string_equals(name, "null/test2");
switch_core_session_rwunlock(session);
@ -456,7 +450,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_loopback_endpoint_originate)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
const char *dialstring = "[group_confirm_key=exec,group_confirm_file='event a=1']loopback/loopback";
@ -475,10 +468,6 @@ FST_CORE_BEGIN("./conf")
FST_SESSION_BEGIN(originate_test_group_confirm_loopback_endpoint_bridge)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
const char *dialstring = "[group_confirm_key=exec,group_confirm_file='event a=1']loopback/loopback";
switch_event_bind("test", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, loopback_group_confirm_event_handler, NULL);
@ -493,7 +482,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_leg_timeout_not_finished)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -521,7 +509,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_leg_timeout_finished)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -552,7 +539,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_timeout_leg)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -581,7 +567,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_timeout_global)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;
@ -610,7 +595,6 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(originate_test_group_confirm_cancel_timeout_global)
{
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
switch_status_t status;
switch_call_cause_t cause;
switch_dial_handle_t *dh;

View File

@ -32,6 +32,7 @@ FST_TEARDOWN_BEGIN()
FST_TEARDOWN_END()
FST_TEST_BEGIN(test_rtp)
{
switch_rtp_stats_t *stats;
switch_core_new_memory_pool(&pool);
rtp_session = switch_rtp_new(rx_host, rx_port, tx_host, tx_port, TEST_PT, 8000, 20 * 1000, flags, "soft", &err, pool, 0, 0);
@ -44,7 +45,7 @@ FST_TEARDOWN_END()
switch_rtp_set_ssrc(rtp_session, 0xabcd);
switch_rtp_set_remote_ssrc(rtp_session, 0xcdef);
fst_xcheck(switch_rtp_get_ssrc(rtp_session) == 0xabcd, "get SSRC");
switch_rtp_stats_t *stats = switch_rtp_get_stats(rtp_session, pool);
stats = switch_rtp_get_stats(rtp_session, pool);
fst_requires(stats);
switch_rtp_destroy(&rtp_session);

View File

@ -29,7 +29,6 @@
*
*/
#include <stdio.h>
#include <switch.h>
#include <test/switch_test.h>
@ -65,6 +64,7 @@ FST_TEST_END()
FST_TEST_BEGIN(b64)
{
switch_size_t size;
char *str = "ABC";
unsigned char b64_str[6];
char decoded_str[4];
@ -73,7 +73,7 @@ FST_TEST_BEGIN(b64)
fst_check(status == SWITCH_STATUS_SUCCESS);
fst_check_string_equals((const char *)b64_str, "QUJD");
switch_size_t size = switch_b64_decode((const char *)b64_str, decoded_str, sizeof(decoded_str));
size = switch_b64_decode((const char *)b64_str, decoded_str, sizeof(decoded_str));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "decoded_str: %s\n", decoded_str);
fst_check_string_equals(decoded_str, str);
fst_check(size == 4);

View File

@ -148,6 +148,7 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(energy)
{
int res;
int16_t *buf = malloc(sizeof(int16_t) * 160);
int duration;
float pos = 0.0;
@ -156,7 +157,7 @@ FST_CORE_BEGIN("./conf")
switch_vad_t *vad = switch_vad_init(8000, 1);
fst_requires(vad);
int res = switch_vad_set_mode(vad, -1);
res = switch_vad_set_mode(vad, -1);
fst_requires(res == 0);
switch_vad_set_param(vad, "silence_ms", 400);
switch_vad_set_param(vad, "voice_ms", 80);

View File

@ -21,9 +21,14 @@ FST_CORE_BEGIN("./conf")
FST_TEST_BEGIN(vp8_test)
{
switch_image_t *img;
uint8_t buf[SWITCH_DEFAULT_VIDEO_SIZE + 12];
switch_status_t status;
switch_codec_t codec = { 0 };
switch_frame_t frame = { 0 };
switch_codec_settings_t codec_settings = {{ 0 }};
int packets = 0;
switch_status_t encode_status;
// switch_set_string(codec_settings.video.config_profile_name, "conference");
codec_settings.video.width = 1280;
@ -39,12 +44,9 @@ FST_CORE_BEGIN("./conf")
&codec_settings, fst_pool);
fst_check(status == SWITCH_STATUS_SUCCESS);
switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, 1280, 720, 1);
img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, 1280, 720, 1);
fst_requires(img);
uint8_t buf[SWITCH_DEFAULT_VIDEO_SIZE + 12];
switch_frame_t frame = { 0 };
frame.packet = buf;
frame.packetlen = SWITCH_DEFAULT_VIDEO_SIZE + 12;
frame.data = buf + 12;
@ -55,9 +57,6 @@ FST_CORE_BEGIN("./conf")
frame.timestamp = 0;
frame.img = img;
int packets = 0;
switch_status_t encode_status;
do {
frame.datalen = SWITCH_DEFAULT_VIDEO_SIZE;
encode_status = switch_core_codec_encode_video(&codec, &frame);