Changeset 1867
- Timestamp:
- Sep 23, 2004, 11:59:16 AM (22 years ago)
- Location:
- trunk/psLib/test/sysUtils
- Files:
-
- 2 edited
-
tst_psError.c (modified) (4 diffs)
-
verified/tst_psError.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sysUtils/tst_psError.c
r1851 r1867 4 4 * 5 5 * This test driver contains the following test points for psError 6 * 1) Multiple type values in error message 7 * 2) String values in error message 8 * 3) Empty strings in error message 6 * testError00 - psError() 7 * testError01 - psErrorMsg(), psErrorStackPrint() 8 * testError02 - psErrorStackPrintV() 9 * testError03 - psErrorGet(), psErrorLast() 10 * testError04 - psErrorClear() 9 11 * 10 12 * @author Eric Van Alst, MHPCC 11 13 * 12 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 2 23:47:09$14 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-23 21:59:16 $ 14 16 * 15 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 25 24 26 static int testError00(void); 27 static int testError01(void); 28 static int testError02(void); 29 static int testError03(void); 30 static int testError04(void); 31 32 // Function used in testError02 to verify the psErrorStackPrintV function 33 static void myErrorStackPrint(FILE *fd, 34 const char *fmt, 35 ...) 36 { 37 va_list ap; 38 39 // Test whether psErrorStackPrintV() accept a va_list for output variables 40 va_start(ap, fmt); 41 psErrorStackPrintV(fd, fmt, ap); 42 va_end(ap); 43 } 25 44 26 45 testDescription tests[] = { 27 46 {testError00, 0, "psError()", 0, false}, 47 {testError01, 0, "psErrorMsg(),psErrorStackPrint()", 0, false}, 48 {testError02, 0, "psErrorStackPrintV()", 0, false}, 49 {testError03, 0, "psErrorGet(),psErrorLast()", 0, false}, 50 {testError04, 0, "psErrorClear()", 0, false}, 28 51 {NULL} 29 52 }; … … 34 57 35 58 return ( !runTestSuite(stderr, "psError", tests, argc, argv) ); 59 } 60 61 static int testError04(void) 62 { 63 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 64 psErr *last = NULL; 65 psErr *lastAfterClear = NULL; 66 67 // Generate three error messages 68 if (psErrorMsg("test3A", code, true, "Error code = %d", code) != code) { 69 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 70 return 30; 71 } 72 if (psErrorMsg("test3A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) { 73 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 74 return 31; 75 } 76 if (psErrorMsg("test3A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) { 77 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 78 return 32; 79 } 80 81 // Get the last error message and verify it has the expected code 82 last = psErrorLast(); 83 if(last->code != (code+2)) { 84 psLogMsg("tst_psError04", PS_LOG_ERROR, "psErrorLast did not return expected."); 85 return 33; 86 } 87 psFree(last); 88 89 // Clear the error stack 90 psErrorClear(); 91 92 // Get the last error message after clear and verify is has PS_ERR_NONE code 93 lastAfterClear = psErrorLast(); 94 if(last->code != PS_ERR_NONE) { 95 psLogMsg("tst_psError05", PS_LOG_ERROR, "psErrorLaster did not return expected."); 96 return 34; 97 } 98 psFree(lastAfterClear); 99 100 return 0; 101 } 102 103 static int testError03(void) 104 { 105 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 106 psErr *last = NULL; 107 psErr *get 108 = NULL; 109 110 // Attempt to get last error message with an empty stack verify psErr with code PS_ERR_NONE 111 last = psErrorLast(); 112 if(last->code != PS_ERR_NONE) { 113 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorLast did return PS_ERR_NONE for empty stack"); 114 return 20; 115 } 116 psFree(last); 117 118 // Attempt to get specific error message with empty stack verify psErr with code PS_ERR_NONE 119 get 120 = psErrorGet(2); 121 if(get 122 ->code != PS_ERR_NONE) { 123 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet did not return PS_ERR_NONE for empty stack"); 124 return 21; 125 } 126 psFree(get 127 ); 128 129 // Attempt to get error message with invalid index and an empty stack 130 get 131 = psErrorGet(-1); 132 if(get 133 ->code != PS_ERR_NONE) { 134 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet with invalid index/empty stack"); 135 return 22; 136 } 137 psFree(get 138 ); 139 140 // Generate three error messages 141 if (psErrorMsg("test3A", code, true, "Error code = %d", code) != code) { 142 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 143 return 23; 144 } 145 if (psErrorMsg("test3A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) { 146 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 147 return 24; 148 } 149 if (psErrorMsg("test3A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) { 150 psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify."); 151 return 25; 152 } 153 154 last = psErrorLast(); 155 get 156 = psErrorGet(0); 157 158 // Check that last and get with 0 index are equal 159 if(last != get 160 ) { 161 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet(0) not equal to psErrorLast"); 162 return 26; 163 } 164 psFree(last); 165 166 // Verify the last error message was returned 167 if ( last->code != (code+2) ) { 168 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorLast() did not retrieve last error"); 169 return 27; 170 } 171 psFree(get 172 ); 173 174 // Verify the middle error message can be retrieved 175 get 176 = psErrorGet(1); 177 if ( get 178 ->code != (code+1)) { 179 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet() did not retrieve proper error"); 180 return 28; 181 } 182 psFree(get 183 ); 184 185 // Verify the psErrorGet returns NULL if an invalid index is given 186 get 187 = psErrorGet(-1); 188 if ( get 189 ->code != PS_ERR_NONE ) { 190 psLogMsg("tst_psError03", PS_LOG_ERROR, "psErrorGet() did not return PS_ERR_NONE w/ invalid arg"); 191 return 29; 192 } 193 psFree(get 194 ); 195 196 return 0; 197 } 198 199 static int testError02(void) 200 { 201 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 202 203 // Generate error message and verify return value 204 if (psErrorMsg("test2A", code, true, "Error code = %d", code) != code ) { 205 psLogMsg("tst_psError02", PS_LOG_ERROR, "Failed return value verify."); 206 return 10; 207 } 208 myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2); 209 210 return 0; 211 } 212 213 static int testError01(void) 214 { 215 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE; 216 217 // Verify the return value of psErrorMsg is the psErrorCode passed 218 if ( psErrorMsg("test1A", code, true, "Error code = %d", code) != code) { 219 psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return value verify."); 220 return 1; 221 } 222 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A"); 223 224 // test1B empty string in for name argument 225 if ( psErrorMsg("", code+1, true, "Error code = %d", code+1) != code+1) { 226 psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with empty string."); 227 return 2; 228 } 229 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B"); 230 231 // test1C null pointer in for name argument 232 if ( psErrorMsg(NULL, code+2, true, "Error code = %d", code+2) != code+2) { 233 psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with null name arg."); 234 return 3; 235 } 236 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1C"); 237 238 // test1D undefined code 239 if ( psErrorMsg("test1D", -1, true, "Error code = %d", -1) != -1) { 240 psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with undefined code."); 241 return 4; 242 } 243 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D"); 244 245 // test1E set psErrorMsg argument to false 246 if( psErrorMsg("test1E", code, false, "Error code = %d", code) != code) { 247 psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with false new arg."); 248 return 5; 249 } 250 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E"); 251 252 // Call psErrorMsg with 253 return 0; 36 254 } 37 255 … … 46 264 47 265 // Test point #1 Multiple type values placed in the error string 48 printPositiveTestHeader(stderr,"psError","Multiple type values in error message");49 266 psError(__func__, 50 267 "ALL TYPES intval = %d longval = %ld floatval = %f charval = %c strval = %s", 51 268 intval,longval,floatval,charval,stringval); 52 printFooter(stderr, "psError","Multiple type values in error message",true);53 269 54 270 // Test point #2 String values in error message 55 printPositiveTestHeader(stderr, "psError","String values in error message");56 271 psError(PS_STRING(__LINE__),"NO VALUES"); 57 printFooter(stderr, "psError","String values in error message",true);58 272 59 273 // Test point #3 Empty strings in error message 60 printPositiveTestHeader(stderr, "psError","Empty strings in error message");61 274 psError("",""); 62 printFooter(stderr, "psError","Empty strings in error message",true); 63 64 return 0; 65 } 66 275 276 return 0; 277 } 278 -
trunk/psLib/test/sysUtils/verified/tst_psError.stderr
r1851 r1867 5 5 \**********************************************************************************/ 6 6 7 <DATE><TIME>|<HOST>|E|testError00 8 ALL TYPES intval = 1 longval = 2 floatval = 3.010000 charval = E strval = E R R O R 9 <DATE><TIME>|<HOST>|E|__LINE__ 10 NO VALUES 11 <DATE><TIME>|<HOST>|E| 12 13 ---> TESTPOINT PASSED (psError{psError()} | tst_psError.c) 14 7 15 /***************************** TESTPOINT ******************************************\ 8 16 * TestFile: tst_psError.c * 9 * TestPoint: psError{ Multiple type values in error message}*17 * TestPoint: psError{psErrorMsg(),psErrorStackPrint()} * 10 18 * TestType: Positive * 11 19 \**********************************************************************************/ 12 20 13 <DATE><TIME>|<HOST>|E|testError00 14 ALL TYPES intval = 1 longval = 2 floatval = 3.010000 charval = E strval = E R R O R 21 <DATE><TIME>|<HOST>|E|test1A 22 Error code = 262 23 ERROR STACK PRINT Test1A -> test1A: parameter is out-of-range 24 Error code = 262 25 <DATE><TIME>|<HOST>|E| 26 Error code = 263 27 ERROR STACK PRINT Test1B -> : parameter is of unsupported type 28 Error code = 263 29 <DATE><TIME>|<HOST>|E| 30 Error code = 264 31 ERROR STACK PRINT Test1C -> : parameter is null 32 Error code = 264 33 <DATE><TIME>|<HOST>|E|test1D 34 Error code = -1 35 ERROR STACK PRINT Test1D -> test1D: (null) 36 Error code = -1 37 <DATE><TIME>|<HOST>|E|test1E 38 Error code = 262 39 ERROR STACK PRINT Test1E -> test1D: (null) 40 Error code = -1 41 -> test1E: parameter is out-of-range 42 Error code = 262 15 43 16 ---> TESTPOINT PASSED (psError{ Multiple type values in error message} | tst_psError.c)44 ---> TESTPOINT PASSED (psError{psErrorMsg(),psErrorStackPrint()} | tst_psError.c) 17 45 18 46 /***************************** TESTPOINT ******************************************\ 19 47 * TestFile: tst_psError.c * 20 * TestPoint: psError{ String values in error message}*48 * TestPoint: psError{psErrorStackPrintV()} * 21 49 * TestType: Positive * 22 50 \**********************************************************************************/ 23 51 24 <DATE><TIME>|<HOST>|E|__LINE__ 25 NO VALUES 52 <DATE><TIME>|<HOST>|E|test2A 53 Error code = 262 54 ERROR STACK PRINT Test2A -> test2A: parameter is out-of-range 55 Error code = 262 26 56 27 ---> TESTPOINT PASSED (psError{ String values in error message} | tst_psError.c)57 ---> TESTPOINT PASSED (psError{psErrorStackPrintV()} | tst_psError.c) 28 58 29 59 /***************************** TESTPOINT ******************************************\ 30 60 * TestFile: tst_psError.c * 31 * TestPoint: psError{ Empty strings in error message}*61 * TestPoint: psError{psErrorGet(),psErrorLast()} * 32 62 * TestType: Positive * 33 63 \**********************************************************************************/ 34 64 35 <DATE><TIME>|<HOST>|E| 65 <DATE><TIME>|<HOST>|E|test3A 66 Error code = 262 67 <DATE><TIME>|<HOST>|E|test3A 68 Error code = 263 69 <DATE><TIME>|<HOST>|E|test3A 70 Error code = 264 36 71 37 ---> TESTPOINT PASSED (psError{ Empty strings in error message} | tst_psError.c)72 ---> TESTPOINT PASSED (psError{psErrorGet(),psErrorLast()} | tst_psError.c) 38 73 74 /***************************** TESTPOINT ******************************************\ 75 * TestFile: tst_psError.c * 76 * TestPoint: psError{psErrorClear()} * 77 * TestType: Positive * 78 \**********************************************************************************/ 39 79 40 ---> TESTPOINT PASSED (psError{psError()} | tst_psError.c) 80 <DATE><TIME>|<HOST>|E|test3A 81 Error code = 262 82 <DATE><TIME>|<HOST>|E|test3A 83 Error code = 263 84 <DATE><TIME>|<HOST>|E|test3A 85 Error code = 264 41 86 87 ---> TESTPOINT PASSED (psError{psErrorClear()} | tst_psError.c) 88
Note:
See TracChangeset
for help on using the changeset viewer.
