IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41171 for trunk/psLib/test/sys


Ignore:
Timestamp:
Nov 27, 2019, 11:57:38 AM (6 years ago)
Author:
eugene
Message:

updates to psLib tests

Location:
trunk/psLib/test/sys
Files:
6 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/sys/tap_psError.c

    r17515 r41171  
    324324
    325325        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:
    336332                a. the result is correct.
    337333        */
    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");
    343337
    344338        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");
    350341   
    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. */
    354343        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:
    360347                a. the execution does not cease.
    361348                b. an appropriate error is generated.
     
    366353        psErr* err = psErrorLast();
    367354        ok(err->code == PS_ERR_BAD_PARAMETER_NULL,
    368         "psErrorCode didn't generate proper error code for NULL input.");
     355        "psErrorCode generated proper error code for NULL input.");
    369356
    370357        psFree(err);
     
    377364        err = psErrorLast();
    378365        ok(err->code == PS_ERR_NONE,
    379             "psErrorCode generated an error for nErrors = 0.");
     366            "psErrorCode did not generate an error for nErrors = 0.");
    380367        psFree(err);
    381368    }
  • trunk/psLib/test/sys/tap_psLine.c

    r12781 r41171  
    2323    psLogSetLevel(PS_LOG_INFO);
    2424
    25     //testLineAlloc()
     25    // testLineAlloc()
    2626    {
    2727        psMemId id = psMemGetId();
    2828        psLine *lineline = NULL;
    2929        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");
    3232        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!");
    3534        psFree(lineline);
    3635        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    4140        psMemId id = psMemGetId();
    4241        psLine *line = NULL;
    43         //Return false for NULL input
     42        // Return false for NULL input
    4443        int okay = !psLineInit(line);
    4544        ok(okay, "psLineInit.  Expected false for NULL psLine input");
    46         //Allocate a line and return true on Init
     45        // Allocate a line and return true on Init
    4746        line = psLineAlloc(1);
    4847        okay = psLineInit(line);
     
    6564        int okay = psLineAdd(line, "Hello %s", "World");
    6665        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.");
    7168        psFree(line);
    7269        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    7976        psLine *line = NULL;
    8077        //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");
    8379        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");
    8681        psFree(line);
    8782        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
  • trunk/psLib/test/sys/tap_psMemory.c

    r24023 r41171  
    4141    psLogSetFormat("HLNM");
    4242    psLogSetLevel(PS_LOG_INFO);
    43     plan_tests(46);
     43    plan_tests(54);
    4444
    4545    // TPFreeReferencedMemory()
     
    7979    // the psMemExhaustedCallback.
    8080    // XXXX: Skipping TPOutOfMemory() because of test abort failure
    81     if (0) {
     81    skip_start (1, 2, "Skipping TPOutOfMemory() because of test abort failure");
     82    {
    8283        psMemId id = psMemGetId();
    8384        psS32 *mem[ 100 ];
     
    8889        exhaustedCallbackCalled = 0;
    8990        cb = psMemExhaustedCallbackSet( TPOutOfMemoryExhaustedCallback );
    90         #ifdef COMMENTED_OUT
     91        // #ifdef COMMENTED_OUT
    9192        // Don't include since intentionally aborts
    9293        for ( psS32 lcv = 0; lcv < 100; lcv++ ) {
     
    99100            psFree( mem[ lcv ] );
    100101        }
    101         #endif
    102         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();
    105106
    106107
     
    108109    // psRealloc shall call the psMemExhaustedCallback.
    109110    // XXXX: Skipping TPReallocOutOfMemory() because of test abort failure
    110     if (0) {
     111    skip_start (1, 2, "Skipping TPReallocOutOfMemory() because of test abort failure");
     112    {
    111113        psMemId id = psMemGetId();
    112114        psS32 *mem[ 100 ];
     
    131133        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    132134    }
    133 
     135    skip_end();
    134136
    135137    // psAlloc shall allocate memory blocks writeable by caller.
     
    236238    // TPcheckLeaks()
    237239    // XXXX: Skipping TPcheckLeaks() because of test abort failure
    238     if (0) {
     240    skip_start (1, 6, "Skipping TPcheckLeaks() because of test abort failure");
     241    {
    239242        const psS32 numBuffers = 5;
    240243        psS32* buffers[ 5 ];
     
    288291        psFree(buffers[3]);
    289292    }
     293    skip_end();
    290294
    291295
     
    304308        psArray *array = psArrayAlloc(100);
    305309        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");
    312314        psFree(array);
    313315
    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);
    322325
    323326        psCube *cube;
    324327        cube = psCubeAlloc();
    325328        okay = psMemCheckType(PS_DATA_CUBE, cube);
    326         if (!okay )
    327             psFree(cube);
     329        if (!okay ) psFree(cube);
    328330        ok(okay, "psMemCheckCube in memCheckType");
    329331        psFree(cube);
     
    335337        psFree(img);
    336338        okay = psMemCheckType(PS_DATA_FITS, fits);
    337         if (!okay )
    338             psFree(fits);
     339        if (!okay ) psFree(fits);
    339340        ok(okay, "psMemCheckFits in memCheckType");
    340341        psFitsClose(fits);
     
    343344        hash = psHashAlloc(100);
    344345        okay = psMemCheckType(PS_DATA_HASH, hash);
    345         if (!okay )
    346             psFree(hash);
     346        if (!okay ) psFree(hash);
    347347        ok(okay, "psMemCheckHash in memCheckType");
    348348        psFree(hash);
     
    351351        histogram = psHistogramAlloc(1.1, 2.2, 2);
    352352        okay = psMemCheckType(PS_DATA_HISTOGRAM, histogram);
    353         if (!okay )
    354             psFree(histogram);
     353        if (!okay ) psFree(histogram);
    355354        ok(okay, "psMemCheckHistogram in memCheckType");
    356355        psFree(histogram);
     
    359358        image = psImageAlloc(5, 5, PS_TYPE_F32);
    360359        okay = psMemCheckType(PS_DATA_IMAGE, image);
    361         if (!okay )
    362             psFree(image);
     360        if (!okay ) psFree(image);
    363361        ok(okay, "psMemCheckImage in memCheckType");
    364362        psFree(image);
     
    367365        kernel = psKernelAlloc(0, 1, 0, 1);
    368366        okay = psMemCheckType(PS_DATA_KERNEL, kernel);
    369         if (!okay )
    370             psFree(kernel);
     367        if (!okay ) psFree(kernel);
    371368        ok(okay, "psMemCheckKernel in memCheckType");
    372369        psFree(kernel);
     
    375372        list = psListAlloc(NULL);
    376373        okay = psMemCheckType(PS_DATA_LIST, list);
    377         if (!okay )
    378             psFree(list);
     374        if (!okay ) psFree(list);
    379375        ok(okay, "psMemCheckList in memCheckType");
    380376        psFree(list);
     
    385381        lookup = psLookupTableAlloc(file, format, 10);
    386382        okay = psMemCheckType(PS_DATA_LOOKUPTABLE, lookup);
    387         if (!okay )
    388             psFree(lookup);
     383        if (!okay ) psFree(lookup);
    389384        ok(okay, "psMemCheckLookupTable in memCheckType");
    390385        psFree(lookup);
     
    393388        metadata = psMetadataAlloc();
    394389        okay = psMemCheckType(PS_DATA_METADATA, metadata);
    395         if (!okay )
    396             psFree(metadata);
     390        if (!okay ) psFree(metadata);
    397391        ok(okay, "psMemCheckMetadata in memCheckType");
    398392        psFree(metadata);
     
    401395        metaItem = psMetadataItemAlloc("name", PS_DATA_S32, "COMMENT", 1);
    402396        okay = psMemCheckType(PS_DATA_METADATAITEM, metaItem);
    403         if (!okay )
    404             psFree(metaItem);
     397        if (!okay ) psFree(metaItem);
    405398        ok(okay, "psMemCheckMetadataItem in memCheckType");
    406399        psFree(metaItem);
    407400
    408401        psMinimization *min;
    409         min = psMinimizationAlloc(3, 0.1);
     402        min = psMinimizationAlloc(3, 0.1, 1.0);
    410403        okay = psMemCheckType(PS_DATA_MINIMIZATION, min);
    411         if (!okay )
    412             psFree(min);
     404        if (!okay ) psFree(min);
    413405        ok(okay, "psMemCheckMinimization in memCheckType");
    414406        psFree(min);
     
    417409        pixels = psPixelsAlloc(100);
    418410        okay = psMemCheckType(PS_DATA_PIXELS, pixels);
    419         if (!okay )
    420             psFree(pixels);
     411        if (!okay ) psFree(pixels);
    421412        ok(okay, "psMemCheckPixels in memCheckType");
    422413        psFree(pixels);
     
    425416        plane = psPlaneAlloc();
    426417        okay = psMemCheckType(PS_DATA_PLANE, plane);
    427         if (!okay )
    428             psFree(plane);
     418        if (!okay ) psFree(plane);
    429419        ok(okay, "psMemCheckPlane in memCheckType.");
    430420        psFree(plane);
     
    433423        planeDistort = psPlaneDistortAlloc(1, 1, 1, 1);
    434424        okay =  psMemCheckType(PS_DATA_PLANEDISTORT, planeDistort);
    435         if (!okay )
    436             psFree(planeDistort);
     425        if (!okay ) psFree(planeDistort);
    437426        ok(okay, "psMemCheckPlaneDistort in memCheckType.");
    438427        psFree(planeDistort);
     
    441430        planeTransform = psPlaneTransformAlloc(1, 1);
    442431        okay = psMemCheckType(PS_DATA_PLANETRANSFORM, planeTransform);
    443         if (!okay )
    444             psFree(planeTransform);
     432        if (!okay ) psFree(planeTransform);
    445433        ok(okay, "psMemCheckPlaneTransform in memCheckType");
    446434        psFree(planeTransform);
     
    449437        poly1 = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2);
    450438        okay = psMemCheckType(PS_DATA_POLYNOMIAL1D, poly1);
    451         if (!okay )
    452             psFree(poly1);
     439        if (!okay ) psFree(poly1);
    453440        ok(okay, "psMemCheckPolynomial1D in memCheckType");
    454441        psFree(poly1);
     
    457444        poly2 = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 2, 1);
    458445        okay = psMemCheckType(PS_DATA_POLYNOMIAL2D, poly2);
    459         if (!okay )
    460             psFree(poly2);
     446        if (!okay ) psFree(poly2);
    461447        ok(okay, "psMemCheckPolynomial2D in memCheckType");
    462448        psFree(poly2);
     
    465451        poly3 = psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 2, 1, 1);
    466452        okay = psMemCheckType(PS_DATA_POLYNOMIAL3D, poly3);
    467         if (!okay )
    468             psFree(poly3);
     453        if (!okay ) psFree(poly3);
    469454        ok(okay, "psMemCheckPolynomial3D in memCheckType");
    470455        psFree(poly3);
     
    473458        poly4 = psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 2, 1, 2, 1);
    474459        okay = psMemCheckType(PS_DATA_POLYNOMIAL4D, poly4);
    475         if (!okay )
    476             psFree(poly4);
     460        if (!okay ) psFree(poly4);
    477461        ok(okay, "psMemCheckPolynomial4D in memCheckType");
    478462        psFree(poly4);
     
    481465        proj = psProjectionAlloc(1, 1, 2.1, 2.1, PS_PROJ_TAN);
    482466        okay = psMemCheckType(PS_DATA_PROJECTION, proj);
    483         if (!okay )
    484             psFree(proj);
     467        if (!okay ) psFree(proj);
    485468        ok(okay, "psMemCheckProjection in memCheckType.");
    486469        psFree(proj);
     
    490473        scalar = psScalarAlloc(f64, PS_TYPE_F64);
    491474        okay = psMemCheckType(PS_DATA_SCALAR, scalar);
    492         if (!okay )
    493             psFree(scalar);
     475        if (!okay ) psFree(scalar);
    494476        ok(okay, "psMemCheckScalar in memCheckType");
    495477        psFree(scalar);
     
    498480        sphere = psSphereAlloc();
    499481        okay = psMemCheckType(PS_DATA_SPHERE, sphere);
    500         if (!okay )
    501             psFree(sphere);
     482        if (!okay ) psFree(sphere);
    502483        ok(okay, "psMemCheckSphere in memCheckType");
    503484        psFree(sphere);
     
    506487        sphereRot = psSphereRotAlloc(0, 0, 20);
    507488        okay = psMemCheckType(PS_DATA_SPHEREROT, sphereRot);
    508         if (!okay )
    509             psFree(sphereRot);
     489        if (!okay ) psFree(sphereRot);
    510490        ok(okay, "psMemCheckSphereRot in memCheckType");
    511491        psFree(sphereRot);
     
    516496        spline = psSpline1DAlloc();
    517497        okay = psMemCheckType(PS_DATA_SPLINE1D, spline);
    518         if (!okay )
    519             psFree(spline);
     498        if (!okay ) psFree(spline);
    520499        ok(okay, "psMemCheckSpline1D in memCheckType");
    521500        psFree(spline);
     
    524503        stats = psStatsAlloc(PS_STAT_MAX);
    525504        okay = psMemCheckType(PS_DATA_STATS, stats);
    526         if (!okay )
    527             psFree(stats);
     505        if (!okay ) psFree(stats);
    528506        ok(okay, "psMemCheckStats in memCheckType");
    529507        psFree(stats);
     
    532510        time = psTimeAlloc(PS_TIME_UT1);
    533511        okay = psMemCheckType(PS_DATA_TIME, time);
    534         if (!okay )
    535             psFree(time);
     512        if (!okay ) psFree(time);
    536513        ok(okay, "psMemCheckTime in memCheckType");
    537514        psFree(time);
     
    548525}
    549526
    550 
    551527#if 0
    552528void TPmemCorruption( void )
  • trunk/psLib/test/sys/tap_psString.c

    r24023 r41171  
    111111    {
    112112        psMemId id = psMemGetId();
    113         psS32   result = 0;
    114         psS32   result1 = 0;
    115         char  *strResult;
    116113        char  *stringvalnocopy = "F A I L";
    117114
    118115        // 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
    125125        psFree(strResult);
    126126        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    149149    }
    150150
    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();
    172171
    173172    // testStringCopy06()
     
    200199    }
    201200
    202 #if 0
    203201    // testStrAppend01()
    204202    {
    205203        psMemId id = psMemGetId();
    206         char *str=NULL;
     204        char *str = NULL;
    207205        // test nonsensical invocations ...
    208206        ssize_t sz = psStringAppend(NULL, NULL);
    209         ok(sz == 0, "Failed test point");
     207        ok(!sz, "append NULL string to NULL string");
    210208        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    }
    215212
    216213    // testStrAppend02()
     
    251248    }
    252249
    253 #if 0
    254250    // testStrPrepend01()
    255251    {
     
    263259        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    264260    }
    265 #endif
    266261
    267262    // testStrPrepend02()
  • trunk/psLib/test/sys/tap_psTrace.c

    r17515 r41171  
    22    This code will test whether trace levels can be set successfully.
    33 
    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*****************************************************************************/
    79#include <stdio.h>
    810#include <fcntl.h>
     
    2022
    2123# define DEBUG 1
    22 # if (DEBUG)
     24# if (!DEBUG)
    2325    FILE *output = fopen ("/dev/null", "w");
    2426    int outFD = fileno (output);
     
    3032    {
    3133        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);
    4646   
    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);
    5049        }
    5150   
    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        }
    6157        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    6258    }
     
    6460
    6561    // 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 should see this");
    72         psTrace(".A.B.C.D.E.F",3,"You should see this too");
    73         psTracePrintLevels();
    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    }
    7773
    7874    // testTrace02()
     
    8076        psMemId id = psMemGetId();
    8177        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    }
    10390
    10491    // testTrace03()
    10592    {
    10693        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);
    11198            psTraceReset();
    11299            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    }
    137119
    138120    // testTrace04()
     
    140122        psMemId id = psMemGetId();
    141123        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);
    175147        }
    176148        close(FD);
     
    182154    {
    183155        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);
    196168        psTracePrintLevels();
    197169        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     
    202174    {
    203175        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);
    215187        psTracePrintLevels();
    216188        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     
    221193    {
    222194        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    }
    253224
    254225    // Ensure that the leading dot in the component names are optional.
     
    257228        psMemId id = psMemGetId();
    258229        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
    295255        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
    296256    }
Note: See TracChangeset for help on using the changeset viewer.