1
0
mirror of https://github.com/FreeRTOS/FreeRTOS-Plus-TCP synced 2025-10-24 03:32:36 +08:00
Files
FreeRTOS-Plus-TCP/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/FreeRTOS_ARP_DataLenLessThanMinPacket_utest.c
Tony Josi 36172f9b66 Fix unit tests wrt. latest dev/IPv6_Integration changes (#740)
* fix ip timers unit tests

* fix FreeRTOS_IP_Utils_DiffConfig_utest tests

* fixed FreeRTOS_IP_Utils_utest

* fix dns cache unit test

* wip arp utests

* fixing arp unit tests

* fix dhcp errors

* clearing structs before usage

* fix dns parser seg fault

* fix dns parser seg fault in unit test

* fix arp uunit tests

* fix arp unit tests

* fixing dns unit test and updating the CBMC proofs

* fixing udp unit tests

* fixing TCP IP unit tests

* fixing TCP IP diffconfig unit tests

* adding additional header file for ARP for declaring missing stub headers

* minor fix

* Uncrustify: triggered by comment

* fixing comments

---------

Co-authored-by: GitHub Action <action@github.com>
2023-02-24 14:41:13 +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 = { 0 };
NetworkInterface_t xInterface;
uint8_t ucBuffer[ sizeof( ARPPacket_t ) + ipBUFFER_PADDING + ipconfigETHERNET_MINIMUM_PACKET_BYTES ];
NetworkBufferDescriptor_t xNetworkBuffer = { 0 };
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 );
/* =================================================== */
}