Changeset 15987 for trunk/psModules/test/camera/tap_pmFPAUtils.c
- Timestamp:
- Jan 2, 2008, 10:53:30 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/camera/tap_pmFPAUtils.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/camera/tap_pmFPAUtils.c
r14882 r15987 5 5 #include "tap.h" 6 6 #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 */ 15 10 16 11 #define CHIP_ALLOC_NAME "ChipName" … … 81 76 cell->hdu = pmHDUAlloc("cellExtName"); 82 77 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"); 87 83 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 } 89 88 } 90 89 … … 102 101 103 102 //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);105 103 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. 107 105 psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC"); 108 106 psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region); … … 122 120 psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 123 121 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 131 123 psArrayRealloc(chip->cells, NUM_CELLS); 132 124 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 } 139 127 return(chip); 140 128 } … … 153 141 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 154 142 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 // }161 143 162 144 psArrayRealloc(fpa->chips, NUM_CHIPS); 163 145 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 } 169 148 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 175 149 return(fpa); 176 }177 178 // XXX: This should only be necessary until the psFree() functions for179 // FPA/chip/cell/readout correctly free all child chips/cells/readouts180 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 150 } 202 151 … … 207 156 psLogSetLevel(PS_LOG_INFO); 208 157 psTraceSetLevel("err", ERR_TRACE_LEVEL); 209 plan_tests(72); 158 plan_tests(40); 159 210 160 211 161 // ---------------------------------------------------------------------- 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 223 184 { 224 185 psMemId id = psMemGetId(); 225 186 // 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"); 233 189 int rc = pmFPAFindChip(fpa, NULL); 234 190 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 243 197 { 244 198 psMemId id = psMemGetId(); 245 199 // 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"); 253 202 // Set unique chip names 254 203 for (int chipID = 0 ; chipID < fpa->chips->n ; chipID++) { … … 267 216 } 268 217 269 myFreeFPA(fpa); 270 psFree(camera); 218 psFree(fpa); 271 219 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 272 220 } … … 275 223 276 224 // ---------------------------------------------------------------------- 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"); 281 230 ok(-1 == rc, "pmChipFindCell() returns -1 with NULL pmChip input param"); 282 231 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 283 232 } 284 233 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 288 247 { 289 248 psMemId id = psMemGetId(); 290 249 // Generate the pmChip heirarchy 291 psMetadata *camera = psMetadataAlloc(); 292 pmFPA* fpa = generateSimpleFPA(camera); 250 pmFPA* fpa = generateSimpleFPA(NULL); 293 251 pmChip *chip = fpa->chips->data[0]; 294 252 pmCell *cell = chip->cells->data[0]; … … 298 256 int rc = pmChipFindCell(chip, NULL); 299 257 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 308 264 { 309 265 psMemId id = psMemGetId(); 310 266 // Generate the pmChip heirarchy 311 psMetadata *camera = psMetadataAlloc(); 312 pmFPA* fpa = generateSimpleFPA(camera); 267 pmFPA* fpa = generateSimpleFPA(NULL); 313 268 pmChip *chip = fpa->chips->data[0]; 314 269 pmCell *cell = chip->cells->data[0]; … … 332 287 } 333 288 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 }
Note:
See TracChangeset
for help on using the changeset viewer.
