IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15987


Ignore:
Timestamp:
Jan 2, 2008, 10:53:30 AM (18 years ago)
Author:
gusciora
Message:

Modified file reads to look for dataFiles and then ../dataFiles.
Other additions as well.
First version: tap_pmReadoutFake.c
First version: tap_pmReadoutStack.c

Location:
trunk/psModules/test/camera
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/camera/tap_pmFPA.c

    r14881 r15987  
    1 /** @file  tst_pmAstrometry.c
    2  *
    3  *  XXX: Untested: pmFPACheckParents()
    4  *
    5     void pmCellFreeReadouts(pmCell *cell)
    6     void pmCellFreeData(pmCell *cell)
    7     void pmChipFreeCells(pmChip *chip)   
    8     void pmChipFreeData(pmChip *chip)
    9     void pmFPAFreeData(pmFPA *fpa)
    10     void pmReadoutFreeData(pmReadout *readout)
    11 
    12 *    pmReadout *pmReadoutAlloc(pmCell *cell)
    13 *    pmCell *pmCellAlloc(pmChip *chip, const char *name)
    14 *    pmChip *pmChipAlloc(pmFPA *fpa, const char *name)
    15 *    pmFPA *pmFPAAlloc(const psMetadata *camera)
    16 
    17     bool pmFPACheckParents(pmFPA *fpa)
    18  *
    19  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    20  *  @date $Date: 2007-09-18 18:57:18 $
    21  *
    22  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    23  */
    241#include <stdio.h>
    252#include <string.h>
     
    285#include "tap.h"
    296#include "pstap.h"
     7/* STATUS:
     8    All functions are tested.
     9*/
    3010
    3111#define CHIP_ALLOC_NAME "ChipName"
     
    8969    psArrayRealloc(cell->readouts, NUM_READOUTS);
    9070    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    91         cell->readouts->data[i] = generateSimpleReadout(cell);
     71        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
    9272    }
    9373    return(cell);
     
    10888    psArrayRealloc(chip->cells, NUM_CELLS);
    10989    for (int i = 0 ; i < NUM_CELLS ; i++) {
    110         chip->cells->data[i] = generateSimpleCell(chip);
     90        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
    11191    }
    11292    return(chip);
     
    129109    psArrayRealloc(fpa->chips, NUM_CHIPS);
    130110    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    131         fpa->chips->data[i] = generateSimpleChip(fpa);
     111        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
    132112    }
    133113
     
    135115}
    136116
    137 // XXX: This should only be necessary until the psFree() functions for
    138 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    139 void myFreeCell(pmCell *cell)
    140 {
    141     for (int k = 0 ; k < cell->readouts->n ; k++) {
    142         psFree(cell->readouts->data[k]);
    143     }
    144     psFree(cell);
    145 }
    146 
    147 void myFreeChip(pmChip *chip) {
    148     for (int j = 0 ; j < chip->cells->n ; j++) {
    149         myFreeCell(chip->cells->data[j]);
    150     }
    151     psFree(chip);
    152 }
    153 
    154 void myFreeFPA(pmFPA *fpa)
    155 {
    156     for (int i = 0 ; i < fpa->chips->n ; i++) {
    157         myFreeChip(fpa->chips->data[i]);
    158     }
    159     psFree(fpa);
    160 }
    161117
    162118psS32 main(psS32 argc, char* argv[])
     
    164120    psLogSetFormat("HLNM");
    165121    psLogSetLevel(PS_LOG_INFO);
    166     plan_tests(56);
     122    plan_tests(92);
    167123
    168124    // ------------------------------------------------------------------------
    169125    // pmFPAAlloc() tests
    170     // XXX: Add tests for NULL inputs.
     126    // Call pmFPAAlloc() with NULL pmCamera input.
     127    {
     128        psMemId id = psMemGetId();
     129        pmFPA* fpa = pmFPAAlloc(NULL);
     130        ok(fpa != NULL && psMemCheckFPA(fpa), "pmFPAAlloc() returned a non-NULL pmFPA with a NULL pmCamera input");
     131        psFree(fpa);
     132        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     133    }
     134
     135    // Call pmFPAAlloc() with acceptable input parameters.
    171136    {
    172137        psMemId id = psMemGetId();
     
    186151           psMemCheckArray(fpa->chips), "pmFPAAlloc() set ->chips correctly");
    187152        ok(fpa->hdu == NULL, "pmFPAAlloc() set ->hdu to NULL");
    188 //        ok(fpa->wrote_phu == false, "pmFPAAlloc() set ->wrote_phu to FALSE");
    189153        psFree(fpa);
    190154        psFree(camera);
     
    192156    }
    193157
     158
    194159    // Populate the pmFPA struct with real data to ensure they were psFree()'ed correctly.
    195160    {
    196161        psMemId id = psMemGetId();
    197162        pmFPA* fpa = generateSimpleFPA(NULL);
    198 
    199         myFreeFPA(fpa);
    200 /*
    201         if (1) {
    202             for (int i = 0 ; i < fpa->chips->n ; i++) {
    203                 pmChip *chip = fpa->chips->data[i];
    204                 for (int j = 0 ; j < chip->cells->n ; j++) {
    205                     pmCell *cell = chip->cells->data[j];
    206                     for (int k = 0 ; k < cell->readouts->n ; k++) {
    207                         pmReadout *readout = cell->readouts->data[k];
    208                         psFree(readout);
    209                     }
    210                     psFree(cell);
    211                 }
    212                 psFree(chip);
    213             }
    214             psFree(fpa);
    215         } else {
    216             for (int i = 0 ; i < fpa->chips->n ; i++) {
    217                 pmChip *chip = fpa->chips->data[i];
    218                 pmChipFreeCells(chip);
    219                 pmChipFreeData(chip);
    220                 psFree(chip);
    221             }
    222             psFree(fpa);
    223         }
    224 */
    225         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    226     }
     163        psFree(fpa);
     164        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Populate the pmFPA struct with real data)");
     165    }
     166
    227167
    228168    // ------------------------------------------------------------------------
    229169    // pmFPAFreeData() tests
    230     // XXX: pmFPAAlloc(), pmChipAlloc(), etc, allocate much of the members of
    231     // those data structures.  We don't really check that those members were
    232     // actually psFree()'ed; we merely ensure that they were set to NULL.
    233     {
    234         psMemId id = psMemGetId();
    235         psMetadata *camera = psMetadataAlloc();
    236         pmFPA* fpa = generateSimpleFPA(camera);
    237 //        pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
    238 //        pmCell *cell = pmCellAlloc(chip, CELL_ALLOC_NAME);
    239 //        pmReadout *readout = pmReadoutAlloc(cell);
     170    // Call pmFPAFreeData() with NULL pmFPA input parameter
     171    {
     172        psMemId id = psMemGetId();
     173        pmFPAFreeData(NULL);
     174        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Call pmFPAFreeData() with NULL pmFPA input parameter)");
     175    }
     176
     177
     178    // Call pmFPAFreeData() with acceptable input parameters
     179    {
     180        psMemId id = psMemGetId();
     181        pmFPA* fpa = generateSimpleFPA(NULL);
     182        fpa->hdu->images = psArrayAlloc(10);
     183        fpa->hdu->weights = psArrayAlloc(10);
     184        fpa->hdu->masks = psArrayAlloc(10);
    240185        pmFPAFreeData(fpa);
    241186        ok(fpa->hdu->images == NULL, "pmFPAFreeData() correctly set fpa->hdu->images to NULL");
    242187        ok(fpa->hdu->weights == NULL, "pmFPAFreeData() correctly set fpa->hdu->weights to NULL");
    243188        ok(fpa->hdu->masks == NULL, "pmFPAFreeData() correctly set fpa->hdu->masks to NULL");
    244      
    245 //        ok(chip->hdu->images == NULL, "pmFPAFreeData() correctly set chip->hdu->images to NULL");
    246 //        ok(chip->hdu->weights == NULL, "pmFPAFreeData() correctly set chip->hdu->weights to NULL");
    247 //        ok(chip->hdu->masks == NULL, "pmFPAFreeData() correctly set chip->hdu->masks to NULL");
    248 //        ok(cell->hdu->images == NULL, "pmFPAFreeData() correctly set cell->hdu->images to NULL");
    249 //        ok(cell->hdu->weights == NULL, "pmFPAFreeData() correctly set cell->hdu->weights to NULL");
    250 //        ok(cell->hdu->masks == NULL, "pmFPAFreeData() correctly set cell->hdu->masks to NULL");
    251         psFree(camera);
    252         psFree(fpa);
    253 //        psFree(chip);
    254 //        psFree(cell);
    255 //        psFree(readout);
    256         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    257     }
    258 
    259     // ------------------------------------------------------------------------
     189        psFree(fpa);
     190        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     191    }
     192
     193
     194    // ------------------------------------------------------------------------
     195    // pmChipAlloc() tests
     196    // Call pmChipAlloc() with NULL input parameters
     197    {
     198        psMemId id = psMemGetId();
     199        pmChip *chip = pmChipAlloc(NULL, CHIP_ALLOC_NAME);
     200        ok(chip != NULL, "pmChipAlloc() returned non-NULL with NULL pmFPA input parameter");
     201        psFree(chip);
     202        pmFPA* fpa = generateSimpleFPA(NULL);
     203        chip = pmChipAlloc(fpa, NULL);
     204        ok(chip != NULL, "pmChipAlloc() returned non-NULL with NULL chip name input parameter");
     205        psFree(fpa);
     206        psFree(chip);
     207        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     208    }
     209
     210
    260211    // pmChipAlloc() tests
    261212    // XXX: Add tests for NULL inputs.
    262213    {
    263214        psMemId id = psMemGetId();
    264         psMetadata *camera = psMetadataAlloc();
    265         pmFPA* fpa = generateSimpleFPA(camera);
     215        pmFPA* fpa = generateSimpleFPA(NULL);
    266216        pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
    267217        ok(chip != NULL, "pmChipAlloc() returned non-NULL");
     
    280230        ok(chip->data_exists == false, "pmChipAlloc() set ->data_exists correctly");
    281231        ok(chip->hdu == NULL, "pmChipAlloc() set ->hdu to NULL");
    282 //        ok(chip->wrote_phu == false, "pmChipAlloc() set ->wrote_phu correctly");
    283         psFree(camera);
    284         psFree(fpa);
    285         psFree(chip);
    286         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    287     }
     232        psFree(fpa);
     233        psFree(chip);
     234        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     235    }
     236
    288237
    289238    // Populate the pmChip struct with real data to ensure they were free'ed correctly.
     
    292241        pmChip *chip = generateSimpleChip(NULL);
    293242        psFree(chip);
     243        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Populate the pmChip struct with real data)");
     244    }
     245
     246
     247    // ------------------------------------------------------------------------
     248    // pmChipFreeData() tests
     249    // Call pmChipFreeData() with NULL pmFPA input parameter
     250    {
     251        psMemId id = psMemGetId();
     252        pmChipFreeData(NULL);
     253        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Call pmChipFreeData() with NULL pmFPA input parameter)");
     254    }
     255
     256
     257    // Call pmChipFreeData() with acceptable input parameters
     258    {
     259        psMemId id = psMemGetId();
     260        pmChip* chip = generateSimpleChip(NULL);
     261        chip->hdu->images = psArrayAlloc(10);
     262        chip->hdu->weights = psArrayAlloc(10);
     263        chip->hdu->masks = psArrayAlloc(10);
     264        pmChipFreeData(chip);
     265        ok(chip->hdu->images == NULL, "pmChipFreeData() correctly set chip->hdu->images to NULL");
     266        ok(chip->hdu->weights == NULL, "pmChipFreeData() correctly set chip->hdu->weights to NULL");
     267        ok(chip->hdu->masks == NULL, "pmChipFreeData() correctly set chip->hdu->masks to NULL");
     268        psFree(chip);
     269        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     270    }
     271
     272
     273    // ------------------------------------------------------------------------
     274    // pmChipFreeCells() tests
     275    // Call pmChipFreeCells() with NULL pmFPA input parameter
     276    {
     277        psMemId id = psMemGetId();
     278        pmChipFreeCells(NULL);
     279        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Call pmChipFreeCells() with NULL pmFPA input parameter)");
     280    }
     281
     282
     283    // Call pmChipFreeCells() with acceptable input parameters
     284    {
     285        psMemId id = psMemGetId();
     286        pmChip* chip = generateSimpleChip(NULL);
     287        pmChipFreeCells(chip);
     288        ok(chip->cells->n == 0, "pmChipFreeCells() free'ed chip->cells correctly");
     289        psFree(chip);
    294290        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    295291    }
     
    298294    // ------------------------------------------------------------------------
    299295    // pmCellAlloc() tests
    300     // XXX: Add tests for NULL inputs.
     296    // Call pmCellAlloc() with NULL input parameters
     297    {
     298        psMemId id = psMemGetId();
     299        pmCell *cell = pmCellAlloc(NULL, CELL_ALLOC_NAME);
     300        ok(cell != NULL, "pmCellAlloc returned non-NULL with NULL pmChip input parameter");
     301        psFree(cell);
     302
     303        pmChip *chip = pmChipAlloc(NULL, NULL);
     304        cell = pmCellAlloc(chip, NULL);
     305        ok(cell != NULL, "pmCellAlloc returned non-NULL with NULL cell name input parameter");
     306        psFree(chip);
     307        psFree(cell);
     308        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     309    }
     310
     311
     312    // pmCellAlloc() tests
     313    // Call pmCellAlloc() with acceptable input parameters
    301314    {
    302315        psMemId id = psMemGetId();
     
    319332        ok(cell->data_exists == false, "pmCellAlloc() set ->data_exists correctly");
    320333        ok(cell->hdu == NULL, "pmCellAlloc() set ->hdu to NULL");
    321 //        ok(cell->wrote_phu == false, "pmCellAlloc() set ->wrote_phu correctly");
    322334        psFree(camera);
    323335        psFree(fpa);
     
    326338        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    327339    }
     340
    328341
    329342    // Populate the pmCell struct with real data to ensure they were
     
    333346        pmCell *cell = generateSimpleCell(NULL);
    334347        psFree(cell);
    335         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    336     }
    337 
    338 
     348        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Populate the pmCell struct with real data)");
     349    }
     350
     351
     352    // ------------------------------------------------------------------------
     353    // pmCellFreeData() tests
     354    // Call pmCellFreeData() with NULL pmFPA input parameter
     355    {
     356        psMemId id = psMemGetId();
     357        pmCellFreeData(NULL);
     358        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Call pmCellFreeData() with NULL pmFPA input parameter)");
     359    }
     360
     361
     362    // Call pmCellFreeData() with acceptable input parameters
     363    {
     364        psMemId id = psMemGetId();
     365        pmCell *cell = generateSimpleCell(NULL);
     366        cell->hdu->images = psArrayAlloc(10);
     367        cell->hdu->weights = psArrayAlloc(10);
     368        cell->hdu->masks = psArrayAlloc(10);
     369        pmCellFreeData(cell);
     370        ok(cell->hdu->images == NULL, "pmCellFreeData() correctly set cell->hdu->images to NULL");
     371        ok(cell->hdu->weights == NULL, "pmCellFreeData() correctly set cell->hdu->weights to NULL");
     372        ok(cell->hdu->masks == NULL, "pmCellFreeData() correctly set cell->hdu->masks to NULL");
     373        psFree(cell);
     374        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     375    }
     376
     377
     378    // ------------------------------------------------------------------------
    339379    // test pmCellFreeReadouts()
    340380    {
     
    350390    // ------------------------------------------------------------------------
    351391    // pmReadoutAlloc() tests
    352     // XXX: Add tests for NULL inputs.
     392    // Call pmReadoutAlloc() with NULL input parameters
     393    {
     394        psMemId id = psMemGetId();
     395        pmReadout *readout = pmReadoutAlloc(NULL);
     396        ok(readout != NULL, "pmReadoutAlloc() returned non-NULL with NULL pmCell input parameter");
     397        psFree(readout);
     398        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     399    }
     400
     401
     402    // Call pmReadoutAlloc() with acceptable parameters
    353403    {
    354404        psMemId id = psMemGetId();
     
    380430    }
    381431
     432
    382433    // Populate the pmReadout struct with real data to ensure they were
    383434    // psFree()'ed correctly.
     
    390441    }
    391442
    392 /*
    393     {
    394         psMemId id = psMemGetId();
    395         pmReadout *readout = pmReadoutAlloc(NULL);
    396         readout->image = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    397         readout->mask = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_U8);
    398         readout->weight = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    399         for (psS32 i = 0 ; i < NUM_BIAS_DATA ; i++) {
    400             psImage *tmpImage = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_F32);
    401             psListAdd(readout->bias, PS_LIST_HEAD, tmpImage);
    402         }
    403         psMetadataAddS32(readout->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    404         return(readout);
    405     }
    406 */
    407 
    408 
    409 }
     443
     444    // ------------------------------------------------------------------------
     445    // pmReadoutFreeData() tests
     446    // Call pmReadoutFreeData() with NULL pmFPA input parameter
     447    {
     448        psMemId id = psMemGetId();
     449        pmReadoutFreeData(NULL);
     450        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks (Call pmReadoutFreeData() with NULL pmFPA input parameter)");
     451    }
     452
     453
     454    // Call pmReadoutFreeData() with acceptable input parameters
     455    {
     456        psMemId id = psMemGetId();
     457        pmReadout *readout = generateSimpleReadout(NULL);
     458        pmReadoutFreeData(readout);
     459        ok(readout->image == NULL, "pmReadoutFreeData() correctly set readout->image to NULL");
     460        ok(readout->weight == NULL, "pmReadoutFreeData() correctly set readout->weight to NULL");
     461        ok(readout->mask == NULL, "pmReadoutFreeData() correctly set readout->mask to NULL");
     462        psFree(readout);
     463        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     464    }
     465
     466
     467    // ------------------------------------------------------------------------
     468    // pmFPACheckParents() tests
     469    // psBool pmFPACheckParents(pmFPA *fpa)
     470    // Call pmFPACheckParents() with NULL pmFPA input parameter
     471    {
     472        psMemId id = psMemGetId();
     473        bool rc = pmFPACheckParents(NULL);
     474        ok(rc == false, "pmFPACheckParents() returned FALSE with NULL pmFPA input parameter");
     475        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     476    }
     477
     478
     479    // pmFPACheckParents() tests
     480    // Call pmFPACheckParents() with acceptable input parameters
     481    {
     482        psMemId id = psMemGetId();
     483        pmFPA* fpa = generateSimpleFPA(NULL);
     484        bool rc = pmFPACheckParents(fpa);
     485        ok(rc == true, "pmFPACheckParents() returned FALSE with acceptable input parameters");
     486        psFree(fpa);
     487        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     488    }
     489
     490}
  • trunk/psModules/test/camera/tap_pmFPACellSquish.c

    r14882 r15987  
    8282    cell->hdu = pmHDUAlloc("cellExtName");
    8383    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    84         cell->readouts->data[i] = generateSimpleReadout(cell);
     84        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
    8585    }
    8686
    87     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     87    // First try to read data from ../dataFiles, then try dataFiles.
     88    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    8889    if (!rc) {
    89         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     90        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     91        if (!rc) {
     92            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     93        }
    9094    }
    9195
     
    123127    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    124128    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    125 //    chip->hdu = pmHDUAlloc("chipExtName");
    126 //
    127 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    128 //    if (!rc) {
    129 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    130 //    }
    131 //
     129
    132130    psArrayRealloc(chip->cells, NUM_CELLS);
    133131    for (int i = 0 ; i < NUM_CELLS ; i++) {
    134         chip->cells->data[i] = generateSimpleCell(chip);
     132        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
    135133    }
    136 
    137     // XXX: Add code to initialize chip pmConcepts
    138 
    139 
    140134    return(chip);
    141135}
     
    154148    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    155149    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    156 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    157 //
    158 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    159 //    if (!rc) {
    160 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    161 //    }
    162 
    163150    psArrayRealloc(fpa->chips, NUM_CHIPS);
    164151    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    165         fpa->chips->data[i] = generateSimpleChip(fpa);
     152        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
    166153    }
    167154
    168     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    169     // reading code from wherever.
    170155    pmConceptsBlankFPA(fpa);
    171 //    bool mdok;
    172 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    173 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    174 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    175 
    176156    return(fpa);
    177 }
    178 
    179 // XXX: This should only be necessary until the psFree() functions for
    180 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    181 void myFreeCell(pmCell *cell)
    182 {
    183     for (int k = 0 ; k < cell->readouts->n ; k++) {
    184         psFree(cell->readouts->data[k]);
    185     }
    186     psFree(cell);
    187 }
    188 
    189 void myFreeChip(pmChip *chip) {
    190     for (int j = 0 ; j < chip->cells->n ; j++) {
    191         myFreeCell(chip->cells->data[j]);
    192     }
    193     psFree(chip);
    194 }
    195 
    196 void myFreeFPA(pmFPA *fpa)
    197 {
    198     for (int i = 0 ; i < fpa->chips->n ; i++) {
    199         myFreeChip(fpa->chips->data[i]);
    200     }
    201     psFree(fpa);
    202157}
    203158
     
    208163    psLogSetLevel(PS_LOG_INFO);
    209164    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    210     plan_tests(25);
     165    plan_tests(4);
    211166
    212167
     
    230185        pmCell *cell = chip->cells->data[0];
    231186        ok(pmCellSquish(cell, 0, false), "pmCellSquish(NULL) returned NULL");
    232         myFreeFPA(fpa);
    233187        psFree(camera);
    234         if (0) psFree(cell);
     188        psFree(fpa);
    235189        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    236190    }
  • trunk/psModules/test/camera/tap_pmFPAConstruct.c

    r14882 r15987  
    1414    psLogSetLevel(PS_LOG_INFO);
    1515    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    16     plan_tests(72);
     16    plan_tests(9);
    1717
    1818    // ----------------------------------------------------------------------
     
    3434    {
    3535        psMetadata *camera = psMetadataAlloc();
    36         bool rc = pmConfigFileRead(&camera, "data/camera0/camera.config", "CAMERA 0 config file");
     36        bool rc = pmConfigFileRead(&camera, "dataFiles/camera0/camera.config", "CAMERA 0 config file");
     37        if (!rc) {
     38             rc = pmConfigFileRead(&camera, "../dataFiles/camera0/camera.config", "CAMERA 0 config file");
     39        }
     40
    3741        // Generate the pmFPA heirarchy
    3842        psMemId id = psMemGetId();
     
    4448        }
    4549        bool errorFlag = false;
    46         ok(fpa->chips->n == 4, "pmFPAConstruct() set fpa->chips->n (%d)", fpa->chips->n);
     50        ok(fpa->chips->n == 2, "pmFPAConstruct() set fpa->chips->n (%d)", fpa->chips->n);
    4751        for (int chipID = 0 ; chipID < fpa->chips->n ; chipID++) {
    4852            pmChip *chip = fpa->chips->data[chipID];
  • trunk/psModules/test/camera/tap_pmFPAExtent.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
     7/* STATUS:
     8    All functions are tested.
     9*/
     10
    1211// XXX: For the genSimpleFPA() code, add IDs to each function so that
    1312// the values set in each chip-?cell-?hdu-?image are unique
     
    8180    cell->hdu = pmHDUAlloc("cellExtName");
    8281    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    83         cell->readouts->data[i] = generateSimpleReadout(cell);
    84     }
    85 
    86     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     82        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     83    }
     84
     85    bool rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    8786    if (!rc) {
    88         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     87        rc = pmConfigFileRead(&cell->hdu->format, "../camera0/format0.config", "Camera format 0");
     88        if (!rc) {
     89            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     90        }
    8991    }
    9092
     
    102104
    103105    //XXX: Should the region be set some other way?  Like through the various config files?
    104 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    105106    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    106107    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     
    122123    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    123124    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    124 //    chip->hdu = pmHDUAlloc("chipExtName");
    125 //
    126 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    127 //    if (!rc) {
    128 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    129 //    }
    130 //
    131125    psArrayRealloc(chip->cells, NUM_CELLS);
    132126    for (int i = 0 ; i < NUM_CELLS ; i++) {
    133         chip->cells->data[i] = generateSimpleCell(chip);
     127        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
    134128    }
    135129
     
    153147    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    154148    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    155 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    156 //
    157 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    158 //    if (!rc) {
    159 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    160 //    }
    161149
    162150    psArrayRealloc(fpa->chips, NUM_CHIPS);
    163151    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    164         fpa->chips->data[i] = generateSimpleChip(fpa);
    165     }
    166 
    167     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    168     // reading code from wherever.
     152        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     153    }
     154
    169155    pmConceptsBlankFPA(fpa);
    170 //    bool mdok;
    171 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    172 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    173 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    174 
    175156    return(fpa);
    176157}
    177158
    178 // XXX: This should only be necessary until the psFree() functions for
    179 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    180 void myFreeCell(pmCell *cell)
    181 {
    182     for (int k = 0 ; k < cell->readouts->n ; k++) {
    183         psFree(cell->readouts->data[k]);
    184     }
    185     psFree(cell);
    186 }
    187 
    188 void myFreeChip(pmChip *chip) {
    189     for (int j = 0 ; j < chip->cells->n ; j++) {
    190         myFreeCell(chip->cells->data[j]);
    191     }
    192     psFree(chip);
    193 }
    194 
    195 void myFreeFPA(pmFPA *fpa)
    196 {
    197     for (int i = 0 ; i < fpa->chips->n ; i++) {
    198         myFreeChip(fpa->chips->data[i]);
    199     }
    200     psFree(fpa);
    201 }
    202159
    203160
     
    250207        ok(!errorFlag, "pmReadoutExtent() passed all tests");
    251208
    252         myFreeFPA(fpa);
     209        psFree(fpa);
    253210        psFree(camera);
    254211        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    258215    // ----------------------------------------------------------------------
    259216    // pmCellExtent() tests: NULL input
    260     // psRegion *pmCellExtent(const pmCell *cell)
    261217    {
    262218        psMemId id = psMemGetId();
     
    312268        ok(!errorFlag, "pmCellExtent() passed all tests");
    313269
    314         myFreeFPA(fpa);
     270        psFree(fpa);
    315271        psFree(camera);
    316272        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    321277    // ----------------------------------------------------------------------
    322278    // pmChipExtent() tests: NULL input
    323     // psRegion *pmChipExtent(const pmChip *chip)
    324279    {
    325280        psMemId id = psMemGetId();
     
    361316        ok(!errorFlag, "pmChipExtent() passed all tests");
    362317
    363         myFreeFPA(fpa);
     318        psFree(fpa);
    364319        psFree(camera);
    365320        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    369324    // ----------------------------------------------------------------------
    370325    // pmChipPixels() tests: NULL input
    371     // psRegion *pmChipPixels(const pmChip *chip)
    372326    {
    373327        psMemId id = psMemGetId();
     
    416370        ok(!errorFlag, "pmChipPixels() passed all tests");
    417371
    418         myFreeFPA(fpa);
     372        psFree(fpa);
    419373        psFree(camera);
    420374        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    424378    // ----------------------------------------------------------------------
    425379    // pmFPAPixels() tests: NULL input
    426     // psRegion *pmFPAPixels(const pmFPA *fpa)
    427380    {
    428381        psMemId id = psMemGetId();
     
    464417        psFree(tstExtent);
    465418        psFree(actualExtent);
    466         myFreeFPA(fpa);
     419        psFree(fpa);
    467420        psFree(camera);
    468421        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    469422    }
    470 
    471 
    472 
    473 
    474 }
     423}
  • trunk/psModules/test/camera/tap_pmFPAFlags.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
     7/* STATUS
     8    TESTED:
     9        pmFPASetFileStatus()
     10        pmChipSetFileStatus()
     11        pmCellSetFileStatus()
     12
     13        pmFPACheckFileStatus()
     14        pmChipCheckFileStatus()
     15        pmCellCheckFileStatus()
     16
     17        pmFPASetDataStatus()
     18        pmChipSetDataStatus()
     19        pmCellSetDataStatus()
     20
     21        pmFPACheckDataStatus()
     22        pmChipCheckDataStatus()
     23        pmCellCheckDataStatus()
     24        pmReadoutCheckDataStatus()
     25    MUST TEST:
     26        pmFPAviewCheckDataStatus()
     27        pmFPASelectChip()
     28        pmChipSelectCell()
     29        pmFPAExcludeChip()
     30        pmChipExcludeCell()
     31*/
     32
    1233// XXX: For the genSimpleFPA() code, add IDs to each function so that
    1334// the values set in each chip-?cell-?hdu-?image are unique
     
    82103    cell->hdu = pmHDUAlloc("cellExtName");
    83104    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    84         cell->readouts->data[i] = generateSimpleReadout(cell);
    85     }
    86 
    87     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     105        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     106    }
     107
     108    bool rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    88109    if (!rc) {
    89         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     110        rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     111        if (!rc) {
     112            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     113        }
    90114    }
    91115
     
    103127
    104128    //XXX: Should the region be set some other way?  Like through the various config files?
    105 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    106129    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    107130    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     
    123146    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    124147    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    125 //    chip->hdu = pmHDUAlloc("chipExtName");
    126 //
    127 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    128 //    if (!rc) {
    129 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    130 //    }
    131 //
    132148    psArrayRealloc(chip->cells, NUM_CELLS);
    133149    for (int i = 0 ; i < NUM_CELLS ; i++) {
    134         chip->cells->data[i] = generateSimpleCell(chip);
     150        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
    135151    }
    136152
     
    154170    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    155171    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    156 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    157 //
    158 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    159 //    if (!rc) {
    160 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    161 //    }
    162 
    163172    psArrayRealloc(fpa->chips, NUM_CHIPS);
    164173    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    165         fpa->chips->data[i] = generateSimpleChip(fpa);
     174        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
    166175    }
    167176
     
    169178    // reading code from wherever.
    170179    pmConceptsBlankFPA(fpa);
    171 //    bool mdok;
    172 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    173 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    174 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    175 
    176180    return(fpa);
    177181}
    178182
    179 // XXX: This should only be necessary until the psFree() functions for
    180 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    181 void myFreeCell(pmCell *cell)
    182 {
    183     for (int k = 0 ; k < cell->readouts->n ; k++) {
    184         psFree(cell->readouts->data[k]);
    185     }
    186     psFree(cell);
    187 }
    188 
    189 void myFreeChip(pmChip *chip) {
    190     for (int j = 0 ; j < chip->cells->n ; j++) {
    191         myFreeCell(chip->cells->data[j]);
    192     }
    193     psFree(chip);
    194 }
    195 
    196 void myFreeFPA(pmFPA *fpa)
    197 {
     183void SetCellFileExists(pmCell *cell) {
     184    cell->file_exists = true;
     185    for (int i = 0 ; i < cell->readouts->n ; i++) {
     186        pmReadout *readout = cell->readouts->data[i];
     187        readout->file_exists = true;
     188    }
     189}
     190
     191void SetChipFileExists(pmChip *chip) {
     192    chip->file_exists = true;
     193    for (int i = 0 ; i < chip->cells->n ; i++) {
     194        pmCell *cell = chip->cells->data[i];
     195        cell->file_exists = true;
     196        SetCellFileExists(cell);
     197    }
     198}
     199
     200void SetFPAFileExists(pmFPA *fpa) {
    198201    for (int i = 0 ; i < fpa->chips->n ; i++) {
    199         myFreeChip(fpa->chips->data[i]);
    200     }
    201     psFree(fpa);
     202        pmChip *chip = fpa->chips->data[i];
     203        chip->file_exists = true;
     204        SetChipFileExists(chip);
     205    }
     206}
     207
     208void SetReadoutDataExists(pmReadout *readout) {
     209    readout->data_exists = true;
     210}
     211
     212void SetCellDataExists(pmCell *cell) {
     213    cell->data_exists = true;
     214    for (int i = 0 ; i < cell->readouts->n ; i++) {
     215        pmReadout *readout = cell->readouts->data[i];
     216        readout->data_exists = true;
     217    }
     218}
     219
     220void SetChipDataExists(pmChip *chip) {
     221    chip->data_exists = true;
     222    for (int i = 0 ; i < chip->cells->n ; i++) {
     223        pmCell *cell = chip->cells->data[i];
     224        cell->data_exists = true;
     225        SetCellDataExists(cell);
     226    }
     227}
     228
     229void SetFPADataExists(pmFPA *fpa) {
     230    for (int i = 0 ; i < fpa->chips->n ; i++) {
     231        pmChip *chip = fpa->chips->data[i];
     232        chip->data_exists = true;
     233        SetChipDataExists(chip);
     234    }
    202235}
    203236
     
    208241    psLogSetLevel(PS_LOG_INFO);
    209242    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    210     plan_tests(72);
    211 
    212     // ----------------------------------------------------------------------
    213     // ----------------------------------------------------------------------
    214     // pmCellSetFileStatus() tests: verify with NULL pmCell param
    215     // bool pmCellSetFileStatus(pmCell *cell, bool status)
    216     {
    217         psMemId id = psMemGetId();
    218         bool rc = pmCellSetFileStatus(NULL, false);
    219         ok(!rc, "pmCellSetFileStatus() returned FALSE with NULL pmCell param");
    220         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    221     }
    222 
    223 
    224     // pmCellSetFileStatus() tests: verify with acceptable data
    225     // bool pmCellSetFileStatus(pmCell *cell, bool status)
    226     {
    227         psMemId id = psMemGetId();
    228         // Generate the pmFPA heirarchy
    229         psMetadata *camera = psMetadataAlloc();
    230         pmFPA* fpa = generateSimpleFPA(camera);
    231         pmChip *chip = fpa->chips->data[0];
    232         pmCell *cell = chip->cells->data[0];
    233         ok(fpa != NULL, "Allocated a pmFPA successfully");
    234         ok(chip != NULL, "Allocated a pmChip successfully");
    235         ok(cell != NULL, "Allocated a pmCell successfully");
    236 
    237         // First, set all flags to FALSE
    238         bool correctStatus = false;
    239         bool rc = pmCellSetFileStatus(cell, correctStatus);
    240         ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params");
    241         bool errorFlag = false;
    242         if (cell->file_exists != correctStatus) {
    243             diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell param\n");
    244             errorFlag = true;
    245         }
    246         for (int i = 0; i < cell->readouts->n; i++) {
    247 
    248             pmReadout *readout = cell->readouts->data[i];
    249             if (readout->file_exists != correctStatus) {
    250                 diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell %d\n", i);
    251                 errorFlag = true;
    252             }
    253         }
    254         ok(!errorFlag, "pmCellSetFileStatus() set file status in all cells to FALSE");
    255 
    256         // Second, set all flags to TRUE
    257         correctStatus = true;
    258         rc = pmCellSetFileStatus(cell, correctStatus);
    259         ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params");
    260         errorFlag = false;
    261         if (cell->file_exists != correctStatus) {
    262             diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell param\n");
    263             errorFlag = true;
    264         }
    265         for (int i = 0; i < cell->readouts->n; i++) {
    266             pmReadout *readout = cell->readouts->data[i];
    267             if (readout->file_exists != correctStatus) {
    268                 diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell %d\n", i);
    269                 errorFlag = true;
    270             }
    271         }
    272         ok(!errorFlag, "pmCellSetFileStatus() set file status in all cells to TRUE");
    273 
    274         // Third, set all flags to FALSE
    275         correctStatus = false;
    276         rc = pmCellSetFileStatus(cell, correctStatus);
    277         ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params");
    278         errorFlag = false;
    279         if (cell->file_exists != correctStatus) {
    280             diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell param\n");
    281             errorFlag = true;
    282         }
    283         for (int i = 0; i < cell->readouts->n; i++) {
    284             pmReadout *readout = cell->readouts->data[i];
    285             if (readout->file_exists != correctStatus) {
    286                 diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for readout %d\n", i);
    287                 errorFlag = true;
    288             }
    289         }
    290         ok(!errorFlag, "pmCellSetFileStatus() set file status in all cells to FALSE");
    291 
    292         myFreeFPA(fpa);
    293         psFree(camera);
    294         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    295     }
    296 
    297 
    298     // ----------------------------------------------------------------------
    299     // ----------------------------------------------------------------------
    300     // pmChipSetFileStatus() tests: verify with NULL pmChip param
    301     // bool pmChipSetFileStatus(pmChip *chip, bool status)
    302     {
    303         psMemId id = psMemGetId();
    304         bool rc = pmChipSetFileStatus(NULL, false);
    305         ok(!rc, "pmChipSetFileStatus() returned FALSE with NULL pmChip param");
    306         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    307     }
    308 
    309 
    310     // pmChipSetFileStatus() tests: verify with acceptable data
    311     // bool pmChipSetFileStatus(pmChip *chip, bool status)
    312     {
    313         psMemId id = psMemGetId();
    314         // Generate the pmFPA heirarchy
    315         psMetadata *camera = psMetadataAlloc();
    316         pmFPA* fpa = generateSimpleFPA(camera);
    317         pmChip *chip = fpa->chips->data[0];
    318         pmCell *cell = chip->cells->data[0];
    319         ok(fpa != NULL, "Allocated a pmFPA successfully");
    320         ok(chip != NULL, "Allocated a pmChip successfully");
    321         ok(cell != NULL, "Allocated a pmCell successfully");
    322 
    323         // First, set all flags to FALSE
    324         bool correctStatus = false;
    325         bool rc = pmChipSetFileStatus(chip, correctStatus);
    326         ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params");
    327         bool errorFlag = false;
    328         if (chip->file_exists != correctStatus) {
    329             diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for chip param");
    330             errorFlag = true;
    331         }
    332         for (int j = 0 ; j < chip->cells->n ; j++) {
    333             pmCell *cell = chip->cells->data[j];
    334             if (cell->file_exists != correctStatus) {
    335                 diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d\n", j);
    336                 errorFlag = true;
    337             }
    338 
    339             for (int i = 0; i < cell->readouts->n; i++) {
    340                 pmReadout *readout = cell->readouts->data[i];
    341                 if (readout->file_exists != correctStatus) {
    342                     diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d readout %d\n", j, i);
    343                     errorFlag = true;
    344                 }
    345             }
    346         }
    347         ok(!errorFlag, "pmChipSetFileStatus() set file status in all cells to FALSE");
    348 
    349         // Second, set all flags to TRUE
    350         correctStatus = true;
    351         rc = pmChipSetFileStatus(chip, correctStatus);
    352         ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params");
    353         errorFlag = false;
    354         if (chip->file_exists != correctStatus) {
    355             diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for chip param");
    356             errorFlag = true;
    357         }
    358         for (int j = 0 ; j < chip->cells->n ; j++) {
    359             pmCell *cell = chip->cells->data[j];
    360             if (cell->file_exists != correctStatus) {
    361                 diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d\n", j);
    362                 errorFlag = true;
    363             }
    364 
    365             for (int i = 0; i < cell->readouts->n; i++) {
    366                 pmReadout *readout = cell->readouts->data[i];
    367                 if (readout->file_exists != correctStatus) {
    368                     diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d readout %d\n", j, i);
    369                     errorFlag = true;
    370                 }
    371             }
    372         }
    373         ok(!errorFlag, "pmChipSetFileStatus() set file status in all cells to TRUE");
    374 
    375         // Third, set all flags to FALSE
    376         correctStatus = false;
    377         rc = pmChipSetFileStatus(chip, correctStatus);
    378         ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params");
    379         errorFlag = false;
    380         if (chip->file_exists != correctStatus) {
    381             diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for chip param");
    382             errorFlag = true;
    383         }
    384         for (int j = 0 ; j < chip->cells->n ; j++) {
    385             pmCell *cell = chip->cells->data[j];
    386             if (cell->file_exists != correctStatus) {
    387                 diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d\n", j);
    388                 errorFlag = true;
    389             }
    390 
    391             for (int i = 0; i < cell->readouts->n; i++) {
    392                 pmReadout *readout = cell->readouts->data[i];
    393                 if (readout->file_exists != correctStatus) {
    394                     diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d readout %d\n", j, i);
    395                     errorFlag = true;
    396                 }
    397             }
    398         }
    399         ok(!errorFlag, "pmChipSetFileStatus() set file status in all cells to FALSE");
    400 
    401 
    402         myFreeFPA(fpa);
    403         psFree(camera);
    404         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    405     }
    406 
    407     // ----------------------------------------------------------------------
     243    plan_tests(107);
     244
     245
    408246    // ----------------------------------------------------------------------
    409247    // pmFPASetFileStatus() tests: verify with NULL pmFPA param
     
    505343        ok(!errorFlag, "pmFPASetFileStatus() set file status in all cells to FALSE");
    506344
    507         myFreeFPA(fpa);
     345        psFree(fpa);
    508346        psFree(camera);
    509347        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    510348    }
    511349
    512     // ----------------------------------------------------------------------
    513     // ----------------------------------------------------------------------
    514     // pmCellSetDataStatus() tests: verify with NULL pmCell param
    515     // bool pmCellSetDataStatus(pmCell *cell, bool status)
    516     {
    517         psMemId id = psMemGetId();
    518         bool rc = pmCellSetDataStatus(NULL, false);
    519         ok(!rc, "pmCellSetDataStatus() returned FALSE with NULL pmCell param");
    520         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    521     }
    522 
    523 
    524     // pmCellSetDataStatus() tests: verify with acceptable data
    525     // bool pmCellSetDataStatus(pmCell *cell, bool status)
     350
     351    // ----------------------------------------------------------------------
     352    // pmChipSetFileStatus() tests: verify with NULL pmChip param
     353    // bool pmChipSetFileStatus(pmChip *chip, bool status)
     354    {
     355        psMemId id = psMemGetId();
     356        bool rc = pmChipSetFileStatus(NULL, false);
     357        ok(!rc, "pmChipSetFileStatus() returned FALSE with NULL pmChip param");
     358        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     359    }
     360
     361
     362    // pmChipSetFileStatus() tests: verify with acceptable data
     363    // bool pmChipSetFileStatus(pmChip *chip, bool status)
    526364    {
    527365        psMemId id = psMemGetId();
     
    537375        // First, set all flags to FALSE
    538376        bool correctStatus = false;
    539         bool rc = pmCellSetDataStatus(cell, correctStatus);
    540         ok(rc, "pmCellSetDataStatus() returned successfully with acceptable input params");
     377        bool rc = pmChipSetFileStatus(chip, correctStatus);
     378        ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params");
    541379        bool errorFlag = false;
    542         if (cell->data_exists != correctStatus) {
    543             diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell param\n");
    544             errorFlag = true;
    545         }
    546         for (int i = 0; i < cell->readouts->n; i++) {
    547             pmReadout *readout = cell->readouts->data[i];
    548             if (readout->data_exists != correctStatus) {
    549                 diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell %d\n", i);
    550                 errorFlag = true;
    551             }
    552         }
    553         ok(!errorFlag, "pmCellSetDataStatus() set data status in all cells to FALSE");
     380        if (chip->file_exists != correctStatus) {
     381            diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for chip param");
     382            errorFlag = true;
     383        }
     384        for (int j = 0 ; j < chip->cells->n ; j++) {
     385            pmCell *cell = chip->cells->data[j];
     386            if (cell->file_exists != correctStatus) {
     387                diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d\n", j);
     388                errorFlag = true;
     389            }
     390
     391            for (int i = 0; i < cell->readouts->n; i++) {
     392                pmReadout *readout = cell->readouts->data[i];
     393                if (readout->file_exists != correctStatus) {
     394                    diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d readout %d\n", j, i);
     395                    errorFlag = true;
     396                }
     397            }
     398        }
     399        ok(!errorFlag, "pmChipSetFileStatus() set file status in all cells to FALSE");
    554400
    555401        // Second, set all flags to TRUE
    556402        correctStatus = true;
    557         rc = pmCellSetDataStatus(cell, correctStatus);
    558         ok(rc, "pmCellSetDataStatus() returned successfully with acceptable input params");
    559         errorFlag = false;
    560         if (cell->data_exists != correctStatus) {
    561             diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell param\n");
    562             errorFlag = true;
    563         }
    564         for (int i = 0; i < cell->readouts->n; i++) {
    565             pmReadout *readout = cell->readouts->data[i];
    566             if (readout->data_exists != correctStatus) {
    567                 diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell %d\n", i);
    568                 errorFlag = true;
    569             }
    570         }
    571         ok(!errorFlag, "pmCellSetDataStatus() set data status in all cells to TRUE");
     403        rc = pmChipSetFileStatus(chip, correctStatus);
     404        ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params");
     405        errorFlag = false;
     406        if (chip->file_exists != correctStatus) {
     407            diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for chip param");
     408            errorFlag = true;
     409        }
     410        for (int j = 0 ; j < chip->cells->n ; j++) {
     411            pmCell *cell = chip->cells->data[j];
     412            if (cell->file_exists != correctStatus) {
     413                diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d\n", j);
     414                errorFlag = true;
     415            }
     416
     417            for (int i = 0; i < cell->readouts->n; i++) {
     418                pmReadout *readout = cell->readouts->data[i];
     419                if (readout->file_exists != correctStatus) {
     420                    diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d readout %d\n", j, i);
     421                    errorFlag = true;
     422                }
     423            }
     424        }
     425        ok(!errorFlag, "pmChipSetFileStatus() set file status in all cells to TRUE");
    572426
    573427        // Third, set all flags to FALSE
    574428        correctStatus = false;
    575         rc = pmCellSetDataStatus(cell, correctStatus);
    576         ok(rc, "pmCellSetDataStatus() returned successfully with acceptable input params");
    577         errorFlag = false;
    578         if (cell->data_exists != correctStatus) {
    579             diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell param\n");
    580             errorFlag = true;
    581         }
    582         for (int i = 0; i < cell->readouts->n; i++) {
    583             pmReadout *readout = cell->readouts->data[i];
    584             if (readout->data_exists != correctStatus) {
    585                 diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for readout %d\n", i);
    586                 errorFlag = true;
    587             }
    588         }
    589         ok(!errorFlag, "pmCellSetDataStatus() set data status in all cells to FALSE");
    590 
    591         myFreeFPA(fpa);
     429        rc = pmChipSetFileStatus(chip, correctStatus);
     430        ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params");
     431        errorFlag = false;
     432        if (chip->file_exists != correctStatus) {
     433            diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for chip param");
     434            errorFlag = true;
     435        }
     436        for (int j = 0 ; j < chip->cells->n ; j++) {
     437            pmCell *cell = chip->cells->data[j];
     438            if (cell->file_exists != correctStatus) {
     439                diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d\n", j);
     440                errorFlag = true;
     441            }
     442
     443            for (int i = 0; i < cell->readouts->n; i++) {
     444                pmReadout *readout = cell->readouts->data[i];
     445                if (readout->file_exists != correctStatus) {
     446                    diag("TEST ERROR: pmChipSetFileStatus() failed to set file status for cell %d readout %d\n", j, i);
     447                    errorFlag = true;
     448                }
     449            }
     450        }
     451        ok(!errorFlag, "pmChipSetFileStatus() set file status in all cells to FALSE");
     452
     453
     454        psFree(fpa);
    592455        psFree(camera);
    593456        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    596459
    597460    // ----------------------------------------------------------------------
    598     // ----------------------------------------------------------------------
    599     // pmChipSetDataStatus() tests: verify with NULL pmChip param
    600     // bool pmChipSetDataStatus(pmChip *chip, bool status)
    601     {
    602         psMemId id = psMemGetId();
    603         bool rc = pmChipSetDataStatus(NULL, false);
    604         ok(!rc, "pmChipSetDataStatus() returned FALSE with NULL pmChip param");
    605         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    606     }
    607 
    608 
    609     // pmChipSetDataStatus() tests: verify with acceptable data
    610     // bool pmChipSetDataStatus(pmChip *chip, bool status)
     461    // pmCellSetFileStatus() tests: verify with NULL pmCell param
     462    {
     463        psMemId id = psMemGetId();
     464        bool rc = pmCellSetFileStatus(NULL, false);
     465        ok(!rc, "pmCellSetFileStatus() returned FALSE with NULL pmCell param");
     466        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     467    }
     468
     469
     470    // pmCellSetFileStatus() tests: verify with acceptable data
     471    // bool pmCellSetFileStatus(pmCell *cell, bool status)
    611472    {
    612473        psMemId id = psMemGetId();
     
    622483        // First, set all flags to FALSE
    623484        bool correctStatus = false;
    624         bool rc = pmChipSetDataStatus(chip, correctStatus);
    625         ok(rc, "pmChipSetDataStatus() returned successfully with acceptable input params");
     485        bool rc = pmCellSetFileStatus(cell, correctStatus);
     486        ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params");
    626487        bool errorFlag = false;
    627         if (chip->data_exists != correctStatus) {
    628             diag("TEST ERROR (a): pmChipSetDataStatus() failed to set file status for chip param\n");
    629             errorFlag = true;
    630         }
    631         for (int j = 0 ; j < chip->cells->n ; j++) {
    632             pmCell *cell = chip->cells->data[j];
    633             if (cell->data_exists != correctStatus) {
    634                 diag("TEST ERROR (b): pmChipSetDataStatus() failed to set file status for cell %d\n", j);
    635                 errorFlag = true;
    636             }
    637 
    638             for (int i = 0; i < cell->readouts->n; i++) {
    639                 pmReadout *readout = cell->readouts->data[i];
    640                 if (readout->data_exists != correctStatus) {
    641                     diag("TEST ERROR (c): pmChipSetDataStatus() failed to set file status for cell %d readout %d\n", j, i);
    642                     errorFlag = true;
    643                 }
    644             }
    645         }
    646         ok(!errorFlag, "pmChipSetDataStatus() set data status in all cells to FALSE");
     488        if (cell->file_exists != correctStatus) {
     489            diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell param\n");
     490            errorFlag = true;
     491        }
     492        for (int i = 0; i < cell->readouts->n; i++) {
     493
     494            pmReadout *readout = cell->readouts->data[i];
     495            if (readout->file_exists != correctStatus) {
     496                diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell %d\n", i);
     497                errorFlag = true;
     498            }
     499        }
     500        ok(!errorFlag, "pmCellSetFileStatus() set file status in all cells to FALSE");
    647501
    648502        // Second, set all flags to TRUE
    649503        correctStatus = true;
    650         rc = pmChipSetDataStatus(chip, correctStatus);
    651         ok(rc, "pmChipSetDataStatus() returned successfully with acceptable input params");
    652         errorFlag = false;
    653         if (chip->data_exists != correctStatus) {
    654             diag("TEST ERROR (a): pmChipSetDataStatus() failed to set file status for chip param\n");
    655             errorFlag = true;
    656         }
    657         for (int j = 0 ; j < chip->cells->n ; j++) {
    658             pmCell *cell = chip->cells->data[j];
    659             if (cell->data_exists != correctStatus) {
    660                 diag("TEST ERROR (b): pmChipSetDataStatus() failed to set file status for cell %d\n", j);
    661                 errorFlag = true;
    662             }
    663 
    664             for (int i = 0; i < cell->readouts->n; i++) {
    665                 pmReadout *readout = cell->readouts->data[i];
    666                 if (readout->data_exists != correctStatus) {
    667                     diag("TEST ERROR (c): pmChipSetDataStatus() failed to set file status for cell %d readout %d\n", j, i);
    668                     errorFlag = true;
    669                 }
    670             }
    671         }
    672         ok(!errorFlag, "pmChipSetDataStatus() set data status in all cells to TRUE");
    673 
    674         // ThirdSecond, set all flags to FALSE
     504        rc = pmCellSetFileStatus(cell, correctStatus);
     505        ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params");
     506        errorFlag = false;
     507        if (cell->file_exists != correctStatus) {
     508            diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell param\n");
     509            errorFlag = true;
     510        }
     511        for (int i = 0; i < cell->readouts->n; i++) {
     512            pmReadout *readout = cell->readouts->data[i];
     513            if (readout->file_exists != correctStatus) {
     514                diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell %d\n", i);
     515                errorFlag = true;
     516            }
     517        }
     518        ok(!errorFlag, "pmCellSetFileStatus() set file status in all cells to TRUE");
     519
     520        // Third, set all flags to FALSE
    675521        correctStatus = false;
    676         rc = pmChipSetDataStatus(chip, correctStatus);
    677         ok(rc, "pmChipSetDataStatus() returned successfully with acceptable input params");
    678         errorFlag = false;
    679         if (chip->data_exists != correctStatus) {
    680             diag("TEST ERROR (a): pmChipSetDataStatus() failed to set file status for chip param\n");
    681             errorFlag = true;
    682         }
    683         for (int j = 0 ; j < chip->cells->n ; j++) {
    684             pmCell *cell = chip->cells->data[j];
    685             if (cell->data_exists != correctStatus) {
    686                 diag("TEST ERROR (b): pmChipSetDataStatus() failed to set file status for cell %d\n", j);
    687                 errorFlag = true;
    688             }
    689 
    690             for (int i = 0; i < cell->readouts->n; i++) {
    691                 pmReadout *readout = cell->readouts->data[i];
    692                 if (readout->data_exists != correctStatus) {
    693                     diag("TEST ERROR (c): pmChipSetDataStatus() failed to set file status for cell %d readout %d\n", j, i);
    694                     errorFlag = true;
    695                 }
    696             }
    697         }
    698         ok(!errorFlag, "pmChipSetDataStatus() set data status in all cells to FALSE");
    699 
    700 
    701         myFreeFPA(fpa);
     522        rc = pmCellSetFileStatus(cell, correctStatus);
     523        ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params");
     524        errorFlag = false;
     525        if (cell->file_exists != correctStatus) {
     526            diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for cell param\n");
     527            errorFlag = true;
     528        }
     529        for (int i = 0; i < cell->readouts->n; i++) {
     530            pmReadout *readout = cell->readouts->data[i];
     531            if (readout->file_exists != correctStatus) {
     532                diag("TEST ERROR: pmCellSetFileStatus() failed to set file status for readout %d\n", i);
     533                errorFlag = true;
     534            }
     535        }
     536        ok(!errorFlag, "pmCellSetFileStatus() set file status in all cells to FALSE");
     537
     538        psFree(fpa);
    702539        psFree(camera);
    703540        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    704541    }
    705542
    706     // ----------------------------------------------------------------------
    707     // ----------------------------------------------------------------------
    708     // pmFPASetFileStatus() tests: verify with NULL pmFPA param
    709     // bool pmFPASetFileStatus(pmFPA *fpa, bool status)
    710     {
    711         psMemId id = psMemGetId();
    712         bool rc = pmFPASetFileStatus(NULL, false);
    713         ok(!rc, "pmFPASetFileStatus() returned FALSE with NULL pmFPA param");
    714         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    715     }
    716 
    717 
     543
     544    // ----------------------------------------------------------------------
     545    // pmFPACheckFileStatus() tests
     546    // bool pmFPACheckFileStatus(const pmFPA *fpa)
     547    // Call with NULL pmFPA input parameter
     548    {
     549        psMemId id = psMemGetId();
     550        bool rc = pmFPACheckFileStatus(NULL);
     551        ok(rc == false, "pmFPACheckFileStatus() returned FALSE with NULL pmFPA input parameter");
     552        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     553    }
     554
     555
     556    // Call with acceptable input parameters
     557    {
     558        psMemId id = psMemGetId();
     559        pmFPA *fpa = generateSimpleFPA(NULL);
     560        bool rc = pmFPACheckFileStatus(fpa);
     561        ok(rc == false, "pmFPACheckFileStatus() returned FALSE with NULL pmFPA input parameter");
     562        SetFPAFileExists(fpa);
     563        rc = pmFPACheckFileStatus(fpa);
     564        ok(rc == true, "pmFPACheckFileStatus() returned TRUE with NULL pmFPA input parameter");
     565        psFree(fpa);
     566        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     567    }
     568
     569
     570    // ----------------------------------------------------------------------
     571    // pmChipCheckFileStatus() tests
     572    // Call with NULL pmChip input parameter
     573    {
     574        psMemId id = psMemGetId();
     575        bool rc = pmChipCheckFileStatus(NULL);
     576        ok(rc == false, "pmChipCheckFileStatus() returned FALSE with NULL pmChip input parameter");
     577        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     578    }
     579
     580
     581    // Call with acceptable input parameter
     582    {
     583        psMemId id = psMemGetId();
     584        pmChip *chip = generateSimpleChip(NULL);
     585        bool rc = pmChipCheckFileStatus(chip);
     586        ok(rc == false, "pmChipCheckFileStatus() returned FALSE with NULL pmChip input parameter");
     587        SetChipFileExists(chip);
     588        rc = pmChipCheckFileStatus(chip);
     589        ok(rc == true, "pmChipCheckFileStatus() returned TRUE with NULL pmChip input parameter");
     590        psFree(chip);
     591        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     592    }
     593
     594
     595    // ----------------------------------------------------------------------
     596    // pmCellCheckFileStatus() tests
     597    // bool pmCellCheckFileStatus(const pmCell *cell)
     598    // Call with NULL pmCell input parameter
     599    {
     600        psMemId id = psMemGetId();
     601        bool rc = pmCellCheckFileStatus(NULL);
     602        ok(rc == false, "pmCellCheckFileStatus() returned FALSE with NULL pmCell input parameter");
     603        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     604    }
     605
     606
     607    // Call with acceptable input parameters
     608    {
     609        psMemId id = psMemGetId();
     610        pmCell *cell = generateSimpleCell(NULL);
     611        bool rc = pmCellCheckFileStatus(cell);
     612        ok(rc == false, "pmCellCheckFileStatus() returned FALSE with acceptable input parameters");
     613        SetCellFileExists(cell);
     614        rc = pmCellCheckFileStatus(cell);
     615        ok(rc == true, "pmCellCheckFileStatus() returned TRUE with acceptable input parameters");
     616        psFree(cell);
     617        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     618    }
     619
     620
     621    // ----------------------------------------------------------------------
     622    // pmFPASetDataStatus() tests: verify with NULL pmFPA param
     623    {
     624        psMemId id = psMemGetId();
     625        bool rc = pmFPASetDataStatus(NULL, false);
     626        ok(!rc, "pmFPASetDataStatus() returned FALSE with NULL pmFPA param");
     627        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     628    }
    718629
    719630
     
    806717        ok(!errorFlag, "pmFPASetDataStatus() set file status in all cells to FALSE");
    807718
    808         myFreeFPA(fpa);
     719        psFree(fpa);
    809720        psFree(camera);
    810721        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    811722    }
    812723
    813 }
     724
     725    // ----------------------------------------------------------------------
     726    // pmChipSetDataStatus() tests: verify with NULL pmChip param
     727    // bool pmChipSetDataStatus(pmChip *chip, bool status)
     728    {
     729        psMemId id = psMemGetId();
     730        bool rc = pmChipSetDataStatus(NULL, false);
     731        ok(!rc, "pmChipSetDataStatus() returned FALSE with NULL pmChip param");
     732        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     733    }
     734
     735
     736    // pmChipSetDataStatus() tests: verify with acceptable data
     737    // bool pmChipSetDataStatus(pmChip *chip, bool status)
     738    {
     739        psMemId id = psMemGetId();
     740        // Generate the pmFPA heirarchy
     741        psMetadata *camera = psMetadataAlloc();
     742        pmFPA* fpa = generateSimpleFPA(camera);
     743        pmChip *chip = fpa->chips->data[0];
     744        pmCell *cell = chip->cells->data[0];
     745        ok(fpa != NULL, "Allocated a pmFPA successfully");
     746        ok(chip != NULL, "Allocated a pmChip successfully");
     747        ok(cell != NULL, "Allocated a pmCell successfully");
     748
     749        // First, set all flags to FALSE
     750        bool correctStatus = false;
     751        bool rc = pmChipSetDataStatus(chip, correctStatus);
     752        ok(rc, "pmChipSetDataStatus() returned successfully with acceptable input params");
     753        bool errorFlag = false;
     754        if (chip->data_exists != correctStatus) {
     755            diag("TEST ERROR (a): pmChipSetDataStatus() failed to set file status for chip param\n");
     756            errorFlag = true;
     757        }
     758        for (int j = 0 ; j < chip->cells->n ; j++) {
     759            pmCell *cell = chip->cells->data[j];
     760            if (cell->data_exists != correctStatus) {
     761                diag("TEST ERROR (b): pmChipSetDataStatus() failed to set file status for cell %d\n", j);
     762                errorFlag = true;
     763            }
     764
     765            for (int i = 0; i < cell->readouts->n; i++) {
     766                pmReadout *readout = cell->readouts->data[i];
     767                if (readout->data_exists != correctStatus) {
     768                    diag("TEST ERROR (c): pmChipSetDataStatus() failed to set file status for cell %d readout %d\n", j, i);
     769                    errorFlag = true;
     770                }
     771            }
     772        }
     773        ok(!errorFlag, "pmChipSetDataStatus() set data status in all cells to FALSE");
     774
     775        // Second, set all flags to TRUE
     776        correctStatus = true;
     777        rc = pmChipSetDataStatus(chip, correctStatus);
     778        ok(rc, "pmChipSetDataStatus() returned successfully with acceptable input params");
     779        errorFlag = false;
     780        if (chip->data_exists != correctStatus) {
     781            diag("TEST ERROR (a): pmChipSetDataStatus() failed to set file status for chip param\n");
     782            errorFlag = true;
     783        }
     784        for (int j = 0 ; j < chip->cells->n ; j++) {
     785            pmCell *cell = chip->cells->data[j];
     786            if (cell->data_exists != correctStatus) {
     787                diag("TEST ERROR (b): pmChipSetDataStatus() failed to set file status for cell %d\n", j);
     788                errorFlag = true;
     789            }
     790
     791            for (int i = 0; i < cell->readouts->n; i++) {
     792                pmReadout *readout = cell->readouts->data[i];
     793                if (readout->data_exists != correctStatus) {
     794                    diag("TEST ERROR (c): pmChipSetDataStatus() failed to set file status for cell %d readout %d\n", j, i);
     795                    errorFlag = true;
     796                }
     797            }
     798        }
     799        ok(!errorFlag, "pmChipSetDataStatus() set data status in all cells to TRUE");
     800
     801        // ThirdSecond, set all flags to FALSE
     802        correctStatus = false;
     803        rc = pmChipSetDataStatus(chip, correctStatus);
     804        ok(rc, "pmChipSetDataStatus() returned successfully with acceptable input params");
     805        errorFlag = false;
     806        if (chip->data_exists != correctStatus) {
     807            diag("TEST ERROR (a): pmChipSetDataStatus() failed to set file status for chip param\n");
     808            errorFlag = true;
     809        }
     810        for (int j = 0 ; j < chip->cells->n ; j++) {
     811            pmCell *cell = chip->cells->data[j];
     812            if (cell->data_exists != correctStatus) {
     813                diag("TEST ERROR (b): pmChipSetDataStatus() failed to set file status for cell %d\n", j);
     814                errorFlag = true;
     815            }
     816
     817            for (int i = 0; i < cell->readouts->n; i++) {
     818                pmReadout *readout = cell->readouts->data[i];
     819                if (readout->data_exists != correctStatus) {
     820                    diag("TEST ERROR (c): pmChipSetDataStatus() failed to set file status for cell %d readout %d\n", j, i);
     821                    errorFlag = true;
     822                }
     823            }
     824        }
     825        ok(!errorFlag, "pmChipSetDataStatus() set data status in all cells to FALSE");
     826
     827
     828        psFree(fpa);
     829        psFree(camera);
     830        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     831    }
     832
     833
     834    // ----------------------------------------------------------------------
     835    // pmCellSetDataStatus() tests: verify with NULL pmCell param
     836    // bool pmCellSetDataStatus(pmCell *cell, bool status)
     837    {
     838        psMemId id = psMemGetId();
     839        bool rc = pmCellSetDataStatus(NULL, false);
     840        ok(!rc, "pmCellSetDataStatus() returned FALSE with NULL pmCell param");
     841        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     842    }
     843
     844
     845    // pmCellSetDataStatus() tests: verify with acceptable data
     846    // bool pmCellSetDataStatus(pmCell *cell, bool status)
     847    {
     848        psMemId id = psMemGetId();
     849        // Generate the pmFPA heirarchy
     850        psMetadata *camera = psMetadataAlloc();
     851        pmFPA* fpa = generateSimpleFPA(camera);
     852        pmChip *chip = fpa->chips->data[0];
     853        pmCell *cell = chip->cells->data[0];
     854        ok(fpa != NULL, "Allocated a pmFPA successfully");
     855        ok(chip != NULL, "Allocated a pmChip successfully");
     856        ok(cell != NULL, "Allocated a pmCell successfully");
     857
     858        // First, set all flags to FALSE
     859        bool correctStatus = false;
     860        bool rc = pmCellSetDataStatus(cell, correctStatus);
     861        ok(rc, "pmCellSetDataStatus() returned successfully with acceptable input params");
     862        bool errorFlag = false;
     863        if (cell->data_exists != correctStatus) {
     864            diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell param\n");
     865            errorFlag = true;
     866        }
     867        for (int i = 0; i < cell->readouts->n; i++) {
     868            pmReadout *readout = cell->readouts->data[i];
     869            if (readout->data_exists != correctStatus) {
     870                diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell %d\n", i);
     871                errorFlag = true;
     872            }
     873        }
     874        ok(!errorFlag, "pmCellSetDataStatus() set data status in all cells to FALSE");
     875
     876        // Second, set all flags to TRUE
     877        correctStatus = true;
     878        rc = pmCellSetDataStatus(cell, correctStatus);
     879        ok(rc, "pmCellSetDataStatus() returned successfully with acceptable input params");
     880        errorFlag = false;
     881        if (cell->data_exists != correctStatus) {
     882            diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell param\n");
     883            errorFlag = true;
     884        }
     885        for (int i = 0; i < cell->readouts->n; i++) {
     886            pmReadout *readout = cell->readouts->data[i];
     887            if (readout->data_exists != correctStatus) {
     888                diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell %d\n", i);
     889                errorFlag = true;
     890            }
     891        }
     892        ok(!errorFlag, "pmCellSetDataStatus() set data status in all cells to TRUE");
     893
     894        // Third, set all flags to FALSE
     895        correctStatus = false;
     896        rc = pmCellSetDataStatus(cell, correctStatus);
     897        ok(rc, "pmCellSetDataStatus() returned successfully with acceptable input params");
     898        errorFlag = false;
     899        if (cell->data_exists != correctStatus) {
     900            diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for cell param\n");
     901            errorFlag = true;
     902        }
     903        for (int i = 0; i < cell->readouts->n; i++) {
     904            pmReadout *readout = cell->readouts->data[i];
     905            if (readout->data_exists != correctStatus) {
     906                diag("TEST ERROR: pmCellSetDataStatus() failed to set file status for readout %d\n", i);
     907                errorFlag = true;
     908            }
     909        }
     910        ok(!errorFlag, "pmCellSetDataStatus() set data status in all cells to FALSE");
     911
     912        psFree(fpa);
     913        psFree(camera);
     914        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     915    }
     916
     917
     918    // ----------------------------------------------------------------------
     919    // pmFPACheckDataStatus() tests
     920    // bool pmFPACheckDataStatus(const pmFPA *fpa)
     921    // Call with NULL pmFPA input parameter
     922    {
     923        psMemId id = psMemGetId();
     924        bool rc = pmFPACheckDataStatus(NULL);
     925        ok(rc == false, "pmFPACheckDataStatus() returned FALSE with NULL pmFPA input parameter");
     926        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     927    }
     928
     929
     930    // Call with acceptable input parameters
     931    {
     932        psMemId id = psMemGetId();
     933        pmFPA *fpa = generateSimpleFPA(NULL);
     934        bool rc = pmFPACheckDataStatus(fpa);
     935        ok(rc == false, "pmFPACheckDataStatus() returned FALSE with NULL pmFPA input parameter");
     936        SetFPADataExists(fpa);
     937        rc = pmFPACheckDataStatus(fpa);
     938        ok(rc == true, "pmFPACheckDataStatus() returned TRUE with NULL pmFPA input parameter");
     939        psFree(fpa);
     940        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     941    }
     942
     943
     944    // ----------------------------------------------------------------------
     945    // pmChipCheckDataStatus() tests
     946    // Call with NULL pmChip input parameter
     947    {
     948        psMemId id = psMemGetId();
     949        bool rc = pmChipCheckDataStatus(NULL);
     950        ok(rc == false, "pmChipCheckDataStatus() returned FALSE with NULL pmChip input parameter");
     951        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     952    }
     953
     954
     955    // Call with acceptable input parameter
     956    {
     957        psMemId id = psMemGetId();
     958        pmChip *chip = generateSimpleChip(NULL);
     959        bool rc = pmChipCheckDataStatus(chip);
     960        ok(rc == false, "pmChipCheckDataStatus() returned FALSE with NULL pmChip input parameter");
     961        SetChipDataExists(chip);
     962        rc = pmChipCheckDataStatus(chip);
     963        ok(rc == true, "pmChipCheckDataStatus() returned TRUE with NULL pmChip input parameter");
     964        psFree(chip);
     965        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     966    }
     967
     968
     969    // ----------------------------------------------------------------------
     970    // pmCellCheckDataStatus() tests
     971    // bool pmCellCheckDataStatus(const pmCell *cell)
     972    // Call with NULL pmCell input parameter
     973    {
     974        psMemId id = psMemGetId();
     975        bool rc = pmCellCheckDataStatus(NULL);
     976        ok(rc == false, "pmCellCheckDataStatus() returned FALSE with NULL pmCell input parameter");
     977        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     978    }
     979
     980
     981    // Call with acceptable input parameters
     982    {
     983        psMemId id = psMemGetId();
     984        pmCell *cell = generateSimpleCell(NULL);
     985        bool rc = pmCellCheckDataStatus(cell);
     986        ok(rc == false, "pmCellCheckDataStatus() returned FALSE with acceptable input parameters");
     987        SetCellDataExists(cell);
     988        rc = pmCellCheckDataStatus(cell);
     989        ok(rc == true, "pmCellCheckDataStatus() returned TRUE with acceptable input parameters");
     990        psFree(cell);
     991        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     992    }
     993
     994
     995    // ----------------------------------------------------------------------
     996    // pmReadoutCheckDataStatus() tests
     997    // bool pmReadoutCheckDataStatus(const pmReadout *readout)
     998    // Call with NULL pmReadout input parameter
     999    {
     1000        psMemId id = psMemGetId();
     1001        bool rc = pmReadoutCheckDataStatus(NULL);
     1002        ok(rc == false, "pmReadoutCheckDataStatus() returned FALSE with NULL pmReadout input parameter");
     1003        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1004    }
     1005
     1006
     1007    // Call with acceptable input parameters
     1008    {
     1009        psMemId id = psMemGetId();
     1010        pmReadout *readout = generateSimpleReadout(NULL);
     1011        bool rc = pmReadoutCheckDataStatus(readout);
     1012        ok(rc == false, "pmReadoutCheckDataStatus() returned FALSE with acceptable input parameters");
     1013        SetReadoutDataExists(readout);
     1014        rc = pmReadoutCheckDataStatus(readout);
     1015        ok(rc == true, "pmReadoutCheckDataStatus() returned TRUE with acceptable input parameters");
     1016        psFree(readout);
     1017        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     1018    }
     1019}
  • trunk/psModules/test/camera/tap_pmFPAHeader.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
    12 // XXX: For the genSimpleFPA() code, add IDs to each function so that
    13 // the values set in each chip-?cell-?hdu-?image are unique
    14 // XXX: For the genSimpleFPA() code, write masks and weights as well
     7/* STATUS:
     8    All functions are tested.
     9*/
    1510
    1611#define CHIP_ALLOC_NAME        "ChipName"
     
    8479    cell->hdu = pmHDUAlloc(extname);
    8580    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    86         cell->readouts->data[i] = generateSimpleReadout(cell);
    87     }
    88 
    89     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     81        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     82    }
     83
     84    // First try to read data from ../dataFiles, then try dataFiles.
     85    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    9086    if (!rc) {
    91         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     87        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     88        if (!rc) {
     89            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     90        }
    9291    }
    9392
     
    104103    }
    105104
    106     //XXX: Should the region be set some other way?  Like through the various config files?
    107 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    108105    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    109     // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     106    // You shouldn't have to remove the key from the metadata.
    110107    psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC");
    111108    psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region);
     
    134131    psArrayRealloc(chip->cells, NUM_CELLS);
    135132    for (int i = 0 ; i < NUM_CELLS ; i++) {
    136         chip->cells->data[i] = generateSimpleCell(chip, i);
    137     }
    138 
    139     // XXX: Add code to initialize chip pmConcepts
    140 
    141 
     133        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip, i));
     134    }
    142135    return(chip);
    143136}
     
    156149    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    157150    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    158 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    159 //
    160 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    161 //    if (!rc) {
    162 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    163 //    }
    164151
    165152    psArrayRealloc(fpa->chips, NUM_CHIPS);
    166153    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    167         fpa->chips->data[i] = generateSimpleChip(fpa, i);
    168     }
    169 
    170     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    171     // reading code from wherever.
     154        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa, i));
     155    }
    172156    pmConceptsBlankFPA(fpa);
    173 //    bool mdok;
    174 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    175 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    176 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    177 
    178157    return(fpa);
    179158}
    180159
    181 // XXX: This should only be necessary until the psFree() functions for
    182 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    183 void myFreeCell(pmCell *cell)
    184 {
    185     for (int k = 0 ; k < cell->readouts->n ; k++) {
    186         psFree(cell->readouts->data[k]);
    187     }
    188     psFree(cell);
    189 }
    190 
    191 void myFreeChip(pmChip *chip) {
    192     for (int j = 0 ; j < chip->cells->n ; j++) {
    193         myFreeCell(chip->cells->data[j]);
    194     }
    195     psFree(chip);
    196 }
    197 
    198 void myFreeFPA(pmFPA *fpa)
    199 {
    200     for (int i = 0 ; i < fpa->chips->n ; i++) {
    201         myFreeChip(fpa->chips->data[i]);
    202     }
    203     psFree(fpa);
    204 }
    205160
    206161
     
    210165    psLogSetLevel(PS_LOG_INFO);
    211166    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    212     plan_tests(25);
     167    plan_tests(75);
    213168
    214169
     
    225180        ok(cell != NULL, "Allocated a pmCell successfully");
    226181        ok(!pmCellReadHeader(cell, NULL), "pmCellReadHeader(cell, NULL) returned FALSE");
    227         myFreeFPA(fpa);
     182        psFree(fpa);
    228183        psFree(camera);
    229184        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    245200    {
    246201        psMemId id = psMemGetId();
    247 
    248202        // Create a FITS file for this test
    249203        psFits* fitsFileW = psFitsOpen(fitsFilename, "w");
     
    264218            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    265219                         "String Item", extname);
    266             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     220            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     221            if (!rc) {
     222                rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     223            }
    267224            ok(rc == true, "pmConfigFileRead() was successful");
    268225            rc = pmHDUWrite(hdu, fitsFileW);
     
    289246        // elsewhere.  However, if we should test it, test it here.
    290247
    291         myFreeFPA(fpa);
     248        psFree(fpa);
    292249        psFree(camera);
    293250        psFree(fitsFileR);
     
    308265        ok(cell != NULL, "Allocated a pmCell successfully");
    309266        ok(!pmChipReadHeader(chip, NULL), "pmChipReadHeader(chip, NULL) returned FALSE");
    310         myFreeFPA(fpa);
     267        psFree(fpa);
    311268        psFree(camera);
    312269        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    347304            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    348305                         "String Item", extname);
    349             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     306            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     307            if (!rc) {
     308               rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     309            }
    350310            ok(rc == true, "pmConfigFileRead() was successful");
    351311            rc = pmHDUWrite(hdu, fitsFileW);
     
    382342        // elsewhere.  However, if we should test it, test it here.
    383343
    384         myFreeFPA(fpa);
     344        psFree(fpa);
    385345        psFree(camera);
    386346        psFree(fitsFileR);
     
    401361        ok(cell != NULL, "Allocated a pmCell successfully");
    402362        ok(!pmFPAReadHeader(fpa, NULL), "pmFPAReadHeader(fpa, NULL) returned FALSE");
    403         myFreeFPA(fpa);
     363        psFree(fpa);
    404364        psFree(camera);
    405365        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    440400            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    441401                         "String Item", extname);
    442             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     402            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     403            if (!rc) {
     404                rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     405            }
    443406            ok(rc == true, "pmConfigFileRead() was successful");
    444407            rc = pmHDUWrite(hdu, fitsFileW);
     
    476439        // elsewhere.  However, if we should test it, test it here.
    477440
    478         myFreeFPA(fpa);
     441        psFree(fpa);
    479442        psFree(camera);
    480443        psFree(fitsFileR);
    481444        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    482445    }
    483 
    484 
    485 
    486 
    487 }
    488 
     446}
     447
  • trunk/psModules/test/camera/tap_pmFPALevel.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
     7/* STATUS:
     8    All functions are tested.
     9    XXX: Add tests for bad input parameters.
     10*/
    711
    812#define ERR_TRACE_LEVEL         0
     
    1317    psLogSetLevel(PS_LOG_INFO);
    1418    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    15     plan_tests(15);
     19    plan_tests(14);
    1620
    17     // ----------------------------------------------------------------------
    1821    // ----------------------------------------------------------------------
    1922    // pmFPALevelToName(): tests
     
    4346
    4447        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    45         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    4648    }
    4749
    4850
    4951    // ----------------------------------------------------------------------
    50     // ----------------------------------------------------------------------
    5152    // pmFPALevelFromName(): tests
    52     // pmFPALevel pmFPALevelFromName(const char *name)
    5353    {
    5454        psMemId id = psMemGetId();
  • trunk/psModules/test/camera/tap_pmFPAMaskW.c

    r14882 r15987  
    66#include "pstap.h"
    77// XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
    128// XXX: For the genSimpleFPA() code, add IDs to each function so that
    139// the values set in each chip-?cell-?hdu-?image are unique
     
    9894    cell->hdu = pmHDUAlloc("cellExtName");
    9995    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    100         cell->readouts->data[i] = generateSimpleReadout(cell);
    101     }
    102 
    103     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     96        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     97    }
     98
     99    // First try to read data from ../dataFiles, then try dataFiles.
     100    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    104101    if (!rc) {
    105         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     102        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     103        if (!rc) {
     104            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     105        }
    106106    }
    107107
     
    119119
    120120    //XXX: Should the region be set some other way?  Like through the various config files?
    121 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    122121    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    123     // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     122    // You shouldn't have to remove the key from the metadata.
    124123    psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC");
    125124    psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region);
     
    139138    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    140139    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    141 //    chip->hdu = pmHDUAlloc("chipExtName");
    142 //
    143 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    144 //    if (!rc) {
    145 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    146 //    }
    147 //
     140
    148141    psArrayRealloc(chip->cells, NUM_CELLS);
    149142    for (int i = 0 ; i < NUM_CELLS ; i++) {
    150         chip->cells->data[i] = generateSimpleCell(chip);
    151     }
    152 
    153     // XXX: Add code to initialize chip pmConcepts
    154 
    155 
     143        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
     144    }
    156145    return(chip);
    157146}
     
    170159    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    171160    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    172 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    173 //
    174 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    175 //    if (!rc) {
    176 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    177 //    }
    178161
    179162    psArrayRealloc(fpa->chips, NUM_CHIPS);
    180163    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    181         fpa->chips->data[i] = generateSimpleChip(fpa);
    182     }
    183 
    184     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    185     // reading code from wherever.
     164        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     165    }
    186166    pmConceptsBlankFPA(fpa);
    187 //    bool mdok;
    188 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    189 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    190 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    191 
    192167    return(fpa);
    193 }
    194 
    195 // XXX: This should only be necessary until the psFree() functions for
    196 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    197 void myFreeCell(pmCell *cell)
    198 {
    199     for (int k = 0 ; k < cell->readouts->n ; k++) {
    200         psFree(cell->readouts->data[k]);
    201     }
    202     psFree(cell);
    203 }
    204 
    205 void myFreeChip(pmChip *chip) {
    206     for (int j = 0 ; j < chip->cells->n ; j++) {
    207         myFreeCell(chip->cells->data[j]);
    208     }
    209     psFree(chip);
    210 }
    211 
    212 void myFreeFPA(pmFPA *fpa)
    213 {
    214     for (int i = 0 ; i < fpa->chips->n ; i++) {
    215         myFreeChip(fpa->chips->data[i]);
    216     }
    217     psFree(fpa);
    218168}
    219169
     
    309259        }
    310260        ok(!errorFlag, "pmReadoutSetMask() set the mask values correctly");
    311         myFreeFPA(fpa);   
     261        psFree(fpa);   
    312262        psFree(camera);
    313263        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    395345        ok(!errorFlag, "pmReadoutGenerateMask() set the mask values correctly");
    396346
    397         myFreeFPA(fpa);   
     347        psFree(fpa);   
    398348        psFree(camera);
    399349        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    467417
    468418        ok(!errorFlag, "pmReadoutSetWeight() set the weight values correctly (Poisson)");
    469         myFreeFPA(fpa);   
     419        psFree(fpa);   
    470420        psFree(camera);
    471421        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    472422    }
    473 
    474 
    475 
    476 }
    477 
     423}
     424
  • trunk/psModules/test/camera/tap_pmFPAReadWrite.c

    r14882 r15987  
    2929#define BASE_WEIGHT             70
    3030#define VERBOSE                 0
    31 #define ERR_TRACE_LEVEL         0
     31#define ERR_TRACE_LEVEL         10
    3232
    3333psPlaneTransform *PS_CREATE_2D_IDENTITY_PLANE_TRANSFORM()
     
    8080    cell->hdu = pmHDUAlloc("cellExtName");
    8181    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    82         cell->readouts->data[i] = generateSimpleReadout(cell);
    83     }
    84 
    85     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     82        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     83    }
     84
     85    // First try to read data from ../dataFiles, then try dataFiles.
     86    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    8687    if (!rc) {
    87         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     88        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     89        if (!rc) {
     90            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     91        }
    8892    }
    8993
     
    101105
    102106    //XXX: Should the region be set some other way?  Like through the various config files?
    103 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    104107    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    105108    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     
    121124    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    122125    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    123 //    chip->hdu = pmHDUAlloc("chipExtName");
    124 //
    125 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    126 //    if (!rc) {
    127 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    128 //    }
    129 //
     126
    130127    psArrayRealloc(chip->cells, NUM_CELLS);
    131128    for (int i = 0 ; i < NUM_CELLS ; i++) {
    132         chip->cells->data[i] = generateSimpleCell(chip);
     129        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
    133130    }
    134131
     
    152149    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    153150    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    154 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    155 //
    156 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    157 //    if (!rc) {
    158 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    159 //    }
    160151
    161152    psArrayRealloc(fpa->chips, NUM_CHIPS);
    162153    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    163         fpa->chips->data[i] = generateSimpleChip(fpa);
    164     }
    165 
    166     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    167     // reading code from wherever.
     154        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     155    }
    168156    pmConceptsBlankFPA(fpa);
    169 //    bool mdok;
    170 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    171 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    172 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    173 
    174157    return(fpa);
    175 }
    176 
    177 // XXX: This should only be necessary until the psFree() functions for
    178 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    179 void myFreeCell(pmCell *cell)
    180 {
    181     for (int k = 0 ; k < cell->readouts->n ; k++) {
    182         psFree(cell->readouts->data[k]);
    183     }
    184     psFree(cell);
    185 }
    186 
    187 void myFreeChip(pmChip *chip) {
    188     for (int j = 0 ; j < chip->cells->n ; j++) {
    189         myFreeCell(chip->cells->data[j]);
    190     }
    191     psFree(chip);
    192 }
    193 
    194 void myFreeFPA(pmFPA *fpa)
    195 {
    196     for (int i = 0 ; i < fpa->chips->n ; i++) {
    197         myFreeChip(fpa->chips->data[i]);
    198     }
    199     psFree(fpa);
    200158}
    201159
     
    206164    psLogSetLevel(PS_LOG_INFO);
    207165    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    208     plan_tests(405);
     166    plan_tests(22);
    209167
    210168    // ----------------------------------------------------------------------
     
    212170    // pmCellWrite(): tests
    213171    // Verify pmCellWrite() with NULL pmCell arg
    214     {
     172    if (0) {
    215173        psMemId id = psMemGetId();
    216174        psFits* fitsFileW = psFitsOpen(".tmp00", "w");
     
    220178    }
    221179
     180
    222181    // Verify pmCellWrite() with NULL pmCell arg
    223182    // XXXX: Big problem: Without the next code, everything else fails.  Why?
    224     if (1) {
     183    if (0) {
    225184        psMemId id = psMemGetId();
    226185        psFits* fitsFileW = psFitsOpen(".tmp00", "w");
     
    232191
    233192    // Verify pmCellWrite() with NULL pmFits arg
    234     {
     193    if (0) {
    235194        psMemId id = psMemGetId();
    236195        psMetadata *camera = psMetadataAlloc();
     
    240199        ok(cell != NULL, "Allocated a pmCell successfully");
    241200        ok(!pmCellWrite(cell, NULL, NULL, false), "pmCellWrite() returned FALSE with NULL psFits param");
    242         myFreeFPA(fpa);
     201        psFree(fpa);
    243202        psFree(camera);
    244203        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    265224        //  Close the FITS file, free memory
    266225        psFitsClose(fitsFileW);
    267         myFreeFPA(fpa);
    268         psFree(camera);
    269         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    270     }
    271 
     226        psFree(fpa);
     227        psFree(camera);
     228        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     229    }
    272230
    273231    // ----------------------------------------------------------------------
     
    291249        pmCell *cell = chip->cells->data[0];
    292250        ok(!pmCellRead(cell, NULL, NULL), "pmCellRead() returned FALSE with NULL pmFits param");
    293         myFreeFPA(fpa);
     251        psFree(fpa);
    294252        psFree(camera);
    295253        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    313271        rc = pmCellRead(cell, fitsFileR, NULL);
    314272        ok(rc, "pmCellRead() returned TRUE");
     273        skip_start(!rc, 1, "Skipping tests because pmCellRead returned NULL");
    315274        for (int k = 0 ; k < cell->hdu->images->n ; k++) {
    316275            bool errorFlag = false;
     
    327286            ok(!errorFlag, "pmCellWrite()/pmCellRead() properly set the image data (image %d)", k);
    328287        }
    329         psFitsClose(fitsFileR);
    330         myFreeFPA(fpa);
     288        skip_end();
     289        psFitsClose(fitsFileR);
     290        psFree(fpa);
    331291        psFree(camera);
    332292        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    356316        ok(cell != NULL, "Allocated a pmCell successfully");
    357317        ok(!pmCellWriteWeight(cell, NULL, NULL, false), "pmCellWriteWeight() returned FALSE with NULL psFits param");
    358         myFreeFPA(fpa);
     318        psFree(fpa);
    359319        psFree(camera);
    360320        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    381341        //  Close the FITS file, free memory
    382342        psFitsClose(fitsFileW);
    383         myFreeFPA(fpa);
     343        psFree(fpa);
    384344        psFree(camera);
    385345        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    407367        pmCell *cell = chip->cells->data[0];
    408368        ok(!pmCellReadWeight(cell, NULL, NULL), "pmCellReadWeight() returned FALSE with NULL pmFits param");
    409         myFreeFPA(fpa);
     369        psFree(fpa);
    410370        psFree(camera);
    411371        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    444404        }
    445405        psFitsClose(fitsFileR);
    446         myFreeFPA(fpa);
     406        psFree(fpa);
    447407        psFree(camera);
    448408        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    473433        ok(cell != NULL, "Allocated a pmCell successfully");
    474434        ok(!pmCellWriteMask(cell, NULL, NULL, false), "pmCellWriteMask() returned FALSE with NULL psFits param");
    475         myFreeFPA(fpa);
     435        psFree(fpa);
    476436        psFree(camera);
    477437        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    498458        //  Close the FITS file, free memory
    499459        psFitsClose(fitsFileW);
    500         myFreeFPA(fpa);
     460        psFree(fpa);
    501461        psFree(camera);
    502462        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    524484        pmCell *cell = chip->cells->data[0];
    525485        ok(!pmCellReadMask(cell, NULL, NULL), "pmCellReadMask() returned FALSE with NULL pmFits param");
    526         myFreeFPA(fpa);
     486        psFree(fpa);
    527487        psFree(camera);
    528488        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    570530        }
    571531        psFitsClose(fitsFileR);
    572         myFreeFPA(fpa);
     532        psFree(fpa);
    573533        psFree(camera);
    574534        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    599559        ok(chip != NULL, "Allocated a pmChip successfully");
    600560        ok(!pmChipWrite(chip, NULL, NULL, false, true), "pmChipWrite() returned NULL with NULL pmFits param");
    601         myFreeFPA(fpa);
     561        psFree(fpa);
    602562        psFree(camera);
    603563        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    621581        //  Close the FITS file, free memory
    622582        psFitsClose(fitsFileW);
    623         myFreeFPA(fpa);
     583        psFree(fpa);
    624584        psFree(camera);
    625585        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    646606        pmChip *chip = fpa->chips->data[0];
    647607        ok(!pmChipRead(chip, NULL, NULL), "pmChipRead() returned NULL with NULL pmFits param");
    648         myFreeFPA(fpa);
     608        psFree(fpa);
    649609        psFree(camera);
    650610        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    663623        for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
    664624            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    665             myFreeCell(cell);
     625            psFree(cell);
    666626            cell = NULL;
    667627        }
     
    676636            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    677637            for (int k = 0 ; k < cell->hdu->images->n ; k++) {
    678                 if (VERBOSE) diag("Cool: image %d\n", k);
     638                if (VERBOSE) diag("NOTE: image %d\n", k);
    679639                psImage *img = cell->hdu->images->data[k];
    680640                for (int i = 0 ; i < img->numRows ; i++) {
     
    692652
    693653        psFitsClose(fitsFileR);
    694         myFreeFPA(fpa);
     654        psFree(fpa);
    695655        psFree(camera);
    696656        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    719679        ok(chip != NULL, "Allocated a pmChip successfully");
    720680        ok(!pmChipWriteWeight(chip, NULL, NULL, false, true), "pmChipWriteWeight() returned NULL with NULL pmFits param");
    721         myFreeFPA(fpa);
     681        psFree(fpa);
    722682        psFree(camera);
    723683        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    741701        //  Close the FITS file, free memory
    742702        psFitsClose(fitsFileW);
    743         myFreeFPA(fpa);
     703        psFree(fpa);
    744704        psFree(camera);
    745705        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    766726        pmChip *chip = fpa->chips->data[0];
    767727        ok(!pmChipReadMask(chip, NULL, NULL), "pmChipReadMask() returned NULL with NULL pmFits param");
    768         myFreeFPA(fpa);
     728        psFree(fpa);
    769729        psFree(camera);
    770730        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    783743        for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
    784744            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    785             myFreeCell(cell);
     745            psFree(cell);
    786746            cell = NULL;
    787747        }
     
    796756            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    797757            for (int k = 0 ; k < cell->hdu->weights->n ; k++) {
    798                 if (VERBOSE) diag("Cool: image %d\n", k);
     758                if (VERBOSE) diag("NOTE: image %d\n", k);
    799759                psImage *wgt = cell->hdu->weights->data[k];
    800760                for (int i = 0 ; i < wgt->numRows ; i++) {
     
    812772
    813773        psFitsClose(fitsFileR);
    814         myFreeFPA(fpa);
     774        psFree(fpa);
    815775        psFree(camera);
    816776        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    837797        pmChip *chip = fpa->chips->data[0];
    838798        ok(!pmChipReadMask(chip, NULL, NULL), "pmChipReadMask() returned NULL with NULL pmFits param");
    839         myFreeFPA(fpa);
     799        psFree(fpa);
    840800        psFree(camera);
    841801        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    854814        for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
    855815            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    856             myFreeCell(cell);
     816            psFree(cell);
    857817            cell = NULL;
    858818        }
     
    867827            pmCell *cell = (pmCell *) chip->cells->data[chipID];
    868828            for (int k = 0 ; k < cell->hdu->masks->n ; k++) {
    869                 if (VERBOSE) diag("Cool: image %d\n", k);
     829                if (VERBOSE) diag("NOTE: image %d\n", k);
    870830                psImage *msk = cell->hdu->masks->data[k];
    871831                for (int i = 0 ; i < msk->numRows ; i++) {
     
    883843
    884844        psFitsClose(fitsFileR);
    885         myFreeFPA(fpa);
     845        psFree(fpa);
    886846        psFree(camera);
    887847        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    911871        ok(fpa != NULL, "Allocated a pmFPA successfully");
    912872        ok(!pmFPAWrite(fpa, NULL, NULL, false, true), "pmFPAWrite() returned NULL with NULL pmFits param");
    913         myFreeFPA(fpa);
     873        psFree(fpa);
    914874        psFree(camera);
    915875        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    929889        //  Close the FITS file, free memory
    930890        psFitsClose(fitsFileW);
    931         myFreeFPA(fpa);
     891        psFree(fpa);
    932892        psFree(camera);
    933893        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    953913        pmFPA* fpa = generateSimpleFPA(camera);
    954914        ok(!pmFPARead(fpa, NULL, NULL), "pmFPARead() returned NULL with NULL pmFits param");
    955         myFreeFPA(fpa);
     915        psFree(fpa);
    956916        psFree(camera);
    957917        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    971931            for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
    972932                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    973                 myFreeCell(cell);
     933                psFree(cell);
    974934                cell = NULL;
    975935            }
     
    988948                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    989949                for (int k = 0 ; k < cell->hdu->images->n ; k++) {
    990                     if (VERBOSE) diag("Cool: image %d\n", k);
     950                    if (VERBOSE) diag("NOTE: image %d\n", k);
    991951                    psImage *img = cell->hdu->images->data[k];
    992952                    for (int i = 0 ; i < img->numRows ; i++) {
     
    1005965
    1006966        psFitsClose(fitsFileR);
    1007         myFreeFPA(fpa);
     967        psFree(fpa);
    1008968        psFree(camera);
    1009969        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    1033993        ok(fpa != NULL, "Allocated a pmFPA successfully");
    1034994        ok(!pmFPAWriteWeight(fpa, NULL, NULL, false, true), "pmFPAWriteWeight() returned NULL with NULL pmFits param");
    1035         myFreeFPA(fpa);
     995        psFree(fpa);
    1036996        psFree(camera);
    1037997        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    10511011        //  Close the FITS file, free memory
    10521012        psFitsClose(fitsFileW);
    1053         myFreeFPA(fpa);
     1013        psFree(fpa);
    10541014        psFree(camera);
    10551015        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    10751035        pmFPA* fpa = generateSimpleFPA(camera);
    10761036        ok(!pmFPARead(fpa, NULL, NULL), "pmFPAReadWeight() returned NULL with NULL pmFits param");
    1077         myFreeFPA(fpa);
     1037        psFree(fpa);
    10781038        psFree(camera);
    10791039        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    10931053            for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
    10941054                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    1095                 myFreeCell(cell);
     1055                psFree(cell);
    10961056                cell = NULL;
    10971057            }
     
    11101070                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    11111071                for (int k = 0 ; k < cell->hdu->weights->n ; k++) {
    1112                     if (VERBOSE) diag("Cool: image %d\n", k);
     1072                    if (VERBOSE) diag("NOTE: image %d\n", k);
    11131073                    psImage *wgt = cell->hdu->weights->data[k];
    11141074                    for (int i = 0 ; i < wgt->numRows ; i++) {
     
    11271087
    11281088        psFitsClose(fitsFileR);
    1129         myFreeFPA(fpa);
     1089        psFree(fpa);
    11301090        psFree(camera);
    11311091        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    11551115        ok(fpa != NULL, "Allocated a pmFPA successfully");
    11561116        ok(!pmFPAWriteMask(fpa, NULL, NULL, false, true), "pmFPAWriteMask() returned NULL with NULL pmFits param");
    1157         myFreeFPA(fpa);
     1117        psFree(fpa);
    11581118        psFree(camera);
    11591119        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    11731133        //  Close the FITS file, free memory
    11741134        psFitsClose(fitsFileW);
    1175         myFreeFPA(fpa);
     1135        psFree(fpa);
    11761136        psFree(camera);
    11771137        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    11971157        pmFPA* fpa = generateSimpleFPA(camera);
    11981158        ok(!pmFPARead(fpa, NULL, NULL), "pmFPAReadMask() returned NULL with NULL pmFits param");
    1199         myFreeFPA(fpa);
     1159        psFree(fpa);
    12001160        psFree(camera);
    12011161        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    12151175            for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) {
    12161176                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    1217                 myFreeCell(cell);
     1177                psFree(cell);
    12181178                cell = NULL;
    12191179            }
     
    12321192                pmCell *cell = (pmCell *) chip->cells->data[chipID];
    12331193                for (int k = 0 ; k < cell->hdu->masks->n ; k++) {
    1234                     if (VERBOSE) diag("Cool: image %d\n", k);
     1194                    if (VERBOSE) diag("NOTE: image %d\n", k);
    12351195                    psImage *msk = cell->hdu->masks->data[k];
    12361196                    for (int i = 0 ; i < msk->numRows ; i++) {
     
    12491209
    12501210        psFitsClose(fitsFileR);
    1251         myFreeFPA(fpa);
     1211        psFree(fpa);
    12521212        psFree(camera);
    12531213        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
  • trunk/psModules/test/camera/tap_pmFPAUtils.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
    12 // XXX: For the genSimpleFPA() code, add IDs to each function so that
    13 // the values set in each chip-?cell-?hdu-?image are unique
    14 // XXX: For the genSimpleFPA() code, write masks and weights as well
     7/* STATUS:
     8    All functions are tested.
     9*/
    1510
    1611#define CHIP_ALLOC_NAME        "ChipName"
     
    8176    cell->hdu = pmHDUAlloc("cellExtName");
    8277    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    83         cell->readouts->data[i] = generateSimpleReadout(cell);
    84     }
    85 
    86     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     78        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     79    }
     80
     81    // First try to read data from ../dataFiles, then try dataFiles.
     82    bool rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    8783    if (!rc) {
    88         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     84        rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     85        if (!rc) {
     86            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     87        }
    8988    }
    9089
     
    102101
    103102    //XXX: Should the region be set some other way?  Like through the various config files?
    104 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    105103    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    106     // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     104    // You shouldn't have to remove the key from the metadata.
    107105    psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC");
    108106    psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region);
     
    122120    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    123121    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    124 //    chip->hdu = pmHDUAlloc("chipExtName");
    125 //
    126 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    127 //    if (!rc) {
    128 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    129 //    }
    130 //
     122
    131123    psArrayRealloc(chip->cells, NUM_CELLS);
    132124    for (int i = 0 ; i < NUM_CELLS ; i++) {
    133         chip->cells->data[i] = generateSimpleCell(chip);
    134     }
    135 
    136     // XXX: Add code to initialize chip pmConcepts
    137 
    138 
     125        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
     126    }
    139127    return(chip);
    140128}
     
    153141    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    154142    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    155 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    156 //
    157 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    158 //    if (!rc) {
    159 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    160 //    }
    161143
    162144    psArrayRealloc(fpa->chips, NUM_CHIPS);
    163145    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    164         fpa->chips->data[i] = generateSimpleChip(fpa);
    165     }
    166 
    167     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    168     // reading code from wherever.
     146        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     147    }
    169148    pmConceptsBlankFPA(fpa);
    170 //    bool mdok;
    171 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    172 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    173 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    174 
    175149    return(fpa);
    176 }
    177 
    178 // XXX: This should only be necessary until the psFree() functions for
    179 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    180 void myFreeCell(pmCell *cell)
    181 {
    182     for (int k = 0 ; k < cell->readouts->n ; k++) {
    183         psFree(cell->readouts->data[k]);
    184     }
    185     psFree(cell);
    186 }
    187 
    188 void myFreeChip(pmChip *chip) {
    189     for (int j = 0 ; j < chip->cells->n ; j++) {
    190         myFreeCell(chip->cells->data[j]);
    191     }
    192     psFree(chip);
    193 }
    194 
    195 void myFreeFPA(pmFPA *fpa)
    196 {
    197     for (int i = 0 ; i < fpa->chips->n ; i++) {
    198         myFreeChip(fpa->chips->data[i]);
    199     }
    200     psFree(fpa);
    201150}
    202151
     
    207156    psLogSetLevel(PS_LOG_INFO);
    208157    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    209     plan_tests(72);
     158    plan_tests(40);
     159
    210160
    211161    // ----------------------------------------------------------------------
    212     // int pmFPAFindChip(const pmFPA *fpa, const char *name)
    213     {
    214         psMemId id = psMemGetId();
    215         int rc = pmFPAFindChip(NULL, "bogus");
    216         ok(-1 == rc, "pmFPAFindChip() returns -1 with NULL pmFPA input param");
    217         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    218     }
    219 
    220 
    221     // ----------------------------------------------------------------------
    222     // int pmFPAFindChip(const pmFPA *fpa, const char *name)
     162    // pmFPAFindChip() tests
     163    // Call pmFPAFindChip() with NULL pmFPA input parameter
     164    {
     165        psMemId id = psMemGetId();
     166        int rc = pmFPAFindChip(NULL, "chip-0");
     167        ok(-1 == rc, "pmFPAFindChip() returns -1 with NULL pmFPA input parameter");
     168        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     169    }
     170
     171
     172    // Call pmFPAFindChip() with bogus chip name
     173    {
     174        psMemId id = psMemGetId();
     175        pmFPA* fpa = generateSimpleFPA(NULL);
     176        int rc = pmFPAFindChip(fpa, "bogus");
     177        ok(-1 == rc, "pmFPAFindChip() returns -1 with bogus chip name");
     178        psFree(fpa);
     179        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     180    }
     181
     182
     183    // Call pmFPAFindChip() with NULL chip name
    223184    {
    224185        psMemId id = psMemGetId();
    225186        // Generate the pmFPA heirarchy
    226         psMetadata *camera = psMetadataAlloc();
    227         pmFPA* fpa = generateSimpleFPA(camera);
    228         pmChip *chip = fpa->chips->data[0];
    229         pmCell *cell = chip->cells->data[0];
    230         ok(fpa != NULL, "Allocated a pmFPA successfully");
    231         ok(chip != NULL, "Allocated a pmChip successfully");
    232         ok(cell != NULL, "Allocated a pmCell successfully");
     187        pmFPA* fpa = generateSimpleFPA(NULL);
     188        ok(fpa != NULL, "Allocated a pmFPA successfully");
    233189        int rc = pmFPAFindChip(fpa, NULL);
    234190        ok(-1 == rc, "pmFPAFindChip() returns -1 with NULL name input param");
    235         myFreeFPA(fpa);
    236         psFree(camera);
    237         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    238     }
    239 
    240 
    241     // ----------------------------------------------------------------------
    242     // int pmFPAFindChip(const pmFPA *fpa, const char *name)
     191        psFree(fpa);
     192        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     193    }
     194
     195
     196    // Call pmFPAFindChip() with acceptable input parameters
    243197    {
    244198        psMemId id = psMemGetId();
    245199        // Generate the pmFPA heirarchy
    246         psMetadata *camera = psMetadataAlloc();
    247         pmFPA* fpa = generateSimpleFPA(camera);
    248         pmChip *chip = fpa->chips->data[0];
    249         pmCell *cell = chip->cells->data[0];
    250         ok(fpa != NULL, "Allocated a pmFPA successfully");
    251         ok(chip != NULL, "Allocated a pmChip successfully");
    252         ok(cell != NULL, "Allocated a pmCell successfully");
     200        pmFPA* fpa = generateSimpleFPA(NULL);
     201        ok(fpa != NULL, "Allocated a pmFPA successfully");
    253202        // Set unique chip names
    254203        for (int chipID = 0 ; chipID < fpa->chips->n ; chipID++) {
     
    267216        }
    268217
    269         myFreeFPA(fpa);
    270         psFree(camera);
     218        psFree(fpa);
    271219        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    272220    }
     
    275223
    276224    // ----------------------------------------------------------------------
    277     // int pmChipFindCell(const pmChip *chip, const char *name)
    278     {
    279         psMemId id = psMemGetId();
    280         int rc = pmChipFindCell(NULL, "bogus");
     225    // pmChipFindCell() tests
     226    // Call pmChipFindCell() with bogus cell name
     227    {
     228        psMemId id = psMemGetId();
     229        int rc = pmChipFindCell(NULL, "cell-0");
    281230        ok(-1 == rc, "pmChipFindCell() returns -1 with NULL pmChip input param");
    282231        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    283232    }
    284233
    285 
    286     // ----------------------------------------------------------------------
    287     // int pmChipFindCell(const pmChip *chip, const char *name)
     234    // Call pmChipFindCell() with bogus cell name
     235    {
     236        psMemId id = psMemGetId();
     237        pmFPA* fpa = generateSimpleFPA(NULL);
     238        pmChip *chip = fpa->chips->data[0];
     239        int rc = pmChipFindCell(chip, "bogus");
     240        ok(-1 == rc, "pmChipFindCell() returns -1 with bogus cell name");
     241        psFree(fpa);
     242        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     243    }
     244
     245
     246    // Call pmChipFindCell() with NULL cell name
    288247    {
    289248        psMemId id = psMemGetId();
    290249        // Generate the pmChip heirarchy
    291         psMetadata *camera = psMetadataAlloc();
    292         pmFPA* fpa = generateSimpleFPA(camera);
     250        pmFPA* fpa = generateSimpleFPA(NULL);
    293251        pmChip *chip = fpa->chips->data[0];
    294252        pmCell *cell = chip->cells->data[0];
     
    298256        int rc = pmChipFindCell(chip, NULL);
    299257        ok(-1 == rc, "pmChipFindCell() returns -1 with NULL name input param");
    300         myFreeFPA(fpa);
    301         psFree(camera);
    302         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    303     }
    304 
    305 
    306     // ----------------------------------------------------------------------
    307     // int pmChipFindCell(const pmChip *chip, const char *name)
     258        psFree(fpa);
     259        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     260    }
     261
     262
     263    // Call pmChipFindCell() with acceptable input parameters
    308264    {
    309265        psMemId id = psMemGetId();
    310266        // Generate the pmChip heirarchy
    311         psMetadata *camera = psMetadataAlloc();
    312         pmFPA* fpa = generateSimpleFPA(camera);
     267        pmFPA* fpa = generateSimpleFPA(NULL);
    313268        pmChip *chip = fpa->chips->data[0];
    314269        pmCell *cell = chip->cells->data[0];
     
    332287        }
    333288
    334         myFreeFPA(fpa);
    335         psFree(camera);
    336         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    337     }
    338 
    339 }
     289        psFree(fpa);
     290        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     291    }
     292
     293}
  • trunk/psModules/test/camera/tap_pmFPAView.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: pmFPAviewThisHDU(): some problems with NULL pmHDUs
    8 // XXX: must test: pmFPAviewThisHDU(), pmFPAviewThisPHU()
    9 // XXX: must test: pmFPAviewThisPHU()
     7/* STATUS:
     8    All functions are tested.
     9*/
    1010
    1111#define ERR_TRACE_LEVEL         0
     
    7777    cell->hdu = pmHDUAlloc("cellExtName");
    7878    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    79         cell->readouts->data[i] = generateSimpleReadout(cell);
    80     }
    81 
    82     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     79        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     80    }
     81
     82    // First try to read data from ../dataFiles, then try dataFiles.
     83    bool rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    8384    if (!rc) {
    84         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     85        rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     86        if (!rc) {
     87            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     88        }
    8589    }
    8690
     
    96100        psImageInit(cell->hdu->weights->data[k], (float) (BASE_WEIGHT+k));
    97101    }
     102    cell->hdu->blankPHU = true;
    98103
    99104    //XXX: Should the region be set some other way?  Like through the various config files?
    100 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    101105    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    102106    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     
    119123    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    120124
    121     if (1) {
    122         chip->hdu = pmHDUAlloc("chipExtName");
    123 //        bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    124 //        if (!rc) {
    125 //            diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    126 //        }
    127     }
     125    chip->hdu = pmHDUAlloc("chipExtName");
     126    bool rc = pmConfigFileRead(&chip->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     127    if (!rc) {
     128        rc = pmConfigFileRead(&chip->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     129        if (!rc) {
     130            diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
     131        }
     132    }
     133    chip->hdu->blankPHU = true;
    128134
    129135    psArrayRealloc(chip->cells, NUM_CELLS);
    130136    for (int i = 0 ; i < NUM_CELLS ; i++) {
    131         chip->cells->data[i] = generateSimpleCell(chip);
    132     }
    133 
    134     // XXX: Add code to initialize chip pmConcepts
    135 
     137        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
     138    }
    136139
    137140    return(chip);
     
    151154    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    152155    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    153 
    154     if (1) {
    155         fpa->hdu = pmHDUAlloc("fpaExtName");
    156         bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
     156    fpa->hdu = pmHDUAlloc("fpaExtName");
     157    bool rc = pmConfigFileRead(&fpa->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     158    if (!rc) {
     159        rc = pmConfigFileRead(&fpa->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    157160        if (!rc) {
    158161            diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    159162        }
    160163    }
     164    fpa->hdu->blankPHU = true;
    161165
    162166    psArrayRealloc(fpa->chips, NUM_CHIPS);
    163167    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    164         fpa->chips->data[i] = generateSimpleChip(fpa);
    165     }
    166 
    167     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    168     // reading code from wherever.
     168        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     169    }
    169170    pmConceptsBlankFPA(fpa);
    170 //    bool mdok;
    171 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    172 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    173 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    174 
    175171    return(fpa);
    176172}
    177173
    178 // XXX: This should only be necessary until the psFree() functions for
    179 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    180 void myFreeCell(pmCell *cell)
    181 {
    182     for (int k = 0 ; k < cell->readouts->n ; k++) {
    183         psFree(cell->readouts->data[k]);
    184     }
    185     psFree(cell);
    186 }
    187 
    188 void myFreeChip(pmChip *chip) {
    189     for (int j = 0 ; j < chip->cells->n ; j++) {
    190         myFreeCell(chip->cells->data[j]);
    191     }
    192     psFree(chip);
    193 }
    194 
    195 void myFreeFPA(pmFPA *fpa)
    196 {
    197     for (int i = 0 ; i < fpa->chips->n ; i++) {
    198         myFreeChip(fpa->chips->data[i]);
    199     }
    200     psFree(fpa);
    201 }
    202174
    203175psS32 main(psS32 argc, char* argv[])
     
    206178    psLogSetLevel(PS_LOG_INFO);
    207179    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    208     plan_tests(137);
     180    plan_tests(174);
     181
    209182
    210183    // ----------------------------------------------------------------------
    211184    // pmFPAViewAlloc() tests
    212     // XXX: Add memCheckPtr() tests
    213     {
    214         psMemId id = psMemGetId();
    215         pmFPAview *tmpView = pmFPAviewAlloc(32);
    216         ok(tmpView != NULL, "pmFPAviewAlloc() returned non-NULL");
     185    {
     186        psMemId id = psMemGetId();
     187        pmFPAview *tmpView = pmFPAviewAlloc(32);
     188        ok(tmpView != NULL && psMemCheckFPAview(tmpView), "pmFPAviewAlloc() returned non-NULL");
    217189        ok(tmpView->nRows == 32, "pmFPAviewAlloc() set ->nRows properly");
    218190        psFree(tmpView);
     
    228200        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    229201    }
     202
    230203
    231204    // pmFPAViewReset() tests: acceptable input
     
    340313        ok(NULL == pmFPAviewThisChip(NULL, fpa), "pmFPAviewThisChip(NULL, fpa) returned NULL");
    341314
    342         myFreeFPA(fpa);
     315        psFree(fpa);
    343316        psFree(camera);
    344317        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    366339        ok(NULL == pmFPAviewThisChip(tmpView, fpa), "pmFPAviewThisChip(pmFPAView, fpa) returned NULL view input");
    367340        fpa->chips = chips;
    368         myFreeFPA(fpa);
     341        psFree(fpa);
    369342        psFree(camera);
    370343        psFree(tmpView);
     
    403376        }
    404377        ok(!errorFlag, "pmFPAviewThisChip() returned the correct pmChip for all tests");
    405         myFreeFPA(fpa);
     378        psFree(fpa);
    406379        psFree(camera);
    407380        psFree(tmpView);
     
    425398        ok(NULL == pmFPAviewNextChip(NULL, fpa, 0), "pmFPAviewNextChip(NULL, fpa, 0) returned NULL");
    426399
    427         myFreeFPA(fpa);
     400        psFree(fpa);
    428401        psFree(camera);
    429402        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    456429        // XXX: Source code is wrong: must guard against input tmpView->chip = -1
    457430        tmpView->chip = -1;
    458         ok(NULL == pmFPAviewNextChip(tmpView, fpa, 0), "pmFPAviewNextChip(pmFPAView, fpa, 0) returned NULL with pmFPAView->chip == -1");
     431        ok(fpa->chips->data[0] == pmFPAviewNextChip(tmpView, fpa, 1), "pmFPAviewNextChip(pmFPAView, fpa, 1) returned NULL with pmFPAView->chip == -1");
    459432
    460433        // Test with tmpView->chip too high
     
    486459        ok(!errorFlag, "pmFPAviewNextChip() returned the correct pmChip for all tests (step = 1)");
    487460
    488         myFreeFPA(fpa);
     461        psFree(fpa);
    489462        psFree(camera);
    490463        psFree(tmpView);
     
    506479        ok(NULL == pmFPAviewThisCell(NULL, fpa), "pmFPAviewThisCell(NULL, fpa) returned NULL");
    507480
    508         myFreeFPA(fpa);
     481        psFree(fpa);
    509482        psFree(camera);
    510483        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    523496
    524497    // pmFPAviewThisCell() tests: NULL fpa->chips input
    525     // XXX: Skipping because the source code does not guard against this
    526     if (0) {
     498    {
    527499        psMemId id = psMemGetId();
    528500        psMetadata *camera = psMetadataAlloc();
     
    533505        ok(NULL == pmFPAviewThisCell(tmpView, fpa), "pmFPAviewThisCell(pmFPAView, fpa) returned NULL view input");
    534506        fpa->chips = chips;
    535         myFreeFPA(fpa);
     507        psFree(fpa);
    536508        psFree(camera);
    537509        psFree(tmpView);
     
    575547        }
    576548        ok(!errorFlag, "pmFPAviewThisCell() returned the correct pmCell for all tests");
    577         myFreeFPA(fpa);
    578         psFree(camera);
    579         psFree(tmpView);
    580         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    581     }
    582 
     549        psFree(fpa);
     550        psFree(camera);
     551        psFree(tmpView);
     552        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     553    }
    583554
    584555
     
    597568        ok(NULL == pmFPAviewNextCell(NULL, fpa, 0), "pmFPAviewNextCell(NULL, fpa, 0) returned NULL");
    598569
    599         myFreeFPA(fpa);
     570        psFree(fpa);
    600571        psFree(camera);
    601572        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    667638        ok(!errorFlag, "pmFPAviewNextCell() returned the correct pmCell for all tests (step = 1)");
    668639
    669         myFreeFPA(fpa);
     640        psFree(fpa);
    670641        psFree(camera);
    671642        psFree(tmpView);
     
    688659        ok(NULL == pmFPAviewThisReadout(NULL, fpa), "pmFPAviewThisReadout(NULL, fpa) returned NULL");
    689660
    690         myFreeFPA(fpa);
     661        psFree(fpa);
    691662        psFree(camera);
    692663        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    705676
    706677    // pmFPAviewThisReadout() tests: NULL fpa->chips input
    707     // XXX: Skipping because the source code does not guard against this
    708     if (0) {
     678    {
    709679        psMemId id = psMemGetId();
    710680        psMetadata *camera = psMetadataAlloc();
     
    715685        ok(NULL == pmFPAviewThisReadout(tmpView, fpa), "pmFPAviewThisReadout(pmFPAView, fpa) returned NULL view input");
    716686        fpa->chips = chips;
    717         myFreeFPA(fpa);
     687        psFree(fpa);
    718688        psFree(camera);
    719689        psFree(tmpView);
     
    761731        ok(!errorFlag, "pmFPAviewThisReadout() returned the correct pmCell for all tests");
    762732
    763         myFreeFPA(fpa);
     733        psFree(fpa);
    764734        psFree(camera);
    765735        psFree(tmpView);
     
    782752        ok(NULL == pmFPAviewNextReadout(NULL, fpa, 0), "pmFPAviewNextReadout(NULL, fpa, 0) returned NULL");
    783753
    784         myFreeFPA(fpa);
     754        psFree(fpa);
    785755        psFree(camera);
    786756        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    857827        ok(!errorFlag, "pmFPAviewNextReadout() returned the correct pmCell for all tests (step = 1)");
    858828
    859         myFreeFPA(fpa);
     829        psFree(fpa);
    860830        psFree(camera);
    861831        psFree(tmpView);
     
    877847        ok(cell != NULL, "Allocated a pmCell successfully");
    878848        ok(NULL == pmFPAviewThisHDU(NULL, fpa), "pmFPAviewThisHDU(NULL, fpa) returned NULL");
    879         myFreeFPA(fpa);
     849        psFree(fpa);
    880850        psFree(camera);
    881851        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    893863
    894864
    895 
    896 
    897 
    898 
    899 
    900 
    901 
    902 
    903 
    904 
    905 
    906 
    907 
    908 
    909 
    910 
    911 
    912 
    913 
    914 
    915 
    916 
    917 
    918 
    919 
    920 
    921 
    922 
    923 
    924 
    925 
    926 
    927 
    928 
    929 
    930 
    931 
    932 
    933 
    934 
    935 
    936 
    937 
    938 
    939 
    940 
    941 
    942 
    943 
    944 
    945 
    946 
    947 
    948865    // pmFPAviewThisHDU() tests: acceptable input
    949     // pmHDU *pmFPAviewThisHDU(const pmFPAview *view, const pmFPA *fpa)
    950866    {
    951867        psMemId id = psMemGetId();
     
    963879        ok(hdu, "pmFPAviewThisHDU() returned non-NULL with tmpView->chip = -1");
    964880        ok(hdu == pmHDUFromFPA(fpa), "pmFPAviewThisHDU() returned the correct HDU");
    965         tmpView->chip = 16;
    966 
    967         // XXX: These tests fail because the pmHDU functions are returning NULL.  Why?
     881        tmpView->chip = NUM_CHIPS/2;
     882
    968883        tmpView->cell = -1;
    969884        hdu = pmFPAviewThisHDU(tmpView, fpa);
    970885        ok(hdu, "pmFPAviewThisHDU() returned non-NULL with tmpView->cell = -1");
    971886        ok(hdu == pmHDUFromChip(pmFPAviewThisChip(tmpView, fpa)), "pmFPAviewThisHDU() returned the correct HDU");
    972         tmpView->cell = 16;
     887        tmpView->cell = NUM_CELLS/2;
    973888
    974889        tmpView->readout = -1;
     
    976891        ok(hdu, "pmFPAviewThisHDU() returned non-NULL with tmpView->readout = -1");
    977892        ok(hdu == pmHDUFromCell(pmFPAviewThisCell(tmpView, fpa)), "pmFPAviewThisHDU() returned the correct HDU");
    978         tmpView->readout = 16;
     893        tmpView->readout = NUM_READOUTS/2;
    979894
    980895        hdu = pmFPAviewThisHDU(tmpView, fpa);
     
    982897        ok(hdu == pmHDUFromReadout(pmFPAviewThisReadout(tmpView, fpa)), "pmFPAviewThisHDU() returned the correct HDU");
    983898
    984         myFreeFPA(fpa);
    985         psFree(camera);
    986         psFree(tmpView);
     899        psFree(fpa);
     900        psFree(camera);
     901        psFree(tmpView);
     902        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     903    }
     904
     905
     906    // ----------------------------------------------------------------------
     907    // pmFPAviewThisPHU() tests: NULL view input
     908    // pmHDU *pmFPAviewThisPHU(const pmFPAview *view, const pmFPA *fpa)
     909    {
     910        psMemId id = psMemGetId();
     911        psMetadata *camera = psMetadataAlloc();
     912        pmFPA* fpa = generateSimpleFPA(camera);
     913        pmChip *chip = fpa->chips->data[0];
     914        pmCell *cell = chip->cells->data[0];
     915        ok(fpa != NULL, "Allocated a pmFPA successfully");
     916        ok(chip != NULL, "Allocated a pmChip successfully");
     917        ok(cell != NULL, "Allocated a pmCell successfully");
     918        ok(NULL == pmFPAviewThisPHU(NULL, fpa), "pmFPAviewThisPHU(NULL, fpa) returned NULL");
     919        psFree(fpa);
     920        psFree(camera);
     921        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     922    }
     923
     924    // pmFPAviewThisPHU() tests: NULL pmFPA input
     925    // pmHDU *pmFPAviewThisPHU(const pmFPAview *view, const pmFPA *fpa)
     926    {
     927        psMemId id = psMemGetId();
     928        pmFPAview *tmpView = pmFPAviewAlloc(32);
     929        ok(NULL == pmFPAviewThisPHU(tmpView, NULL), "pmFPAviewThisPHU(pmFPAView, NULL) returned NULL");
     930        psFree(tmpView);
     931        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     932    }
     933
     934
     935    // pmFPAviewThisPHU() tests: acceptable input
     936    {
     937        psMemId id = psMemGetId();
     938        psMetadata *camera = psMetadataAlloc();
     939        pmFPA* fpa = generateSimpleFPA(camera);
     940        pmChip *chip = fpa->chips->data[0];
     941        pmCell *cell = chip->cells->data[0];
     942        ok(fpa != NULL, "Allocated a pmFPA successfully");
     943        ok(chip != NULL, "Allocated a pmChip successfully");
     944        ok(cell != NULL, "Allocated a pmCell successfully");
     945        pmFPAview *tmpView = pmFPAviewAlloc(32);
     946
     947        tmpView->chip = -1;
     948        pmHDU *hdu = pmFPAviewThisPHU(tmpView, fpa);
     949        ok(hdu, "pmFPAviewThisPHU() returned non-NULL with tmpView->chip = -1");
     950        ok(hdu == pmHDUFromFPA(fpa), "pmFPAviewThisPHU() returned the correct HDU");
     951        tmpView->chip = NUM_CHIPS/2;
     952
     953        tmpView->cell = -1;
     954        hdu = pmFPAviewThisPHU(tmpView, fpa);
     955        ok(hdu, "pmFPAviewThisPHU() returned non-NULL with tmpView->cell = -1");
     956        ok(hdu == pmHDUFromChip(pmFPAviewThisChip(tmpView, fpa)), "pmFPAviewThisPHU() returned the correct HDU");
     957        tmpView->cell = NUM_CELLS/2;
     958
     959        tmpView->readout = -1;
     960        hdu = pmFPAviewThisPHU(tmpView, fpa);
     961        ok(hdu, "pmFPAviewThisPHU() returned non-NULL with tmpView->readout = -1");
     962        ok(hdu == pmHDUFromCell(pmFPAviewThisCell(tmpView, fpa)), "pmFPAviewThisPHU() returned the correct HDU");
     963        tmpView->readout = NUM_READOUTS/2;
     964
     965        hdu = pmFPAviewThisPHU(tmpView, fpa);
     966        ok(hdu == NULL, "pmFPAviewThisPHU() returned NULL");
     967
     968        psFree(fpa);
     969        psFree(camera);
     970        psFree(tmpView);
     971        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     972    }
     973
     974
     975    // ----------------------------------------------------------------------
     976    // pmFPAviewGenerate() tests: NULL pmFPA input
     977    {
     978        psMemId id = psMemGetId();
     979        int chipID = NUM_CHIPS/2;
     980        int cellID = NUM_CELLS/2;
     981        int readoutID = NUM_READOUTS/2;
     982        pmFPA* fpa = generateSimpleFPA(NULL);
     983        pmChip *chip = fpa->chips->data[chipID];
     984        pmCell *cell = chip->cells->data[cellID];
     985        pmReadout *readout = cell->readouts->data[readoutID];
     986        ok(fpa != NULL, "Allocated a pmFPA successfully");
     987        ok(chip != NULL, "Allocated a pmChip successfully");
     988        ok(cell != NULL, "Allocated a pmCell successfully");
     989        ok(readout != NULL, "Allocated a pmReadout successfully");
     990        pmFPAview *view = pmFPAviewGenerate(NULL, chip, cell, readout);
     991        ok(view == NULL, "pmFPAviewGenerate(NULL, chip, cell, readout) returned NULL");
     992        psFree(fpa);
     993        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     994    }
     995
     996
     997    // pmFPAviewGenerate() tests: acceptable input parameters
     998    // XX: Add more input combinations.
     999    {
     1000        psMemId id = psMemGetId();
     1001        int chipID = NUM_CHIPS/2;
     1002        int cellID = NUM_CELLS/2;
     1003        int readoutID = NUM_READOUTS/2;
     1004        pmFPA* fpa = generateSimpleFPA(NULL);
     1005        pmChip *chip = fpa->chips->data[chipID];
     1006        pmCell *cell = chip->cells->data[cellID];
     1007        pmReadout *readout = cell->readouts->data[readoutID];
     1008        ok(fpa != NULL, "Allocated a pmFPA successfully");
     1009        ok(chip != NULL, "Allocated a pmChip successfully");
     1010        ok(cell != NULL, "Allocated a pmCell successfully");
     1011        ok(readout != NULL, "Allocated a pmReadout successfully");
     1012        pmFPAview *view = pmFPAviewGenerate(fpa, chip, cell, readout);
     1013        ok(view != NULL && psMemCheckFPAview(view), "pmFPAviewGenerate() returned an pmFPAviw with acceptable input parameters");
     1014        ok(view->chip == chipID, "pmFPAviewGenerate() set pmFPAview->chip correctly");
     1015        ok(view->cell == cellID, "pmFPAviewGenerate() set pmFPAview->cell correctly");
     1016        ok(view->readout == readoutID, "pmFPAviewGenerate() set pmFPAview->readout correctly");
     1017        psFree(view);
     1018        psFree(fpa);
    9871019        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    9881020    }
    9891021}
     1022
  • trunk/psModules/test/camera/tap_pmHDU.c

    r14881 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 /*
    8     The following psModule functions are tested:
    9         pmHDUAlloc()
    10         pmHDUReadHeader()
    11         pmHDURead()
    12         pmHDUReadMask()
    13         pmHDUReadWeight()
    14         pmHDUWrite()
    15         pmHDUWriteMask()
    16         pmHDUWriteWeight()
     7/* STATUS:
     8    All functions are tested.
    179*/
    1810
     
    2618    psTraceSetLevel("err", 0);
    2719    plan_tests(159);
     20
    2821
    2922    // ----------------------------------------------------------------------
     
    9386        hdu->header = psMetadataAlloc();
    9487        psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYINT", PS_DATA_S32, "psS32 Item", 0);
    95         bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     88        bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     89        if (!rc) {
     90            rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     91        }
    9692        ok(rc == true, "pmConfigFileRead() was successful");
    9793        rc = pmHDUWrite(hdu, NULL);
     
    105101    {
    106102        psMemId id = psMemGetId();
    107         psFits* fitsFile = psFitsOpen("data/sampleFitsFile.fits", "r");
     103        psFits* fitsFile = psFitsOpen("../dataFiles/sampleFitsFile.fits", "r");
     104        if (!fitsFile) {
     105            fitsFile = psFitsOpen("dataFiles/sampleFitsFile.fits", "r");
     106        }
    108107        ok(fitsFile != NULL, "psFitsOpen() was successful");
    109108        bool rc = pmHDURead(NULL, fitsFile);
     
    147146        //    Set hdu->images
    148147        pmHDU *hdu = pmHDUAlloc("extname");
    149         bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera format 0");
     148        bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     149        if (!rc) {
     150            rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     151        }
    150152        ok(rc, "pmConfigFileRead() was successful");
    151153        hdu->images = psArrayAlloc(NUM_HDUS);
     
    219221        hdu->header = psMetadataAlloc();
    220222        psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYINT", PS_DATA_S32, "psS32 Item", 0);
    221         bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     223        bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     224        if (!rc) {
     225            rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     226        }
    222227        ok(rc == true, "pmConfigFileRead() was successful");
    223228        rc = pmHDUWriteWeight(hdu, NULL);
     
    231236    {
    232237        psMemId id = psMemGetId();
    233         psFits* fitsFile = psFitsOpen("data/sampleFitsFile.fits", "r");
     238        psFits* fitsFile = psFitsOpen("../dataFiles/sampleFitsFile.fits", "r");
     239        if (!fitsFile) {
     240            fitsFile = psFitsOpen("dataFiles/sampleFitsFile.fits", "r");
     241        }
    234242        ok(fitsFile != NULL, "psFitsOpen() was successful");
    235243        bool rc = pmHDUReadWeight(NULL, fitsFile);
     
    273281        //    Set hdu->images
    274282        pmHDU *hdu = pmHDUAlloc("extname");
    275         bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera format 0");
     283        bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     284        if (!rc) {
     285            rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     286        }
    276287        ok(rc, "pmConfigFileRead() was successful");
    277288        hdu->weights = psArrayAlloc(NUM_HDUS);
     
    345356        hdu->header = psMetadataAlloc();
    346357        psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYINT", PS_DATA_S32, "psS32 Item", 0);
    347         bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     358        bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     359        if (!rc) {
     360             pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     361        }
    348362        ok(rc == true, "pmConfigFileRead() was successful");
    349363        rc = pmHDUWriteMask(hdu, NULL);
     
    357371    {
    358372        psMemId id = psMemGetId();
    359         psFits* fitsFile = psFitsOpen("data/sampleFitsFile.fits", "r");
     373        psFits* fitsFile = psFitsOpen("../dataFiles/sampleFitsFile.fits", "r");
     374        if (!fitsFile) {
     375            fitsFile = psFitsOpen("dataFiles/sampleFitsFile.fits", "r");
     376        }
    360377        ok(fitsFile != NULL, "psFitsOpen() was successful");
    361378        bool rc = pmHDUReadMask(NULL, fitsFile);
     
    399416        //    Set hdu->images
    400417        pmHDU *hdu = pmHDUAlloc("extname");
    401         bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera format 0");
     418        bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     419        if (!rc) {
     420            rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     421        }
    402422        ok(rc, "pmConfigFileRead() was successful");
    403423        hdu->masks = psArrayAlloc(NUM_HDUS);
     
    450470    {
    451471        psMemId id = psMemGetId();
    452         psFits* fitsFile = psFitsOpen("data/sampleFitsFile.fits", "r");
     472        psFits* fitsFile = psFitsOpen("../dataFiles/sampleFitsFile.fits", "r");
     473        if (!fitsFile) {
     474            fitsFile = psFitsOpen("dataFiles/sampleFitsFile.fits", "r");
     475        }
    453476        ok(fitsFile != NULL, "psFitsOpen() was successful");
    454477        bool rc = pmHDUReadHeader(NULL, fitsFile);
     
    490513                         "psBool Item", (lcv%2 == 0));
    491514            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    492 
    493             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     515                         "psStr Item", extname);
     516
     517            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     518            if (!rc) {
     519                rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     520            }
    494521            ok(rc == true, "pmConfigFileRead() was successful");
    495522            rc = pmHDUWrite(hdu, fitsFileW);
  • trunk/psModules/test/camera/tap_pmHDUUtils.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
    12 // XXX: This simpleFPA() requires that the HDUs be allocated.
    13 
     7/* STATUS:
     8    All functions are tested.
     9*/
    1410
    1511#define CHIP_ALLOC_NAME        "ChipName"
     
    8076    cell->hdu = pmHDUAlloc("cellExtName");
    8177    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    82         cell->readouts->data[i] = generateSimpleReadout(cell);
    83     }
    84 
    85     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     78        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     79    }
     80
     81    // First try to read data from ../dataFiles, then try dataFiles.
     82    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    8683    if (!rc) {
    87         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     84        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     85        if (!rc) {
     86            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     87        }
    8888    }
    8989
     
    101101
    102102    //XXX: Should the region be set some other way?  Like through the various config files?
    103 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    104103    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    105104    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     
    123122    chip->hdu = pmHDUAlloc("chipExtName");
    124123
    125     bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
     124    bool rc = pmConfigFileRead(&chip->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    126125    if (!rc) {
    127         diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
     126        rc = pmConfigFileRead(&chip->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     127        if (!rc) {
     128            diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
     129        }
    128130    }
    129131
    130132    psArrayRealloc(chip->cells, NUM_CELLS);
    131133    for (int i = 0 ; i < NUM_CELLS ; i++) {
    132         chip->cells->data[i] = generateSimpleCell(chip);
    133     }
    134 
    135     // XXX: Add code to initialize chip pmConcepts
    136 
    137 
     134        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
     135    }
    138136    return(chip);
    139137}
     
    153151    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    154152    fpa->hdu = pmHDUAlloc("fpaExtName");
    155 
    156     bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
     153    bool rc = pmConfigFileRead(&fpa->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    157154    if (!rc) {
    158         diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
     155        rc = pmConfigFileRead(&fpa->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     156        if (!rc) {
     157            diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
     158        }
    159159    }
    160160
    161161    psArrayRealloc(fpa->chips, NUM_CHIPS);
    162162    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    163         fpa->chips->data[i] = generateSimpleChip(fpa);
    164     }
    165 
    166     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    167     // reading code from wherever.
     163        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     164    }
    168165    pmConceptsBlankFPA(fpa);
    169 //    bool mdok;
    170 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    171 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    172 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    173 
    174166    return(fpa);
    175 }
    176 
    177 // XXX: This should only be necessary until the psFree() functions for
    178 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    179 void myFreeCell(pmCell *cell)
    180 {
    181     for (int k = 0 ; k < cell->readouts->n ; k++) {
    182         psFree(cell->readouts->data[k]);
    183     }
    184     psFree(cell);
    185 }
    186 
    187 void myFreeChip(pmChip *chip) {
    188     for (int j = 0 ; j < chip->cells->n ; j++) {
    189         myFreeCell(chip->cells->data[j]);
    190     }
    191     psFree(chip);
    192 }
    193 
    194 void myFreeFPA(pmFPA *fpa)
    195 {
    196     for (int i = 0 ; i < fpa->chips->n ; i++) {
    197         myFreeChip(fpa->chips->data[i]);
    198     }
    199     psFree(fpa);
    200167}
    201168
     
    208175    plan_tests(73);
    209176
    210     // ----------------------------------------------------------------------
    211     // pmHDU *pmHDUFromFPA(const pmFPA *fpa)
     177
     178    // ----------------------------------------------------------------------
    212179    // pmHDUFromFPA() tests
    213     // pmHDUFromFPA() verify with NULL input params
     180    // Call pmHDUFromFPA() with NULL input params
    214181    {
    215182        psMemId id = psMemGetId();
     
    219186    }
    220187
    221     //pmHDUFromFPA() verify with acceptable input params
     188
     189    // Call pmHDUFromFPA() with acceptable input params
    222190    {
    223191        psMemId id = psMemGetId();
     
    232200        pmHDU *hdu = pmHDUFromFPA(fpa);
    233201        ok(hdu == fpa->hdu, "pmHDUFromFPA(NULL) returned the correct pmHDU of an pmFPA struct");
    234         myFreeFPA(fpa);
    235         psFree(camera);
    236         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    237     }
    238 
    239 
    240     // ----------------------------------------------------------------------
    241     // pmHDU *pmHDUFromChip(const pmChip *chip)
     202        psFree(fpa);
     203        psFree(camera);
     204        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     205    }
     206
     207
     208    // ----------------------------------------------------------------------
    242209    // pmHDUFromChip() tests
    243     // pmHDUFromChip() verify with NULL input params
     210    // Call pmHDUFromChip() with NULL input params
    244211    {
    245212        psMemId id = psMemGetId();
     
    249216    }
    250217
    251     //pmHDUFromChip() verify with acceptable input params
     218
     219    // Call pmHDUFromChip() with acceptable input params
    252220    {
    253221        psMemId id = psMemGetId();
     
    262230        pmHDU *hdu = pmHDUFromChip(chip);
    263231        ok(hdu == chip->hdu, "pmHDUFromChip() returned the correct pmHDU of an pmChip struct");
    264         myFreeFPA(fpa);
    265         psFree(camera);
    266         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    267     }
    268 
    269     //pmHDUFromChip() verify with acceptable input params
     232        psFree(fpa);
     233        psFree(camera);
     234        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     235    }
     236
     237
     238    // Call pmHDUFromChip() with acceptable input params
    270239    // Set chip->hdu to NULL, verify chip->parent->hdu is returned
    271240    {
     
    283252        pmHDU *hdu = pmHDUFromChip(chip);
    284253        ok(hdu == chip->parent->hdu, "pmHDUFromChip() returned the correct pmHDU of an pmChip struct");
    285         myFreeFPA(fpa);
    286         psFree(camera);
    287         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    288     }
    289 
    290 
    291     // ----------------------------------------------------------------------
    292     // pmHDU *pmHDUFromCell(const pmCell *cell)
     254        psFree(fpa);
     255        psFree(camera);
     256        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     257    }
     258
     259
     260    // ----------------------------------------------------------------------
    293261    // pmHDUFromCell() tests
    294     // pmHDUFromCell() verify with NULL input params
     262    // Call pmHDUFromCell() with NULL input params
    295263    {
    296264        psMemId id = psMemGetId();
     
    300268    }
    301269
    302     //pmHDUFromCell() verify with acceptable input params
     270
     271    // Call pmHDUFromCell() with acceptable input params
    303272    {
    304273        psMemId id = psMemGetId();
     
    313282        pmHDU *hdu = pmHDUFromCell(cell);
    314283        ok(hdu == cell->hdu, "pmHDUFromCell() returned the correct pmHDU of an pmCell struct");
    315         myFreeFPA(fpa);
    316         psFree(camera);
    317         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    318     }
    319 
    320     //pmHDUFromCell() verify with acceptable input params
     284        psFree(fpa);
     285        psFree(camera);
     286        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     287    }
     288
     289
     290    // Call pmHDUFromCell() with acceptable input params
    321291    // Set cell->hdu to NULL, verify cell->parent->hdu is returned
    322292    {
     
    334304        pmHDU *hdu = pmHDUFromCell(cell);
    335305        ok(hdu == cell->parent->hdu, "pmHDUFromCell() returned the correct pmHDU of an pmCell struct");
    336         myFreeFPA(fpa);
    337         psFree(camera);
    338         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    339     }
    340 
    341 
    342     // ----------------------------------------------------------------------
    343     // pmHDU *pmHDUFromReadout(const pmCell *cell)
     306        psFree(fpa);
     307        psFree(camera);
     308        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     309    }
     310
     311
     312    // ----------------------------------------------------------------------
    344313    // pmHDUFromReadout() tests
    345     // pmHDUFromReadout() verify with NULL input params
     314    // Call pmHDUFromReadout() with NULL input params
    346315    {
    347316        psMemId id = psMemGetId();
     
    351320    }
    352321
    353     //pmHDUFromReadout() verify with acceptable input params
     322
     323    // Call pmHDUFromReadout() with acceptable input params
    354324    {
    355325        psMemId id = psMemGetId();
     
    366336        pmHDU *hdu = pmHDUFromReadout(readout);
    367337        ok(hdu == readout->parent->hdu, "pmHDUFromReadout() returned the correct pmHDU of an pmReadout struct");
    368         myFreeFPA(fpa);
    369         psFree(camera);
    370         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    371     }
    372 
    373 
    374     // ----------------------------------------------------------------------
    375     //pmHDUGetLowest() tests
    376     //pmHDU *pmHDUGetLowest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    377     //pmHDUGetLowest(): verify with all NULL inputs
     338        psFree(fpa);
     339        psFree(camera);
     340        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     341    }
     342
     343
     344    // ----------------------------------------------------------------------
     345    // pmHDUGetLowest() tests
     346    // Call pmHDUGetLowest() with all NULL inputs
    378347    {
    379348        psMemId id = psMemGetId();
     
    384353
    385354
    386     //pmHDUGetLowest() tests
    387     //pmHDU *pmHDUGetLowest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    388     //pmHDUGetLowest(): verify with all acceptable inputs
     355    // Call pmHDUGetLowest() with all acceptable inputs
    389356    {
    390357        psMemId id = psMemGetId();
     
    399366        pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell);
    400367        ok(hdu == cell->hdu, "pmHDUGetLowest(fpa, chip, cell)");
    401         myFreeFPA(fpa);
    402         psFree(camera);
    403         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    404     }
    405 
    406 
    407     //pmHDUGetLowest() tests
    408     //pmHDU *pmHDUGetLowest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    409     //pmHDUGetLowest(): verify with all (fpa, chip, NULL) inputs
     368        psFree(fpa);
     369        psFree(camera);
     370        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     371    }
     372
     373
     374    // Call pmHDUGetLowest() with all (fpa, chip, NULL) inputs
    410375    {
    411376        psMemId id = psMemGetId();
     
    420385        pmHDU *hdu = pmHDUGetLowest(fpa, chip, NULL);
    421386        ok(hdu == chip->hdu, "pmHDUGetLowest(fpa, chip, NULL)");
    422         myFreeFPA(fpa);
    423         psFree(camera);
    424         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    425     }
    426 
    427 
    428     //pmHDUGetLowest() tests
    429     //pmHDU *pmHDUGetLowest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    430     //pmHDUGetLowest(): verify with all (fpa, NULL, NULL) inputs
     387        psFree(fpa);
     388        psFree(camera);
     389        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     390    }
     391
     392
     393    // Call pmHDUGetLowest() with all (fpa, NULL, NULL) inputs
    431394    {
    432395        psMemId id = psMemGetId();
     
    441404        pmHDU *hdu = pmHDUGetLowest(fpa, NULL, NULL);
    442405        ok(hdu == fpa->hdu, "pmHDUGetLowest(fpa, NULL, NULL)");
    443         myFreeFPA(fpa);
    444         psFree(camera);
    445         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    446     }
    447 
     406        psFree(fpa);
     407        psFree(camera);
     408        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     409    }
    448410
    449411
    450412    // ----------------------------------------------------------------------
    451413    //pmHDUGetHighest() tests
    452     //pmHDU *pmHDUGetHighest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    453     //pmHDUGetHighest(): verify with all NULL inputs
     414    // Call pmHDUGetHighest() with all NULL inputs
    454415    {
    455416        psMemId id = psMemGetId();
     
    460421
    461422
    462     //pmHDUGetHighest() tests
    463     //pmHDU *pmHDUGetHighest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    464     //pmHDUGetHighest(): verify with all acceptable inputs
     423    // Call pmHDUGetHighest() with all acceptable inputs
    465424    {
    466425        psMemId id = psMemGetId();
     
    475434        pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell);
    476435        ok(hdu == fpa->hdu, "pmHDUGetHighest(fpa, chip, cell)");
    477         myFreeFPA(fpa);
    478         psFree(camera);
    479         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    480     }
    481 
    482 
    483     //pmHDUGetHighest() tests
    484     //pmHDU *pmHDUGetHighest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    485     //pmHDUGetHighest(): verify with (NULL, chip, cell) inputs
     436        psFree(fpa);
     437        psFree(camera);
     438        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     439    }
     440
     441
     442    // Call pmHDUGetHighest() with (NULL, chip, cell) inputs
    486443    {
    487444        psMemId id = psMemGetId();
     
    496453        pmHDU *hdu = pmHDUGetHighest(NULL, chip, cell);
    497454        ok(hdu == chip->hdu, "pmHDUGetHighest(NULL, chip, cell)");
    498         myFreeFPA(fpa);
    499         psFree(camera);
    500         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    501     }
    502 
    503 
    504     //pmHDUGetHighest() tests
    505     //pmHDU *pmHDUGetHighest(const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
    506     //pmHDUGetHighest(): verify with (NULL, NULL, cell) inputs
     455        psFree(fpa);
     456        psFree(camera);
     457        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     458    }
     459
     460
     461    // Call pmHDUGetHighest() with (NULL, NULL, cell) inputs
    507462    {
    508463        psMemId id = psMemGetId();
     
    517472        pmHDU *hdu = pmHDUGetHighest(NULL, NULL, cell);
    518473        ok(hdu == cell->hdu, "pmHDUGetHighest(NULL, NULL, cell)");
    519         myFreeFPA(fpa);
    520         psFree(camera);
    521         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    522     }
    523 
    524 
    525 }
     474        psFree(fpa);
     475        psFree(camera);
     476        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     477    }
     478}
Note: See TracChangeset for help on using the changeset viewer.