Changeset 11662
- Timestamp:
- Feb 5, 2007, 6:09:55 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sys/tap_psError.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys/tap_psError.c
r10810 r11662 13 13 * @author Eric Van Alst, MHPCC 14 14 * 15 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $16 * @date $Date: 200 6-12-18 19:18:46$15 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-02-06 04:09:55 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "pstap.h" 28 28 29 static psS32 testError00(void);30 static psS32 testError01(void);31 static psS32 testError02(void);32 static psS32 testError03(void);33 static psS32 testError04(void);34 static psS32 testError05(void);35 static psS32 testErrorRegister(void);36 37 29 // Function used in testError02 to verify the psErrorStackPrintV function 38 30 static void myErrorStackPrint(FILE *fd, … … 49 41 50 42 51 psS32 main( psS32 argc, char* argv[] ) 52 { 53 plan_tests(38); 54 55 testError00(); 56 testError01(); 57 testError02(); 58 testError03(); 59 testError04(); 60 testError05(); 61 testErrorRegister(); 62 } 63 64 static psS32 testError05(void) 65 { 66 diag("testError05"); 67 68 // Verify the return value of psErrorCodeString 69 // psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 70 // psLogMsg("tst_psError05", PS_LOG_INFO, psErrorCodeString(code)); 71 72 // Verify the return value of psErrorCodeString if code is negative 73 ok( psErrorCodeString(-1) == NULL, "error string with neg. code"); 74 75 return 0; 76 } 77 78 static psS32 testError04(void) 79 { 80 diag("testError04"); 43 static psS32 testError00(void) 44 { 45 diag("testError00"); 46 47 psS32 intval=1; 48 psS64 longval = 2; 49 float floatval = 3.01; 50 char charval = 'E'; 51 char *stringval = "E R R O R"; 52 53 // Test point #1 Multiple type values placed in the error string 54 psError(PS_ERR_UNKNOWN, true, 55 "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s", 56 intval,longval,floatval,charval,stringval); 57 58 // Test point #2 String values in error message 59 psError(PS_ERR_UNKNOWN, true, "NO VALUES"); 60 61 // Test point #3 Empty strings in error message 62 psError(PS_ERR_UNKNOWN, true, " "); 63 64 return 0; 65 } 66 67 68 static psS32 testError01(void) 69 { 70 diag("testError01"); 71 72 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE; 73 74 // Verify the return value of psErrorMsg is the psErrorCode passed 75 ok ( psError(code, true, "Error code = %d", code) == code, 76 "Failed return value verify."); 77 skip_start ( psError(code, true, "Error code = %d", code) != code, 78 4, "Failed return value verify."); 79 80 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A"); 81 82 // test1B empty string in for name argument 83 ok ( psError(code+1, true, "Error code = %d", code+1) == code+1, 84 "Failed return with empty string."); 85 skip_start ( psError(code+1, true, "Error code = %d", code+1) != code+1, 86 3, "Failed return with empty string."); 87 88 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B"); 89 90 // test1D undefined code 91 ok ( psError(-1, true, "Error code = %d", -1) == -1, 92 "Failed return with undefined code."); 93 skip_start ( psError(-1, true, "Error code = %d", -1) != -1, 94 2, "Failed return with undefined code."); 95 96 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D"); 97 98 // test1E set psErrorMsg argument to false 99 ok( psError(code, false, "Error code = %d", code) == code, 100 "Failed return with false new arg."); 101 skip_start( psError(code, false, "Error code = %d", code) != code, 102 1, "Failed return with false new arg."); 103 104 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E"); 105 106 // test1F psErrorMsg with a error code less then PS_ERR_BASE(256) 107 ok( psError(9, true, "Errno code = %d", 9) == 9, "Error Code" ); 108 109 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F"); 110 111 skip_end(); 112 skip_end(); 113 skip_end(); 114 skip_end(); 115 116 return 0; 117 } 118 119 120 static psS32 testError02(void) 121 { 122 diag("testError02"); 81 123 82 124 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 83 psErr *last = NULL; 84 psErr *lastAfterClear = NULL; 85 86 // With an attemp error stack call psErrorClear 87 psErrorClear(); 88 89 // Get the last error message and verify PS_ERR_NONE (empty stack) 90 lastAfterClear = psErrorLast(); 91 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected."); 92 skip_start(lastAfterClear->code != PS_ERR_NONE, 93 5, "psErrorLast return expected."); 94 95 psFree(lastAfterClear); 96 97 // Generate three error messages to have messages on error stack 98 ok (psError(code, true, "Error code = %d", code) == code, 125 126 // Generate error message and verify return value 127 ok (psError(code, true, "Error code = %d", code) == code, 99 128 "Failed return value verify."); 100 skip_start (psError(code, true, "Error code = %d", code) != code, 101 4, "Failed return value verify."); 102 103 ok (psError((code+1), false, "Error code = %d", (code+1)) == (code+1), 104 "Failed return value verify."); 105 skip_start (psError((code+1), false, "Error code = %d", (code+1))!=(code+1), 106 3, "Failed return value verify."); 107 108 ok (psError((code+2), false, "Error code = %d", (code+2)) == (code+2), 109 "Failed return value verify."); 110 skip_start (psError((code+2), false, "Error code = %d", (code+2))!=(code+2), 111 2, "Failed return value verify."); 112 113 // Get the last error message and verify it has the expected code 114 last = psErrorLast(); 115 ok(last->code == (code+2), "psErrorLast return expected."); 116 skip_start(last->code != (code+2), 1, "psErrorLast return expected."); 117 118 psFree(last); 119 120 // Clear the error stack 121 psErrorClear(); 122 123 // Get the last error message after clear and verify is has PS_ERR_NONE code 124 lastAfterClear = psErrorLast(); 125 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected."); 126 127 skip_end(); 128 skip_end(); 129 skip_end(); 130 skip_end(); 131 skip_end(); 132 133 psFree(lastAfterClear); 134 135 return 0; 136 } 129 130 myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2); 131 132 return 0; 133 } 134 137 135 138 136 static psS32 testError03(void) … … 146 144 // Attempt to get last error message with an empty stack verify psErr with code PS_ERR_NONE 147 145 last = psErrorLast(); 148 ok(last->code != PS_ERR_NONE,149 "psErrorLast did return PS_ERR_NONE for empty stack ");146 ok(last->code == PS_ERR_NONE, 147 "psErrorLast did return PS_ERR_NONE for empty stack (%d)", last->code); 150 148 skip_start(last->code == PS_ERR_NONE, 151 149 9, "psErrorLast did return PS_ERR_NONE for empty stack"); … … 153 151 psFree(last); 154 152 153 // HEY 155 154 // Attempt to get specific error message with empty stack verify psErr with code PS_ERR_NONE 156 155 getErr= psErrorGet(2); 157 ok(getErr->code != PS_ERR_NONE,158 "psErrorGet did not return PS_ERR_NONE for empty stack ");156 ok(getErr->code == PS_ERR_NONE, 157 "psErrorGet did not return PS_ERR_NONE for empty stack (%d)", getErr->code); 159 158 skip_start(getErr->code == PS_ERR_NONE, 160 159 8, "psErrorGet did not return PS_ERR_NONE for empty stack"); … … 233 232 } 234 233 235 static psS32 testError02(void) 236 { 237 diag("testError02"); 234 235 static psS32 testError04(void) 236 { 237 diag("testError04"); 238 238 239 239 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 240 241 // Generate error message and verify return value 242 ok (psError(code, true, "Error code = %d", code) == code, 240 psErr *last = NULL; 241 psErr *lastAfterClear = NULL; 242 243 // With an attemp error stack call psErrorClear 244 psErrorClear(); 245 246 // Get the last error message and verify PS_ERR_NONE (empty stack) 247 lastAfterClear = psErrorLast(); 248 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected."); 249 skip_start(lastAfterClear->code != PS_ERR_NONE, 250 5, "psErrorLast return expected."); 251 252 psFree(lastAfterClear); 253 254 // Generate three error messages to have messages on error stack 255 ok (psError(code, true, "Error code = %d", code) == code, 243 256 "Failed return value verify."); 244 245 myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2); 246 247 return 0; 248 } 249 250 static psS32 testError01(void) 251 { 252 diag("testError01"); 253 254 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE; 255 256 // Verify the return value of psErrorMsg is the psErrorCode passed 257 ok ( psError(code, true, "Error code = %d", code) == code, 258 "Failed return value verify."); 259 skip_start ( psError(code, true, "Error code = %d", code) != code, 260 4, "Failed return value verify."); 261 262 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A"); 263 264 // test1B empty string in for name argument 265 ok ( psError(code+1, true, "Error code = %d", code+1) == code+1, 266 "Failed return with empty string."); 267 skip_start ( psError(code+1, true, "Error code = %d", code+1) != code+1, 268 3, "Failed return with empty string."); 269 270 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B"); 271 272 // test1D undefined code 273 ok ( psError(-1, true, "Error code = %d", -1) == -1, 274 "Failed return with undefined code."); 275 skip_start ( psError(-1, true, "Error code = %d", -1) != -1, 276 2, "Failed return with undefined code."); 277 278 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D"); 279 280 // test1E set psErrorMsg argument to false 281 ok( psError(code, false, "Error code = %d", code) == code, 282 "Failed return with false new arg."); 283 skip_start( psError(code, false, "Error code = %d", code) != code, 284 1, "Failed return with false new arg."); 285 286 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E"); 287 288 // test1F psErrorMsg with a error code less then PS_ERR_BASE(256) 289 ok( psError(9, true, "Errno code = %d", 9) == 9, "Error Code" ); 290 291 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F"); 292 293 skip_end(); 294 skip_end(); 295 skip_end(); 296 skip_end(); 297 298 return 0; 299 } 300 301 static psS32 testError00(void) 302 { 303 diag("testError00"); 304 305 psS32 intval=1; 306 psS64 longval = 2; 307 float floatval = 3.01; 308 char charval = 'E'; 309 char *stringval = "E R R O R"; 310 311 // Test point #1 Multiple type values placed in the error string 312 psError(PS_ERR_UNKNOWN, true, 313 "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s", 314 intval,longval,floatval,charval,stringval); 315 316 // Test point #2 String values in error message 317 psError(PS_ERR_UNKNOWN, true, "NO VALUES"); 318 319 // Test point #3 Empty strings in error message 320 psError(PS_ERR_UNKNOWN, true, " "); 321 322 return 0; 323 } 257 skip_start (psError(code, true, "Error code = %d", code) != code, 258 4, "Failed return value verify."); 259 260 ok (psError((code+1), false, "Error code = %d", (code+1)) == (code+1), 261 "Failed return value verify."); 262 skip_start (psError((code+1), false, "Error code = %d", (code+1))!=(code+1), 263 3, "Failed return value verify."); 264 265 ok (psError((code+2), false, "Error code = %d", (code+2)) == (code+2), 266 "Failed return value verify."); 267 skip_start (psError((code+2), false, "Error code = %d", (code+2))!=(code+2), 268 2, "Failed return value verify."); 269 270 // Get the last error message and verify it has the expected code 271 last = psErrorLast(); 272 ok(last->code == (code+2), "psErrorLast return expected."); 273 skip_start(last->code != (code+2), 1, "psErrorLast return expected."); 274 275 psFree(last); 276 277 // Clear the error stack 278 psErrorClear(); 279 280 // Get the last error message after clear and verify is has PS_ERR_NONE code 281 lastAfterClear = psErrorLast(); 282 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected."); 283 284 skip_end(); 285 skip_end(); 286 skip_end(); 287 skip_end(); 288 skip_end(); 289 290 psFree(lastAfterClear); 291 292 return 0; 293 } 294 295 296 static psS32 testError05(void) 297 { 298 diag("testError05"); 299 300 // Verify the return value of psErrorCodeString 301 // psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 302 // psLogMsg("tst_psError05", PS_LOG_INFO, psErrorCodeString(code)); 303 304 // Verify the return value of psErrorCodeString if code is negative 305 ok( psErrorCodeString(-1) == NULL, "error string with neg. code"); 306 307 return 0; 308 } 309 324 310 325 311 static psS32 testErrorRegister(void) … … 397 383 return 0; 398 384 } 385 386 387 psS32 main( psS32 argc, char* argv[] ) 388 { 389 psLogSetFormat("HLNM"); 390 plan_tests(38); 391 392 // XXX: testError03() fails if we put it in sequence with the others. 393 testError03(); 394 testError00(); 395 testError01(); 396 testError02(); 397 testError04(); 398 testError05(); 399 testErrorRegister(); 400 } 401 402
Note:
See TracChangeset
for help on using the changeset viewer.
