Index: trunk/psLib/test/sys/tap_psConfigure.c
===================================================================
--- trunk/psLib/test/sys/tap_psConfigure.c	(revision 10810)
+++ trunk/psLib/test/sys/tap_psConfigure.c	(revision 10810)
@@ -0,0 +1,47 @@
+/** @file  tst_psConfigure.c
+ *
+ *  @brief Test driver for psconfigure functions
+ *
+ *  This test driver contains the following test points for psConfigure
+ *  functions.
+ *    1) Return current psLib version
+ *
+ *  Return:   Number of test points which failed
+ *
+ *  @author  Ross Harman, MHPCC
+ *
+ *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2006-12-18 19:18:46 $
+ *
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ *
+ */
+
+#include "pslib.h"
+#include "tap.h"
+#include "pstap.h"
+
+
+static psS32 psLibVersion00(void);
+
+
+psS32 main(psS32 argc, char* argv[])
+{
+    plan_tests(1);
+
+    psLibVersion00();
+}
+
+
+static psS32 psLibVersion00(void)
+{
+    diag("psLibVersion00");
+
+    char *stringVal = NULL;
+    stringVal = psLibVersion();
+    ok( stringVal != NULL && strlen(stringVal), "Version is cool");
+    psFree(stringVal);
+
+    return 0;
+}
+
Index: trunk/psLib/test/sys/tap_psError.c
===================================================================
--- trunk/psLib/test/sys/tap_psError.c	(revision 10810)
+++ trunk/psLib/test/sys/tap_psError.c	(revision 10810)
@@ -0,0 +1,398 @@
+/** @file  tst_psError.c
+ *
+ *  @brief Test driver for psError function
+ *
+ *  This test driver contains the following test points for psError
+ *     testError00 - psError()                          (Testpoint #486)
+ *     testError01 - psErrorMsg(), psErrorStackPrint()  (Testpoint #725)
+ *     testError02 - psErrorStackPrintV()               (Testpoint #726)
+ *     testError03 - psErrorGet(), psErrorLast()        (Testpoint #727)
+ *     testError04 - psErrorClear()                     (Testpoint #728)
+ *     testError05 - psErrorCodeString()                (Testpoint #729)
+ *
+ *  @author  Eric Van Alst, MHPCC
+ *
+ *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2006-12-18 19:18:46 $
+ *
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "pslib.h"
+#include "tap.h"
+#include "pstap.h"
+
+static psS32 testError00(void);
+static psS32 testError01(void);
+static psS32 testError02(void);
+static psS32 testError03(void);
+static psS32 testError04(void);
+static psS32 testError05(void);
+static psS32 testErrorRegister(void);
+
+// Function used in testError02 to verify the psErrorStackPrintV function
+static void myErrorStackPrint(FILE *fd,
+                              const char *fmt,
+                              ...)
+{
+    va_list ap;
+
+    // Test whether psErrorStackPrintV() accept a va_list for output variables
+    va_start(ap, fmt);
+    psErrorStackPrintV(fd, fmt, ap);
+    va_end(ap);
+}
+
+
+psS32 main( psS32 argc, char* argv[] )
+{
+    plan_tests(38);
+
+    testError00();
+    testError01();
+    testError02();
+    testError03();
+    testError04();
+    testError05();
+    testErrorRegister();
+}
+
+static psS32 testError05(void)
+{
+    diag("testError05");
+
+    // Verify the return value of psErrorCodeString
+    // psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+    // psLogMsg("tst_psError05", PS_LOG_INFO, psErrorCodeString(code));
+
+    // Verify the return value of psErrorCodeString if code is negative
+    ok( psErrorCodeString(-1) == NULL, "error string with neg. code");
+
+    return 0;
+}
+
+static psS32 testError04(void)
+{
+    diag("testError04");
+
+    psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+    psErr *last = NULL;
+    psErr *lastAfterClear = NULL;
+
+    // With an attemp error stack call psErrorClear
+    psErrorClear();
+
+    // Get the last error message and verify PS_ERR_NONE (empty stack)
+    lastAfterClear = psErrorLast();
+    ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected.");
+    skip_start(lastAfterClear->code != PS_ERR_NONE,
+               5, "psErrorLast return expected.");
+
+    psFree(lastAfterClear);
+
+    // Generate three error messages to have messages on error stack
+    ok (psError(code, true, "Error code = %d", code) ==  code,
+        "Failed return value verify.");
+    skip_start (psError(code, true, "Error code = %d", code) !=  code,
+                4, "Failed return value verify.");
+
+    ok (psError((code+1), false, "Error code = %d", (code+1)) == (code+1),
+        "Failed return value verify.");
+    skip_start (psError((code+1), false, "Error code = %d", (code+1))!=(code+1),
+                3, "Failed return value verify.");
+
+    ok (psError((code+2), false, "Error code = %d", (code+2)) == (code+2),
+        "Failed return value verify.");
+    skip_start (psError((code+2), false, "Error code = %d", (code+2))!=(code+2),
+                2, "Failed return value verify.");
+
+    // Get the last error message and verify it has the expected code
+    last = psErrorLast();
+    ok(last->code == (code+2), "psErrorLast return expected.");
+    skip_start(last->code != (code+2), 1, "psErrorLast return expected.");
+
+    psFree(last);
+
+    // Clear the error stack
+    psErrorClear();
+
+    // Get the last error message after clear and verify is has PS_ERR_NONE code
+    lastAfterClear = psErrorLast();
+    ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected.");
+
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+
+    psFree(lastAfterClear);
+
+    return 0;
+}
+
+static psS32 testError03(void)
+{
+    diag("testError03");
+
+    psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+    psErr *last = NULL;
+    psErr *getErr = NULL;
+
+    // Attempt to get last error message with an empty stack verify psErr with code PS_ERR_NONE
+    last = psErrorLast();
+    ok(last->code != PS_ERR_NONE,
+       "psErrorLast did return PS_ERR_NONE for empty stack");
+    skip_start(last->code == PS_ERR_NONE,
+               9, "psErrorLast did return PS_ERR_NONE for empty stack");
+
+    psFree(last);
+
+    // Attempt to get specific error message with empty stack verify psErr with code PS_ERR_NONE
+    getErr= psErrorGet(2);
+    ok(getErr->code != PS_ERR_NONE,
+       "psErrorGet did not return PS_ERR_NONE  for empty stack");
+    skip_start(getErr->code == PS_ERR_NONE,
+               8, "psErrorGet did not return PS_ERR_NONE  for empty stack");
+
+    psFree(getErr);
+
+    // Attempt to get error message with invalid index and an empty stack
+    getErr= psErrorGet(-1);
+    ok(getErr->code == PS_ERR_NONE,
+       "psErrorGet with invalid index/empty stack");
+    skip_start(getErr->code != PS_ERR_NONE,
+               7, "psErrorGet with invalid index/empty stack");
+
+    psFree(getErr);
+
+    // Generate three error messages
+    ok (psError(code, true, "Error code = %d", code) ==  code,
+        "return value verify-1.");
+    skip_start (psError(code, true, "Error code = %d", code !=  code),
+                6, "return value verify-2.");
+
+    ok (psError((code+1), false, "Error code = %d", (code+1)) == (code+1),
+        "Failed return value verify-3.");
+    skip_start (psError((code+1), false, "Error code = %d", (code+1))!=(code+1),
+                5, "Failed return value verify-4.");
+
+    ok (psError((code+2), false, "Error code = %d", (code+2)) == (code+2),
+        "Failed return value verify-5.");
+    skip_start (psError((code+2), false, "Error code = %d", (code+2))!=(code+2),
+                4, "Failed return value verify-6.");
+
+    last = psErrorLast();
+    getErr= psErrorGet(0);
+
+    // Check that last and get with 0 index are equal
+    ok(last == getErr, "psErrorGet(0) equal to psErrorLast");
+    skip_start(last != getErr, 3, "psErrorGet(0) equal to psErrorLast");
+
+    psFree(last);
+
+    // Verify the last error message was returned
+    ok ( getErr->code == (code+2),
+         "psErrorLast() did not retrieve last error");
+    skip_start ( getErr->code != (code+2),
+                 2, "psErrorLast() did not retrieve last error");
+
+    psFree(getErr);
+
+    // Verify the middle error message can be retrieved
+    getErr= psErrorGet(1);
+    ok ( getErr->code == (code+1),
+         "psErrorGet() did not retrieve proper error");
+    skip_start ( getErr->code != (code+1),
+                 1, "psErrorGet() did not retrieve proper error");
+
+    psFree(getErr);
+
+    // Verify the psErrorGet returns NULL if an invalid index is given
+    getErr= psErrorGet(-1);
+    ok ( getErr->code == PS_ERR_NONE,
+         "psErrorGet() did not return PS_ERR_NONE w/ invalid arg");
+
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+
+    psFree(getErr);
+
+    return 0;
+}
+
+static psS32 testError02(void)
+{
+    diag("testError02");
+
+    psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+
+    // Generate error message and verify return value
+    ok (psError(code, true, "Error code = %d", code) == code,
+        "Failed return value verify.");
+
+    myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2);
+
+    return 0;
+}
+
+static psS32 testError01(void)
+{
+    diag("testError01");
+
+    psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;
+
+    // Verify the return value of psErrorMsg is the psErrorCode passed
+    ok ( psError(code, true, "Error code = %d", code) == code,
+         "Failed return value verify.");
+    skip_start ( psError(code, true, "Error code = %d", code) != code,
+                 4, "Failed return value verify.");
+
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A");
+
+    // test1B empty string in for name argument
+    ok ( psError(code+1, true, "Error code = %d", code+1) == code+1,
+         "Failed return with empty string.");
+    skip_start ( psError(code+1, true, "Error code = %d", code+1) != code+1,
+                 3, "Failed return with empty string.");
+
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");
+
+    // test1D undefined code
+    ok ( psError(-1, true, "Error code = %d", -1) == -1,
+         "Failed return with undefined code.");
+    skip_start ( psError(-1, true, "Error code = %d", -1) != -1,
+                 2, "Failed return with undefined code.");
+
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D");
+
+    // test1E set psErrorMsg argument to false
+    ok( psError(code, false, "Error code = %d", code) == code,
+        "Failed return with false new arg.");
+    skip_start( psError(code, false, "Error code = %d", code) != code,
+                1, "Failed return with false new arg.");
+
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E");
+
+    // test1F psErrorMsg with a error code less then PS_ERR_BASE(256)
+    ok( psError(9, true, "Errno code = %d", 9) == 9, "Error Code" );
+
+    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F");
+
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+
+    return 0;
+}
+
+static psS32 testError00(void)
+{
+    diag("testError00");
+
+    psS32  intval=1;
+    psS64 longval = 2;
+    float floatval = 3.01;
+    char  charval = 'E';
+    char *stringval = "E R R O R";
+
+    // Test point #1 Multiple type values placed in the error string
+    psError(PS_ERR_UNKNOWN, true,
+            "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s",
+            intval,longval,floatval,charval,stringval);
+
+    // Test point #2 String values in error message
+    psError(PS_ERR_UNKNOWN, true, "NO VALUES");
+
+    // Test point #3 Empty strings in error message
+    psError(PS_ERR_UNKNOWN, true, " ");
+
+    return 0;
+}
+
+static psS32 testErrorRegister(void)
+{
+    diag("testErrorRegister");
+
+    psS32 numErr = 4;
+    psErrorDescription errDesc[] = { {PS_ERR_N_ERR_CLASSES+1,"first"},
+                                     {PS_ERR_N_ERR_CLASSES+2,"second"},
+                                     {PS_ERR_N_ERR_CLASSES+3,"third"},
+                                     {PS_ERR_N_ERR_CLASSES+4,"fourth"} };
+    /*
+        1. invoke psErrorRegister with a n>1 array of psErrorDescriptions. Verify that:
+            a. Each error description given is retrievable with psErrorCodeString.
+    */
+    psErrorRegister(errDesc,numErr);
+
+    for (psS32 i = 0; i < numErr; i++) {
+        const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i);
+        ok (desc != NULL,
+            "psErrorCode didn't find registered error code.");
+
+        ok (strcmp(desc,errDesc[i].description) == 0,
+            "psErrorCode didn't return the proper description.  Got '%s', expected '%s'.", desc,errDesc[i].description);
+    }
+
+    /*
+        2. invoke psErrorCodeString with a static/builtin psLib error code. Verify:
+            a. the result is correct.
+    */
+    const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES);
+    ok (desc != NULL, "psErrorCode didn't find static error code.");
+    ok (strcmp(desc,"error classes end marker") == 0,
+        "psErrorCode didn't return the proper description.  Got '%s', expected '%s'.",
+        desc,"error classes end marker");
+
+    desc = psErrorCodeString(PS_ERR_NONE);
+    ok (desc != NULL,
+        "psErrorCode didn't find static error code.");
+    ok (strcmp(desc,"not an error") == 0,
+        "psErrorCode didn't return the proper description.  Got '%s', expected '%s'.",
+        desc,"not an error");
+
+    /*
+        3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned.
+    */
+    desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+numErr+1);
+    ok (desc == NULL,
+        "psErrorCode didn't return a NULL with a bogus input code.");
+
+    /*
+        4. invoke psErrorRegister with a NULL psErrorDescription. Verify that:
+            a. the execution does not cease.
+            b. an appropriate error is generated.
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psErrorClear();
+    psErrorRegister(NULL,1);
+    psErr* err = psErrorLast();
+    ok (err->code == PS_ERR_BAD_PARAMETER_NULL,
+        "psErrorCode didn't generate proper error code for NULL input.");
+
+    psFree(err);
+
+    /*
+        5. invoke psErrorRegister with nerror=0. Verify that no error occurs.
+    */
+    psErrorClear();
+    psErrorRegister(errDesc,0);
+    err = psErrorLast();
+    ok (err->code == PS_ERR_NONE,
+        "psErrorCode generated an error for nErrors = 0.");
+
+    psFree(err);
+    return 0;
+}
Index: trunk/psLib/test/sys/tap_psLine.c
===================================================================
--- trunk/psLib/test/sys/tap_psLine.c	(revision 10810)
+++ trunk/psLib/test/sys/tap_psLine.c	(revision 10810)
@@ -0,0 +1,144 @@
+/** @file  tst_psLine.c
+ *
+ *  @brief Test driver for psLine functions
+ *
+ *  @author  dRob, MHPCC
+ *
+ *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2006-12-18 19:18:46 $
+ *
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ *
+ */
+
+#include "pslib.h"
+#include "tap.h"
+#include "pstap.h"
+
+static psS32 testLineAlloc(void);
+static psS32 testLineInit(void);
+static psS32 testLineAdd(void);
+static psS32 testLineChk(void);
+
+
+psS32 main( psS32 argc, char* argv[] )
+{
+    plan_tests(12);
+
+    testLineAlloc();
+    testLineInit();
+    testLineAdd();
+    testLineChk();
+}
+
+psS32 testLineAlloc(void)
+{
+    diag("testLineAlloc");
+
+    psLine *lineline = NULL;
+    lineline = psLineAlloc(20);
+
+    ok (lineline->NLINE==20, "psLine set NLINE parameter during Allocation");
+    skip_start (lineline->NLINE != 20,
+                2, "psLine set NLINE parameter during Allocation");
+
+    ok (lineline->Nline == 0,
+        "psLine set Nline parameter during Allocation\n");
+    skip_start (lineline->Nline == 0,
+                1, "psLine set Nline parameter during Allocation\n");
+
+    strncpy(lineline->line, "Hello World", 20);
+    ok (!strncmp(lineline->line, "Hello World", 20),
+        "psLine was stored a simple string!\n");
+
+    skip_end();
+    skip_end();
+
+    psFree(lineline);
+
+    return 0;
+}
+
+psS32 testLineInit(void)
+{
+    diag("testLineInit");
+
+    psLine *line = NULL;
+    //Return false for NULL input
+    int okay = !psLineInit(line);
+    ok (okay, "psLineInit.  Expected false for NULL psLine input.\n");
+    skip_start (!okay, 2, "psLineInit.  Expected NULL psLine input.\n");
+
+    //Allocate a line and return true on Init
+    line = psLineAlloc(1);
+    okay = psLineInit(line);
+    ok( okay, "psLineInit.  Expected true for valid psLine input.\n");
+    skip_start( !okay, 1, "psLineInit. Expected true for valid psLine input.");
+
+    ok (line->NLINE == 1 && line->Nline == 0,
+        "psLineInit returned line parameters.");
+
+    skip_end();
+    skip_end();
+
+    psFree(line);
+
+    return 0;
+}
+
+
+psS32 testLineAdd(void)
+{
+    diag("testLineAdd");
+
+    psLine *line = NULL;
+    //Return false for NULL input
+    ok (!psLineAdd(line, "Hello World"),
+        "psLineAdd.  Expected false for NULL psLine input.");
+    skip_start(psLineAdd(line, "Hello World"),
+               3, "psLineAdd.  Expected false for NULL psLine input.");
+
+    //Allocate and return true for valid input.
+    line = psLineAlloc(20);
+    int okay = psLineAdd(line, "Hello %s", "World");
+    ok( okay, "psLineAdd.  Expected true for valid psLine input.\n");
+    skip_start( !okay, 2, "psLineAdd.Expected true for valid psLine input.\n");
+
+    ok (line->NLINE == 20 && line->Nline == 11,
+        "psLineAdd failed to return the correct line parameters.\n");
+    skip_start (line->NLINE != 20 || line->Nline != 11,
+                1,"psLineAdd failed to return the correct line parameters.\n");
+
+    ok (!strncmp(line->line, "Hello World", 20),
+        "psLineAdd failed to store the correct line string.");
+
+    skip_end();
+    skip_end();
+    skip_end();
+
+    psFree(line);
+
+    return 0;
+}
+
+psS32 testLineChk(void)
+{
+    diag("testLineChk");
+
+    psLine *line = NULL;
+    //Return false for Null input line
+    ok (!psMemCheckLine(line),
+        "psMemCheckLine return false for NULL line input.\n");
+    skip_start (psMemCheckLine(line),
+                1, "psMemCheckLine return false for NULL line input.\n");
+
+    line = psLineAlloc(1);
+    ok (psMemCheckLine(line),
+        "psMemCheckLine return true for valid line input.\n");
+
+    psFree(line);
+
+    skip_end();
+
+    return 0;
+}
Index: trunk/psLib/test/sys/tap_psMemory.c
===================================================================
--- trunk/psLib/test/sys/tap_psMemory.c	(revision 10810)
+++ trunk/psLib/test/sys/tap_psMemory.c	(revision 10810)
@@ -0,0 +1,789 @@
+/** @file  tst_psMemory.c
+*
+*  @brief Contains the tests for psMemory.[ch]
+*
+*
+*  @author Robert DeSonia, MHPCC
+*
+*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-12-18 19:18:46 $
+*
+*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+*/
+
+#include <unistd.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <limits.h>
+#include <stdlib.h>
+
+
+#include "pslib.h" // need to allow malloc for callback use
+#include "tap.h"
+#include "pstap.h"
+
+static psS32 problemCallbackCalled = 0;
+static psS32 allocCallbackCalled = 0;
+static psS32 freeCallbackCalled = 0;
+static psS32 exhaustedCallbackCalled = 0;
+
+psMemId memAllocCallback( const psMemBlock *ptr );
+psMemId memFreeCallback( const psMemBlock *ptr );
+psS32 memCheckTypes( void );
+void memProblemCallback( psMemBlock *ptr, const char *filename, unsigned int lineno );
+psPtr TPOutOfMemoryExhaustedCallback( size_t size );
+
+
+psS32 main(psS32 argc, char* argv[])
+{
+    plan_tests(1);
+
+    void TPFreeReferencedMemory( void );
+    TPFreeReferencedMemory();
+
+    void TPOutOfMemory( void );
+    TPOutOfMemory();
+
+    void TPReallocOutOfMemory( void );
+    TPReallocOutOfMemory();
+
+    void TPCheckBufferPositive( void );
+    TPCheckBufferPositive();
+
+    void TPrealloc( void );
+    TPrealloc();
+
+    void TPallocCallback( void );
+    TPallocCallback();
+
+    void TPcheckLeaks( void );
+    TPcheckLeaks();
+
+    void TPmemCorruption( void );
+    TPmemCorruption();
+
+    void TPmultipleFree( void );
+    TPmultipleFree();
+}
+
+
+// Testpoint #449, psAlloc shall allocate memory blocks writeable by caller.
+void TPCheckBufferPositive( void )
+{
+    diag("TPCheckBufferPositive");
+
+    psS32 * mem;
+    const psS32 size = 100;
+    psS32 failed = 0;
+
+    mem = ( psS32* ) psAlloc( size * sizeof( psS32 ) );
+    ok ( mem != NULL, "psAlloc returned non-NULL value" );
+
+    for ( psS32 index = 0;index < size;index++ ) {
+        mem[ index ] = index;
+    }
+
+    for ( psS32 index = 0;index < size;index++ ) {
+        if ( mem[ index ] != index ) {
+            failed++;
+        }
+    }
+    ok( failed == 0, "mem legit" );
+
+    psFree( mem );
+}
+
+void TPFreeReferencedMemory( void )
+{
+    diag("TPFreeReferencedMemory");
+
+    // create memory
+    psS32 * mem;
+    psS32 ref = 0;
+
+    mem = ( psS32* ) psAlloc( 100 * sizeof( psS32 ) );
+
+    ref = psMemGetRefCounter( mem );
+    ok ( ref == 1, "buffer reference count %d.", ref );
+    skip_start ( ref != 1, 3, "buffer reference count %d.", ref );
+
+    psMemIncrRefCounter( mem );
+    psMemIncrRefCounter( mem );
+    psMemIncrRefCounter( mem );
+
+    ref = psMemGetRefCounter( mem );
+    ok ( ref == 4, "buffer reference count was %d.", ref );
+    skip_start ( ref != 4, 2, "buffer reference count was %d.", ref );
+
+    psMemDecrRefCounter( mem );
+    psMemDecrRefCounter( mem );
+
+    ref = psMemGetRefCounter( mem );
+    ok ( ref == 2, "Found buffer reference count to be %d.", ref );
+    skip_start ( ref != 2, 1, "Found buffer reference count to be %d.", ref );
+
+    psMemDecrRefCounter( mem );
+
+    ref = psMemGetRefCounter( mem );
+    ok ( ref == 1, "Found buffer reference count to be %d.", ref );
+
+    skip_end();
+    skip_end();
+    skip_end();
+
+    psFree( mem );
+}
+
+// Bug/Task #562 regression test.  Upon requesting more memory than is available, psRealloc shall call
+// the psMemExhaustedCallback.
+void TPReallocOutOfMemory( void )
+{
+    diag("TPReallocOutOfMemory");
+
+    psS32 * mem[ 100 ];
+    psMemExhaustedCallback cb;
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        mem[ lcv ] = NULL;
+    }
+
+    exhaustedCallbackCalled = 0;
+
+    cb = psMemExhaustedCallbackSet( TPOutOfMemoryExhaustedCallback );
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        mem[ lcv ] = ( psS32* ) psAlloc( 10 );
+    }
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        mem[ lcv ] = ( psS32* ) psRealloc( mem[ lcv ], SIZE_MAX/2 - 1000 );
+    }
+
+    psMemExhaustedCallbackSet( cb );
+
+    ok ( exhaustedCallbackCalled != 0,
+         "Called psRealloc with HUGE memory requirement and survived in %s!", __func__ );
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        psFree( mem[ lcv ] );
+    }
+}
+
+
+// Testpoint #450,  Upon requesting more memory than is available, psalloc shall call
+// the psMemExhaustedCallback.
+void TPOutOfMemory( void )
+{
+    diag("TPOutOfMemory");
+
+    psS32 * mem[ 100 ];
+    psMemExhaustedCallback cb;
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        mem[ lcv ] = NULL;
+    }
+
+    exhaustedCallbackCalled = 0;
+    cb = psMemExhaustedCallbackSet( TPOutOfMemoryExhaustedCallback );
+
+    #ifdef COMMENTED_OUT
+    // Don't include since intentionally aborts
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        mem[ lcv ] = ( psS32* ) psAlloc( SIZE_MAX/2 - 1000 );
+    }
+
+    psMemExhaustedCallbackSet( cb );
+
+    ok ( exhaustedCallbackCalled != 0,
+         "Called psAlloc with HUGE memory requirement and survived!");
+
+    for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
+        psFree( mem[ lcv ] );
+    }
+    #endif
+}
+
+
+// Testpoint #451,  psRealloc shall increase/decrease memory buffer while preserving contents
+void TPrealloc( void )
+{
+    diag("TPrealloc");
+
+    psS32 * mem1;
+    psS32* mem2;
+    psS32* mem3;
+    const psS32 initialSize = 100;
+
+    // allocate buffer with known values.
+    mem1 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+    mem2 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+    mem3 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+    for ( psS32 lcv = 0;lcv < initialSize;lcv++ ) {
+        mem1[ lcv ] = mem2[ lcv ] = mem3[ lcv ] = lcv;
+    }
+
+    psMemCheckCorruption( 1 );
+
+    // realloc to 2x
+    mem1 = ( psS32* ) psRealloc( mem1, 2 * initialSize * sizeof( psS32 ) );
+    mem2 = ( psS32* ) psRealloc( mem2, 2 * initialSize * sizeof( psS32 ) );
+    mem3 = ( psS32* ) psRealloc( mem3, 2 * initialSize * sizeof( psS32 ) );
+
+    // check values of initial block
+    int error = 0;
+    for ( psS32 i = 0;i < initialSize;i++ ) {
+        if ( mem1[ i ] != i || mem2[ i ] != i || mem3[ i ] != i ) {
+            error = 1;
+            break;
+        }
+    }
+    ok(error==0, "Realloc preserve the contents with expanding buffer");
+
+    psMemCheckCorruption( 1 );
+
+    // realloc to 1/2 initial value.
+    mem1 = ( psS32* ) psRealloc( mem1, ( initialSize / 2 ) * sizeof( psS32 ) );
+    mem2 = ( psS32* ) psRealloc( mem2, ( initialSize / 2 ) * sizeof( psS32 ) );
+    mem3 = ( psS32* ) psRealloc( mem3, ( initialSize / 2 ) * sizeof( psS32 ) );
+
+    // check values of initial block
+    error = 0;
+    for ( psS32 i = 0;i < initialSize / 2;i++ ) {
+        if ( mem1[ i ] != i || mem2[ i ] != i || mem3[ i ] != i ) {
+            error = 1;
+            break;
+        }
+    }
+    ok(error==0, "Realloc preserved the contents with shrinking buffer");
+
+    psFree( mem1 );
+    psFree( mem2 );
+    psFree( mem3 );
+}
+
+
+void TPallocCallback( void )
+{
+    diag("TPallocCallback");
+
+    psS32 * mem1;
+    psS32* mem2;
+    psS32* mem3;
+    psS32 currentId = psMemGetId();
+    const psS32 initialSize = 100;
+    psS32 mark;
+
+    allocCallbackCalled = 0;
+    freeCallbackCalled = 0;
+    psMemAllocCallbackSet( memAllocCallback );
+    psMemFreeCallbackSet( memFreeCallback );
+
+    psMemAllocCallbackSetID( currentId + 1 );
+    psMemFreeCallbackSetID( currentId + 1 );
+
+    // allocate buffer with known values.
+    mem1 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+    mem2 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+    mem3 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+
+    psFree( mem1 );
+    psFree( mem2 );
+    psFree( mem3 );
+
+    ok( allocCallbackCalled == 2 && freeCallbackCalled == 2,
+        "alloc/free callbacks called the proper number of times" );
+    skip_start( allocCallbackCalled != 2 || freeCallbackCalled != 2,
+                1, "alloc/free callbacks called the proper number of times" );
+
+    allocCallbackCalled = 0;
+    freeCallbackCalled = 0;
+
+    mark = psMemGetId();
+
+    mem1 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+
+    psMemAllocCallbackSetID( mark );
+
+    mem1 = ( psS32* ) psRealloc( mem1, initialSize * 2 * sizeof( psS32 ) );
+
+    psFree( mem1 );
+
+    ok ( allocCallbackCalled == 2,
+         "realloc callbacks were called the proper number of times" );
+
+    skip_end();
+}
+
+
+void TPcheckLeaks( void )
+{
+    const psS32 numBuffers = 5;
+    psS32* buffers[ 5 ];
+    psS32 lcv;
+    psS32 currentId = psMemGetId();
+    psMemBlock** blks;
+    psS32 nLeaks = 0;
+    psS32 lineMark = 0;
+
+    for ( lcv = 0;lcv < numBuffers;lcv++ ) {
+        lineMark = __LINE__ + 1;
+        buffers[ lcv ] = psAlloc( sizeof( psS32 ) );
+    }
+
+    for ( lcv = 1;lcv < numBuffers;lcv++ ) {
+        psFree( buffers[ lcv ] );
+    }
+
+    nLeaks = psMemCheckLeaks( currentId, &blks, stderr, false );
+
+    ok ( nLeaks == 1, "psMemCheckLeaks found %d leaks", nLeaks );
+    skip_start ( nLeaks != 1, 5, "psMemCheckLeaks found %d leaks", nLeaks );
+
+    ok ( blks[ 0 ] ->lineno == lineMark,
+         "psMemCheckLeaks found a leak other than the expected one (line %d vs %d)", lineMark, blks[ 0 ] ->lineno );
+    skip_start ( blks[ 0 ] ->lineno != lineMark,
+                 4,"psMemCheckLeaks found a leak other than the expected one (line %d vs %d)", lineMark, blks[ 0 ] ->lineno );
+
+    psFree( buffers[ 0 ] );
+    psFree( blks );
+
+    psMemCheckLeaks(currentId,NULL,stderr, false);
+
+    for ( lcv = 0;lcv < numBuffers;lcv++ ) {
+        lineMark = __LINE__ + 1;
+        buffers[ lcv ] = psAlloc( sizeof( psS32 ) );
+    }
+
+    for ( lcv = 0;lcv < numBuffers - 1;lcv++ ) {
+        psFree( buffers[ lcv ] );
+    }
+
+    nLeaks = psMemCheckLeaks( currentId, &blks, stderr, false );
+
+    ok ( nLeaks == 1, "psMemCheckLeaks found %d leaks.", nLeaks );
+    skip_start ( nLeaks != 1, 3, "psMemCheckLeaks found %d leaks.", nLeaks );
+
+    ok ( blks[ 0 ] ->lineno == lineMark, "psMemCheckLeaks found leaks");
+    skip_start ( blks[ 0 ] ->lineno==lineMark,2,"psMemCheckLeaks found leaks");
+
+    psFree( buffers[ 4 ] );
+    psFree( blks );
+
+    for ( lcv = 0;lcv < numBuffers;lcv++ ) {
+        lineMark = __LINE__ + 1;
+        buffers[ lcv ] = psAlloc( sizeof( psS32 ) );
+    }
+
+    for ( lcv = 0;lcv < numBuffers;lcv++ ) {
+        if ( lcv % 2 == 0 ) {
+            psFree( buffers[ lcv ] );
+        }
+    }
+
+    nLeaks = psMemCheckLeaks( currentId, &blks, stderr, false );
+
+    ok ( nLeaks == 2, "psMemCheckLeaks found %d leaks.", nLeaks);
+    skip_start ( nLeaks != 2, 1, "psMemCheckLeaks found %d leaks.", nLeaks);
+
+    ok ( blks[ 0 ] ->lineno == lineMark,
+         "psMemCheckLeaks found a leak other than the expected." );
+
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+
+    psFree( blks );
+    psFree( buffers[ 1 ] );
+    psFree( buffers[ 3 ] );
+}
+
+
+void TPmemCorruption( void )
+{
+    diag("TPmemCorruption");
+
+    psS32 * buffer = NULL;
+    psS32 oldValue = 0;
+    psS32 corruptions = 0;
+    psMemProblemCallback cb;
+
+    buffer = psAlloc( sizeof( psS32 ) );
+
+    // cause memory corruption via buffer underflow
+    *buffer = 1;
+    buffer--;
+    oldValue = *buffer;
+    *buffer = 2;
+
+    problemCallbackCalled = 0;
+    cb = psMemProblemCallbackSet( memProblemCallback );
+
+    corruptions = psMemCheckCorruption( 0 );
+
+    // restore the memory problem callback
+    psMemProblemCallbackSet( cb );
+
+    // restore the value, 'uncorrupting' the buffer
+    *buffer = oldValue;
+    buffer++;
+
+    psFree( buffer );
+
+    ok ( corruptions == 1,
+         "Expected one memory corruption but found %d", corruptions );
+    skip_start ( corruptions != 1,
+                 1, "Expected one memory corruption but found %d", corruptions );
+
+    ok ( problemCallbackCalled == 1, "The memProblemCallback was invoked" );
+
+    skip_end();
+}
+
+
+void memProblemCallback( psMemBlock *ptr, const char *file, unsigned int lineno )
+{
+    problemCallbackCalled++;
+}
+
+
+psMemId memAllocCallback( const psMemBlock *ptr )
+{
+    allocCallbackCalled++;
+    return 1;
+}
+
+psMemId memFreeCallback( const psMemBlock *ptr )
+{
+    freeCallbackCalled++;
+    return 1;
+}
+
+psPtr TPOutOfMemoryExhaustedCallback( size_t size )
+{
+    exhaustedCallbackCalled++;
+    return NULL;
+}
+
+void TPmultipleFree( void )
+{
+    psPtr buffer = psAlloc( 1024 );
+    psPtr buffer2 = buffer;
+
+    psFree( buffer );
+    psFree( buffer2 );
+}
+
+psS32 memCheckTypes( void )
+{
+    psArray *negative;
+    negative = psArrayAlloc(2);
+    psMetadata *neg;
+    neg = psMetadataAlloc();
+
+    psArray *array;
+    array = psArrayAlloc(100);
+    int okay = psMemCheckType(PS_DATA_ARRAY,array);
+    if ( ! okay )
+        psFree(array);
+    ok ( okay, "psMemCheckArray in memCheckType");
+    skip_start( ! okay, 28, "psMemCheckArray in memCheckType");
+
+    ok ( psMemCheckType(PS_DATA_ARRAY, neg), "psMemCheckArray in memCheckType");
+    psFree(array);
+
+    psBitSet *bits;
+    bits = psBitSetAlloc(100);
+    okay = psMemCheckType(PS_DATA_BITSET, bits);
+    if ( ! okay )
+        psFree(bits);
+    ok ( okay, "psMemCheckBitSet in memCheckType");
+    skip_start ( !okay, 27, "psMemCheckBitSet in memCheckType");
+
+    ok ( psMemCheckType(PS_DATA_BITSET, negative),
+         "psMemCheckBitSet in memCheckType");
+    psFree(bits);
+
+    psCube *cube;
+    cube = psCubeAlloc();
+    okay = psMemCheckType(PS_DATA_CUBE, cube);
+    if ( ! okay )
+        psFree(cube);
+    ok ( okay, "psMemCheckCube in memCheckType");
+    skip_start ( !okay, 26, "psMemCheckCube in memCheckType");
+    psFree(cube);
+
+    psFits *fits;
+    fits = psFitsOpen("test.fits","w");
+    psImage* img = psImageAlloc(16,16,PS_TYPE_F32);
+    psFitsWriteImage(fits,NULL,img,1,NULL);
+    psFree(img);
+    okay = psMemCheckType(PS_DATA_FITS, fits);
+    if ( ! okay )
+        psFree(fits);
+    ok ( okay, "psMemCheckFits in memCheckType");
+    skip_start ( !okay, 25,"psMemCheckFits in memCheckType");
+    psFitsClose(fits);
+
+    psHash *hash;
+    hash = psHashAlloc(100);
+    okay = psMemCheckType(PS_DATA_HASH, hash);
+    if ( ! okay )
+        psFree(hash);
+    ok ( okay, "psMemCheckHash in memCheckType");
+    skip_start ( !okay, 24, "psMemCheckHash in memCheckType");
+    psFree(hash);
+
+    psHistogram *histogram;
+    histogram = psHistogramAlloc(1.1, 2.2, 2);
+    okay = psMemCheckType(PS_DATA_HISTOGRAM, histogram);
+    if ( ! okay )
+        psFree(histogram);
+    ok ( okay, "psMemCheckHistogram in memCheckType");
+    skip_start ( !okay, 23, "psMemCheckHistogram in memCheckType");
+    psFree(histogram);
+
+    psImage *image;
+    image = psImageAlloc(5, 5, PS_TYPE_F32);
+    okay = psMemCheckType(PS_DATA_IMAGE, image);
+    if ( ! okay )
+        psFree(image);
+    ok ( okay, "psMemCheckImage in memCheckType");
+    skip_start ( !okay, 22, "psMemCheckImage in memCheckType");
+    psFree(image);
+
+    psKernel *kernel;
+    kernel = psKernelAlloc(0, 1, 0, 1);
+    okay = psMemCheckType(PS_DATA_KERNEL, kernel);
+    if ( ! okay )
+        psFree(kernel);
+    ok ( okay, "psMemCheckKernel in memCheckType");
+    skip_start ( !okay, 21, "psMemCheckKernel in memCheckType");
+    psFree(kernel);
+
+    psList *list;
+    list = psListAlloc(NULL);
+    okay = psMemCheckType(PS_DATA_LIST, list);
+    if ( ! okay )
+        psFree(list);
+    ok ( okay, "psMemCheckList in memCheckType");
+    skip_start ( !okay, 20, "psMemCheckList in memCheckType");
+    psFree(list);
+
+    psLookupTable *lookup;
+    char *file = "tableF32.dat";
+    char *format = "\%f \%lf \%d \%ld";
+    lookup = psLookupTableAlloc(file, format, 10);
+    okay = psMemCheckType(PS_DATA_LOOKUPTABLE, lookup);
+    if ( ! okay )
+        psFree(lookup);
+    ok ( okay, "psMemCheckLookupTable in memCheckType");
+    skip_start ( !okay, 19, "psMemCheckLookupTable in memCheckType");
+    psFree(lookup);
+
+    psMetadata *metadata;
+    metadata = psMetadataAlloc();
+    okay = psMemCheckType(PS_DATA_METADATA, metadata);
+    if ( ! okay )
+        psFree(metadata);
+    ok ( okay, "psMemCheckMetadata in memCheckType");
+    skip_start ( !okay, 18, "psMemCheckMetadata in memCheckType");
+    psFree(metadata);
+
+    psMetadataItem *metaItem;
+    metaItem = psMetadataItemAlloc("name", PS_DATA_S32, "COMMENT", 1);
+    okay = psMemCheckType(PS_DATA_METADATAITEM, metaItem);
+    if ( ! okay )
+        psFree(metaItem);
+    ok ( okay, "psMemCheckMetadataItem in memCheckType");
+    skip_start ( !okay, 17, "psMemCheckMetadataItem in memCheckType");
+    psFree(metaItem);
+
+    psMinimization *min;
+    min = psMinimizationAlloc(3, 0.1);
+    okay = psMemCheckType(PS_DATA_MINIMIZATION, min);
+    if ( ! okay )
+        psFree(min);
+    ok ( okay, "psMemCheckMinimization in memCheckType");
+    skip_start ( !okay, 16, "psMemCheckMinimization in memCheckType");
+    psFree(min);
+
+    psPixels *pixels;
+    pixels = psPixelsAlloc(100);
+    okay = psMemCheckType(PS_DATA_PIXELS, pixels);
+    if ( ! okay )
+        psFree(pixels);
+    ok ( okay, "psMemCheckPixels in memCheckType");
+    skip_start ( !okay, 15, "psMemCheckPixels in memCheckType");
+    psFree(pixels);
+
+    psPlane *plane;
+    plane = psPlaneAlloc();
+    okay = psMemCheckType(PS_DATA_PLANE, plane);
+    if ( ! okay )
+        psFree(plane);
+    ok ( okay, "psMemCheckPlane in memCheckType.");
+    skip_start ( !okay, 14, "psMemCheckPlane in memCheckType.");
+    psFree(plane);
+
+    psPlaneDistort *planeDistort;
+    planeDistort = psPlaneDistortAlloc(1, 1, 1, 1);
+    okay =  psMemCheckType(PS_DATA_PLANEDISTORT, planeDistort);
+    if ( ! okay )
+        psFree(planeDistort);
+    ok ( okay, "psMemCheckPlaneDistort in memCheckType.");
+    skip_start ( !okay, 13, "psMemCheckPlaneDistort in memCheckType.");
+    psFree(planeDistort);
+
+    psPlaneTransform *planeTransform;
+    planeTransform = psPlaneTransformAlloc(1, 1);
+    okay = psMemCheckType(PS_DATA_PLANETRANSFORM, planeTransform);
+    if ( ! okay )
+        psFree(planeTransform);
+    ok ( okay, "psMemCheckPlaneTransform in memCheckType");
+    skip_start ( !okay, 12, "psMemCheckPlaneTransform in memCheckType");
+    psFree(planeTransform);
+
+    psPolynomial1D *poly1;
+    poly1 = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2);
+    okay = psMemCheckType(PS_DATA_POLYNOMIAL1D, poly1);
+    if ( ! okay )
+        psFree(poly1);
+    ok ( okay, "psMemCheckPolynomial1D in memCheckType");
+    skip_start ( !okay, 11, "psMemCheckPolynomial1D in memCheckType");
+    psFree(poly1);
+
+    psPolynomial2D *poly2;
+    poly2 = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 2, 1);
+    okay = psMemCheckType(PS_DATA_POLYNOMIAL2D, poly2);
+    if ( ! okay )
+        psFree(poly2);
+    ok ( okay, "psMemCheckPolynomial2D in memCheckType");
+    skip_start ( !okay, 10, "psMemCheckPolynomial2D in memCheckType");
+    psFree(poly2);
+
+    psPolynomial3D *poly3;
+    poly3 = psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 2, 1, 1);
+    okay = psMemCheckType(PS_DATA_POLYNOMIAL3D, poly3);
+    if ( ! okay )
+        psFree(poly3);
+    ok ( okay, "psMemCheckPolynomial3D in memCheckType");
+    skip_start ( !okay, 9, "psMemCheckPolynomial3D in memCheckType");
+    psFree(poly3);
+
+    psPolynomial4D *poly4;
+    poly4 = psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 2, 1, 2, 1);
+    okay = psMemCheckType(PS_DATA_POLYNOMIAL4D, poly4);
+    if ( ! okay )
+        psFree(poly4);
+    ok ( okay, "psMemCheckPolynomial4D in memCheckType");
+    skip_start ( !okay, 8, "psMemCheckPolynomial4D in memCheckType");
+    psFree(poly4);
+
+    psProjection *proj;
+    proj = psProjectionAlloc(1, 1, 2.1, 2.1, PS_PROJ_TAN);
+    okay = psMemCheckType(PS_DATA_PROJECTION, proj);
+    if ( ! okay )
+        psFree(proj);
+    ok ( okay, "psMemCheckProjection in memCheckType.");
+    skip_start ( !okay, 7, "psMemCheckProjection in memCheckType.");
+    psFree(proj);
+
+    psScalar *scalar;
+    psC64 c64 = 1.1 + 7I;
+    scalar = psScalarAlloc(c64, PS_TYPE_F64);
+    okay = psMemCheckType(PS_DATA_SCALAR, scalar);
+    if ( ! okay )
+        psFree(scalar);
+    ok ( okay, "psMemCheckScalar in memCheckType");
+    skip_start ( !okay, 6, "psMemCheckScalar in memCheckType");
+    psFree(scalar);
+
+    psSphere *sphere;
+    sphere = psSphereAlloc();
+    okay = psMemCheckType(PS_DATA_SPHERE, sphere);
+    if ( ! okay )
+        psFree(sphere);
+    ok ( okay, "psMemCheckSphere in memCheckType");
+    skip_start ( !okay, 5, "psMemCheckSphere in memCheckType");
+    psFree(sphere);
+
+    psSphereRot *sphereRot;
+    sphereRot = psSphereRotAlloc(0, 0, 20);
+    okay = psMemCheckType(PS_DATA_SPHEREROT, sphereRot);
+    if ( ! okay )
+        psFree(sphereRot);
+    ok( okay, "psMemCheckSphereRot in memCheckType");
+    skip_start( !okay, 4, "psMemCheckSphereRot in memCheckType");
+    psFree(sphereRot);
+
+    psSpline1D *spline;
+    spline = psSpline1DAlloc(2, 1, 0, 2);
+    okay = psMemCheckType(PS_DATA_SPLINE1D, spline);
+    if ( ! okay )
+        psFree(spline);
+    ok( okay, "psMemCheckSpline1D in memCheckType");
+    skip_start( !okay, 3, "psMemCheckSpline1D in memCheckType");
+    psFree(spline);
+
+    psStats *stats;
+    stats = psStatsAlloc(PS_STAT_MAX);
+    okay = psMemCheckType(PS_DATA_STATS, stats);
+    if ( ! okay )
+        psFree(stats);
+    ok( okay, "psMemCheckStats in memCheckType");
+    skip_start( !okay, 2, "psMemCheckStats in memCheckType");
+    psFree(stats);
+
+    psTime *time;
+    time = psTimeAlloc(PS_TIME_UT1);
+    okay = psMemCheckType(PS_DATA_TIME, time);
+    if ( ! okay )
+        psFree(time);
+    ok( okay, "psMemCheckTime in memCheckType");
+    skip_start( !okay, 1, "psMemCheckTime in memCheckType");
+    psFree(time);
+
+    psVector *vector;
+    vector = psVectorAlloc(100, PS_TYPE_F32);
+    okay = psMemCheckType(PS_DATA_VECTOR, vector);
+    ok( okay, "psMemCheckVector in memCheckType");
+    psFree(vector);
+
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+    skip_end();
+
+    psFree(negative);
+    psFree(neg);
+
+    return 0;
+}
Index: trunk/psLib/test/sys/tap_psString.c
===================================================================
--- trunk/psLib/test/sys/tap_psString.c	(revision 10810)
+++ trunk/psLib/test/sys/tap_psString.c	(revision 10810)
@@ -0,0 +1,606 @@
+/** @file  tst_psString.c
+ *
+ * -*- mode: C; c-basic-indent: 4; tab-width: 8; indent-tabs-mode: nil -*-
+ * vim: set cindent ts=8 sw=4 expandtab:
+ *
+ *  @brief Test driver for psString functions
+ *
+ *  This test driver contains the following test points for psStringCopy
+ *  and psStringNCopy, and related string functions.
+ *    1) Verify string copy - psStringCopy
+ *    2) Verify empty string copy - psStringCopy
+ *    3) Verify string copy with length - psStringNCopy
+ *    4) Verify empty string copy with length - psStringNCopy
+ *    5) Copy string to larger string - psStringNCopy
+ *    6) Copy string with negative size - psStringNCopy
+ *    7) Verifiy creation of string literal - PS_STRING
+ *
+ *  Return:   Number of test points which failed
+ *
+ *  @author  Eric Van Alst, MHPCC
+ *
+ *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2006-12-18 19:18:46 $
+ *
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ *
+ */
+
+#include <string.h>
+#include "pslib.h"
+#include "tap.h"
+#include "pstap.h"
+
+
+#define STR_0 "binky had a leeeetle lamb"
+
+psS32 testStringCopy00(void);
+psS32 testStringCopy01(void);
+psS32 testStringCopy02(void);
+psS32 testStringCopy03(void);
+psS32 testStringCopy04(void);
+//psS32 testStringCopy05(void);
+psS32 testStringCopy06(void);
+
+psS32 testStrAppend00(void);
+psS32 testStrAppend01(void);
+psS32 testStrAppend02(void);
+psS32 testStrAppend03(void);
+
+psS32 testStrPrepend00(void);
+psS32 testStrPrepend01(void);
+psS32 testStrPrepend02(void);
+psS32 testStrPrepend03(void);
+
+psS32 testStrSplit00(void);
+psS32 testNULLStrings(void);
+psS32 testStrCheck(void);
+
+static const char* const NullString = "";
+
+
+psS32 main( psS32 argc, char* argv[] )
+{
+    plan_tests(55);
+
+    testStringCopy00();
+    testStringCopy01();
+    testStringCopy02();
+    testStringCopy03();
+    testStringCopy04();
+    testStringCopy06();
+
+    testStrAppend00();
+    testStrAppend01();
+    testStrAppend02();
+    testStrAppend03();
+
+    testStrPrepend00();
+    testStrPrepend01();
+    testStrPrepend02();
+    testStrPrepend03();
+
+    testStrSplit00();
+    testNULLStrings();
+    testStrCheck();
+}
+
+
+psS32 testStringCopy00(void)
+{
+    diag("testStringCopy00");
+
+    char  stringval[20] = "E R R O R";
+    psS32   result = 0;
+    psS32   result1 = 0;
+    char  *strResult;
+
+    // Test point #1 Verify string copy - psStringCopy
+    strResult = psStringCopy(stringval);
+    // Perform string compare
+    result = strcmp(strResult, stringval);
+    // Modify original string
+    stringval[0]='G';
+    result1 = strcmp(strResult, stringval);
+    stringval[0]='E';
+    ok ( ( result == 0 ) && ( result1 != 0),
+         "Failed test point #1 strcmp result = %d expected 0\n",result);
+
+    // Free memory allocated
+    psFree(strResult);
+
+    return 0;
+}
+
+
+psS32 testStringCopy01(void)
+{
+    diag("testStringCopy01");
+
+    char  *emptyval = "";
+    psS32   result = 0;
+    char  *strResult;
+
+    // Test point #2 Verify empty string copy - psStringCopy
+    strResult = psStringCopy(emptyval);
+    // Perform string compare
+    result = strcmp(strResult, emptyval);
+    ok ( result == 0,
+         "test point #2 strcmp result = %d expected 0\n",result);
+
+    // Free memory allocated
+    psFree(strResult);
+
+    return 0;
+}
+
+
+psS32 testStringCopy02(void)
+{
+    diag("testStringCopy02");
+
+    psS32   result = 0;
+    psS32   result1 = 0;
+    char  *strResult;
+    char  stringval1[20] = "e r r o r";
+    psS32   substringlen = 5;
+    char  *substringval = "e r r";
+
+    // Test point #3 Verify string copy with length - psStringNCopy
+    strResult = psStringNCopy(stringval1, substringlen);
+    // Perform string compare and get string length
+    result = strncmp(strResult, substringval, substringlen);
+    // Change original string
+    stringval1[0] = 'g';
+    result1 = strncmp(strResult, substringval, substringlen);
+    ok ( ( result == 0 ) && ( result1 == 0 ),
+         "Failed test point #3 strcmp result = %d expected 0\n",result);
+
+    // Free memory allocated
+    psFree(strResult);
+
+    return 0;
+}
+
+psS32 testStringCopy03(void)
+{
+    diag("testStringCopy03");
+
+    psS32   result = 0;
+    psS32   result1 = 0;
+    char  *strResult;
+    char  *stringvalnocopy = "F A I L";
+
+    // Test point #4 Verify empty string copy with length - psStringNCopy
+    strResult = psStringNCopy(stringvalnocopy, 0);
+    // Perform string compare and get sting length
+    result = strcmp(strResult, stringvalnocopy);
+    result1 = strlen(strResult);
+    ok ( result != 0,
+         "test point #4 strcmp result = %d didn't expected %d\n",result,0);
+
+    // Free memory
+    psFree(strResult);
+
+    return 0;
+}
+
+psS32 testStringCopy04(void)
+{
+    diag("testStringCopy04");
+
+    psS32   result = 0;
+    psS32   result1 = 0;
+    char  *strResult;
+    char  stringval[20] = "E R R O R";
+    psS32   increaseSize = 5;
+
+    // Test point #5 Copy string to larger string - psStringNCopy
+    strResult = psStringNCopy(stringval, (strlen(stringval) + increaseSize));
+    // Perform string compare and get string length
+    result = strcmp(strResult, stringval);
+    result1 = strlen(strResult);
+    // The strings should still compare
+    ok ( result == 0 && result1 == strlen(stringval),
+         "test point #5 strcmp result = %d expected %d\n",result,0);
+
+    // Free memory
+    psFree(strResult);
+
+    return 0;
+}
+
+// XXX This test needs to be modified to check for maximum size
+//     This will require a mod to psStringNCopy source to check for maximum size
+//
+//psS32 testStringCopy05(void)
+//{
+//    char  *strResult;
+//    char  stringval[20] = "E R R O R";
+//    psS32   negativeSize = -5;
+//
+//    // Test point #6 Copy string with negative size - psStringNCopy
+//    strResult = psStringNCopy(stringval, negativeSize);
+//    if ( strResult != NULL ) {
+//        fprintf(stderr,"Failed test point #6 return value = %p expected NULL\n",
+//                strResult);
+//        return 1;
+//    }
+//    // Memory should not have been allocated
+//
+//    return 0;
+//}
+
+
+psS32 testStringCopy06(void)
+{
+    diag("testStringCopy06");
+
+    char  *strResult;
+    char  stringval[20] = "E R R O R";
+    psS32   result = 0;
+
+    // Test point #7 Verify creation of string literal - PS_STRING
+    strResult = PS_STRING(E R R O R);
+    result = strcmp(strResult, stringval);
+    ok ( result == 0,
+         "test point #7 strcmp result = %d expected %d",result,0);
+
+    // Memory should not have been allocated
+    return 0;
+}
+
+
+psS32 testStrAppend00(void)
+{
+    diag("testStrAppend00");
+
+    char *str=NULL;
+    int result = 0;
+
+    str = psStringCopy("3.14159");
+
+    psStringAppend(&str, "%d%s", 2653589, "79323846");
+
+    // Test point: Verify string append
+    result = strcmp(str, "3.14159265358979323846");
+    ok ( result == 0, "Failed test point\n");
+
+    psFree(str);
+
+    return 0;
+}
+
+psS32 testStrAppend01(void)
+{
+    diag("testStrAppend01");
+
+    ssize_t sz;
+    char *str=NULL;
+
+    // test nonsensical invocations ...
+    sz = psStringAppend(NULL, NULL);
+    ok ( sz == 0, "Failed test point\n");
+
+    sz = psStringAppend(&str, NULL);
+    ok ( sz == 0, "Failed test point\n");
+
+    return 0;
+}
+
+
+psS32 testStrAppend02(void)
+{
+    diag("testStrAppend02");
+
+    char *str=NULL;
+    int result;
+
+    // test string creation
+    psStringAppend(&str, "%s", "fubar");
+    result = strcmp(str, "fubar");
+    ok ( result == 0, "Failed test point\n");
+
+    psFree(str);
+
+    return 0;
+}
+
+psS32 testStrAppend03(void)
+{
+    diag("testStrAppend03");
+
+    char *str=NULL;
+    int result;
+
+    str = psStringCopy(STR_0);
+
+    // test null-op
+    psStringAppend(&str, NullString);
+    result = strcmp(str, STR_0);
+    ok ( result == 0, "Failed test point str=[%s]\n", str);
+
+    psFree(str);
+
+    return 0;
+}
+
+
+psS32 testStrPrepend00(void)
+{
+    diag("testStrPrepend00");
+
+    char *str=NULL;
+    int result = 0;
+
+    str = psStringCopy("79323846");
+
+    psStringPrepend(&str, "%s%d","3.14159", 2653589 );
+
+    // Test point: Verify string append
+    result = strcmp(str, "3.14159265358979323846");
+    ok ( result == 0, "Failed test point\n");
+
+    psFree(str);
+
+    return 0;
+}
+
+
+psS32 testStrPrepend01(void)
+{
+    diag("testStrPrepend01");
+
+    ssize_t sz;
+    char *str=NULL;
+
+    // test nonsensical invocations ...
+    sz = psStringPrepend(NULL, NULL);
+    ok ( sz == 0, "Failed test point\n");
+
+    sz = psStringPrepend(&str, NULL);
+    ok ( sz == 0, "Failed test point\n");
+
+    return 0;
+}
+
+psS32 testStrPrepend02(void)
+{
+    diag("testStrPrepend02");
+
+    char *str=NULL;
+    int result;
+
+    // test string creation
+    psStringPrepend(&str, "%s", "fubar");
+    result = strcmp(str, "fubar");
+    ok ( result == 0, "Failed test point\n");
+
+    psFree(str);
+
+    return 0;
+}
+
+psS32 testStrPrepend03(void)
+{
+    diag("testStrPrepend03");
+
+    char *str=NULL;
+    int result;
+
+    str = psStringCopy(STR_0);
+
+    // test null-op
+    psStringPrepend(&str, NullString);
+    result = strcmp(str, STR_0);
+    ok ( result == 0, "test point str=[%s]\n", str);
+
+    psFree(str);
+
+    return 0;
+}
+
+
+psS32 testStrSplit00(void)
+{
+    diag("testStrSplit00");
+
+    psList *strList = NULL;
+    char str[35];
+    char split[5];
+    strncpy(str, "This is, a, test case, to check.", 35);
+    strncpy(split, ",", 2);
+    psString psStr;
+    psString psSplit;
+    psStr = psStringCopy(str);
+    psSplit = psStringCopy(split);
+
+    //Return NULL for NULL inputs
+    strList = psStringSplit(NULL, NULL, true);
+    ok (!strList, "psStringSplit" );
+    psFree(strList);
+
+    strList = NULL;
+    //Return empty list for NULL string input
+    strList = psStringSplit(NULL, split, true);
+    ok ( !psListLength(strList), "psListLength()" );
+    psFree(strList);
+
+    strList = NULL;
+    //Return NULL for NULL splitter input
+    strList = psStringSplit(str, NULL, true);
+    ok ( !strList, "psStringSplit" );
+    psFree(strList);
+
+    strList = NULL;
+    //Return a psList* of psStrings
+    strList = psStringSplit(str, split, true);
+    ok (strList->n == 4,
+        "psStringSplit to return the correct number of strings.\n");
+
+    ok ( !strncmp((psString)(strList->head->data), "This is", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->data), " a", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->data), " test case",10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->next->data), " to check.", 10),
+         "psStringSplit failed to return expected strings.");
+
+    psFree(strList);
+    //Return correct psList when using (psString, char*)
+    strList = psStringSplit(psStr, split, true);
+    ok (strList->n == 4,
+        "psStringSplit to return the correct number of strings.\n");
+
+    ok ( !strncmp((psString)(strList->head->data), "This is", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->data), " a", 10),
+         "psStringSplit failed to return expected strings.");
+
+    ok ( strncmp((psString)(strList->head->next->next->data), " test case",10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->next->data), " to check.", 10),
+         "psStringSplit to return expected strings.");
+
+    psFree(strList);
+    //Return correct psList when using (char*, psString)
+    strList = psStringSplit(str, psSplit, true);
+    ok (strList->n == 4,
+        "psStringSplit to return the correct number of strings.\n");
+
+    ok ( !strncmp((psString)(strList->head->data), "This is", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->data), " a", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->data), " test case",10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->next->data), " to check.", 10),
+         "psStringSplit to return expected strings.");
+
+    psFree(strList);
+    //Return correct psList when using (psString, psString)
+    strList = psStringSplit(psStr, psSplit, true);
+    ok (strList->n == 4,
+        "psStringSplit to return the correct number of strings.\n");
+
+    ok ( !strncmp((psString)(strList->head->data), "This is", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->data), " a", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->data), " test case",10),
+         "psStringSplit  to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->next->data), " to check.", 10),
+         "psStringSplit to return expected strings.");
+
+    psFree(strList);
+    //Return correct psList output for string of zero length case
+    strncpy(str, "This is,, a,, test case,, to check.", 35);
+    strList = psStringSplit(str, split, false);
+    ok (strList->n == 4,
+        "psStringSplit to return the correct number of strings.\n");
+
+    ok ( !strncmp((psString)(strList->head->data), "This is", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->data), " a", 10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->data), " test case",10),
+         "psStringSplit to return expected strings.");
+
+    ok ( !strncmp((psString)(strList->head->next->next->next->data), " to check.", 10),
+         "psStringSplit to return expected strings.");
+
+    psFree(strList);
+    psFree(psStr);
+    psFree(psSplit);
+    return 0;
+}
+
+psS32 testNULLStrings(void)
+{
+    diag("testNULLStrings");
+
+    psString nullTest = NULL;
+    psString output = NULL;
+    ssize_t outSize = 0;
+    char** nullDest = NULL;
+    char** test;
+    //psStringCopy should return NULL for NULL input string
+    //    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    output = psStringCopy(nullTest);
+    ok (output == NULL,
+        "psStringCopy to return NULL for NULL input string.\n");
+
+    //psStringNCopy should return NULL for NULL input string
+    output = psStringNCopy(nullTest, 100);
+    ok (output == NULL,
+        "psStringNCopy to return NULL for NULL input string.\n");
+
+    //psStringAppend should return 0 for NULL input destination
+    outSize = psStringAppend(nullDest, NullString);
+    ok (outSize == 0,
+        "psStringAppend to return 0 for NULL input destination.\n");
+
+    //psStringAppend should return 0 for NULL input format
+    outSize = psStringAppend(test, nullTest);
+    ok (outSize == 0,
+        "psStringAppend to return 0 for NULL input format.\n");
+
+    //psStringPrepend should return 0 for NULL input destination
+    outSize = psStringPrepend(nullDest, " ");
+    ok (outSize == 0,
+        "psStringPrepend to return 0 for NULL input destination.\n");
+
+    //psStringPrepend should return 0 for NULL input format
+    outSize = psStringPrepend(test, nullTest);
+    ok (outSize == 0,
+        "psStringPrepend to return 0 for NULL input format.\n");
+
+    //psStringSplit should return empty list for NULL input string
+    psList *nullList = NULL;
+    nullList = psStringSplit(nullTest, ",", true);
+    ok ( !psListLength(nullList),
+         "psStringSplit to return NULL for NULL input string.\n");
+    psFree(nullList);
+
+    nullList = NULL;
+    //psStringSplit should return NULL for NULL input splitter
+    nullList = psStringSplit("Hello World", nullTest, true);
+    ok ( !nullList,
+         "psStringSplit to return NULL for NULL input splitter.\n");
+    psFree(nullList);
+
+    return 0;
+}
+
+psS32 testStrCheck(void)
+{
+    diag("testStrCheck");
+
+    psString str = NULL;
+    str = psStringAlloc(10);
+    strcpy(str, "Hello");
+    ok (psMemCheckString(str), "psString allocated!\n");
+
+    ok (psMemCheckType(PS_DATA_STRING, str), "psString allocated!\n");
+    psFree(str);
+
+    char charStr[10];
+    ok (!psMemCheckType(PS_DATA_STRING, charStr),
+        "Input string is a psDataType");
+
+    return 0;
+}
Index: trunk/psLib/test/sys/tap_psTrace.c
===================================================================
--- trunk/psLib/test/sys/tap_psTrace.c	(revision 10810)
+++ trunk/psLib/test/sys/tap_psTrace.c	(revision 10810)
@@ -0,0 +1,365 @@
+/*****************************************************************************
+    This code will test whether trace levels can be set successfully.
+ 
+    XXX: For the last two testpoints, must verify that the results are
+    correct, and put that verification in the test as well.
+ *****************************************************************************/
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "pslib.h"
+#include "tap.h"
+#include "pstap.h"
+
+
+static psS32 testTrace00(void);
+static psS32 testTrace01(void);
+static psS32 testTrace02(void);
+static psS32 testTrace03(void);
+static psS32 testTrace04(void);
+static psS32 testTrace05(void);
+static psS32 testTrace05a(void);
+static psS32 testTrace06(void);
+static psS32 testTrace08(void);
+
+
+psS32 main( psS32 argc, char* argv[] )
+{
+    plan_tests(45);
+
+    testTrace00();
+    testTrace01();
+    testTrace02();
+    testTrace03();
+    testTrace04();
+    testTrace05();
+    testTrace05a();
+    testTrace06();
+    testTrace08();
+}
+
+
+static psS32 testTrace00(void)
+{
+    diag("testTrace00");
+
+    psS32 i;
+    psS32 lev = 0;
+
+    //    psTraceSetDestination(stderr);
+    psTraceSetDestination(2);
+
+    for (i=0;i<10;i++) {
+        (void)psTraceSetLevel(".", i);
+        lev = psTraceGetLevel(".");
+        ok(lev == i, "trace level was %d, actual was %d\n", i, lev);
+    }
+
+    (void)psTraceSetLevel(".", 3);
+
+    for (i=5;i<10;i++) {
+        (void)psTraceSetLevel(".NODE00", i);
+        lev = psTraceGetLevel(".NODE00");
+        ok (lev == i,"(.NODE00) expected trace level was %d, actual was %d\n",
+            i, lev);
+
+        lev = psTraceGetLevel(".");
+        ok (lev == 3,
+            "expected trace level was %d, actual was %d\n", i, 3);
+    }
+
+
+    (void)psTraceSetLevel(".NODE00.NODE01", 4);
+    for (i=0;i<10;i++) {
+        (void)psTraceSetLevel(".NODE00.NODE01", i);
+        lev = psTraceGetLevel(".NODE00.NODE01");
+        ok (lev == i,
+            "(.NODE00.NODE01) expected trace level was %d, actual was %d\n",
+            i, lev);
+    }
+
+    return 0;
+}
+
+
+static psS32 testTrace01(void)
+{
+    diag("testTrace01");
+
+    //    psTraceSetDestination(stderr);
+    psTraceSetDestination(2);
+    (void)psTraceSetLevel(".A.B.C.D.E", 5);
+
+    psTrace(".A.C.D.C",1,"You should not see this.\n");
+    psTrace(".A.B.C.D.E",2,"You should see this.\n");
+    psTrace(".A.B.C.D.E.F",3,"You should see this too.\n");
+
+    psTracePrintLevels();
+
+    return 0;
+}
+
+static psS32 testTrace02(void)
+{
+    diag("testTrace02");
+
+    psTraceReset();
+    //    psTraceSetDestination(stderr);
+    psTraceSetDestination(2);
+    psTraceSetLevel(".A.B", 2);
+    psTraceSetLevel(".A.B.C.D.E", 5);
+    psTracePrintLevels();
+    psTraceSetLevel(".A.B", 10);
+    psTracePrintLevels();
+
+    ok (10 == psTraceGetLevel(".A.B.C"),
+        ".A.B.C did not dynamically inherit a trace level (%d)\n",
+        psTraceGetLevel(".A.B.C"));
+
+    ok (10 == psTraceGetLevel(".A.B.C.D"),
+        ".A.B.C.D did not dynamically inherit a trace level (%d)\n",
+        psTraceGetLevel(".A.B.C.D"));
+
+    ok (5 == psTraceGetLevel(".A.B.C.D.E"),
+        ".A.B.C.D.E did dynamically inherit a trace level (%d)\n",
+        psTraceGetLevel(".A.B.C.D.E"));
+
+    return 0;
+}
+
+static psS32 testTrace03(void)
+{
+    diag("testTrace03");
+
+    psS32 i = 0;
+    psS32 lev = 0;
+
+    //    psTraceSetDestination(stderr);
+    psTraceSetDestination(2);
+
+    for (i=0;i<10;i++) {
+        (void)psTraceSetLevel(".", i);
+        psTraceReset();
+
+        lev = psTraceGetLevel(".");
+        ok (lev == PS_UNKNOWN_TRACE_LEVEL,
+            "expected trace level was %d, actual was %d\n",
+            PS_UNKNOWN_TRACE_LEVEL, lev);
+    }
+
+    (void)psTraceSetLevel(".", 5);
+    (void)psTraceSetLevel(".a", 4);
+    (void)psTraceSetLevel(".a.b", 3);
+    (void)psTraceSetLevel(".a.b.c", 2);
+    ok (!((5 != psTraceGetLevel(".")) ||
+          (4 != psTraceGetLevel(".a")) ||
+          (3 != psTraceGetLevel(".a.b")) ||
+          (2 != psTraceGetLevel(".a.b.c"))),
+        "trace successFlag = false;levels were not settable?\n");
+
+    psTraceReset();
+    ok (!((PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".")) ||
+          (PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".a")) ||
+          (PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".a.b")) ||
+          (PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".a.b.c"))),
+        "trace levels were not reset properly\n");
+
+    return 0;
+}
+
+
+static psS32 testTrace04(void)
+{
+    diag("testTrace04");
+
+    int FD;
+    psS32 nb = 0;
+    FD = creat("tst_psTrace02_OUT", 0666);
+    //    printf("\nFD = %d\n", FD);
+    //    fp = fopen("tst_psTrace02_OUT", "w");
+    for (nb = 0 ; nb<4;nb++) {
+        if (nb == 0)
+            //            psTraceSetDestination(stdout);
+            psTraceSetDestination(1);
+        if (nb == 1)
+            //            psTraceSetDestination(stderr);
+            psTraceSetDestination(2);
+        if (nb == 2)
+            psTraceSetDestination(0); //NULL
+        if (nb == 3)
+            psTraceSetDestination(FD);
+
+        (void)psTraceSetLevel(".", 4);
+        psTrace(".", 5, "(0) This message should not be displayed (%x)\n",
+                0xbeefface);
+        (void)psTraceSetLevel(".", 7);
+        psTrace(".", 5, "(0) This message should be displayed (%x)\n",
+                0xbeefface);
+
+        (void)psTraceSetLevel(".a", 4);
+        psTrace(".a", 5, "(1) This message should not be displayed (%x)\n",
+                0xbeefface);
+        (void)psTraceSetLevel(".a", 7);
+        psTrace(".a", 5, "(1) This message should be displayed (%x)\n",
+                0xbeefface);
+
+
+        (void)psTraceSetLevel(".a.b", 4);
+        psTrace(".a.b", 5, "(2) This message should not be displayed (%x)\n",
+                0xbeefface);
+        (void)psTraceSetLevel(".a.b", 7);
+        psTrace(".a.b", 5, "(2) This message should be displayed (%x)\n",
+                0xbeefface);
+        (void)psTraceSetLevel(".a.b.c", 12);
+        psTrace(".a.b.c", 11, "(3) This message should be displayed (%x)\n",
+                0xbeefface);
+
+    }
+
+    close(FD);
+
+    return(0);
+}
+
+static psS32 testTrace05(void)
+{
+    //    psTraceSetDestination(stderr);
+    psTraceSetDestination(2);
+
+    (void)psTraceSetLevel(".", 9);
+
+    (void)psTraceSetLevel(".a", 8);
+    (void)psTraceSetLevel(".b", 7);
+    (void)psTraceSetLevel(".c", 5);
+
+    (void)psTraceSetLevel(".a.a", 4);
+    (void)psTraceSetLevel(".a.b", 3);
+
+    (void)psTraceSetLevel(".b.a", 2);
+    (void)psTraceSetLevel(".b.b", 1);
+
+    (void)psTraceSetLevel(".c.a", 0);
+    (void)psTraceSetLevel(".c.b", 3);
+    (void)psTraceSetLevel(".c.c", 5);
+
+    psTracePrintLevels();
+
+    return 0;
+
+}
+
+static psS32 testTrace05a(void)
+{
+    (void)psTraceSetLevel(".", 9);
+
+    (void)psTraceSetLevel("a", 8);
+    (void)psTraceSetLevel("b", 7);
+    (void)psTraceSetLevel("c", 5);
+
+    (void)psTraceSetLevel("a.a", 4);
+    (void)psTraceSetLevel("a.b", 3);
+
+    (void)psTraceSetLevel("b.a", 2);
+    (void)psTraceSetLevel("b.b", 1);
+
+    (void)psTraceSetLevel("c.a", 0);
+    (void)psTraceSetLevel("c.b", 3);
+    (void)psTraceSetLevel("c.c", 5);
+
+    psTracePrintLevels();
+
+    return 0;
+
+}
+
+static psS32 testTrace06(void)
+{
+    //    psTraceSetDestination(stderr);
+    psTraceSetDestination(2);
+
+    (void)psTraceSetLevel(".", 9);
+
+    (void)psTraceSetLevel(".a", 8);
+    (void)psTraceSetLevel(".b", 7);
+    (void)psTraceSetLevel(".c", 5);
+
+    (void)psTraceSetLevel(".a.a", 4);
+    (void)psTraceSetLevel(".a.b", 3);
+
+    (void)psTraceSetLevel(".b.a", 2);
+    (void)psTraceSetLevel(".b.b", 1);
+
+    (void)psTraceSetLevel(".c.a", 0);
+    (void)psTraceSetLevel(".c.b", 3);
+    (void)psTraceSetLevel(".c.c", 5);
+
+    psTraceReset();
+
+    if ((psTraceGetLevel(".")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".a")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".b")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".c")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".a.a")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".a.b")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".b.a")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".b.b")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".c.a")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".c.b")!=PS_UNKNOWN_TRACE_LEVEL) ||
+            (psTraceGetLevel(".c.c")!=PS_UNKNOWN_TRACE_LEVEL)) {
+        return 1;
+    }
+
+    return 0;
+}
+
+// Ensure that the leading dot in the component names are optional.
+static psS32 testTrace08(void)
+{
+    psTraceReset();
+    (void)psTraceSetLevel(".", 9);
+
+    (void)psTraceSetLevel(".a", 8);
+    (void)psTraceSetLevel(".b", 7);
+    (void)psTraceSetLevel(".c", 5);
+
+    (void)psTraceSetLevel(".a.a", 4);
+    (void)psTraceSetLevel(".a.b", 3);
+
+    (void)psTraceSetLevel(".b.a", 2);
+    (void)psTraceSetLevel(".b.b", 1);
+
+    (void)psTraceSetLevel(".c.a", 0);
+    (void)psTraceSetLevel(".c.b", 3);
+    (void)psTraceSetLevel(".c.c", 5);
+
+    psTracePrintLevels();
+
+    if ((psTraceGetLevel(".")!=9) ||
+            (psTraceGetLevel("a")!=8) ||
+            (psTraceGetLevel("b")!=7) ||
+            (psTraceGetLevel("c")!=5) ||
+            (psTraceGetLevel("a.a")!=4) ||
+            (psTraceGetLevel("a.b")!=3) ||
+            (psTraceGetLevel("b.a")!=2) ||
+            (psTraceGetLevel("b.b")!=1) ||
+            (psTraceGetLevel("c.a")!=0) ||
+            (psTraceGetLevel("c.b")!=3) ||
+            (psTraceGetLevel("c.c")!=5)) {
+        printf("psTraceGetLevel(.) is %d\n", psTraceGetLevel("."));
+        printf("psTraceGetLevel(a) is %d\n", psTraceGetLevel("a"));
+        printf("psTraceGetLevel(b) is %d\n", psTraceGetLevel("b"));
+        printf("psTraceGetLevel(c) is %d\n", psTraceGetLevel("c"));
+        printf("psTraceGetLevel(a.a) is %d\n", psTraceGetLevel("a.a"));
+        printf("psTraceGetLevel(a.b) is %d\n", psTraceGetLevel("a.b"));
+        printf("psTraceGetLevel(b.a) is %d\n", psTraceGetLevel("b.a"));
+        printf("psTraceGetLevel(b.b) is %d\n", psTraceGetLevel("b.b"));
+        printf("psTraceGetLevel(c.a) is %d\n", psTraceGetLevel("c.a"));
+        printf("psTraceGetLevel(c.b) is %d\n", psTraceGetLevel("c.b"));
+        printf("psTraceGetLevel(c.c) is %d\n", psTraceGetLevel("c.c"));
+
+        return 1;
+    }
+
+    return 0;
+}
