From 1927367cbc63e8c3f37ca46bce6266eff9333987 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 21 Jan 2020 21:50:08 +0400 Subject: [PATCH] [Unit-tests] Fix leaks mod_av and mod_conference tests, fix fonts and paths. --- src/mod/applications/mod_av/test/test_mod_av.c | 1 + src/mod/applications/mod_conference/test/test_image.c | 6 ++++-- .../applications/mod_conference/test/test_member.c | 11 ++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_av/test/test_mod_av.c b/src/mod/applications/mod_av/test/test_mod_av.c index 0910c56973..a058aa63fd 100644 --- a/src/mod/applications/mod_av/test/test_mod_av.c +++ b/src/mod/applications/mod_av/test/test_mod_av.c @@ -130,6 +130,7 @@ FST_CORE_BEGIN("conf") fst_check(packets > 0); switch_core_codec_destroy(&codec); + switch_img_free(&img); } FST_TEST_END() diff --git a/src/mod/applications/mod_conference/test/test_image.c b/src/mod/applications/mod_conference/test/test_image.c index 32d28e3bb2..3b4556a2f3 100644 --- a/src/mod/applications/mod_conference/test/test_image.c +++ b/src/mod/applications/mod_conference/test/test_image.c @@ -78,7 +78,7 @@ FST_CORE_BEGIN("./conf") switch_image_t *scaled_img = NULL; char name[1024]; - switch_snprintf(name, sizeof(name), "images/signalwire-scaled-ARGB-%d.png", i); + switch_snprintf(name, sizeof(name), "../images/signalwire-scaled-ARGB-%d.png", i); sprintf(path, "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, name); switch_img_scale(img, &scaled_img, img->d_w / i, img->d_h / i); fst_requires(scaled_img); @@ -107,13 +107,15 @@ FST_CORE_BEGIN("./conf") sprintf(path, "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "../images/signalwire-scaled-ARGB-8.png"); img = switch_img_read_png(path, SWITCH_IMG_FMT_ARGB); - switch_img_txt_handle_create(&txthandle, font_face, fg, bg, font_size, 0, NULL); + sprintf(path, "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, font_face); + switch_img_txt_handle_create(&txthandle, path, fg, bg, font_size, 0, NULL); switch_img_txt_handle_render(txthandle, img, 50, 3, txt, NULL, fg, bg, font_size, 0); switch_img_txt_handle_render(txthandle, img, 60, 15, alttxt, NULL, altfg, "#000000", font_size, 0); sprintf(path, "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "../images/signalwire-scaled-ARGB-8-txt.png"); switch_img_write_png(img, path); switch_img_free(&img); + switch_img_txt_handle_destroy(&txthandle); } FST_TEST_END() diff --git a/src/mod/applications/mod_conference/test/test_member.c b/src/mod/applications/mod_conference/test/test_member.c index 29d0004e7f..1df2b850a0 100644 --- a/src/mod/applications/mod_conference/test/test_member.c +++ b/src/mod/applications/mod_conference/test/test_member.c @@ -53,16 +53,17 @@ FST_CORE_BEGIN("./conf") FST_TEST_BEGIN(member_test) { char path[4096]; - const char *logo = "{position=left-bot,text_x=center," - "center_offset=190,text=#000000:transparent:font/AEH.ttf:50:" - "'FREESWITCH ROCKS',alt_text_x=center,alt_center_offset=190," - "alt_text_y=88,alt_text=#ffffff:transparent:font/AEH.ttf:40:" - "'freeswitch'}"; + char logo[1024]; conference_member_t smember = { 0 }; conference_member_t *member = &smember; switch_image_t *img; int i; + sprintf(logo, "%s%s%s%s%s%s%s", "{position=left-bot,text_x=center," + "center_offset=190,text=#000000:transparent:", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "font/AEH.ttf:50:" + "'FREESWITCH ROCKS',alt_text_x=center,alt_center_offset=190," + "alt_text_y=88,alt_text=#ffffff:transparent:", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "font/AEH.ttf:40:" + "'freeswitch'}"); sprintf(path, "%s%s%s%s", logo, SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "../images/signalwire.png"); switch_mutex_init(&member->write_mutex, SWITCH_MUTEX_NESTED, fst_pool); switch_mutex_init(&member->flag_mutex, SWITCH_MUTEX_NESTED, fst_pool);