GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > SIIS / dev

Constituent: siis_unit_test     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

siis_unit_test.c File Reference

Test the SIIS package. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CCSDS/CCSDS_pkt.h"
#include "CCSDS/CCSDS_pri.h"
#include "MSG/MSG_pubdefs.h"
#include "MSG/MSG_printProc.h"
#include "PBS/PBS.h"
#include "PBS/TASK.h"
#include "SIIS/SIIS_rec.h"
#include "SIIS/SIIS_vcdu.h"
#include "SIIS/SIIS_moc.h"

Include dependency graph for siis_unit_test.c:


Data Structures

struct  _test_Test_Descriptor
 Description of a test state. More...
struct  _File_Info_Wrapper
struct  _Raw_Telem_Wrapper
struct  _Vcdu_Hdr_Wrapper
struct  _Pdu_Hdr_Wrapper
struct  _Pdu_Buf_Wrapper

Defines

#define DIM(a)   (sizeof (a) / sizeof ((a)[0]))
 Dimension of an array.
#define FILE_INFO_HDR_LENGTH   12
#define RAW_TELEM_HDR_LENGTH   17

Typedefs

typedef _test_Test_Descriptor test_Test_Descriptor
 Typedef for _test_Test_Descriptor.
typedef _File_Info_Wrapper File_Info_Wrapper
typedef _Raw_Telem_Wrapper Raw_Telem_Wrapper
typedef _Vcdu_Hdr_Wrapper Vcdu_Hdr_Wrapper
typedef _Pdu_Hdr_Wrapper Pdu_Hdr_Wrapper
typedef _Pdu_Buf_Wrapper Pdu_Buf_Wrapper

Functions

static void show_banner (const char *desc_1, const char *desc_2)
 Display a message as a banner.
static void show_at_level (const int level, const char *item_1, const char *item_2)
 Display text with indentation.
void test_Push_State (test_Test_Descriptor *td_p, const char *desc)
 Enter a new test state.
void test_Pop_State (test_Test_Descriptor *td_p)
 Return for a test state.
static void show_desc_stack (const test_Test_Descriptor *td_p)
 Display the current state decription stack.
static unsigned int start_message_system (void)
static unsigned int stop_message_system (void)
int test_Status_Compare (const test_Test_Descriptor *td_p, const unsigned int expect, const unsigned int actual, const char *func)
 Check a status value returned from a library function.
int test_Value32_Compare (const test_Test_Descriptor *td_p, const unsigned int expect, const unsigned int actual, const char *desc)
 Check a 32-bit value.
int test_String_Compare (const test_Test_Descriptor *td_p, const unsigned int expect_bytes, const char *expect, const unsigned int actual_bytes, const char *actual, const char *desc)
 Check a string.
int test_Memory_Compare (const test_Test_Descriptor *td_p, const void *expect, const void *actual, const size_t num_bytes)
 Verify the contents of a buffer in memory.
static int test_rec_hdr (test_Test_Descriptor *td_p, const unsigned char *hdr_buf, const unsigned int hdr_buf_bytes, SIIS_Rec_Hdr *hdr_info, const unsigned int exp_status, const unsigned int exp_type, const unsigned int exp_time_tag, const unsigned int exp_body_bytes, const char *test_name)
static void siis_recGetHdr_test (test_Test_Descriptor *td_p, const unsigned int bit_mask)
 SIIS_recGetHdr subtest.
static int test_file_info (test_Test_Descriptor *td_p, const unsigned char *body_buf, const unsigned int body_buf_bytes, File_Info_Wrapper *wrapper, const unsigned int exp_status, const unsigned int exp_time_tag, const unsigned int exp_sys_id_bytes, const unsigned int exp_sys_id_offset, const char *exp_sys_id, const char *test_name)
static void siis_recGetFileInfo_test (test_Test_Descriptor *td_p, const unsigned int bit_mask)
 SIIS_recGetFileInfo subtest.
static int test_raw_telem (test_Test_Descriptor *td_p, const unsigned char *body_buf, const unsigned int body_buf_bytes, Raw_Telem_Wrapper *wrapper, const unsigned int exp_status, const unsigned int exp_sat_id_bytes, const unsigned int exp_sat_id_offset, const char *exp_sat_id, const unsigned int exp_frame_type, const unsigned int exp_sync_status, const unsigned int exp_time_tag, const unsigned int exp_frame_bytes, const unsigned int exp_frame_offset, const char *test_name)
static void siis_recGetRawTelem_test (test_Test_Descriptor *td_p, const unsigned int bit_mask)
 SIIS_recGetRawTelem subtest.
static int test_vcdu_hdr (test_Test_Descriptor *td_p, const unsigned char *hdr_buf, const unsigned int hdr_buf_bytes, Vcdu_Hdr_Wrapper *wrapper, const unsigned int exp_status, const unsigned int exp_version, const unsigned int exp_spacecraft, const unsigned int exp_channel, const unsigned int exp_chan_count, const unsigned int exp_replay, const unsigned int exp_reserved, const unsigned int exp_second, const unsigned int exp_sub_second, const unsigned int exp_m_pdu_hdr, const unsigned int exp_data_offset, const char *test_name)
static void siis_vcduGetHdr_test (test_Test_Descriptor *td_p, const unsigned int bit_mask)
 SIIS_vcduGetHdr subtest.
static int test_pdu_get_hdr (test_Test_Descriptor *td_p, const unsigned char *hdr_buf, const unsigned int hdr_buf_bytes, Pdu_Hdr_Wrapper *wrapper, const unsigned int exp_status, const unsigned int exp_frame_version, const unsigned int exp_frame_spacecraft, const unsigned int exp_frame_channel, const unsigned int exp_frame_err_enabled, const unsigned int exp_frame_crc_error, const unsigned int exp_frame_hdr_error, const unsigned int exp_frame_seq_error, const unsigned int exp_rs_err_enabled, const unsigned int exp_rs_error, const unsigned int exp_rs_corrected, const unsigned int exp_pkt_hdr_error, const unsigned int exp_pkt_seq_error, const unsigned int exp_pkt_incomplete, const unsigned int exp_fill_offset, const unsigned int exp_direction, const unsigned int exp_time_format, const unsigned int exp_rcv_time_hi, const unsigned int exp_rcv_time_lo, const char *test_name)
static void siis_mocGetHdr_test (test_Test_Descriptor *td_p, const unsigned int bit_mask)
 SIIS_mocGetHdr subtest.
static int test_pdu_put_hdr (test_Test_Descriptor *td_p, Pdu_Buf_Wrapper *wrapper, const unsigned int hdr_buf_bytes, const SIIS_Pdu_Hdr *hdr_info, const unsigned int exp_status, const unsigned char *exp_hdr_buf, const char *test_name)
static void siis_mocPutHdr_test (test_Test_Descriptor *td_p, const unsigned int bit_mask)
 SIIS_mocPutHdr subtest.
int siis_unit_test ()
 The test entry point.
int main (void)
 The application entry point.

Detailed Description

Test the SIIS package.

  CVS $Id: siis_unit_test.c,v 1.3 2005/10/31 15:57:20 dmay Exp $
  

Test the constituents of the SIIS package. Included in this file is the test 'main', which configures the test environment, invokes individual subtests, and reports status. The actual subtests are also included in this file, but should be moved to separate source files if their number increases.

This file includes some support functions that can be used by the subtests to compare actual and expected values, and to display various types of information and status. By passing all user output through these support functions, the output mechanism can be modified without affecting the subtest source code (e.g. changing printf to fprintf).


Define Documentation

#define FILE_INFO_HDR_LENGTH   12
 

Defines the expected length of the FILE_INFORMATION record secondary header.

#define RAW_TELEM_HDR_LENGTH   17
 

Defines the expected length of the FILE_INFORMATION record secondary header.


Typedef Documentation

File_Info_Wrapper
 

The typedef for _File_Info_Wrapper.

Pdu_Buf_Wrapper
 

The typedef for _Pdu_Buf_Wrapper.

Pdu_Hdr_Wrapper
 

The typedef for _Pdu_Hdr_Wrapper.

Raw_Telem_Wrapper
 

The typedef for _Raw_Telem_Wrapper.

Vcdu_Hdr_Wrapper
 

The typedef for _Vcdu_Hdr_Wrapper.


Function Documentation

int main void   ) 
 

The application entry point.

Return values:
0 Success.
-1 Failure.

void show_at_level const int  level,
const char *  item_1,
const char *  item_2
[static]
 

Display text with indentation.

Display text with indentation appropriate for the specified test state level.

Parameters:
level Test state level.
item_1 First text string to display.
item_2 Second text string to display.
Returns:
Nothing.

void show_banner const char *  desc_1,
const char *  desc_2
[static]
 

Display a message as a banner.

Parameters:
desc_1 First text string to display.
desc_2 Second text string to display.
Returns:
Nothing.

void show_desc_stack const test_Test_Descriptor td_p  )  [static]
 

Display the current state decription stack.

Display all the state descriptions on the test's state stack.

Parameters:
td_p Pointer to test descriptor.
Returns:
Nothing.

void siis_mocGetHdr_test test_Test_Descriptor td_p,
const unsigned int  bit_mask
[static]
 

SIIS_mocGetHdr subtest.

Test the SIIS_mocGetHdr function.

Parameters:
td_p Pointer to test descriptor.
bit_mask Bitmask ID for this subtest.
Returns:
Nothing.

void siis_mocPutHdr_test test_Test_Descriptor td_p,
const unsigned int  bit_mask
[static]
 

SIIS_mocPutHdr subtest.

Test the SIIS_mocPutHdr function.

Parameters:
td_p Pointer to test descriptor.
bit_mask Bitmask ID for this subtest.
Returns:
Nothing.

void siis_recGetFileInfo_test test_Test_Descriptor td_p,
const unsigned int  bit_mask
[static]
 

SIIS_recGetFileInfo subtest.

Test the SIIS_recGetFileInfo function.

Parameters:
td_p Pointer to test descriptor.
bit_mask Bitmask ID for this subtest.
Returns:
Nothing.

void siis_recGetHdr_test test_Test_Descriptor td_p,
const unsigned int  bit_mask
[static]
 

SIIS_recGetHdr subtest.

Test the SIIS_recGetHdr function.

Parameters:
td_p Pointer to test descriptor.
bit_mask Bitmask ID for this subtest.
Returns:
Nothing.

void siis_recGetRawTelem_test test_Test_Descriptor td_p,
const unsigned int  bit_mask
[static]
 

SIIS_recGetRawTelem subtest.

Test the SIIS_recGetRawTelem function.

Parameters:
td_p Pointer to test descriptor.
bit_mask Bitmask ID for this subtest.
Returns:
Nothing.

int siis_unit_test void   ) 
 

The test entry point.

Configures the test environment, runs the various subtests, collects the status values, and displays the results.

Return values:
0 Success.
-1 Failure.

void siis_vcduGetHdr_test test_Test_Descriptor td_p,
const unsigned int  bit_mask
[static]
 

SIIS_vcduGetHdr subtest.

Test the SIIS_vcduGetHdr function.

Parameters:
td_p Pointer to test descriptor.
bit_mask Bitmask ID for this subtest.
Returns:
Nothing.

unsigned int start_message_system void   )  [static]
 

Start the messaging system.

Returns:
A SIIS MSG value.

unsigned int stop_message_system void   )  [static]
 

Stop the messaging system.

Returns:
A SIIS MSG value.

int test_file_info test_Test_Descriptor td_p,
const unsigned char *  body_buf,
const unsigned int  body_buf_bytes,
File_Info_Wrapper wrapper,
const unsigned int  exp_status,
const unsigned int  exp_time_tag,
const unsigned int  exp_sys_id_bytes,
const unsigned int  exp_sys_id_offset,
const char *  exp_sys_id,
const char *  test_name
[static]
 

Call the SIIS_recGetFileInfo library function and verify the status and returned record values.

Parameters:
td_p Pointer to test descriptor
body_buf body_buf parameter for SIIS_recGetFileInfo.
body_buf_bytes body_buf_bytes parameter for SIIS_recGetFileInfo.
wrapper wrapper for SIIS_recGetFileInfo file_info param.
exp_status Expected status value.
exp_time_tag Expected time_tag value.
exp_sys_id_bytes Expected sys_id_bytes value.
exp_sys_id_offset Expected sys_id_offset value.
exp_sys_id Expected sys_id value.
test_name Name of the subtest.
Return values:
0 Status and returned record values are correct.
-1 One or more values are incorrect.

int test_Memory_Compare const test_Test_Descriptor td_p,
const void *  expect,
const void *  actual,
const size_t  num_bytes
 

Verify the contents of a buffer in memory.

This function verifies the contents of a memory buffer and reports an error if the values are not as expected.

Parameters:
td_p Pointer to test descriptor.
expect Pointer to a memory buffer with the expected values.
actual Pointer to the memory buffer to verify.
num_bytes Number of bytes to verify within the buffer.
Return values:
0 Buffer values are correct.
-1 One or more values within the buffer are incorrect.

int test_pdu_get_hdr test_Test_Descriptor td_p,
const unsigned char *  hdr_buf,
const unsigned int  hdr_buf_bytes,
Pdu_Hdr_Wrapper wrapper,
const unsigned int  exp_status,
const unsigned int  exp_frame_version,
const unsigned int  exp_frame_spacecraft,
const unsigned int  exp_frame_channel,
const unsigned int  exp_frame_err_enabled,
const unsigned int  exp_frame_crc_error,
const unsigned int  exp_frame_hdr_error,
const unsigned int  exp_frame_seq_error,
const unsigned int  exp_rs_err_enabled,
const unsigned int  exp_rs_error,
const unsigned int  exp_rs_corrected,
const unsigned int  exp_pkt_hdr_error,
const unsigned int  exp_pkt_seq_error,
const unsigned int  exp_pkt_incomplete,
const unsigned int  exp_fill_offset,
const unsigned int  exp_direction,
const unsigned int  exp_time_format,
const unsigned int  exp_rcv_time_hi,
const unsigned int  exp_rcv_time_lo,
const char *  test_name
[static]
 

Call the SIIS_mocGetHdr library function and verify the status and returned record values.

Parameters:
td_p Pointer to test descriptor.
hdr_buf hdr_buf parameter for SIIS_vcduGetHdr.
hdr_buf_bytes hdr_buf_bytes parameter for SIIS_vcduGetHdr.
wrapper wrapper for SIIS_vcduGetHdr hdr_info param.
exp_status Expected status value.
exp_frame_version Expected frame_version value.
exp_frame_spacecraft Expected frame_spacecraft value.
exp_frame_channel Expected frame_channel value.
exp_frame_err_enabled Expected frame_err_enabled value.
exp_frame_crc_error Expected frame_crc_error value.
exp_frame_hdr_error Expected frame_hdr_error value.
exp_frame_seq_error Expected frame_seq_error value.
exp_rs_err_enabled Expected rs_err_enabled value.
exp_rs_error Expected rs_error value.
exp_rs_corrected Expected rs_corrected value.
exp_pkt_hdr_error Expected pkt_hdr_error value.
exp_pkt_seq_error Expected pkt_seq_error value.
exp_pkt_incomplete Expected pkt_incomplete value.
exp_fill_offset Expected fill_offset value.
exp_direction Expected direction value.
exp_time_format Expected time_format value.
exp_rcv_time_hi Expected rcv_time_hi value.
exp_rcv_time_lo Expected rcv_time_lo value.
test_name Name of the subtest.
Return values:
0 Status and returned record values are correct.
-1 One or more values are incorrect.

int test_pdu_put_hdr test_Test_Descriptor td_p,
Pdu_Buf_Wrapper wrapper,
const unsigned int  hdr_buf_bytes,
const SIIS_Pdu_Hdr hdr_info,
const unsigned int  exp_status,
const unsigned char *  exp_hdr_buf,
const char *  test_name
[static]
 

Call the SIIS_mocPutHdr library function and verify the status and returned buffer values.

Parameters:
td_p Pointer to test descriptor.
wrapper wrapper for SIIS_mocPutHdr hdr_buf parameter.
hdr_buf_bytes hdr_buf_bytes parameter for SIIS_mocPutHdr.
hdr_info hdr_info parameter for SIIS_mocPutHdr.
exp_status Expected status value.
exp_hdr_buf Expected hdr_buf buffer after SIIS_mocPutHdr.
test_name Name of the subtest.
Return values:
0 Status and returned record values are correct.
-1 One or more values are incorrect.

void test_Pop_State test_Test_Descriptor td_p  ) 
 

Return for a test state.

Pop a test state description from a test's state stack.

Parameters:
td_p Pointer to test descriptor.
Returns:
Nothing.

void test_Push_State test_Test_Descriptor td_p,
const char *  desc
 

Enter a new test state.

Push a new test state description onto a test's state stack. This state stack provides a trace of the execution of the test.

Parameters:
td_p Pointer to test descriptor.
desc Description of the new state.
Returns:
Nothing.

int test_raw_telem test_Test_Descriptor td_p,
const unsigned char *  body_buf,
const unsigned int  body_buf_bytes,
Raw_Telem_Wrapper wrapper,
const unsigned int  exp_status,
const unsigned int  exp_sat_id_bytes,
const unsigned int  exp_sat_id_offset,
const char *  exp_sat_id,
const unsigned int  exp_frame_type,
const unsigned int  exp_sync_status,
const unsigned int  exp_time_tag,
const unsigned int  exp_frame_bytes,
const unsigned int  exp_frame_offset,
const char *  test_name
[static]
 

Call the SIIS_recGetRawTelem library function and verify the status and returned record values.

Parameters:
td_p Pointer to test descriptor.
body_buf body_buf parameter for SIIS_recGetRawTelem.
body_buf_bytes body_buf_bytes parameter for SIIS_recGetRawTelem.
wrapper wrapper for SIIS_recGetRawTelem raw_telem param.
exp_status Expected status value.
exp_sat_id_bytes Expected sat_id_bytes value.
exp_sat_id_offset Expected sat_id_offset value.
exp_sat_id Expected sat_id value.
exp_frame_type Expected frame_type value.
exp_sync_status Expected sync_status value.
exp_time_tag Expected time_tag value.
exp_frame_bytes Expected frame_bytes value.
exp_frame_offset Expected frame_offset value.
test_name Name of the subtest.
Return values:
0 Status and returned record values are correct.
-1 One or more values are incorrect.

int test_rec_hdr test_Test_Descriptor td_p,
const unsigned char *  hdr_buf,
const unsigned int  hdr_buf_bytes,
SIIS_Rec_Hdr hdr_info,
const unsigned int  exp_status,
const unsigned int  exp_type,
const unsigned int  exp_time_tag,
const unsigned int  exp_body_bytes,
const char *  test_name
[static]
 

Call the SIIS_recGetHdr library function and verify the status and returned header values.

Parameters:
td_p Pointer to test descriptor.
hdr_buf hdr_buf parameter for SIIS_recGetHdr.
hdr_buf_bytes hdr_buf_bytes parameter for SIIS_recGetHdr.
hdr_info hdr_info parameter for SIIS_recGetHdr.
exp_status Expected status value.
exp_type Expected type value.
exp_time_tag Expected time_tag value.
exp_body_bytes Expected body_bytes value.
test_name Name of the subtest.
Return values:
0 Status and returned header values are correct.
-1 One or more values are incorrect.

int test_Status_Compare const test_Test_Descriptor td_p,
const unsigned int  expect,
const unsigned int  actual,
const char *  func
 

Check a status value returned from a library function.

Compare actual and expected status values returned from a function and display a message if they differ.

Parameters:
td_p Pointer to test descriptor.
expect Expected value.
actual Actual value.
func Name of the function that returned the status.
Return values:
0 Actual value == Expected value.
-1 Actual value != Expected value.

int test_String_Compare const test_Test_Descriptor td_p,
const unsigned int  expect_bytes,
const char *  expect,
const unsigned int  actual_bytes,
const char *  actual,
const char *  desc
 

Check a string.

Compare actual and expected strings and display a message if they differ.

Parameters:
td_p Pointer to test descriptor.
expect_bytes Length of expected string, in bytes.
expect Pointer to expected string.
actual_bytes Length of actual string, in bytes.
actual Pointer to actual string.
desc Description of the string.
Return values:
0 Actual string == Expected string.
-1 Actual string != Expected string.

int test_Value32_Compare const test_Test_Descriptor td_p,
const unsigned int  expect,
const unsigned int  actual,
const char *  desc
 

Check a 32-bit value.

Compare actual and expected 32-bit values and display a message if they differ.

Parameters:
td_p Pointer to test descriptor.
expect Expected value.
actual Actual value.
desc Description of the value.
Return values:
0 Actual value == Expected value.
-1 Actual value != Expected value.

int test_vcdu_hdr test_Test_Descriptor td_p,
const unsigned char *  hdr_buf,
const unsigned int  hdr_buf_bytes,
Vcdu_Hdr_Wrapper wrapper,
const unsigned int  exp_status,
const unsigned int  exp_version,
const unsigned int  exp_spacecraft,
const unsigned int  exp_channel,
const unsigned int  exp_chan_count,
const unsigned int  exp_replay,
const unsigned int  exp_reserved,
const unsigned int  exp_second,
const unsigned int  exp_sub_second,
const unsigned int  exp_m_pdu_hdr,
const unsigned int  exp_data_offset,
const char *  test_name
[static]
 

Call the SIIS_vcduGetHdr library function and verify the status and returned record values.

Parameters:
td_p Pointer to test descriptor.
hdr_buf hdr_buf parameter for SIIS_vcduGetHdr.
hdr_buf_bytes hdr_buf_bytes parameter for SIIS_vcduGetHdr.
wrapper wrapper for SIIS_vcduGetHdr hdr_info param.
exp_status Expected status value.
exp_version Expected version value.
exp_spacecraft Expected spacecraft value.
exp_channel Expected channel value.
exp_chan_count Expected chan_count value.
exp_replay Expected replay value.
exp_reserved Expected reserved value.
exp_second Expected second value.
exp_sub_second Expected sub_second value.
exp_m_pdu_hdr Expected m_pdu_hdr value.
exp_data_offset Expected data_offset value.
test_name Name of the subtest.
Return values:
0 Status and returned record values are correct.
-1 One or more values are incorrect.


Generated on Tue Dec 4 12:25:52 2007 by  doxygen 1.4.4