GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBI / V0-1-3 > test_unions / rhel5-64


Interface   Data Structures   File List   Data Fields   Globals  

test_unions.c File Reference

Unit test of the macros in PBI/Unions.h. More...

#include <stdio.h>
#include <PBI/Endianness.h>
#include <PBI/Unions.h>

Classes

struct  A_short
 Union an unsigned short against 2 unsigned chars. More...
struct  A_int
 Union an unsigned int against 2 unsigned shorts and 4 unsigned chars. More...
struct  A_longlong
 Union an unsigned long long against 2 unsigned ints, 4 unsigned shorts and 8 unsigned chars. More...

Defines

#define ENAME   "unknown"
 Defines a string describing the endianness of the machine.
#define COMPILER_VERSION   "UNKNOWN"
 If supported by the compiler, a string representing the compiler version.
#define TEST_MISSION
 Symbol representing the string stating the mission of this test. It is purely here to make the code read nicer.
#define TEST_MISSION_WARNING
 Symbol representing the string stating a warning on the limitations of the test implementation. It is purely here to make the code read nicer.
#define X4
 Internal formatting symbol.
#define X_8_8X
 Internal formatting symbol.
#define X_16_16XLL____
 Internal formatting symbol.
#define X22
 Internal formatting symbol.
#define S4
 Internal formatting symbol.
#define S9_____
 Internal formatting symbol.
#define TEST_RESULTS_TITLE
 Symbol representing the formatting string for the test results title bar.It is here purely to make the code read nicer.
#define TEST_RESULTS_SHORT
 Symbol representing the formatting string for the test results for shorts.It is here purely to make the code read nicer.
#define TEST_RESULTS_INT
 Symbol representing the formatting string for the test results for ints.It is here purely to make the code read nicer.
#define TEST_RESULTS_LL
 Symbol representing the formatting string for the test results for long long. It is here purely to make the code read nicer.
#define TEST_RESULTS_SUMMARY
 Symbol representing the formatting string for the test results summary. It is here purely to make the code read nicer.

Functions

int main (int argc, char **argv)
 Standard main entry point for Unix platforms. It merely calls the testing routine test_unions ().
int test_unions (void)
 The test program itself and also the entry point for running this test on VxWork's platforms.


Detailed Description

Unit test of the macros in PBI/Unions.h.

Author:
JJRussell - russell@slac.stanford.edu
  CVS $Id: test_unions.c,v 1.5 2011/03/24 20:50:58 apw Exp $

To run the program type

On Unix platforms:
$ test_unions

On VxWorks
> test_unions()

The program returns 0 if successful, else -1.

Attention:
The compiler currently used for the PPC (2.7) has problems with long longs. In particular, printf will not correctly format a long long. This has led to a bit of a kludge in the one place where a long long is printed. I have had to break it up into two 32-bit integers. This seems not so good, since the macro the breaks up the long long is one that is being tested. The operation of comparing two long long does work, so the check that the two values are the same is okay, it is just the printing of them that is a bit dubious.

Define Documentation

#define ENAME   "unknown"

Defines a string describing the endianness of the machine.

Defines a string describing the endianness of the machine as determined by the macros ins PBI/Endianness.h. As such, the success of this program depends on whether the testing of PBI/Endianness.h was successful.

#define S9_____

Internal formatting symbol.

\* -------------------------------------------------------------------------

#define TEST_MISSION

Value:

"\n"                                                                          \
" Test Unions\n"                                                              \
" -----------\n"                                                              \
" This tests the ability to interpret various integer types as compositions\n"\
" of narrower integer types. This is used, for example, to correctly select\n"\
" the integer with the 32 numerically most significant bits from a 64 bit\n"  \
" long long on different endian machines. It also tests the ability to\n"     \
" form wider integer types by packing narrower types.\n"                      \
"\n"                                                                          \
" The first row of each type checks that the packing macros produce the\n"    \
" anticipated result. The next two rows check the simplified macros which\n"  \
" pick out the high and low halves of the type. For example, for an int,\n"   \
" U_UNPACK_INT_LO_SHORT returns the numerically least significant short.\n"   \
" The subsequent rows then break down the packed integer into narrower\n"     \
" types.\n"                                                                   \
"\n"                                                                          \
" Compiler Version : "COMPILER_VERSION"\n"                                    \
" ----------------\n"                                                         \
" Since this code is so compiler dependent, the compiler version is\n"        \
" recorded here.\n"
Symbol representing the string stating the mission of this test. It is purely here to make the code read nicer.

Referenced by test_unions().


Function Documentation

int main ( int  argc,
char **  argv 
)

Standard main entry point for Unix platforms. It merely calls the testing routine test_unions ().

Return values:
0,if successful
-1,if unsuccessful
This program takes no arguments.

References test_unions().

int test_unions ( void   ) 


Generated on Sat Apr 9 17:16:46 2011 by  doxygen 1.5.8