Skip to content

Commit

Permalink
Wrong test in function prvTCPSendLoop() (FreeRTOS#1043)
Browse files Browse the repository at this point in the history
* Wrong test in function prvTCPSendLoop()

* fix unit tests

---------

Co-authored-by: tony-josi-aws <tonyjosi@amazon.com>
  • Loading branch information
htibosch and tony-josi-aws authored Nov 14, 2023
1 parent 9abe2d1 commit c263e33
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -4546,7 +4546,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
xBytesLeft -= xByteCount;
xBytesSent += xByteCount;

if( ( xBytesLeft == 0 ) && ( pvBuffer == NULL ) )
if( ( xBytesLeft == 0 ) || ( pvBuffer == NULL ) )
{
/* pvBuffer can be NULL in case TCP zero-copy transmissions are used. */
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,6 @@ void test_FreeRTOS_send_ExactSpaceInStreamBuffer( void )
xTaskResumeAll_ExpectAndReturn( pdFALSE );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );
xSendEventToIPTask_ExpectAndReturn( eTCPTimerEvent, pdPASS );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );

xReturn = FreeRTOS_send( &xSocket, pvBuffer, uxDataLength, xFlags );

Expand All @@ -1008,7 +1007,6 @@ void test_FreeRTOS_send_ExactSpaceInStreamBuffer( void )
uxStreamBufferAdd_ExpectAndReturn( xSocket.u.xTCP.txStream, 0U, pvBuffer, uxDataLength, uxDataLength );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );
xSendEventToIPTask_ExpectAndReturn( eTCPTimerEvent, pdPASS );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );
xReturn = FreeRTOS_send( &xSocket, pvBuffer, uxDataLength, xFlags );

TEST_ASSERT_EQUAL( uxDataLength, xReturn );
Expand Down Expand Up @@ -1044,7 +1042,6 @@ void test_FreeRTOS_send_MoreSpaceInStreamBuffer( void )
xTaskResumeAll_ExpectAndReturn( pdFALSE );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );
xSendEventToIPTask_ExpectAndReturn( eTCPTimerEvent, pdPASS );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );
xReturn = FreeRTOS_send( &xSocket, pvBuffer, uxDataLength, xFlags );

TEST_ASSERT_EQUAL( uxDataLength, xReturn );
Expand Down Expand Up @@ -1132,7 +1129,6 @@ void test_FreeRTOS_send_LessSpaceInStreamBuffer_EventuallySpaceAvailable( void )
uxStreamBufferAdd_ExpectAndReturn( xSocket.u.xTCP.txStream, 0U, &pvBuffer[ 80 ], 20, 20 );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );
xSendEventToIPTask_ExpectAndReturn( eTCPTimerEvent, pdFALSE );
xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdTRUE );

xReturn = FreeRTOS_send( &xSocket, pvBuffer, uxDataLength, xFlags );

Expand Down Expand Up @@ -1290,7 +1286,6 @@ void test_FreeRTOS_send_IPTaskWithNULLBuffer_LessSpaceInStreamBuffer( void )
uxStreamBufferGetSpace_ExpectAndReturn( xSocket.u.xTCP.txStream, uxDataLength - 20 );
uxStreamBufferAdd_ExpectAndReturn( xSocket.u.xTCP.txStream, 0U, NULL, uxDataLength - 20, uxDataLength - 20 );
xIsCallingFromIPTask_ExpectAndReturn( pdTRUE );
xIsCallingFromIPTask_ExpectAndReturn( pdTRUE );

xReturn = FreeRTOS_send( &xSocket, NULL, uxDataLength, xFlags );

Expand Down Expand Up @@ -1360,7 +1355,6 @@ void test_FreeRTOS_send_ExactSpaceInStreamBufferInIPTask( void )
uxStreamBufferAdd_ExpectAndReturn( xSocket.u.xTCP.txStream, 0U, pvBuffer, uxDataLength, uxDataLength );
xTaskResumeAll_ExpectAndReturn( pdFALSE );
xIsCallingFromIPTask_ExpectAndReturn( pdTRUE );
xIsCallingFromIPTask_ExpectAndReturn( pdFALSE );

xReturn = FreeRTOS_send( &xSocket, pvBuffer, uxDataLength, xFlags );

Expand Down

0 comments on commit c263e33

Please sign in to comment.