Index: /trunk/psLib/test/sys/tap_psError.c
===================================================================
--- /trunk/psLib/test/sys/tap_psError.c	(revision 11661)
+++ /trunk/psLib/test/sys/tap_psError.c	(revision 11662)
@@ -13,6 +13,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2006-12-18 19:18:46 $
+ *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-02-06 04:09:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -27,12 +27,4 @@
 #include "pstap.h"
 
-static psS32 testError00(void);
-static psS32 testError01(void);
-static psS32 testError02(void);
-static psS32 testError03(void);
-static psS32 testError04(void);
-static psS32 testError05(void);
-static psS32 testErrorRegister(void);
-
 // Function used in testError02 to verify the psErrorStackPrintV function
 static void myErrorStackPrint(FILE *fd,
@@ -49,90 +41,96 @@
 
 
-psS32 main( psS32 argc, char* argv[] )
-{
-    plan_tests(38);
-
-    testError00();
-    testError01();
-    testError02();
-    testError03();
-    testError04();
-    testError05();
-    testErrorRegister();
-}
-
-static psS32 testError05(void)
-{
-    diag("testError05");
-
-    // Verify the return value of psErrorCodeString
-    // psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
-    // psLogMsg("tst_psError05", PS_LOG_INFO, psErrorCodeString(code));
-
-    // Verify the return value of psErrorCodeString if code is negative
-    ok( psErrorCodeString(-1) == NULL, "error string with neg. code");
-
-    return 0;
-}
-
-static psS32 testError04(void)
-{
-    diag("testError04");
+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;
-    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,
+
+    // Generate error message and verify return value
+    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;
-}
+
+    myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2);
+
+    return 0;
+}
+
 
 static psS32 testError03(void)
@@ -146,6 +144,6 @@
     // 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");
+    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");
@@ -153,8 +151,9 @@
     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");
+    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");
@@ -233,93 +232,80 @@
 }
 
-static psS32 testError02(void)
-{
-    diag("testError02");
+
+static psS32 testError04(void)
+{
+    diag("testError04");
 
     psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;
-
-    // Generate error message and verify return value
-    ok (psError(code, true, "Error code = %d", code) == code,
+    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.");
-
-    myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2);
-
-    return 0;
-}
-
-static psS32 testError01(void)
-{
-    diag("testError01");
-
-    psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;
-
-    // Verify the return value of psErrorMsg is the psErrorCode passed
-    ok ( psError(code, true, "Error code = %d", code) == code,
-         "Failed return value verify.");
-    skip_start ( psError(code, true, "Error code = %d", code) != code,
-                 4, "Failed return value verify.");
-
-    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A");
-
-    // test1B empty string in for name argument
-    ok ( psError(code+1, true, "Error code = %d", code+1) == code+1,
-         "Failed return with empty string.");
-    skip_start ( psError(code+1, true, "Error code = %d", code+1) != code+1,
-                 3, "Failed return with empty string.");
-
-    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");
-
-    // test1D undefined code
-    ok ( psError(-1, true, "Error code = %d", -1) == -1,
-         "Failed return with undefined code.");
-    skip_start ( psError(-1, true, "Error code = %d", -1) != -1,
-                 2, "Failed return with undefined code.");
-
-    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D");
-
-    // test1E set psErrorMsg argument to false
-    ok( psError(code, false, "Error code = %d", code) == code,
-        "Failed return with false new arg.");
-    skip_start( psError(code, false, "Error code = %d", code) != code,
-                1, "Failed return with false new arg.");
-
-    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E");
-
-    // test1F psErrorMsg with a error code less then PS_ERR_BASE(256)
-    ok( psError(9, true, "Errno code = %d", 9) == 9, "Error Code" );
-
-    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F");
-
-    skip_end();
-    skip_end();
-    skip_end();
-    skip_end();
-
-    return 0;
-}
-
-static psS32 testError00(void)
-{
-    diag("testError00");
-
-    psS32  intval=1;
-    psS64 longval = 2;
-    float floatval = 3.01;
-    char  charval = 'E';
-    char *stringval = "E R R O R";
-
-    // Test point #1 Multiple type values placed in the error string
-    psError(PS_ERR_UNKNOWN, true,
-            "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s",
-            intval,longval,floatval,charval,stringval);
-
-    // Test point #2 String values in error message
-    psError(PS_ERR_UNKNOWN, true, "NO VALUES");
-
-    // Test point #3 Empty strings in error message
-    psError(PS_ERR_UNKNOWN, true, " ");
-
-    return 0;
-}
+    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)
@@ -397,2 +383,20 @@
     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();
+}
+
+
