From 4ff35a87df5eff891e635e0f9c8ccea7d16a58b8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 25 Feb 2013 17:44:51 +0100 Subject: [PATCH 1/7] fix offer answer bug when counting active streams. --- coreapi/offeranswer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index ab38f7636..9823c24a6 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -313,10 +313,9 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities }else ms_warning("Unknown protocol for mline %i, declining",i); if (ls){ initiate_incoming(ls,rs,&result->streams[i],one_matching_codec); - result->n_active_streams++; - } - else { - /* create an inactive stream for the answer, as there where no matching stream a local capability */ + if (result->streams[i].rtp_port!=0) result->n_active_streams++; + }else { + /* create an inactive stream for the answer, as there where no matching stream in local capabilities */ result->streams[i].dir=SalStreamInactive; result->streams[i].rtp_port=0; result->streams[i].type=rs->type; From 936ec61f405da21440d6b0f355553243232915ab Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 26 Feb 2013 17:29:28 +0100 Subject: [PATCH 2/7] call->audio_bw should be rouded to the upper value --- coreapi/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 927c3b55a..e84c8cce9 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #endif - +#include #if !defined(WIN32) @@ -244,7 +244,7 @@ static double get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *p } void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt){ - call->audio_bw=(int)(get_audio_payload_bandwidth(call->core,pt)/1000.0); + call->audio_bw=(int)(ceil(get_audio_payload_bandwidth(call->core,pt)/1000.0)); /*rounding codec bandwidth should be avoid, specially for AMR*/ ms_message("Audio bandwidth for this call is %i",call->audio_bw); } From 7ac3735bde39757a1759d5eaedbf437a974e3f9d Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 27 Feb 2013 11:24:39 +0100 Subject: [PATCH 3/7] make sure exosip is optionnal --- configure.ac | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7361fa6dc..a311afe34 100644 --- a/configure.ac +++ b/configure.ac @@ -419,8 +419,6 @@ AC_DEFINE_UNQUOTED(PACKAGE_SOUND_DIR, "${package_prefix}/${DATADIRNAME}/sounds/l dnl check if we have the getifaddrs() sytem call AC_CHECK_FUNCS(getifaddrs) -dnl check for osip2 -LP_CHECK_OSIP2 dnl conditionnal build for ssl AC_ARG_ENABLE(ssl, @@ -436,8 +434,6 @@ AC_ARG_ENABLE(ssl, if test "$build_ssl" = "true"; then PKG_CHECK_MODULES(OPENSSL, libssl >= 0.9.8) fi -dnl setup flags for exosip library -LP_SETUP_EXOSIP dnl check exosip support of DSCP in exosip AC_MSG_CHECKING([for DSCP support in exosip]) @@ -685,6 +681,10 @@ if test $USE_BELLESIP_TRUE !='#' ; then SIPSTACK_LIBS=$BELLESIP_LIBS AC_DEFINE(USE_BELLESIP,1,[Defined when bellesip is used]) else + dnl check for osip2 + LP_CHECK_OSIP2 + dnl setup flags for exosip library + LP_SETUP_EXOSIP SIPSTACK_CFLAGS=$EXOSIP_CFLAGS $OSIP_CFLAGS SIPSTACK_LIBS=$EXOSIP_LIBS $OSIP_LIBS fi From 0b06ac3fb57e7e4453c6ee3be79663011f4bd3b0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 27 Feb 2013 14:42:21 +0100 Subject: [PATCH 4/7] implement op->call_id --- coreapi/bellesip_sal/sal_impl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index cedd2b83f..619defd5c 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -182,6 +182,9 @@ static void process_request_event(void *sal, const belle_sip_request_event_t *ev sal_op_set_remote_ua(op,BELLE_SIP_MESSAGE(req)); } + if (!op->base.call_id) { + op->base.call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_call_id_t)))); + } if (op->callbacks.process_request_event) { op->callbacks.process_request_event(op,event); } else { @@ -220,7 +223,9 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even if (!op->base.remote_ua) { sal_op_set_remote_ua(op,BELLE_SIP_MESSAGE(response)); } - + if (!op->base.call_id) { + op->base.call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(response), belle_sip_header_call_id_t)))); + } if (op->callbacks.process_response_event) { if (op->base.root->nat_helper_enabled) { @@ -377,7 +382,10 @@ Sal * sal_init(){ sal->nat_helper_enabled=TRUE; snprintf(stack_string,sizeof(stack_string)-1,"(belle-sip/%s)",belle_sip_version_to_string()); sal->user_agent=belle_sip_header_user_agent_new(); +#if defined(PACKAGE_NAME) && defined(LINPHONE_VERSION) belle_sip_header_user_agent_add_product(sal->user_agent, PACKAGE_NAME "/" LINPHONE_VERSION); +#endif + belle_sip_header_user_agent_add_product(sal->user_agent,stack_string); belle_sip_object_ref(sal->user_agent); belle_sip_set_log_handler(_belle_sip_log); From 1a5169a1472b81e1d68b8248550dc789b54b607c Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Thu, 28 Feb 2013 10:44:32 +0100 Subject: [PATCH 5/7] uPnP improvements Fix mutex lock in the destructor Add firewall commands in console --- console/commands.c | 6 ++++++ coreapi/upnp.c | 9 +++------ mediastreamer2 | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/console/commands.c b/console/commands.c index a91c58c44..22b09a5a6 100644 --- a/console/commands.c +++ b/console/commands.c @@ -244,6 +244,8 @@ static LPC_COMMAND commands[] = { "'firewall none' : use direct connection.\n" "'firewall nat' : use nat address given with the 'nat' command.\n" "'firewall stun' : use stun server given with the 'stun' command.\n" + "'firewall ice' : use ice.\n" + "'firewall upnp' : use uPnP IGD.\n" }, { "call-logs", lpc_cmd_call_logs, "Calls history", NULL }, { "friend", lpc_cmd_friend, "Manage friends", @@ -850,6 +852,10 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args) { linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall); } + else if (strcmp(args,"upnp")==0) + { + linphone_core_set_firewall_policy(lc,LinphonePolicyUseUpnp); + } else if (strcmp(args,"ice")==0) { setting = linphone_core_get_stun_server(lc); diff --git a/coreapi/upnp.c b/coreapi/upnp.c index 86d16d0f0..28477b4de 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -309,15 +309,14 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) { ms_message("uPnP IGD: Wait all pending port bindings ..."); ms_cond_wait(&lupnp->empty_cond, &lupnp->mutex); } + ms_mutex_unlock(&lupnp->mutex); if(lupnp->upnp_igd_ctxt != NULL) { - // upnp_igd_destroy is synchronous so the callbacks will be called in the same thread. - // So release the mutex before upnp_igd_destroy call. - ms_mutex_unlock(&lupnp->mutex); upnp_igd_destroy(lupnp->upnp_igd_ctxt); - ms_mutex_lock(&lupnp->mutex); lupnp->upnp_igd_ctxt = NULL; } + + /* No more multi threading here */ /* Run one more time configuration update and proxy */ linphone_upnp_update_config(lupnp); @@ -345,8 +344,6 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) { ms_list_for_each(lupnp->pending_bindings,(void (*)(void*))linphone_upnp_port_binding_release); lupnp->pending_bindings = ms_list_free(lupnp->pending_bindings); - ms_mutex_unlock(&lupnp->mutex); - ms_mutex_destroy(&lupnp->mutex); ms_cond_destroy(&lupnp->empty_cond); diff --git a/mediastreamer2 b/mediastreamer2 index e033b06a7..8d85a5ded 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit e033b06a731d0b9bc4e69afc690f6469eae73f66 +Subproject commit 8d85a5ded3b18e2d3d4ba22ee75e0f1ef9c0f739 From bf0db8f9e4e18b4745a55e7943b59ced8ff4a8d2 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 28 Feb 2013 16:06:13 +0100 Subject: [PATCH 6/7] io error repporting for calls --- coreapi/bellesip_sal/sal_impl.c | 10 ++++++++-- coreapi/bellesip_sal/sal_op_call.c | 9 ++++++++- coreapi/bellesip_sal/sal_op_impl.c | 6 +++--- coreapi/sal.h | 3 +++ tester/call_tester.c | 20 ++++++++++++++++++++ tester/liblinphone_tester.c | 10 ++++++---- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 619defd5c..17e3f2d42 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -582,8 +582,8 @@ MSList * sal_get_pending_auths(Sal *sal){ /*misc*/ void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen){ - ms_fatal("sal_get_default_local_ip not implemented yet"); - return ; + strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen); + ms_error("Could not find default routable ip address !"); } const char *sal_get_root_ca(Sal* ctx) { @@ -611,3 +611,9 @@ void sal_nat_helper_enable(Sal *sal,bool_t enable) { bool_t sal_nat_helper_enabled(Sal *sal) { return sal->nat_helper_enabled; } +void sal_set_dns_timeout(Sal* sal,int timeout) { + belle_sip_stack_set_dns_timeout(sal->stack, timeout); +} +int sal_get_dns_timeout(const Sal* sal) { + return belle_sip_stack_get_dns_timeout(sal->stack); +} diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 88f6d7457..f2ec4e883 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -81,7 +81,14 @@ static int set_sdp_from_desc(belle_sip_message_t *msg, const SalMediaDescription } static void call_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){ - ms_error("call_process_io_error not implemented yet"); + SalOp* op=(SalOp*)user_ctx; + if (!op->dialog) { + /*call terminated very early*/ + op->base.root->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,"Service Unavailable",503); + op->state=SalOpStateTerminated; + } else { + /*dialog will terminated shortly, nothing to do*/ + } } static void process_dialog_terminated(void *ctx, const belle_sip_dialog_terminated_event_t *event) { SalOp* op=(SalOp*)ctx; diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index c33feb7d4..43ceb22ae 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -169,7 +169,7 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req } int sal_op_send_request(SalOp* op, belle_sip_request_t* request) { - bool_t need_ack=FALSE; + bool_t need_contact=FALSE; /* Header field where proxy ACK BYE CAN INV OPT REG ___________________________________________________________ @@ -179,9 +179,9 @@ int sal_op_send_request(SalOp* op, belle_sip_request_t* request) { ||strcmp(belle_sip_request_get_method(request),"REGISTER")==0 ||strcmp(belle_sip_request_get_method(request),"SUBSCRIBE")==0 ||strcmp(belle_sip_request_get_method(request),"OPTION")==0) - need_ack=TRUE; + need_contact=TRUE; - return _sal_op_send_request_with_contact(op, request,need_ack); + return _sal_op_send_request_with_contact(op, request,need_contact); } diff --git a/coreapi/sal.h b/coreapi/sal.h index d7c75b46c..886f69c0f 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -519,4 +519,7 @@ void sal_set_recv_error(Sal *sal,int value); /*enable contact fixing*/ void sal_nat_helper_enable(Sal *sal,bool_t enable); bool_t sal_nat_helper_enabled(Sal *sal); + +void sal_set_dns_timeout(Sal* sal,int timeout); +int sal_get_dns_timeout(const Sal* sal); #endif diff --git a/tester/call_tester.c b/tester/call_tester.c index c68ec96ab..8ffbdb7bf 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -197,6 +197,22 @@ static void call_canceled() { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } + +static void call_with_dns_time_out() { + LinphoneCoreManager* marie = linphone_core_manager_new(NULL); + LCSipTransports transport = {9773,0,0,0}; + linphone_core_set_sip_transports(marie->lc,&transport); + linphone_core_iterate(marie->lc); + sal_set_dns_timeout(marie->lc->sal,0); + linphone_core_invite(marie->lc,"sip:toto@toto.com"); + linphone_core_iterate(marie->lc); + linphone_core_iterate(marie->lc); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingInit,1); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingProgress,1); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1); + linphone_core_manager_destroy(marie); +} + static void call_ringing_canceled() { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -585,6 +601,10 @@ int call_test_suite () { if (NULL == CU_add_test(pSuite, "call_canceled", call_canceled)) { return CU_get_error(); } + if (NULL == CU_add_test(pSuite, "call_with_dns_time_out", call_with_dns_time_out)) { + return CU_get_error(); + } + if (NULL == CU_add_test(pSuite, "call_ringing_canceled", call_ringing_canceled)) { return CU_get_error(); } diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index ebbafc7d1..4c8861a13 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -159,17 +159,19 @@ LinphoneCoreManager* linphone_core_manager_new(const char* rc_file) { mgr->v_table.new_subscription_request=new_subscribtion_request; mgr->v_table.notify_presence_recv=notify_presence_received; mgr->v_table.transfer_state_changed=linphone_transfer_state_changed; - mgr->lc=configure_lc_from(&mgr->v_table,rc_file,1); + mgr->lc=configure_lc_from(&mgr->v_table,rc_file,rc_file?1:0); enable_codec(mgr->lc,"PCMU",8000); linphone_core_set_user_data(mgr->lc,&mgr->stat); linphone_core_get_default_proxy(mgr->lc,&proxy); - mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); - linphone_address_clean(mgr->identity); + if (proxy) { + mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); + linphone_address_clean(mgr->identity); + } return mgr; } void linphone_core_manager_destroy(LinphoneCoreManager* mgr) { linphone_core_destroy(mgr->lc); - linphone_address_destroy(mgr->identity); + if (mgr->identity) linphone_address_destroy(mgr->identity); free(mgr); } From d4a36148d08715914539fc60639161785e5e31da Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 1 Mar 2013 10:40:11 +0100 Subject: [PATCH 7/7] Reorganize liblinphone tests. --- tester/Makefile.am | 2 +- tester/call_tester.c | 119 ++++++++------------ tester/liblinphone_tester.c | 217 ++++++++++++++++++++++++------------ tester/liblinphone_tester.h | 52 ++++++++- tester/message_tester.c | 43 +++---- tester/presence_tester.c | 40 +++---- tester/register_tester.c | 75 +++++-------- tester/setup_tester.c | 52 +++++++++ 8 files changed, 370 insertions(+), 230 deletions(-) create mode 100644 tester/setup_tester.c diff --git a/tester/Makefile.am b/tester/Makefile.am index e1d2c692f..801d20ca0 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -4,7 +4,7 @@ if BUILD_CUNIT_TESTS noinst_PROGRAMS=liblinphone_tester TESTS=$(noinst_PROGRAMS) -liblinphone_tester_SOURCES= liblinphone_tester.c register_tester.c message_tester.c call_tester.c presence_tester.c +liblinphone_tester_SOURCES= liblinphone_tester.c setup_tester.c register_tester.c message_tester.c call_tester.c presence_tester.c #liblinphone_tester_CFLAGS=$(CUNIT_CFLAGS) diff --git a/tester/call_tester.c b/tester/call_tester.c index 8ffbdb7bf..44383a4c9 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include #include "CUnit/Basic.h" #include "linphonecore.h" @@ -22,13 +23,6 @@ #include "liblinphone_tester.h" -static int init(void) { - return 0; -} -static int uninit(void) { - return 0; -} - void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){ char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to); char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from); @@ -60,6 +54,7 @@ void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState CU_FAIL("unexpected event");break; } } + void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state) { char* to=linphone_address_as_string(linphone_call_get_call_log(transfered)->to); char* from=linphone_address_as_string(linphone_call_get_call_log(transfered)->from); @@ -80,6 +75,7 @@ void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, CU_FAIL("unexpected event");break; } } + static void linphone_call_cb(LinphoneCall *call,void * user_data) { char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to); char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from); @@ -90,6 +86,7 @@ static void linphone_call_cb(LinphoneCall *call,void * user_data) { stats* counters = (stats*)linphone_core_get_user_data(lc); counters->number_of_IframeDecoded++; } + static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr) { LinphoneProxyConfig* proxy; linphone_core_get_default_proxy(callee_mgr->lc,&proxy); @@ -140,7 +137,8 @@ static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_m wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1); } -static void simple_call() { + +static void simple_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -180,7 +178,8 @@ static void simple_call() { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void call_canceled() { + +static void cancelled_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -198,7 +197,7 @@ static void call_canceled() { linphone_core_manager_destroy(pauline); } -static void call_with_dns_time_out() { +static void call_with_dns_time_out(void) { LinphoneCoreManager* marie = linphone_core_manager_new(NULL); LCSipTransports transport = {9773,0,0,0}; linphone_core_set_sip_transports(marie->lc,&transport); @@ -213,7 +212,7 @@ static void call_with_dns_time_out() { linphone_core_manager_destroy(marie); } -static void call_ringing_canceled() { +static void cancelled_ringing_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -231,7 +230,7 @@ static void call_ringing_canceled() { linphone_core_manager_destroy(pauline); } -static void call_early_declined() { +static void early_declined_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -252,7 +251,7 @@ static void call_early_declined() { linphone_core_manager_destroy(pauline); } -static void call_terminated_by_caller() { +static void call_terminated_by_caller(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -266,7 +265,7 @@ static void call_terminated_by_caller() { linphone_core_manager_destroy(pauline); } -static void call_paused_resumed() { +static void call_paused_resumed(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); LinphoneCall* call_obj; @@ -303,7 +302,8 @@ static bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,Linph CU_ASSERT_EQUAL(linphone_call_get_state(call_2),LinphoneCallPausedByRemote); return linphone_call_get_state(call_1) == LinphoneCallPaused && linphone_call_get_state(call_2)==LinphoneCallPausedByRemote; } -static void call_paused_resumed_from_callee() { + +static void call_paused_resumed_from_callee(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); LinphoneCall* call_obj; @@ -329,7 +329,7 @@ static void call_paused_resumed_from_callee() { linphone_core_manager_destroy(pauline); } -static void call_with_video_added() { +static void call_with_video_added(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); LinphoneCall* call_obj; @@ -371,7 +371,8 @@ static void call_with_video_added() { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void simple_conference() { + +static void simple_conference(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); stats initial_marie_stat; stats initial_pauline_stat; @@ -428,8 +429,7 @@ static void simple_conference() { ms_list_free(lcs); } - -static void call_srtp() { +static void srtp_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -450,7 +450,7 @@ static void call_srtp() { linphone_core_manager_destroy(pauline); } -static void call_early_media() { +static void early_media_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_early_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -468,22 +468,19 @@ static void call_early_media() { linphone_core_manager_destroy(pauline); } -static void simple_call_transfer() { +static void simple_call_transfer(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); LinphoneCoreManager* laure = linphone_core_manager_new("./tester/laure_rc"); + LinphoneCall* pauline_called_by_marie; char* laure_identity=linphone_address_as_string(laure->identity); MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc); lcs=ms_list_append(lcs,laure->lc); - LinphoneCall* marie_call_pauline; - LinphoneCall* pauline_called_by_marie; - CU_ASSERT_TRUE(call(marie,pauline)); - marie_call_pauline=linphone_core_get_current_call(marie->lc); pauline_called_by_marie=linphone_core_get_current_call(pauline->lc); reset_counters(&marie->stat); @@ -520,7 +517,7 @@ static void simple_call_transfer() { ms_list_free(lcs); } -static void call_transfer_existing_call_outgoing_call() { +static void call_transfer_existing_call_outgoing_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); LinphoneCoreManager* laure = linphone_core_manager_new("./tester/laure_rc"); @@ -593,51 +590,29 @@ static void call_transfer_existing_call_outgoing_call() { ms_list_free(lcs); } -int call_test_suite () { - CU_pSuite pSuite = CU_add_suite("Call", init, uninit); - if (NULL == CU_add_test(pSuite, "call_early_declined", call_early_declined)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_canceled", call_canceled)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_with_dns_time_out", call_with_dns_time_out)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_ringing_canceled", call_ringing_canceled)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_call", simple_call)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_early_media", call_early_media)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_terminated_by_caller", call_terminated_by_caller)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_paused_resumed", call_paused_resumed)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_paused_resumed_from_callee", call_paused_resumed_from_callee)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_srtp", call_srtp)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_with_video_added", call_with_video_added)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_conference", simple_conference)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_call_transfer", simple_call_transfer)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "call_transfer_existing_call_outgoing_call", call_transfer_existing_call_outgoing_call)) { - return CU_get_error(); - } +test_t call_tests[] = { + { "Early declined call", early_declined_call }, + { "Cancelled call", cancelled_call }, + { "Call with DNS timeout", call_with_dns_time_out }, + { "Cancelled ringing call", cancelled_ringing_call }, + { "Simple call", simple_call }, + { "Early-media call", early_media_call }, + { "Call terminated by caller", call_terminated_by_caller }, + { "Call paused resumed", call_paused_resumed }, + { "Call paused resumed from callee", call_paused_resumed_from_callee }, + { "SRTP call", srtp_call }, + { "Call with video added", call_with_video_added }, + { "Simple conference", simple_conference }, + { "Simple call transfer", simple_call_transfer }, + { "Call transfer existing call outgoing call", call_transfer_existing_call_outgoing_call } +}; + +test_suite_t call_test_suite = { + "Call", + NULL, + NULL, + sizeof(call_tests) / sizeof(call_tests[0]), + call_tests +}; - return 0; -} diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 4c8861a13..26c6fbacd 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -22,24 +22,21 @@ #include "liblinphone_tester.h" +static test_suite_t **test_suite = NULL; +static int nb_test_suites = 0; + + +#if HAVE_CU_CURSES +static unsigned char curses = 0; +#endif + + +static stats global_stat; const char* test_domain="sipopen.example.org"; const char* auth_domain="sip.example.org"; const char* test_username="liblinphone_tester"; const char* test_password="secret"; -static int init(void) { - return 0; -} -static int uninit(void) { - return 0; -} -static void core_init_test(void) { - LinphoneCoreVTable v_table; - memset (&v_table,0,sizeof(v_table)); - LinphoneCore* lc = linphone_core_new(&v_table,NULL,NULL,NULL); - CU_ASSERT_PTR_NOT_NULL_FATAL(lc); - linphone_core_destroy(lc); -} LinphoneAddress * create_linphone_address(const char * domain) { LinphoneAddress *addr = linphone_address_new(NULL); @@ -54,13 +51,6 @@ LinphoneAddress * create_linphone_address(const char * domain) { CU_ASSERT_STRING_EQUAL("Mr Tester",linphone_address_get_display_name(addr)); return addr; } -static void linphone_address_test(void) { - linphone_address_destroy(create_linphone_address(NULL)); -} - - -static stats global_stat; - void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username) { ms_message("Auth info requested for user id [%s] at realm [%s]\n" @@ -110,8 +100,6 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* file,in return lc; } - - bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value) { MSList* lcs=NULL; if (lc_1) @@ -123,6 +111,7 @@ bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value) { ms_list_free(lcs); return result; } + bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { int retry=0; MSList* iterator; @@ -135,6 +124,7 @@ bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { if(*counterlc); if (mgr->identity) linphone_address_destroy(mgr->identity); @@ -176,44 +166,152 @@ void linphone_core_manager_destroy(LinphoneCoreManager* mgr) { } - -int init_test_suite () { - -CU_pSuite pSuite = CU_add_suite("Setup", init, uninit); - - - if (NULL == CU_add_test(pSuite, "linphone address tester", linphone_address_test)) { - return CU_get_error(); +static void add_test_suite(test_suite_t *suite) { + if (test_suite == NULL) { + test_suite = (test_suite_t **)malloc(10 * sizeof(test_suite_t *)); } - if (NULL == CU_add_test(pSuite, "linphone core init/uninit tester", core_init_test)) { - return CU_get_error(); + test_suite[nb_test_suites] = suite; + nb_test_suites++; + if ((nb_test_suites % 10) == 0) { + test_suite = (test_suite_t **)realloc(test_suite, (nb_test_suites + 10) * sizeof(test_suite_t *)); } +} - register_test_suite(); +static int run_test_suite(test_suite_t *suite) { + int i; - call_test_suite(); + CU_pSuite pSuite = CU_add_suite(suite->name, suite->init_func, suite->cleanup_func); - message_test_suite(); - - presence_test_suite(); + for (i = 0; i < suite->nb_tests; i++) { + if (NULL == CU_add_test(pSuite, suite->tests[i].name, suite->tests[i].func)) { + return CU_get_error(); + } + } return 0; } -int main (int argc, char *argv[]) { + +static int test_suite_index(const char *suite_name) { int i; - char *test_name=NULL; + for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) { + if ((strcmp(suite_name, test_suite[i]->name) == 0) && (strlen(suite_name) == strlen(test_suite[i]->name))) { + return i; + } + } + + return -1; +} + +int liblinphone_tester_nb_test_suites(void) { + return nb_test_suites; +} + +int liblinphone_tester_nb_tests(const char *suite_name) { + int i = test_suite_index(suite_name); + if (i < 0) return 0; + return test_suite[i]->nb_tests; +} + +const char * liblinphone_tester_test_suite_name(int suite_index) { + if (suite_index >= liblinphone_tester_nb_test_suites()) return NULL; + return test_suite[suite_index]->name; +} + +const char * liblinphone_tester_test_name(const char *suite_name, int test_index) { + int suite_index = test_suite_index(suite_name); + if ((suite_index < 0) || (suite_index >= liblinphone_tester_nb_test_suites())) return NULL; + if (test_index >= test_suite[suite_index]->nb_tests) return NULL; + return test_suite[suite_index]->tests[test_index].name; +} + +void liblinphone_tester_init(void) { + add_test_suite(&setup_test_suite); + add_test_suite(®ister_test_suite); + add_test_suite(&call_test_suite); + add_test_suite(&message_test_suite); + add_test_suite(&presence_test_suite); +} + +void liblinphone_tester_uninit(void) { + if (test_suite != NULL) { + free(test_suite); + test_suite = NULL; + nb_test_suites = 0; + } +} + +int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) { + int i; + + /* initialize the CUnit test registry */ + if (CUE_SUCCESS != CU_initialize_registry()) + return CU_get_error(); + + for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) { + run_test_suite(test_suite[i]); + } + +#if HAVE_CU_GET_SUITE + if (suite_name){ + CU_pSuite suite; + CU_basic_set_mode(CU_BRM_VERBOSE); + suite=CU_get_suite(suite_name); + if (test_name) { + CU_pTest test=CU_get_test_by_name(test_name, suite); + CU_basic_run_test(suite, test); + } else + CU_basic_run_suite(suite); + } else +#endif + { +#if HAVE_CU_CURSES + if (curses) { + /* Run tests using the CUnit curses interface */ + CU_curses_run_tests(); + } + else +#endif + { + /* Run all tests using the CUnit Basic interface */ + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + } + } + + CU_cleanup_registry(); + return CU_get_error(); +} + + +#ifndef WINAPI_FAMILY_PHONE_APP +int main (int argc, char *argv[]) { + int i; + int ret; char *suite_name=NULL; + char *test_name=NULL; + for(i=1;i\n" + "\t\t\t---auth-domain \n" +#if HAVE_CU_GET_SUITE + "\t\t\t--suite \n" + "\t\t\t--test \n" +#endif +#if HAVE_CU_CURSES + "\t\t\t--curses\n" +#endif + , argv[0]); + return 0; }else if (strcmp(argv[i],"--verbose")==0){ - linphone_core_enable_logs(NULL); + linphone_core_enable_logs(NULL); }else if (strcmp(argv[i],"--domain")==0){ i++; test_domain=argv[i]; - } else if (strcmp(argv[i],"--auth-domain")==0){ + }else if (strcmp(argv[i],"--auth-domain")==0){ i++; auth_domain=argv[i]; }else if (strcmp(argv[i],"--test")==0){ @@ -225,29 +323,10 @@ int main (int argc, char *argv[]) { } } - /* initialize the CUnit test registry */ - if (CUE_SUCCESS != CU_initialize_registry()) - return CU_get_error(); - - init_test_suite(); - /* Run all tests using the CUnit Basic interface */ - CU_basic_set_mode(CU_BRM_VERBOSE); -if (suite_name){ -#if 1 /*HAVE_CU_GET_SUITE*/ - CU_pSuite suite; - suite=CU_get_suite(suite_name); - if (test_name) { - CU_pTest test=CU_get_test_by_name(test_name, suite); - CU_basic_run_test(suite, test); - } else - CU_basic_run_suite(suite); -#else - fprintf(stderr,"Your CUnit version does not support suite selection.\n"); -#endif - } else - CU_basic_run_tests(); - - CU_cleanup_registry(); - return CU_get_error(); - + liblinphone_tester_init(); + ret = liblinphone_tester_run_tests(suite_name, test_name); + liblinphone_tester_uninit(); + return ret; } +#endif + diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 46263bf46..1d17dbffc 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -21,6 +21,51 @@ +#include "CUnit/Basic.h" + + +typedef void (*test_function_t)(void); +typedef int (*test_suite_function_t)(const char *name); + +typedef struct { + const char *name; + test_function_t func; +} test_t; + +typedef struct { + const char *name; + CU_InitializeFunc init_func; + CU_CleanupFunc cleanup_func; + int nb_tests; + test_t *tests; +} test_suite_t; + + +#ifdef __cplusplus +extern "C" { +#endif + +extern test_suite_t setup_test_suite; +extern test_suite_t register_test_suite; +extern test_suite_t call_test_suite; +extern test_suite_t message_test_suite; +extern test_suite_t presence_test_suite; + + +extern int liblinphone_tester_nb_test_suites(void); +extern int liblinphone_tester_nb_tests(const char *suite_name); +extern const char * liblinphone_tester_test_suite_name(int suite_index); +extern const char * liblinphone_tester_test_name(const char *suite_name, int test_index); +extern void liblinphone_tester_init(void); +extern void liblinphone_tester_uninit(void); +extern int liblinphone_tester_run_tests(const char *suite_name, const char *test_name); + + +#ifdef __cplusplus +}; +#endif + + const char* test_domain; const char* auth_domain; const char* test_username; @@ -77,6 +122,7 @@ typedef struct _stats { int number_of_IframeDecoded; }stats; + typedef struct _LinphoneCoreManager { LinphoneCoreVTable v_table; LinphoneCore* lc; @@ -104,9 +150,7 @@ LinphoneAddress * create_linphone_address(const char * domain); LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* file,int proxy_count); bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value); bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms); -int call_test_suite (); -int register_test_suite (); -int message_test_suite (); -int presence_test_suite (); + #endif /* LIBLINPHONE_TESTER_H_ */ + diff --git a/tester/message_tester.c b/tester/message_tester.c index 424a12b32..5050a84a8 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -15,16 +15,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include #include "CUnit/Basic.h" #include "linphonecore.h" #include "private.h" #include "liblinphone_tester.h" + void text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from_address, const char *message) { stats* counters = (stats*)linphone_core_get_user_data(lc); counters->number_of_LinphoneMessageReceivedLegacy++; } + void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* message) { char* from=linphone_address_as_string(linphone_chat_message_get_from(message)); ms_message("Message from [%s] is [%s] , external URL [%s]",from @@ -57,7 +60,7 @@ void linphone_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMes } -static void text_message() { +static void text_message(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); char* to = linphone_address_as_string(marie->identity); @@ -69,7 +72,7 @@ static void text_message() { linphone_core_manager_destroy(pauline); } -static void text_message_with_ack() { +static void text_message_with_ack(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); char* to = linphone_address_as_string(marie->identity); @@ -82,7 +85,8 @@ static void text_message_with_ack() { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void text_message_with_external_body() { + +static void text_message_with_external_body(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); char* to = linphone_address_as_string(marie->identity); @@ -99,7 +103,7 @@ static void text_message_with_external_body() { linphone_core_manager_destroy(pauline); } -static void text_message_with_send_error() { +static void text_message_with_send_error(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); char* to = linphone_address_as_string(pauline->identity); @@ -118,20 +122,19 @@ static void text_message_with_send_error() { linphone_core_manager_destroy(pauline); } -int message_test_suite () { - CU_pSuite pSuite = CU_add_suite("Message", NULL, NULL); - if (NULL == CU_add_test(pSuite, "text_message", text_message)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "text_message_with_ack", text_message_with_ack)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "text_message_with_send_error", text_message_with_send_error)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "text_message_with_external_body", text_message_with_external_body)) { - return CU_get_error(); - } - return 0; -} +test_t message_tests[] = { + { "Text message", text_message }, + { "Text message with ack", text_message_with_ack }, + { "Text message with send error", text_message_with_send_error }, + { "Text message with external body", text_message_with_external_body } +}; + +test_suite_t message_test_suite = { + "Message", + NULL, + NULL, + sizeof(message_tests) / sizeof(message_tests[0]), + message_tests +}; + diff --git a/tester/presence_tester.c b/tester/presence_tester.c index eb4bb1b95..478f042c6 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include #include "CUnit/Basic.h" #include "linphonecore.h" @@ -29,8 +30,8 @@ void new_subscribtion_request(LinphoneCore *lc, LinphoneFriend *lf, const char * stats* counters = (stats*)linphone_core_get_user_data(lc); counters->number_of_NewSubscriptionRequest++; linphone_core_add_friend(lc,lf); /*accept subscription*/ - } + void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) { char* from=linphone_address_as_string(linphone_friend_get_address(lf)); ms_message("New Notify request from [%s] ",from); @@ -39,7 +40,7 @@ void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) { counters->number_of_NotifyReceived++; } -static void simple_publish() { +static void simple_publish(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneProxyConfig* proxy; linphone_core_get_default_proxy(marie->lc,&proxy); @@ -50,8 +51,7 @@ static void simple_publish() { linphone_core_manager_destroy(marie); } - -static void simple_subscribe() { +static void simple_subscribe(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); const MSList* marie_friends = linphone_core_get_friend_list(marie->lc); @@ -69,7 +69,8 @@ static void simple_subscribe() { linphone_core_manager_destroy(pauline); } -static void unsubscribe_while_subscribing() { + +static void unsubscribe_while_subscribing(void) { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneFriend* friend = linphone_friend_new_with_addr("sip:toto@git.linphone.org"); /*any unexisting address*/ linphone_friend_edit(friend); @@ -78,19 +79,20 @@ static void unsubscribe_while_subscribing() { linphone_core_add_friend(marie->lc,friend); linphone_core_iterate(marie->lc); linphone_core_manager_destroy(marie); - } -int presence_test_suite () { - CU_pSuite pSuite = CU_add_suite("Presence", NULL, NULL); - if (NULL == CU_add_test(pSuite, "simple_subscribe", simple_subscribe)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_publish", simple_publish)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "unsubscribe_while_subscribing", unsubscribe_while_subscribing)) { - return CU_get_error(); - } - return 0; -} + +test_t presence_tests[] = { + { "Simple Subscribe", simple_subscribe }, + { "Simple Publish", simple_publish }, + { "Unsubscribe while subscribing", unsubscribe_while_subscribing }, +}; + +test_suite_t presence_test_suite = { + "Presence", + NULL, + NULL, + sizeof(presence_tests) / sizeof(presence_tests[0]), + presence_tests +}; + diff --git a/tester/register_tester.c b/tester/register_tester.c index a6b4b920a..16ae53da3 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include #include "CUnit/Basic.h" #include "linphonecore.h" @@ -27,7 +28,6 @@ static LinphoneCore* create_lc() { return create_lc_with_auth(0); } - void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){ ms_message("New registration state %s for user id [%s] at proxy [%s]\n" ,linphone_registration_state_to_string(cstate) @@ -45,6 +45,7 @@ void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *c } } + static void register_with_refresh_base_2(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route,bool_t late_auth_info) { int retry=0; LCSipTransports transport = {5070,5070,0,5071}; @@ -92,9 +93,11 @@ static void register_with_refresh_base_2(LinphoneCore* lc, bool_t refresh,const CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0); } + static void register_with_refresh_base(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route) { register_with_refresh_base_2(lc,refresh,domain,route,FALSE); } + static void register_with_refresh(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route) { stats* counters = (stats*)linphone_core_get_user_data(lc); register_with_refresh_base(lc,refresh,domain,route); @@ -124,6 +127,7 @@ static void register_with_refresh_with_send_error(void) { CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0); } + static void simple_register(){ LinphoneCore* lc = create_lc(); stats* counters = (stats*)linphone_core_get_user_data(lc); @@ -131,7 +135,6 @@ static void simple_register(){ CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,0); } - /*take care of min expires configuration from server*/ static void simple_register_with_refresh() { LinphoneCore* lc = create_lc(); @@ -153,6 +156,7 @@ static void simple_tcp_register(){ LinphoneCore* lc = create_lc(); register_with_refresh(lc,FALSE,NULL,route); } + static void simple_tls_register(){ char route[256]; sprintf(route,"sip:%s;transport=tls",test_domain); @@ -183,6 +187,7 @@ static void authenticated_register_with_no_initial_credentials(){ register_with_refresh(lc,FALSE,auth_domain,NULL); CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,1); } + static void auth_info_requested2(LinphoneCore *lc, const char *realm, const char *username) { ms_message("Auth info requested for user id [%s] at realm [%s]\n" ,username @@ -282,48 +287,28 @@ static void io_recv_error(){ linphone_core_destroy(lc); } -int register_test_suite () { - CU_pSuite pSuite = CU_add_suite("Register", NULL, NULL); - if (NULL == CU_add_test(pSuite, "simple_register", simple_register)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "tcp register tester", simple_tcp_register)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "tls register tester", simple_tls_register)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_authenticated_register", simple_authenticated_register)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "register with digest auth tester without initial credentials", authenticated_register_with_no_initial_credentials)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "authenticated_register_with_late_credentials", authenticated_register_with_late_credentials)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_register_with_refresh", simple_register_with_refresh)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "simple_auth_register_with_refresh", simple_auth_register_with_refresh)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "register_with_refresh_with_send_error", register_with_refresh_with_send_error)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "multi account", multiple_proxy)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "transport_change", transport_change)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "network_state_change", network_state_change)) { - return CU_get_error(); - } - if (NULL == CU_add_test(pSuite, "io_recv_error_0", io_recv_error)) { - return CU_get_error(); - } +test_t register_tests[] = { + { "Simple register", simple_register }, + { "TCP register", simple_tcp_register }, + { "TLS register", simple_tls_register }, + { "Simple authenticated register", simple_authenticated_register }, + { "Digest auth without initial credentials", authenticated_register_with_no_initial_credentials }, + { "Authenticated register with late credentials", authenticated_register_with_late_credentials }, + { "Register with refresh", simple_register_with_refresh }, + { "Authenticated register with refresh", simple_auth_register_with_refresh }, + { "Register with refresh & send error", register_with_refresh_with_send_error }, + { "Multi account", multiple_proxy }, + { "Transport change", transport_change }, + { "Network state change", network_state_change }, + { "io_recv_error_0", io_recv_error } +}; + +test_suite_t register_test_suite = { + "Register", + NULL, + NULL, + sizeof(register_tests) / sizeof(register_tests[0]), + register_tests +}; - return 0; -} diff --git a/tester/setup_tester.c b/tester/setup_tester.c new file mode 100644 index 000000000..4ee2564c5 --- /dev/null +++ b/tester/setup_tester.c @@ -0,0 +1,52 @@ +/* + belle-sip - SIP (RFC3261) library. + Copyright (C) 2010 Belledonne Communications SARL + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include "CUnit/Basic.h" +#include "linphonecore.h" +#include "private.h" +#include "liblinphone_tester.h" + + + +static void core_init_test(void) { + LinphoneCoreVTable v_table; + memset (&v_table,0,sizeof(v_table)); + LinphoneCore* lc = linphone_core_new(&v_table,NULL,NULL,NULL); + CU_ASSERT_PTR_NOT_NULL_FATAL(lc); + linphone_core_destroy(lc); +} + +static void linphone_address_test(void) { + linphone_address_destroy(create_linphone_address(NULL)); +} + + +test_t setup_tests[] = { + { "Linphone Address", linphone_address_test }, + { "Linphone core init/uninit", core_init_test }, +}; + +test_suite_t setup_test_suite = { + "Setup", + NULL, + NULL, + sizeof(setup_tests) / sizeof(setup_tests[0]), + setup_tests +}; +