Doxygen Documentation

Main Index

Package Index

Package:

PBI

Version:

V0-0-4

Marked:

(not marked)

Constituent:

test_unions

Tag:

mv2304


Interface   Compound List   File List   Compound Members   File Members  

test_unions.c File Reference

Program to test the macros in PBI/Unions.h. More...

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

Include dependency graph for test_unions.c:

Include dependency graph

Data Structures

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...

struct  A_short
 Union an unsigned short against 2 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   "%4.4x"
 Internal formatting symbol.

#define X_8_8X   "%8.8x"
 Internal formatting symbol.

#define X_16_16XLL____   "%16.16llx"
 Internal formatting symbol.

#define X22   "%2.2x %2.2x"
 Internal formatting symbol.

#define S4   "%4s"
 Internal formatting symbol.

#define S9_____   "%9s"
 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

Program to test the macros in PBI/Unions.h.

Author:
JJRussell - russell@slac.stanford.edu

  CVS $Id: test_unions.c,v 1.2 2004/02/17 01:30:09 russell 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 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.

#define TEST_MISSION_WARNING
 

Value:

"\n"                                                                          \
" WARNING\n"                                                                  \
" The long long test failed. This may be due to a compiler error. It is\n"    \
" known that version 2.7 of the PPC compiler had problems with long longs.\n" \
" In particular, printf will not correctly format a long long.\n"             \
"\n"                                                                          \
" An early version of the test had a kludge in the one to get around this.\n" \
" However, now that the compiler has been upgraded, this is no longer a\n"    \
" a problem. However, given that this test failed, looking at the version\n"  \
" of might be a good place to look.\n"                                        \
"\n"                                                                          \
" Compiler Version => "COMPILER_VERSION"\n"
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 TEST_RESULTS_INT
 

Value:

" |Int       |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |Lo Short  |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |Hi Short  |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |As Shorts |              "X4"  "X4" |              "X4"  "X4" |   "S4" |\n"\
" |As Bytes  |            "X22"  "X22" |             "X22" "X22" |   "S4" |\n"\
" +----------+-------------------------+-------------------------+--------+\n"
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
 

Value:

" |Long Long |      0x"X_16_16XLL____" |      0x"X_16_16XLL____" |   "S4" |\n"\
" |Lo Int    |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |Hi Int    |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |As Ints   |     "X_8_8X"   "X_8_8X" |     "X_8_8X"   "X_8_8X" |   "S4" |\n"\
" |As Shorts |  "X4"  "X4"  "X4"  "X4" |  "X4"  "X4"  "X4"  "X4" |   "S4" |\n"\
" |As Bytes  | "X22" "X22" "X22" "X22" | "X22" "X22" "X22" "X22" |   "S4" |\n"\
" +----------+-------------------------+-------------------------+--------+\n"
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_SHORT
 

Value:

" |Short     |                  0x"X4" |                  0x"X4" |   "S4" |\n"\
" |Lo Byte   |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |Hi Byte   |              0x"X_8_8X" |              0x"X_8_8X" |   "S4" |\n"\
" |As Bytes  |                   "X22" |                   "X22" |   "S4" |\n"\
" +----------+-------------------------+-------------------------+--------+\n"
Symbol representing the formatting string for the test results for shorts.It is here purely to make the code read nicer.

#define TEST_RESULTS_SUMMARY
 

Value:

" |This "S9_____" matches the expected results on this "ENAME"            |\n"\
" |endian machine, therefore the overall result of Test Unions is    "S4" |\n"\
" +-----------------------------------------------------------------------+\n"\
"\n"
Symbol representing the formatting string for the test results summary. It is here purely to make the code read nicer.

#define TEST_RESULTS_TITLE
 

Value:

" +-----------------------------------------------------------------------+\n"\
" |                              Test Results                             |\n"\
" +----------+-------------------------+-------------------------+--------+\n"\
" |What      |                Expected |                     Got | Result |\n"\
" +----------+-------------------------+-------------------------+--------+"
Symbol representing the formatting string for the test results title bar.It is here purely to make the code read nicer.


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.

Here is the call graph for this function:

int test_unions void   ) 
 

The test program itself and also the entry point for running this test on VxWork's platforms.

Return values:
0,if successful
-1,if unsucceful


Generated on Tue Feb 17 05:07:20 2004 by doxygen 1.3.3