mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 00:59:20 +00:00
fix build and robustize tests
This commit is contained in:
parent
ffe22a6d7d
commit
a3c33f5036
4 changed files with 74 additions and 50 deletions
|
|
@ -32,6 +32,7 @@ gtk/audio_assistant.c
|
|||
[type: gettext/glade]gtk/ldap.ui
|
||||
[type: gettext/glade]gtk/config-uri.ui
|
||||
[type: gettext/glade]gtk/provisioning-fetch.ui
|
||||
[type: gettext/glade]gtk/chat_view.ui
|
||||
coreapi/linphonecore.c
|
||||
coreapi/misc.c
|
||||
coreapi/presence.c
|
||||
|
|
|
|||
|
|
@ -634,7 +634,6 @@ static void multiple_answers_call_with_media_relay(void) {
|
|||
static void call_with_specified_codec_bitrate(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
const LinphoneCallStats *pauline_stats,*marie_stats;
|
||||
bool_t call_ok;
|
||||
const char * codec = "opus";
|
||||
int rate = 48000;
|
||||
|
|
@ -676,13 +675,12 @@ static void call_with_specified_codec_bitrate(void) {
|
|||
/*wait a bit that bitstreams are stabilized*/
|
||||
wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
|
||||
|
||||
marie_stats=linphone_call_get_audio_stats(linphone_core_get_current_call(marie->lc));
|
||||
pauline_stats=linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc));
|
||||
|
||||
BC_ASSERT_LOWER(marie_stats->download_bandwidth, min_bw+5+min_bw*.1, int, "%i");
|
||||
BC_ASSERT_GREATER(marie_stats->download_bandwidth, 10, int, "%i"); /*check that at least something is received */
|
||||
BC_ASSERT_GREATER(pauline_stats->download_bandwidth, (max_bw-5-max_bw*.1), int, "%i");
|
||||
|
||||
BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_down_bw(marie), min_bw+5+min_bw*.1, int, "%i");
|
||||
BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie), 10, int, "%i"); /*check that at least something is received */
|
||||
BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(pauline), (max_bw-5-max_bw*.1), int, "%i");
|
||||
linphone_core_terminate_all_calls(pauline->lc);
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
|
||||
end:
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
|
|
@ -2312,52 +2310,57 @@ static void call_with_file_player(void) {
|
|||
char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav");
|
||||
char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav");
|
||||
bool_t call_ok;
|
||||
int attempts;
|
||||
double similar=1;
|
||||
const double threshold = 0.9;
|
||||
|
||||
/*this test is actually attempted three times in case of failure, because the audio comparison at the end is very sensitive to
|
||||
* jitter buffer drifts, which sometimes happen if the machine is unable to run the test in good realtime conditions */
|
||||
for (attempts=0; attempts<3; attempts++){
|
||||
reset_counters(&marie->stat);
|
||||
reset_counters(&pauline->stat);
|
||||
/*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
|
||||
unlink(recordpath);
|
||||
/*caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player*/
|
||||
linphone_core_use_files(marie->lc,TRUE);
|
||||
linphone_core_set_play_file(marie->lc,NULL);
|
||||
|
||||
/*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
|
||||
unlink(recordpath);
|
||||
/*callee is recording and plays file*/
|
||||
linphone_core_use_files(pauline->lc,TRUE);
|
||||
linphone_core_set_play_file(pauline->lc,NULL);
|
||||
linphone_core_set_record_file(pauline->lc,recordpath);
|
||||
|
||||
|
||||
/*caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player*/
|
||||
linphone_core_use_files(marie->lc,TRUE);
|
||||
linphone_core_set_play_file(marie->lc,NULL);
|
||||
|
||||
/*callee is recording and plays file*/
|
||||
linphone_core_use_files(pauline->lc,TRUE);
|
||||
linphone_core_set_play_file(pauline->lc,NULL);
|
||||
linphone_core_set_record_file(pauline->lc,recordpath);
|
||||
|
||||
BC_ASSERT_TRUE((call_ok=call(marie,pauline)));
|
||||
if (!call_ok) goto end;
|
||||
player=linphone_call_get_player(linphone_core_get_current_call(marie->lc));
|
||||
BC_ASSERT_PTR_NOT_NULL(player);
|
||||
if (player){
|
||||
BC_ASSERT_TRUE(linphone_player_open(player,hellopath,on_eof,marie)==0);
|
||||
BC_ASSERT_TRUE(linphone_player_start(player)==0);
|
||||
}
|
||||
|
||||
/* This assert should be modified to be at least as long as the WAV file */
|
||||
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_player_eof,1,10000));
|
||||
|
||||
/*just to sleep*/
|
||||
linphone_core_terminate_all_calls(marie->lc);
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
|
||||
/*cannot run on iphone simulator because locks main loop beyond permitted time (should run
|
||||
on another thread) */
|
||||
#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID)
|
||||
{
|
||||
double similar;
|
||||
const int threshold = 90;
|
||||
BC_ASSERT_EQUAL(ms_audio_diff(hellopath,recordpath,&similar,audio_cmp_max_shift,NULL,NULL), 0, int, "%d");
|
||||
BC_ASSERT_GREATER(100*similar, threshold, int, "%d");
|
||||
BC_ASSERT_LOWER(100*similar, 100, int, "%d");
|
||||
if (threshold < 100*similar && 100*similar < 100) {
|
||||
remove(recordpath);
|
||||
BC_ASSERT_TRUE((call_ok=call(marie,pauline)));
|
||||
if (!call_ok) goto end;
|
||||
player=linphone_call_get_player(linphone_core_get_current_call(marie->lc));
|
||||
BC_ASSERT_PTR_NOT_NULL(player);
|
||||
if (player){
|
||||
BC_ASSERT_TRUE(linphone_player_open(player,hellopath,on_eof,marie)==0);
|
||||
BC_ASSERT_TRUE(linphone_player_start(player)==0);
|
||||
}
|
||||
}
|
||||
|
||||
/* This assert should be modified to be at least as long as the WAV file */
|
||||
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_player_eof,1,10000));
|
||||
|
||||
/*just to sleep*/
|
||||
linphone_core_terminate_all_calls(marie->lc);
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
|
||||
/*cannot run on iphone simulator because locks main loop beyond permitted time (should run
|
||||
on another thread) */
|
||||
#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID)
|
||||
BC_ASSERT_EQUAL(ms_audio_diff(hellopath,recordpath,&similar,audio_cmp_max_shift,NULL,NULL), 0, int, "%d");
|
||||
if (similar>=threshold)
|
||||
break;
|
||||
#else
|
||||
remove(recordpath);
|
||||
remove(recordpath);
|
||||
#endif
|
||||
}
|
||||
BC_ASSERT_GREATER(similar, threshold, double, "%g");
|
||||
BC_ASSERT_LOWER(similar, 1.0, double, "%g");
|
||||
if (similar >= threshold && similar <= 1.0) {
|
||||
remove(recordpath);
|
||||
}
|
||||
end:
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
|
|
|
|||
|
|
@ -325,6 +325,9 @@ static const int audio_cmp_max_shift=20;
|
|||
* this function return max value in the last 3 seconds*/
|
||||
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr);
|
||||
int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr);
|
||||
int linphone_core_manager_get_mean_audio_down_bw(const LinphoneCoreManager *mgr);
|
||||
int linphone_core_manager_get_mean_audio_up_bw(const LinphoneCoreManager *mgr);
|
||||
|
||||
void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled);
|
||||
|
||||
int liblinphone_tester_setup();
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ void liblinphone_tester_add_suites() {
|
|||
bc_tester_add_suite(&proxy_config_test_suite);
|
||||
}
|
||||
|
||||
static bool_t linphone_core_manager_get_max_audio_bw_base(const int array[],int array_size) {
|
||||
static int linphone_core_manager_get_max_audio_bw_base(const int array[],int array_size) {
|
||||
int i,result=0;
|
||||
for (i=0; i<array_size; i++) {
|
||||
result = MAX(result,array[i]);
|
||||
|
|
@ -439,6 +439,14 @@ static bool_t linphone_core_manager_get_max_audio_bw_base(const int array[],int
|
|||
return result;
|
||||
}
|
||||
|
||||
static int linphone_core_manager_get_mean_audio_bw_base(const int array[],int array_size) {
|
||||
int i,result=0;
|
||||
for (i=0; i<array_size; i++) {
|
||||
result += array[i];
|
||||
}
|
||||
return result/array_size;
|
||||
}
|
||||
|
||||
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr) {
|
||||
return linphone_core_manager_get_max_audio_bw_base(mgr->stat.audio_download_bandwidth
|
||||
, sizeof(mgr->stat.audio_download_bandwidth)/sizeof(int));
|
||||
|
|
@ -448,6 +456,15 @@ int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr) {
|
|||
, sizeof(mgr->stat.audio_upload_bandwidth)/sizeof(int));
|
||||
}
|
||||
|
||||
int linphone_core_manager_get_mean_audio_down_bw(const LinphoneCoreManager *mgr) {
|
||||
return linphone_core_manager_get_mean_audio_bw_base(mgr->stat.audio_download_bandwidth
|
||||
, sizeof(mgr->stat.audio_download_bandwidth)/sizeof(int));
|
||||
}
|
||||
int linphone_core_manager_get_mean_audio_up_bw(const LinphoneCoreManager *mgr) {
|
||||
return linphone_core_manager_get_mean_audio_bw_base(mgr->stat.audio_upload_bandwidth
|
||||
, sizeof(mgr->stat.audio_upload_bandwidth)/sizeof(int));
|
||||
}
|
||||
|
||||
int liblinphone_tester_setup() {
|
||||
if (manager_count != 0) {
|
||||
// crash in some linphone core have not been destroyed because if we continue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue