From ff3ff7aec1e396390fa2ff27ec7974690ef61236 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 16 Sep 2016 09:10:35 +0200 Subject: [PATCH] fix logs and ipv6 enablement in tester. --- coreapi/linphonecore.c | 16 ++++++++-------- tester/accountmanager.c | 5 ++++- tester/call_single_tester.c | 25 +++++++++---------------- tester/liblinphone_tester.c | 9 ++++++--- tester/liblinphone_tester.h | 1 + tester/tester.c | 35 ++++++++++++++++++----------------- 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3c4284e97..7df7fc502 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7727,15 +7727,15 @@ const char * linphone_core_get_video_preset(const LinphoneCore *lc) { #ifdef ANDROID static int linphone_core_call_void_method(jobject obj, jmethodID id) { JNIEnv *env=ms_get_jni_env(); - if (env && obj) { - (*env)->CallVoidMethod(env,obj,id); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionClear(env); - return -1; - } else - return 0; - } else + if (env && obj) { + (*env)->CallVoidMethod(env,obj,id); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionClear(env); return -1; + } else + return 0; + } else + return -1; } void linphone_core_wifi_lock_acquire(LinphoneCore *lc) { diff --git a/tester/accountmanager.c b/tester/accountmanager.c index 18e9055ae..fe56707ae 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -245,9 +245,12 @@ static LinphoneAddress *account_manager_check_account(AccountManager *m, Linphon void linphone_core_manager_check_accounts(LinphoneCoreManager *m){ const bctbx_list_t *it; AccountManager *am=account_manager_get(); - + int logmask = ortp_get_log_level_mask(NULL); + + if (!liblinphonetester_show_account_manager_logs) linphone_core_set_log_level_mask(ORTP_ERROR|ORTP_FATAL); for(it=linphone_core_get_proxy_config_list(m->lc);it!=NULL;it=it->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)it->data; account_manager_check_account(am,cfg,m->phone_alias); } + if (!liblinphonetester_show_account_manager_logs) linphone_core_set_log_level_mask(logmask); } diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index ed1d25e52..c3f65ac5c 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -4853,9 +4853,6 @@ static void v6_call_over_nat_64(void){ if (!liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ - bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/ - liblinphonetester_ipv6=TRUE; - marie = linphone_core_manager_new("marie_nat64_rc"); pauline = linphone_core_manager_new("pauline_nat64_rc"); @@ -4872,26 +4869,22 @@ static void v6_call_over_nat_64(void){ end_call(marie,pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/ }else ms_warning("Test skipped, no ipv6 nat64 available"); } static void call_with_ice_in_ipv4_with_v6_enabled(void) { - LinphoneCoreManager* marie; - LinphoneCoreManager* pauline; + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; - if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ - bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/ - liblinphonetester_ipv6=TRUE; - marie = linphone_core_manager_new("marie_v4proxy_rc"); - pauline = linphone_core_manager_new("pauline_v4proxy_rc"); + if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ + marie = linphone_core_manager_new("marie_v4proxy_rc"); + pauline = linphone_core_manager_new("pauline_v4proxy_rc"); - _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/ - } else ms_warning("Test skipped, need both ipv6 and v4 available"); + _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + } else ms_warning("Test skipped, need both ipv6 and v4 available"); } test_t call_tests[] = { diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 9e16c0884..1e33d6c78 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -213,7 +213,8 @@ static const char* liblinphone_helper = "\t\t\t--keep-recorded-files\n" "\t\t\t--disable-leak-detector\n" "\t\t\t--disable-tls-support\n" - "\t\t\t--6\n" + "\t\t\t--no-ipv6 (turn off IPv6 in LinphoneCore, tests requiring IPv6 will be skipped)\n" + "\t\t\t--show-account-manager-logs (show temporary test account creation logs)\n" ; int main (int argc, char *argv[]) @@ -255,8 +256,10 @@ int main (int argc, char *argv[]) liblinphone_tester_disable_leak_detector(TRUE); } else if (strcmp(argv[i],"--disable-tls-support")==0){ liblinphone_tester_tls_support_disabled = TRUE; - } else if (strcmp(argv[i],"--6")==0){ - liblinphonetester_ipv6=TRUE; + } else if (strcmp(argv[i],"--no-ipv6")==0){ + liblinphonetester_ipv6 = FALSE; + } else if (strcmp(argv[i],"--show-account-manager-logs")==0){ + liblinphonetester_show_account_manager_logs=TRUE; } else { int bret = bc_tester_parse_args(argc, argv, i); if (bret>0) { diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 92483d38c..ca26e2359 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -114,6 +114,7 @@ extern bool_t liblinphone_tester_tls_support_disabled; extern const MSAudioDiffParams audio_cmp_params; extern const char *liblinphone_tester_mire_id; extern bool_t liblinphonetester_ipv6; +extern bool_t liblinphonetester_show_account_manager_logs; typedef struct _stats { int number_of_LinphoneRegistrationNone; diff --git a/tester/tester.c b/tester/tester.c index 5a4393003..f2a5b531e 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -56,7 +56,8 @@ const char* test_username="liblinphone_tester"; const char* test_password="secret"; const char* test_route="sip2.linphone.org"; const char *userhostsfile = "tester_hosts"; -bool_t liblinphonetester_ipv6 = FALSE; +bool_t liblinphonetester_ipv6 = TRUE; +bool_t liblinphonetester_show_account_manager_logs = FALSE; const char *liblinphone_tester_mire_id="Mire: Mire (synthetic moving picture)"; @@ -402,12 +403,10 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies } LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) { - int old_log_level = ortp_get_log_level_mask(NULL); LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1); - linphone_core_set_log_level(ORTP_ERROR); + linphone_core_manager_init(manager, rc_file, phone_alias); linphone_core_manager_start(manager, check_for_proxies); - linphone_core_set_log_level(old_log_level); return manager; } @@ -476,19 +475,21 @@ void linphone_core_manager_destroy(LinphoneCoreManager* mgr) { } int liblinphone_tester_ipv6_available(void){ - struct addrinfo *ai=bctbx_ip_address_to_addrinfo(AF_INET6,SOCK_STREAM,"2a01:e00::2",53); - if (ai){ - struct sockaddr_storage ss; - struct addrinfo src; - socklen_t slen=sizeof(ss); - char localip[128]; - int port=0; - belle_sip_get_src_addr_for(ai->ai_addr,(socklen_t)ai->ai_addrlen,(struct sockaddr*) &ss,&slen,4444); - src.ai_addr=(struct sockaddr*) &ss; - src.ai_addrlen=slen; - bctbx_addrinfo_to_ip_address(&src,localip, sizeof(localip),&port); - freeaddrinfo(ai); - return strcmp(localip,"::1")!=0; + if (liblinphonetester_ipv6) { + struct addrinfo *ai=bctbx_ip_address_to_addrinfo(AF_INET6,SOCK_STREAM,"2a01:e00::2",53); + if (ai){ + struct sockaddr_storage ss; + struct addrinfo src; + socklen_t slen=sizeof(ss); + char localip[128]; + int port=0; + belle_sip_get_src_addr_for(ai->ai_addr,(socklen_t)ai->ai_addrlen,(struct sockaddr*) &ss,&slen,4444); + src.ai_addr=(struct sockaddr*) &ss; + src.ai_addrlen=slen; + bctbx_addrinfo_to_ip_address(&src,localip, sizeof(localip),&port); + freeaddrinfo(ai); + return strcmp(localip,"::1")!=0; + } } return FALSE; }