Index: trunk/psModules/test/camera/tap_pmFPAExtent.c
===================================================================
--- trunk/psModules/test/camera/tap_pmFPAExtent.c	(revision 14882)
+++ trunk/psModules/test/camera/tap_pmFPAExtent.c	(revision 15987)
@@ -5,9 +5,8 @@
 #include "tap.h"
 #include "pstap.h"
-// XXX: Use better name for the temporary FITS file
-// XXX: The code to generate and free the FPA hierarchy was copied from
-// tap-pmFPA.c.  EIther include it directly, or library, or something.
-// Also, get rid of the manual free functions and use psFree() once
-// it correctly frees child members
+/* STATUS:
+    All functions are tested.
+*/
+
 // XXX: For the genSimpleFPA() code, add IDs to each function so that
 // the values set in each chip-?cell-?hdu-?image are unique
@@ -81,10 +80,13 @@
     cell->hdu = pmHDUAlloc("cellExtName");
     for (int i = 0 ; i < NUM_READOUTS ; i++) {
-        cell->readouts->data[i] = generateSimpleReadout(cell);
-    }
-
-    bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
+        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
+    }
+
+    bool rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     if (!rc) {
-        diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
+        rc = pmConfigFileRead(&cell->hdu->format, "../camera0/format0.config", "Camera format 0");
+        if (!rc) {
+            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
+        }
     }
 
@@ -102,5 +104,4 @@
 
     //XXX: Should the region be set some other way?  Like through the various config files?
-//    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
     psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
     // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
@@ -122,14 +123,7 @@
     psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
     psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
-//    chip->hdu = pmHDUAlloc("chipExtName");
-//
-//    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
-//    if (!rc) {
-//        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
-//    }
-//
     psArrayRealloc(chip->cells, NUM_CELLS);
     for (int i = 0 ; i < NUM_CELLS ; i++) {
-        chip->cells->data[i] = generateSimpleCell(chip);
+        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
     }
 
@@ -153,51 +147,14 @@
     psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
     psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
-//    fpa->hdu = pmHDUAlloc("fpaExtName");
-//
-//    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
-//    if (!rc) {
-//        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
-//    }
 
     psArrayRealloc(fpa->chips, NUM_CHIPS);
     for (int i = 0 ; i < NUM_CHIPS ; i++) {
-        fpa->chips->data[i] = generateSimpleChip(fpa);
-    }
-
-    // XXX: Eventually, when you finish the pmConcepts tests, add full concept
-    // reading code from wherever.
+        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
+    }
+
     pmConceptsBlankFPA(fpa);
-//    bool mdok;
-//    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
-//    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
-//    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
-
     return(fpa);
 }
 
-// XXX: This should only be necessary until the psFree() functions for
-// FPA/chip/cell/readout correctly free all child chips/cells/readouts
-void myFreeCell(pmCell *cell)
-{
-    for (int k = 0 ; k < cell->readouts->n ; k++) {
-        psFree(cell->readouts->data[k]);
-    }
-    psFree(cell);
-}
-
-void myFreeChip(pmChip *chip) {
-    for (int j = 0 ; j < chip->cells->n ; j++) {
-        myFreeCell(chip->cells->data[j]);
-    }
-    psFree(chip);
-}
-
-void myFreeFPA(pmFPA *fpa)
-{
-    for (int i = 0 ; i < fpa->chips->n ; i++) {
-        myFreeChip(fpa->chips->data[i]);
-    }
-    psFree(fpa);
-}
 
 
@@ -250,5 +207,5 @@
         ok(!errorFlag, "pmReadoutExtent() passed all tests");
 
-        myFreeFPA(fpa);
+        psFree(fpa);
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -258,5 +215,4 @@
     // ----------------------------------------------------------------------
     // pmCellExtent() tests: NULL input
-    // psRegion *pmCellExtent(const pmCell *cell)
     {
         psMemId id = psMemGetId();
@@ -312,5 +268,5 @@
         ok(!errorFlag, "pmCellExtent() passed all tests");
 
-        myFreeFPA(fpa);
+        psFree(fpa);
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -321,5 +277,4 @@
     // ----------------------------------------------------------------------
     // pmChipExtent() tests: NULL input
-    // psRegion *pmChipExtent(const pmChip *chip)
     {
         psMemId id = psMemGetId();
@@ -361,5 +316,5 @@
         ok(!errorFlag, "pmChipExtent() passed all tests");
 
-        myFreeFPA(fpa);
+        psFree(fpa);
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -369,5 +324,4 @@
     // ----------------------------------------------------------------------
     // pmChipPixels() tests: NULL input
-    // psRegion *pmChipPixels(const pmChip *chip)
     {
         psMemId id = psMemGetId();
@@ -416,5 +370,5 @@
         ok(!errorFlag, "pmChipPixels() passed all tests");
 
-        myFreeFPA(fpa);
+        psFree(fpa);
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -424,5 +378,4 @@
     // ----------------------------------------------------------------------
     // pmFPAPixels() tests: NULL input
-    // psRegion *pmFPAPixels(const pmFPA *fpa)
     {
         psMemId id = psMemGetId();
@@ -464,11 +417,7 @@
         psFree(tstExtent);
         psFree(actualExtent);
-        myFreeFPA(fpa);
+        psFree(fpa);
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
-
-
-
-
-}
+}
