Index: trunk/psModules/test/astrom/tst_pmAstrometry.c
===================================================================
--- trunk/psModules/test/astrom/tst_pmAstrometry.c	(revision 5366)
+++ trunk/psModules/test/astrom/tst_pmAstrometry.c	(revision 5435)
@@ -1,11 +1,11 @@
 /** @file  tst_pmAstrometry.c
  *
- *  @brief Contains the tests for pmAstrometry.[ch].  Only the pmxxxAlloc()
+ *  @brief Contains the tests: pmAstrometry.[ch].  Only the pmxxxAlloc()
  *  and psFree() functionality are used here.
  *
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-28 20:42:51 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-20 23:06:24 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,4 +32,7 @@
                           };
 
+#define CHIP_ALLOC_NAME "ChipName"
+#define CELL_ALLOC_NAME "CellName"
+
 psS32 main(psS32 argc, char* argv[])
 {
@@ -44,136 +47,126 @@
     // XXX: Do something more with these arguments.
     const psMetadata *camera = psMetadataAlloc();
-    psDB *db = NULL;
-    pmFPA* fpa = pmFPAAlloc(camera, db);
+    pmFPA* fpa = pmFPAAlloc(camera);
 
     if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.");
         return 1;
     }
 
     if (fpa->fromTangentPlane != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->fromTangentPlane to NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->fromTangentPlane to NULL.");
         return 2;
     }
 
     if (fpa->toTangentPlane != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->toTangentPlane to NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->toTangentPlane to NULL.");
         return 3;
     }
     if (fpa->projection != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->projection to NULL.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->projection to NULL.");
         return 4;
     }
 
     if (fpa->concepts == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->concepts.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->concepts.");
         return 5;
     }
 
-    if (fpa->analysis == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->analysis.");
+    if (fpa->analysis != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->analysis to NULL.");
         return 6;
     }
 
     if (fpa->camera != camera) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->camera.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->camera.");
         return 7;
     }
 
     if (fpa->chips == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->chips.");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->chips.");
         return 8;
     }
 
-    if (fpa->header != NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->header to NULL.");
+    if (fpa->private != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->private to NULL.");
         return 9;
     }
 
-    if (fpa->db != db) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->db.");
+    psFree(fpa);
+    psFree(camera);
+
+    return 0;
+}
+
+static psS32 testChipAlloc(void)
+{
+    const psMetadata *camera = psMetadataAlloc();
+    pmFPA* fpa = pmFPAAlloc(camera);
+    if (fpa == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.");
+        return 1;
+    }
+
+    pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
+    if (chip == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.");
+        return 1;
+    }
+
+    if (chip->col0 != -1) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->col0 set improperly.\n");
+        return 5;
+    }
+
+    if (chip->row0 != -1) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->row0 set improperly.\n");
+        return 6;
+    }
+
+    if (chip->toFPA != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toChip set improperly.\n");
+        return 7;
+    }
+
+    if (chip->fromFPA != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toFPA set improperly.\n");
+        return 8;
+    }
+
+    if (chip->concepts == NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->concepts set improperly.\n");
+        return 21;
+    } else {
+        psMetadataItem *tmpMeta = psMetadataLookup(chip->concepts, "CHIP.NAME");
+        if (0 != strcmp((char *) tmpMeta->data.V, CHIP_ALLOC_NAME)) {
+            psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n");
+            return (32);
+        }
+        // XXX: Code a test to ensure the metadata has the correct type
+    }
+
+    if (chip->analysis != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->analysis set improperly.\n");
         return 10;
     }
 
-    psFree(camera);
-    psFree(fpa);
-
-    return 0;
-}
-
-static psS32 testChipAlloc(void)
-{
-    const psMetadata *camera = psMetadataAlloc();
-    psDB *db = NULL;
-    pmFPA* fpa = pmFPAAlloc(camera, db);
-    if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");
-        return 1;
-    }
-
-    pmChip *chip = pmChipAlloc(fpa);
-    if (chip == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.");
-        return 1;
-    }
-
-    if (chip->col0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->col0 set improperly.\n");
-        return 5;
-    }
-
-    if (chip->row0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->row0 set improperly.\n");
-        return 6;
-    }
-
-    if (chip->toFPA != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->toChip set improperly.\n");
-        return 7;
-    }
-
-    if (chip->fromFPA != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->toFPA set improperly.\n");
-        return 8;
-    }
-
-    if (chip->concepts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->concepts set improperly.\n");
-        return 21;
-    }
-
-    if (chip->analysis == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->analysis set improperly.\n");
-        return 10;
-    }
-
     if (chip->cells == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->cells set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->cells set improperly.\n");
         return 22;
     }
 
     if (chip->parent != fpa) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->parent set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->parent set improperly.\n");
         return 23;
     }
 
     if (chip->valid != false) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->valid set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->valid set improperly.\n");
         return 24;
     }
 
-    if (chip->extname != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->extname set improperly.\n");
+    if (chip->private != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->private set improperly.\n");
         return 25;
-    }
-
-    if (chip->pixels != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->pixels set improperly.\n");
-        return 26;
-    }
-
-    if (chip->header != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "chip->header set improperly.\n");
-        return 27;
     }
 
@@ -187,86 +180,87 @@
 static psS32 testCellAlloc(void)
 {
-    psDB *db = NULL;
     const psMetadata *camera = psMetadataAlloc();
-    pmFPA* fpa = pmFPAAlloc(camera, db);
+    pmFPA* fpa = pmFPAAlloc(camera);
     if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.n");
-        return 1;
-    }
-
-    pmChip *chip = pmChipAlloc(fpa);
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.n");
+        return 1;
+    }
+
+    pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME);
     if (chip == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.n");
         return 2;
     }
 
-    pmCell *cell = pmCellAlloc(chip);
+    pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, CELL_ALLOC_NAME);
     if (cell == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.n");
         return 3;
     }
 
     if (cell->col0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->col0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->col0 set improperly.\n");
         return 5;
     }
 
     if (cell->row0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->row0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->row0 set improperly.\n");
         return 6;
     }
 
     if (cell->toChip != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->toChip set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toChip set improperly.\n");
         return 7;
     }
 
     if (cell->toFPA != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->toFPA set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toFPA set improperly.\n");
         return 8;
     }
 
     if (cell->toSky != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->toSky set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toSky set improperly.\n");
         return 9;
     }
 
-    if (cell->analysis == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->analysis set improperly.\n");
+    if (cell->concepts == NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->concepts set improperly.\n");
+        return 21;
+    } else {
+        psMetadataItem *tmpMeta = psMetadataLookup(cell->concepts, "CELL.NAME");
+        if (0 != strcmp((char *) tmpMeta->data.V, CELL_ALLOC_NAME)) {
+            psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n");
+            return (32);
+        }
+        // XXX: Code a test to ensure the metadata has the correct type
+    }
+
+    if (cell->camera != camera) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->camera set improperly.\n");
+        return 20;
+    }
+
+    if (cell->analysis != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->analysis set improperly.\n");
         return 10;
     }
 
-    if (cell->concepts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->concepts set improperly.\n");
-        return 21;
-    }
-
     if (cell->readouts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->readouts set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->readouts set improperly.\n");
         return 22;
     }
 
     if (cell->parent != chip) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->parent set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->parent set improperly.\n");
         return 23;
     }
 
     if (cell->valid != false) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->valid set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->valid set improperly.\n");
         return 24;
     }
 
-    if (cell->extname != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->extname set improperly.\n");
-        return 25;
-    }
-
-    if (cell->pixels != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->pixels set improperly.\n");
-        return 26;
-    }
-
-    if (cell->header != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "cell->header set improperly.\n");
+    if (cell->private != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->private set improperly.\n");
         return 27;
     }
@@ -282,22 +276,21 @@
 static psS32 testReadoutAlloc(void)
 {
-    psDB *db = NULL;
     const psMetadata *camera = psMetadataAlloc();
-    pmFPA* fpa = pmFPAAlloc(camera, db);
+    pmFPA* fpa = pmFPAAlloc(camera);
 
     if (fpa == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.\n");
-        return 1;
-    }
-
-    pmChip *chip = pmChipAlloc(fpa);
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.\n");
+        return 1;
+    }
+
+    pmChip *chip = pmChipAlloc(fpa, "ChipName");
     if (chip == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.\n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.\n");
         return 2;
     }
 
-    pmCell *cell = pmCellAlloc(chip);
+    pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, "CellName");
     if (cell == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmCellAlloc returned a NULL.\n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.\n");
         return 3;
     }
@@ -305,51 +298,56 @@
     pmReadout *readout = pmReadoutAlloc(cell);
     if (readout == NULL) {
-        psLogMsg(__func__,PS_LOG_ERROR, "pmReadoutAlloc returned a NULL.\n");
+        psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmReadoutAlloc returned a NULL.\n");
         return 4;
     }
 
     if (readout->col0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->col0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->col0 set improperly.\n");
         return 5;
     }
 
     if (readout->row0 != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->row0 set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->row0 set improperly.\n");
         return 6;
     }
 
     if (readout->colBins != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->colBins set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n");
         return 7;
     }
 
     if (readout->rowBins != -1) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->colBins set improperly.\n");
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n");
         return 8;
     }
 
     if (readout->image != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->image set improperly.\n");
-        return 9;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->image set improperly.\n");
+        return 10;
     }
 
     if (readout->mask != NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->mask set improperly.\n");
-        return 10;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->mask set improperly.\n");
+        return 12;
+    }
+
+    if (readout->weight != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->weight set improperly.\n");
+        return 14;
+    }
+
+    if (readout->bias != NULL) {
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->bias set improperly.\n");
+        return 16;
     }
 
     if (readout->analysis == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->analysis set improperly.\n");
-        return 11;
-    }
-
-    if (readout->concepts == NULL) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->concepts set improperly.\n");
-        return 12;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->analysis set improperly.\n");
+        return 18;
     }
 
     if (readout->parent != cell) {
-        psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->parent set improperly.\n");
-        return 15;
+        psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->parent set improperly.\n");
+        return 20;
     }
 
@@ -362,2 +360,3 @@
     return 0;
 }
+
Index: trunk/psModules/test/config/Makefile.am
===================================================================
--- trunk/psModules/test/config/Makefile.am	(revision 5366)
+++ trunk/psModules/test/config/Makefile.am	(revision 5435)
@@ -4,5 +4,8 @@
 AM_CFLAGS  = @AM_CFLAGS@ $(PSMODULE_CFLAGS) $(SRCINC)
 
-TESTS =
+TESTS = \
+    tst_pmConfig
+
+tst_pmConfig_SOURCES = tst_pmConfig.c
 
 check_PROGRAMS = $(TESTS)
@@ -10,5 +13,9 @@
 TESTS_ENVIRONMENT = perl $(top_srcdir)/test/runTest --verified=$(srcdir)/verified
 
-tests:
+tests: $(TESTS)
+
+EXTRA_DIST = verified
+
+CLEANFILES = $(TESTS) temp/*
 
 test: check
Index: trunk/psModules/test/detrend/tst_pmFlatField.c
===================================================================
--- trunk/psModules/test/detrend/tst_pmFlatField.c	(revision 5366)
+++ trunk/psModules/test/detrend/tst_pmFlatField.c	(revision 5435)
@@ -21,6 +21,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-28 20:42:52 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-20 23:06:24 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -85,12 +85,8 @@
     inReadout->row0 = 0;
     inReadout->col0 = 0;
+    CREATE_AND_SET_IMAGE(inMask, U8, 0, 3,3);
+    inReadout->mask = inMask;
+    PRINT_MATRIX((inReadout->mask),U8,"Input mask:");
     PRINT_MATRIX(inImage,F64,"Input image:");
-
-    CREATE_AND_SET_IMAGE(inMask,U8,0,3,3)
-    pmReadout *inMaskReadout = pmReadoutAlloc(NULL);
-    inMaskReadout->image = inMask;
-    inMaskReadout->row0 = 0;
-    inMaskReadout->col0 = 0;
-    PRINT_MATRIX(inMask,U8,"Input mask:");
 
     CREATE_AND_SET_IMAGE(flatImage1,F64,2.0,3,3)
@@ -101,5 +97,5 @@
     PRINT_MATRIX(flatImage1,F64,"Flat image:");
 
-    if ( !pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( !pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test A - Returned false should be true");
         return 1;
@@ -116,9 +112,9 @@
     PRINT_MATRIX(flatImage2, F64, "Flat image:");
     flatReadout->image = flatImage2;
-    if ( !pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( !pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test B - Returned false should be true");
         return 2;
     }
-    PRINT_MATRIX(inMaskReadout->image, PS_TYPE_MASK_DATA, "Resulting mask:");
+    PRINT_MATRIX(inReadout->mask, PS_TYPE_MASK_DATA, "Resulting mask:");
     PRINT_MATRIX(inImage,F64,"Resulting image:");
     printFooter(stdout, "pmFlatField", "Test B - Mask flat image data", true);
@@ -135,5 +131,5 @@
     psFree(inReadout->mask);
     inReadout->mask = mask1;
-    if ( !pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( !pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test C - Returned false should be true");
         return 3;
@@ -149,5 +145,5 @@
     printNegativeTestHeader(stdout,"pmFlatField", "Test D - Attempt to use null flat readout",
                             "Null not allowed for flat readout", 0);
-    if( pmFlatField(inReadout, inMaskReadout, NULL) ) {
+    if( pmFlatField(inReadout, NULL) ) {
         psError(PS_ERR_UNKNOWN,true,"Test D - Returned true should be false");
         return 4;
@@ -162,9 +158,9 @@
     psImage *temp = inReadout->image;
     inReadout->image = NULL;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test E - Returned true should be false" );
         return 5;
     }
-    inReadout->image = temp;
+    inReadout->image = temp    ;
     printFooter(stdout, "pmFlatField", "Test E - Attempt to use null input image", true);
     printf("\n\n\n");
@@ -176,5 +172,5 @@
     temp = flatReadout->image;
     flatReadout->image = NULL;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test F - Returned true should be false" );
         return 6;
@@ -191,5 +187,5 @@
     temp = flatReadout->image;
     flatReadout->image = smallFlat;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test G - Returned true should be false");
         return 7;
@@ -198,5 +194,4 @@
     printFooter(stdout, "pmFlatField", "Test G - Attempt to use input image bigger than flat image", true);
     printf("\n\n\n");
-
 
     // Test H - Attempt to use input image mask bigger than flat image
@@ -204,14 +199,12 @@
                             "Input image mask size exceeds that of flat image", 0);
     CREATE_AND_SET_IMAGE(largeMask,F64,0.0,5,5);
-    temp = inReadout->mask;
-    inMaskReadout->image = largeMask;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    inReadout->mask = largeMask;
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test H - Returned true should be false");
         return 8;
     }
-    inReadout->mask = temp;
     printFooter(stdout, "pmFlatField", "Test H - Attempt to use input image mask bigger than flat image", true);
     printf("\n\n\n");
-
+    inReadout->mask = mask1;
 
     // Test I - Attempt to use offset greater than input image
@@ -220,5 +213,5 @@
     *(int*)&inReadout->col0 = 50;
     *(int*)&inReadout->row0 = 50;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test I - Returned true should be false");
         return 9;
@@ -234,5 +227,5 @@
                             "Complex types not allowed for input image", 0);
     *(psElemType* ) & inReadout->image->type.type = PS_TYPE_C64;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test J - Returned true should be false");
         return 10;
@@ -247,5 +240,5 @@
                             "Complex types not allowed for flat image", 0);
     *(psElemType* ) & flatReadout->image->type.type = PS_TYPE_C64;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test K - Returned ture should be false");
         return 11;
@@ -260,5 +253,5 @@
                             "Input and flat image types differ", 0);
     *(psElemType* ) & flatReadout->image->type.type = PS_TYPE_F32;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test L - Returned true should be false");
         return 12;
@@ -273,5 +266,5 @@
                             "Mask must be PS_TYPE_MASK type", 0);
     *(psElemType* ) & inReadout->mask->type.type = PS_TYPE_F32;
-    if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) {
+    if ( pmFlatField(inReadout, flatReadout) ) {
         psError(PS_ERR_UNKNOWN,true,"Test M - Returned true should be false");
         return 13;
@@ -283,8 +276,4 @@
 
     // Free memory
-    psFree(inMask);
-    psFree(largeMask);
-    inMaskReadout->image = NULL;
-    psFree(inMaskReadout);
     psFree(inReadout);
     psFree(flatReadout);
@@ -293,4 +282,5 @@
     //psFree(flatImage1);
     psFree(smallFlat);
+    psFree(largeMask);
 
     return 0;
Index: trunk/psModules/test/detrend/tst_pmNonLinear.c
===================================================================
--- trunk/psModules/test/detrend/tst_pmNonLinear.c	(revision 5366)
+++ trunk/psModules/test/detrend/tst_pmNonLinear.c	(revision 5435)
@@ -1,3 +1,3 @@
-/** @file tst_pmNonLinear.c
+/* @file tst_pmNonLinear.c
  *
  *  @brief Contains the tests for pmNonLinear.c:
@@ -16,6 +16,9 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-28 20:42:52 $
+ *  XXX: Add tests in which the lookup file has incorrect number of entries,
+ *  and where the data is outside the pmReadout range.
+ *
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-20 23:06:24 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -37,13 +40,25 @@
                           };
 
-
-int main(int argc, char* argv[])
-{
-    psLogSetFormat("HLNM");
-    return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);
-}
-
 #define NUM_ROWS 8
 #define NUM_COLS 8
+#define LOOKUP_FILENAME ".tmp_tst_pmNonLinearLookupFile"
+int main(int argc, char* argv[])
+{
+    psLogSetFormat("HLNM");
+    //
+    // We generate a lookup file for future tests.  We should probably remove
+    // it when we're done.
+    //
+    FILE *fp = fopen(LOOKUP_FILENAME, "w");
+    ;
+    for (psS32 i=0;i<PS_MAX(NUM_COLS, NUM_ROWS)*3;i++) {
+        fprintf(fp, "%f %f\n", (float) i, (float) (2 * i));
+    }
+    fclose(fp);
+
+    //    system("rm LOOKUP_FILENAME");
+    return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);
+}
+
 int doNonLinearityPolynomialTest(int numCols, int numRows)
 {
@@ -105,10 +120,7 @@
     float expect;
     int testStatus = true;
-    int tableSize = PS_MAX(numCols, numRows)*2;
     psImage *myImage = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     pmReadout *myReadout = pmReadoutAlloc(NULL);
     myReadout->image = myImage;
-    psVector *in = psVectorAlloc(tableSize, PS_TYPE_F32);
-    psVector *out = psVectorAlloc(tableSize, PS_TYPE_F32);
 
     printPositiveTestHeader(stdout, "pmNonLinear", "doNonLinearityLookupTest");
@@ -119,10 +131,5 @@
     }
 
-    for (i=0;i<tableSize;i++) {
-        in->data.F32[i] = (float) i;
-        out->data.F32[i] = (float) (2 * i);
-    }
-
-    myReadout = pmNonLinearityLookup(myReadout, in, out);
+    myReadout = pmNonLinearityLookup(myReadout, LOOKUP_FILENAME);
     for (i=0;i<numRows;i++) {
         for (j=0;j<numCols;j++) {
@@ -136,8 +143,5 @@
     }
 
-
-    psFree(myReadout);
-    psFree(in);
-    psFree(out);
+    psFree(myReadout);
     printFooter(stdout, "pmNonLinear", "doNonLinearityLookupTest", true);
     return(testStatus);
@@ -220,40 +224,14 @@
 int test03()
 {
-    int i;
-    int j;
-    int testStatus = true;
-    int tableSize = PS_MAX(NUM_COLS, NUM_ROWS)*3;
+    int testStatus = true;
     psImage *myImage = psImageAlloc(NUM_COLS, NUM_ROWS, PS_TYPE_F32);
     pmReadout *myReadout = pmReadoutAlloc(NULL);
     pmReadout *rc = NULL;
     myReadout->image = myImage;
-    psVector *in = psVectorAlloc(tableSize, PS_TYPE_F32);
-    psVector *inOne = psVectorAlloc(1, PS_TYPE_F32);
-    psVector *inSmall = psVectorAlloc(tableSize-1, PS_TYPE_F32);
-    psVector *inBig = psVectorAlloc(tableSize+1, PS_TYPE_F32);
-    psVector *out = psVectorAlloc(tableSize, PS_TYPE_F32);
-    psVector *outOne = psVectorAlloc(1, PS_TYPE_F32);
-    psVector *outSmall = psVectorAlloc(tableSize-1, PS_TYPE_F32);
-    psVector *outBig = psVectorAlloc(tableSize+1, PS_TYPE_F32);
 
     test03Init(myReadout);
-    for (i=0;i<tableSize;i++) {
-        in->data.F32[i] = (float) i;
-        out->data.F32[i] = (float) (2 * i);
-        inBig->data.F32[i] = (float) i;
-        outBig->data.F32[i] = (float) (2 * i);
-        if (i < tableSize-1) {
-            inSmall->data.F32[i] = (float) i;
-            outSmall->data.F32[i] = (float) (2 * i);
-        }
-    }
-    inBig->data.F32[tableSize] = (float) tableSize;
-    outBig->data.F32[tableSize] = (float) (2 * tableSize);
-    inOne->data.F32[0] = 0.0;
-    outOne->data.F32[0] = 0.0;
-
     printf("------------------------------------------------------------\n");
     printf("Calling pmNonLinearityLookup() with NULL input pmReadout.  Should generate error, return NULL.\n");
-    rc = pmNonLinearityLookup(NULL, in, out);
+    rc = pmNonLinearityLookup(NULL, LOOKUP_FILENAME);
     if (rc != NULL) {
         printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n");
@@ -265,5 +243,5 @@
     psImage *tmpImage = myReadout->image;
     myReadout->image = NULL;
-    rc = pmNonLinearityLookup(myReadout, in, out);
+    rc = pmNonLinearityLookup(myReadout, LOOKUP_FILENAME);
     if (rc != NULL) {
         printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n");
@@ -273,237 +251,16 @@
 
     printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with NULL inFlux psVector.  Should generate error, return NULL.\n");
-    rc = pmNonLinearityLookup(myReadout, NULL, out);
-    if (rc != NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n");
-        testStatus = false;
-    }
-
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with NULL outFlux psVector.  Should generate error, return NULL.\n");
-    rc = pmNonLinearityLookup(myReadout, in, NULL);
-    if (rc != NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n");
-        testStatus = false;
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors.  Should generate warning.\n");
-    rc = pmNonLinearityLookup(myReadout, in, outBig);
+    printf("Calling pmNonLinearityLookup() with non-existent lookup file.\n");
+    rc = pmNonLinearityLookup(myReadout, "I_DONT_EXIST");
     if (rc == NULL) {
         printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
         testStatus = false;
     }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors.  Should generate warning.\n");
-    rc = pmNonLinearityLookup(myReadout, in, outSmall);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors.  Should generate warning.\n");
-    rc = pmNonLinearityLookup(myReadout, inSmall, out);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors.  Should generate warning.\n");
-    rc = pmNonLinearityLookup(myReadout, inBig, out);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors.  Should generate warning.\n");
-    rc = pmNonLinearityLookup(myReadout, inSmall, outBig);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors.  Should generate warning.\n");
-    rc = pmNonLinearityLookup(myReadout, inBig, outSmall);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with inFlux psVector size 1.  Should generate error, return original pmReadout.\n");
-    rc = pmNonLinearityLookup(myReadout, inOne, out);
-    if (rc != myReadout) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() did not return the original pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) ((i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
+
 
     printf("------------------------------------------------------------\n");
     printf("Calling pmNonLinearityLookup() with one pixels outside inFlux range.  Should generate warnings.\n");
-    test03Init(myReadout);
-    myReadout->image->data.F32[0][0] = -1;
-    rc = pmNonLinearityLookup(myReadout, in, out);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if(i==0 && j==0) {
-                if(actual != 0.0) {
-                    printf("TEST ERROR: image[%d][%d] is %f, should be %f\n",i,j,actual,0.0);
-                }
-            } else {
-                if (FLT_EPSILON < fabs(expect - actual)) {
-                    printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                    testStatus = false;
-                }
-            }
-        }
-    }
-
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with one pixels outside inFlux range.  Should generate warnings.\n");
-    test03Init(myReadout);
-    myReadout->image->data.F32[NUM_ROWS-1][NUM_COLS-1] = 100;
-    rc = pmNonLinearityLookup(myReadout, in, out);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            psF32 actual = rc->image->data.F32[i][j];
-            if(i==(NUM_ROWS-1) && j==(NUM_COLS-1)) {
-                if(actual != (tableSize-1)*2) {
-                    printf("TEST ERROR: image[%d][%d] is %f, should be %f\n",i,j,actual,(tableSize-1)*2.0);
-                }
-            } else {
-                if (FLT_EPSILON < fabs(expect - actual)) {
-                    printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                    testStatus = false;
-                }
-            }
-        }
-    }
-
-    test03Init(myReadout);
-    printf("------------------------------------------------------------\n");
-    printf("Calling pmNonLinearityLookup() with image values not in vector.\n");
-    myReadout->image->data.F32[0][0] = 0.5;
-    rc = pmNonLinearityLookup(myReadout, in, out);
-    if (rc == NULL) {
-        printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n");
-        testStatus = false;
-    }
-    for (i=0;i<NUM_ROWS;i++) {
-        for (j=0;j<NUM_COLS;j++) {
-            psF32 expect = (float) (2 * (i + j));
-            if(i==0 && j==0) {
-                expect = 1.0;
-            }
-            psF32 actual = rc->image->data.F32[i][j];
-            if (FLT_EPSILON < fabs(expect - actual)) {
-                printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect);
-                testStatus = false;
-            }
-        }
-    }
-
-    psFree(myReadout);
-    psFree(in);
-    psFree(inOne);
-    psFree(inSmall);
-    psFree(inBig);
-    psFree(out);
-    psFree(outOne);
-    psFree(outSmall);
-    psFree(outBig);
+
+    psFree(myReadout);
 
     printFooter(stdout, "pmNonLinear", "Testing bad input parameter conditions.", true);
Index: trunk/psModules/test/objects/tst_pmObjects01.c
===================================================================
--- trunk/psModules/test/objects/tst_pmObjects01.c	(revision 5366)
+++ trunk/psModules/test/objects/tst_pmObjects01.c	(revision 5435)
@@ -1,5 +1,5 @@
-/** @file tst_pmFindObjects.c
+/** @file tst_pmObjects.c
  *
- *  @brief Contains the tests for pmSubtractSky.c:
+ *  @brief Contains the tests for pmObjects.c:
  *
  * test00: This code will ...
@@ -9,4 +9,6 @@
  * XXX: Must test
  *       pmSourceRoughClass
+ *  many others...
+ *
  *
  * XXX: Must test output results for many other functions.
@@ -23,8 +25,8 @@
 Weakly Tested:
     pmSourceMoments()
- 
+    most of psObjects.c is not tested
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-10-10 21:55:42 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-20 23:06:24 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -47,11 +49,9 @@
 //static int test06(void);
 //static int test07(void);
-/*
-static int test08(void);
+//static int test08(void);
 static int test09(void);
 static int test15(void);
 static int test16(void);
 static int test20(void);
-*/
 testDescription tests[] = {
                               {test00, 000, "pmObjects: structure allocators and deallocators", true, false},
@@ -63,11 +63,9 @@
                               //                              {test06, 001, "pmObjects: pmSourceSetPixelsCircle()", true, false},
                               //                              {test07, 001, "pmObjects: pmMin()", true, false},
-                              /*
-                                                            {test08, 001, "pmObjects: pmSourceModelGuess()", true, false},
-                                                            {test09, 001, "pmObjects: pmSourceContour()", true, false},
-                                                            {test15, 001, "pmObjects: pmSourceAddModel()", true, false},
-                                                            {test16, 001, "pmObjects: pmSourceSubModel()", true, false},
-                                                            {test20, 001, "pmObjects: pmSourceSubModel()", true, false},
-                              */
+                              //                              {test08, 001, "pmObjects: pmSourceModelGuess()", true, false},
+                              {test09, 001, "pmObjects: pmSourceContour()", true, false},
+                              {test15, 001, "pmObjects: pmSourceAddModel()", true, false},
+                              {test16, 001, "pmObjects: pmSourceSubModel()", true, false},
+                              {test20, 001, "pmObjects: pmSourceSubModel()", true, false},
                               {NULL}
                           };
@@ -975,4 +973,318 @@
 }
 
+#define TST09_NUM_ROWS 70
+#define TST09_NUM_COLS 70
+#define TST09_SKY 5.0
+#define TST09_INNER_RADIUS 3
+#define TST09_OUTER_RADIUS 10
+#define LEVEL (TST09_SKY + 10.0)
+/******************************************************************************
+test09(): We first test pmSourceContour() with various NULL and unallowable
+input parameters.
+ 
+XXX: We don't verify the numbers.
+ *****************************************************************************/
+int test09( void )
+{
+    bool testStatus = true;
+    psImage *imgData = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_F32);
+    psImageInit(imgData, TST09_SKY);
+    psImage *imgMask = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_U8);
+    psImageInit(imgMask, 0);
+    pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST09_NUM_ROWS / 2),
+                                  (psF32) (TST09_NUM_COLS / 2),
+                                  200.0,
+                                  PM_PEAK_LONE);
+    pmSource *tmpSource = pmSourceAlloc();
+    tmpSource->pixels = imgData;
+    tmpSource->mask = imgMask;
+    tmpSource->peak = tmpPeak;
+    psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0);
+    if (rc == false) {
+        printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceContour with NULL pmSource .  Should generate error, return FALSE.\n");
+    rc = pmSourceContour(NULL, imgData, LEVEL, PS_CONTOUR_CRUDE);
+    if (rc != false) {
+        printf("TEST ERROR: pmSourceContour() returned TRUE.\n");
+        testStatus = false;
+        psFree(rc);
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceContour with NULL psImage .  Should generate error, return FALSE.\n");
+    rc = pmSourceContour(tmpSource, NULL, LEVEL, PS_CONTOUR_CRUDE);
+    if (rc != FALSE) {
+        printf("TEST ERROR: pmSourceContour() returned TRUE.\n");
+        testStatus = false;
+        psFree(rc);
+    }
+
+    //
+    // XXX: pmSourceContour() has a problem with contour tops/bottoms.
+    // Must correct this.
+    //
+    if (1) {
+        printf("----------------------------------------------------------------------------------\n");
+        printf("Calling pmSourceContour with acceptable data.\n");
+        printf("NOTE: must figure out the parameters for this test to be meaningful.\n");
+        tmpSource->modelPSF->params->data.F32[0] = TST09_SKY;
+        tmpSource->modelPSF->params->data.F32[1] = 15.0;
+        tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST09_NUM_ROWS / 2);
+        tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST09_NUM_COLS / 2);
+        tmpSource->modelPSF->params->data.F32[4] = 2.0;
+        tmpSource->modelPSF->params->data.F32[5] = 2.0;
+        tmpSource->modelPSF->params->data.F32[6] = 2.0;
+        rc = pmSourceContour(tmpSource, imgData, LEVEL, PS_CONTOUR_CRUDE);
+        if (rc == false) {
+            printf("TEST ERROR: pmSourceContour() returned FALSE.\n");
+            testStatus = false;
+        } else {
+            psFree(rc);
+        }
+    }
+
+    psFree(tmpSource);
+    return(testStatus);
+}
+
+#define TST15_NUM_ROWS 100
+#define TST15_NUM_COLS 100
+#define TST15_SKY 10.0
+#define TST15_INNER_RADIUS 3
+#define TST15_OUTER_RADIUS 5
+/******************************************************************************
+test15(): We first test pmSourceAddModel() with various NULL and unallowable
+input parameters.
+ 
+XXX: We don't verify the numbers.
+ *****************************************************************************/
+int test15( void )
+{
+    bool testStatus = true;
+    psImage *imgData = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_F32);
+    psImageInit(imgData, TST15_SKY);
+    psImage *imgMask = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_U8);
+    psImageInit(imgMask, 0);
+    pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST15_NUM_ROWS / 2),
+                                  (psF32) (TST15_NUM_COLS / 2),
+                                  200.0,
+                                  PM_PEAK_LONE);
+    pmSource *tmpSource = pmSourceAlloc();
+    tmpSource->pixels = imgData;
+    tmpSource->mask = imgMask;
+    tmpSource->peak = tmpPeak;
+    psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0);
+    if (rc == false) {
+        printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n");
+        testStatus = false;
+    }
+
+
+    tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS);
+    tmpSource->modelPSF->params->data.F32[0] = 5.0;
+    tmpSource->modelPSF->params->data.F32[1] = 70.0;
+    tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST15_NUM_ROWS / 2);
+    tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST15_NUM_COLS / 2);
+    tmpSource->modelPSF->params->data.F32[4] = 1.0;
+    tmpSource->modelPSF->params->data.F32[5] = 1.0;
+    tmpSource->modelPSF->params->data.F32[6] = 2.0;
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceAddModel with NULL psImage.  Should generate error, return FALSE.\n");
+    rc = pmSourceAddModel(NULL, tmpSource, true);
+    if (rc == true) {
+        printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceAddModel with NULL psSrc.  Should generate error, return FALSE.\n");
+    rc = pmSourceAddModel(imgData, NULL, true);
+    if (rc == true) {
+        printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceAddModel with acceptable data.\n");
+    rc = pmSourceAddModel(imgData, tmpSource, true);
+    if (rc != true) {
+        printf("TEST ERROR: pmSourceAddModel() returned FALSE.\n");
+        testStatus = false;
+    }
+
+    psFree(tmpSource);
+    psFree(imgData);
+    return(testStatus);
+}
+
+#define TST16_NUM_ROWS 100
+#define TST16_NUM_COLS 100
+#define TST16_SKY 10.0
+#define TST16_INNER_RADIUS 3
+#define TST16_OUTER_RADIUS 5
+/******************************************************************************
+test16(): We first test pmSourceSubModel() with various NULL and unallowable
+input parameters.
+ 
+XXX: We don't verify the numbers.
+ *****************************************************************************/
+int test16( void )
+{
+    bool testStatus = true;
+    psImage *imgData = psImageAlloc(TST16_NUM_COLS, TST16_NUM_ROWS, PS_TYPE_F32);
+    for (psS32 i = 0 ; i < imgData->numRows; i++) {
+        for (psS32 j = 0 ; j < imgData->numCols; j++) {
+            imgData->data.F32[i][j] = TST16_SKY;
+        }
+    }
+    pmSource *tmpSource = NULL;
+    psBool rc = false;
+
+    pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST16_NUM_ROWS / 2),
+                                  (psF32) (TST16_NUM_COLS / 2),
+                                  200.0,
+                                  PM_PEAK_LONE);
+
+    printf("Calling pmSourceLocalSky with valid data.\n");
+    tmpPeak->x = (psF32) (TST16_NUM_ROWS / 2);
+    tmpPeak->y = (psF32) (TST16_NUM_COLS / 2);
+    tmpSource = pmSourceLocalSky(imgData,
+                                 tmpPeak,
+                                 PS_STAT_SAMPLE_MEAN,
+                                 (psF32) TST16_INNER_RADIUS,
+                                 (psF32) TST16_OUTER_RADIUS);
+
+    if (tmpSource == NULL) {
+        printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");
+        testStatus = false;
+    }
+
+    tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS);
+    tmpSource->modelPSF->params->data.F32[0] = 5.0;
+    tmpSource->modelPSF->params->data.F32[1] = 70.0;
+    tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST16_NUM_ROWS / 2);
+    tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST16_NUM_COLS / 2);
+    tmpSource->modelPSF->params->data.F32[4] = 1.0;
+    tmpSource->modelPSF->params->data.F32[5] = 1.0;
+    tmpSource->modelPSF->params->data.F32[6] = 2.0;
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceSubModel with NULL psImage.  Should generate error, return FALSE.\n");
+    rc = pmSourceSubModel(NULL, tmpSource, true);
+    if (rc == true) {
+        printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceSubModel with NULL psSrc.  Should generate error, return FALSE.\n");
+    rc = pmSourceSubModel(imgData, NULL, true);
+    if (rc == true) {
+        printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceSubModel with acceptable data.\n");
+    rc = pmSourceSubModel(imgData, tmpSource, true);
+    if (rc != true) {
+        printf("TEST ERROR: pmSourceSubModel() returned FALSE.\n");
+        testStatus = false;
+    }
+
+    psFree(tmpSource);
+    psFree(imgData);
+    return(testStatus);
+}
+
+#define TST20_NUM_ROWS 100
+#define TST20_NUM_COLS 100
+#define TST20_SKY 10.0
+#define TST20_INNER_RADIUS 3
+#define TST20_OUTER_RADIUS 5
+/******************************************************************************
+test20(): We first test pmSourceSubModel() with various NULL and unallowable
+input parameters.
+ 
+XXX: We don't verify the numbers.
+ *****************************************************************************/
+int test20( void )
+{
+    bool testStatus = true;
+    psImage *imgData = psImageAlloc(TST20_NUM_COLS, TST20_NUM_ROWS, PS_TYPE_F32);
+    for (psS32 i = 0 ; i < imgData->numRows; i++) {
+        for (psS32 j = 0 ; j < imgData->numCols; j++) {
+            imgData->data.F32[i][j] = TST20_SKY;
+        }
+    }
+    pmSource *tmpSource = NULL;
+    psBool rc = false;
+
+    pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST20_NUM_ROWS / 2),
+                                  (psF32) (TST20_NUM_COLS / 2),
+                                  200.0,
+                                  PM_PEAK_LONE);
+
+    printf("Calling pmSourceLocalSky with valid data.\n");
+    tmpPeak->x = (psF32) (TST20_NUM_ROWS / 2);
+    tmpPeak->y = (psF32) (TST20_NUM_COLS / 2);
+    tmpSource = pmSourceLocalSky(imgData,
+                                 tmpPeak,
+                                 PS_STAT_SAMPLE_MEAN,
+                                 (psF32) TST20_INNER_RADIUS,
+                                 (psF32) TST20_OUTER_RADIUS);
+
+    if (tmpSource == NULL) {
+        printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");
+        testStatus = false;
+    }
+
+    tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS);
+
+
+    tmpSource->modelPSF->params->data.F32[0] = 5.0;
+    tmpSource->modelPSF->params->data.F32[1] = 70.0;
+    tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST20_NUM_ROWS / 2);
+    tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST20_NUM_COLS / 2);
+    tmpSource->modelPSF->params->data.F32[4] = 1.0;
+    tmpSource->modelPSF->params->data.F32[5] = 1.0;
+    tmpSource->modelPSF->params->data.F32[6] = 2.0;
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceFitModel with NULL psImage.  Should generate error, return FALSE.\n");
+    rc = pmSourceFitModel(tmpSource, NULL);
+    if (rc == true) {
+        printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceFitModel with NULL pmSource.  Should generate error, return FALSE.\n");
+    rc = pmSourceFitModel(NULL, imgData);
+    if (rc == true) {
+        printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n");
+        testStatus = false;
+    }
+
+    printf("----------------------------------------------------------------------------------\n");
+    printf("Calling pmSourceFitModel with acceptable data.\n");
+    rc = pmSourceFitModel(tmpSource, imgData);
+    printf("pmSourceFitModel returned %d\n", rc);
+
+    // XXX: Memory leaks are not being tested
+    psVector *junk = psVectorAlloc(10, PS_TYPE_F32);
+    junk->data.F32[0] = 0.0;
+
+    psFree(tmpSource);
+    psFree(imgData);
+    return(testStatus);
+}
+
+
 // this code will
 
