Changeset 41171 for trunk/psLib/test/sys
- Timestamp:
- Nov 27, 2019, 11:57:38 AM (6 years ago)
- Location:
- trunk/psLib/test/sys
- Files:
-
- 6 deleted
- 5 edited
-
tap_psError.c (modified) (3 diffs)
-
tap_psLine.c (modified) (4 diffs)
-
tap_psMemory.c (modified) (34 diffs)
-
tap_psString.c (modified) (5 diffs)
-
tap_psTrace.c (modified) (10 diffs)
-
tst_psConfigure.c (deleted)
-
tst_psError.c (deleted)
-
tst_psLine.c (deleted)
-
tst_psMemory.c (deleted)
-
tst_psString.c (deleted)
-
tst_psTrace.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys/tap_psError.c
r17515 r41171 324 324 325 325 for (psS32 i = 0; i < numErr; i++) { 326 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i); 327 ok(desc != NULL, 328 "psErrorCode didn't find registered error code."); 329 330 ok(strcmp(desc,errDesc[i].description) == 0, 331 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", desc,errDesc[i].description); 332 } 333 334 /* 335 2. invoke psErrorCodeString with a static/builtin psLib error code. Verify: 326 const char *desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i); 327 ok(desc, "psErrorCode found registered error code."); 328 ok(!strcmp(desc,errDesc[i].description), "psErrorCode returned the proper description. Got '%s', expected '%s'.", desc, errDesc[i].description); 329 } 330 331 /* 2. invoke psErrorCodeString with a static/builtin psLib error code. Verify: 336 332 a. the result is correct. 337 333 */ 338 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES); 339 ok(desc != NULL, "psErrorCode didn't find static error code."); 340 ok(strcmp(desc,"error classes end marker") == 0, 341 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 342 desc,"error classes end marker"); 334 const char *desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES); 335 ok(desc, "psErrorCode found static error code."); 336 ok(!strcmp(desc, "error classes end marker"), "psErrorCode returned the proper description. Got '%s', expected '%s'.", desc, "error classes end marker"); 343 337 344 338 desc = psErrorCodeString(PS_ERR_NONE); 345 ok(desc != NULL, 346 "psErrorCode didn't find static error code."); 347 ok(strcmp(desc,"not an error") == 0, 348 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 349 desc,"not an error"); 339 ok(desc, "psErrorCode found static error code."); 340 ok(!strcmp(desc,"not an error"), "psErrorCode returned the proper description. Got '%s', expected '%s'.", desc, "not an error"); 350 341 351 /* 352 3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned. 353 */ 342 /* 3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned. */ 354 343 desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+numErr+1); 355 ok(desc == NULL, 356 "psErrorCode didn't return a NULL with a bogus input code."); 357 358 /* 359 4. invoke psErrorRegister with a NULL psErrorDescription. Verify that: 344 ok(!desc, "psErrorCode returns a NULL with a bogus input code."); 345 346 /* 4. invoke psErrorRegister with a NULL psErrorDescription. Verify that: 360 347 a. the execution does not cease. 361 348 b. an appropriate error is generated. … … 366 353 psErr* err = psErrorLast(); 367 354 ok(err->code == PS_ERR_BAD_PARAMETER_NULL, 368 "psErrorCode didn't generateproper error code for NULL input.");355 "psErrorCode generated proper error code for NULL input."); 369 356 370 357 psFree(err); … … 377 364 err = psErrorLast(); 378 365 ok(err->code == PS_ERR_NONE, 379 "psErrorCode generatedan error for nErrors = 0.");366 "psErrorCode did not generate an error for nErrors = 0."); 380 367 psFree(err); 381 368 } -
trunk/psLib/test/sys/tap_psLine.c
r12781 r41171 23 23 psLogSetLevel(PS_LOG_INFO); 24 24 25 // testLineAlloc()25 // testLineAlloc() 26 26 { 27 27 psMemId id = psMemGetId(); 28 28 psLine *lineline = NULL; 29 29 lineline = psLineAlloc(20); 30 ok(lineline->NLINE ==20, "psLine set NLINE parameter during Allocation");31 ok(lineline->Nline == 0, "psLine set Nline parameter during Allocation");30 ok(lineline->NLINE == 20, "psLine set NLINE parameter during Allocation"); 31 ok(lineline->Nline == 0, "psLine set Nline parameter during Allocation"); 32 32 strncpy(lineline->line, "Hello World", 20); 33 ok(!strncmp(lineline->line, "Hello World", 20), 34 "psLine was stored a simple string!"); 33 ok(!strncmp(lineline->line, "Hello World", 20), "psLine was stored a simple string!"); 35 34 psFree(lineline); 36 35 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 41 40 psMemId id = psMemGetId(); 42 41 psLine *line = NULL; 43 // Return false for NULL input42 // Return false for NULL input 44 43 int okay = !psLineInit(line); 45 44 ok(okay, "psLineInit. Expected false for NULL psLine input"); 46 // Allocate a line and return true on Init45 // Allocate a line and return true on Init 47 46 line = psLineAlloc(1); 48 47 okay = psLineInit(line); … … 65 64 int okay = psLineAdd(line, "Hello %s", "World"); 66 65 ok( okay, "psLineAdd. Expected true for valid psLine input"); 67 ok(line->NLINE == 20 && line->Nline == 11, 68 "psLineAdd failed to return the correct line parameters"); 69 ok(!strncmp(line->line, "Hello World", 20), 70 "psLineAdd failed to store the correct line string."); 66 ok(line->NLINE == 20 && line->Nline == 11, "psLineAdd failed to return the correct line parameters"); 67 ok(!strncmp(line->line, "Hello World", 20), "psLineAdd failed to store the correct line string."); 71 68 psFree(line); 72 69 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 79 76 psLine *line = NULL; 80 77 //Return false for Null input line 81 ok(!psMemCheckLine(line), 82 "psMemCheckLine return false for NULL line input"); 78 ok(!psMemCheckLine(line), "psMemCheckLine return false for NULL line input"); 83 79 line = psLineAlloc(1); 84 ok(psMemCheckLine(line), 85 "psMemCheckLine return true for valid line input"); 80 ok(psMemCheckLine(line), "psMemCheckLine return true for valid line input"); 86 81 psFree(line); 87 82 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); -
trunk/psLib/test/sys/tap_psMemory.c
r24023 r41171 41 41 psLogSetFormat("HLNM"); 42 42 psLogSetLevel(PS_LOG_INFO); 43 plan_tests( 46);43 plan_tests(54); 44 44 45 45 // TPFreeReferencedMemory() … … 79 79 // the psMemExhaustedCallback. 80 80 // XXXX: Skipping TPOutOfMemory() because of test abort failure 81 if (0) { 81 skip_start (1, 2, "Skipping TPOutOfMemory() because of test abort failure"); 82 { 82 83 psMemId id = psMemGetId(); 83 84 psS32 *mem[ 100 ]; … … 88 89 exhaustedCallbackCalled = 0; 89 90 cb = psMemExhaustedCallbackSet( TPOutOfMemoryExhaustedCallback ); 90 #ifdef COMMENTED_OUT91 // #ifdef COMMENTED_OUT 91 92 // Don't include since intentionally aborts 92 93 for ( psS32 lcv = 0; lcv < 100; lcv++ ) { … … 99 100 psFree( mem[ lcv ] ); 100 101 } 101 #endif102 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 103 } 104 102 // #endif 103 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 104 } 105 skip_end(); 105 106 106 107 … … 108 109 // psRealloc shall call the psMemExhaustedCallback. 109 110 // XXXX: Skipping TPReallocOutOfMemory() because of test abort failure 110 if (0) { 111 skip_start (1, 2, "Skipping TPReallocOutOfMemory() because of test abort failure"); 112 { 111 113 psMemId id = psMemGetId(); 112 114 psS32 *mem[ 100 ]; … … 131 133 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 132 134 } 133 135 skip_end(); 134 136 135 137 // psAlloc shall allocate memory blocks writeable by caller. … … 236 238 // TPcheckLeaks() 237 239 // XXXX: Skipping TPcheckLeaks() because of test abort failure 238 if (0) { 240 skip_start (1, 6, "Skipping TPcheckLeaks() because of test abort failure"); 241 { 239 242 const psS32 numBuffers = 5; 240 243 psS32* buffers[ 5 ]; … … 288 291 psFree(buffers[3]); 289 292 } 293 skip_end(); 290 294 291 295 … … 304 308 psArray *array = psArrayAlloc(100); 305 309 int okay = psMemCheckType(PS_DATA_ARRAY,array); 306 if (!okay) { 307 psFree(array); 308 } 309 ok(okay, "psMemCheckArray in memCheckType"); 310 311 ok(!psMemCheckType(PS_DATA_ARRAY, neg), "psMemCheckType with metadata input"); 310 if (!okay) psFree(array); 311 ok(okay, "psMemCheckType PS_DATA_ARRAY in memCheckType"); 312 313 ok(!psMemCheckType(PS_DATA_ARRAY, neg), "psMemCheckType PS_DATA_ARRAY with metadata input"); 312 314 psFree(array); 313 315 314 psBitSet *bits; 315 bits = psBitSetAlloc(100); 316 okay = psMemCheckType(PS_DATA_BITSET, bits); 317 if (!okay ) 318 psFree(bits); 319 ok(okay, "psMemCheckBitSet in memCheckType"); 320 ok(!psMemCheckType(PS_DATA_BITSET, negative), "psMemCheckType on psArray"); 321 psFree(bits); 316 // XXX EAM 2019.11.08 : this data type no longer exists 317 // psBitSet *bits; 318 // bits = psBitSetAlloc(100); 319 // okay = psMemCheckType(PS_DATA_BITSET, bits); 320 // if (!okay ) psFree(bits); 321 // 322 // ok(okay, "psMemCheckBitSet in memCheckType"); 323 // ok(!psMemCheckType(PS_DATA_BITSET, negative), "psMemCheckType on psArray"); 324 // psFree(bits); 322 325 323 326 psCube *cube; 324 327 cube = psCubeAlloc(); 325 328 okay = psMemCheckType(PS_DATA_CUBE, cube); 326 if (!okay ) 327 psFree(cube); 329 if (!okay ) psFree(cube); 328 330 ok(okay, "psMemCheckCube in memCheckType"); 329 331 psFree(cube); … … 335 337 psFree(img); 336 338 okay = psMemCheckType(PS_DATA_FITS, fits); 337 if (!okay ) 338 psFree(fits); 339 if (!okay ) psFree(fits); 339 340 ok(okay, "psMemCheckFits in memCheckType"); 340 341 psFitsClose(fits); … … 343 344 hash = psHashAlloc(100); 344 345 okay = psMemCheckType(PS_DATA_HASH, hash); 345 if (!okay ) 346 psFree(hash); 346 if (!okay ) psFree(hash); 347 347 ok(okay, "psMemCheckHash in memCheckType"); 348 348 psFree(hash); … … 351 351 histogram = psHistogramAlloc(1.1, 2.2, 2); 352 352 okay = psMemCheckType(PS_DATA_HISTOGRAM, histogram); 353 if (!okay ) 354 psFree(histogram); 353 if (!okay ) psFree(histogram); 355 354 ok(okay, "psMemCheckHistogram in memCheckType"); 356 355 psFree(histogram); … … 359 358 image = psImageAlloc(5, 5, PS_TYPE_F32); 360 359 okay = psMemCheckType(PS_DATA_IMAGE, image); 361 if (!okay ) 362 psFree(image); 360 if (!okay ) psFree(image); 363 361 ok(okay, "psMemCheckImage in memCheckType"); 364 362 psFree(image); … … 367 365 kernel = psKernelAlloc(0, 1, 0, 1); 368 366 okay = psMemCheckType(PS_DATA_KERNEL, kernel); 369 if (!okay ) 370 psFree(kernel); 367 if (!okay ) psFree(kernel); 371 368 ok(okay, "psMemCheckKernel in memCheckType"); 372 369 psFree(kernel); … … 375 372 list = psListAlloc(NULL); 376 373 okay = psMemCheckType(PS_DATA_LIST, list); 377 if (!okay ) 378 psFree(list); 374 if (!okay ) psFree(list); 379 375 ok(okay, "psMemCheckList in memCheckType"); 380 376 psFree(list); … … 385 381 lookup = psLookupTableAlloc(file, format, 10); 386 382 okay = psMemCheckType(PS_DATA_LOOKUPTABLE, lookup); 387 if (!okay ) 388 psFree(lookup); 383 if (!okay ) psFree(lookup); 389 384 ok(okay, "psMemCheckLookupTable in memCheckType"); 390 385 psFree(lookup); … … 393 388 metadata = psMetadataAlloc(); 394 389 okay = psMemCheckType(PS_DATA_METADATA, metadata); 395 if (!okay ) 396 psFree(metadata); 390 if (!okay ) psFree(metadata); 397 391 ok(okay, "psMemCheckMetadata in memCheckType"); 398 392 psFree(metadata); … … 401 395 metaItem = psMetadataItemAlloc("name", PS_DATA_S32, "COMMENT", 1); 402 396 okay = psMemCheckType(PS_DATA_METADATAITEM, metaItem); 403 if (!okay ) 404 psFree(metaItem); 397 if (!okay ) psFree(metaItem); 405 398 ok(okay, "psMemCheckMetadataItem in memCheckType"); 406 399 psFree(metaItem); 407 400 408 401 psMinimization *min; 409 min = psMinimizationAlloc(3, 0.1 );402 min = psMinimizationAlloc(3, 0.1, 1.0); 410 403 okay = psMemCheckType(PS_DATA_MINIMIZATION, min); 411 if (!okay ) 412 psFree(min); 404 if (!okay ) psFree(min); 413 405 ok(okay, "psMemCheckMinimization in memCheckType"); 414 406 psFree(min); … … 417 409 pixels = psPixelsAlloc(100); 418 410 okay = psMemCheckType(PS_DATA_PIXELS, pixels); 419 if (!okay ) 420 psFree(pixels); 411 if (!okay ) psFree(pixels); 421 412 ok(okay, "psMemCheckPixels in memCheckType"); 422 413 psFree(pixels); … … 425 416 plane = psPlaneAlloc(); 426 417 okay = psMemCheckType(PS_DATA_PLANE, plane); 427 if (!okay ) 428 psFree(plane); 418 if (!okay ) psFree(plane); 429 419 ok(okay, "psMemCheckPlane in memCheckType."); 430 420 psFree(plane); … … 433 423 planeDistort = psPlaneDistortAlloc(1, 1, 1, 1); 434 424 okay = psMemCheckType(PS_DATA_PLANEDISTORT, planeDistort); 435 if (!okay ) 436 psFree(planeDistort); 425 if (!okay ) psFree(planeDistort); 437 426 ok(okay, "psMemCheckPlaneDistort in memCheckType."); 438 427 psFree(planeDistort); … … 441 430 planeTransform = psPlaneTransformAlloc(1, 1); 442 431 okay = psMemCheckType(PS_DATA_PLANETRANSFORM, planeTransform); 443 if (!okay ) 444 psFree(planeTransform); 432 if (!okay ) psFree(planeTransform); 445 433 ok(okay, "psMemCheckPlaneTransform in memCheckType"); 446 434 psFree(planeTransform); … … 449 437 poly1 = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2); 450 438 okay = psMemCheckType(PS_DATA_POLYNOMIAL1D, poly1); 451 if (!okay ) 452 psFree(poly1); 439 if (!okay ) psFree(poly1); 453 440 ok(okay, "psMemCheckPolynomial1D in memCheckType"); 454 441 psFree(poly1); … … 457 444 poly2 = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 2, 1); 458 445 okay = psMemCheckType(PS_DATA_POLYNOMIAL2D, poly2); 459 if (!okay ) 460 psFree(poly2); 446 if (!okay ) psFree(poly2); 461 447 ok(okay, "psMemCheckPolynomial2D in memCheckType"); 462 448 psFree(poly2); … … 465 451 poly3 = psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 2, 1, 1); 466 452 okay = psMemCheckType(PS_DATA_POLYNOMIAL3D, poly3); 467 if (!okay ) 468 psFree(poly3); 453 if (!okay ) psFree(poly3); 469 454 ok(okay, "psMemCheckPolynomial3D in memCheckType"); 470 455 psFree(poly3); … … 473 458 poly4 = psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 2, 1, 2, 1); 474 459 okay = psMemCheckType(PS_DATA_POLYNOMIAL4D, poly4); 475 if (!okay ) 476 psFree(poly4); 460 if (!okay ) psFree(poly4); 477 461 ok(okay, "psMemCheckPolynomial4D in memCheckType"); 478 462 psFree(poly4); … … 481 465 proj = psProjectionAlloc(1, 1, 2.1, 2.1, PS_PROJ_TAN); 482 466 okay = psMemCheckType(PS_DATA_PROJECTION, proj); 483 if (!okay ) 484 psFree(proj); 467 if (!okay ) psFree(proj); 485 468 ok(okay, "psMemCheckProjection in memCheckType."); 486 469 psFree(proj); … … 490 473 scalar = psScalarAlloc(f64, PS_TYPE_F64); 491 474 okay = psMemCheckType(PS_DATA_SCALAR, scalar); 492 if (!okay ) 493 psFree(scalar); 475 if (!okay ) psFree(scalar); 494 476 ok(okay, "psMemCheckScalar in memCheckType"); 495 477 psFree(scalar); … … 498 480 sphere = psSphereAlloc(); 499 481 okay = psMemCheckType(PS_DATA_SPHERE, sphere); 500 if (!okay ) 501 psFree(sphere); 482 if (!okay ) psFree(sphere); 502 483 ok(okay, "psMemCheckSphere in memCheckType"); 503 484 psFree(sphere); … … 506 487 sphereRot = psSphereRotAlloc(0, 0, 20); 507 488 okay = psMemCheckType(PS_DATA_SPHEREROT, sphereRot); 508 if (!okay ) 509 psFree(sphereRot); 489 if (!okay ) psFree(sphereRot); 510 490 ok(okay, "psMemCheckSphereRot in memCheckType"); 511 491 psFree(sphereRot); … … 516 496 spline = psSpline1DAlloc(); 517 497 okay = psMemCheckType(PS_DATA_SPLINE1D, spline); 518 if (!okay ) 519 psFree(spline); 498 if (!okay ) psFree(spline); 520 499 ok(okay, "psMemCheckSpline1D in memCheckType"); 521 500 psFree(spline); … … 524 503 stats = psStatsAlloc(PS_STAT_MAX); 525 504 okay = psMemCheckType(PS_DATA_STATS, stats); 526 if (!okay ) 527 psFree(stats); 505 if (!okay ) psFree(stats); 528 506 ok(okay, "psMemCheckStats in memCheckType"); 529 507 psFree(stats); … … 532 510 time = psTimeAlloc(PS_TIME_UT1); 533 511 okay = psMemCheckType(PS_DATA_TIME, time); 534 if (!okay ) 535 psFree(time); 512 if (!okay ) psFree(time); 536 513 ok(okay, "psMemCheckTime in memCheckType"); 537 514 psFree(time); … … 548 525 } 549 526 550 551 527 #if 0 552 528 void TPmemCorruption( void ) -
trunk/psLib/test/sys/tap_psString.c
r24023 r41171 111 111 { 112 112 psMemId id = psMemGetId(); 113 psS32 result = 0;114 psS32 result1 = 0;115 char *strResult;116 113 char *stringvalnocopy = "F A I L"; 117 114 118 115 // Test point #4 Verify empty string copy with length - psStringNCopy 119 strResult = psStringNCopy(stringvalnocopy, 0); 120 // Perform string compare and get sting length 121 result = strcmp(strResult, stringvalnocopy); 122 result1 = strlen(strResult); 123 ok(result != 0, 124 "test point #4 strcmp result = %d didn't expected %d",result,0); 116 char *strResult = psStringNCopy(stringvalnocopy, 0); 117 118 // Perform string compare and get string length 119 int result = strcmp(strResult, stringvalnocopy); 120 ok(result != 0, "test point #4 strcmp result = %d, expected %d", result, 4); 121 122 int resultLen = strlen(strResult); 123 ok(resultLen == 0, "test point #4 strcmp result = %d, expected %d", resultLen, 0); 124 125 125 psFree(strResult); 126 126 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 149 149 } 150 150 151 // XXX This test needs to be modified to check for maximum size 152 // This will require a mod to psStringNCopy source to check for maximum size 153 // 154 //psS32 testStringCopy05() 155 //{ 156 // char *strResult; 157 // char stringval[20] = "E R R O R"; 158 // psS32 negativeSize = -5; 159 // 160 // // Test point #6 Copy string with negative size - psStringNCopy 161 // strResult = psStringNCopy(stringval, negativeSize); 162 // if ( strResult != NULL ) { 163 // fprintf(stderr,"Failed test point #6 return value = %p expected NULL\n", 164 // strResult); 165 // return 1; 166 // } 167 // // Memory should not have been allocated 168 // 169 // return 0; 170 //} 171 151 // XXX This test needs to be modified to check for maximum size 152 // This will require a mod to psStringNCopy source to check for maximum size 153 154 // psS32 testStringCopy05() 155 skip_start (1, 6, "Skipping psSTringNCopy() because of failure to test max value"); 156 { 157 char *strResult; 158 char stringval[20] = "E R R O R"; 159 psS32 negativeSize = -5; 160 161 // Test point #6 Copy string with negative size - psStringNCopy 162 strResult = psStringNCopy(stringval, negativeSize); 163 if ( strResult != NULL ) { 164 fprintf(stderr,"Failed test point #6 return value = %p expected NULL\n", 165 strResult); 166 return 1; 167 } 168 // Memory should not have been allocated 169 } 170 skip_end(); 172 171 173 172 // testStringCopy06() … … 200 199 } 201 200 202 #if 0203 201 // testStrAppend01() 204 202 { 205 203 psMemId id = psMemGetId(); 206 char *str =NULL;204 char *str = NULL; 207 205 // test nonsensical invocations ... 208 206 ssize_t sz = psStringAppend(NULL, NULL); 209 ok( sz == 0, "Failed test point");207 ok(!sz, "append NULL string to NULL string"); 210 208 sz = psStringAppend(&str, NULL); 211 ok(sz == 0, "Failed test point"); 212 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 213 } 214 #endif 209 ok(!sz, "append NULL string to NULL string"); 210 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 211 } 215 212 216 213 // testStrAppend02() … … 251 248 } 252 249 253 #if 0254 250 // testStrPrepend01() 255 251 { … … 263 259 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 264 260 } 265 #endif266 261 267 262 // testStrPrepend02() -
trunk/psLib/test/sys/tap_psTrace.c
r17515 r41171 2 2 This code will test whether trace levels can be set successfully. 3 3 4 XXX: For the last two testpoints, must verify that the results are 5 correct, and put that verification in the test as well. 6 *****************************************************************************/ 4 XXX : various tests result in text sent to stdout -- these should go to a file 5 or buffer and be validated against a truth set. 6 7 XXX : some of the error messages have the wrong sense (they report a negative result even if the test is successful) 8 *****************************************************************************/ 7 9 #include <stdio.h> 8 10 #include <fcntl.h> … … 20 22 21 23 # define DEBUG 1 22 # if ( DEBUG)24 # if (!DEBUG) 23 25 FILE *output = fopen ("/dev/null", "w"); 24 26 int outFD = fileno (output); … … 30 32 { 31 33 psMemId id = psMemGetId(); 32 psS32 lev = 0; 33 (void)psTraceSetDestination(outFD); 34 for (int i=0;i<10;i++) { 35 (void)psTraceSetLevel(".", i); 36 lev = psTraceGetLevel("."); 37 ok(lev == i, "trace level was %d, actual was %d", i, lev); 38 } 39 40 (void)psTraceSetLevel(".", 3); 41 for (int i=5;i<10;i++) { 42 (void)psTraceSetLevel(".NODE00", i); 43 lev = psTraceGetLevel(".NODE00"); 44 ok (lev == i,"(.NODE00) expected trace level was %d, actual was %d", 45 i, lev); 34 psTraceSetDestination(outFD); 35 for (int i = 0; i < 10; i++) { 36 psTraceSetLevel(".", i); 37 int lev = psTraceGetLevel("."); 38 ok (lev == i, "trace level was %d, actual was %d", i, lev); 39 } 40 41 psTraceSetLevel(".", 3); 42 for (int i = 5; i < 10;i++) { 43 psTraceSetLevel(".NODE00", i); 44 int lev1 = psTraceGetLevel(".NODE00"); 45 ok (lev1 == i,"(.NODE00) expected trace level was %d, actual was %d", i, lev1); 46 46 47 lev = psTraceGetLevel("."); 48 ok (lev == 3, 49 "expected trace level was %d, actual was %d", i, 3); 47 int lev2 = psTraceGetLevel("."); 48 ok (lev2 == 3, "expected trace level was %d, actual was %d", 3, lev2); 50 49 } 51 50 52 (void)psTraceSetLevel(".NODE00.NODE01", 4); 53 for (int i=0;i<10;i++) { 54 (void)psTraceSetLevel(".NODE00.NODE01", i); 55 lev = psTraceGetLevel(".NODE00.NODE01"); 56 ok (lev == i, 57 "(.NODE00.NODE01) expected trace level was %d, actual was %d", 58 i, lev); 59 } 60 51 psTraceSetLevel(".NODE00.NODE01", 4); 52 for (int i = 0; i < 10; i++) { 53 psTraceSetLevel(".NODE00.NODE01", i); 54 int lev = psTraceGetLevel(".NODE00.NODE01"); 55 ok (lev == i, "(.NODE00.NODE01) expected trace level was %d, actual was %d", i, lev); 56 } 61 57 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 62 58 } … … 64 60 65 61 // testTrace01() 66 {67 psMemId id = psMemGetId();68 (void)psTraceSetDestination(outFD);69 (void)psTraceSetLevel(".A.B.C.D.E", 5);70 psTrace (".A.C.D.C",1,"You should not see this");71 psTrace(".A. B.C.D.E",2,"You shouldsee this");72 psTrace(".A.B.C.D.E .F",3,"You should see this too");73 psTrace PrintLevels();74 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");75 }76 62 // XXX need to check the output on these as part of the test 63 { 64 psMemId id = psMemGetId(); 65 psTraceSetDestination(outFD); 66 psTraceSetLevel(".A.B.C.D.E", 5); 67 psTrace(".A.C.D.C", 1, "You should not see this"); 68 psTrace(".A.B.C.D.E", 2, "You should see this"); 69 psTrace(".A.B.C.D.E.F", 3, "You should see this too"); 70 psTracePrintLevels(); 71 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 72 } 77 73 78 74 // testTrace02() … … 80 76 psMemId id = psMemGetId(); 81 77 psTraceReset(); 82 (void)psTraceSetDestination(outFD); 83 (void)psTraceSetLevel(".A.B", 2); 84 (void)psTraceSetLevel(".A.B.C.D.E", 5); 85 psTracePrintLevels(); 86 (void)psTraceSetLevel(".A.B", 10); 87 psTracePrintLevels(); 88 89 ok (10 == psTraceGetLevel(".A.B.C"), 90 ".A.B.C did not dynamically inherit a trace level (%d)", 91 psTraceGetLevel(".A.B.C")); 92 93 ok (10 == psTraceGetLevel(".A.B.C.D"), 94 ".A.B.C.D did not dynamically inherit a trace level (%d)", 95 psTraceGetLevel(".A.B.C.D")); 96 97 ok (5 == psTraceGetLevel(".A.B.C.D.E"), 98 ".A.B.C.D.E did dynamically inherit a trace level (%d)", 99 psTraceGetLevel(".A.B.C.D.E")); 100 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 101 } 102 78 psTraceSetDestination(outFD); 79 psTraceSetLevel(".A.B", 2); 80 psTraceSetLevel(".A.B.C.D.E", 5); 81 psTracePrintLevels(); 82 psTraceSetLevel(".A.B", 10); 83 psTracePrintLevels(); 84 85 ok (10 == psTraceGetLevel(".A.B.C"), ".A.B.C did not dynamically inherit a trace level (%d)", psTraceGetLevel(".A.B.C")); 86 ok (10 == psTraceGetLevel(".A.B.C.D"), ".A.B.C.D did not dynamically inherit a trace level (%d)", psTraceGetLevel(".A.B.C.D")); 87 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")); 88 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 89 } 103 90 104 91 // testTrace03() 105 92 { 106 93 psMemId id = psMemGetId(); 107 (void)psTraceSetDestination(outFD);108 109 for (int i =0;i<10;i++) {110 (void)psTraceSetLevel(".", i);94 psTraceSetDestination(outFD); 95 96 for (int i = 0; i < 10; i++) { 97 psTraceSetLevel(".", i); 111 98 psTraceReset(); 112 99 int lev = psTraceGetLevel("."); 113 ok (lev == PS_UNKNOWN_TRACE_LEVEL, 114 "expected trace level was %d, actual was %d", 115 PS_UNKNOWN_TRACE_LEVEL, lev); 116 } 117 118 (void)psTraceSetLevel(".", 5); 119 (void)psTraceSetLevel(".a", 4); 120 (void)psTraceSetLevel(".a.b", 3); 121 (void)psTraceSetLevel(".a.b.c", 2); 122 ok (!((5 != psTraceGetLevel(".")) || 123 (4 != psTraceGetLevel(".a")) || 124 (3 != psTraceGetLevel(".a.b")) || 125 (2 != psTraceGetLevel(".a.b.c"))), 126 "trace successFlag = false;levels were not settable?"); 127 128 psTraceReset(); 129 ok (!((PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".")) || 130 (PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".a")) || 131 (PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".a.b")) || 132 (PS_UNKNOWN_TRACE_LEVEL != psTraceGetLevel(".a.b.c"))), 133 "trace levels were not reset properly"); 134 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 135 } 136 100 ok (lev == PS_UNKNOWN_TRACE_LEVEL, "expected trace level was %d, actual was %d", PS_UNKNOWN_TRACE_LEVEL, lev); 101 } 102 103 psTraceSetLevel(".", 5); 104 psTraceSetLevel(".a", 4); 105 psTraceSetLevel(".a.b", 3); 106 psTraceSetLevel(".a.b.c", 2); 107 ok (5 == psTraceGetLevel("."), "level 0"); 108 ok (4 == psTraceGetLevel(".a"), "level 1"); 109 ok (3 == psTraceGetLevel(".a.b"), "level 2"); 110 ok (2 == psTraceGetLevel(".a.b.c"), "level 3"); 111 112 psTraceReset(); 113 ok (PS_UNKNOWN_TRACE_LEVEL == psTraceGetLevel("."), "trace levels were not reset properly"); 114 ok (PS_UNKNOWN_TRACE_LEVEL == psTraceGetLevel(".a"), "trace levels were not reset properly"); 115 ok (PS_UNKNOWN_TRACE_LEVEL == psTraceGetLevel(".a.b"), "trace levels were not reset properly"); 116 ok (PS_UNKNOWN_TRACE_LEVEL == psTraceGetLevel(".a.b.c"), "trace levels were not reset properly"); 117 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 118 } 137 119 138 120 // testTrace04() … … 140 122 psMemId id = psMemGetId(); 141 123 int FD = creat("tst_psTrace02_OUT", 0666); 142 for (int nb = 0 ; nb<4;nb++) { 143 if (nb == 0) 144 (void)psTraceSetDestination(((outFD == 2) ? 1 : outFD)); 145 if (nb == 1) 146 (void)psTraceSetDestination(((outFD == 2) ? 2 : outFD)); 147 if (nb == 2) 148 (void)psTraceSetDestination(((outFD == 2) ? 0 : outFD)); 149 if (nb == 3) 150 (void)psTraceSetDestination(FD); 151 152 (void)psTraceSetLevel(".", 4); 153 psTrace(".", 5, "(0) This message should not be displayed (%x)", 154 0xbeefface); 155 (void)psTraceSetLevel(".", 7); 156 psTrace(".", 5, "(0) This message should be displayed (%x)", 157 0xbeefface); 158 159 (void)psTraceSetLevel(".a", 4); 160 psTrace(".a", 5, "(1) This message should not be displayed (%x)", 161 0xbeefface); 162 (void)psTraceSetLevel(".a", 7); 163 psTrace(".a", 5, "(1) This message should be displayed (%x)", 164 0xbeefface); 165 166 (void)psTraceSetLevel(".a.b", 4); 167 psTrace(".a.b", 5, "(2) This message should not be displayed (%x)", 168 0xbeefface); 169 (void)psTraceSetLevel(".a.b", 7); 170 psTrace(".a.b", 5, "(2) This message should be displayed (%x)", 171 0xbeefface); 172 (void)psTraceSetLevel(".a.b.c", 12); 173 psTrace(".a.b.c", 11, "(3) This message should be displayed (%x)", 174 0xbeefface); 124 for (int nb = 0; nb < 4; nb++) { 125 if (nb == 0) psTraceSetDestination(((outFD == 2) ? 1 : outFD)); 126 if (nb == 1) psTraceSetDestination(((outFD == 2) ? 2 : outFD)); 127 if (nb == 2) psTraceSetDestination(((outFD == 2) ? 0 : outFD)); 128 if (nb == 3) psTraceSetDestination(FD); 129 130 psTraceSetLevel(".", 4); 131 psTrace(".", 5, "(0) This message should not be displayed (%x)", 0xbeefface); 132 psTraceSetLevel(".", 7); 133 psTrace(".", 5, "(0) This message should be displayed (%x)", 0xbeefface); 134 135 psTraceSetLevel(".a", 4); 136 psTrace(".a", 5, "(1) This message should not be displayed (%x)", 0xbeefface); 137 psTraceSetLevel(".a", 7); 138 psTrace(".a", 5, "(1) This message should be displayed (%x)", 0xbeefface); 139 140 psTraceSetLevel(".a.b", 4); 141 psTrace(".a.b", 5, "(2) This message should not be displayed (%x)", 0xbeefface); 142 psTraceSetLevel(".a.b", 7); 143 psTrace(".a.b", 5, "(2) This message should be displayed (%x)", 0xbeefface); 144 145 psTraceSetLevel(".a.b.c", 12); 146 psTrace(".a.b.c", 11, "(3) This message should be displayed (%x)", 0xbeefface); 175 147 } 176 148 close(FD); … … 182 154 { 183 155 psMemId id = psMemGetId(); 184 (void)psTraceSetDestination(outFD);185 (void)psTraceSetLevel(".", 9);186 (void)psTraceSetLevel(".a", 8);187 (void)psTraceSetLevel(".b", 7);188 (void)psTraceSetLevel(".c", 5);189 (void)psTraceSetLevel(".a.a", 4);190 (void)psTraceSetLevel(".a.b", 3);191 (void)psTraceSetLevel(".b.a", 2);192 (void)psTraceSetLevel(".b.b", 1);193 (void)psTraceSetLevel(".c.a", 0);194 (void)psTraceSetLevel(".c.b", 3);195 (void)psTraceSetLevel(".c.c", 5);156 psTraceSetDestination(outFD); 157 psTraceSetLevel(".", 9); 158 psTraceSetLevel(".a", 8); 159 psTraceSetLevel(".b", 7); 160 psTraceSetLevel(".c", 5); 161 psTraceSetLevel(".a.a", 4); 162 psTraceSetLevel(".a.b", 3); 163 psTraceSetLevel(".b.a", 2); 164 psTraceSetLevel(".b.b", 1); 165 psTraceSetLevel(".c.a", 0); 166 psTraceSetLevel(".c.b", 3); 167 psTraceSetLevel(".c.c", 5); 196 168 psTracePrintLevels(); 197 169 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); … … 202 174 { 203 175 psMemId id = psMemGetId(); 204 (void)psTraceSetLevel(".", 9);205 (void)psTraceSetLevel("a", 8);206 (void)psTraceSetLevel("b", 7);207 (void)psTraceSetLevel("c", 5);208 (void)psTraceSetLevel("a.a", 4);209 (void)psTraceSetLevel("a.b", 3);210 (void)psTraceSetLevel("b.a", 2);211 (void)psTraceSetLevel("b.b", 1);212 (void)psTraceSetLevel("c.a", 0);213 (void)psTraceSetLevel("c.b", 3);214 (void)psTraceSetLevel("c.c", 5);176 psTraceSetLevel(".", 9); 177 psTraceSetLevel("a", 8); 178 psTraceSetLevel("b", 7); 179 psTraceSetLevel("c", 5); 180 psTraceSetLevel("a.a", 4); 181 psTraceSetLevel("a.b", 3); 182 psTraceSetLevel("b.a", 2); 183 psTraceSetLevel("b.b", 1); 184 psTraceSetLevel("c.a", 0); 185 psTraceSetLevel("c.b", 3); 186 psTraceSetLevel("c.c", 5); 215 187 psTracePrintLevels(); 216 188 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); … … 221 193 { 222 194 psMemId id = psMemGetId(); 223 (void)psTraceSetDestination(outFD); 224 (void)psTraceSetLevel(".", 9); 225 (void)psTraceSetLevel(".a", 8); 226 (void)psTraceSetLevel(".b", 7); 227 (void)psTraceSetLevel(".c", 5); 228 (void)psTraceSetLevel(".a.a", 4); 229 (void)psTraceSetLevel(".a.b", 3); 230 (void)psTraceSetLevel(".b.a", 2); 231 (void)psTraceSetLevel(".b.b", 1); 232 (void)psTraceSetLevel(".c.a", 0); 233 (void)psTraceSetLevel(".c.b", 3); 234 (void)psTraceSetLevel(".c.c", 5); 235 psTraceReset(); 236 237 if ((psTraceGetLevel(".")!=PS_UNKNOWN_TRACE_LEVEL) || 238 (psTraceGetLevel(".a")!=PS_UNKNOWN_TRACE_LEVEL) || 239 (psTraceGetLevel(".b")!=PS_UNKNOWN_TRACE_LEVEL) || 240 (psTraceGetLevel(".c")!=PS_UNKNOWN_TRACE_LEVEL) || 241 (psTraceGetLevel(".a.a")!=PS_UNKNOWN_TRACE_LEVEL) || 242 (psTraceGetLevel(".a.b")!=PS_UNKNOWN_TRACE_LEVEL) || 243 (psTraceGetLevel(".b.a")!=PS_UNKNOWN_TRACE_LEVEL) || 244 (psTraceGetLevel(".b.b")!=PS_UNKNOWN_TRACE_LEVEL) || 245 (psTraceGetLevel(".c.a")!=PS_UNKNOWN_TRACE_LEVEL) || 246 (psTraceGetLevel(".c.b")!=PS_UNKNOWN_TRACE_LEVEL) || 247 (psTraceGetLevel(".c.c")!=PS_UNKNOWN_TRACE_LEVEL)) { 248 return 1; 249 } 250 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 251 } 252 195 psTraceSetDestination(outFD); 196 psTraceSetLevel(".", 9); 197 psTraceSetLevel(".a", 8); 198 psTraceSetLevel(".b", 7); 199 psTraceSetLevel(".c", 5); 200 psTraceSetLevel(".a.a", 4); 201 psTraceSetLevel(".a.b", 3); 202 psTraceSetLevel(".b.a", 2); 203 psTraceSetLevel(".b.b", 1); 204 psTraceSetLevel(".c.a", 0); 205 psTraceSetLevel(".c.b", 3); 206 psTraceSetLevel(".c.c", 5); 207 psTraceReset(); 208 209 // the reset should clear all of the levels above 210 ok (psTraceGetLevel(".") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 211 ok (psTraceGetLevel(".a") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 212 ok (psTraceGetLevel(".b") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 213 ok (psTraceGetLevel(".c") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 214 ok (psTraceGetLevel(".a.a") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 215 ok (psTraceGetLevel(".a.b") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 216 ok (psTraceGetLevel(".b.a") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 217 ok (psTraceGetLevel(".b.b") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 218 ok (psTraceGetLevel(".c.a") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 219 ok (psTraceGetLevel(".c.b") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 220 ok (psTraceGetLevel(".c.c") == PS_UNKNOWN_TRACE_LEVEL, "valid trace level"); 221 222 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 223 } 253 224 254 225 // Ensure that the leading dot in the component names are optional. … … 257 228 psMemId id = psMemGetId(); 258 229 psTraceReset(); 259 (void)psTraceSetLevel(".", 9); 260 (void)psTraceSetLevel(".a", 8); 261 (void)psTraceSetLevel(".b", 7); 262 (void)psTraceSetLevel(".c", 5); 263 (void)psTraceSetLevel(".a.a", 4); 264 (void)psTraceSetLevel(".a.b", 3); 265 (void)psTraceSetLevel(".b.a", 2); 266 (void)psTraceSetLevel(".b.b", 1); 267 (void)psTraceSetLevel(".c.a", 0); 268 (void)psTraceSetLevel(".c.b", 3); 269 (void)psTraceSetLevel(".c.c", 5); 270 psTracePrintLevels(); 271 if ((psTraceGetLevel(".")!=9) || 272 (psTraceGetLevel("a")!=8) || 273 (psTraceGetLevel("b")!=7) || 274 (psTraceGetLevel("c")!=5) || 275 (psTraceGetLevel("a.a")!=4) || 276 (psTraceGetLevel("a.b")!=3) || 277 (psTraceGetLevel("b.a")!=2) || 278 (psTraceGetLevel("b.b")!=1) || 279 (psTraceGetLevel("c.a")!=0) || 280 (psTraceGetLevel("c.b")!=3) || 281 (psTraceGetLevel("c.c")!=5)) { 282 printf("psTraceGetLevel(.) is %d", psTraceGetLevel(".")); 283 printf("psTraceGetLevel(a) is %d", psTraceGetLevel("a")); 284 printf("psTraceGetLevel(b) is %d", psTraceGetLevel("b")); 285 printf("psTraceGetLevel(c) is %d", psTraceGetLevel("c")); 286 printf("psTraceGetLevel(a.a) is %d", psTraceGetLevel("a.a")); 287 printf("psTraceGetLevel(a.b) is %d", psTraceGetLevel("a.b")); 288 printf("psTraceGetLevel(b.a) is %d", psTraceGetLevel("b.a")); 289 printf("psTraceGetLevel(b.b) is %d", psTraceGetLevel("b.b")); 290 printf("psTraceGetLevel(c.a) is %d", psTraceGetLevel("c.a")); 291 printf("psTraceGetLevel(c.b) is %d", psTraceGetLevel("c.b")); 292 printf("psTraceGetLevel(c.c) is %d", psTraceGetLevel("c.c")); 293 return 1; 294 } 230 psTraceSetLevel(".", 9); 231 psTraceSetLevel(".a", 8); 232 psTraceSetLevel(".b", 7); 233 psTraceSetLevel(".c", 5); 234 psTraceSetLevel(".a.a", 4); 235 psTraceSetLevel(".a.b", 3); 236 psTraceSetLevel(".b.a", 2); 237 psTraceSetLevel(".b.b", 1); 238 psTraceSetLevel(".c.a", 0); 239 psTraceSetLevel(".c.b", 3); 240 psTraceSetLevel(".c.c", 5); 241 psTracePrintLevels(); 242 243 ok(psTraceGetLevel(".") == 9, "level is valid without first dot"); 244 ok(psTraceGetLevel("a") == 8, "level is valid without first dot"); 245 ok(psTraceGetLevel("b") == 7, "level is valid without first dot"); 246 ok(psTraceGetLevel("c") == 5, "level is valid without first dot"); 247 ok(psTraceGetLevel("a.a") == 4, "level is valid without first dot"); 248 ok(psTraceGetLevel("a.b") == 3, "level is valid without first dot"); 249 ok(psTraceGetLevel("b.a") == 2, "level is valid without first dot"); 250 ok(psTraceGetLevel("b.b") == 1, "level is valid without first dot"); 251 ok(psTraceGetLevel("c.a") == 0, "level is valid without first dot"); 252 ok(psTraceGetLevel("c.b") == 3, "level is valid without first dot"); 253 ok(psTraceGetLevel("c.c") == 5, "level is valid without first dot"); 254 295 255 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 296 256 }
Note:
See TracChangeset
for help on using the changeset viewer.
