tester: update common and display test duration and fix some non removed core managers

parent d8e8f448
mediastreamer2 @ 173e62d6
Subproject commit 20c50eea5e84531555df193db114b588fca383db
Subproject commit 173e62d6c0ec34e89f0f67b0d731150390328b2d
......@@ -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;
......
......@@ -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);
......
......@@ -23,24 +23,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "bc_tester_utils.h"
#include <stdlib.h>
#include <time.h>
#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
/* 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
#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;j<nb_test_suites;j++) {
bc_tester_printf(bc_printf_verbosity_info, "%s", bc_tester_suite_name(j));
......@@ -146,15 +151,19 @@ static void suite_cleanup_failure_message_handler(const CU_pSuite pSuite) {
}
#ifdef HAVE_CU_GET_SUITE
static time_t suite_start_time = 0;
static void suite_start_message_handler(const CU_pSuite pSuite) {
bc_tester_printf(bc_printf_verbosity_info,"Suite [%s] started\n", pSuite->pName);
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 <xml file prefix (will be suffixed by '-Results.xml')>\n"
"\t\t\t--xml-file <xml file name>\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);
}
......@@ -25,8 +25,9 @@
#include <string.h>
#include <math.h>
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,
......
......@@ -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");
......
......@@ -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];
......
......@@ -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) {
......
......@@ -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("<sip:Jehan@sip.linphone.org>");
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("<sip:Jehan@sip.linphone.org>");
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);
}
......
......@@ -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);
......
......@@ -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);
}
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
} </