From e5251162800375ba4959cf3a904f75adfdd250eb Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 10 Jun 2016 16:53:23 +0200 Subject: [PATCH] Prevent tester from crashing if error in openning database file --- tester/message_tester.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tester/message_tester.c b/tester/message_tester.c index 5ada03f4e..bf2d160bd 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1201,6 +1201,8 @@ static void database_migration(void) { // the messages.db has 10000 dummy messages with the very first DB scheme. // This will test the migration procedure linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatrooms = linphone_core_get_chat_rooms(marie->lc); BC_ASSERT(ms_list_size(chatrooms) > 0); @@ -1208,6 +1210,7 @@ static void database_migration(void) { // check that all messages have been migrated to the UTC time storage BC_ASSERT(sqlite3_exec(marie->lc->db, "SELECT COUNT(*) FROM history WHERE time != '-1';", check_no_strange_time, NULL, NULL) == SQLITE_OK ); +end: linphone_core_manager_destroy(marie); remove(tmp_db); ms_free(src_db); @@ -1224,6 +1227,8 @@ static void history_range(void){ BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatroom = linphone_core_get_chat_room(marie->lc, jehan_addr); BC_ASSERT_PTR_NOT_NULL(chatroom); @@ -1247,6 +1252,8 @@ static void history_range(void){ history_message_count_helper(chatroom, -2, 2, 3); history_message_count_helper(chatroom, -3, 1, 2); } + +end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); remove(tmp_db); @@ -1265,6 +1272,8 @@ static void history_count(void) { BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatroom = linphone_core_get_chat_room(marie->lc, jehan_addr); BC_ASSERT_PTR_NOT_NULL(chatroom); @@ -1313,6 +1322,8 @@ static void history_count(void) { BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } + +end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); remove(tmp_db); @@ -1378,7 +1389,9 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo if (sql_storage) { linphone_core_set_chat_database_path(marie->lc, marie_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); linphone_core_set_chat_database_path(pauline->lc, pauline_db); + BC_ASSERT_PTR_NOT_NULL(pauline->lc->db); if (do_not_store_rtt_messages_in_sql_storage) { lp_config_set_int(marie->lc->config, "misc", "store_rtt_messages", 0); lp_config_set_int(pauline->lc->config, "misc", "store_rtt_messages", 0);