From 2fc10b13c463a8d779bca6142932c534451c72a0 Mon Sep 17 00:00:00 2001
From: Danmei Chen <danmei.chen@belledonne-communications.com>
Date: Tue, 9 Feb 2021 09:20:52 +0100
Subject: [PATCH] fix some crash for unitest ios

---
 tester/audio_quality_tester.cpp | 5 +++--
 tester/call_single_tester.c     | 2 ++
 tester/rcfiles/laure_rc_udp     | 2 ++
 tester/rcfiles/laure_tcp_rc     | 3 +++
 tester/rcfiles/michelle_rc_udp  | 2 ++
 tester/rcfiles/pauline_tcp_rc   | 3 +++
 6 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/tester/audio_quality_tester.cpp b/tester/audio_quality_tester.cpp
index 12969b19e2..85e086b149 100644
--- a/tester/audio_quality_tester.cpp
+++ b/tester/audio_quality_tester.cpp
@@ -153,11 +153,11 @@ static void audio_mono_call_opus(void){
 }
 
 static void audio_call_loss_resilience(const char *codec_name, int clock_rate, int bitrate_override, int jitterBufferMs, bool_t stereo, std::pair<double,double> threshold ) {
+#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__)
 	LinphoneCoreManager *marie = nullptr, *pauline = nullptr;
 	char *recordPath = nullptr;
 	char *referenceFile = bc_tester_res("sounds/vrroom.wav");
 
-#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__)
 	OrtpNetworkSimulatorParams simparams = { 0 };
 	PayloadType *mariePt, *paulinePt;
 	int sampleLength = 6000;
@@ -258,11 +258,12 @@ static void audio_call_loss_resilience(const char *codec_name, int clock_rate, i
 	}
 
 end:
-#endif
+
 	linphone_core_manager_destroy(marie);
 	linphone_core_manager_destroy(pauline);
 	bc_free(recordPath);
 	bc_free(referenceFile);
+#endif
 }
 
 static void audio_call_loss_resilience_opus(){
diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c
index b2322a7590..7ab4c73085 100644
--- a/tester/call_single_tester.c
+++ b/tester/call_single_tester.c
@@ -2270,6 +2270,8 @@ static void call_paused_resumed_with_loss(void) {
 bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,LinphoneCoreManager* mgr_2,LinphoneCall* call_2) {
 	stats initial_call_stat_1=mgr_1->stat;
 	stats initial_call_stat_2=mgr_2->stat;
+	BC_ASSERT_PTR_NOT_NULL(call_1);
+	if (!call_1) return FALSE;
 	linphone_call_pause(call_1);
 	BC_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_1->stat.number_of_LinphoneCallPausing,initial_call_stat_1.number_of_LinphoneCallPausing+1));
 	BC_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_1->stat.number_of_LinphoneCallPaused,initial_call_stat_1.number_of_LinphoneCallPaused+1));
diff --git a/tester/rcfiles/laure_rc_udp b/tester/rcfiles/laure_rc_udp
index 9653ab6df9..8258d6a8dd 100644
--- a/tester/rcfiles/laure_rc_udp
+++ b/tester/rcfiles/laure_rc_udp
@@ -45,3 +45,5 @@ echocancellation=0 #to not overload cpu in case of VG
 
 stun_server=stun.example.org
 
+[tester]
+test_env=1
diff --git a/tester/rcfiles/laure_tcp_rc b/tester/rcfiles/laure_tcp_rc
index 8a09580194..729dc1285a 100644
--- a/tester/rcfiles/laure_tcp_rc
+++ b/tester/rcfiles/laure_tcp_rc
@@ -46,3 +46,6 @@ stun_server=stun.example.org
 [misc]
 hide_chat_rooms_from_removed_proxies=0
 hide_empty_chat_rooms=0
+
+[tester]
+test_env=1
diff --git a/tester/rcfiles/michelle_rc_udp b/tester/rcfiles/michelle_rc_udp
index 336bfb709b..2e857ce8b7 100644
--- a/tester/rcfiles/michelle_rc_udp
+++ b/tester/rcfiles/michelle_rc_udp
@@ -42,3 +42,5 @@ echocancellation=0 #to not overload cpu in case of VG
 
 stun_server=stun.linphone.org
 
+[tester]
+test_env=1
diff --git a/tester/rcfiles/pauline_tcp_rc b/tester/rcfiles/pauline_tcp_rc
index 213d81965f..e48ff70189 100644
--- a/tester/rcfiles/pauline_tcp_rc
+++ b/tester/rcfiles/pauline_tcp_rc
@@ -49,3 +49,6 @@ echocancellation=0 #to not overload cpu in case of VG
 
 [net]
 stun_server=stun.example.org
+
+[tester]
+test_env=1
-- 
GitLab