@@ -984,6 +984,7 @@ void test_FreeRTOS_send_LessSpaceInStreamBuffer_Timeout( void )
984984 xIsCallingFromIPTask_ExpectAndReturn ( pdFALSE );
985985 vTaskSetTimeOutState_ExpectAnyArgs ();
986986 xEventGroupWaitBits_ExpectAndReturn ( xSocket .xEventGroup , eSOCKET_SEND | eSOCKET_CLOSED , pdTRUE , pdFALSE , 100 , pdFALSE );
987+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
987988
988989 /* Second Iteration. No space still. */
989990 uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , 0 );
@@ -1026,6 +1027,7 @@ void test_FreeRTOS_send_LessSpaceInStreamBuffer_EventuallySpaceAvailable( void )
10261027 xIsCallingFromIPTask_ExpectAndReturn ( pdFALSE );
10271028 vTaskSetTimeOutState_ExpectAnyArgs ();
10281029 xEventGroupWaitBits_ExpectAndReturn ( xSocket .xEventGroup , eSOCKET_SEND | eSOCKET_CLOSED , pdTRUE , pdFALSE , 100 , pdFALSE );
1030+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
10291031
10301032 /* Second Iteration. */
10311033 uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , 20 );
@@ -1068,6 +1070,7 @@ void test_FreeRTOS_send_MultipleIterationsAndNoSuccess( void )
10681070 xIsCallingFromIPTask_ExpectAndReturn ( pdFALSE );
10691071 vTaskSetTimeOutState_ExpectAnyArgs ();
10701072 xEventGroupWaitBits_ExpectAndReturn ( xSocket .xEventGroup , eSOCKET_SEND | eSOCKET_CLOSED , pdTRUE , pdFALSE , 100 , pdFALSE );
1073+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
10711074
10721075 /* Second Iteration. */
10731076 uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , 10 );
@@ -1078,6 +1081,7 @@ void test_FreeRTOS_send_MultipleIterationsAndNoSuccess( void )
10781081 xTaskCheckForTimeOut_ExpectAnyArgsAndReturn ( pdFALSE );
10791082
10801083 xEventGroupWaitBits_ExpectAndReturn ( xSocket .xEventGroup , eSOCKET_SEND | eSOCKET_CLOSED , pdTRUE , pdFALSE , 100 , pdFALSE );
1084+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
10811085
10821086 /* Third iteration. No space still. */
10831087 uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , 0 );
@@ -1089,6 +1093,46 @@ void test_FreeRTOS_send_MultipleIterationsAndNoSuccess( void )
10891093 TEST_ASSERT_EQUAL ( uxDataLength - 10 , xReturn );
10901094}
10911095
1096+ /*
1097+ * @brief While waiting for space, the socket gets disconnected.
1098+ */
1099+ void test_FreeRTOS_send_DisconnectionOccursDuringWait ( void )
1100+ {
1101+ BaseType_t xReturn ;
1102+ FreeRTOS_Socket_t xSocket ;
1103+ uint8_t pvBuffer [ ipconfigTCP_MSS ];
1104+ size_t uxDataLength ;
1105+ BaseType_t xFlags = 0 ;
1106+ StreamBuffer_t xLocalStreamBuffer ;
1107+
1108+ memset ( & xSocket , 0 , sizeof ( xSocket ) );
1109+ memset ( pvBuffer , 0 , ipconfigTCP_MSS );
1110+
1111+ xSocket .ucProtocol = FREERTOS_IPPROTO_TCP ;
1112+ xSocket .u .xTCP .eTCPState = eESTABLISHED ;
1113+ xSocket .u .xTCP .bits .bFinSent = pdFALSE_UNSIGNED ;
1114+ xSocket .u .xTCP .txStream = & xLocalStreamBuffer ;
1115+ xSocket .xSendBlockTime = 100 ;
1116+
1117+ uxDataLength = 100 ;
1118+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
1119+ uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , uxDataLength - 20 );
1120+ uxStreamBufferAdd_ExpectAndReturn ( xSocket .u .xTCP .txStream , 0U , pvBuffer , uxDataLength - 20 , uxDataLength - 20 );
1121+ xIsCallingFromIPTask_ExpectAndReturn ( pdFALSE );
1122+ xSendEventToIPTask_ExpectAndReturn ( eTCPTimerEvent , pdFALSE );
1123+ xIsCallingFromIPTask_ExpectAndReturn ( pdFALSE );
1124+ vTaskSetTimeOutState_ExpectAnyArgs ();
1125+ xEventGroupWaitBits_ExpectAndReturn ( xSocket .xEventGroup , eSOCKET_SEND | eSOCKET_CLOSED , pdTRUE , pdFALSE , 100 , pdFALSE );
1126+
1127+ /* Let `socketSOCKET_IS_BOUND()` return false, so that prvTCPSendCheck()
1128+ * returns en error, so that the loop is stopped. */
1129+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( NULL );
1130+
1131+ xReturn = FreeRTOS_send ( & xSocket , pvBuffer , uxDataLength , xFlags );
1132+
1133+ TEST_ASSERT_EQUAL ( uxDataLength - 20 , xReturn );
1134+ }
1135+
10921136/*
10931137 * @brief IP task is calling send function with a NULL buffer. Also there are 20 bytes worth of space
10941138 * less in the stream buffer as the data length.
0 commit comments