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

A program for testing the Cloud Digital Interface (CDI), also known as CDI SDK. This file contains the definitions of the functions used for the cdi_test program. More...

#include "cdi_test.h"
#include <assert.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "configuration.h"
#include "cdi_logger_api.h"
#include "cdi_os_api.h"
#include "curses.h"
#include "optarg.h"
#include "run_test.h"
#include "test_common.h"
#include "test_console.h"

Macros

#define __USE_XOPEN2K
 Linux definition.
 
#define _GNU_SOURCE
 _GNU_SOURCE Linux required for pthread_setname_np().
 
#define MAX_COMMAND_LINE_STRING_LENGTH   (10000)
 The maximum length of a command line.
 

Functions

static void InitializeGlobalTestSettings (void)
 
static void SignalHandler (int signal_number, siginfo_t *siginfo_ptr, void *context_ptr)
 
static bool SetupSignalHandlers (void)
 
static void FreeAppLoggerResources (void)
 Free logging resources used by this test application.
 
static bool CreateStringFromArray (const char *array_of_strings_ptr[], int num_entries, const char *separator_str, char *concat_str, int concat_max_len)
 
GlobalTestSettingsGetGlobalTestSettings (void)
 
int main (int argc, const char **argv)
 

Variables

CdiLoggerHandle test_app_logger_handle = NULL
 Handle to log for test.
 
static TestSettings test_settings [CDI_MAX_SIMULTANEOUS_CONNECTIONS] = {{ 0 }}
 An array of TestSettings objects used to store settings from the command line for each requested connection.
 
static GlobalTestSettings global_test_settings = { 0 }
 A global structure used to hold the information global to all test settings.
 
static CdiCsID signal_handler_lock = NULL
 Critical section to lock access to the signal handler.
 

Detailed Description

A program for testing the Cloud Digital Interface (CDI), also known as CDI SDK. This file contains the definitions of the functions used for the cdi_test program.

This test program allows users to test every aspect of the API and provides reference code for those starting out with SDK integration.

Command line options allow users to configure tests that verify sending user-specified blocks of data over multiple payloads at various frame rates from one EC2 instance to another within AWS. Test options can specify the type of pattern to use for the payload, the data type to send (Raw, AVM) as well as any configuration data needed by the chosen data type. Other options control test flow, such as logging, timeouts, distribution of payload transmission, and CPU core assignments.

Users can enable numerous unique connections simultaneously using the –new_conn (-X) option to delineate between command line options for one connections and command line options for another connection.

Each connection can be run as a receive (Rx) instance or transmit (Tx) instance.

Additionally, the SDK provides three adapter types for testing, although only the EFA adapter type is available for production applications. The socket adapter types can be used for development and debug. Command line options allow the test to be run in any of the adapter modes.

See CDI Test for block diagrams and a discussion of program flow.

Function Documentation

◆ CreateStringFromArray()

static bool CreateStringFromArray ( const char * array_of_strings_ptr[],
int num_entries,
const char * separator_str,
char * concat_str,
int concat_max_len )
static

Concatenate an array of strings into a single string buffer with a user-supplied separator between each element.

Parameters
array_of_strings_ptrPointer to the input array of strings.
num_entriesThe number of strings in the array.
separator_strThe separator string, such as " " or ", ".
concat_strPointer to the concatenation string buffer.
concat_max_lenThe maximum size of the write buffer for the concatenation string.
Returns
True if string is fully written; false if an error (such as buffer overrun) occurs.

◆ GetGlobalTestSettings()

GlobalTestSettings * GetGlobalTestSettings ( void )

Return the pointer to the global test settings structure.

Returns
The pointer to the global test settings structure.

◆ InitializeGlobalTestSettings()

static void InitializeGlobalTestSettings ( void )
static

Initialize global test settings.

◆ main()

int main ( int argc,
const char ** argv )

C main entry function.

Parameters
argcNumber of command line arguments.
argvPointer to array of pointers to command line arguments
Returns
Return 0 on success, otherwise 1 indicating a failure occurred.

◆ SetupSignalHandlers()

static bool SetupSignalHandlers ( void )
static

Setup signal handlers so we can catch segfaults, aborts (asserts) and Ctrl+C interrupts. This allows our application to perform some minimal cleanup (ie. flush log files) before exiting.

Returns
Returns true if successful, otherwise false is returned.

◆ SignalHandler()

static void SignalHandler ( int signal_number,
siginfo_t * siginfo_ptr,
void * context_ptr )
static

Signal handler for catching segfaults and other signals that cause abnormal program termination.

Parameters
signal_numberThe number of the signal that was raised.
siginfo_ptrA pointer to the siginfo_t structure. Valid only in Linux.
context_ptrA pointer to the context used in sigaction. Valid only in Linux.