]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Unit-tests] Fix previously defined AM_* in tests.
authors3rj1k <evasive.gyron@gmail.com>
Tue, 23 Feb 2021 17:59:26 +0000 (19:59 +0200)
committerGitHub <noreply@github.com>
Tue, 23 Feb 2021 17:59:26 +0000 (20:59 +0300)
12 files changed:
src/include/test/switch_test.h
tests/unit/Makefile.am
tests/unit/switch_console.c
tests/unit/switch_core_db.c
tests/unit/switch_core_video.c
tests/unit/switch_event.c
tests/unit/switch_hash.c
tests/unit/switch_ivr_originate.c
tests/unit/switch_rtp.c
tests/unit/switch_utils.c
tests/unit/switch_vad.c
tests/unit/switch_vpx.c

index 561bf7a4fb6d03f62f9f6d9e7e463ff64cc24837..eb6f7f3ee6d442d09a38b860128b6aae63d2065e 100644 (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); \
index 214ec467b16cebd848621498aa07e0822b881b13..6e7e128d6290d38466ea231b780c78abbdecbb04 100644 (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
index 49a2568e7121a09cacf4be5d5cf83a588a83b9a0..8e470b56fdb018170faf4a28eb1295b0f59f8efc 100644 (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));
index 5ebf41c8ab8cbdc48cb209e5341e6210aa4638ab..f688b3ff2e4465ce175c1866435f0ecf90debbf5 100644 (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);
 
                        }
 
index cdd03cbac12d0e1fd4323f10300b16a9b11e5a0c..bd963a4d0367d6df129ac273a5dd93ac042156a7 100644 (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");
index 69410cec489df015b94e158075fd4f1bf43f67dc..bf8c3f43d2c94bf87f76499627a2fc714301f720 100644 (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;
index e0de4079175fc9b937c62b89f229e17654b12aeb..5c647bde62c43e2b6fb6c80c1ed1011fe7a375b6 100644 (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;
index 49174f3b3365a9400e604910b358f8fb31b494f7..9369506b133e935ba836d3ab48dc337402ead282 100644 (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;
index 54597753938a4bf233fa586188125f2715545ea9..d411fe20fc9fc330b09c2493c76a1e8c2ec93f00 100644 (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);
 
index 7b7fa3729a51c0417e34eb144866318bf8038a10..1fc291ea96d8fdd64e7972f2a688110d1b20e9bf 100644 (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);
index 9b97d8bd182ae8454b090be8ec7707c0b4df03a4..8b0f85bb1ff97badcbb47f5daecba5d14992fca6 100644 (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);
index d97d09f186f52d8cf5a3c178443a96f7163d3060..0c42fd8665983d4c99b0327e42ddbfe24d5d6f24 100644 (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);