CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
test_unit_sgl.c File Reference

This file contains a unit test for the CdiCoreGather() function. More...

#include <stddef.h>
#include <string.h>
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "utilities_api.h"

Data Structures

struct  Entry
 
struct  CaseParams
 

Macros

#define MAX_UNIT_TEST_SGL_ENTRIES   5
 The maximum number of SGL entries in a single SGL used in this unit test.
 
#define UNIT_TEST_BUFFER_SIZE   1000
 The size of the buffers used in this unit test. It determines the maximum size of an SGL to be tested.
 

Functions

static void SglEntryInit (CdiSglEntry *sgl_entry_ptr, uint8_t *address_ptr, int size_in_bytes)
 
static bool TestCase (const CaseParams *params_ptr)
 
CdiReturnStatus TestUnitSgl (void)
 External declarations.
 

Variables

static uint8_t data []
 

Detailed Description

This file contains a unit test for the CdiCoreGather() function.

Function Documentation

◆ SglEntryInit()

static void SglEntryInit ( CdiSglEntry * sgl_entry_ptr,
uint8_t * address_ptr,
int size_in_bytes )
static

Initializes a single SGL entry structure suitably for use in TestCase().

Parameters
sgl_entry_ptrThe address of the structure to initialize.
address_ptrThe data address to have the entry point to.
size_in_bytesThe number of bytes to set the entry to.

◆ TestCase()

static bool TestCase ( const CaseParams * params_ptr)
static

Runs a single test case. Two buffers are used, the first is filled with the entire contents of the entries specified in params. The second buffer is written into with CdiCoreGather(). The contents of the two buffers are then compared and if they're the same the function returns true.

Parameters
params_ptrThe address of the structure containing the test case parameters.
Returns
bool true if the case passed, false if it failed.

◆ TestUnitSgl()

CdiReturnStatus TestUnitSgl ( void )

External declarations.

Runs all of the defined CdiCoreGather() test cases. Testing stops on the first failed case.

Returns
bool true if all of the cases passed, false if one case failed.

Variable Documentation

◆ data

uint8_t data[]
static
Initial value:
= {
0x9a, 0xd7, 0x04, 0xf4, 0x50, 0xaa, 0x87, 0x93, 0x8d, 0x5d, 0x8f, 0xb3, 0xc3, 0xcd, 0xc8, 0x6e,
0x35, 0xdb, 0xfa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x64, 0xa6, 0x28, 0x29, 0x89, 0x88,
0x9b, 0x83, 0xe5, 0x0c, 0x5c, 0x51, 0xc6, 0x39, 0xce, 0xb9, 0x68, 0x48, 0x11, 0xae, 0x8c, 0x8a,
0x4b, 0xd2, 0x1c, 0xa2, 0x2c, 0x65, 0x6e, 0xb9, 0x47, 0x76, 0x14, 0xda, 0x26, 0x0e, 0xbd, 0x4d,
0xf9, 0x59, 0x0c, 0x9f, 0x3d, 0xe1, 0x25, 0x99, 0x0c, 0x88, 0xfd, 0x65, 0xf4, 0x2d, 0x41, 0xc0,
}

This is a block of 256 random byte values used for running the test cases.