Skip to content

Commit

Permalink
Repair unit test FreeRTOS_Sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
htibosch committed Dec 22, 2023
1 parent 497eca1 commit a3e6480
Showing 1 changed file with 57 additions and 15 deletions.
72 changes: 57 additions & 15 deletions test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_UDP_API_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,14 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_JustUDPHeader( void )

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();

uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );

uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -441,9 +446,13 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_Packet100( void )

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();
{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );

uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -503,9 +512,13 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_Packet100SizeSmall( void

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();
{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );

uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -566,7 +579,13 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_Packet100SizeSmall_Peek(

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();

{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
}

xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -624,7 +643,12 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_Packet100SizeSmall_Peek_

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();

{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -681,9 +705,15 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_Packet100SizeSmall_ZeroC

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();

{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );

uxListRemove_ExpectAndReturn( &xNetworkBuffer.xBufferListItem, 0U );
}

uxListRemove_ExpectAndReturn( &xNetworkBuffer.xBufferListItem, 0U );
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -733,7 +763,11 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBegining_Packet100SizeSmall_Zero
xListItem.pvOwner = &xNetworkBuffer;
xSocket->u.xUDP.xWaitingPacketsList.xListEnd.pxNext = &xListItem;

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();
{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER );

Expand Down Expand Up @@ -789,9 +823,13 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_IPv6Packet100( void )

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();
{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );

uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER );

Expand Down Expand Up @@ -850,9 +888,13 @@ void test_FreeRTOS_recvfrom_BlockingGetsPacketInBetween_UnknownIPHeaderSize( voi

listCURRENT_LIST_LENGTH_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), 0x12 );

listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );
vTaskSuspendAll_Expect();
{
listGET_OWNER_OF_HEAD_ENTRY_ExpectAndReturn( &( xSocket->u.xUDP.xWaitingPacketsList ), &xNetworkBuffer );

uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
uxListRemove_ExpectAndReturn( &( xNetworkBuffer.xBufferListItem ), 0 );
}
xTaskResumeAll_ExpectAndReturn( pdFALSE );

uxIPHeaderSizePacket_IgnoreAndReturn( 0xFF );

Expand Down

0 comments on commit a3e6480

Please sign in to comment.