diff --git a/tests/test_ParodusInternal.c b/tests/test_ParodusInternal.c index 67328f2..4442163 100644 --- a/tests/test_ParodusInternal.c +++ b/tests/test_ParodusInternal.c @@ -56,7 +56,7 @@ char *get_global_reconnect_reason() void test_getWebpaConveyHeader() { ParodusCfg cfg; - + memset(&cfg, 0, sizeof(ParodusCfg)); parStrncpy(cfg.hw_model, "TG1682", sizeof(cfg.hw_model)); parStrncpy(cfg.hw_serial_number, "Fer23u948590", sizeof(cfg.hw_serial_number)); parStrncpy(cfg.hw_manufacturer , "ARRISGroup,Inc.", sizeof(cfg.hw_manufacturer)); diff --git a/tests/test_client_list.c b/tests/test_client_list.c index 0422b1a..c7fcc48 100644 --- a/tests/test_client_list.c +++ b/tests/test_client_list.c @@ -87,13 +87,23 @@ static void *client_rcv_task() int byte =0; int rv1=0; int t=25000; + int rc = -1; + int bind; wrp_msg_t *msg1; int sock1 = nn_socket (AF_SP, NN_PULL); - nn_bind(sock1, TEST_CLIENT1_URL); + bind = nn_bind(sock1, TEST_CLIENT1_URL); + if(bind < 0) + { + ParodusError("Unable to bind socket (errno=%d, %s)\n",errno, strerror(errno)); + } void *buf = NULL; - nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t)); + rc = nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t)); + if(rc < 0) + { + ParodusError ("Unable to set socket timeout (errno=%d, %s)\n",errno, strerror(errno)); + } ParodusPrint("Client 1 waiting for acknowledgement \n"); byte = nn_recv(sock1, &buf, NN_MSG, 0); @@ -119,13 +129,23 @@ static void *client2_rcv_task() int byte =0; int rv1=0; int t=25000; + int rc = -1; + int bind; wrp_msg_t *msg1; int sock1 = nn_socket (AF_SP, NN_PULL); - nn_bind(sock1, TEST_CLIENT2_URL); + bind = nn_bind(sock1, TEST_CLIENT2_URL); + if(bind < 0) + { + ParodusError("Unable to bind socket (errno=%d, %s)\n",errno, strerror(errno)); + } void *buf = NULL; - nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t)); + rc = nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t)); + if(rc < 0) + { + ParodusError ("Unable to set socket timeout (errno=%d, %s)\n",errno, strerror(errno)); + } ParodusPrint("Client 2 waiting for acknowledgement \n"); byte = nn_recv(sock1, &buf, NN_MSG, 0); diff --git a/tests/test_conn_interface.c b/tests/test_conn_interface.c index 17835f6..0bc37b5 100644 --- a/tests/test_conn_interface.c +++ b/tests/test_conn_interface.c @@ -34,6 +34,7 @@ UpStreamMsg *UpStreamMsgQ; ParodusMsg *ParodusMsgQ; extern bool close_retry; +extern pthread_mutex_t close_mut; extern volatile unsigned int heartBeatTimer; /*----------------------------------------------------------------------------*/ /* Mocks */ @@ -160,7 +161,9 @@ void test_createSocketConnection() ParodusCfg cfg; memset(&cfg,0,sizeof(ParodusCfg)); + pthread_mutex_lock (&close_mut); close_retry = false; + pthread_mutex_unlock (&close_mut); expect_function_call(nopoll_thread_handlers); will_return(nopoll_ctx_new, (intptr_t)&ctx); @@ -195,7 +198,9 @@ void test_createSocketConnection1() noPollCtx *ctx; ParodusCfg cfg; memset(&cfg,0, sizeof(ParodusCfg)); + pthread_mutex_lock (&close_mut); close_retry = true; + pthread_mutex_unlock (&close_mut); expect_function_call(nopoll_thread_handlers); will_return(nopoll_ctx_new, (intptr_t)&ctx); @@ -242,7 +247,9 @@ void test_createSocketConnection2() parStrncpy(cfg.webpa_uuid , "1234567-345456546", sizeof(cfg.webpa_uuid)); cfg.webpa_ping_timeout = 1; + pthread_mutex_lock (&close_mut); close_retry = false; + pthread_mutex_unlock (&close_mut); expect_function_call(nopoll_thread_handlers); will_return(nopoll_ctx_new, (intptr_t)&ctx); @@ -279,7 +286,9 @@ void test_createSocketConnection2() void err_createSocketConnection() { + pthread_mutex_lock (&close_mut); close_retry = true; + pthread_mutex_unlock (&close_mut); heartBeatTimer = 0; expect_function_call(nopoll_thread_handlers); diff --git a/tests/test_mutex.c b/tests/test_mutex.c index a1a4321..42d52bd 100644 --- a/tests/test_mutex.c +++ b/tests/test_mutex.c @@ -54,9 +54,7 @@ void* a(void *in) lockMutex(data->mutex); data->number++; - sleep(1); data->number++; - sleep(1); data->number++; unlockMutex(data->mutex); @@ -69,9 +67,7 @@ void* b(void *in) lockMutex(data->mutex); data->number+=10; - sleep(1); data->number+=10; - sleep(1); data->number+=10; unlockMutex(data->mutex); @@ -108,6 +104,8 @@ void err_mutex() will_return(pthread_mutex_init, -1); mutex = createMutex(); + destroyMutex(mutex); + } void err_mutexNull() diff --git a/tests/test_partners_check.c b/tests/test_partners_check.c index 46121c1..a3ad973 100755 --- a/tests/test_partners_check.c +++ b/tests/test_partners_check.c @@ -129,7 +129,8 @@ void test_validate_partner_id_for_event() partners_t *list = NULL; int ret = validate_partner_id(msg, &list); - assert_int_equal(ret, 1); + assert_int_equal(ret, 1); + free(list); free(msg); } diff --git a/tests/test_service_alive.c b/tests/test_service_alive.c index e93f41c..0742380 100644 --- a/tests/test_service_alive.c +++ b/tests/test_service_alive.c @@ -77,13 +77,23 @@ static void *client_rcv_task() int byte =0; int rv1=0; int t=25000; + int rc = -1; + int bind; wrp_msg_t *msg1; sock1 = nn_socket (AF_SP, NN_PULL); - nn_bind(sock1, TEST_SERVICE_URL); + bind = nn_bind(sock1, TEST_SERVICE_URL); + if(bind < 0) + { + ParodusError("Unable to bind socket (errno=%d, %s)\n",errno, strerror(errno)); + } void *buf = NULL; - nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t)); + rc = nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t)); + if(rc < 0) + { + ParodusError ("Unable to set socket timeout (errno=%d, %s)\n",errno, strerror(errno)); + } ParodusPrint("Client 1 waiting for acknowledgement \n"); byte = nn_recv(sock1, &buf, NN_MSG, 0);