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

This file contains the RunTestGeneric() function which is the main test execution function that uses the SDK's API to initialize the adapter, create connections, and send and receive payloads. More...

#include "run_test.h"
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "configuration.h"
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "cdi_os_api.h"
#include "cdi_raw_api.h"
#include "cdi_test.h"
#include "curses.h"
#include "test_args.h"
#include "test_console.h"
#include "test_dynamic.h"
#include "test_receiver.h"
#include "test_transmitter.h"

Data Structures

struct  PoolInitArgs
 Structure used to pass arguments into InitPoolSgl(). More...
 

Functions

static char * ThreadName (const char *direction, int number)
 
static bool CreateCommonResources (TestConnectionInfo *connection_info_ptr)
 
static void DestroyCommonResources (TestConnectionInfo *connection_info_ptr)
 
static bool IsAnyConnected (TestConnectionInfo *connection_info_array, int num_connections)
 
static void WaitForTestToComplete (TestConnectionInfo *connection_info_array, int num_connections)
 
static bool InitPoolSgl (const void *context_ptr, void *item_ptr)
 
static bool DestroyPoolSgl (const void *context_ptr, void *item_ptr)
 
static bool CreateTxBufferPools (TestConnectionInfo *connection_info_ptr, uint8_t **tx_buffer_ptr)
 
static int NextMultipleOf (int value, int quantum)
 
bool RunTestGeneric (TestSettings *test_settings_ptr, int max_test_settings_entries, int num_connections)
 

Detailed Description

This file contains the RunTestGeneric() function which is the main test execution function that uses the SDK's API to initialize the adapter, create connections, and send and receive payloads.

This function takes in the TestSettings array, and for each TestSetting instance, we create a TestConnectionInfo instance which contains a pointer to the TestSettings instance associated with that connection.

Then we register the SDK adapter, launch all Rx connections, and then launch up all Tx connections. Once all connection threads have been launched, we wait until all of the threads complete and then check for any failures.

See CDI Test Application Architecture Top Level for diagrams and detailed description of this test function.

Function Documentation

◆ CreateCommonResources()

static bool CreateCommonResources ( TestConnectionInfo * connection_info_ptr)
static

Create resources that are common to both Tx and Rx connections.

Parameters
connection_info_ptrPointer to test connection structure.
Returns
bool Returns true if successfully created, otherwise false is returned.

◆ CreateTxBufferPools()

static bool CreateTxBufferPools ( TestConnectionInfo * connection_info_ptr,
uint8_t ** tx_buffer_ptr )
static

Creates all of the pools for tracking the connection's transmit buffers. Each stream in the connection has its own pool. The buffer passed through connection_info_ptr is assumed to have been sized correctly to account for all streams of all connections before the first time this function is called.

Parameters
connection_info_ptrpointer to the structure containing all of the specifics of the connection for which to create the transmit buffer SGL pools.
tx_buffer_ptrpointer to the pointer which tracks the assignment of each stream's buffers.
Returns
true if the pool creations succeeded, false if not.

◆ DestroyCommonResources()

static void DestroyCommonResources ( TestConnectionInfo * connection_info_ptr)
static

Destroy resources that are common to both Tx and Rx connections.

Parameters
connection_info_ptrPointer to test connection structure.

◆ DestroyPoolSgl()

static bool DestroyPoolSgl ( const void * context_ptr,
void * item_ptr )
static

Pool operator function that gets called once for each item prior to the destruction of the transmit buffer SGL pool. This function must free any resources that were allocated in InitPoolSgl().

Parameters
context_ptrpointer to the structure containing all of the values passed into CdiPoolForEach() for a given connection's transmit buffer pool.
item_ptrthe address of the particular CdiSgList need of cleanup.
Returns
true always.

◆ InitPoolSgl()

static bool InitPoolSgl ( const void * context_ptr,
void * item_ptr )
static

Pool operator function that gets called once for each item during the creation of the transmit buffer SGL pool. Updates context_ptr->tx_buffer_ptr as a side-effect.

Parameters
context_ptrpointer to the structure containing all of the values passed into CdiPoolCreateAndInitItems() for a given connection's transmit buffer pool.
item_ptrthe address of the particular CdiSgList being added to the pool in need of initialization.
Returns
true if the SGL item was initialized or false if a problem was encountered while attempting initialization.

◆ IsAnyConnected()

static bool IsAnyConnected ( TestConnectionInfo * connection_info_array,
int num_connections )
static

Tell if any of the connections is in connected state.

Parameters
connection_info_arrayPointer to array of all the test connection structures.
num_connectionsNumber of connections.
Returns
True if and only if at least one connection is in connected state.

◆ NextMultipleOf()

static int NextMultipleOf ( int value,
int quantum )
static

Helper function to up-quantize an integer value.

Parameters
valueThe value to quantize up.
quantumThe number to calculate a multiple of.
Returns
The smallest multiple of quantum equal to or greater than value.

◆ RunTestGeneric()

bool RunTestGeneric ( TestSettings * test_settings_ptr,
int max_test_settings_entries,
int num_connections )

Runs a test using the test parameters provided by the user.

Parameters
test_settings_ptrPointer to an array of user-supplied test settings for all connections.
max_test_settings_entriesThe maximum number of test settings structures that the test_settings array can hold.
num_connectionsThe number of connections to create.
Returns
true if all tests pass; false any tests fail

◆ ThreadName()

static char * ThreadName ( const char * direction,
int number )
static

Create a unique thread name for an Rx or Tx thread.

Parameters
directionEither "Rx" or "Tx".
numberUnique number for this thread.
Returns
Returns the generated name.

◆ WaitForTestToComplete()

static void WaitForTestToComplete ( TestConnectionInfo * connection_info_array,
int num_connections )
static

Wait for test to complete and provides stats update on the console while tests are running.

Parameters
connection_info_arrayPointer to array of all the test connection structures.
num_connectionsNumber of connections.