diff --git a/mediastreamer2 b/mediastreamer2
index 20c50eea5..173e62d6c 160000
--- a/mediastreamer2
+++ b/mediastreamer2
@@ -1 +1 @@
-Subproject commit 20c50eea5e84531555df193db114b588fca383db
+Subproject commit 173e62d6c0ec34e89f0f67b0d731150390328b2d
diff --git a/tester/accountmanager.c b/tester/accountmanager.c
index 85fbc4045..c3b6d1090 100644
--- a/tester/accountmanager.c
+++ b/tester/accountmanager.c
@@ -123,7 +123,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf
vtable.registration_state_changed=account_created_on_server_cb;
vtable.auth_info_requested=account_created_auth_requested_cb;
- lc=configure_lc_from(&vtable,bc_tester_read_dir_prefix,NULL,account);
+ lc=configure_lc_from(&vtable,bc_tester_get_resource_dir_prefix(),NULL,account);
tr.udp_port=LC_SIP_TRANSPORT_RANDOM;
tr.tcp_port=LC_SIP_TRANSPORT_RANDOM;
tr.tls_port=LC_SIP_TRANSPORT_RANDOM;
diff --git a/tester/call_tester.c b/tester/call_tester.c
index eeb8c81f2..729c52354 100644
--- a/tester/call_tester.c
+++ b/tester/call_tester.c
@@ -1795,8 +1795,8 @@ void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager* marie,
}
if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */
- marie->lc->user_certificates_path = ms_strdup_printf("%s/certificates-marie", bc_tester_writable_dir_prefix);
- pauline->lc->user_certificates_path = ms_strdup_printf("%s/certificates-pauline", bc_tester_writable_dir_prefix);
+ marie->lc->user_certificates_path = bc_tester_file("certificates-marie");
+ pauline->lc->user_certificates_path = bc_tester_file("certificates-pauline");
belle_sip_mkdir(marie->lc->user_certificates_path);
belle_sip_mkdir(pauline->lc->user_certificates_path);
}
@@ -2341,14 +2341,13 @@ static void call_with_file_player(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphonePlayer *player;
- char hellopath[256];
- char *recordpath = create_filepath(bc_tester_writable_dir_prefix, "record-call_with_file_player", "wav");
+ char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav");
+ char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav");
bool_t call_ok;
/*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
unlink(recordpath);
- snprintf(hellopath,sizeof(hellopath), "%s/sounds/ahbahouaismaisbon.wav", bc_tester_read_dir_prefix);
/*caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player*/
linphone_core_use_files(marie->lc,TRUE);
@@ -2395,6 +2394,7 @@ end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
ms_free(recordpath);
+ ms_free(hellopath);
}
static bool_t is_format_supported(LinphoneCore *lc, const char *fmt){
@@ -2409,8 +2409,8 @@ static void call_with_mkv_file_player(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphonePlayer *player;
- char hellomkv[256];
- char hellowav[256];
+ char *hellomkv;
+ char *hellowav;
char *recordpath;
bool_t call_ok;
#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID)
@@ -2418,17 +2418,17 @@ static void call_with_mkv_file_player(void) {
const double threshold = 0.9;
#define DO_AUDIO_CMP
#endif
+ hellomkv = bc_tester_res("sounds/hello8000_mkv_ref.wav");
+ hellowav = bc_tester_res("sounds/hello8000.mkv");
if (!is_format_supported(marie->lc,"mkv")){
ms_warning("Test skipped, no mkv support.");
goto end;
}
- recordpath = create_filepath(bc_tester_writable_dir_prefix, "record-call_with_mkv_file_player", "wav");
+ recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_mkv_file_player", "wav");
/*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
unlink(recordpath);
- snprintf(hellowav,sizeof(hellowav), "%s/sounds/hello8000_mkv_ref.wav", bc_tester_read_dir_prefix);
- snprintf(hellomkv,sizeof(hellomkv), "%s/sounds/hello8000.mkv", bc_tester_read_dir_prefix);
/*caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player*/
linphone_core_use_files(marie->lc,TRUE);
@@ -2474,7 +2474,8 @@ static void call_with_mkv_file_player(void) {
end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
-
+ ms_free(hellomkv);
+ ms_free(hellowav);
}
void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel, const char *marie_rc, const char *pauline_rc) {
@@ -2508,8 +2509,8 @@ void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video
linphone_core_set_media_encryption(marie->lc,mode);
linphone_core_set_media_encryption(pauline->lc,mode);
if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */
- marie->lc->user_certificates_path = ms_strdup_printf("%s/certificates-marie", bc_tester_writable_dir_prefix);
- pauline->lc->user_certificates_path = ms_strdup_printf("%s/certificates-pauline", bc_tester_writable_dir_prefix);
+ marie->lc->user_certificates_path = bc_tester_file("certificates-marie");
+ pauline->lc->user_certificates_path = bc_tester_file("certificates-pauline");
belle_sip_mkdir(marie->lc->user_certificates_path);
belle_sip_mkdir(pauline->lc->user_certificates_path);
}
@@ -3415,7 +3416,7 @@ static void record_call(const char *filename, bool_t enableVideo) {
formats = linphone_core_get_supported_file_formats(marie->lc);
for(i=0, format = formats[0]; format != NULL; i++, format = formats[i]) {
- filepath = create_filepath(bc_tester_writable_dir_prefix, filename, format);
+ filepath = create_filepath(bc_tester_get_writable_dir_prefix(), filename, format);
remove(filepath);
linphone_call_params_set_record_file(marieParams, filepath);
BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams));
@@ -3453,7 +3454,7 @@ static void video_call_snapshot(void) {
LinphoneCallParams *marieParams = linphone_core_create_default_call_parameters(marie->lc);
LinphoneCallParams *paulineParams = linphone_core_create_default_call_parameters(pauline->lc);
LinphoneCall *callInst = NULL;
- char *filename = create_filepath(bc_tester_writable_dir_prefix, "snapshot", "jpeg");
+ char *filename = create_filepath(bc_tester_get_writable_dir_prefix(), "snapshot", "jpeg");
int dummy = 0;
bool_t call_succeeded = FALSE;
@@ -3920,8 +3921,8 @@ static void call_with_generic_cn(void) {
LinphoneCoreManager* marie;
LinphoneCoreManager* pauline;
LinphoneCall *pauline_call;
- char *audio_file_with_silence=ms_strdup_printf("%s/%s",bc_tester_read_dir_prefix,"sounds/ahbahouaismaisbon.wav");
- char *recorded_file=ms_strdup_printf("%s/%s",bc_tester_writable_dir_prefix,"result.wav");
+ char *audio_file_with_silence=bc_tester_res("sounds/ahbahouaismaisbon.wav");
+ char *recorded_file=bc_tester_file("result.wav");
belle_sip_object_enable_leak_detector(TRUE);
begin=belle_sip_object_get_object_count();
@@ -4165,8 +4166,8 @@ static void simple_stereo_call(const char *codec_name, int clock_rate, int bitra
LinphoneCoreManager* marie;
LinphoneCoreManager* pauline;
PayloadType *pt;
- char *stereo_file = ms_strdup_printf("%s/%s",bc_tester_read_dir_prefix,"sounds/vrroom.wav");
- char *recordpath = create_filepath(bc_tester_writable_dir_prefix, "stereo-record", "wav");
+ char *stereo_file = bc_tester_res("sounds/vrroom.wav");
+ char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "stereo-record", "wav");
int dummy=0;
belle_sip_object_enable_leak_detector(TRUE);
diff --git a/tester/common/bc_tester_utils.c b/tester/common/bc_tester_utils.c
index 7c47dc25f..1e9262a6c 100644
--- a/tester/common/bc_tester_utils.c
+++ b/tester/common/bc_tester_utils.c
@@ -23,24 +23,29 @@ along with this program. If not, see .
#include "bc_tester_utils.h"
#include
+#include
#include "CUnit/Basic.h"
#include "CUnit/Automated.h"
-
-#if WINAPI_FAMILY_PHONE_APP
-const char *bc_tester_read_dir_prefix="Assets";
-#elif defined(__QNX__)
-const char *bc_tester_read_dir_prefix="./app/native/assets/";
-#else
-const char *bc_tester_read_dir_prefix=".";
+#ifdef _WIN32
+#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
+#define BC_TESTER_WINDOWS_DESKTOP 1
+#elif defined(WINAPI_FAMILY_PARTITION)
+#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define BC_TESTER_WINDOWS_DESKTOP 1
+#endif
+#if defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
+#define BC_TESTER_WINDOWS_PHONE 1
+#endif
+#if defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#define BC_TESTER_WINDOWS_UNIVERSAL 1
+#endif
+#endif
#endif
-/* TODO: have the same "static" for QNX and windows as above? */
-#ifdef ANDROID
-const char *bc_tester_writable_dir_prefix = "/data/data/org.linphone.tester/cache";
-#else
-const char *bc_tester_writable_dir_prefix = ".";
-#endif
+
+static char *bc_tester_resource_dir_prefix = NULL;
+static char *bc_tester_writable_dir_prefix = NULL;
int bc_printf_verbosity_info;
int bc_printf_verbosity_error;
@@ -97,7 +102,7 @@ int bc_tester_suite_index(const char *suite_name) {
return -1;
}
-int bc_tester_nb_suites() {
+int bc_tester_nb_suites(void) {
return nb_test_suites;
}
@@ -114,7 +119,7 @@ int bc_tester_nb_tests(const char *suite_name) {
return test_suite[i]->nb_tests;
}
-void bc_tester_list_suites() {
+void bc_tester_list_suites(void) {
int j;
for(j=0;jpName);
+ suite_start_time = time(NULL);
}
static void suite_complete_message_handler(const CU_pSuite pSuite, const CU_pFailureRecord pFailure) {
- bc_tester_printf(bc_printf_verbosity_info,"Suite [%s] ended\n", pSuite->pName);
+ bc_tester_printf(bc_printf_verbosity_info,"Suite [%s] ended in %lu sec\n", pSuite->pName, time(NULL) - suite_start_time);
}
+static time_t test_start_time = 0;
static void test_start_message_handler(const CU_pTest pTest, const CU_pSuite pSuite) {
bc_tester_printf(bc_printf_verbosity_info,"Suite [%s] Test [%s] started", pSuite->pName,pTest->pName);
+ test_start_time = time(NULL);
}
/*derivated from cunit*/
@@ -178,7 +187,7 @@ static void test_complete_message_handler(const CU_pTest pTest,
} else {
strncat(result, " passed", strlen(" passed"));
}
- bc_tester_printf(bc_printf_verbosity_info,"%s\n", result);
+ bc_tester_printf(bc_printf_verbosity_info,"%s in %lu sec\n", result, (unsigned long)(time(NULL) - test_start_time));
}
#endif
@@ -264,7 +273,7 @@ void bc_tester_helper(const char *name, const char* additionnal_helper) {
"\t\t\t--curses\n"
#endif
"\t\t\t--xml\n"
- "\t\t\t--xml-file \n"
+ "\t\t\t--xml-file \n"
"And additionally:\n"
"%s"
, name
@@ -272,6 +281,22 @@ void bc_tester_helper(const char *name, const char* additionnal_helper) {
}
void bc_tester_init(void (*ftester_printf)(int level, const char *fmt, va_list args), int iverbosity_info, int iverbosity_error) {
+#if defined(BC_TESTER_WINDOWS_PHONE) || defined(BC_TESTER_WINDOWS_UNIVERSAL)
+ bc_tester_set_resource_dir_prefix("Assets");
+#elif defined(__QNX__)
+ bc_tester_set_resource_dir_prefix("./app/native/assets/");
+#else
+ bc_tester_set_resource_dir_prefix(".");
+#endif
+
+#ifdef ANDROID
+ bc_tester_set_writable_dir_prefix("/data/data/org.linphone.tester/cache");
+#elif defined(__QNX__)
+ bc_tester_set_writable_dir_prefix("./tmp");
+#else
+ bc_tester_set_writable_dir_prefix(".");
+#endif
+
tester_printf_va = ftester_printf;
bc_printf_verbosity_error = iverbosity_error;
bc_printf_verbosity_info = iverbosity_info;
@@ -316,7 +341,7 @@ int bc_tester_parse_args(int argc, char **argv, int argid)
return i - argid + 1;
}
-int bc_tester_start() {
+int bc_tester_start(void) {
int ret;
if( xml_enabled ){
size_t size = strlen(xml_file) + strlen(".tmp") + 1;
@@ -341,7 +366,7 @@ void bc_tester_add_suite(test_suite_t *suite) {
}
}
-void bc_tester_uninit() {
+void bc_tester_uninit(void) {
/* Redisplay list of failed tests on end */
if (CU_get_number_of_failure_records()){
CU_basic_show_failures(CU_get_failure_list());
@@ -364,14 +389,56 @@ void bc_tester_uninit() {
test_suite = NULL;
nb_test_suites = 0;
}
+
+ if (bc_tester_resource_dir_prefix != NULL) {
+ free(bc_tester_resource_dir_prefix);
+ bc_tester_resource_dir_prefix = NULL;
+ }
+ if (bc_tester_writable_dir_prefix != NULL) {
+ free(bc_tester_writable_dir_prefix);
+ bc_tester_writable_dir_prefix = NULL;
+ }
}
-char * bc_tester_res(const char *name) {
+static void bc_tester_set_dir_prefix(char **prefix, const char *name) {
+ size_t len = strlen(name);
+ if (*prefix != NULL) free(*prefix);
+ *prefix = malloc(len + 1);
+ strncpy(*prefix, name, len);
+ (*prefix)[len] = '\0';
+}
+
+const char * bc_tester_get_resource_dir_prefix(void) {
+ return bc_tester_resource_dir_prefix;
+}
+
+void bc_tester_set_resource_dir_prefix(const char *name) {
+ bc_tester_set_dir_prefix(&bc_tester_resource_dir_prefix, name);
+}
+
+const char * bc_tester_get_writable_dir_prefix(void) {
+ return bc_tester_writable_dir_prefix;
+}
+
+void bc_tester_set_writable_dir_prefix(const char *name) {
+ bc_tester_set_dir_prefix(&bc_tester_writable_dir_prefix, name);
+}
+
+static char * bc_tester_path(const char *prefix, const char *name) {
char* file = NULL;
if (name) {
- size_t len = strlen(bc_tester_read_dir_prefix) + 1 + strlen(name) + 1;
+ size_t len = strlen(prefix) + 1 + strlen(name) + 1;
file = malloc(len);
- snprintf(file, len, "%s/%s", bc_tester_read_dir_prefix, name);
+ snprintf(file, len, "%s/%s", prefix, name);
+ file[strlen(file)] = '\0';
}
return file;
}
+
+char * bc_tester_res(const char *name) {
+ return bc_tester_path(bc_tester_resource_dir_prefix, name);
+}
+
+char * bc_tester_file(const char *name) {
+ return bc_tester_path(bc_tester_writable_dir_prefix, name);
+}
diff --git a/tester/common/bc_tester_utils.h b/tester/common/bc_tester_utils.h
index a0e95884a..86192091d 100644
--- a/tester/common/bc_tester_utils.h
+++ b/tester/common/bc_tester_utils.h
@@ -25,8 +25,9 @@
#include
#include
-extern const char *bc_tester_read_dir_prefix;
-extern const char *bc_tester_writable_dir_prefix;
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
extern int bc_printf_verbosity_info;
extern int bc_printf_verbosity_error;
@@ -64,14 +65,18 @@ void bc_tester_init(void (*ftester_printf)(int level, const char *fmt, va_list a
, int verbosity_info, int verbosity_error);
void bc_tester_helper(const char *name, const char* additionnal_helper);
int bc_tester_parse_args(int argc, char** argv, int argid);
-int bc_tester_start();
+int bc_tester_start(void);
void bc_tester_add_suite(test_suite_t *suite);
-void bc_tester_uninit();
+void bc_tester_uninit(void);
void bc_tester_printf(int level, const char *fmt, ...);
+const char * bc_tester_get_resource_dir_prefix(void);
+void bc_tester_set_resource_dir_prefix(const char *name);
+const char * bc_tester_get_writable_dir_prefix(void);
+void bc_tester_set_writable_dir_prefix(const char *name);
-int bc_tester_nb_suites();
+int bc_tester_nb_suites(void);
int bc_tester_nb_tests(const char* name);
-void bc_tester_list_suites();
+void bc_tester_list_suites(void);
void bc_tester_list_tests(const char *suite_name);
const char * bc_tester_suite_name(int suite_index);
const char * bc_tester_test_name(const char *suite_name, int test_index);
@@ -83,11 +88,19 @@ int bc_tester_suite_index(const char *suite_name);
/**
* Get full path to the given resource
*
- * @param name relative resource path (relative to bc_tester_writable_dir_prefix)
+ * @param name relative resource path
* @return path to the resource. Must be freed by caller.
*/
char * bc_tester_res(const char *name);
+/**
+* Get full path to the given writable_file
+*
+* @param name relative writable file path
+* @return path to the writable file. Must be freed by caller.
+*/
+char * bc_tester_file(const char *name);
+
/*Redefine the CU_... macros WITHOUT final ';' semicolon, to allow IF conditions and with smarter error message */
extern int CU_assertImplementation(int bValue,
diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c
index 1cfc4dbff..03a306ef5 100644
--- a/tester/flexisip_tester.c
+++ b/tester/flexisip_tester.c
@@ -736,8 +736,8 @@ static void file_transfer_message_rcs_to_external_body_client(void) {
LinphoneContent* content;
FILE *file_to_send = NULL;
size_t file_size;
- char *send_filepath = ms_strdup_printf("%s/images/nowebcamCIF.jpg", bc_tester_read_dir_prefix);
- char *receive_filepath = ms_strdup_printf("%s/receive_file.dump", bc_tester_writable_dir_prefix);
+ char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg");
+ char *receive_filepath = bc_tester_file("receive_file.dump");
LinphoneCoreManager* pauline = linphone_core_manager_init( "pauline_rc");
linphone_proxy_config_set_custom_header(marie->lc->default_proxy, "Accept", "application/sdp");
diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c
index 0a3a5ce4b..cd54c8458 100644
--- a/tester/liblinphone_tester.c
+++ b/tester/liblinphone_tester.c
@@ -217,7 +217,7 @@ int main (int argc, char *argv[])
auth_domain=argv[i];
} else if (strcmp(argv[i],"--config")==0){
CHECK_ARG("--config", ++i, argc);
- bc_tester_read_dir_prefix=argv[i];
+ bc_tester_set_resource_dir_prefix(argv[i]);
}else if (strcmp(argv[i],"--dns-hosts")==0){
CHECK_ARG("--dns-hosts", ++i, argc);
userhostsfile=argv[i];
diff --git a/tester/log_collection_tester.c b/tester/log_collection_tester.c
index 663b13777..9a374d110 100644
--- a/tester/log_collection_tester.c
+++ b/tester/log_collection_tester.c
@@ -91,7 +91,7 @@ static size_t getline(char **lineptr, size_t *n, FILE *stream) {
static LinphoneLogCollectionState old_collection_state;
static void collect_init() {
old_collection_state = linphone_core_log_collection_enabled();
- linphone_core_set_log_collection_path(bc_tester_writable_dir_prefix);
+ linphone_core_set_log_collection_path(bc_tester_get_writable_dir_prefix());
}
static void collect_cleanup(LinphoneCoreManager *marie) {
@@ -186,7 +186,7 @@ static time_t check_file(LinphoneCoreManager* mgr) {
BC_ASSERT_PTR_NOT_NULL(file);
if (!file) return 0;
// 1) expect to find folder name in filename path
- BC_ASSERT_PTR_NOT_NULL(strstr(filepath, bc_tester_writable_dir_prefix));
+ BC_ASSERT_PTR_NOT_NULL(strstr(filepath, bc_tester_get_writable_dir_prefix()));
// 2) check file contents
while (getline(&line, &line_size, file) != -1) {
diff --git a/tester/message_tester.c b/tester/message_tester.c
index 7574ba421..57bdb6c46 100644
--- a/tester/message_tester.c
+++ b/tester/message_tester.c
@@ -64,16 +64,15 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess
* */
void file_transfer_received(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer){
FILE* file=NULL;
- char receive_file[256];
+ char *receive_file = bc_tester_file("receive_file.dump");
LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(message);
LinphoneCore *lc = linphone_chat_room_get_core(cr);
- snprintf(receive_file,sizeof(receive_file), "%s/receive_file.dump", bc_tester_writable_dir_prefix);
if (!linphone_chat_message_get_user_data(message)) {
/*first chunk, creating file*/
file = fopen(receive_file,"wb");
linphone_chat_message_set_user_data(message,(void*)file); /*store fd for next chunks*/
}
-
+ ms_free(receive_file);
file = (FILE*)linphone_chat_message_get_user_data(message);
if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */
@@ -450,8 +449,8 @@ static void file_transfer_message(void) {
LinphoneContent* content;
FILE *file_to_send = NULL;
size_t file_size;
- char *send_filepath = ms_strdup_printf("%s/images/nowebcamCIF.jpg", bc_tester_read_dir_prefix);
- char *receive_filepath = ms_strdup_printf("%s/receive_file.dump", bc_tester_writable_dir_prefix);
+ char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg");
+ char *receive_filepath = bc_tester_file("receive_file.dump");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
reset_counters(&marie->stat);
@@ -578,7 +577,7 @@ static void small_file_transfer_message(void) {
#ifdef HAVE_LIME
static FILE* fopen_from_write_dir(const char * name, const char * mode) {
- char *filepath = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix,name);
+ char *filepath = bc_tester_res("%s", bc_tester_writable_dir_prefix,name);
FILE * file = fopen(filepath,mode);
ms_free(filepath);
return file;
@@ -629,11 +628,11 @@ static void lime_file_transfer_message_base(bool_t encrypt_file) {
ms_free(marie_id);
ms_free(pauline_id);
- filepath = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix,"tmpZIDCacheMarie.xml");
+ filepath = bc_tester_res("%s", bc_tester_writable_dir_prefix,"tmpZIDCacheMarie.xml");
linphone_core_set_zrtp_secrets_file(marie->lc, filepath);
ms_free(filepath);
- filepath = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix,"tmpZIDCachePauline.xml");
+ filepath = bc_tester_res("%s", bc_tester_writable_dir_prefix,"tmpZIDCachePauline.xml");
linphone_core_set_zrtp_secrets_file(pauline->lc, filepath);
ms_free(filepath);
@@ -890,11 +889,11 @@ static void lime_text_message(void) {
fclose(ZIDCacheMarieFD);
fclose(ZIDCachePaulineFD);
- filepath = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix,"tmpZIDCacheMarie.xml");
+ filepath = bc_tester_res("%s", bc_tester_writable_dir_prefix,"tmpZIDCacheMarie.xml");
linphone_core_set_zrtp_secrets_file(marie->lc, filepath);
ms_free(filepath);
- filepath = ms_strdup_printf("%s/%s", bc_tester_writable_dir_prefix,"tmpZIDCachePauline.xml");
+ filepath = bc_tester_res("%s", bc_tester_writable_dir_prefix,"tmpZIDCachePauline.xml");
linphone_core_set_zrtp_secrets_file(pauline->lc, filepath);
ms_free(filepath);
@@ -1231,8 +1230,8 @@ static void file_transfer_message_two_messages() {
LinphoneContent* content;
FILE *file_to_send = NULL;
size_t file_size;
- char *send_filepath = ms_strdup_printf("%s/images/nowebcamCIF.jpg", bc_tester_read_dir_prefix);
- char *receive_filepath = ms_strdup_printf("%s/receive_file.dump", bc_tester_writable_dir_prefix);
+ char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg");
+ char *receive_filepath = bc_tester_file("receive_file.dump");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
reset_counters(&marie->stat);
@@ -1444,8 +1443,8 @@ static void info_message_with_args(bool_t with_content) {
if (linphone_content_get_buffer(content))BC_ASSERT_TRUE(strcmp((const char*)linphone_content_get_buffer(content),info_content)==0);
BC_ASSERT_EQUAL(linphone_content_get_size(content),strlen(info_content), int, "%d");
}
- linphone_core_manager_destroy(marie);
}
+ linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
@@ -1542,11 +1541,9 @@ static int check_no_strange_time(void* data,int argc, char** argv,char** cNames)
static void message_storage_migration() {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
- char src_db[256];
- char tmp_db[256];
+ char *src_db = bc_tester_res("messages.db");
+ char *tmp_db = bc_tester_file("tmp.db");
MSList* chatrooms;
- snprintf(src_db,sizeof(src_db), "%s/messages.db", bc_tester_read_dir_prefix);
- snprintf(tmp_db,sizeof(tmp_db), "%s/tmp.db", bc_tester_writable_dir_prefix);
BC_ASSERT_EQUAL_FATAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d");
@@ -1565,6 +1562,8 @@ static void message_storage_migration() {
linphone_core_manager_destroy(marie);
remove(tmp_db);
+ ms_free(src_db);
+ ms_free(tmp_db);
}
static void history_message_count_helper(LinphoneChatRoom* chatroom, int x, int y, int expected ){
@@ -1583,10 +1582,8 @@ static void history_range_full_test(){
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *jehan_addr = linphone_address_new("");
LinphoneChatRoom *chatroom;
- char src_db[256];
- char tmp_db[256];
- snprintf(src_db,sizeof(src_db), "%s/messages.db", bc_tester_read_dir_prefix);
- snprintf(tmp_db,sizeof(tmp_db), "%s/tmp.db", bc_tester_writable_dir_prefix);
+ char *src_db = bc_tester_res("messages.db");
+ char *tmp_db = bc_tester_file("tmp.db");
BC_ASSERT_EQUAL_FATAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d");
@@ -1613,10 +1610,12 @@ static void history_range_full_test(){
history_message_count_helper(chatroom, -1, 3, 4);
history_message_count_helper(chatroom, -2, 2, 3);
history_message_count_helper(chatroom, -3, 1, 2);
- linphone_core_manager_destroy(marie);
}
+ linphone_core_manager_destroy(marie);
linphone_address_destroy(jehan_addr);
remove(tmp_db);
+ ms_free(src_db);
+ ms_free(tmp_db);
}
@@ -1625,10 +1624,8 @@ static void history_messages_count() {
LinphoneAddress *jehan_addr = linphone_address_new("");
LinphoneChatRoom *chatroom;
MSList *messages;
- char src_db[256];
- char tmp_db[256];
- snprintf(src_db,sizeof(src_db), "%s/messages.db", bc_tester_read_dir_prefix);
- snprintf(tmp_db,sizeof(tmp_db), "%s/tmp.db", bc_tester_writable_dir_prefix);
+ char *src_db = bc_tester_res("messages.db");
+ char *tmp_db = bc_tester_file("tmp.db");
BC_ASSERT_EQUAL_FATAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d");
@@ -1672,10 +1669,12 @@ static void history_messages_count() {
messages = linphone_chat_room_get_history_range(chatroom, 1265, 1260);
BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d");
ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref);
- linphone_core_manager_destroy(marie);
}
+ linphone_core_manager_destroy(marie);
linphone_address_destroy(jehan_addr);
remove(tmp_db);
+ ms_free(src_db);
+ ms_free(tmp_db);
}
diff --git a/tester/player_tester.c b/tester/player_tester.c
index 9e6ec1a0b..332bcffbc 100644
--- a/tester/player_tester.c
+++ b/tester/player_tester.c
@@ -71,7 +71,7 @@ static void play_file(const char *filename, bool_t unsupported_format, const cha
}
static void playing_test(void) {
- char *filename = ms_strdup_printf("%s/sounds/hello_opus_h264.mkv", bc_tester_read_dir_prefix);
+ char *filename = bc_tester_res("sounds/hello_opus_h264.mkv");
const char *audio_mime = "opus";
const char *video_mime = "h264";
play_file(filename, !linphone_local_player_matroska_supported(), audio_mime, video_mime);
diff --git a/tester/register_tester.c b/tester/register_tester.c
index dd414bd01..e44748ca8 100644
--- a/tester/register_tester.c
+++ b/tester/register_tester.c
@@ -764,23 +764,24 @@ static void tls_certificate_failure(){
if (transport_supported(LinphoneTransportTls)) {
LinphoneCoreManager* lcm;
LinphoneCore *lc;
- char rootcapath[256];
+ char *rootcapath = bc_tester_res("certificates/cn/agent.pem"); /*bad root ca*/
lcm=linphone_core_manager_new2("pauline_rc",FALSE);
lc=lcm->lc;
- snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/agent.pem", bc_tester_read_dir_prefix); /*bad root ca*/
linphone_core_set_root_ca(lcm->lc,rootcapath);
linphone_core_set_network_reachable(lc,TRUE);
BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&lcm->stat.number_of_LinphoneRegistrationFailed,1));
linphone_core_set_root_ca(lcm->lc,NULL); /*no root ca*/
linphone_core_refresh_registers(lcm->lc);
BC_ASSERT_TRUE(wait_for(lc,lc,&lcm->stat.number_of_LinphoneRegistrationFailed,2));
- snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/cafile.pem", bc_tester_read_dir_prefix); /*goot root ca*/
+ ms_free(rootcapath);
+ rootcapath = bc_tester_res("certificates/cn/cafile.pem"); /*good root ca*/
linphone_core_set_root_ca(lcm->lc,rootcapath);
linphone_core_refresh_registers(lcm->lc);
BC_ASSERT_TRUE(wait_for(lc,lc,&lcm->stat.number_of_LinphoneRegistrationOk,1));
BC_ASSERT_EQUAL(lcm->stat.number_of_LinphoneRegistrationFailed,2, int, "%d");
linphone_core_manager_destroy(lcm);
+ ms_free(rootcapath);
}
}
@@ -813,16 +814,16 @@ static void tls_alt_name_register(){
if (transport_supported(LinphoneTransportTls)) {
LinphoneCoreManager* lcm;
LinphoneCore *lc;
- char rootcapath[256];
+ char *rootcapath = bc_tester_res("certificates/cn/cafile.pem");
lcm=linphone_core_manager_new2("pauline_alt_rc",FALSE);
lc=lcm->lc;
- snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/cafile.pem", bc_tester_read_dir_prefix);
linphone_core_set_root_ca(lc,rootcapath);
linphone_core_refresh_registers(lc);
BC_ASSERT_TRUE(wait_for(lc,lc,&lcm->stat.number_of_LinphoneRegistrationOk,1));
BC_ASSERT_EQUAL(lcm->stat.number_of_LinphoneRegistrationFailed,0, int, "%d");
linphone_core_manager_destroy(lcm);
+ ms_free(rootcapath);
}
}
@@ -830,16 +831,16 @@ static void tls_wildcard_register(){
if (transport_supported(LinphoneTransportTls)) {
LinphoneCoreManager* lcm;
LinphoneCore *lc;
- char rootcapath[256];
+ char *rootcapath = bc_tester_res("certificates/cn/cafile.pem");
lcm=linphone_core_manager_new2("pauline_wild_rc",FALSE);
lc=lcm->lc;
- snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/cafile.pem", bc_tester_read_dir_prefix);
linphone_core_set_root_ca(lc,rootcapath);
linphone_core_refresh_registers(lc);
BC_ASSERT_TRUE(wait_for(lc,lc,&lcm->stat.number_of_LinphoneRegistrationOk,2));
BC_ASSERT_EQUAL(lcm->stat.number_of_LinphoneRegistrationFailed,0, int, "%d");
linphone_core_manager_destroy(lcm);
+ ms_free(rootcapath);
}
}
diff --git a/tester/remote_provisioning_tester.c b/tester/remote_provisioning_tester.c
index 19ca62c89..7a5de0876 100644
--- a/tester/remote_provisioning_tester.c
+++ b/tester/remote_provisioning_tester.c
@@ -98,7 +98,7 @@ static void remote_provisioning_default_values(void) {
LpConfig* lp = linphone_core_get_config(marie->lc);
BC_ASSERT_STRING_EQUAL(lp_config_get_string(lp,"app","toto","empty"),"titi");
}
-
+ linphone_proxy_config_destroy(lpc);
linphone_core_manager_destroy(marie);
}
diff --git a/tester/setup_tester.c b/tester/setup_tester.c
index fe243d288..58a0dc817 100644
--- a/tester/setup_tester.c
+++ b/tester/setup_tester.c
@@ -127,7 +127,7 @@ static void linphone_lpconfig_from_buffer_zerolen_value(){
static void linphone_lpconfig_from_file_zerolen_value(){
/* parameters that have no value should return NULL, not "". */
const char* zero_rc_file = "zero_length_params_rc";
- char* rc_path = ms_strdup_printf("%s/rcfiles/%s", bc_tester_read_dir_prefix, zero_rc_file);
+ char* rc_path = ms_strdup_printf("%s/rcfiles/%s", bc_tester_get_resource_dir_prefix(), zero_rc_file);
LpConfig* conf;
/* not using lp_config_new() because it expects a readable file, and iOS (for instance)
@@ -148,7 +148,7 @@ static void linphone_lpconfig_from_file_zerolen_value(){
static void linphone_lpconfig_from_xml_zerolen_value(){
const char* zero_xml_file = "remote_zero_length_params_rc";
- char* xml_path = ms_strdup_printf("%s/rcfiles/%s", bc_tester_read_dir_prefix, zero_xml_file);
+ char* xml_path = ms_strdup_printf("%s/rcfiles/%s", bc_tester_get_resource_dir_prefix(), zero_xml_file);
LpConfig* conf;
LinphoneCoreManager* mgr = linphone_core_manager_new2("empty_rc",FALSE);
diff --git a/tester/tester.c b/tester/tester.c
index 7c5c83a7d..e8bd983bf 100644
--- a/tester/tester.c
+++ b/tester/tester.c
@@ -259,7 +259,7 @@ LinphoneCoreManager* linphone_core_manager_init(const char* rc_file) {
reset_counters(&mgr->stat);
if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
- mgr->lc=configure_lc_from(&mgr->v_table, bc_tester_read_dir_prefix, rc_path, mgr);
+ mgr->lc=configure_lc_from(&mgr->v_table, bc_tester_get_resource_dir_prefix(), rc_path, mgr);
linphone_core_manager_check_accounts(mgr);
manager_count++;
@@ -287,16 +287,16 @@ LinphoneCoreManager* linphone_core_manager_init(const char* rc_file) {
if( manager_count >= 2){
- char hellopath[512];
- char *recordpath = ms_strdup_printf("%s/record_for_lc_%p.wav",bc_tester_writable_dir_prefix,mgr->lc);
+ char *hellopath = bc_tester_file("sounds/hello8000.wav");
+ char *recordpath = ms_strdup_printf("%s/record_for_lc_%p.wav",bc_tester_get_writable_dir_prefix(),mgr->lc);
ms_message("Manager for '%s' using files", rc_file ? rc_file : "--");
linphone_core_set_use_files(mgr->lc, TRUE);
- snprintf(hellopath,sizeof(hellopath), "%s/sounds/hello8000.wav", bc_tester_read_dir_prefix);
linphone_core_set_play_file(mgr->lc,hellopath);
linphone_core_set_record_file(mgr->lc,recordpath);
ms_free(recordpath);
+ ms_free(hellopath);
}
- linphone_core_set_user_certificates_path(mgr->lc,bc_tester_writable_dir_prefix);
+ linphone_core_set_user_certificates_path(mgr->lc,bc_tester_get_writable_dir_prefix());
if (rc_path) ms_free(rc_path);
@@ -445,7 +445,9 @@ int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr) {
int liblinphone_tester_setup() {
if (manager_count != 0) {
- ms_error("%d linphone core manager still alive!", manager_count);
+ // crash in some linphone core have not been destroyed because if we continue
+ // it will crash in CUnit AND we should NEVER keep a manager alive
+ ms_fatal("%d linphone core manager still alive!", manager_count);
return 1;
}
return 0;
diff --git a/tester/video_tester.c b/tester/video_tester.c
index 5d0115562..843778884 100644
--- a/tester/video_tester.c
+++ b/tester/video_tester.c
@@ -305,7 +305,7 @@ static void two_incoming_early_media_video_calls_test(void) {
/* Configure early media audio to play ring during early-media and send remote ring back tone. */
linphone_core_set_ring_during_incoming_early_media(marie->lc, TRUE);
- ringback_path = ms_strdup_printf("%s/sounds/ringback.wav", bc_tester_read_dir_prefix);
+ ringback_path = bc_tester_res("sounds/ringback.wav");
linphone_core_set_remote_ringback_tone(marie->lc, ringback_path);
ms_free(ringback_path);