tester: use new macros instead of CUnit ones to get better error logs

parent 2a60bb24
......@@ -23,8 +23,6 @@
#include "belle-sip/auth-helper.h"
#include "belle_sip_tester.h"
#include <stdio.h>
#include "CUnit/Basic.h"
#ifdef HAVE_POLARSSL
#include <polarssl/version.h>
......@@ -39,9 +37,9 @@ static void test_authentication(void) {
belle_sip_header_www_authenticate_t* www_authenticate=belle_sip_header_www_authenticate_parse(l_raw_header);
belle_sip_header_authorization_t* authorization = belle_sip_auth_helper_create_authorization(www_authenticate);
belle_sip_header_authorization_set_uri(authorization,belle_sip_uri_parse("sip:sip.linphone.org"));
CU_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_compute_ha1("jehan-mac","sip.linphone.org","toto",ha1));
CU_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_fill_authorization(authorization,"REGISTER",ha1));
CU_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_response(authorization),"77ebf3de72e41934d806175586086508");
BC_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_compute_ha1("jehan-mac","sip.linphone.org","toto",ha1), int, "%d");
BC_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_fill_authorization(authorization,"REGISTER",ha1), int, "%d");
BC_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_response(authorization),"77ebf3de72e41934d806175586086508");
belle_sip_object_unref(www_authenticate);
belle_sip_object_unref(authorization);
}
......@@ -57,11 +55,11 @@ static void test_authentication_qop_auth(void) {
belle_sip_header_authorization_set_nonce_count(authorization,1);
belle_sip_header_authorization_set_qop(authorization,"auth");
belle_sip_header_authorization_set_cnonce(authorization,"8302210f"); /*for testing purpose*/
CU_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_compute_ha1("jehan-mac","sip.linphone.org","toto",ha1));
CU_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_fill_authorization(authorization,"REGISTER",ha1));
CU_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_qop(authorization),"auth");
CU_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_response(authorization),"694dab8dfe7d50d28ba61e8c43e30666");
CU_ASSERT_EQUAL(belle_sip_header_authorization_get_nonce_count(authorization),1);
BC_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_compute_ha1("jehan-mac","sip.linphone.org","toto",ha1), int, "%d");
BC_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_fill_authorization(authorization,"REGISTER",ha1), int, "%d");
BC_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_qop(authorization),"auth");
BC_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_response(authorization),"694dab8dfe7d50d28ba61e8c43e30666");
BC_ASSERT_EQUAL(belle_sip_header_authorization_get_nonce_count(authorization),1, int, "%d");
belle_sip_object_unref(www_authenticate);
belle_sip_object_unref(authorization);
}
......@@ -74,9 +72,9 @@ static void test_proxy_authentication(void) {
belle_sip_header_proxy_authenticate_t* proxy_authenticate=belle_sip_header_proxy_authenticate_parse(l_raw_header);
belle_sip_header_proxy_authorization_t* proxy_authorization = belle_sip_auth_helper_create_proxy_authorization(proxy_authenticate);
belle_sip_header_authorization_set_uri(BELLE_SIP_HEADER_AUTHORIZATION(proxy_authorization),belle_sip_uri_parse("sip:sip.linphone.org"));
CU_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_compute_ha1("jehan-mac","sip.linphone.org","toto",ha1));
CU_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_fill_proxy_authorization(proxy_authorization,"REGISTER",ha1));
CU_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_response(BELLE_SIP_HEADER_AUTHORIZATION(proxy_authorization))
BC_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_compute_ha1("jehan-mac","sip.linphone.org","toto",ha1), int, "%d");
BC_ASSERT_EQUAL_FATAL(0,belle_sip_auth_helper_fill_proxy_authorization(proxy_authorization,"REGISTER",ha1), int, "%d");
BC_ASSERT_STRING_EQUAL(belle_sip_header_authorization_get_response(BELLE_SIP_HEADER_AUTHORIZATION(proxy_authorization))
,"77ebf3de72e41934d806175586086508");
belle_sip_object_unref(proxy_authenticate);
belle_sip_object_unref(proxy_authorization);
......@@ -96,28 +94,28 @@ static void test_generate_and_parse_certificates(void) {
/* create 2 certificates in the temporary certificate directory (TODO : set the directory in a absolute path?? where?)*/
ret = belle_sip_generate_self_signed_certificate(belle_sip_certificate_temporary_dir, "test_certificate1", &certificate, &key);
CU_ASSERT_EQUAL_FATAL(0, ret);
BC_ASSERT_EQUAL_FATAL(0, ret, int, "%d");
ret = belle_sip_generate_self_signed_certificate(belle_sip_certificate_temporary_dir, "test_certificate2", &certificate, &key);
CU_ASSERT_EQUAL_FATAL(0, ret);
BC_ASSERT_EQUAL_FATAL(0, ret, int, "%d");
/* parse directory to get the certificate2 */
ret = belle_sip_get_certificate_and_pkey_in_dir(belle_sip_certificate_temporary_dir, "test_certificate2", &parsed_certificate, &parsed_key, BELLE_SIP_CERTIFICATE_RAW_FORMAT_PEM);
belle_sip_free(belle_sip_certificate_temporary_dir);
CU_ASSERT_EQUAL_FATAL(0, ret);
BC_ASSERT_EQUAL_FATAL(0, ret, int, "%d");
/* get pem version of generated and parsed certificate and compare them */
pem_certificate = belle_sip_certificates_chain_get_pem(certificate);
CU_ASSERT_TRUE_FATAL(pem_certificate!=NULL);
BC_ASSERT_TRUE_FATAL(pem_certificate!=NULL);
pem_parsed_certificate = belle_sip_certificates_chain_get_pem(parsed_certificate);
CU_ASSERT_TRUE_FATAL(pem_parsed_certificate!=NULL);
CU_ASSERT_STRING_EQUAL(pem_certificate, pem_parsed_certificate);
BC_ASSERT_TRUE_FATAL(pem_parsed_certificate!=NULL);
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);
CU_ASSERT_TRUE_FATAL(pem_key!=NULL);
BC_ASSERT_TRUE_FATAL(pem_key!=NULL);
pem_parsed_key = belle_sip_signing_key_get_pem(parsed_key);
CU_ASSERT_TRUE_FATAL(pem_parsed_key!=NULL);
CU_ASSERT_STRING_EQUAL(pem_key, pem_parsed_key);
BC_ASSERT_TRUE_FATAL(pem_parsed_key!=NULL);
BC_ASSERT_STRING_EQUAL(pem_key, pem_parsed_key);
belle_sip_free(pem_certificate);
belle_sip_free(pem_parsed_certificate);
......@@ -169,8 +167,8 @@ static void test_certificate_fingerprint(void) {
/* generate fingerprint */
fingerprint = belle_sip_certificates_chain_get_fingerprint(cert);
CU_ASSERT_TRUE_FATAL(fingerprint!=NULL);
CU_ASSERT_STRING_EQUAL(fingerprint, belle_sip_tester_client_cert_fingerprint);
BC_ASSERT_TRUE_FATAL(fingerprint!=NULL);
BC_ASSERT_STRING_EQUAL(fingerprint, belle_sip_tester_client_cert_fingerprint);
belle_sip_free(fingerprint);
belle_sip_object_unref(cert);
......@@ -180,8 +178,8 @@ static void test_certificate_fingerprint(void) {
/* generate fingerprint */
fingerprint = belle_sip_certificates_chain_get_fingerprint(cert);
CU_ASSERT_TRUE_FATAL(fingerprint!=NULL);
CU_ASSERT_STRING_EQUAL(fingerprint, belle_sip_tester_fingerprint256_cert_fingerprint);
BC_ASSERT_TRUE_FATAL(fingerprint!=NULL);
BC_ASSERT_STRING_EQUAL(fingerprint, belle_sip_tester_fingerprint256_cert_fingerprint);
belle_sip_free(fingerprint);
belle_sip_object_unref(cert);
......
......@@ -18,8 +18,6 @@
#include "belle-sip/belle-sip.h"
#include "belle_sip_tester.h"
#include <stdio.h>
#include "CUnit/Basic.h"
static void test_basic_uri() {
......@@ -31,19 +29,19 @@ static void test_basic_uri() {
belle_sip_object_unref(source_uri);
belle_sip_object_unref(first_uri);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"http");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"www.linphone.org");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"http");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"www.linphone.org");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
belle_sip_object_unref(uri);
source_uri = belle_generic_uri_parse("http://www.linphone.org/");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/");
belle_sip_object_unref(source_uri);
source_uri = belle_generic_uri_parse("http://www.linphone.org/a/b/c");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/a/b/c");
CU_ASSERT_STRING_EQUAL("http://www.linphone.org/a/b/c",source_uri_raw = belle_sip_object_to_string(source_uri));
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/a/b/c");
BC_ASSERT_STRING_EQUAL("http://www.linphone.org/a/b/c",source_uri_raw = belle_sip_object_to_string(source_uri));
belle_sip_free(source_uri_raw);
belle_sip_object_unref(source_uri);
}
......@@ -58,14 +56,14 @@ static void test_complex_uri() {
belle_sip_object_unref(source_uri);
belle_sip_object_unref(first_uri);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"ftp");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"ftp.linphone.fr");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_user(uri),"toto");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_user_password(uri),"secret");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"ftp.linphone.fr");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/url");
CU_ASSERT_EQUAL(belle_generic_uri_get_port(uri),1234);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_query(uri),"sa=t&rct=j&url=http://translate.google.fr");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"ftp");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"ftp.linphone.fr");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_user(uri),"toto");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_user_password(uri),"secret");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"ftp.linphone.fr");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/url");
BC_ASSERT_EQUAL(belle_generic_uri_get_port(uri),1234,int,"%d");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_query(uri),"sa=t&rct=j&url=http://translate.google.fr");
belle_sip_object_unref(uri);
}
......@@ -79,28 +77,28 @@ static void test_file_path() {
belle_sip_object_unref(source_uri);
belle_sip_object_unref(first_uri);
CU_ASSERT_PTR_NULL(belle_generic_uri_get_scheme(uri));
CU_ASSERT_PTR_NULL(belle_generic_uri_get_host(uri));
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
BC_ASSERT_PTR_NULL(belle_generic_uri_get_scheme(uri));
BC_ASSERT_PTR_NULL(belle_generic_uri_get_host(uri));
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
belle_sip_object_unref(uri);
source_uri = belle_generic_uri_parse("file:///tmp/absolute-file");
CU_ASSERT_PTR_NOT_NULL(source_uri);
BC_ASSERT_PTR_NOT_NULL(source_uri);
if (source_uri!=NULL){
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(source_uri),"file");
CU_ASSERT_PTR_NULL(belle_generic_uri_get_host(source_uri));
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/tmp/absolute-file");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(source_uri),"file");
BC_ASSERT_PTR_NULL(belle_generic_uri_get_host(source_uri));
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/tmp/absolute-file");
belle_sip_object_unref(source_uri);
}
/*this is INVALID*/
source_uri = belle_generic_uri_parse("file://./relative-file");
CU_ASSERT_PTR_NOT_NULL(source_uri);
BC_ASSERT_PTR_NOT_NULL(source_uri);
/* PATH segment always start by / */
source_uri = belle_generic_uri_parse("./relative-file");
CU_ASSERT_PTR_NULL(source_uri);
BC_ASSERT_PTR_NULL(source_uri);
if (source_uri!=NULL){
belle_sip_object_unref(source_uri);
}
......@@ -115,8 +113,8 @@ static void test_absolute_uri() {
belle_sip_object_unref(source_uri);
belle_sip_object_unref(first_uri);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"tel");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_opaque_part(uri),"+33123457");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"tel");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_opaque_part(uri),"+33123457");
belle_sip_object_unref(uri);
source_uri = belle_generic_uri_parse("tel:11234567888;phone-context=vzims.com");
......@@ -127,8 +125,8 @@ static void test_absolute_uri() {
belle_sip_object_unref(source_uri);
belle_sip_object_unref(first_uri);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"tel");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_opaque_part(uri),"11234567888;phone-context=vzims.com");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"tel");
BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_opaque_part(uri),"11234567888;phone-context=vzims.com");
belle_sip_object_unref(uri);
}
......
......@@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CUnit/Basic.h"
#include "belle-sip/belle-sip.h"
#include "belle_sip_tester.h"
#include <belle_sip_internal.h>
......@@ -45,7 +43,7 @@ static int wait_for(belle_sip_stack_t*s1,int* counter,int value,int timeout) {
static void process_response(void *data, const belle_http_response_event_t *event){
http_counters_t *counters=(http_counters_t*)data;
counters->response_count++;
CU_ASSERT_PTR_NOT_NULL(event->response);
BC_ASSERT_PTR_NOT_NULL(event->response);
if (event->response){
int code=belle_http_response_get_status_code(event->response);
belle_sip_body_handler_t *body=belle_sip_message_get_body_handler(BELLE_SIP_MESSAGE(event->response));
......@@ -55,7 +53,7 @@ static void process_response(void *data, const belle_http_response_event_t *even
counters->three_hundred++;
else if (code>=300 && code <400)
counters->four_hundred++;
CU_ASSERT_PTR_NOT_NULL(body);
BC_ASSERT_PTR_NOT_NULL(body);
}
}
......@@ -100,9 +98,9 @@ static void one_get(const char *url,http_counters_t* counters, int *counter){
belle_http_request_listener_t *l;
belle_generic_uri_t *uri;
belle_http_request_t *req;
uri=belle_generic_uri_parse(url);
req=belle_http_request_create("GET",
uri,
belle_sip_header_create("User-Agent","belle-sip/"PACKAGE_VERSION),
......@@ -113,55 +111,55 @@ static void one_get(const char *url,http_counters_t* counters, int *counter){
l=belle_http_request_listener_create_from_callbacks(&cbs,counters);
belle_http_provider_send_request(prov,req,l);
wait_for(stack,counter,1,10000);
belle_sip_object_unref(l);
}
static void one_http_get(void){
http_counters_t counters={0};
one_get("http://smtp.linphone.org",&counters,&counters.response_count);
CU_ASSERT_TRUE(counters.response_count==1);
CU_ASSERT_TRUE(counters.io_error_count==0);
CU_ASSERT_EQUAL(counters.two_hundred,1);
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
}
static void http_get_empty_body(void){
http_counters_t counters={0};
one_get("http://smtp.linphone.org/marie_invalid",&counters,&counters.response_count);
CU_ASSERT_TRUE(counters.response_count==1);
CU_ASSERT_TRUE(counters.io_error_count==0);
CU_ASSERT_EQUAL(counters.two_hundred,1);
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
}
static void http_get_io_error(void){
http_counters_t counters={0};
one_get("http://blablabla.cul",&counters,&counters.io_error_count);
CU_ASSERT_TRUE(counters.response_count==0);
CU_ASSERT_EQUAL(counters.io_error_count,1);
BC_ASSERT_TRUE(counters.response_count==0);
BC_ASSERT_EQUAL(counters.io_error_count,1,int,"%d");
}
static void one_https_get(void){
http_counters_t counters={0};
one_get("https://smtp.linphone.org",&counters,&counters.response_count);
CU_ASSERT_TRUE(counters.response_count==1);
CU_ASSERT_TRUE(counters.io_error_count==0);
CU_ASSERT_EQUAL(counters.two_hundred,1);
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
}
static void https_get_long_body(void){
http_counters_t counters={0};
one_get("https://smtp.linphone.org/linphone.html",&counters, &counters.response_count);
CU_ASSERT_TRUE(counters.response_count==1);
CU_ASSERT_TRUE(counters.io_error_count==0);
CU_ASSERT_EQUAL(counters.two_hundred,1);
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
}
static void https_digest_get(void){
http_counters_t counters={0};
one_get("https://pauline:pouet@smtp.linphone.org/restricted",&counters,&counters.response_count);
CU_ASSERT_TRUE(counters.response_count==1);
CU_ASSERT_TRUE(counters.io_error_count==0);
CU_ASSERT_EQUAL(counters.three_hundred,1);
BC_ASSERT_TRUE(counters.response_count==1);
BC_ASSERT_TRUE(counters.io_error_count==0);
BC_ASSERT_EQUAL(counters.three_hundred,1,int,"%d");
}
#if 0
static void https_client_cert_connection(void){
......@@ -170,7 +168,7 @@ static void https_client_cert_connection(void){
belle_tls_verify_policy_set_exceptions(policy,BELLE_TLS_VERIFY_ANY_REASON);/*ignore the server verification because we don't have a true certificate*/
belle_http_provider_set_tls_verify_policy(prov,policy);
one_get("https://sip2.linphone.org:5063",&counters);
CU_ASSERT_EQUAL(counters.two_hundred,1);
BC_ASSERT_EQUAL(counters.two_hundred,1,int,"%d");
belle_tls_verify_policy_set_exceptions(policy,0);
belle_sip_object_unref(policy);
}
......@@ -197,7 +195,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){
int partlen=sizeof(MULTIPART_BEGIN);
CU_ASSERT_TRUE_FATAL(partlen<*size);
BC_ASSERT_TRUE_FATAL(partlen<*size);
memcpy(buffer,MULTIPART_BEGIN,partlen);
*size=partlen;
}else if (offset<end_of_img){
......@@ -223,9 +221,9 @@ static void https_post_long_body(void){
const char *url="https://www.linphone.org:444/upload.php";
belle_sip_user_body_handler_t *bh=belle_sip_user_body_handler_new(image_size+sizeof(MULTIPART_BEGIN)+sizeof(MULTIPART_END), on_progress, NULL, on_send_body, NULL);
char *content_type=belle_sip_strdup_printf("multipart/form-data; boundary=%s",multipart_boudary);
uri=belle_generic_uri_parse(url);
req=belle_http_request_create("POST",
uri,
belle_sip_header_create("User-Agent","belle-sip/" PACKAGE_VERSION),
......@@ -238,8 +236,8 @@ static void https_post_long_body(void){
cbs.process_auth_requested=process_auth_requested;
l=belle_http_request_listener_create_from_callbacks(&cbs,&counters);
belle_http_provider_send_request(prov,req,l);
CU_ASSERT_TRUE(wait_for(stack,&counters.two_hundred,1,20000));
BC_ASSERT_TRUE(wait_for(stack,&counters.two_hundred,1,20000));
belle_sip_object_unref(l);
}
......@@ -252,7 +250,7 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t
static void process_response_headers(void *data, const belle_http_response_event_t *event){
http_counters_t *counters=(http_counters_t*)data;
counters->response_headers_count++;
CU_ASSERT_PTR_NOT_NULL(event->response);
BC_ASSERT_PTR_NOT_NULL(event->response);
if (event->response){
/*we are receiving a response, set a specific body handler to acquire the response.
* if not done, belle-sip will create a memory body handler, the default*/
......@@ -274,9 +272,9 @@ static void http_get_long_user_body(void){
belle_sip_body_handler_t *bh;
belle_http_response_t *resp;
FILE *outfile=fopen("download.tar.gz","w");
uri=belle_generic_uri_parse(url);
req=belle_http_request_create("GET",
uri,
belle_sip_header_create("User-Agent","belle-sip/" PACKAGE_VERSION),
......@@ -289,13 +287,13 @@ static void http_get_long_user_body(void){
belle_sip_object_ref(req);
belle_sip_object_data_set(BELLE_SIP_OBJECT(req),"file",outfile,NULL);
belle_http_provider_send_request(prov,req,l);
CU_ASSERT_TRUE(wait_for(stack,&counters.two_hundred,1,20000));
CU_ASSERT_TRUE(counters.response_headers_count==1);
BC_ASSERT_TRUE(wait_for(stack,&counters.two_hundred,1,20000));
BC_ASSERT_TRUE(counters.response_headers_count==1);
resp=belle_http_request_get_response(req);
CU_ASSERT_PTR_NOT_NULL(resp);
BC_ASSERT_PTR_NOT_NULL(resp);
if (resp){
bh=belle_sip_message_get_body_handler((belle_sip_message_t*)resp);
CU_ASSERT_TRUE(belle_sip_body_handler_get_size(bh)>0);
BC_ASSERT_TRUE(belle_sip_body_handler_get_size(bh)>0);
}
belle_sip_object_unref(req);
belle_sip_object_unref(l);
......
This diff is collapsed.
......@@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CUnit/Basic.h"
#include "belle-sip/belle-sip.h"
#include "belle-sip/object.h"
#include "belle-sip/dict.h"
......@@ -69,9 +67,9 @@ static void test_object_data(void)
/* normal insertion with no destroy callback */
// should return 0
CU_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_i", INT_TO_VOIDPTR(i), NULL), 0);
BC_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_i", INT_TO_VOIDPTR(i), NULL), 0, int, "%d");
// should return the value we put in it
CU_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), i);
BC_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), i, int, "%d");
/*
......@@ -81,27 +79,27 @@ static void test_object_data(void)
// overwrite data: should return 1 when set()
i = 124;
CU_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_i", INT_TO_VOIDPTR(i), NULL), 1 );
BC_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_i", INT_TO_VOIDPTR(i), NULL), 1 , int, "%d");
// should return the new value we put in it
CU_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), i);
BC_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), i, int, "%d");
/*
* normal insertion with destroy callback
*/
CU_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_str",
BC_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_str",
(void*)belle_sip_strdup(str),
test_object_data_string_destroy),
0);
0, int, "%d");
// we should get back the same string
CU_ASSERT_STRING_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"),
BC_ASSERT_STRING_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"),
str );
CU_ASSERT_EQUAL(belle_sip_object_data_remove(obj, "test_str"),0);
BC_ASSERT_EQUAL(belle_sip_object_data_remove(obj, "test_str"),0, int, "%d");
// we expect the destroy() function to be called on removal
CU_ASSERT_EQUAL(destroy_called, 1);
BC_ASSERT_EQUAL(destroy_called, 1, int, "%d");
destroy_called = 0;
/*
......@@ -113,36 +111,37 @@ static void test_object_data(void)
belle_sip_object_data_set(obj, "test_str",
(void*)belle_sip_strdup(str2),
test_object_data_string_destroy);
CU_ASSERT_EQUAL(destroy_called, 1); // we expect the dtor to have been called to free the first string
BC_ASSERT_EQUAL(destroy_called, 1, int, "%d"); // we expect the dtor to have been called to free the first string
/*
* Get non-existent key
*/
CU_ASSERT_EQUAL(belle_sip_object_data_get(obj, "non-exist"),NULL);
BC_ASSERT_PTR_NULL(belle_sip_object_data_get(obj, "non-exist"));
/*
* test cloning the dictionary
*/
belle_sip_object_data_clone(obj, cloned, test_object_data_string_clone);
CU_ASSERT_EQUAL(clone_called,2); // we expect the clone function to be called for "test_i" and "test_str"
BC_ASSERT_EQUAL(clone_called,2,int,"%d"); // we expect the clone function to be called for "test_i" and "test_st, int, "%d"r"
// the values should be equal
CU_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")),
VOIDPTR_TO_INT(belle_sip_object_data_get(cloned, "test_i")) );
BC_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")),
VOIDPTR_TO_INT(belle_sip_object_data_get(cloned, "test_i"))
, int, "%d");
CU_ASSERT_STRING_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"),
BC_ASSERT_STRING_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"),
(const char*)belle_sip_object_data_get(cloned, "test_str"));
// but the pointers should be different
CU_ASSERT_NOT_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"),
(const char*)belle_sip_object_data_get(cloned, "test_str"));
BC_ASSERT_PTR_NOT_EQUAL( belle_sip_object_data_get(obj, "test_str"),
belle_sip_object_data_get(cloned, "test_str"));
/*
* Foreach test
*/
belle_sip_object_data_foreach(obj, test_object_data_foreach_cb, NULL);
CU_ASSERT_EQUAL( foreach_called, 2 );
BC_ASSERT_EQUAL( foreach_called, 2 , int, "%d");
belle_sip_object_unref(obj);
belle_sip_object_unref(cloned);
......@@ -157,32 +156,32 @@ static void test_dictionary(void)
int64_t i64 = 0xF2345678 << 1; // gcc doesn't like 0x1234567890 as a 64 bit literal..
belle_sip_dict_set_int(obj, "test_i", i);
CU_ASSERT_EQUAL(belle_sip_dict_get_int(obj,"test_i",-1),i);
BC_ASSERT_EQUAL(belle_sip_dict_get_int(obj,"test_i",-1),i, int, "%d");
// return default int value
CU_ASSERT_EQUAL(belle_sip_dict_get_int(obj,"unexistent",-1),-1);
BC_ASSERT_EQUAL(belle_sip_dict_get_int(obj,"unexistent",-1),-1, int, "%d");
// remove existing entry
CU_ASSERT_EQUAL(belle_sip_dict_remove(obj, "test_i"),0);
BC_ASSERT_EQUAL(belle_sip_dict_remove(obj, "test_i"),0, int, "%d");
// test_i should't be present anymore
CU_ASSERT_EQUAL(belle_sip_dict_get_int(obj,"test_i",-1),-1);
BC_ASSERT_EQUAL(belle_sip_dict_get_int(obj,"test_i",-1),-1, int, "%d");
// remove unknown entry
CU_ASSERT_NOT_EQUAL(belle_sip_dict_remove(obj, "unexistent"),0);
BC_ASSERT_NOT_EQUAL(belle_sip_dict_remove(obj, "unexistent"),0,int,"%d");
belle_sip_dict_set_string(obj, "test_str", str);
CU_ASSERT_STRING_EQUAL( (const char*)belle_sip_dict_get_string(obj, "test_str", ""),str);
BC_ASSERT_STRING_EQUAL( (const char*)belle_sip_dict_get_string(obj, "test_str", ""),str);
// unknown string value
CU_ASSERT_STRING_EQUAL( (const char*)belle_sip_dict_get_string(obj, "unexistent", "toto"),"toto");
BC_ASSERT_STRING_EQUAL( (const char*)belle_sip_dict_get_string(obj, "unexistent", "toto"),"toto");
belle_sip_dict_set_int64(obj, "test_i64", i64);
CU_ASSERT_EQUAL(belle_sip_dict_get_int64(obj,"test_i64",-1),i64);
BC_ASSERT_EQUAL(belle_sip_dict_get_int64(obj,"test_i64",-1),i64, int, "%d");
belle_sip_dict_clear(obj);
// test_str shouldn't exist anymore
CU_ASSERT_STRING_EQUAL(belle_sip_dict_get_string(obj,"test_str","toto"),"toto");
BC_ASSERT_STRING_EQUAL(belle_sip_dict_get_string(obj,"test_str","toto"),"toto");
belle_sip_object_unref(obj);
}
......
......@@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CUnit/Basic.h"
#include "belle-sip/belle-sip.h"
#include "belle_sip_tester.h"
......@@ -110,10 +108,10 @@ static void caller_process_request_event(void *user_ctx, const belle_sip_request
}
belle_sip_message("caller_process_request_event received [%s] message",belle_sip_request_get_method(belle_sip_request_event_get_request(event)));
server_transaction=belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event));
CU_ASSERT_STRING_EQUAL_FATAL("BYE",belle_sip_request_get_method(belle_sip_request_event_get_request(event)));
BC_ASSERT_STRING_EQUAL_FATAL("BYE",belle_sip_request_get_method(belle_sip_request_event_get_request(event)));
dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(server_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(dialog);
CU_ASSERT_EQUAL(belle_sip_dialog_get_state(dialog) , BELLE_SIP_DIALOG_CONFIRMED);
BC_ASSERT_PTR_NOT_NULL_FATAL(dialog);
BC_ASSERT_EQUAL(belle_sip_dialog_get_state(dialog) , BELLE_SIP_DIALOG_CONFIRMED, int, "%d");
resp=belle_sip_response_create_from_request(belle_sip_request_event_get_request(event),200);
belle_sip_server_transaction_send_response(server_transaction,resp);
......@@ -135,11 +133,11 @@ static void callee_process_request_event(void *user_ctx, const belle_sip_request
if (!server_transaction && strcmp(method,"ACK")!=0) {
server_transaction= belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event));
}
belle_sip_message("callee_process_request_event received [%s] message",method);
dialog = belle_sip_request_event_get_dialog(event);
if (!dialog ) {
CU_ASSERT_STRING_EQUAL_FATAL("INVITE",method);
BC_ASSERT_STRING_EQUAL_FATAL("INVITE",method);
dialog=belle_sip_provider_create_dialog(prov,BELLE_SIP_TRANSACTION(server_transaction));
callee_dialog=dialog;
inserv_transaction=server_transaction;
......@@ -180,14 +178,14 @@ static void caller_process_response_event(void *user_ctx, const belle_sip_respon
status = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event));
belle_sip_message("caller_process_response_event [%i]",status);
CU_ASSERT_PTR_NOT_NULL_FATAL(client_transaction);
BC_ASSERT_PTR_NOT_NULL_FATAL(client_transaction);
dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(dialog);
CU_ASSERT_PTR_EQUAL(caller_dialog,dialog);
BC_ASSERT_PTR_NOT_NULL_FATAL(dialog);
BC_ASSERT_PTR_EQUAL(caller_dialog,dialog);
if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_NULL) {
CU_ASSERT_EQUAL(status,100);
BC_ASSERT_EQUAL(status,100, int, "%d");
} else if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_EARLY){
CU_ASSERT_EQUAL(status,180);
BC_ASSERT_EQUAL(status,180, int, "%d");
/*send 200ok from callee*/
belle_sip_server_transaction_send_response(inserv_transaction,ok_response);
belle_sip_object_unref(ok_response);
......@@ -210,10 +208,10 @@ static void callee_process_response_event(void *user_ctx, const belle_sip_respon
belle_sip_message("Message [%p] not for callee, skipping",belle_sip_response_event_get_response(event));
return; /*not for the callee*/
}
CU_ASSERT_PTR_NOT_NULL_FATAL(client_transaction);
BC_ASSERT_PTR_NOT_NULL_FATAL(client_transaction);
dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(dialog);
CU_ASSERT_PTR_EQUAL(callee_dialog,dialog);
BC_ASSERT_PTR_NOT_NULL_FATAL(dialog);
BC_ASSERT_PTR_EQUAL(callee_dialog,dialog);
if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_TERMINATED) {
call_endeed=1;
belle_sip_main_loop_quit(belle_sip_stack_get_main_loop(stack));
......@@ -319,7 +317,7 @@ static void do_simple_call(void) {
client_transaction = belle_sip_provider_create_client_transaction(prov,req);
caller_dialog=belle_sip_provider_create_dialog(prov,BELLE_SIP_TRANSACTION(client_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction)));
BC_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction)));
//belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),op);
call_endeed=0;
belle_sip_client_transaction_send_request(client_transaction);
......@@ -327,7 +325,7 @@ static void do_simple_call(void) {
//for(i=0;i<10 &&!call_endeed;i++)
belle_sip_stack_sleep(stack,30000);
CU_ASSERT_EQUAL(call_endeed,1);
BC_ASSERT_EQUAL(call_endeed,1, int, "%d");
belle_sip_provider_remove_sip_listener(prov,caller_listener);
belle_sip_provider_remove_sip_listener(prov,callee_listener);
......
This diff is collapsed.
This diff is collapsed.
......@@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CUnit/Basic.h"
#include "belle-sip/belle-sip.h"
#include "belle_sip_internal.h"
#include "belle_sip_tester.h"
......@@ -95,7 +93,7 @@ static unsigned int wait_for(belle_sip_stack_t*s1, belle_sip_stack_t*s2,int* co
//static void process_io_error(void *obj, const belle_sip_io_error_event_t *event){
// belle_sip_warning("process_io_error");
// /*belle_sip_main_loop_quit(belle_sip_stack_get_main_loop(stack));*/
// /*CU_ASSERT(CU_FALSE);*/
// /*BC_ASSERT(CU_FALSE);*/
//}
static void compute_response(const char* username
......@@ -227,15 +225,15 @@ static void server_process_request_event(void *obj, const belle_sip_request_even
belle_sip_header_t* sip_if_match=belle_sip_message_get_header(BELLE_SIP_MESSAGE(resp),"SIP-If-Match");
if (sip_if_match) {
CU_ASSERT_STRING_EQUAL(belle_sip_header_extension_get_value(BELLE_SIP_HEADER_EXTENSION(sip_if_match)),"blablietag");
BC_ASSERT_STRING_EQUAL(belle_sip_header_extension_get_value(BELLE_SIP_HEADER_EXTENSION(sip_if_match)),"blablietag");
}
/*check for body*/
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)));
BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)));
if (belle_sip_message_get_body(BELLE_SIP_MESSAGE(req))) {
CU_ASSERT_STRING_EQUAL(belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)),publish_body);
BC_ASSERT_STRING_EQUAL(belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)),publish_body);
}
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header_by_type(req,belle_sip_header_content_type_t));
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header_by_type(req,belle_sip_header_content_length_t));
BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header_by_type(req,belle_sip_header_content_type_t));
BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header_by_type(req,belle_sip_header_content_length_t));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),belle_sip_header_create("SIP-ETag","blablietag"));
}
} else {
......@@ -263,11 +261,11 @@ static void client_process_response_event(void *obj, const belle_sip_response_ev
int family_found;
belle_sip_header_contact_t *ct=belle_sip_message_get_header_by_type(
(belle_sip_message_t*)belle_sip_response_event_get_response(event),belle_sip_header_contact_t);
CU_ASSERT_PTR_NOT_NULL_FATAL(ct);
BC_ASSERT_PTR_NOT_NULL_FATAL(ct);
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;