1
0
mirror of https://github.com/FreeRTOS/FreeRTOS-Plus-TCP synced 2025-10-23 18:38:33 +08:00
Files
FreeRTOS-Plus-TCP/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/FreeRTOS_ARP_DataLenLessThanMinPacket_utest.c
Tony Josi 0639fd45a0 Fix unit test build issues and test failures for IP Utils (#699)
* Fix seg fault

* Remove ipconfigUSE_IPV6

* Add change for FreeRTOS_IP_Utils unit test case

* Fix  comments

* Uncrustify: triggered by comment.

* Fixed build issue with IP utils unit test build.

* Removed calculation of checksum being done twice for debug printf

---------

Co-authored-by: Monika Singh <moninom@amazon.com>
Co-authored-by: Monika Singh <108652024+moninom1@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
2023-02-07 10:19:09 +05:30

68 lines
2.1 KiB
C

/* Include Unity header */
#include "unity.h"
/* Include standard libraries */
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "FreeRTOSIPConfig.h"
#include "mock_FreeRTOS_IP.h"
#include "mock_FreeRTOS_Routing.h"
#include "mock_FreeRTOS_IP_Timers.h"
#include "mock_FreeRTOS_IP_Private.h"
#include "mock_task.h"
#include "mock_NetworkBufferManagement.h"
#include "mock_NetworkInterface.h"
#include "mock_ARP_DataLenLessThanMinPacket_list_macros.h"
#include "FreeRTOS_ARP_DataLenLessThanMinPacket_stubs.c"
#include "FreeRTOS_ARP.h"
#include "catch_assert.h"
static uint32_t uInterfaceOut_Called = 0;
BaseType_t xNetworkInterfaceOutput_ARP_Stub( NetworkInterface_t * pxInterface,
NetworkBufferDescriptor_t * const pxNetworkBuffer,
BaseType_t bReleaseAfterSend )
{
uInterfaceOut_Called = 1;
return pdTRUE_UNSIGNED;
}
void test_FreeRTOS_OutputARPRequest_MinimumPacketSizeLessThanARPPacket( void )
{
NetworkEndPoint_t xEndPoint;
NetworkInterface_t xInterface;
uint8_t ucBuffer[ sizeof( ARPPacket_t ) + ipBUFFER_PADDING + ipconfigETHERNET_MINIMUM_PACKET_BYTES ];
NetworkBufferDescriptor_t xNetworkBuffer;
uint32_t ulIPAddress = 0xAAAAAAAA;
xNetworkBuffer.pucEthernetBuffer = ucBuffer;
xNetworkBuffer.xDataLength = sizeof( ARPPacket_t );
xInterface.pfOutput = xNetworkInterfaceOutput_ARP_Stub;
xEndPoint.pxNetworkInterface = &xInterface;
xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED;
xEndPoint.ipv4_settings.ulIPAddress = 0xC0C0C0C0;
/* =================================================== */
FreeRTOS_FirstEndPoint_ExpectAndReturn(NULL, &xEndPoint);
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
xIsCallingFromIPTask_IgnoreAndReturn( pdTRUE );
FreeRTOS_NextEndPoint_ExpectAndReturn(NULL, &xEndPoint, NULL);
FreeRTOS_OutputARPRequest( ulIPAddress );
TEST_ASSERT_EQUAL( uInterfaceOut_Called, 1 );
/* =================================================== */
}