From 08ed9d52e11248baaec93af95f2adf3c27f6d2ee Mon Sep 17 00:00:00 2001 From: Holden Date: Sun, 25 Aug 2024 18:41:56 -0400 Subject: [PATCH] Fix Tests --- .github/.cSpellWords.txt | 1 + .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 10 ++++---- .../ut.cmake | 2 +- .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 24 +++++++++---------- .../FreeRTOS_IP_Timers_stubs.c | 1 + test/unit-test/FreeRTOS_IP_Utils/ut.cmake | 1 + .../FreeRTOS_TCP_Transmission_utest.c | 2 +- .../FreeRTOS_TCP_Transmission_IPv6_utest.c | 2 +- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt index ed12e1e9c1..a179360172 100644 --- a/.github/.cSpellWords.txt +++ b/.github/.cSpellWords.txt @@ -1263,6 +1263,7 @@ STLIDMPUSR STLIMPUOR STLNVICACTVOR STLNVICPENDOR +Storex strbt STRBT strexb diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index b0e3d04c1e..e75eee9780 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1961,7 +1961,7 @@ void test_eARPGetCacheEntryByMac_NoMatchingEntries( void ) eResolutionLookupResult_t eResult; MACAddress_t xMACAddress = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }; int i; - struct xNetworkInterface * xInterface; + NetworkInterface_t xInterface, * pxInterface = &xInterface; /* =================================================== */ /* Make sure no entry matches. */ @@ -1971,7 +1971,7 @@ void test_eARPGetCacheEntryByMac_NoMatchingEntries( void ) memset( xARPCache[ i ].xMACAddress.ucBytes, 0x11, sizeof( xMACAddress.ucBytes ) ); } - eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); + eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &pxInterface ); TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); TEST_ASSERT_EQUAL( 0x12345678, ulIPAddress ); /* =================================================== */ @@ -1984,7 +1984,7 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) MACAddress_t xMACAddress = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }; int i; NetworkEndPoint_t xNetworkEndPoint = { 0 }; - NetworkInterface_t xInterface, * pxInterface = NULL; + NetworkInterface_t xInterface, * pxInterface = &xInterface; xNetworkEndPoint.pxNetworkInterface = &xInterface; @@ -2000,7 +2000,7 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) ulEntryToTest = 1; memset( xARPCache[ ulEntryToTest ].xMACAddress.ucBytes, 0x22, sizeof( xMACAddress.ucBytes ) ); xARPCache[ ulEntryToTest ].ulIPAddress = 0xAABBCCEE; - eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); + eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &pxInterface ); TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); TEST_ASSERT_EQUAL( &xInterface, pxInterface ); @@ -2010,7 +2010,7 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ xARPCache[ ulEntryToTest ].pxEndPoint = NULL; - eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); + eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &pxInterface ); TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ diff --git a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake index 6455955658..949036f436 100644 --- a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake +++ b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake @@ -41,7 +41,7 @@ list(APPEND mock_define_list # list the files you would like to test here set(real_source_files "") list(APPEND real_source_files - ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c + ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/FreeRTOS_ARP.c ) # list the directories the module under test includes set(real_include_directories "") diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index ff9a69706b..5f2c192c5c 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -2116,7 +2116,7 @@ void test_prvProcessEthernetPacket_ARPFrameType2( void ) /** * @brief test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution - * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingARPResolution + * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingResolution * without pxARPWaitingNetworkBuffer. */ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution( void ) @@ -2141,7 +2141,7 @@ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution( void ) pxEthernetHeader->usFrameType = ipARP_FRAME_TYPE; - eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingARPResolution ); + eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingResolution ); vIPTimerStartARPResolution_ExpectAnyArgs(); @@ -2150,7 +2150,7 @@ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution( void ) /** * @brief test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution2 - * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingARPResolution + * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingResolution * with pxARPWaitingNetworkBuffer. */ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution2( void ) @@ -2175,7 +2175,7 @@ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution2( void ) pxEthernetHeader->usFrameType = ipARP_FRAME_TYPE; - eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingARPResolution ); + eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingResolution ); vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); @@ -2489,7 +2489,7 @@ void test_prvProcessIPPacket_ValidHeader_ARPResolutionReqd( void ) eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); } /** @@ -2825,12 +2825,12 @@ void test_prvProcessIPPacket_ARPResolutionReqd_UDP( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); xProcessReceivedUDPPacket_ExpectAndReturn( pxNetworkBuffer, pxUDPPacket->xUDPHeader.usDestinationPort, NULL, pdFAIL ); - xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForARPResolution(); - xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForARPResolution( &xReturnValue ); + xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForResolution(); + xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForResolution( &xReturnValue ); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); TEST_ASSERT_EQUAL( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) + sizeof( UDPPacket_t ), pxNetworkBuffer->xDataLength ); TEST_ASSERT_EQUAL( pxNetworkBuffer->usPort, pxUDPPacket->xUDPHeader.usSourcePort ); TEST_ASSERT_EQUAL( pxNetworkBuffer->xIPAddress.ulIP_IPv4, pxUDPPacket->xIPHeader.ulSourceIPAddress ); @@ -2876,12 +2876,12 @@ void test_prvProcessIPPacket_ARPResolutionReqd_UDP1( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); xProcessReceivedUDPPacket_ExpectAndReturn( pxNetworkBuffer, pxUDPPacket->xUDPHeader.usDestinationPort, NULL, pdFAIL ); - xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForARPResolution(); - xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForARPResolution( &xReturnValue ); + xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForResolution(); + xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForResolution( &xReturnValue ); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); TEST_ASSERT_EQUAL( pxNetworkBuffer->usPort, pxUDPPacket->xUDPHeader.usSourcePort ); TEST_ASSERT_EQUAL( pxNetworkBuffer->xIPAddress.ulIP_IPv4, pxUDPPacket->xIPHeader.ulSourceIPAddress ); } @@ -3360,7 +3360,7 @@ void test_prvProcessIPPacket_TCP_IPv6_ARPResolution( void ) eResult = prvProcessIPPacket( ( IPPacket_t * ) pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); } /** diff --git a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c index 2674e64080..11feca0715 100644 --- a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c +++ b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c @@ -43,6 +43,7 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer; +NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer; struct xNetworkEndPoint * pxNetworkEndPoints; struct xNetworkInterface * pxNetworkInterfaces; diff --git a/test/unit-test/FreeRTOS_IP_Utils/ut.cmake b/test/unit-test/FreeRTOS_IP_Utils/ut.cmake index 8c5f73078b..70d93eed9f 100644 --- a/test/unit-test/FreeRTOS_IP_Utils/ut.cmake +++ b/test/unit-test/FreeRTOS_IP_Utils/ut.cmake @@ -18,6 +18,7 @@ list(APPEND mock_list "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h" + "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ND.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCPv6.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h" diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index 4980db9eb4..bdfae76934 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -1212,7 +1212,7 @@ void test_prvTCPPrepareConnect_Ready_TCPWindowCreateFail( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; pxSocket->bits.bIsIPv6 = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0x11111111 ); prvSocketSetMSS_ExpectAnyArgs(); xTCPWindowCreate_ExpectAnyArgsAndReturn( pdFAIL ); diff --git a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c index b840ebb61b..31c4339ce7 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c @@ -574,7 +574,7 @@ void test_prvTCPPrepareConnect_IPV6_CreateTCPWindowFails( void ) memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); pxSocket->bits.bIsIPv6 = 1; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER );