From 2ad32695a54aa0d33d49b9847facf926b86cc7ef Mon Sep 17 00:00:00 2001
From: Simon Morlat <simon.morlat@linphone.org>
Date: Tue, 13 Dec 2016 22:25:52 +0100
Subject: [PATCH] adjust timers and document a test that tends to fail
 sometimes.

---
 tester/presence_server_tester.c | 18 ++++++++++++------
 tester/tester.c                 |  2 +-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/tester/presence_server_tester.c b/tester/presence_server_tester.c
index 6bd5248368..dcb1cb4cf1 100644
--- a/tester/presence_server_tester.c
+++ b/tester/presence_server_tester.c
@@ -140,7 +140,7 @@ static void subscriber_no_longer_reachable(void){
 	lcs = bctbx_list_append(lcs, marie->lc);
 	lcs = bctbx_list_append(lcs, pauline1->lc);
 
-	lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 60);
+	lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 80);
 	linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL);
 	linphone_core_set_user_agent(pauline1->lc, "full-presence-support", NULL);
 
@@ -152,7 +152,7 @@ static void subscriber_no_longer_reachable(void){
 
 	linphone_core_add_friend(marie->lc, lf);
 	linphone_friend_unref(lf);
-	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceBasicStatusOpen,1, 2000));
+	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceBasicStatusOpen,1, 5000));
 
 	/*make sure marie subscribe is not reset by accident because of code below located in linphone_core_iterate
 
@@ -173,16 +173,22 @@ static void subscriber_no_longer_reachable(void){
 
 	//sal_set_send_error(marie->lc->sal,0);
 
-	/*because of notify timeout detected by server, so subscription is reset*/
+	/*
+	 * Because of notify timeout detected by server, subscription is reset.
+	 * The server then sends a NOTIFY with subscription-state terminated, which translated in Offline status to be notified.
+	 */
 	previous_number_of_LinphonePresenceActivityOffline = marie->stat.number_of_LinphonePresenceBasicStatusClosed;
 	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOffline,previous_number_of_LinphonePresenceActivityOffline+1, 4000));
 
-	// now subscription is supposed to be dead because notify was not answered in time.
+	/*
+	 * The client handles this subscription terminated event.
+	 * It will not resubmit a new SUBSCRIBE until expiration of the current one.
+	 */
 	presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline,NULL);
 	linphone_core_set_presence_model(pauline1->lc,presence);
 
-	/*because subscription not is automatically restarted*/
-	BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,previous_number_of_LinphonePresenceActivityOnline+1, 4000));
+	/*because subscription is not restarted, the online status shall not be notified again.*/
+	BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,previous_number_of_LinphonePresenceActivityOnline+1, 8000));
 
 	linphone_core_manager_destroy(marie);
 	linphone_core_manager_destroy(pauline1);
diff --git a/tester/tester.c b/tester/tester.c
index fdfea8af9c..2c719bbbda 100644
--- a/tester/tester.c
+++ b/tester/tester.c
@@ -438,7 +438,7 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){
 			}
 		}
 		linphone_core_destroy(mgr->lc);
-		if (chatdb) {
+		if (chatdb && ortp_file_exist(chatdb)==0) {
 			if (unlink(chatdb) != 0){
 				ms_error("Could not delete %s: %s", chatdb, strerror(errno));
 			}
-- 
GitLab