tester: move from BC_ASSERT_TRUE to more accurate asserts for some tests

This commit is contained in:
Gautier Pelloux-Prayer 2015-05-18 13:55:22 +02:00
parent fd159f62cd
commit 2dc1116da8
4 changed files with 25 additions and 29 deletions

@ -1 +1 @@
Subproject commit 8bd02510cd99b3c246b0959da5494a5e27328df5
Subproject commit ebf5adcbb3a9e48ef5d71635cdfc62ecddba10d4

View file

@ -4105,14 +4105,10 @@ static void simple_stereo_call(const char *codec_name, int clock_rate, int bitra
else{
#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID)
double similar;
const int threshold = 70;
const double threshold = .7f;
BC_ASSERT_EQUAL(ms_audio_diff(stereo_file,recordpath,&similar,audio_cmp_max_shift,NULL,NULL), 0, int, "%d");
BC_ASSERT_TRUE(100*similar >= threshold);
BC_ASSERT_TRUE(100*similar <= 100);
if (threshold < 100*similar && 100*similar <= 100) {
ms_error("similarity is %g", similar);
//remove(recordpath);
}
BC_ASSERT_GREATER(100*similar, threshold, float, "%f");
BC_ASSERT_LOWER(100*similar, 1.f, float, "%f");
#endif
}

View file

@ -142,8 +142,8 @@ extern int CU_assertImplementation(int bValue,
#define BC_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity) _BC_ASSERT_PRED("BC_ASSERT_DOUBLE_NOT_EQUAL_FATAL", ((fabs((double)(cactual) - (cexpected)) > fabs((double)(granularity)))), actual, expected, double, TRUE, "Expected %f but was %f.", cexpected, cactual)
/*Custom defines*/
#define BC_ASSERT_GREATER(actual, lower, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_GREATER", ((cactual) >= (cexpected)), actual, lower, type, FALSE, "Expected " type_format " but was " type_format ".", cexpected, cactual)
#define BC_ASSERT_LOWER(actual, lower, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_LOWER", ((cactual) <= (cexpected)), actual, lower, type, FALSE, "Expected " type_format " but was " type_format ".", cexpected, cactual)
#define BC_ASSERT_GREATER(actual, lower, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_GREATER", ((cactual) >= (cexpected)), actual, lower, type, FALSE, "Expected at least " type_format " but was " type_format ".", cexpected, cactual)
#define BC_ASSERT_LOWER(actual, lower, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_LOWER", ((cactual) <= (cexpected)), actual, lower, type, FALSE, "Expected at most " type_format " but was " type_format ".", cexpected, cactual)
#ifdef __cplusplus
}

View file

@ -104,8 +104,8 @@ static void message_forking_with_unreachable_recipients(void) {
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageDelivered,1,1000));
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1, int, "%d");
BC_ASSERT_TRUE( marie2->stat.number_of_LinphoneMessageReceived==0);
BC_ASSERT_TRUE( marie3->stat.number_of_LinphoneMessageReceived==0);
BC_ASSERT_EQUAL(marie2->stat.number_of_LinphoneMessageReceived, 0, int, "%d");
BC_ASSERT_EQUAL(marie3->stat.number_of_LinphoneMessageReceived, 0, int, "%d");
/*marie 2 goes online */
linphone_core_set_network_reachable(marie2->lc,TRUE);
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneMessageReceived,1,3000));
@ -148,9 +148,9 @@ static void message_forking_with_all_recipients_unreachable(void) {
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageInProgress,1,5000));
/*flexisip will accept the message with 202 after 16 seconds*/
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageDelivered,1,18000));
BC_ASSERT_TRUE( marie->stat.number_of_LinphoneMessageReceived==0);
BC_ASSERT_TRUE( marie2->stat.number_of_LinphoneMessageReceived==0);
BC_ASSERT_TRUE( marie3->stat.number_of_LinphoneMessageReceived==0);
BC_ASSERT_EQUAL( marie->stat.number_of_LinphoneMessageReceived, 0, int, "%d");
BC_ASSERT_EQUAL( marie2->stat.number_of_LinphoneMessageReceived, 0, int, "%d");
BC_ASSERT_EQUAL( marie3->stat.number_of_LinphoneMessageReceived, 0, int, "%d");
/*marie 1 goes online */
linphone_core_set_network_reachable(marie->lc,TRUE);
@ -551,12 +551,12 @@ static void early_media_call_forking(void) {
/*wait a bit that streams are established*/
wait_for_list(lcs,&dummy,1,6000);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>60
&& linphone_call_get_audio_stats(pauline_call)->download_bandwidth<99);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>60
&& linphone_call_get_audio_stats(marie1_call)->download_bandwidth<99);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie2_call)->download_bandwidth>60
&& linphone_call_get_audio_stats(marie2_call)->download_bandwidth<99);
BC_ASSERT_GREATER(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 60, int, "%d");
BC_ASSERT_LOWER(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 99, int, "%d");
BC_ASSERT_GREATER(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 60, int, "%d");
BC_ASSERT_LOWER(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 99, int, "%d");
BC_ASSERT_GREATER(linphone_call_get_audio_stats(marie2_call)->download_bandwidth, 60, int, "%d");
BC_ASSERT_LOWER(linphone_call_get_audio_stats(marie2_call)->download_bandwidth, 99, int, "%d");
linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,3000));
@ -567,10 +567,10 @@ static void early_media_call_forking(void) {
/*wait a bit that streams are established*/
wait_for_list(lcs,&dummy,1,3000);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>60
&& linphone_call_get_audio_stats(pauline_call)->download_bandwidth<99 );
BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>60
&& linphone_call_get_audio_stats(marie1_call)->download_bandwidth<99 );
BC_ASSERT_GREATER(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 60, int, "%d");
BC_ASSERT_LOWER(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 99, int, "%d");
BC_ASSERT_GREATER(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 60, int, "%d");
BC_ASSERT_LOWER(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 99, int, "%d");
linphone_core_terminate_all_calls(pauline->lc);
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000));
@ -610,7 +610,7 @@ static void call_with_sips(void){
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000));
/*pauline2 should not have ring*/
BC_ASSERT_TRUE(pauline2->stat.number_of_LinphoneCallIncomingReceived==0);
BC_ASSERT_EQUAL(pauline2->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d");
linphone_core_terminate_call(pauline1->lc,linphone_core_get_current_call(pauline1->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphoneCallEnd,1,3000));
@ -692,7 +692,7 @@ static void call_with_ipv6(void) {
ct_addr=linphone_address_new(contact);
BC_ASSERT_PTR_NOT_NULL(ct_addr);
if (ct_addr){
BC_ASSERT_TRUE(strchr(linphone_address_get_domain(ct_addr),':')!=NULL);
BC_ASSERT_PTR_NOT_NULL(strchr(linphone_address_get_domain(ct_addr),':'));
}
linphone_address_destroy(ct_addr);
}
@ -706,7 +706,7 @@ static void call_with_ipv6(void) {
liblinphone_tester_enable_ipv6(FALSE);
leaked_objects=belle_sip_object_get_object_count()-begin;
BC_ASSERT_TRUE(leaked_objects==0);
BC_ASSERT_EQUAL(leaked_objects, 0, int, "%d");
if (leaked_objects>0){
belle_sip_object_dump_active_objects();
}
@ -881,7 +881,7 @@ static void dos_module_trigger(void) {
// At this point we should be banned for a minute
ms_usleep(90000000); // Wait 90 seconds to ensure we are not banned anymore
BC_ASSERT_TRUE(marie->stat.number_of_LinphoneMessageReceived < number_of_messge_to_send);
BC_ASSERT_LOWER(marie->stat.number_of_LinphoneMessageReceived, number_of_messge_to_send, int, "%d");
reset_counters(&marie->stat);
reset_counters(&pauline->stat);