@@ -1233,10 +1233,40 @@ void test_FreeRTOS_send_DisconnectionOccursDuringWait( void )
12331233}
12341234
12351235/*
1236- * @brief IP task is calling send function with a NULL buffer. Also there are 20 bytes worth of space
1237- * less in the stream buffer as the data length.
1236+ * @brief IP task is calling send function with a NULL buffer (TCP zero copy).
12381237 */
12391238void test_FreeRTOS_send_IPTaskWithNULLBuffer ( void )
1239+ {
1240+ BaseType_t xReturn ;
1241+ FreeRTOS_Socket_t xSocket ;
1242+ size_t uxNettLength = 100 ;
1243+ BaseType_t xFlags = 0 ;
1244+ StreamBuffer_t xLocalStreamBuffer ;
1245+
1246+ memset ( & xSocket , 0 , sizeof ( xSocket ) );
1247+ memset ( & xLocalStreamBuffer , 0 , sizeof ( xLocalStreamBuffer ) );
1248+
1249+ xSocket .ucProtocol = FREERTOS_IPPROTO_TCP ;
1250+ xSocket .u .xTCP .eTCPState = eESTABLISHED ;
1251+ xSocket .u .xTCP .bits .bFinSent = pdFALSE_UNSIGNED ;
1252+ xSocket .u .xTCP .txStream = & xLocalStreamBuffer ;
1253+ xSocket .xSendBlockTime = 100 ;
1254+
1255+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
1256+ uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , uxNettLength );
1257+ uxStreamBufferAdd_ExpectAndReturn ( xSocket .u .xTCP .txStream , 0U , NULL , uxNettLength , uxNettLength );
1258+ xIsCallingFromIPTask_ExpectAndReturn ( pdTRUE );
1259+
1260+ xReturn = FreeRTOS_send ( & xSocket , NULL , uxNettLength , xFlags );
1261+
1262+ TEST_ASSERT_EQUAL ( uxNettLength , xReturn );
1263+ }
1264+
1265+ /*
1266+ * @brief IP task is calling send function with a NULL buffer (TCP zero copy). Also there are 20 bytes worth of space
1267+ * less in the stream buffer as the data length.
1268+ */
1269+ void test_FreeRTOS_send_IPTaskWithNULLBuffer_LessSpaceInStreamBuffer ( void )
12401270{
12411271 BaseType_t xReturn ;
12421272 FreeRTOS_Socket_t xSocket ;
@@ -1256,9 +1286,15 @@ void test_FreeRTOS_send_IPTaskWithNULLBuffer( void )
12561286
12571287 uxDataLength = 100 ;
12581288
1289+ listLIST_ITEM_CONTAINER_ExpectAnyArgsAndReturn ( & xBoundTCPSocketsList );
1290+ uxStreamBufferGetSpace_ExpectAndReturn ( xSocket .u .xTCP .txStream , uxDataLength - 20 );
1291+ uxStreamBufferAdd_ExpectAndReturn ( xSocket .u .xTCP .txStream , 0U , NULL , uxDataLength - 20 , uxDataLength - 20 );
1292+ xIsCallingFromIPTask_ExpectAndReturn ( pdTRUE );
1293+ xIsCallingFromIPTask_ExpectAndReturn ( pdTRUE );
1294+
12591295 xReturn = FreeRTOS_send ( & xSocket , NULL , uxDataLength , xFlags );
12601296
1261- TEST_ASSERT_EQUAL ( - pdFREERTOS_ERRNO_EINVAL , xReturn );
1297+ TEST_ASSERT_EQUAL ( uxDataLength - 20 , xReturn );
12621298}
12631299
12641300/**
0 commit comments