From f58754fd814e0978872b3e58754eda908018c882 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 18 Oct 2016 21:22:47 +0200 Subject: [PATCH] fix removal of chatdb and record files after succesfull tests. --- tester/accountmanager.c | 4 ++++ tester/tester.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tester/accountmanager.c b/tester/accountmanager.c index fe56707ae..ada9094b3 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -132,11 +132,13 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf char *tmp; LinphoneAddress *server_addr; LCSipTransports tr; + char *chatdb; vtable.registration_state_changed=account_created_on_server_cb; // TEMPORARY CODE: remove line below when flexisip is updated, this is not needed anymore! vtable.auth_info_requested=account_created_auth_requested_cb; lc=configure_lc_from(&vtable,bc_tester_get_resource_dir_prefix(),NULL,account); + chatdb = ms_strdup(linphone_core_get_chat_database_path(lc)); tr.udp_port=LC_SIP_TRANSPORT_RANDOM; tr.tcp_port=LC_SIP_TRANSPORT_RANDOM; tr.tls_port=LC_SIP_TRANSPORT_RANDOM; @@ -192,6 +194,8 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf ms_error("Account creation could not clean the registration context."); } linphone_core_destroy(lc); + unlink(chatdb); + ms_free(chatdb); } static LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg,const char* phone_alias){ diff --git a/tester/tester.c b/tester/tester.c index 2be8bbdec..6ea047c8c 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -428,7 +428,7 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){ if (mgr->lc) { const char *record_file = linphone_core_get_record_file(mgr->lc); char *chatdb = ms_strdup(linphone_core_get_chat_database_path(mgr->lc)); - if (!liblinphone_tester_keep_record_files && record_file && ortp_file_exist(record_file)) { + if (!liblinphone_tester_keep_record_files && record_file && ortp_file_exist(record_file)==0) { if ((bc_get_number_of_failures() - mgr->number_of_bcunit_error_at_creation)>0) { ms_error("Test has failed, keeping recorded file [%s]", record_file); } @@ -438,7 +438,9 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){ } linphone_core_destroy(mgr->lc); if (chatdb) { - unlink(chatdb); + if (unlink(chatdb) != 0){ + ms_error("Could not delete %s: %s", chatdb, strerror(errno)); + } ms_free(chatdb); } mgr->lc = NULL;