From 80e2cc7e0d96ea1361e71212583da1861db6843c Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 1 Dec 2023 14:00:00 +0000 Subject: [PATCH] Fix UT coverage --- .../FreeRTOS_Sockets_TCP_API_utest.c | 4 +++ .../FreeRTOS_Sockets_privates_utest.c | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c index f242720d8..8a562c408 100644 --- a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c +++ b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c @@ -1863,6 +1863,10 @@ void test_FreeRTOS_get_tx_base_InvalidParams( void ) xSocket.ucProtocol = FREERTOS_IPPROTO_TCP; pucReturn = FreeRTOS_get_tx_base( &xSocket ); TEST_ASSERT_EQUAL( NULL, pucReturn ); + + xSocket.u.xTCP.bits.bMallocError == pdTRUE_UNSIGNED; + pucReturn = FreeRTOS_get_tx_base( &xSocket ); + TEST_ASSERT_EQUAL( NULL, pucReturn ); } /** diff --git a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_privates_utest.c b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_privates_utest.c index 53ef4625a..8c7304893 100644 --- a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_privates_utest.c +++ b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_privates_utest.c @@ -591,7 +591,7 @@ void test_vSocketBind_TCP( void ) /** * @brief Address passed is NULL. */ -void test_vSocketBind_TCPNULLAddress( void ) +void test_vSocketBind_TCPNULLAddress_v4( void ) { BaseType_t xReturn; FreeRTOS_Socket_t xSocket; @@ -603,6 +603,30 @@ void test_vSocketBind_TCPNULLAddress( void ) memset( &xSocket, 0, sizeof( xSocket ) ); xSocket.ucProtocol = ( uint8_t ) FREERTOS_IPPROTO_TCP; + xSocket.bits.bIsIPv6 = 0; + + xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdFALSE ); + xReturn = vSocketBind( &xSocket, NULL, uxAddressLength, xInternal ); + + TEST_ASSERT_EQUAL( -pdFREERTOS_ERRNO_EADDRNOTAVAIL, xReturn ); +} + +/** + * @brief Address passed is NULL. + */ +void test_vSocketBind_TCPNULLAddress_v6( void ) +{ + BaseType_t xReturn; + FreeRTOS_Socket_t xSocket; + struct freertos_sockaddr xBindAddress; + size_t uxAddressLength; + BaseType_t xInternal = pdFALSE; + + memset( &xBindAddress, 0xFC, sizeof( xBindAddress ) ); + memset( &xSocket, 0, sizeof( xSocket ) ); + + xSocket.ucProtocol = ( uint8_t ) FREERTOS_IPPROTO_TCP; + xSocket.bits.bIsIPv6 = 1; xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdFALSE ); xReturn = vSocketBind( &xSocket, NULL, uxAddressLength, xInternal );