tester: reworks BC_macro usage

parent 3b5ca834
......@@ -105,16 +105,16 @@ static void test_generate_and_parse_certificates(void) {
/* get pem version of generated and parsed certificate and compare them */
pem_certificate = belle_sip_certificates_chain_get_pem(certificate);
BC_ASSERT_TRUE_FATAL(pem_certificate!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(pem_certificate);
pem_parsed_certificate = belle_sip_certificates_chain_get_pem(parsed_certificate);
BC_ASSERT_TRUE_FATAL(pem_parsed_certificate!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(pem_parsed_certificate);
BC_ASSERT_STRING_EQUAL(pem_certificate, pem_parsed_certificate);
/* get pem version of generated and parsed key and compare them */
pem_key = belle_sip_signing_key_get_pem(key);
BC_ASSERT_TRUE_FATAL(pem_key!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(pem_key);
pem_parsed_key = belle_sip_signing_key_get_pem(parsed_key);
BC_ASSERT_TRUE_FATAL(pem_parsed_key!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(pem_parsed_key);
BC_ASSERT_STRING_EQUAL(pem_key, pem_parsed_key);
belle_sip_free(pem_certificate);
......@@ -170,7 +170,7 @@ static void test_certificate_fingerprint(void) {
/* generate fingerprint */
fingerprint = belle_sip_certificates_chain_get_fingerprint(cert);
BC_ASSERT_TRUE_FATAL(fingerprint!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(fingerprint);
BC_ASSERT_STRING_EQUAL(fingerprint, belle_sip_tester_client_cert_fingerprint);
belle_sip_free(fingerprint);
......@@ -181,7 +181,7 @@ static void test_certificate_fingerprint(void) {
/* generate fingerprint */
fingerprint = belle_sip_certificates_chain_get_fingerprint(cert);
BC_ASSERT_TRUE_FATAL(fingerprint!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(fingerprint);
BC_ASSERT_STRING_EQUAL(fingerprint, belle_sip_tester_fingerprint256_cert_fingerprint);
belle_sip_free(fingerprint);
......
......@@ -84,7 +84,7 @@ static int http_before_all(void) {
belle_tls_crypto_config_set_root_ca(crypto_config,belle_sip_tester_get_root_ca_path());
belle_http_provider_set_tls_crypto_config(prov,crypto_config);
belle_sip_object_unref(crypto_config);
}
return 0;
}
......@@ -132,8 +132,8 @@ static int one_get(const char *url,http_counters_t* counters, int *counter){
static void one_http_get(void){
http_counters_t counters={0};
if (one_get("http://smtp.linphone.org",&counters,&counters.response_count) == 0) {
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.response_count,1,int,"%d");
BC_ASSERT_EQUAL(counters.io_error_count,0,int,"%d");
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
}
}
......@@ -141,8 +141,8 @@ static void one_http_get(void){
static void http_get_empty_body(void){
http_counters_t counters={0};
if (one_get("http://smtp.linphone.org/marie_invalid",&counters,&counters.response_count) == 0) {
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.response_count,1,int,"%d");
BC_ASSERT_EQUAL(counters.io_error_count,0,int,"%d");
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
}
}
......@@ -216,7 +216,7 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *
size_t end_of_img=sizeof(MULTIPART_BEGIN)+image_size;
if (offset==0){
size_t partlen=sizeof(MULTIPART_BEGIN);
BC_ASSERT_TRUE_FATAL(partlen<*size);
BC_ASSERT_LOWER_STRICT(partlen,*size,int,"%d");
memcpy(buffer,MULTIPART_BEGIN,partlen);
*size=partlen;
}else if (offset<end_of_img){
......@@ -314,12 +314,12 @@ static void http_get_long_user_body(void){
belle_sip_object_data_set(BELLE_SIP_OBJECT(req),"file",outfile,NULL);
belle_http_provider_send_request(prov,req,l);
BC_ASSERT_TRUE(wait_for(stack,&counters.two_hundred,1,20000));
BC_ASSERT_TRUE(counters.response_headers_count==1);
BC_ASSERT_EQUAL(counters.response_headers_count,1,int,"%d");
resp=belle_http_request_get_response(req);
BC_ASSERT_PTR_NOT_NULL(resp);
if (resp){
bh=belle_sip_message_get_body_handler((belle_sip_message_t*)resp);
BC_ASSERT_TRUE(belle_sip_body_handler_get_size(bh)>0);
BC_ASSERT_GREATER_STRICT(belle_sip_body_handler_get_size(bh),0,size_t,"%lu");
}
belle_sip_object_unref(req);
belle_sip_object_unref(l);
......
......@@ -113,8 +113,8 @@ static void test_rtcp_xr_attribute(void) {
lAttribute = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute_parse_marshall_parse_clone("a=rtcp-xr"));
BC_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_name(BELLE_SDP_ATTRIBUTE(lAttribute)), "rtcp-xr");
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute) == FALSE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute) == FALSE);
BC_ASSERT_FALSE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute));
BC_ASSERT_FALSE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute));
belle_sip_object_unref(BELLE_SIP_OBJECT(lAttribute));
lAttribute = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute_parse_marshall_parse_clone("a=rtcp-xr:rcvr-rtt=all:10"));
......@@ -126,13 +126,13 @@ static void test_rtcp_xr_attribute(void) {
lAttribute = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute_parse_marshall_parse_clone("a=rtcp-xr:stat-summary"));
BC_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_name(BELLE_SDP_ATTRIBUTE(lAttribute)), "rtcp-xr");
BC_ASSERT_PTR_NULL(belle_sdp_rtcp_xr_attribute_get_rcvr_rtt_mode(lAttribute));
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute) == TRUE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute) == FALSE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute));
BC_ASSERT_FALSE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute));
belle_sip_object_unref(BELLE_SIP_OBJECT(lAttribute));
lAttribute = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute_parse_marshall_parse_clone("a=rtcp-xr:stat-summary=loss,jitt"));
BC_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_name(BELLE_SDP_ATTRIBUTE(lAttribute)), "rtcp-xr");
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute) == TRUE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute));
BC_ASSERT_PTR_NOT_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "loss"));
BC_ASSERT_PTR_NOT_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "jitt"));
BC_ASSERT_PTR_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "HL"));
......@@ -140,19 +140,19 @@ static void test_rtcp_xr_attribute(void) {
lAttribute = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute_parse_marshall_parse_clone("a=rtcp-xr:voip-metrics"));
BC_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_name(BELLE_SDP_ATTRIBUTE(lAttribute)), "rtcp-xr");
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute) == FALSE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute) == TRUE);
BC_ASSERT_FALSE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute));
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute));
belle_sip_object_unref(BELLE_SIP_OBJECT(lAttribute));
lAttribute = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute_parse_marshall_parse_clone("a=rtcp-xr:rcvr-rtt=sender stat-summary=loss,dup,jitt,TTL voip-metrics"));
BC_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_name(BELLE_SDP_ATTRIBUTE(lAttribute)), "rtcp-xr");
BC_ASSERT_STRING_EQUAL(belle_sdp_rtcp_xr_attribute_get_rcvr_rtt_mode(lAttribute), "sender");
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute) == TRUE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_stat_summary(lAttribute));
BC_ASSERT_PTR_NOT_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "loss"));
BC_ASSERT_PTR_NOT_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "dup"));
BC_ASSERT_PTR_NOT_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "jitt"));
BC_ASSERT_PTR_NOT_NULL(belle_sip_list_find_custom(belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(lAttribute), (belle_sip_compare_func)strcasecmp, "TTL"));
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute) == TRUE);
BC_ASSERT_TRUE(belle_sdp_rtcp_xr_attribute_has_voip_metrics(lAttribute));
belle_sip_object_unref(BELLE_SIP_OBJECT(lAttribute));
}
......@@ -553,7 +553,7 @@ static void test_overflow(void){
BC_ASSERT_EQUAL(belle_sip_object_marshal(BELLE_SIP_OBJECT(sdp),buffer,buffsize,&offset),BELLE_SIP_BUFFER_OVERFLOW, int, "%d");
belle_sip_message("marshal size is %i",(int)offset);
BC_ASSERT_TRUE(offset==buffsize);
BC_ASSERT_EQUAL(offset,buffsize,int,"%d");
belle_sip_object_unref(sdp);
belle_sip_free(buffer);
}
......
......@@ -941,7 +941,7 @@ static void _test_date_header(void){
date2=belle_sip_header_date_create_from_time(&utc);
BC_ASSERT_PTR_NOT_NULL(date2);
if (date2){
BC_ASSERT_TRUE(strcmp(belle_sip_header_date_get_date(date2),DATE_EXAMPLE)==0);
BC_ASSERT_STRING_EQUAL(belle_sip_header_date_get_date(date2),DATE_EXAMPLE);
BC_ASSERT_PTR_NULL(belle_sip_header_date_parse("nimportequoi"));
belle_sip_object_unref(date2);
}
......
......@@ -288,7 +288,7 @@ static void client_process_response_event(void *obj, const belle_sip_response_ev
host=belle_sip_uri_get_host(belle_sip_header_address_get_uri((belle_sip_header_address_t*)ct));
if (strchr(host,':')) family_found=AF_INET6;
else family_found=AF_INET;
BC_ASSERT_TRUE(family_found==endpoint->connection_family);
BC_ASSERT_EQUAL(family_found,endpoint->connection_family,int,"%d");
}
break;
case 401:endpoint->stat.fourHundredOne++; break;
......@@ -437,15 +437,15 @@ static void refresher_base_with_body(endpoint_t* client
}
client->refresher= refresher = belle_sip_client_transaction_create_refresher(trans);
}
BC_ASSERT_TRUE_FATAL(refresher!=NULL);
BC_ASSERT_PTR_NOT_NULL_FATAL(refresher);
belle_sip_object_unref(trans);
belle_sip_refresher_set_listener(refresher,belle_sip_refresher_listener,client);
begin = belle_sip_time_ms();
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,client->register_count+(client->early_refresher?1:0),client->register_count*1000 + 1000));
end = belle_sip_time_ms();
BC_ASSERT_TRUE(end-begin>=client->register_count*1000*.9); /*because refresh is at 90% of expire*/
BC_ASSERT_TRUE(end-begin<(client->register_count*1000 + 2000));
BC_ASSERT_GREATER(end-begin,client->register_count*1000*.9,uint64_t,"%llu"); /*because refresh is at 90% of expire*/
BC_ASSERT_LOWER_STRICT(end-begin,(client->register_count*1000 + 2000),uint64_t,"%llu");
/*unregister twice to make sure refresh operation can be safely cascaded*/
belle_sip_refresher_refresh(refresher,0);
belle_sip_refresher_refresh(refresher,0);
......@@ -576,8 +576,8 @@ static void subscribe_base(int with_resource_lists) {
begin = belle_sip_time_ms();
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,3,4000));
end = belle_sip_time_ms();
BC_ASSERT_TRUE(end-begin>=3000*.9);
BC_ASSERT_TRUE(end-begin<5000);
BC_ASSERT_GREATER(end-begin,3000*.9,uint64_t,"%llu");
BC_ASSERT_LOWER_STRICT(end-begin,5000,uint64_t,"%llu");
belle_sip_message("simulating dialog error and recovery");
belle_sip_stack_set_send_error(client->stack, 1500);
......
......@@ -436,7 +436,7 @@ static void stateful_register_tls_with_http_proxy(void) {
}
static void stateful_register_tls_with_wrong_http_proxy(void){
belle_sip_tls_listening_point_t * lp = (belle_sip_tls_listening_point_t*)belle_sip_provider_get_listening_point(prov, "tls");
if (!lp) {
belle_sip_error("No TLS support, test skipped.");
......@@ -448,7 +448,7 @@ static void stateful_register_tls_with_wrong_http_proxy(void){
try_register_user_at_domain(stack,prov,"tls",1,"tester",test_domain,NULL,0);
belle_sip_stack_set_http_proxy_host(stack, NULL);
belle_sip_stack_set_http_proxy_port(stack, 0);
}
......@@ -462,7 +462,8 @@ static void bad_req_process_response_event(void *user_ctx, const belle_sip_respo
belle_sip_response_t *resp=belle_sip_response_event_get_response(event);
int *bad_request_response_received=(int*)user_ctx;
if (belle_sip_response_event_get_client_transaction(event) != NULL) {
BC_ASSERT_TRUE(resp && belle_sip_response_get_status_code(resp)==400);
BC_ASSERT_PTR_NOT_NULL(resp);
BC_ASSERT_EQUAL(belle_sip_response_get_status_code(resp),400,int,"%d");
*bad_request_response_received=1;
belle_sip_main_loop_quit(belle_sip_stack_get_main_loop(stack));
}
......@@ -506,7 +507,7 @@ static void test_bad_request(void) {
t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t);
belle_sip_stack_sleep(stack,3000);
BC_ASSERT_TRUE(bad_request_response_received==1);
BC_ASSERT_EQUAL(bad_request_response_received,1,int,"%d");
belle_sip_provider_remove_sip_listener(prov,bad_req_listener);
belle_sip_object_unref(bad_req_listener);
......@@ -556,7 +557,7 @@ static void test_connection_failure(void){
belle_sip_request_t *req;
io_error_count=0;
req=try_register_user_at_domain(stack, prov, "TCP",1,"tester","sip.linphone.org",no_server_running_here,0);
BC_ASSERT_TRUE(io_error_count>=1);
BC_ASSERT_GREATER(io_error_count,1,int,"%d");
if (req) belle_sip_object_unref(req);
}
......@@ -592,7 +593,7 @@ static void test_tls_to_tcp(void){
belle_sip_stack_set_transport_timeout(stack,2000);
req=try_register_user_at_domain(stack, prov, "TLS",1,"tester",test_domain,test_domain_tls_to_tcp,0);
if (req){
BC_ASSERT_TRUE(io_error_count>=1);
BC_ASSERT_GREATER(io_error_count,1,int,"%d");
belle_sip_object_unref(req);
}
belle_sip_stack_set_transport_timeout(stack,orig);
......@@ -602,7 +603,7 @@ static void register_dns_srv_tcp(void){
belle_sip_request_t *req;
io_error_count=0;
req=try_register_user_at_domain(stack, prov, "TCP",1,"tester",client_auth_domain,"sip:linphone.net;transport=tcp",1);
BC_ASSERT_TRUE(io_error_count==0);
BC_ASSERT_EQUAL(io_error_count,0,int,"%d");
if (req) belle_sip_object_unref(req);
}
......
......@@ -285,7 +285,7 @@ static void ipv6_aaaa_query(void) {
int ntohsi = ntohs(sock_in6->sin6_port);
BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d");
/*the IPv6 address shall return first, and must be a real ipv6 address*/
BC_ASSERT_TRUE(client->ai_list->ai_family==AF_INET6);
BC_ASSERT_EQUAL(client->ai_list->ai_family,AF_INET6,int,"%d");
BC_ASSERT_FALSE(IN6_IS_ADDR_V4MAPPED(&sock_in6->sin6_addr));
ai = belle_sip_ip_address_to_addrinfo(AF_INET6, IPV6_SIP_IP, SIP_PORT);
BC_ASSERT_PTR_NOT_NULL(ai);
......@@ -302,7 +302,7 @@ static void ipv6_aaaa_query(void) {
if (next){
int ntohsi = ntohs(sock_in6->sin6_port);
sock_in6 = (struct sockaddr_in6 *)next->ai_addr;
BC_ASSERT_TRUE(next->ai_family==AF_INET6);
BC_ASSERT_EQUAL(next->ai_family,AF_INET6,int,"%d");
BC_ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(&sock_in6->sin6_addr));
BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d");
ai = belle_sip_ip_address_to_addrinfo(AF_INET6, IPV6_SIP_IPV4, SIP_PORT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment