Changeset 41171
- Timestamp:
- Nov 27, 2019, 11:57:38 AM (6 years ago)
- Location:
- trunk/psLib
- Files:
-
- 28 deleted
- 13 edited
-
src/sys/psString.c (modified) (1 diff)
-
test/astro/tap_psTime_03.c (modified) (3 diffs)
-
test/fft/tst_psImageFFT.c (deleted)
-
test/fft/tst_psVectorFFT.c (deleted)
-
test/sys/tap_psError.c (modified) (3 diffs)
-
test/sys/tap_psLine.c (modified) (4 diffs)
-
test/sys/tap_psMemory.c (modified) (34 diffs)
-
test/sys/tap_psString.c (modified) (5 diffs)
-
test/sys/tap_psTrace.c (modified) (10 diffs)
-
test/sys/tst_psConfigure.c (deleted)
-
test/sys/tst_psError.c (deleted)
-
test/sys/tst_psLine.c (deleted)
-
test/sys/tst_psMemory.c (deleted)
-
test/sys/tst_psString.c (deleted)
-
test/sys/tst_psTrace.c (deleted)
-
test/types (modified) (1 prop)
-
test/types/tap_psArguments_all.c (modified) (13 diffs)
-
test/types/tap_psList_all.c (modified) (1 diff)
-
test/types/tap_psMetadataConfigParse.c (modified) (2 diffs)
-
test/types/tap_psMetadata_copying.c (modified) (4 diffs)
-
test/types/tap_psMetadata_manip.c (modified) (1 diff)
-
test/types/tst_psArguments.c (deleted)
-
test/types/tst_psArray.c (deleted)
-
test/types/tst_psBitSet.c (deleted)
-
test/types/tst_psHash00.c (deleted)
-
test/types/tst_psHash01.c (deleted)
-
test/types/tst_psHash02.c (deleted)
-
test/types/tst_psHash03.c (deleted)
-
test/types/tst_psHash04.c (deleted)
-
test/types/tst_psHash05.c (deleted)
-
test/types/tst_psList.c (deleted)
-
test/types/tst_psLookupTable_01.c (deleted)
-
test/types/tst_psMetadataIO.c (deleted)
-
test/types/tst_psMetadata_01.c (deleted)
-
test/types/tst_psMetadata_02.c (deleted)
-
test/types/tst_psMetadata_03.c (deleted)
-
test/types/tst_psMetadata_04.c (deleted)
-
test/types/tst_psMetadata_05.c (deleted)
-
test/types/tst_psMetadata_06.c (deleted)
-
test/types/tst_psMetadata_07.c (deleted)
-
test/types/tst_psPixels.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psString.c
r40551 r41171 107 107 108 108 // Check the number of characters to copy is non-negative 109 // XXX need to limit nChar to < memtotal 109 110 if (nChar < 0) { 110 111 // Log error message and return NULL -
trunk/psLib/test/astro/tap_psTime_03.c
r24303 r41171 494 494 psFree(timeStr); 495 495 496 bool status =psTimeConvert(time, PS_TIME_TT);496 psTimeConvert(time, PS_TIME_TT); 497 497 timeStr = psTimeToISO(time); 498 498 is_str(timeStr, testTimeBStrTT[i], "TT ISO string"); … … 500 500 501 501 // Verify UTC ISO string 502 status =psTimeConvert(time, PS_TIME_UTC);502 psTimeConvert(time, PS_TIME_UTC); 503 503 time->leapsecond = testTimeBLeapsecond[i]; 504 504 timeStr = psTimeToISO(time); … … 506 506 psFree(timeStr); 507 507 508 status =psTimeConvert(time, PS_TIME_UT1);508 psTimeConvert(time, PS_TIME_UT1); 509 509 timeStr = psTimeToISO(time); 510 510 is_str(timeStr, testTimeBStrUT1[i], "UT1 ISO string"); -
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 } -
trunk/psLib/test/types
- Property svn:ignore
-
old new 75 75 tap_psMetadataOverlay 76 76 tap_psTree 77 tap_psBits_all
-
- Property svn:ignore
-
trunk/psLib/test/types/tap_psArguments_all.c
r17515 r41171 37 37 int argc = 5; 38 38 39 // Try to get an argument's position 40 int i = psArgumentGet(argc, argv, "-float"); 41 { 42 ok( i == 3, 43 "psArgumentGet: return correct location of input argument."); 44 } 45 46 // Return 0 for attempting to get from a NULL input argument. 47 { 48 ok( psArgumentGet(argc, NULL, "-float") == 0, 49 "psArgumentGet: return 0 for a NULL input argument."); 50 } 51 52 // Return 0 for attempting to find a NULL string 53 { 54 ok( psArgumentGet(argc, argv, NULL) == 0, 55 "psArgumentGet: return 0 for a NULL input string."); 56 } 57 58 // Return 0 for attempting to find an empty string 59 { 60 ok( psArgumentGet(argc, argv, "") == 0, 61 "psArgumentGet: return 0 for an empty input string."); 62 } 63 64 // Return 0 for attempting to get an argument that doesn't match 65 { 66 ok( psArgumentGet(argc, argv, "-xxx") == 0, 67 "psArgumentGet: return 0 for an empty input string."); 68 } 69 70 // Return false for attempting to remove argnum = 0 71 { 72 ok( !psArgumentRemove(0, &argc, argv), 73 "psArgumentRemove: return false for argnum = 0."); 74 } 75 76 // Return false for attempting to remove NULL argc 77 { 78 ok( !psArgumentRemove(0, NULL, argv), 79 "psArgumentRemove: return false for NULL argc."); 80 } 39 // define a simple fake argument list : this is not modified 40 char *argvBad[5]; 41 argvBad[0] = "./program"; 42 argvBad[1] = "-string"; 43 argvBad[2] = "new"; 44 argvBad[3] = "-test"; 45 argvBad[4] = "6.66"; 46 int argcBad = 5; 81 47 82 48 // simple argument definitions for comparison … … 86 52 psMetadataAdd(args, PS_LIST_TAIL, "-double", PS_DATA_F64, "Test Double", 0.666); 87 53 54 ok( psArgumentGet(argc, argv, "-float") == 3, "psArgumentGet: return correct location of input argument."); 55 ok( psArgumentGet(argc, NULL, "-float") == 0, "psArgumentGet: return 0 for a NULL input argument."); 56 57 ok( psArgumentGet(argc, argv, NULL) == 0, "psArgumentGet: return 0 for a NULL input string."); 58 ok( psArgumentGet(argc, argv, "") == 0, "psArgumentGet: return 0 for an empty input string."); 59 60 ok( psArgumentGet(argc, argv, "-xxx") == 0, "psArgumentGet: return 0 for an unmatched input string."); 61 62 ok( !psArgumentRemove(0, &argc, argv), "psArgumentRemove: return false for argnum = 0."); 63 ok( !psArgumentRemove(0, NULL, argv), "psArgumentRemove: return false for NULL argc."); 64 88 65 // psArgumentParse tests 89 // Return false for NULL input arguments 90 { 91 ok( !psArgumentParse(NULL, &argc, argv), 92 "psArgumentParse: return false for NULL argument metadata input."); 93 } 94 95 // Return false for NULL input argc 96 { 97 ok( !psArgumentParse(args, NULL, argv), 98 "psArgumentParse: return false for NULL argc input."); 99 } 100 101 // Return false for NULL input argv 102 { 103 ok( !psArgumentParse(args, &argc, NULL), 104 "psArgumentParse: return false for NULL argv input."); 105 } 106 107 // Return false for argc = 0 108 { 109 int tempc = 0; 110 ok( !psArgumentParse(args, &tempc, argv), 111 "psArgumentParse: return false for argc = 1 input."); 112 } 113 114 // Return false for string not found in metadata arguments 115 { 116 // define a simple fake argument list : this is not modified 117 char *argvBad[5]; 118 argvBad[0] = "./program"; 119 argvBad[1] = "-string"; 120 argvBad[2] = "new"; 121 argvBad[3] = "-test"; 122 argvBad[4] = "6.66"; 123 int argcBad = 5; 124 125 ok( !psArgumentParse(args, &argcBad, argvBad), 126 "psArgumentParse: return false for argv containing unspecified input."); 127 } 128 129 // Check for Memory leaks 130 { 131 psFree(args); 132 checkMem(); 133 } 66 ok( !psArgumentParse(NULL, &argc, argv), "psArgumentParse: return false for NULL argument metadata input."); 67 ok( !psArgumentParse(args, NULL, argv), "psArgumentParse: return false for NULL argc input."); 68 ok( !psArgumentParse(args, &argc, NULL), "psArgumentParse: return false for NULL argv input."); 69 70 int tempc = 0; 71 ok( !psArgumentParse(args, &tempc, argv), "psArgumentParse: return false for argc = 0 input."); 72 ok( !psArgumentParse(args, &argcBad, argvBad), "psArgumentParse: return false for argv containing unspecified input."); 73 74 psFree(args); 134 75 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 135 76 } … … 195 136 ok( psArgumentParse(args, &argc, argv), "psArgumentParse: return true for valid inputs."); 196 137 138 // XXX does not check the results... 139 197 140 // Check for Memory leaks 198 141 psFree(args); … … 221 164 argv[0] = "./program"; 222 165 argv[1] = "-string"; 223 ok( !psArgumentParse(tempArg, &argc, argv), 224 "psArgumentParse: return false for inconsistent argc."); 166 ok( !psArgumentParse(tempArg, &argc, argv), "psArgumentParse: return false for inconsistent argc."); 225 167 psFree(tempArg); 168 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 226 169 } 227 170 … … 240 183 argv[0] = "./program"; 241 184 argv[1] = "-string"; 242 ok( !psArgumentParse(args, &argc, argv), 243 "psArgumentParse: return false for incomplete string syntax."); 185 ok( !psArgumentParse(args, &argc, argv), "psArgumentParse: return false for incomplete string syntax."); 244 186 } 245 187 … … 251 193 argv[1] = "-multi"; 252 194 argv[2] = "2"; 253 ok( psArgumentParse(args, &argc, argv), 254 "psArgumentParse: return true for MULTI."); 195 ok( psArgumentParse(args, &argc, argv), "psArgumentParse: return true for MULTI."); 255 196 } 256 197 257 198 // Check for Memory leaks 258 { 259 psFree(args); 260 checkMem(); 261 } 199 psFree(args); 262 200 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 263 201 } … … 269 207 { 270 208 int argc = 1; 271 ok( psArgumentVerbosity(&argc, NULL) == 2, 272 "psArgumentVerbosity: return 2 for NULL argument input."); 209 ok( psArgumentVerbosity(&argc, NULL) == 2, "psArgumentVerbosity: return 2 for NULL argument input."); 273 210 } 274 211 … … 277 214 char *argv[1]; 278 215 argv[0] = "./program"; 279 ok( psArgumentVerbosity(NULL, argv) == 2, 280 "psArgumentVerbosity: return 2 for NULL argument input."); 216 ok( psArgumentVerbosity(NULL, argv) == 2, "psArgumentVerbosity: return 2 for NULL argument input."); 281 217 } 282 218 … … 287 223 argv[0] = "./program"; 288 224 argv[1] = "-v"; 289 ok( psArgumentVerbosity(&argc, argv) == 3, 290 "psArgumentVerbosity: return 3 for '-v' argument input."); 225 ok( psArgumentVerbosity(&argc, argv) == 3, "psArgumentVerbosity: return 3 for '-v' argument input."); 291 226 } 292 227 … … 297 232 argv[0] = "./program"; 298 233 argv[1] = "-vv"; 299 ok( psArgumentVerbosity(&argc, argv) == 4, 300 "psArgumentVerbosity: return 4 for '-vv' argument input."); 234 ok( psArgumentVerbosity(&argc, argv) == 4, "psArgumentVerbosity: return 4 for '-vv' argument input."); 301 235 } 302 236 … … 307 241 argv[0] = "./program"; 308 242 argv[1] = "-vvv"; 309 ok( psArgumentVerbosity(&argc, argv) == 5, 310 "psArgumentVerbosity: return 5 for '-vvv' argument input."); 243 ok( psArgumentVerbosity(&argc, argv) == 5, "psArgumentVerbosity: return 5 for '-vvv' argument input."); 311 244 } 312 245 … … 359 292 { 360 293 // this function sends output to the screen or /dev/null (i 361 # if (!DEBUG)294 # if (!DEBUG) 362 295 FILE *f = fopen ("/dev/null", "w"); 363 296 int fd = fileno(f); 364 297 psTraceSetDestination (fd); 365 # endif298 # endif 366 299 367 300 int argc = 2; … … 374 307 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 375 308 } 309 310 /** EAM 2019.11.09 this section is commented out because these functions do not exist 311 void testLogTraceArguments(void) 312 { 313 note(" >>>Test 3: psLogArguments & psTraceArguments Fxns"); 314 315 // Return 2 (default) for NULL arguments input 316 { 317 int argc = 4; 318 ok( psLogArguments(&argc, NULL) == 2, "psLogArguments: return 2 for NULL argument input."); 319 } 320 321 // Return 2 (default) for NULL argc input 322 { 323 char *argv[1]; 324 argv[0] = "./program"; 325 ok( psLogArguments(NULL, argv) == 2, "psLogArguments: return 2 for NULL argc input."); 326 } 327 328 // Return 3 for "-v" option 329 { 330 int argc = 2; 331 char *argv[2]; 332 argv[0] = "./program"; 333 argv[1] = "-v"; 334 ok( psLogArguments(&argc, argv) == 3, "psLogArguments: return 3 for '-v' argument input."); 335 } 336 337 // Return 4 for "-vv" option 338 { 339 int argc = 2; 340 char *argv[2]; 341 argv[0] = "./program"; 342 argv[1] = "-vv"; 343 ok( psLogArguments(&argc, argv) == 4, "psLogArguments: return 4 for '-vv' argument input."); 344 } 345 346 // Return 5 for "-vvv" option 347 { 348 int argc = 2; 349 char *argv[2]; 350 argv[0] = "./program"; 351 argv[1] = "-vvv"; 352 ok( psLogArguments(&argc, argv) == 5, "psLogArguments: return 5 for '-vvv' argument input."); 353 } 354 355 // Return 2 for "-logfmt" option 356 { 357 int argc = 2; 358 char *argv[2]; 359 argv[0] = "./program"; 360 argv[1] = "-logfmt"; 361 ok( psLogArguments(&argc, argv) == 2, "psLogArguments: return 2 for '-logfmt' argument input."); 362 } 363 364 // Return 2 for "-logfmt" option with "H" 365 { 366 int argc = 3; 367 char *argv[3]; 368 argv[0] = "./program"; 369 argv[1] = "-logfmt"; 370 argv[2] = "H"; 371 ok( psLogArguments(&argc, argv) == 2, "psLogArguments: return 2 for '-logfmt H' argument inputs."); 372 } 373 374 // psTraceArguments Tests 375 // Return 0 (default) for NULL arguments input 376 { 377 int argc = 4; 378 ok( psTraceArguments(&argc, NULL) == 0, "psTraceArguments: return 0 for NULL argument input."); 379 } 380 381 // Return 0 (default) for NULL argc input 382 { 383 char *argv[1]; 384 argv[0] = "./program"; 385 ok( psTraceArguments(NULL, argv) == 0, "psTraceArguments: return 0 for NULL argc input."); 386 } 387 388 // Return 0 for "-trace" option 389 { 390 int argc = 2; 391 char *argv[2]; 392 argv[0] = "./program"; 393 argv[1] = "-trace"; 394 ok( psTraceArguments(&argc, argv) == 0, "psTraceArguments: return 2 for '-trace' argument input."); 395 } 396 397 // Return 2 for "-trace 1 2" option 398 { 399 int argc = 4; 400 char *argv[4]; 401 argv[0] = "./program"; 402 argv[1] = "-trace"; 403 argv[2] = "1"; 404 argv[3] = "2"; 405 ok( psTraceArguments(&argc, argv) == 1, "psTraceArguments: return 2 for '-trace 1 2' argument inputs."); 406 } 407 408 // Return 2 for "-trace-levels" option 409 { 410 int argc = 2; 411 char *argv[2]; 412 argv[0] = "./program"; 413 argv[1] = "-trace-levels"; 414 ok( psTraceArguments(&argc, argv) == 0, "psTraceArguments: return 2 for '-trace-levels' argument input."); 415 } 416 417 // Check for Memory leaks 418 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 419 } 420 **/ 376 421 } 377 378 379 /* XXX: Why is this commented out?380 void testLogTraceArguments(void)381 {382 note(" >>>Test 3: psLogArguments & psTraceArguments Fxns");383 384 // Return 2 (default) for NULL arguments input385 {386 int argc = 4;387 ok( psLogArguments(&argc, NULL) == 2,388 "psLogArguments: return 2 for NULL argument input.");389 }390 // Return 2 (default) for NULL argc input391 {392 char *argv[1];393 argv[0] = "./program";394 ok( psLogArguments(NULL, argv) == 2,395 "psLogArguments: return 2 for NULL argc input.");396 }397 // Return 3 for "-v" option398 {399 int argc = 2;400 char *argv[2];401 argv[0] = "./program";402 argv[1] = "-v";403 ok( psLogArguments(&argc, argv) == 3,404 "psLogArguments: return 3 for '-v' argument input.");405 }406 // Return 4 for "-vv" option407 {408 int argc = 2;409 char *argv[2];410 argv[0] = "./program";411 argv[1] = "-vv";412 ok( psLogArguments(&argc, argv) == 4,413 "psLogArguments: return 4 for '-vv' argument input.");414 }415 // Return 5 for "-vvv" option416 {417 int argc = 2;418 char *argv[2];419 argv[0] = "./program";420 argv[1] = "-vvv";421 ok( psLogArguments(&argc, argv) == 5,422 "psLogArguments: return 5 for '-vvv' argument input.");423 }424 // Return 2 for "-logfmt" option425 {426 int argc = 2;427 char *argv[2];428 argv[0] = "./program";429 argv[1] = "-logfmt";430 ok( psLogArguments(&argc, argv) == 2,431 "psLogArguments: return 2 for '-logfmt' argument input.");432 }433 // Return 2 for "-logfmt" option with "H"434 {435 int argc = 3;436 char *argv[3];437 argv[0] = "./program";438 argv[1] = "-logfmt";439 argv[2] = "H";440 ok( psLogArguments(&argc, argv) == 2,441 "psLogArguments: return 2 for '-logfmt H' argument inputs.");442 }443 444 445 // psTraceArguments Tests446 // Return 0 (default) for NULL arguments input447 {448 int argc = 4;449 ok( psTraceArguments(&argc, NULL) == 0,450 "psTraceArguments: return 0 for NULL argument input.");451 }452 // Return 0 (default) for NULL argc input453 {454 char *argv[1];455 argv[0] = "./program";456 ok( psTraceArguments(NULL, argv) == 0,457 "psTraceArguments: return 0 for NULL argc input.");458 }459 // Return 0 for "-trace" option460 {461 int argc = 2;462 char *argv[2];463 argv[0] = "./program";464 argv[1] = "-trace";465 ok( psTraceArguments(&argc, argv) == 0,466 "psTraceArguments: return 2 for '-trace' argument input.");467 }468 // Return 2 for "-trace 1 2" option469 {470 int argc = 4;471 char *argv[4];472 argv[0] = "./program";473 argv[1] = "-trace";474 argv[2] = "1";475 argv[3] = "2";476 ok( psTraceArguments(&argc, argv) == 1,477 "psTraceArguments: return 2 for '-trace 1 2' argument inputs.");478 }479 // Return 2 for "-trace-levels" option480 {481 int argc = 2;482 char *argv[2];483 argv[0] = "./program";484 argv[1] = "-trace-levels";485 ok( psTraceArguments(&argc, argv) == 0,486 "psTraceArguments: return 2 for '-trace-levels' argument input.");487 }488 489 // Check for Memory leaks490 {491 checkMem();492 }493 }494 */ -
trunk/psLib/test/types/tap_psList_all.c
r17515 r41171 150 150 "psListAddAfter: return true for adding a list element to the head."); 151 151 } 152 psFree(noList); 153 152 154 //Return true for adding to an empty list 153 psFree(noList);154 155 noList = psListAlloc(NULL); 155 156 psListIterator *iter3 = psListIteratorAlloc(noList, 0, true); 156 157 { 157 ok( psListAddAfter(iter3, md), 158 "psListAddAfter: return true for adding to an empty list."); 158 ok( psListAddAfter(iter3, md), "psListAddAfter: return true for adding to an empty list."); 159 159 } 160 160 -
trunk/psLib/test/types/tap_psMetadataConfigParse.c
r12781 r41171 58 58 skip_start(item == NULL, 2, 59 59 "Skipping 1 tests because metadata container is empty!"); 60 ok(item->type == PS_ TYPE_S32, "return correcot metdataItem type");60 ok(item->type == PS_DATA_S32, "return correct metdataItem type"); 61 61 is_int(item->data.S32, 666, "return correct metadataItem data"); 62 62 is_str(item->name, "new", "return correct metadataItem name"); … … 105 105 skip_start(item == NULL, 2, 106 106 "Skipping 1 tests because metadata container is empty!"); 107 ok(item->type == PS_ TYPE_S8, "metdataItem type");107 ok(item->type == PS_DATA_S8, "metdataItem type"); 108 108 is_int(item->data.S8, 3, "metdataItem value"); 109 109 is_str(item->name, "item8", "return correct metadataItem name"); -
trunk/psLib/test/types/tap_psMetadata_copying.c
r12781 r41171 421 421 //Return false for NULL in input 422 422 { 423 ok( !psMetadataItemSupplement(out, NULL, key),423 ok( !psMetadataItemSupplement(NULL, out, NULL, key), 424 424 "psMetadataItemSupplement: return false for NULL in metadata."); 425 425 } 426 426 //Return false for NULL out input 427 427 { 428 ok( !psMetadataItemSupplement(NULL, in, key),428 ok( !psMetadataItemSupplement(NULL, NULL, in, key), 429 429 "psMetadataItemSupplement: return false for NULL out metadata."); 430 430 } 431 431 //Return false for NULL key input 432 432 { 433 ok( !psMetadataItemSupplement( out, in, NULL),433 ok( !psMetadataItemSupplement(NULL, out, in, NULL), 434 434 "psMetadataItemSupplement: return false for NULL key string."); 435 435 } … … 439 439 //Return true for valid inputs 440 440 { 441 bool transfered = psMetadataItemSupplement( out, in, key);441 bool transfered = psMetadataItemSupplement(NULL, out, in, key); 442 442 psMetadataItem *item = NULL; 443 443 if (transfered) … … 460 460 { 461 461 strncpy(key, "not MY key", 15); 462 ok( !psMetadataItemSupplement( out, in, key),462 ok( !psMetadataItemSupplement(NULL, out, in, key), 463 463 "psMetadataItemSupplement: return false for invalid key."); 464 464 } … … 468 468 invalid->hash = NULL; 469 469 { 470 ok( !psMetadataItemSupplement( invalid, in, "key"),470 ok( !psMetadataItemSupplement(NULL, invalid, in, "key"), 471 471 "psMetadataItemSupplement: return false for invalid metadata."); 472 472 } -
trunk/psLib/test/types/tap_psMetadata_manip.c
r17515 r41171 231 231 psMetadataAddPtr(metadata, PS_LIST_TAIL, "ptr", PS_DATA_SPHERE | PS_META_DUPLICATE_OK, "", s); 232 232 psFree(s); 233 psMetadataItem *metadataItem = NULL;234 metadataItem = psMetadataLookup(metadata, "ptr");233 // psMetadataItem *metadataItem = NULL; 234 // metadataItem = psMetadataLookup(metadata, "ptr"); 235 235 bool status = false; 236 236 psSphere *sph = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
