GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> MON / dev > mon_unit_test / rad750
#include <MSG/MSG_pubdefs.h>
#include <MSG/MSG_printProc.h>
#include <PBS/PBS.h>
#include <PBS/TASK.h>
#include <MON/MON_msgs.h>
#include <MON/MON_pubdefs.h>
#include <mon_test_control.h>
#include <mon_test_loading.h>
#include <mon_test_perf.h>
#include <mon_test_watchdog.h>
#include <mon_unit_test.h>
#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
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, const int index) |
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 description stack. | |
static unsigned int | start_message_system (void) |
Start the messaging system. | |
static unsigned int | stop_message_system (void) |
Stop the messaging system. | |
void | test_Show (const test_Test_Descriptor *td_p, const int level, const char *item_1, const char *item_2) |
Display text with indentation. | |
void | test_Show_Msg_OK (const test_Test_Descriptor *td_p) |
Indicate that the next error message is expected. | |
void | test_Sleep_Sec (const test_Test_Descriptor *td_p, const int num_secs) |
Sleep for the specified number of seconds. | |
int | test_Generic_Error (const test_Test_Descriptor *td_p, const char *fmt, const char *str_param, const unsigned int int_param) |
Display a generic error message. | |
int | test_Status_Compare (const test_Test_Descriptor *td_p, const unsigned int expect, const unsigned int actual, const char *func) |
Check a MSG status code value. | |
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_NULL_Compare (const test_Test_Descriptor *td_p, const unsigned int actual, const char *desc) |
Check a 32-bit value to make sure it is not NULL. | |
int | test_Memory_Compare (const test_Test_Descriptor *td_p, const void *expect_p, const void *actual_p, const void *mask_p, const size_t num_bytes) |
Verify the contents of a buffer in memory. | |
int | test_Loading_Compare (const test_Test_Descriptor *td_p, const MON_Load_Stats *min_p, const MON_Load_Stats *max_p, const MON_Load_Stats *actual_p) |
Verify CPU loading statistics. | |
int | test_Perf_Compare (const test_Test_Descriptor *td_p, const MON_Perf_Stats *min_p, const MON_Perf_Stats *max_p, const MON_Perf_Stats *actual_p, const MON_Perf_Config *cfg_p) |
Verify performance monitor statistics. | |
void | test_Show_Item (const test_Test_Descriptor *td_p, const char *name, const char *fmt, const char *str_param, const unsigned int int_param) |
Display an item of data. | |
int | mon_unit_test (unsigned int test_watchdog) |
The unit test entry point. | |
int | main (void) |
The application entry point for the sun-gcc version of the test. |
** CVS $Id: mon_unit_test.c,v 1.4 2011/03/28 23:52:02 russell Exp $ **
Test the MON package functionality. Included in this file is the test 'main', which configures the test environment, invokes individual subtests, and reports status. The actual subtests are contained in separate source files.
This file also 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).
int main | ( | void | ) |
The application entry point for the sun-gcc version of the test.
0 | Success. | |
-1 | Failure. |
References mon_unit_test().
int mon_unit_test | ( | unsigned int | test_watchdog | ) |
The unit test entry point.
Configures the test environment, runs the various subtests, collects the status values, and displays the results.
test_watchdog | Nonzero indicates that watchdog should be tested. |
0 | Success. | |
-1 | Failure. |
References DIM, _test_Test_Descriptor::exec, _test_Test_Descriptor::fail, mon_test_control(), mon_test_loading(), mon_test_perf(), mon_test_watchdog(), show_banner(), start_message_system(), stop_message_system(), test_Pop_State(), and test_Push_State().
Referenced by main().
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.
level | Test state level. | |
item_1 | First text string to display. | |
item_2 | Second text string to display. |
Referenced by show_desc_stack(), test_Generic_Error(), test_Loading_Compare(), test_Memory_Compare(), test_NULL_Compare(), test_Perf_Compare(), test_Push_State(), test_Show(), test_Show_Item(), test_Sleep_Sec(), test_Status_Compare(), and test_Value32_Compare().
void show_banner | ( | const char * | desc_1, | |
const char * | desc_2 | |||
) | [static] |
Display a message as a banner.
desc_1 | First text string to display. | |
desc_2 | Second text string to display. |
Referenced by mon_unit_test(), test_Pop_State(), and test_Push_State().
void show_desc_stack | ( | const test_Test_Descriptor * | td_p | ) | [static] |
Display the current state description stack.
Display all the state descriptions on the test's state stack.
td_p | Pointer to test descriptor. |
References _test_Test_Descriptor::depth, _test_Test_Descriptor::desc, _test_Test_Descriptor::index, and show_at_level().
Referenced by test_Generic_Error(), test_Loading_Compare(), test_Memory_Compare(), test_NULL_Compare(), test_Perf_Compare(), test_Status_Compare(), and test_Value32_Compare().
unsigned int start_message_system | ( | void | ) | [static] |
unsigned int stop_message_system | ( | void | ) | [static] |
int test_Generic_Error | ( | const test_Test_Descriptor * | td_p, | |
const char * | fmt, | |||
const char * | str_param, | |||
const unsigned int | int_param | |||
) |
Display a generic error message.
td_p | Pointer to test descriptor. | |
fmt | Format string to display. | |
str_param | First parameter (string) for fmt string. | |
int_param | Second parameter (uint) for fmt string. |
References _test_Test_Descriptor::depth, show_at_level(), and show_desc_stack().
Referenced by mon_test_watchdog().
int test_Loading_Compare | ( | const test_Test_Descriptor * | td_p, | |
const MON_Load_Stats * | min_p, | |||
const MON_Load_Stats * | max_p, | |||
const MON_Load_Stats * | actual_p | |||
) |
Verify CPU loading statistics.
td_p | Pointer to test descriptor. | |
min_p | Pointer to minimum loading values. | |
max_p | Pointer to maximum loading values. | |
actual_p | Pointer to actual loading values. |
0 | Loading statistics are between min and max values. | |
-1 | One or more loading statistics values is incorrect. |
References _MON_Load_Stats::avg_prev_min, _MON_Load_Stats::avg_prev_sec, _test_Test_Descriptor::depth, _MON_Load_Stats::max_prev_min, _MON_Load_Stats::min_prev_min, show_at_level(), and show_desc_stack().
Referenced by mon_get_loading_wrap().
int test_Memory_Compare | ( | const test_Test_Descriptor * | td_p, | |
const void * | expect_p, | |||
const void * | actual_p, | |||
const void * | mask_p, | |||
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. An optional mask can be used to indicate which bits should be verified.
td_p | Pointer to test descriptor. | |
expect_p | Pointer to a memory buffer with the expected values. | |
actual_p | Pointer to the memory buffer to verify. | |
mask_p | Pointer to a memory buffer of mask values. | |
num_bytes | Number of bytes to verify within the buffer. |
0 | Buffer values are correct. | |
-1 | One or more values within the buffer are incorrect. |
References _test_Test_Descriptor::depth, show_at_level(), and show_desc_stack().
int test_NULL_Compare | ( | const test_Test_Descriptor * | td_p, | |
const unsigned int | actual, | |||
const char * | desc | |||
) |
Check a 32-bit value to make sure it is not NULL.
td_p | Pointer to test descriptor. | |
actual | Actual value. | |
desc | Description of the value. |
0 | Actual value != NULL. | |
-1 | Actual value == NULL. |
References _test_Test_Descriptor::depth, show_at_level(), and show_desc_stack().
Referenced by mon_allocate().
int test_Perf_Compare | ( | const test_Test_Descriptor * | td_p, | |
const MON_Perf_Stats * | min_p, | |||
const MON_Perf_Stats * | max_p, | |||
const MON_Perf_Stats * | actual_p, | |||
const MON_Perf_Config * | cfg_p | |||
) |
Verify performance monitor statistics.
td_p | Pointer to test descriptor. | |
min_p | Pointer to minimum statistics values. | |
max_p | Pointer to maximum statistics values. | |
actual_p | Pointer to actual statistics values. | |
cfg_p | Pointer to performance monitor configuration. |
0 | Performance statistics are between min and max values. | |
-1 | One or more performance statistics values is incorrect. |
References _MON_Perf_Stats::config, _MON_Perf_Stats::count_1, _MON_Perf_Stats::count_2, _MON_Perf_Stats::count_3, _MON_Perf_Stats::count_4, _test_Test_Descriptor::depth, _MON_Perf_Config::event_1, _MON_Perf_Config::event_2, _MON_Perf_Config::event_3, _MON_Perf_Config::event_4, _MON_Perf_Config::rtc_select, show_at_level(), show_desc_stack(), and _MON_Perf_Config::threshold.
Referenced by mon_collect_perf_stats_wrap(), and mon_stop_perf_mon_wrap().
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.
td_p | Pointer to test descriptor. |
References _test_Test_Descriptor::depth, _test_Test_Descriptor::desc, and show_banner().
Referenced by mon_allocate(), mon_collect_perf_stats_wrap(), mon_free(), mon_get_loading_wrap(), mon_initialize_wrap(), mon_set_watchdog_wrap(), mon_shutdown_wrap(), mon_start_db_wrap(), mon_start_load_task(), mon_start_perf_mon_wrap(), mon_start_wrap(), mon_stop_load_task(), mon_stop_perf_mon_wrap(), mon_stop_wrap(), mon_test_control(), mon_test_loading(), mon_test_perf(), mon_test_watchdog(), and mon_unit_test().
void test_Push_State | ( | test_Test_Descriptor * | td_p, | |
const char * | desc, | |||
const int | index | |||
) |
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.
td_p | Pointer to test descriptor. | |
desc | Description of the new state. | |
index | Generic index value. |
References _test_Test_Descriptor::depth, _test_Test_Descriptor::desc, DIM, _test_Test_Descriptor::index, show_at_level(), and show_banner().
Referenced by mon_allocate(), mon_collect_perf_stats_wrap(), mon_free(), mon_get_loading_wrap(), mon_initialize_wrap(), mon_set_watchdog_wrap(), mon_shutdown_wrap(), mon_start_db_wrap(), mon_start_load_task(), mon_start_perf_mon_wrap(), mon_start_wrap(), mon_stop_load_task(), mon_stop_perf_mon_wrap(), mon_stop_wrap(), mon_test_control(), mon_test_loading(), mon_test_perf(), mon_test_watchdog(), and mon_unit_test().
void test_Show | ( | const test_Test_Descriptor * | td_p, | |
const int | level, | |||
const char * | item_1, | |||
const char * | item_2 | |||
) |
Display text with indentation.
Display text with indentation appropriate for the specified level.
td_p | Pointer to test descriptor. | |
level | Indentation level. | |
item_1 | First text string to display. | |
item_2 | Second text string to display. |
References show_at_level().
Referenced by test_Show_Msg_OK().
void test_Show_Item | ( | const test_Test_Descriptor * | td_p, | |
const char * | name, | |||
const char * | fmt, | |||
const char * | str_param, | |||
const unsigned int | int_param | |||
) |
Display an item of data.
This function displays an item of data in a predefined format.
td_p | Pointer to test descriptor. | |
name | Name of the item. | |
fmt | Format string to display the item's value. | |
str_param | First parameter (string) for fmt string. | |
int_param | Second parameter (uint) for fmt string. |
References _test_Test_Descriptor::depth, and show_at_level().
void test_Show_Msg_OK | ( | const test_Test_Descriptor * | td_p | ) |
Indicate that the next error message is expected.
Display text that indicates that the next error message is expected.
td_p | Pointer to test descriptor. |
References test_Show().
Referenced by mon_collect_perf_stats_wrap(), mon_get_loading_wrap(), mon_initialize_wrap(), mon_set_watchdog_wrap(), mon_shutdown_wrap(), mon_start_db_wrap(), mon_start_perf_mon_wrap(), mon_start_wrap(), mon_stop_perf_mon_wrap(), and mon_stop_wrap().
void test_Sleep_Sec | ( | const test_Test_Descriptor * | td_p, | |
const int | num_secs | |||
) |
Sleep for the specified number of seconds.
td_p | Pointer to test descriptor. | |
num_secs | Number of seconds to sleep. |
References _test_Test_Descriptor::depth, and show_at_level().
Referenced by mon_collect_perf_stats_wrap(), mon_test_loading(), mon_test_perf(), and mon_test_watchdog().
int test_Status_Compare | ( | const test_Test_Descriptor * | td_p, | |
const unsigned int | expect, | |||
const unsigned int | actual, | |||
const char * | func | |||
) |
Check a MSG status code value.
Compare actual and expected status code values and display a message if they differ.
td_p | Pointer to test descriptor. | |
expect | Expected value. | |
actual | Actual value. | |
func | Name of the function that returned the status. |
0 | Actual value == Expected value | |
-1 | Actual value != Expected value. |
References _test_Test_Descriptor::depth, show_at_level(), and show_desc_stack().
Referenced by mon_collect_perf_stats_wrap(), mon_get_loading_wrap(), mon_initialize_wrap(), mon_set_watchdog_wrap(), mon_shutdown_wrap(), mon_start_db_wrap(), mon_start_perf_mon_wrap(), mon_start_wrap(), mon_stop_perf_mon_wrap(), and mon_stop_wrap().
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.
td_p | Pointer to test descriptor. | |
expect | Expected value. | |
actual | Actual value. | |
desc | Description of the value. |
0 | Actual value == Expected value | |
-1 | Actual value != Expected value. |
References _test_Test_Descriptor::depth, show_at_level(), and show_desc_stack().
Referenced by mon_collect_perf_stats_wrap(), mon_free(), mon_start_load_task(), and mon_stop_load_task().