From 91f12b592020a8bf8f57f8a8518640c558e98fe2 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Tue, 23 Feb 2021 19:59:26 +0200 Subject: [PATCH] [Unit-tests] Fix previously defined AM_* in tests. --- src/include/test/switch_test.h | 3 ++- tests/unit/Makefile.am | 7 +++---- tests/unit/switch_console.c | 6 ++---- tests/unit/switch_core_db.c | 4 ++-- tests/unit/switch_core_video.c | 2 +- tests/unit/switch_event.c | 5 +---- tests/unit/switch_hash.c | 6 +----- tests/unit/switch_ivr_originate.c | 28 ++++++---------------------- tests/unit/switch_rtp.c | 3 ++- tests/unit/switch_utils.c | 4 ++-- tests/unit/switch_vad.c | 3 ++- tests/unit/switch_vpx.c | 13 ++++++------- 12 files changed, 30 insertions(+), 54 deletions(-) diff --git a/src/include/test/switch_test.h b/src/include/test/switch_test.h index 561bf7a4fb..eb6f7f3ee6 100644 --- a/src/include/test/switch_test.h +++ b/src/include/test/switch_test.h @@ -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); \ diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 214ec467b1..6e7e128d62 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -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 diff --git a/tests/unit/switch_console.c b/tests/unit/switch_console.c index 49a2568e71..8e470b56fd 100644 --- a/tests/unit/switch_console.c +++ b/tests/unit/switch_console.c @@ -29,7 +29,6 @@ * */ -#include #include #include @@ -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)); diff --git a/tests/unit/switch_core_db.c b/tests/unit/switch_core_db.c index 5ebf41c8ab..f688b3ff2e 100644 --- a/tests/unit/switch_core_db.c +++ b/tests/unit/switch_core_db.c @@ -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); } diff --git a/tests/unit/switch_core_video.c b/tests/unit/switch_core_video.c index cdd03cbac1..bd963a4d03 100644 --- a/tests/unit/switch_core_video.c +++ b/tests/unit/switch_core_video.c @@ -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"); diff --git a/tests/unit/switch_event.c b/tests/unit/switch_event.c index 69410cec48..bf8c3f43d2 100644 --- a/tests/unit/switch_event.c +++ b/tests/unit/switch_event.c @@ -1,4 +1,3 @@ -#include #include #include @@ -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; diff --git a/tests/unit/switch_hash.c b/tests/unit/switch_hash.c index e0de407917..5c647bde62 100644 --- a/tests/unit/switch_hash.c +++ b/tests/unit/switch_hash.c @@ -1,4 +1,3 @@ -#include #include #include @@ -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; diff --git a/tests/unit/switch_ivr_originate.c b/tests/unit/switch_ivr_originate.c index 49174f3b33..9369506b13 100644 --- a/tests/unit/switch_ivr_originate.c +++ b/tests/unit/switch_ivr_originate.c @@ -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; diff --git a/tests/unit/switch_rtp.c b/tests/unit/switch_rtp.c index 5459775393..d411fe20fc 100644 --- a/tests/unit/switch_rtp.c +++ b/tests/unit/switch_rtp.c @@ -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); diff --git a/tests/unit/switch_utils.c b/tests/unit/switch_utils.c index 7b7fa3729a..1fc291ea96 100644 --- a/tests/unit/switch_utils.c +++ b/tests/unit/switch_utils.c @@ -29,7 +29,6 @@ * */ -#include #include #include @@ -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); diff --git a/tests/unit/switch_vad.c b/tests/unit/switch_vad.c index 9b97d8bd18..8b0f85bb1f 100644 --- a/tests/unit/switch_vad.c +++ b/tests/unit/switch_vad.c @@ -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); diff --git a/tests/unit/switch_vpx.c b/tests/unit/switch_vpx.c index d97d09f186..0c42fd8665 100644 --- a/tests/unit/switch_vpx.c +++ b/tests/unit/switch_vpx.c @@ -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);