Commit edbf1330 authored by Simon Morlat's avatar Simon Morlat

Add several fixes to allow the liblinphone_tester in parallel mode to run to the end without crash.

parent edab1395
......@@ -62,11 +62,13 @@ void CorePrivate::init () {
uri = q->getDataPath() + LINPHONE_DB;
}
lInfo() << "Opening linphone database: " << uri;
if (!mainDb->connect(backend, uri))
lFatal() << "Unable to open linphone database.";
if (uri != "null"){ //special uri "null" means don't open database. We need this for tests.
lInfo() << "Opening linphone database " << uri << " with backend " << backend;
if (!mainDb->connect(backend, uri))
lFatal() << "Unable to open linphone database with uri " << uri << " and backend " << backend;
loadChatRooms();
loadChatRooms();
}else lWarning() << "Database explicitely not requested, this Core is built with no database support.";
}
void CorePrivate::registerListener (CoreListener *listener) {
......
......@@ -75,7 +75,7 @@ bool AbstractDb::connect (Backend backend, const string &parameters) {
try {
d->safeInit();
} catch (const exception &e) {
lWarning() << "Unable to init database: " << e.what();
lError() << "Unable to init database: " << e.what();
// Reset session.
d->dbSession = DbSession();
......@@ -138,4 +138,16 @@ void AbstractDb::init () {
// Nothing.
}
std::ostream& operator<<(std::ostream& os, AbstractDb::Backend b){
switch(b){
case AbstractDb::Mysql:
os<<"Mysql";
break;
case AbstractDb::Sqlite3:
os<<"Sqlite3";
break;
}
return os;
}
LINPHONE_END_NAMESPACE
......@@ -57,6 +57,8 @@ private:
L_DISABLE_COPY(AbstractDb);
};
std::ostream& operator<<(std::ostream& os, AbstractDb::Backend b);
LINPHONE_END_NAMESPACE
#endif // ifndef _L_ABSTRACT_DB_H_
......@@ -266,7 +266,7 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
linphone_core_cbs_set_registration_state_changed(cbs, account_created_on_server_cb);
LinphoneCore *lc = configure_lc_from(cbs, bc_tester_get_resource_dir_prefix(), NULL, account);
linphone_core_cbs_unref(cbs);
LinphoneSipTransports tr;
LinphoneSipTransports tr = {0};
tr.udp_port = LC_SIP_TRANSPORT_RANDOM;
tr.tcp_port = LC_SIP_TRANSPORT_RANDOM;
tr.tls_port = LC_SIP_TRANSPORT_RANDOM;
......@@ -302,7 +302,7 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
linphone_account_creator_create_account(creator);
if (wait_for_until(lc, NULL, &state.account_created, TRUE, 3000) == FALSE)
if (wait_for_until(lc, NULL, &state.account_created, TRUE, 15000) == FALSE)
ms_fatal("Could not create account %s on db", linphone_proxy_config_get_identity(cfg));
LinphoneAuthInfo *ai = linphone_auth_info_new(username, NULL, password, NULL, domain, domain);
......@@ -313,7 +313,7 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
linphone_account_creator_cbs_set_get_confirmation_key(creator_cbs, get_confirmation_key_cb);
linphone_account_creator_get_confirmation_key(creator);
if (wait_for_until(lc, NULL, &state.confirmation_key_received, TRUE, 3000) == FALSE)
if (wait_for_until(lc, NULL, &state.confirmation_key_received, TRUE, 15000) == FALSE)
ms_fatal("Could not get confirmation key for account %s", linphone_proxy_config_get_identity(cfg));
// activate account
......@@ -323,7 +323,7 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
else
linphone_account_creator_activate_email_account_linphone(creator);
if (wait_for_until(lc, NULL, &state.account_activated, TRUE, 3000) == FALSE)
if (wait_for_until(lc, NULL, &state.account_activated, TRUE, 15000) == FALSE)
ms_fatal("Could not activate account %s", linphone_proxy_config_get_identity(cfg));
linphone_account_creator_set_proxy_config(creator, default_cfg);
......
......@@ -465,6 +465,9 @@ FILE *sip_start(const char *senario, const char* dest_username, const char *pass
void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice );
void linphone_conf_event_notify(LinphoneEvent *lev);
/*Convenience function providing the path to the "empty_rc" config file*/
const char *liblinphone_tester_get_empty_rc(void);
#ifdef __cplusplus
};
#endif
......
......@@ -35,7 +35,7 @@ static int get_codec_position(const MSList *l, const char *mime_type, int rate){
/*check basic things about codecs at startup: order and enablement*/
static void start_with_no_config(void){
LinphoneCore *lc=linphone_factory_create_core_2(linphone_factory_get(), NULL, NULL, NULL, NULL, system_context);
LinphoneCore *lc=linphone_factory_create_core_3(linphone_factory_get(), NULL, liblinphone_tester_get_empty_rc(), system_context);
const MSList *codecs=linphone_core_get_audio_codecs(lc);
int opus_codec_pos;
int speex_codec_pos=get_codec_position(codecs, "speex", 8000);
......
[net]
mtu=1300
[sip]
ping_with_options=0
sip_random_port=1
\ No newline at end of file
sip_random_port=1
[storage]
#this will explicitely request to not use database. We need this for a few tests where multiple cores are instanciated, so that they don't
#try to connect to the same default sqlite3 database.
uri=null
......@@ -125,7 +125,7 @@ static void linphone_version_test(void){
static void core_init_test(void) {
LinphoneCore* lc;
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,NULL, NULL, system_context);
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,liblinphone_tester_get_empty_rc(), NULL, system_context);
/* until we have good certificates on our test server... */
linphone_core_verify_server_certificates(lc,FALSE);
......@@ -152,7 +152,7 @@ static void linphone_address_test(void) {
static void core_sip_transport_test(void) {
LinphoneCore* lc;
LCSipTransports tr;
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,NULL, NULL, system_context);
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,liblinphone_tester_get_empty_rc(), NULL, system_context);
if (!BC_ASSERT_PTR_NOT_NULL(lc)) return;
linphone_core_get_sip_transports(lc,&tr);
BC_ASSERT_EQUAL(tr.udp_port,5060, int, "%d"); /*default config*/
......@@ -181,7 +181,7 @@ static void linphone_interpret_url_test(void) {
LinphoneAddress* address;
LinphoneProxyConfig *proxy_config;
char *tmp;
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,NULL, NULL, system_context);
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL, NULL, liblinphone_tester_get_empty_rc(), NULL, system_context);
if (!BC_ASSERT_PTR_NOT_NULL( lc )) return;
proxy_config =linphone_core_create_proxy_config(lc);
......@@ -374,7 +374,7 @@ void linphone_proxy_config_is_server_config_changed_test(void) {
static void chat_room_test(void) {
LinphoneCore* lc;
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL,NULL, NULL, system_context);
lc = linphone_factory_create_core_2(linphone_factory_get(),NULL,NULL, liblinphone_tester_get_empty_rc(), NULL, system_context);
if (!BC_ASSERT_PTR_NOT_NULL(lc)) return;
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room_from_uri(lc,"sip:toto@titi.com"));
linphone_core_unref(lc);
......
......@@ -35,6 +35,7 @@ extern jobject system_context;
void *system_context=0;
#endif
static char *liblinphone_tester_empty_rc_path = NULL;
static int liblinphone_tester_keep_accounts_flag = 0;
static bool_t liblinphone_tester_keep_record_files = FALSE;
static bool_t liblinphone_tester_leak_detector_disabled = FALSE;
......@@ -153,7 +154,8 @@ LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, const ch
lp_config_set_string(config, "sip", "root_ca" , rootcapath);
lc = linphone_factory_create_core_with_config_3(linphone_factory_get(), config, system_context);
} else {
lc = linphone_factory_create_core_3(linphone_factory_get(), NULL, (filepath && (filepath[0] != '\0')) ? filepath : NULL, system_context);
lc = linphone_factory_create_core_3(linphone_factory_get(), NULL, (filepath && (filepath[0] != '\0')) ? filepath :
liblinphone_tester_get_empty_rc(), system_context);
linphone_core_set_ring(lc, ringpath);
linphone_core_set_ringback(lc, ringbackpath);
linphone_core_set_root_ca(lc,rootcapath);
......@@ -1051,3 +1053,11 @@ void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv) {
linphone_core_cbs_unref(conf_srv->cbs);
linphone_core_manager_destroy((LinphoneCoreManager *)conf_srv);
}
const char *liblinphone_tester_get_empty_rc(void){
if (liblinphone_tester_empty_rc_path == NULL){
liblinphone_tester_empty_rc_path = bc_tester_res("rcfiles/empty_rc");
}
return liblinphone_tester_empty_rc_path;
}
......@@ -264,7 +264,7 @@ static void friends_sqlite_storage(void) {
cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_friend_list_created(cbs, friend_list_created_cb);
linphone_core_cbs_set_friend_list_removed(cbs, friend_list_removed_cb);
lc = linphone_factory_create_core_2(linphone_factory_get(), cbs, NULL, NULL, NULL, system_context);
lc = linphone_factory_create_core_2(linphone_factory_get(), cbs, NULL, liblinphone_tester_get_empty_rc(), NULL, system_context);
linphone_core_cbs_unref(cbs);
friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc));
lfl = linphone_core_create_friend_list(lc);
......@@ -357,7 +357,7 @@ end:
}
static void friends_sqlite_store_lot_of_friends(void) {
LinphoneCore* lc = linphone_factory_create_core_2(linphone_factory_get(), NULL, NULL, NULL, NULL, system_context);
LinphoneCore* lc = linphone_factory_create_core_2(linphone_factory_get(), NULL, NULL, liblinphone_tester_get_empty_rc(), NULL, system_context);
sqlite3 *db;
int i;
char* errmsg = NULL;
......@@ -427,7 +427,7 @@ static void friends_sqlite_store_lot_of_friends(void) {
}
static void friends_sqlite_find_friend_in_lot_of_friends(void) {
LinphoneCore* lc = linphone_factory_create_core_2(linphone_factory_get(), NULL, NULL, NULL, NULL, system_context);
LinphoneCore* lc = linphone_factory_create_core_2(linphone_factory_get(), NULL, NULL, liblinphone_tester_get_empty_rc(), NULL, system_context);
sqlite3 *db;
int i;
char* errmsg = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment