Index: trunk/psLib/test/sys/tap_psConfigure.c
===================================================================
--- trunk/psLib/test/sys/tap_psConfigure.c	(revision 12607)
+++ trunk/psLib/test/sys/tap_psConfigure.c	(revision 12781)
@@ -11,6 +11,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-02-07 22:50:18 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-04-10 21:09:31 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -24,25 +24,18 @@
 
 
-static psS32 psLibVersion00(void);
-
-
 psS32 main(psS32 argc, char* argv[])
 {
-    plan_tests(1);
+    plan_tests(2);
 
-    psLibVersion00();
+    // Simple test of psLibVersion()
+    // XX: Must somehow verify the output is correct.
+    {
+        psMemId id = psMemGetId();
+        char *stringVal = NULL;
+        stringVal = psLibVersion();
+        ok(stringVal != NULL && strlen(stringVal), "Version is cool");
+        psFree(stringVal);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 }
 
-
-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 12607)
+++ trunk/psLib/test/sys/tap_psError.c	(revision 12781)
@@ -3,16 +3,8 @@
  *  @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.3 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-20 03:57:25 $
+ *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-04-10 21:09:31 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -28,7 +20,8 @@
 
 // Function used in testError02 to verify the psErrorStackPrintV function
-static void myErrorStackPrint(FILE *fd,
-                              const char *fmt,
-                              ...)
+static void myErrorStackPrint(
+    FILE *fd,
+    const char *fmt,
+    ...)
 {
     va_list ap;
@@ -41,362 +34,346 @@
 
 
-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 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 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 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 (%d)", last->code);
-    skip_start(last->code == PS_ERR_NONE,
-               9, "psErrorLast did return PS_ERR_NONE for empty stack");
-
-    psFree(last);
-
-    // HEY
-    // 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 (%d)", getErr->code);
-    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 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 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 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;
-}
-
-
 psS32 main( psS32 argc, char* argv[] )
 {
     psLogSetFormat("HLNM");
-    plan_tests(38);
-
-    // XXX: testError03() fails if we put it in sequence with the others.
-    testError03();
-    testError00();
-    testError01();
-    testError02();
-    testError04();
-    testError05();
-    testErrorRegister();
+    plan_tests(60);
+
+
+    //psError() tests
+    {
+        psS32  intval=1;
+        psS64 longval = 2;
+        float floatval = 3.01;
+        char  charval = 'E';
+        char *stringval = "E R R O R";
+
+        // Multiple type values placed in the error string
+        // XX: The output is never verified
+        {
+            psMemId id = psMemGetId();
+            psError(PS_ERR_UNKNOWN, true,
+                    "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s",
+                    intval,longval,floatval,charval,stringval);
+            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+        }
+    
+
+        // String values in error message
+        // XX: The output is never verified
+        {
+            psMemId id = psMemGetId();
+            psError(PS_ERR_UNKNOWN, true, "NO VALUES");
+            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // Empty strings in error message
+        // XX: The output is never verified
+        {
+            psMemId id = psMemGetId();
+            psError(PS_ERR_UNKNOWN, true, " ");
+            ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // Verify the return value of psErrorMsg is the psErrorCode passed
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;
+            ok(psError(code, true, "Error code = %d", code) == code, "Failed return value verify.");
+            psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A");
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // test1B empty string in for name argument
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;
+            ok(psError(code+1, true, "Error code = %d", code+1) == code+1,
+                 "Failed return with empty string.");
+            psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // test1D undefined code
+        {
+            psMemId id = psMemGetId();
+            ok(psError(-1, true, "Error code = %d", -1) == -1,
+                 "Failed return with undefined code.");
+            psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D");
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // test1E set psErrorMsg argument to false
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;
+            ok(psError(code, false, "Error code = %d", code) == code,
+                "Failed return with false new arg.");
+            psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E");
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // test1F psErrorMsg with a error code less then PS_ERR_BASE(256)
+        {
+            psMemId id = psMemGetId();
+            ok(psError(9, true, "Errno code = %d", 9) == 9, "Error Code" );
+            psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F");
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+    }
+
+
+    //testError02()
+    {
+        // Generate error message and verify return value
+        {
+            psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+            psMemId id = psMemGetId();
+            ok(psError(code, true, "Error code = %d", code) == code,
+                "Failed return value verify.");
+            myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+    }
+
+
+    //psErrorGet(), psErrorLast()
+    {
+        // Attempt to get last error message with an empty stack verify 
+        // psErr with code PS_ERR_NONE
+        {
+            psMemId id = psMemGetId();
+            psErrorClear();
+            psErr *last = psErrorLast();
+            ok(last != NULL, "psErrorLast() returned non-NULL");
+            skip_start(last == NULL, 1, "Skipping tests because psErrorLast() returned NULL");
+            ok(last->code == PS_ERR_NONE,
+              "psErrorLast did return PS_ERR_NONE for empty stack(%d)", last->code);
+            skip_end();
+            psFree(last);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+        // Attempt to get specific error message with empty stack verify
+        // psErr with code PS_ERR_NONE
+        {
+            psMemId id = psMemGetId();
+            psErr *getErr= psErrorGet(2);
+            ok(getErr != NULL, "psErrorGet(2) returned non-NULL");
+            skip_start(getErr == NULL, 1, "Skipping tests because psErrorGet() returned NULL");
+            ok(getErr->code == PS_ERR_NONE,
+               "psErrorGet(2) did return PS_ERR_NONE for empty stack(%d)", getErr->code);
+            skip_end();
+            psFree(getErr);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // Attempt to get error message with invalid index and an empty stack
+        {
+            psMemId id = psMemGetId();
+            psErr *getErr= psErrorGet(-1);
+            ok(getErr != NULL, "psErrorGet(-1) returned non-NULL");
+            skip_start(getErr == NULL, 1, "Skipping tests because psErrorGet(-1) returned NULL");
+            ok(getErr->code == PS_ERR_NONE, "psErrorGet with invalid index/empty stack");
+            skip_end();
+            psFree(getErr);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // Generate three error messages, ensure they are correctly returned by psError()
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+            ok(psError(code, true, "Error code = %d", code) ==  code,
+                "psError() returned correct error code (example 1)");
+            ok(psError((code+1), false, "Error code = %d", (code+1)) == (code+1),
+                "psError() returned correct error code (example 2)");
+            ok(psError((code+2), false, "Error code = %d", (code+2)) == (code+2),
+                "psError() returned correct error code (example 3)");
+    
+            psErr *last = psErrorLast();
+            psErr *getErr= psErrorGet(0);
+    
+            // Check that last and get with 0 index are equal
+            ok(last == getErr, "psErrorGet(0) equal to psErrorLast()");
+            psFree(last);
+
+            // Verify the last error message was returned
+            ok(getErr->code == (code+2), "psErrorLast() did retrieve last error");
+            psFree(getErr);
+            psErrorClear();
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // Verify the middle error message can be retrieved
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+            psError(code, true, "Error code = %d", code);
+            psError((code+1), false, "Error code = %d", (code+1));
+            psError((code+2), false, "Error code = %d", (code+2));
+            psErr *getErr= psErrorGet(1);
+            ok(getErr->code == (code+1), "psErrorGet() did not retrieve proper error");
+            psFree(getErr);
+            psErrorClear();
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+        // Verify the psErrorGet returns non-NULL PS_ERR_NONE if an invalid index
+        // is given with non-empty error stack
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+            psError(code, true, "Error code = %d", code);
+            psError((code+1), false, "Error code = %d", (code+1));
+            psError((code+2), false, "Error code = %d", (code+2));
+            psErr *getErr= psErrorGet(-1);
+            ok(getErr->code == PS_ERR_NONE, "psErrorGet() did not return PS_ERR_NONE w/ invalid arg");
+            psFree(getErr);
+            psErrorClear();
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+    }
+
+
+    // psErrorClear()
+    {
+        // With an attemp error stack call psErrorClear
+        {
+            psMemId id = psMemGetId();
+            psErrorClear();
+            // Get the last error message and verify PS_ERR_NONE (empty stack)
+            psErr *lastAfterClear = psErrorLast();
+            ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected.");
+            psFree(lastAfterClear);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+
+        // Generate three error messages to have messages on error stack
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+            ok(psError(code, true, "Error code = %d", code) == code,
+                "Failed return value verify.");
+            ok(psError((code+1), false, "Error code = %d", (code+1)) == (code+1),
+                "Failed return value verify.");
+            ok(psError((code+2), false, "Error code = %d", (code+2)) == (code+2),
+                "Failed return value verify.");
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+        // Get the last error message and verify it has the expected code
+        {
+            psMemId id = psMemGetId();
+            psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
+            psErr *last = psErrorLast();
+            ok(last->code == (code+2), "psErrorLast return expected.");
+            psFree(last);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+
+        // Clear the error stack
+        {
+            psMemId id = psMemGetId();
+            psErrorClear();
+            // Get the last error message after clear and verify is has PS_ERR_NONE code
+            psErr *lastAfterClear  = psErrorLast();
+            ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected.");
+            psFree(lastAfterClear);
+            ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        }
+    }
+
+
+    // psErrorCodeString()
+    {
+        // 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");
+    }
+
+
+    //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);
+    }
 }
-
-
+//HERE
Index: trunk/psLib/test/sys/tap_psLine.c
===================================================================
--- trunk/psLib/test/sys/tap_psLine.c	(revision 12607)
+++ trunk/psLib/test/sys/tap_psLine.c	(revision 12781)
@@ -5,6 +5,6 @@
  *  @author  dRob, MHPCC
  *
- *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-22 22:47:07 $
+ *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-04-10 21:09:31 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -17,129 +17,73 @@
 #include "string.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(16);
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
+
+    //testLineAlloc()
+    {
+        psMemId id = psMemGetId();
+        psLine *lineline = NULL;
+        lineline = psLineAlloc(20);
+        ok(lineline->NLINE==20, "psLine set NLINE parameter during Allocation");
+        ok(lineline->Nline == 0, "psLine set Nline parameter during Allocation");
+        strncpy(lineline->line, "Hello World", 20);
+        ok(!strncmp(lineline->line, "Hello World", 20),
+            "psLine was stored a simple string!");
+        psFree(lineline);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+    // testLineInit()
+    {
+        psMemId id = psMemGetId();
+        psLine *line = NULL;
+        //Return false for NULL input
+        int okay = !psLineInit(line);
+        ok(okay, "psLineInit.  Expected false for NULL psLine input");
+        //Allocate a line and return true on Init
+        line = psLineAlloc(1);
+        okay = psLineInit(line);
+        ok(okay, "psLineInit.  Expected true for valid psLine input");
+        ok(line->NLINE == 1 && line->Nline == 0, "psLineInit returned line parameters.");
+        psFree(line);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 
 
-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;
-}
+    // testLineAdd()
+    {
+        psMemId id = psMemGetId();
+        psLine *line = NULL;
+        //Return false for NULL input
+        ok(!psLineAdd(line, "Hello World"),
+            "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");
+        ok(line->NLINE == 20 && line->Nline == 11,
+            "psLineAdd failed to return the correct line parameters");
+        ok(!strncmp(line->line, "Hello World", 20),
+            "psLineAdd failed to store the correct line string.");
+        psFree(line);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 
 
-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;
+    // testLineChk()
+    {
+        psMemId id = psMemGetId();
+        psLine *line = NULL;
+        //Return false for Null input line
+        ok(!psMemCheckLine(line),
+            "psMemCheckLine return false for NULL line input");
+        line = psLineAlloc(1);
+        ok(psMemCheckLine(line),
+            "psMemCheckLine return true for valid line input");
+        psFree(line);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 }
-
-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 12607)
+++ trunk/psLib/test/sys/tap_psMemory.c	(revision 12781)
@@ -3,9 +3,8 @@
 *  @brief Contains the tests for psMemory.[ch]
 *
-*
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-03-20 03:57:25 $
+*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-04-10 21:09:31 $
 *
 *  XXXX: Several tests fail with an Abort and are commented out.
@@ -42,43 +41,252 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(10);
-
-    void TPFreeReferencedMemory( void );
-    if (1) {
-        TPFreeReferencedMemory();
-    }
-
-    void TPOutOfMemory( void );
+    plan_tests(46);
+
+    // TPFreeReferencedMemory()
+    {
+        psMemId id = psMemGetId();
+        psS32 *mem  = ( psS32* ) psAlloc( 100 * sizeof( psS32 ) );
+        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);
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Upon requesting more memory than is available, psalloc shall call
+    // the psMemExhaustedCallback.
     // XXXX: Skipping TPOutOfMemory() because of test abort failure
     if (0) {
-        TPOutOfMemory();
-    }
-
-    void TPReallocOutOfMemory( void );
+        psMemId id = psMemGetId();
+        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
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+
+    // Bug/Task #562 regression test.  Upon requesting more memory than is available,
+    // psRealloc shall call the psMemExhaustedCallback.
     // XXXX: Skipping TPReallocOutOfMemory() because of test abort failure
     if (0) {
-        TPReallocOutOfMemory();
-    }
-
-    void TPCheckBufferPositive( void );
-    if (1) {
-        TPCheckBufferPositive();
-    }
-
-    void TPrealloc( void );
-    if (1) {
-        TPrealloc();
-    }
-
-    void TPallocCallback( void );
-    if (1) {
-        TPallocCallback();
-    }
-
-    void TPcheckLeaks( void );
+        psMemId id = psMemGetId();
+        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 ] );
+        }
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psAlloc shall allocate memory blocks writeable by caller.
+    {
+        psMemId id = psMemGetId();
+        const psS32 size = 100;
+        psS32 *mem = ( psS32* ) psAlloc( size * sizeof( psS32 ) );
+        ok(mem != NULL, "psAlloc returned non-NULL value" );
+        for ( psS32 index = 0;index < size;index++ ) {
+            mem[ index ] = index;
+        }
+        psS32 failed = 0;
+        for ( psS32 index = 0;index < size;index++ ) {
+            if ( mem[ index ] != index ) {
+                failed++;
+            }
+        }
+        ok(failed == 0, "mem legit" );
+        psFree( mem );
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // psRealloc shall increase/decrease memory buffer while preserving contents
+    {
+        psMemId id = psMemGetId();
+        const psS32 initialSize = 100;
+        // allocate buffer with known values.
+        psS32 *mem1 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+        psS32 *mem2 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+        psS32 *mem3 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+        for ( psS32 lcv = 0;lcv < initialSize;lcv++ ) {
+            mem1[lcv] = mem2[lcv] = mem3[lcv] = lcv;
+        }
+        psMemCheckCorruption(stderr, false);
+        // 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(stderr, false);
+        // 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 );
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // TPallocCallback()
+    {
+        psMemId id = psMemGetId();
+        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.
+        psS32 *mem1 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+        psS32 *mem2 = ( psS32* ) psAlloc( initialSize * sizeof( psS32 ) );
+        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" );
+        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" );
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // TPcheckLeaks()
     // XXXX: Skipping TPcheckLeaks() because of test abort failure
     if (0) {
-        TPcheckLeaks();
-    }
+        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 );
+        ok(blks[ 0 ] ->lineno == lineMark,
+             "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 );
+        ok(blks[ 0 ] ->lineno == lineMark, "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);
+        ok(blks[ 0 ] ->lineno == lineMark,
+             "psMemCheckLeaks found a leak other than the expected." );
+        psFree(blks);
+        psFree(buffers[1]);
+        psFree(buffers[3]);
+    }
+
 
     void TPmultipleFree( void );
@@ -87,337 +295,254 @@
         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(stderr, false);
-
-    // 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(stderr, false);
-
-    // 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 ] );
+
+//HERE
+    // memCheckTypes()
+    if (1) {
+        psMemId id = psMemGetId();
+        psArray *negative = psArrayAlloc(2);
+        psMetadata *neg = psMetadataAlloc();
+
+        psArray *array = psArrayAlloc(100);
+        int okay = psMemCheckType(PS_DATA_ARRAY,array);
+        if (!okay) {
+            psFree(array);
+        }
+        ok(okay, "psMemCheckArray in memCheckType");
+
+        ok(!psMemCheckType(PS_DATA_ARRAY, neg), "psMemCheckType with metadata input");
+        psFree(array);
+
+        psBitSet *bits;
+        bits = psBitSetAlloc(100);
+        okay = psMemCheckType(PS_DATA_BITSET, bits);
+        if (!okay )
+            psFree(bits);
+        ok(okay, "psMemCheckBitSet in memCheckType");
+        ok(!psMemCheckType(PS_DATA_BITSET, negative), "psMemCheckType on psArray");
+        psFree(bits);
+
+        psCube *cube;
+        cube = psCubeAlloc();
+        okay = psMemCheckType(PS_DATA_CUBE, cube);
+        if (!okay )
+            psFree(cube);
+        ok(okay, "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");
+        psFitsClose(fits);
+
+        psHash *hash;
+        hash = psHashAlloc(100);
+        okay = psMemCheckType(PS_DATA_HASH, hash);
+        if (!okay )
+            psFree(hash);
+        ok(okay, "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");
+        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");
+        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");
+        psFree(kernel);
+
+        psList *list;
+        list = psListAlloc(NULL);
+        okay = psMemCheckType(PS_DATA_LIST, list);
+        if (!okay )
+            psFree(list);
+        ok(okay, "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");
+        psFree(lookup);
+
+        psMetadata *metadata;
+        metadata = psMetadataAlloc();
+        okay = psMemCheckType(PS_DATA_METADATA, metadata);
+        if (!okay )
+            psFree(metadata);
+        ok(okay, "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");
+        psFree(metaItem);
+
+        psMinimization *min;
+        min = psMinimizationAlloc(3, 0.1);
+        okay = psMemCheckType(PS_DATA_MINIMIZATION, min);
+        if (!okay )
+            psFree(min);
+        ok(okay, "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");
+        psFree(pixels);
+
+        psPlane *plane;
+        plane = psPlaneAlloc();
+        okay = psMemCheckType(PS_DATA_PLANE, plane);
+        if (!okay )
+            psFree(plane);
+        ok(okay, "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.");
+        psFree(planeDistort);
+
+        psPlaneTransform *planeTransform;
+        planeTransform = psPlaneTransformAlloc(1, 1);
+        okay = psMemCheckType(PS_DATA_PLANETRANSFORM, planeTransform);
+        if (!okay )
+            psFree(planeTransform);
+        ok(okay, "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");
+        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");
+        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");
+        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");
+        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.");
+        psFree(proj);
+    
+        psScalar *scalar;
+        psF64 f64 = 1.1;
+        scalar = psScalarAlloc(f64, PS_TYPE_F64);
+        okay = psMemCheckType(PS_DATA_SCALAR, scalar);
+        if (!okay )
+            psFree(scalar);
+        ok(okay, "psMemCheckScalar in memCheckType");
+        psFree(scalar);
+    
+        psSphere *sphere;
+        sphere = psSphereAlloc();
+        okay = psMemCheckType(PS_DATA_SPHERE, sphere);
+        if (!okay )
+            psFree(sphere);
+        ok(okay, "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");
+        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");
+        psFree(spline);
+    
+        psStats *stats;
+        stats = psStatsAlloc(PS_STAT_MAX);
+        okay = psMemCheckType(PS_DATA_STATS, stats);
+        if (!okay )
+            psFree(stats);
+        ok(okay, "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");
+        psFree(time);
+    
+        psVector *vector;
+        vector = psVectorAlloc(100, PS_TYPE_F32);
+        okay = psMemCheckType(PS_DATA_VECTOR, vector);
+        ok(okay, "psMemCheckVector in memCheckType");
+        psFree(vector);
+        psFree(negative);
+        psFree(neg);
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
 }
 
@@ -455,12 +580,7 @@
     psFree( buffer );
 
-    ok ( corruptions == 1,
+    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();
+    ok(problemCallbackCalled == 1, "The memProblemCallback was invoked" );
 }
 #endif
@@ -500,312 +620,3 @@
 }
 
-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;
-    psF64 f64 = 1.1;
-    scalar = psScalarAlloc(f64, 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 12607)
+++ trunk/psLib/test/sys/tap_psString.c	(revision 12781)
@@ -20,6 +20,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-27 22:52:03 $
+ *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-04-10 21:09:31 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -35,182 +35,124 @@
 #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);
-
 
 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;
-}
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
+    plan_tests(72);
+
+
+    //testStringCopy00()
+    {
+        psMemId id = psMemGetId();
+        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",result);
+        // Free memory allocated
+        psFree(strResult);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStringCopy01()
+    {
+        psMemId id = psMemGetId();
+        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",result);
+        // Free memory allocated
+        psFree(strResult);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStringCopy02()
+    {
+        psMemId id = psMemGetId();
+        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",result);
+        psFree(strResult);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStringCopy03()
+    {
+        psMemId id = psMemGetId();
+        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",result,0);
+        psFree(strResult);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStringCopy04()
+    {
+        psMemId id = psMemGetId();
+        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",result,0);
+        psFree(strResult);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 
 // 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)
+//psS32 testStringCopy05()
 //{
 //    char  *strResult;
@@ -231,369 +173,293 @@
 
 
-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;
+    // testStringCopy06()
+    {
+        psMemId id = psMemGetId();
+        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
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrAppend00()
+    {
+        psMemId id = psMemGetId();
+        char *str = psStringCopy("3.14159");
+        psStringAppend(&str, "%d%s", 2653589, "79323846");
+        // Test point: Verify string append
+        int result = strcmp(str, "3.14159265358979323846");
+        ok(result == 0, "Failed test point");
+        psFree(str);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrAppend01()
+    {
+        psMemId id = psMemGetId();
+        char *str=NULL;
+        // test nonsensical invocations ...
+        ssize_t sz = psStringAppend(NULL, NULL);
+        ok(sz == 0, "Failed test point");
+        sz = psStringAppend(&str, NULL);
+        ok(sz == 0, "Failed test point");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrAppend02()
+    {
+        psMemId id = psMemGetId();
+        char *str=NULL;
+        // test string creation
+        psStringAppend(&str, "%s", "fubar");
+        int result = strcmp(str, "fubar");
+        ok(result == 0, "Failed test point");
+        psFree(str);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrAppend03()
+    {
+        psMemId id = psMemGetId();
+        char *str =psStringCopy(STR_0);
+        // test null-op
+        psStringAppend(&str, "%s", "");
+        is_str(str, STR_0, "Failed test point");
+        psFree(str);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrPrepend00()
+    {
+        psMemId id = psMemGetId();
+        char *str = psStringCopy("79323846");
+        psStringPrepend(&str, "%s%d","3.14159", 2653589 );
+        // Test point: Verify string append
+        int result = strcmp(str, "3.14159265358979323846");
+        ok(result == 0, "Failed test point");
+        psFree(str);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrPrepend01()
+    {
+        psMemId id = psMemGetId();
+        char *str=NULL;
+        // test nonsensical invocations ...
+        ssize_t sz = psStringPrepend(NULL, NULL);
+        ok(sz == 0, "Failed test point");
+        sz = psStringPrepend(&str, NULL);
+        ok(sz == 0, "Failed test point");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrPrepend02()
+    {
+        psMemId id = psMemGetId();
+        char *str=NULL;
+        // test string creation
+        psStringPrepend(&str, "%s", "fubar");
+        int result = strcmp(str, "fubar");
+        ok(result == 0, "Failed test point");
+        psFree(str);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrPrepend03()
+    {
+        // test null-op
+        psMemId id = psMemGetId();
+        char *str =  psStringCopy(STR_0);
+        psStringPrepend(&str, "%s", "");
+        int result = strcmp(str, STR_0);
+        ok(result == 0, "test point str=[%s]", str);
+        psFree(str);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrSplit00()
+    {
+        psMemId id = psMemGetId();
+        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");
+        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");
+        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 failed 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");
+        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");
+        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");
+        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);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testNULLStrings()
+    {
+        psMemId id = psMemGetId();
+        psString nullTest = NULL;
+        psString output = NULL;
+        ssize_t outSize = 0;
+        char** nullDest = NULL;
+        char** test = NULL;
+        //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");
+    
+        //psStringNCopy should return NULL for NULL input string
+        output = psStringNCopy(nullTest, 100);
+        ok(output == NULL, "psStringNCopy to return NULL for NULL input string");
+    
+        //psStringAppend should return 0 for NULL input destination
+        outSize = psStringAppend(nullDest, "%s", "");
+        ok(outSize == 0, "psStringAppend to return 0 for NULL input destination");
+    
+        //psStringAppend should return 0 for NULL input format
+        outSize = psStringAppend(test, nullTest);
+        ok(outSize == 0, "psStringAppend to return 0 for NULL input format");
+    
+        //psStringPrepend should return 0 for NULL input destination
+        outSize = psStringPrepend(nullDest, " ");
+        ok(outSize == 0, "psStringPrepend to return 0 for NULL input destination");
+    
+        //psStringPrepend should return 0 for NULL input format
+        outSize = psStringPrepend(test, nullTest);
+        ok(outSize == 0, "psStringPrepend to return 0 for NULL input format");
+    
+        //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");
+        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");
+        psFree(nullList);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testStrCheck()
+    {
+        psMemId id = psMemGetId();
+        psString str = psStringAlloc(10);
+        strcpy(str, "Hello");
+        ok(psMemCheckString(str), "psString allocated!");
+        ok(psMemCheckType(PS_DATA_STRING, str), "psString allocated");
+        psFree(str);
+    
+        char charStr[10];
+        ok(!psMemCheckType(PS_DATA_STRING, charStr),
+            "Input string is a psDataType");
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
 }
-
-
-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 =psStringCopy(STR_0);
-
-    // test null-op
-    psStringAppend(&str, "%s", "");
-    is_str(str, STR_0, "Failed test point");
-    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, "%s", "");
-    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 failed 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("test""s");
-
-    psString nullTest = NULL;
-    psString output = NULL;
-    ssize_t outSize = 0;
-    char** nullDest = NULL;
-    char** test = NULL;
-    //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, "%s", "");
-    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;
-}
+// HERE
Index: trunk/psLib/test/sys/tap_psStringSubstitute.c
===================================================================
--- trunk/psLib/test/sys/tap_psStringSubstitute.c	(revision 12607)
+++ trunk/psLib/test/sys/tap_psStringSubstitute.c	(revision 12781)
@@ -11,73 +11,87 @@
 int main (void)
 {
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
     plan_tests(16);
 
-    diag("psStringSubstitute() tests");
 
     // Return input for NULL key
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy(ORIGINAL);
         psStringSubstitute(&input, ",", NULL);
         ok(input && strcmp(input, ORIGINAL) == 0, "output = %s", input);
         psFree(input);
-        //        ok(psMemCheckLeaks(0, NULL, stdout, false) == 0, "Memory Leaks");
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Return input for empty key
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy(ORIGINAL);
         psStringSubstitute(&input, "XXX", "");
         ok(input && strcmp(input, ORIGINAL) == 0, "output = %s", input);
         psFree(input);
-        //        ok(psMemCheckLeaks(0, NULL, stdout, false) == 0, "Memory Leaks");
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Return corrected version for NULL replace
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy(ORIGINAL);
         psStringSubstitute(&input, NULL, ",");
         ok(input && strcmp(input, CORRECTED) == 0, "output = %s", input);
         psFree(input);
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Return corrected version for empty replace
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy(ORIGINAL);
         psStringSubstitute(&input, "", ",");
         ok(input && strcmp(input, CORRECTED) == 0, "output = %s", input);
         psFree(input);
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Return NULL for NULL input
     {
+        psMemId id = psMemGetId();
         int status = psStringSubstitute(NULL, "XXX", ",");
         ok(status == 0, "status = %d", status);
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Return emptry string for empty input
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy("");
         psStringSubstitute(&input, "XXX", ",");
         ok(input && strcmp(input, "") == 0, "output = %s", input);
         psFree(input);
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Change commas to bangs
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy(ORIGINAL);
         psStringSubstitute(&input, "!", ",");
         ok(input && strcmp(input, "This is! a! test case! to check.") == 0, "output = %s", input);
         psFree(input);
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
+
 
     // Long replacement text --- should allocate new space
     {
+        psMemId id = psMemGetId();
         psString input = psStringCopy(ORIGINAL);
         psStringSubstitute(&input, "; This string is too long to fit in input(35 chars)", ".");
@@ -86,8 +100,5 @@
            "output = %s", input);
         psFree(input);
-        mem();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
-
-
-    return exit_status();
 }
Index: trunk/psLib/test/sys/tap_psTrace.c
===================================================================
--- trunk/psLib/test/sys/tap_psTrace.c	(revision 12607)
+++ trunk/psLib/test/sys/tap_psTrace.c	(revision 12781)
@@ -8,5 +8,4 @@
 #include <fcntl.h>
 #include <unistd.h>
-
 #include "pslib.h"
 #include "tap.h"
@@ -14,288 +13,219 @@
 
 
-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);
-    (void)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);
-    (void)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);
-    (void)psTraceSetDestination(2);
-    (void)psTraceSetLevel(".A.B", 2);
-    (void)psTraceSetLevel(".A.B.C.D.E", 5);
-    psTracePrintLevels();
-    (void)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);
-    (void)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);
-            (void)psTraceSetDestination(1);
-        if (nb == 1)
-            //            psTraceSetDestination(stderr);
-            (void)psTraceSetDestination(2);
-        if (nb == 2)
-            (void)psTraceSetDestination(0); //NULL
-        if (nb == 3)
-            (void)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);
-
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
+    plan_tests(54);
+
+    // testTrace00()
+    {
+        psMemId id = psMemGetId();
+        psS32 lev = 0;
+        (void)psTraceSetDestination(2);
+        for (int i=0;i<10;i++) {
+            (void)psTraceSetLevel(".", i);
+            lev = psTraceGetLevel(".");
+            ok(lev == i, "trace level was %d, actual was %d", i, lev);
+        }
+
+        (void)psTraceSetLevel(".", 3);
+        for (int i=5;i<10;i++) {
+            (void)psTraceSetLevel(".NODE00", i);
+            lev = psTraceGetLevel(".NODE00");
+            ok (lev == i,"(.NODE00) expected trace level was %d, actual was %d",
+                i, lev);
+    
+            lev = psTraceGetLevel(".");
+            ok (lev == 3,
+                "expected trace level was %d, actual was %d", i, 3);
+        }
+    
+        (void)psTraceSetLevel(".NODE00.NODE01", 4);
+        for (int 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",
+                i, lev);
+        }
+
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace01()
+    {
+        psMemId id = psMemGetId();
+        (void)psTraceSetDestination(2);
+        (void)psTraceSetLevel(".A.B.C.D.E", 5);
+        psTrace(".A.C.D.C",1,"You should not see this");
+        psTrace(".A.B.C.D.E",2,"You should see this");
+        psTrace(".A.B.C.D.E.F",3,"You should see this too");
+        psTracePrintLevels();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace02()
+    {
+        psMemId id = psMemGetId();
+        psTraceReset();
+        (void)psTraceSetDestination(2);
+        (void)psTraceSetLevel(".A.B", 2);
+        (void)psTraceSetLevel(".A.B.C.D.E", 5);
+        psTracePrintLevels();
+        (void)psTraceSetLevel(".A.B", 10);
+        psTracePrintLevels();
+
+        ok (10 == psTraceGetLevel(".A.B.C"),
+            ".A.B.C did not dynamically inherit a trace level (%d)",
+            psTraceGetLevel(".A.B.C"));
+
+        ok (10 == psTraceGetLevel(".A.B.C.D"),
+            ".A.B.C.D did not dynamically inherit a trace level (%d)",
+            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)",
+            psTraceGetLevel(".A.B.C.D.E"));
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace03()
+    {
+        psMemId id = psMemGetId();
+        (void)psTraceSetDestination(2);
+
+        for (int i=0;i<10;i++) {
+            (void)psTraceSetLevel(".", i);
+            psTraceReset();
+            int lev = psTraceGetLevel(".");
+            ok (lev == PS_UNKNOWN_TRACE_LEVEL,
+                "expected trace level was %d, actual was %d",
+                PS_UNKNOWN_TRACE_LEVEL, lev);
+        }
+
+        (void)psTraceSetLevel(".", 5);
         (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);
-    (void)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);
-    (void)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) ||
+        (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?");
+
+        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");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace04()
+    {
+        psMemId id = psMemGetId();
+        int FD = creat("tst_psTrace02_OUT", 0666);
+        for (int nb = 0 ; nb<4;nb++) {
+            if (nb == 0)
+                (void)psTraceSetDestination(1);
+            if (nb == 1)
+                (void)psTraceSetDestination(2);
+            if (nb == 2)
+                (void)psTraceSetDestination(0);
+            if (nb == 3)
+                (void)psTraceSetDestination(FD);
+
+            (void)psTraceSetLevel(".", 4);
+            psTrace(".", 5, "(0) This message should not be displayed (%x)",
+                    0xbeefface);
+            (void)psTraceSetLevel(".", 7);
+            psTrace(".", 5, "(0) This message should be displayed (%x)",
+                    0xbeefface);
+
+            (void)psTraceSetLevel(".a", 4);
+            psTrace(".a", 5, "(1) This message should not be displayed (%x)",
+                    0xbeefface);
+            (void)psTraceSetLevel(".a", 7);
+            psTrace(".a", 5, "(1) This message should be displayed (%x)",
+                    0xbeefface);
+
+            (void)psTraceSetLevel(".a.b", 4);
+            psTrace(".a.b", 5, "(2) This message should not be displayed (%x)",
+                    0xbeefface);
+            (void)psTraceSetLevel(".a.b", 7);
+            psTrace(".a.b", 5, "(2) This message should be displayed (%x)",
+                    0xbeefface);
+            (void)psTraceSetLevel(".a.b.c", 12);
+            psTrace(".a.b.c", 11, "(3) This message should be displayed (%x)",
+                    0xbeefface);
+        }
+        close(FD);
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace05()
+    {
+        psMemId id = psMemGetId();
+        (void)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();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace05a()
+    {
+        psMemId id = psMemGetId();
+        (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();
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testTrace06()
+    {
+        psMemId id = psMemGetId();
+        (void)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) ||
@@ -308,33 +238,28 @@
             (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) ||
+            return 1;
+        }
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // Ensure that the leading dot in the component names are optional.
+    // testTrace08()
+    {
+        psMemId id = psMemGetId();
+        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) ||
@@ -347,19 +272,18 @@
             (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;
+            printf("psTraceGetLevel(.) is %d", psTraceGetLevel("."));
+            printf("psTraceGetLevel(a) is %d", psTraceGetLevel("a"));
+            printf("psTraceGetLevel(b) is %d", psTraceGetLevel("b"));
+            printf("psTraceGetLevel(c) is %d", psTraceGetLevel("c"));
+            printf("psTraceGetLevel(a.a) is %d", psTraceGetLevel("a.a"));
+            printf("psTraceGetLevel(a.b) is %d", psTraceGetLevel("a.b"));
+            printf("psTraceGetLevel(b.a) is %d", psTraceGetLevel("b.a"));
+            printf("psTraceGetLevel(b.b) is %d", psTraceGetLevel("b.b"));
+            printf("psTraceGetLevel(c.a) is %d", psTraceGetLevel("c.a"));
+            printf("psTraceGetLevel(c.b) is %d", psTraceGetLevel("c.b"));
+            printf("psTraceGetLevel(c.c) is %d", psTraceGetLevel("c.c"));
+            return 1;
+        }
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
 }
