@@ -1233,10 +1233,40 @@ void test_FreeRTOS_send_DisconnectionOccursDuringWait( void )
1233
1233
}
1234
1234
1235
1235
/*
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).
1238
1237
*/
1239
1238
void 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 )
1240
1270
{
1241
1271
BaseType_t xReturn ;
1242
1272
FreeRTOS_Socket_t xSocket ;
@@ -1256,9 +1286,15 @@ void test_FreeRTOS_send_IPTaskWithNULLBuffer( void )
1256
1286
1257
1287
uxDataLength = 100 ;
1258
1288
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
+
1259
1295
xReturn = FreeRTOS_send ( & xSocket , NULL , uxDataLength , xFlags );
1260
1296
1261
- TEST_ASSERT_EQUAL ( - pdFREERTOS_ERRNO_EINVAL , xReturn );
1297
+ TEST_ASSERT_EQUAL ( uxDataLength - 20 , xReturn );
1262
1298
}
1263
1299
1264
1300
/**
0 commit comments