Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Aug 26, 2024
1 parent 6a8b501 commit 973fbc4
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ STLIDMPUSR
STLIMPUOR
STLNVICACTVOR
STLNVICPENDOR
Storex
strbt
STRBT
strexb
Expand Down
10 changes: 5 additions & 5 deletions test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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 );
/* =================================================== */
Expand All @@ -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;

Expand All @@ -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 );
Expand All @@ -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 );
/* =================================================== */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
24 changes: 12 additions & 12 deletions test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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();

Expand All @@ -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 )
Expand All @@ -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 );

Expand Down Expand Up @@ -2489,7 +2489,7 @@ void test_prvProcessIPPacket_ValidHeader_ARPResolutionReqd( void )

eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer );

TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult );
TEST_ASSERT_EQUAL( eWaitingResolution, eResult );
}

/**
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
volatile BaseType_t xInsideInterrupt = pdFALSE;

NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer;
NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer;

struct xNetworkEndPoint * pxNetworkEndPoints;
struct xNetworkInterface * pxNetworkInterfaces;
Expand Down
1 change: 1 addition & 0 deletions test/unit-test/FreeRTOS_IP_Utils/ut.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -3680,13 +3680,13 @@ void test_xCheckRequiresResolution( void )
IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader );

*ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234;
xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234;

xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00;
xNetworkBuffer.pxEndPoint = &xEndPoint;

/* Make sure there is no match. */
pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask );
pxIPHeader->ulSourceIPAddress = ~( xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );
xCheckRequiresARPResolution_IgnoreAndReturn( pdFALSE );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 973fbc4

Please sign in to comment.