Changeset 15987
- Timestamp:
- Jan 2, 2008, 10:53:30 AM (18 years ago)
- Location:
- trunk/psModules/test/camera
- Files:
-
- 2 added
- 13 edited
-
tap_pmFPA.c (modified) (18 diffs)
-
tap_pmFPACellSquish.c (modified) (5 diffs)
-
tap_pmFPAConstruct.c (modified) (3 diffs)
-
tap_pmFPAExtent.c (modified) (14 diffs)
-
tap_pmFPAFlags.c (modified) (12 diffs)
-
tap_pmFPAHeader.c (modified) (16 diffs)
-
tap_pmFPALevel.c (modified) (3 diffs)
-
tap_pmFPAMaskW.c (modified) (8 diffs)
-
tap_pmFPAReadWrite.c (modified) (56 diffs)
-
tap_pmFPAUtils.c (modified) (10 diffs)
-
tap_pmFPAView.c (modified) (30 diffs)
-
tap_pmHDU.c (modified) (13 diffs)
-
tap_pmHDUUtils.c (modified) (24 diffs)
-
tap_pmReadoutFake.c (added)
-
tap_pmReadoutStack.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/camera/tap_pmFPA.c
r14881 r15987 1 /** @file tst_pmAstrometry.c2 *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 Hawaii23 */24 1 #include <stdio.h> 25 2 #include <string.h> … … 28 5 #include "tap.h" 29 6 #include "pstap.h" 7 /* STATUS: 8 All functions are tested. 9 */ 30 10 31 11 #define CHIP_ALLOC_NAME "ChipName" … … 89 69 psArrayRealloc(cell->readouts, NUM_READOUTS); 90 70 for (int i = 0 ; i < NUM_READOUTS ; i++) { 91 cell->readouts->data[i] = generateSimpleReadout(cell);71 cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell)); 92 72 } 93 73 return(cell); … … 108 88 psArrayRealloc(chip->cells, NUM_CELLS); 109 89 for (int i = 0 ; i < NUM_CELLS ; i++) { 110 chip->cells->data[i] = generateSimpleCell(chip);90 chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip)); 111 91 } 112 92 return(chip); … … 129 109 psArrayRealloc(fpa->chips, NUM_CHIPS); 130 110 for (int i = 0 ; i < NUM_CHIPS ; i++) { 131 fpa->chips->data[i] = generateSimpleChip(fpa);111 fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa)); 132 112 } 133 113 … … 135 115 } 136 116 137 // XXX: This should only be necessary until the psFree() functions for138 // FPA/chip/cell/readout correctly free all child chips/cells/readouts139 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 }161 117 162 118 psS32 main(psS32 argc, char* argv[]) … … 164 120 psLogSetFormat("HLNM"); 165 121 psLogSetLevel(PS_LOG_INFO); 166 plan_tests( 56);122 plan_tests(92); 167 123 168 124 // ------------------------------------------------------------------------ 169 125 // 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. 171 136 { 172 137 psMemId id = psMemGetId(); … … 186 151 psMemCheckArray(fpa->chips), "pmFPAAlloc() set ->chips correctly"); 187 152 ok(fpa->hdu == NULL, "pmFPAAlloc() set ->hdu to NULL"); 188 // ok(fpa->wrote_phu == false, "pmFPAAlloc() set ->wrote_phu to FALSE");189 153 psFree(fpa); 190 154 psFree(camera); … … 192 156 } 193 157 158 194 159 // Populate the pmFPA struct with real data to ensure they were psFree()'ed correctly. 195 160 { 196 161 psMemId id = psMemGetId(); 197 162 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 227 167 228 168 // ------------------------------------------------------------------------ 229 169 // 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); 240 185 pmFPAFreeData(fpa); 241 186 ok(fpa->hdu->images == NULL, "pmFPAFreeData() correctly set fpa->hdu->images to NULL"); 242 187 ok(fpa->hdu->weights == NULL, "pmFPAFreeData() correctly set fpa->hdu->weights to NULL"); 243 188 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 260 211 // pmChipAlloc() tests 261 212 // XXX: Add tests for NULL inputs. 262 213 { 263 214 psMemId id = psMemGetId(); 264 psMetadata *camera = psMetadataAlloc(); 265 pmFPA* fpa = generateSimpleFPA(camera); 215 pmFPA* fpa = generateSimpleFPA(NULL); 266 216 pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME); 267 217 ok(chip != NULL, "pmChipAlloc() returned non-NULL"); … … 280 230 ok(chip->data_exists == false, "pmChipAlloc() set ->data_exists correctly"); 281 231 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 288 237 289 238 // Populate the pmChip struct with real data to ensure they were free'ed correctly. … … 292 241 pmChip *chip = generateSimpleChip(NULL); 293 242 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); 294 290 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 295 291 } … … 298 294 // ------------------------------------------------------------------------ 299 295 // 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 301 314 { 302 315 psMemId id = psMemGetId(); … … 319 332 ok(cell->data_exists == false, "pmCellAlloc() set ->data_exists correctly"); 320 333 ok(cell->hdu == NULL, "pmCellAlloc() set ->hdu to NULL"); 321 // ok(cell->wrote_phu == false, "pmCellAlloc() set ->wrote_phu correctly");322 334 psFree(camera); 323 335 psFree(fpa); … … 326 338 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 327 339 } 340 328 341 329 342 // Populate the pmCell struct with real data to ensure they were … … 333 346 pmCell *cell = generateSimpleCell(NULL); 334 347 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 // ------------------------------------------------------------------------ 339 379 // test pmCellFreeReadouts() 340 380 { … … 350 390 // ------------------------------------------------------------------------ 351 391 // 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 353 403 { 354 404 psMemId id = psMemGetId(); … … 380 430 } 381 431 432 382 433 // Populate the pmReadout struct with real data to ensure they were 383 434 // psFree()'ed correctly. … … 390 441 } 391 442 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 82 82 cell->hdu = pmHDUAlloc("cellExtName"); 83 83 for (int i = 0 ; i < NUM_READOUTS ; i++) { 84 cell->readouts->data[i] = generateSimpleReadout(cell);84 cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell)); 85 85 } 86 86 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"); 88 89 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 } 90 94 } 91 95 … … 123 127 psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 124 128 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 132 130 psArrayRealloc(chip->cells, NUM_CELLS); 133 131 for (int i = 0 ; i < NUM_CELLS ; i++) { 134 chip->cells->data[i] = generateSimpleCell(chip);132 chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip)); 135 133 } 136 137 // XXX: Add code to initialize chip pmConcepts138 139 140 134 return(chip); 141 135 } … … 154 148 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 155 149 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 163 150 psArrayRealloc(fpa->chips, NUM_CHIPS); 164 151 for (int i = 0 ; i < NUM_CHIPS ; i++) { 165 fpa->chips->data[i] = generateSimpleChip(fpa);152 fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa)); 166 153 } 167 154 168 // XXX: Eventually, when you finish the pmConcepts tests, add full concept169 // reading code from wherever.170 155 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 176 156 return(fpa); 177 }178 179 // XXX: This should only be necessary until the psFree() functions for180 // FPA/chip/cell/readout correctly free all child chips/cells/readouts181 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);202 157 } 203 158 … … 208 163 psLogSetLevel(PS_LOG_INFO); 209 164 psTraceSetLevel("err", ERR_TRACE_LEVEL); 210 plan_tests( 25);165 plan_tests(4); 211 166 212 167 … … 230 185 pmCell *cell = chip->cells->data[0]; 231 186 ok(pmCellSquish(cell, 0, false), "pmCellSquish(NULL) returned NULL"); 232 myFreeFPA(fpa);233 187 psFree(camera); 234 if (0) psFree(cell);188 psFree(fpa); 235 189 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 236 190 } -
trunk/psModules/test/camera/tap_pmFPAConstruct.c
r14882 r15987 14 14 psLogSetLevel(PS_LOG_INFO); 15 15 psTraceSetLevel("err", ERR_TRACE_LEVEL); 16 plan_tests( 72);16 plan_tests(9); 17 17 18 18 // ---------------------------------------------------------------------- … … 34 34 { 35 35 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 37 41 // Generate the pmFPA heirarchy 38 42 psMemId id = psMemGetId(); … … 44 48 } 45 49 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); 47 51 for (int chipID = 0 ; chipID < fpa->chips->n ; chipID++) { 48 52 pmChip *chip = fpa->chips->data[chipID]; -
trunk/psModules/test/camera/tap_pmFPAExtent.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 7 /* STATUS: 8 All functions are tested. 9 */ 10 12 11 // XXX: For the genSimpleFPA() code, add IDs to each function so that 13 12 // the values set in each chip-?cell-?hdu-?image are unique … … 81 80 cell->hdu = pmHDUAlloc("cellExtName"); 82 81 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"); 87 86 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 } 89 91 } 90 92 … … 102 104 103 105 //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 106 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 106 107 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value. … … 122 123 psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 123 124 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 //131 125 psArrayRealloc(chip->cells, NUM_CELLS); 132 126 for (int i = 0 ; i < NUM_CELLS ; i++) { 133 chip->cells->data[i] = generateSimpleCell(chip);127 chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip)); 134 128 } 135 129 … … 153 147 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 154 148 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 149 162 150 psArrayRealloc(fpa->chips, NUM_CHIPS); 163 151 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 169 155 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 156 return(fpa); 176 157 } 177 158 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 }202 159 203 160 … … 250 207 ok(!errorFlag, "pmReadoutExtent() passed all tests"); 251 208 252 myFreeFPA(fpa);209 psFree(fpa); 253 210 psFree(camera); 254 211 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 258 215 // ---------------------------------------------------------------------- 259 216 // pmCellExtent() tests: NULL input 260 // psRegion *pmCellExtent(const pmCell *cell)261 217 { 262 218 psMemId id = psMemGetId(); … … 312 268 ok(!errorFlag, "pmCellExtent() passed all tests"); 313 269 314 myFreeFPA(fpa);270 psFree(fpa); 315 271 psFree(camera); 316 272 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 321 277 // ---------------------------------------------------------------------- 322 278 // pmChipExtent() tests: NULL input 323 // psRegion *pmChipExtent(const pmChip *chip)324 279 { 325 280 psMemId id = psMemGetId(); … … 361 316 ok(!errorFlag, "pmChipExtent() passed all tests"); 362 317 363 myFreeFPA(fpa);318 psFree(fpa); 364 319 psFree(camera); 365 320 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 369 324 // ---------------------------------------------------------------------- 370 325 // pmChipPixels() tests: NULL input 371 // psRegion *pmChipPixels(const pmChip *chip)372 326 { 373 327 psMemId id = psMemGetId(); … … 416 370 ok(!errorFlag, "pmChipPixels() passed all tests"); 417 371 418 myFreeFPA(fpa);372 psFree(fpa); 419 373 psFree(camera); 420 374 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 424 378 // ---------------------------------------------------------------------- 425 379 // pmFPAPixels() tests: NULL input 426 // psRegion *pmFPAPixels(const pmFPA *fpa)427 380 { 428 381 psMemId id = psMemGetId(); … … 464 417 psFree(tstExtent); 465 418 psFree(actualExtent); 466 myFreeFPA(fpa);419 psFree(fpa); 467 420 psFree(camera); 468 421 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 469 422 } 470 471 472 473 474 } 423 } -
trunk/psModules/test/camera/tap_pmFPAFlags.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 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 12 33 // XXX: For the genSimpleFPA() code, add IDs to each function so that 13 34 // the values set in each chip-?cell-?hdu-?image are unique … … 82 103 cell->hdu = pmHDUAlloc("cellExtName"); 83 104 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"); 88 109 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 } 90 114 } 91 115 … … 103 127 104 128 //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);106 129 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 107 130 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value. … … 123 146 psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 124 147 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 //132 148 psArrayRealloc(chip->cells, NUM_CELLS); 133 149 for (int i = 0 ; i < NUM_CELLS ; i++) { 134 chip->cells->data[i] = generateSimpleCell(chip);150 chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip)); 135 151 } 136 152 … … 154 170 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 155 171 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 163 172 psArrayRealloc(fpa->chips, NUM_CHIPS); 164 173 for (int i = 0 ; i < NUM_CHIPS ; i++) { 165 fpa->chips->data[i] = generateSimpleChip(fpa);174 fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa)); 166 175 } 167 176 … … 169 178 // reading code from wherever. 170 179 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 176 180 return(fpa); 177 181 } 178 182 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 { 183 void 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 191 void 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 200 void SetFPAFileExists(pmFPA *fpa) { 198 201 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 208 void SetReadoutDataExists(pmReadout *readout) { 209 readout->data_exists = true; 210 } 211 212 void 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 220 void 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 229 void 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 } 202 235 } 203 236 … … 208 241 psLogSetLevel(PS_LOG_INFO); 209 242 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 408 246 // ---------------------------------------------------------------------- 409 247 // pmFPASetFileStatus() tests: verify with NULL pmFPA param … … 505 343 ok(!errorFlag, "pmFPASetFileStatus() set file status in all cells to FALSE"); 506 344 507 myFreeFPA(fpa);345 psFree(fpa); 508 346 psFree(camera); 509 347 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 510 348 } 511 349 512 // ---------------------------------------------------------------------- 513 // ---------------------------------------------------------------------- 514 // pmC ellSetDataStatus() tests: verify with NULL pmCellparam515 // bool pmC ellSetDataStatus(pmCell *cell, bool status)516 { 517 psMemId id = psMemGetId(); 518 bool rc = pmC ellSetDataStatus(NULL, false);519 ok(!rc, "pmC ellSetDataStatus() returned FALSE with NULL pmCellparam");520 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 521 } 522 523 524 // pmC ellSetDataStatus() tests: verify with acceptable data525 // bool pmC ellSetDataStatus(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) 526 364 { 527 365 psMemId id = psMemGetId(); … … 537 375 // First, set all flags to FALSE 538 376 bool correctStatus = false; 539 bool rc = pmC ellSetDataStatus(cell, correctStatus);540 ok(rc, "pmC ellSetDataStatus() returned successfully with acceptable input params");377 bool rc = pmChipSetFileStatus(chip, correctStatus); 378 ok(rc, "pmChipSetFileStatus() returned successfully with acceptable input params"); 541 379 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"); 554 400 555 401 // Second, set all flags to TRUE 556 402 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"); 572 426 573 427 // Third, set all flags to FALSE 574 428 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); 592 455 psFree(camera); 593 456 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 596 459 597 460 // ---------------------------------------------------------------------- 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) 611 472 { 612 473 psMemId id = psMemGetId(); … … 622 483 // First, set all flags to FALSE 623 484 bool correctStatus = false; 624 bool rc = pmC hipSetDataStatus(chip, correctStatus);625 ok(rc, "pmC hipSetDataStatus() returned successfully with acceptable input params");485 bool rc = pmCellSetFileStatus(cell, correctStatus); 486 ok(rc, "pmCellSetFileStatus() returned successfully with acceptable input params"); 626 487 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"); 647 501 648 502 // Second, set all flags to TRUE 649 503 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 675 521 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); 702 539 psFree(camera); 703 540 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 704 541 } 705 542 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 } 718 629 719 630 … … 806 717 ok(!errorFlag, "pmFPASetDataStatus() set file status in all cells to FALSE"); 807 718 808 myFreeFPA(fpa);719 psFree(fpa); 809 720 psFree(camera); 810 721 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 811 722 } 812 723 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 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" … … 84 79 cell->hdu = pmHDUAlloc(extname); 85 80 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"); 90 86 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 } 92 91 } 93 92 … … 104 103 } 105 104 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);108 105 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. 110 107 psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC"); 111 108 psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region); … … 134 131 psArrayRealloc(chip->cells, NUM_CELLS); 135 132 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 } 142 135 return(chip); 143 136 } … … 156 149 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 157 150 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 // }164 151 165 152 psArrayRealloc(fpa->chips, NUM_CHIPS); 166 153 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 } 172 156 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 178 157 return(fpa); 179 158 } 180 159 181 // XXX: This should only be necessary until the psFree() functions for182 // FPA/chip/cell/readout correctly free all child chips/cells/readouts183 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 }205 160 206 161 … … 210 165 psLogSetLevel(PS_LOG_INFO); 211 166 psTraceSetLevel("err", ERR_TRACE_LEVEL); 212 plan_tests( 25);167 plan_tests(75); 213 168 214 169 … … 225 180 ok(cell != NULL, "Allocated a pmCell successfully"); 226 181 ok(!pmCellReadHeader(cell, NULL), "pmCellReadHeader(cell, NULL) returned FALSE"); 227 myFreeFPA(fpa);182 psFree(fpa); 228 183 psFree(camera); 229 184 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 245 200 { 246 201 psMemId id = psMemGetId(); 247 248 202 // Create a FITS file for this test 249 203 psFits* fitsFileW = psFitsOpen(fitsFilename, "w"); … … 264 218 psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING, 265 219 "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 } 267 224 ok(rc == true, "pmConfigFileRead() was successful"); 268 225 rc = pmHDUWrite(hdu, fitsFileW); … … 289 246 // elsewhere. However, if we should test it, test it here. 290 247 291 myFreeFPA(fpa);248 psFree(fpa); 292 249 psFree(camera); 293 250 psFree(fitsFileR); … … 308 265 ok(cell != NULL, "Allocated a pmCell successfully"); 309 266 ok(!pmChipReadHeader(chip, NULL), "pmChipReadHeader(chip, NULL) returned FALSE"); 310 myFreeFPA(fpa);267 psFree(fpa); 311 268 psFree(camera); 312 269 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 347 304 psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING, 348 305 "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 } 350 310 ok(rc == true, "pmConfigFileRead() was successful"); 351 311 rc = pmHDUWrite(hdu, fitsFileW); … … 382 342 // elsewhere. However, if we should test it, test it here. 383 343 384 myFreeFPA(fpa);344 psFree(fpa); 385 345 psFree(camera); 386 346 psFree(fitsFileR); … … 401 361 ok(cell != NULL, "Allocated a pmCell successfully"); 402 362 ok(!pmFPAReadHeader(fpa, NULL), "pmFPAReadHeader(fpa, NULL) returned FALSE"); 403 myFreeFPA(fpa);363 psFree(fpa); 404 364 psFree(camera); 405 365 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 440 400 psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING, 441 401 "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 } 443 406 ok(rc == true, "pmConfigFileRead() was successful"); 444 407 rc = pmHDUWrite(hdu, fitsFileW); … … 476 439 // elsewhere. However, if we should test it, test it here. 477 440 478 myFreeFPA(fpa);441 psFree(fpa); 479 442 psFree(camera); 480 443 psFree(fitsFileR); 481 444 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 482 445 } 483 484 485 486 487 } 488 446 } 447 -
trunk/psModules/test/camera/tap_pmFPALevel.c
r14882 r15987 5 5 #include "tap.h" 6 6 #include "pstap.h" 7 /* STATUS: 8 All functions are tested. 9 XXX: Add tests for bad input parameters. 10 */ 7 11 8 12 #define ERR_TRACE_LEVEL 0 … … 13 17 psLogSetLevel(PS_LOG_INFO); 14 18 psTraceSetLevel("err", ERR_TRACE_LEVEL); 15 plan_tests(1 5);19 plan_tests(14); 16 20 17 // ----------------------------------------------------------------------18 21 // ---------------------------------------------------------------------- 19 22 // pmFPALevelToName(): tests … … 43 46 44 47 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 45 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");46 48 } 47 49 48 50 49 51 // ---------------------------------------------------------------------- 50 // ----------------------------------------------------------------------51 52 // pmFPALevelFromName(): tests 52 // pmFPALevel pmFPALevelFromName(const char *name)53 53 { 54 54 psMemId id = psMemGetId(); -
trunk/psModules/test/camera/tap_pmFPAMaskW.c
r14882 r15987 6 6 #include "pstap.h" 7 7 // XXX: Use better name for the temporary FITS file 8 // XXX: The code to generate and free the FPA hierarchy was copied from9 // tap-pmFPA.c. EIther include it directly, or library, or something.10 // Also, get rid of the manual free functions and use psFree() once11 // it correctly frees child members12 8 // XXX: For the genSimpleFPA() code, add IDs to each function so that 13 9 // the values set in each chip-?cell-?hdu-?image are unique … … 98 94 cell->hdu = pmHDUAlloc("cellExtName"); 99 95 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"); 104 101 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 } 106 106 } 107 107 … … 119 119 120 120 //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);122 121 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. 124 123 psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC"); 125 124 psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region); … … 139 138 psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 140 139 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 148 141 psArrayRealloc(chip->cells, NUM_CELLS); 149 142 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 } 156 145 return(chip); 157 146 } … … 170 159 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 171 160 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 // }178 161 179 162 psArrayRealloc(fpa->chips, NUM_CHIPS); 180 163 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 } 186 166 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 192 167 return(fpa); 193 }194 195 // XXX: This should only be necessary until the psFree() functions for196 // FPA/chip/cell/readout correctly free all child chips/cells/readouts197 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);218 168 } 219 169 … … 309 259 } 310 260 ok(!errorFlag, "pmReadoutSetMask() set the mask values correctly"); 311 myFreeFPA(fpa);261 psFree(fpa); 312 262 psFree(camera); 313 263 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 395 345 ok(!errorFlag, "pmReadoutGenerateMask() set the mask values correctly"); 396 346 397 myFreeFPA(fpa);347 psFree(fpa); 398 348 psFree(camera); 399 349 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 467 417 468 418 ok(!errorFlag, "pmReadoutSetWeight() set the weight values correctly (Poisson)"); 469 myFreeFPA(fpa);419 psFree(fpa); 470 420 psFree(camera); 471 421 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 472 422 } 473 474 475 476 } 477 423 } 424 -
trunk/psModules/test/camera/tap_pmFPAReadWrite.c
r14882 r15987 29 29 #define BASE_WEIGHT 70 30 30 #define VERBOSE 0 31 #define ERR_TRACE_LEVEL 031 #define ERR_TRACE_LEVEL 10 32 32 33 33 psPlaneTransform *PS_CREATE_2D_IDENTITY_PLANE_TRANSFORM() … … 80 80 cell->hdu = pmHDUAlloc("cellExtName"); 81 81 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"); 86 87 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 } 88 92 } 89 93 … … 101 105 102 106 //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);104 107 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 105 108 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value. … … 121 124 psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 122 125 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 130 127 psArrayRealloc(chip->cells, NUM_CELLS); 131 128 for (int i = 0 ; i < NUM_CELLS ; i++) { 132 chip->cells->data[i] = generateSimpleCell(chip);129 chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip)); 133 130 } 134 131 … … 152 149 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 153 150 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 // }160 151 161 152 psArrayRealloc(fpa->chips, NUM_CHIPS); 162 153 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 } 168 156 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 174 157 return(fpa); 175 }176 177 // XXX: This should only be necessary until the psFree() functions for178 // FPA/chip/cell/readout correctly free all child chips/cells/readouts179 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);200 158 } 201 159 … … 206 164 psLogSetLevel(PS_LOG_INFO); 207 165 psTraceSetLevel("err", ERR_TRACE_LEVEL); 208 plan_tests( 405);166 plan_tests(22); 209 167 210 168 // ---------------------------------------------------------------------- … … 212 170 // pmCellWrite(): tests 213 171 // Verify pmCellWrite() with NULL pmCell arg 214 {172 if (0) { 215 173 psMemId id = psMemGetId(); 216 174 psFits* fitsFileW = psFitsOpen(".tmp00", "w"); … … 220 178 } 221 179 180 222 181 // Verify pmCellWrite() with NULL pmCell arg 223 182 // XXXX: Big problem: Without the next code, everything else fails. Why? 224 if ( 1) {183 if (0) { 225 184 psMemId id = psMemGetId(); 226 185 psFits* fitsFileW = psFitsOpen(".tmp00", "w"); … … 232 191 233 192 // Verify pmCellWrite() with NULL pmFits arg 234 {193 if (0) { 235 194 psMemId id = psMemGetId(); 236 195 psMetadata *camera = psMetadataAlloc(); … … 240 199 ok(cell != NULL, "Allocated a pmCell successfully"); 241 200 ok(!pmCellWrite(cell, NULL, NULL, false), "pmCellWrite() returned FALSE with NULL psFits param"); 242 myFreeFPA(fpa);201 psFree(fpa); 243 202 psFree(camera); 244 203 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 265 224 // Close the FITS file, free memory 266 225 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 } 272 230 273 231 // ---------------------------------------------------------------------- … … 291 249 pmCell *cell = chip->cells->data[0]; 292 250 ok(!pmCellRead(cell, NULL, NULL), "pmCellRead() returned FALSE with NULL pmFits param"); 293 myFreeFPA(fpa);251 psFree(fpa); 294 252 psFree(camera); 295 253 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 313 271 rc = pmCellRead(cell, fitsFileR, NULL); 314 272 ok(rc, "pmCellRead() returned TRUE"); 273 skip_start(!rc, 1, "Skipping tests because pmCellRead returned NULL"); 315 274 for (int k = 0 ; k < cell->hdu->images->n ; k++) { 316 275 bool errorFlag = false; … … 327 286 ok(!errorFlag, "pmCellWrite()/pmCellRead() properly set the image data (image %d)", k); 328 287 } 329 psFitsClose(fitsFileR); 330 myFreeFPA(fpa); 288 skip_end(); 289 psFitsClose(fitsFileR); 290 psFree(fpa); 331 291 psFree(camera); 332 292 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 356 316 ok(cell != NULL, "Allocated a pmCell successfully"); 357 317 ok(!pmCellWriteWeight(cell, NULL, NULL, false), "pmCellWriteWeight() returned FALSE with NULL psFits param"); 358 myFreeFPA(fpa);318 psFree(fpa); 359 319 psFree(camera); 360 320 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 381 341 // Close the FITS file, free memory 382 342 psFitsClose(fitsFileW); 383 myFreeFPA(fpa);343 psFree(fpa); 384 344 psFree(camera); 385 345 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 407 367 pmCell *cell = chip->cells->data[0]; 408 368 ok(!pmCellReadWeight(cell, NULL, NULL), "pmCellReadWeight() returned FALSE with NULL pmFits param"); 409 myFreeFPA(fpa);369 psFree(fpa); 410 370 psFree(camera); 411 371 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 444 404 } 445 405 psFitsClose(fitsFileR); 446 myFreeFPA(fpa);406 psFree(fpa); 447 407 psFree(camera); 448 408 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 473 433 ok(cell != NULL, "Allocated a pmCell successfully"); 474 434 ok(!pmCellWriteMask(cell, NULL, NULL, false), "pmCellWriteMask() returned FALSE with NULL psFits param"); 475 myFreeFPA(fpa);435 psFree(fpa); 476 436 psFree(camera); 477 437 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 498 458 // Close the FITS file, free memory 499 459 psFitsClose(fitsFileW); 500 myFreeFPA(fpa);460 psFree(fpa); 501 461 psFree(camera); 502 462 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 524 484 pmCell *cell = chip->cells->data[0]; 525 485 ok(!pmCellReadMask(cell, NULL, NULL), "pmCellReadMask() returned FALSE with NULL pmFits param"); 526 myFreeFPA(fpa);486 psFree(fpa); 527 487 psFree(camera); 528 488 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 570 530 } 571 531 psFitsClose(fitsFileR); 572 myFreeFPA(fpa);532 psFree(fpa); 573 533 psFree(camera); 574 534 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 599 559 ok(chip != NULL, "Allocated a pmChip successfully"); 600 560 ok(!pmChipWrite(chip, NULL, NULL, false, true), "pmChipWrite() returned NULL with NULL pmFits param"); 601 myFreeFPA(fpa);561 psFree(fpa); 602 562 psFree(camera); 603 563 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 621 581 // Close the FITS file, free memory 622 582 psFitsClose(fitsFileW); 623 myFreeFPA(fpa);583 psFree(fpa); 624 584 psFree(camera); 625 585 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 646 606 pmChip *chip = fpa->chips->data[0]; 647 607 ok(!pmChipRead(chip, NULL, NULL), "pmChipRead() returned NULL with NULL pmFits param"); 648 myFreeFPA(fpa);608 psFree(fpa); 649 609 psFree(camera); 650 610 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 663 623 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { 664 624 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 665 myFreeCell(cell);625 psFree(cell); 666 626 cell = NULL; 667 627 } … … 676 636 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 677 637 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); 679 639 psImage *img = cell->hdu->images->data[k]; 680 640 for (int i = 0 ; i < img->numRows ; i++) { … … 692 652 693 653 psFitsClose(fitsFileR); 694 myFreeFPA(fpa);654 psFree(fpa); 695 655 psFree(camera); 696 656 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 719 679 ok(chip != NULL, "Allocated a pmChip successfully"); 720 680 ok(!pmChipWriteWeight(chip, NULL, NULL, false, true), "pmChipWriteWeight() returned NULL with NULL pmFits param"); 721 myFreeFPA(fpa);681 psFree(fpa); 722 682 psFree(camera); 723 683 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 741 701 // Close the FITS file, free memory 742 702 psFitsClose(fitsFileW); 743 myFreeFPA(fpa);703 psFree(fpa); 744 704 psFree(camera); 745 705 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 766 726 pmChip *chip = fpa->chips->data[0]; 767 727 ok(!pmChipReadMask(chip, NULL, NULL), "pmChipReadMask() returned NULL with NULL pmFits param"); 768 myFreeFPA(fpa);728 psFree(fpa); 769 729 psFree(camera); 770 730 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 783 743 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { 784 744 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 785 myFreeCell(cell);745 psFree(cell); 786 746 cell = NULL; 787 747 } … … 796 756 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 797 757 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); 799 759 psImage *wgt = cell->hdu->weights->data[k]; 800 760 for (int i = 0 ; i < wgt->numRows ; i++) { … … 812 772 813 773 psFitsClose(fitsFileR); 814 myFreeFPA(fpa);774 psFree(fpa); 815 775 psFree(camera); 816 776 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 837 797 pmChip *chip = fpa->chips->data[0]; 838 798 ok(!pmChipReadMask(chip, NULL, NULL), "pmChipReadMask() returned NULL with NULL pmFits param"); 839 myFreeFPA(fpa);799 psFree(fpa); 840 800 psFree(camera); 841 801 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 854 814 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { 855 815 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 856 myFreeCell(cell);816 psFree(cell); 857 817 cell = NULL; 858 818 } … … 867 827 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 868 828 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); 870 830 psImage *msk = cell->hdu->masks->data[k]; 871 831 for (int i = 0 ; i < msk->numRows ; i++) { … … 883 843 884 844 psFitsClose(fitsFileR); 885 myFreeFPA(fpa);845 psFree(fpa); 886 846 psFree(camera); 887 847 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 911 871 ok(fpa != NULL, "Allocated a pmFPA successfully"); 912 872 ok(!pmFPAWrite(fpa, NULL, NULL, false, true), "pmFPAWrite() returned NULL with NULL pmFits param"); 913 myFreeFPA(fpa);873 psFree(fpa); 914 874 psFree(camera); 915 875 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 929 889 // Close the FITS file, free memory 930 890 psFitsClose(fitsFileW); 931 myFreeFPA(fpa);891 psFree(fpa); 932 892 psFree(camera); 933 893 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 953 913 pmFPA* fpa = generateSimpleFPA(camera); 954 914 ok(!pmFPARead(fpa, NULL, NULL), "pmFPARead() returned NULL with NULL pmFits param"); 955 myFreeFPA(fpa);915 psFree(fpa); 956 916 psFree(camera); 957 917 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 971 931 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { 972 932 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 973 myFreeCell(cell);933 psFree(cell); 974 934 cell = NULL; 975 935 } … … 988 948 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 989 949 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); 991 951 psImage *img = cell->hdu->images->data[k]; 992 952 for (int i = 0 ; i < img->numRows ; i++) { … … 1005 965 1006 966 psFitsClose(fitsFileR); 1007 myFreeFPA(fpa);967 psFree(fpa); 1008 968 psFree(camera); 1009 969 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1033 993 ok(fpa != NULL, "Allocated a pmFPA successfully"); 1034 994 ok(!pmFPAWriteWeight(fpa, NULL, NULL, false, true), "pmFPAWriteWeight() returned NULL with NULL pmFits param"); 1035 myFreeFPA(fpa);995 psFree(fpa); 1036 996 psFree(camera); 1037 997 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1051 1011 // Close the FITS file, free memory 1052 1012 psFitsClose(fitsFileW); 1053 myFreeFPA(fpa);1013 psFree(fpa); 1054 1014 psFree(camera); 1055 1015 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1075 1035 pmFPA* fpa = generateSimpleFPA(camera); 1076 1036 ok(!pmFPARead(fpa, NULL, NULL), "pmFPAReadWeight() returned NULL with NULL pmFits param"); 1077 myFreeFPA(fpa);1037 psFree(fpa); 1078 1038 psFree(camera); 1079 1039 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1093 1053 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { 1094 1054 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 1095 myFreeCell(cell);1055 psFree(cell); 1096 1056 cell = NULL; 1097 1057 } … … 1110 1070 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 1111 1071 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); 1113 1073 psImage *wgt = cell->hdu->weights->data[k]; 1114 1074 for (int i = 0 ; i < wgt->numRows ; i++) { … … 1127 1087 1128 1088 psFitsClose(fitsFileR); 1129 myFreeFPA(fpa);1089 psFree(fpa); 1130 1090 psFree(camera); 1131 1091 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1155 1115 ok(fpa != NULL, "Allocated a pmFPA successfully"); 1156 1116 ok(!pmFPAWriteMask(fpa, NULL, NULL, false, true), "pmFPAWriteMask() returned NULL with NULL pmFits param"); 1157 myFreeFPA(fpa);1117 psFree(fpa); 1158 1118 psFree(camera); 1159 1119 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1173 1133 // Close the FITS file, free memory 1174 1134 psFitsClose(fitsFileW); 1175 myFreeFPA(fpa);1135 psFree(fpa); 1176 1136 psFree(camera); 1177 1137 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1197 1157 pmFPA* fpa = generateSimpleFPA(camera); 1198 1158 ok(!pmFPARead(fpa, NULL, NULL), "pmFPAReadMask() returned NULL with NULL pmFits param"); 1199 myFreeFPA(fpa);1159 psFree(fpa); 1200 1160 psFree(camera); 1201 1161 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 1215 1175 for (int chipID = 0 ; chipID < chip->cells->n ; chipID++) { 1216 1176 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 1217 myFreeCell(cell);1177 psFree(cell); 1218 1178 cell = NULL; 1219 1179 } … … 1232 1192 pmCell *cell = (pmCell *) chip->cells->data[chipID]; 1233 1193 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); 1235 1195 psImage *msk = cell->hdu->masks->data[k]; 1236 1196 for (int i = 0 ; i < msk->numRows ; i++) { … … 1249 1209 1250 1210 psFitsClose(fitsFileR); 1251 myFreeFPA(fpa);1211 psFree(fpa); 1252 1212 psFree(camera); 1253 1213 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); -
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 } -
trunk/psModules/test/camera/tap_pmFPAView.c
r14882 r15987 5 5 #include "tap.h" 6 6 #include "pstap.h" 7 / / XXX: pmFPAviewThisHDU(): some problems with NULL pmHDUs8 // XXX: must test: pmFPAviewThisHDU(), pmFPAviewThisPHU() 9 // XXX: must test: pmFPAviewThisPHU() 7 /* STATUS: 8 All functions are tested. 9 */ 10 10 11 11 #define ERR_TRACE_LEVEL 0 … … 77 77 cell->hdu = pmHDUAlloc("cellExtName"); 78 78 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"); 83 84 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 } 85 89 } 86 90 … … 96 100 psImageInit(cell->hdu->weights->data[k], (float) (BASE_WEIGHT+k)); 97 101 } 102 cell->hdu->blankPHU = true; 98 103 99 104 //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);101 105 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 102 106 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value. … … 119 123 psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 120 124 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; 128 134 129 135 psArrayRealloc(chip->cells, NUM_CELLS); 130 136 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 } 136 139 137 140 return(chip); … … 151 154 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 152 155 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"); 157 160 if (!rc) { 158 161 diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())"); 159 162 } 160 163 } 164 fpa->hdu->blankPHU = true; 161 165 162 166 psArrayRealloc(fpa->chips, NUM_CHIPS); 163 167 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 } 169 170 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 171 return(fpa); 176 172 } 177 173 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 }202 174 203 175 psS32 main(psS32 argc, char* argv[]) … … 206 178 psLogSetLevel(PS_LOG_INFO); 207 179 psTraceSetLevel("err", ERR_TRACE_LEVEL); 208 plan_tests(137); 180 plan_tests(174); 181 209 182 210 183 // ---------------------------------------------------------------------- 211 184 // 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"); 217 189 ok(tmpView->nRows == 32, "pmFPAviewAlloc() set ->nRows properly"); 218 190 psFree(tmpView); … … 228 200 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 229 201 } 202 230 203 231 204 // pmFPAViewReset() tests: acceptable input … … 340 313 ok(NULL == pmFPAviewThisChip(NULL, fpa), "pmFPAviewThisChip(NULL, fpa) returned NULL"); 341 314 342 myFreeFPA(fpa);315 psFree(fpa); 343 316 psFree(camera); 344 317 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 366 339 ok(NULL == pmFPAviewThisChip(tmpView, fpa), "pmFPAviewThisChip(pmFPAView, fpa) returned NULL view input"); 367 340 fpa->chips = chips; 368 myFreeFPA(fpa);341 psFree(fpa); 369 342 psFree(camera); 370 343 psFree(tmpView); … … 403 376 } 404 377 ok(!errorFlag, "pmFPAviewThisChip() returned the correct pmChip for all tests"); 405 myFreeFPA(fpa);378 psFree(fpa); 406 379 psFree(camera); 407 380 psFree(tmpView); … … 425 398 ok(NULL == pmFPAviewNextChip(NULL, fpa, 0), "pmFPAviewNextChip(NULL, fpa, 0) returned NULL"); 426 399 427 myFreeFPA(fpa);400 psFree(fpa); 428 401 psFree(camera); 429 402 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 456 429 // XXX: Source code is wrong: must guard against input tmpView->chip = -1 457 430 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"); 459 432 460 433 // Test with tmpView->chip too high … … 486 459 ok(!errorFlag, "pmFPAviewNextChip() returned the correct pmChip for all tests (step = 1)"); 487 460 488 myFreeFPA(fpa);461 psFree(fpa); 489 462 psFree(camera); 490 463 psFree(tmpView); … … 506 479 ok(NULL == pmFPAviewThisCell(NULL, fpa), "pmFPAviewThisCell(NULL, fpa) returned NULL"); 507 480 508 myFreeFPA(fpa);481 psFree(fpa); 509 482 psFree(camera); 510 483 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 523 496 524 497 // pmFPAviewThisCell() tests: NULL fpa->chips input 525 // XXX: Skipping because the source code does not guard against this 526 if (0) { 498 { 527 499 psMemId id = psMemGetId(); 528 500 psMetadata *camera = psMetadataAlloc(); … … 533 505 ok(NULL == pmFPAviewThisCell(tmpView, fpa), "pmFPAviewThisCell(pmFPAView, fpa) returned NULL view input"); 534 506 fpa->chips = chips; 535 myFreeFPA(fpa);507 psFree(fpa); 536 508 psFree(camera); 537 509 psFree(tmpView); … … 575 547 } 576 548 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 } 583 554 584 555 … … 597 568 ok(NULL == pmFPAviewNextCell(NULL, fpa, 0), "pmFPAviewNextCell(NULL, fpa, 0) returned NULL"); 598 569 599 myFreeFPA(fpa);570 psFree(fpa); 600 571 psFree(camera); 601 572 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 667 638 ok(!errorFlag, "pmFPAviewNextCell() returned the correct pmCell for all tests (step = 1)"); 668 639 669 myFreeFPA(fpa);640 psFree(fpa); 670 641 psFree(camera); 671 642 psFree(tmpView); … … 688 659 ok(NULL == pmFPAviewThisReadout(NULL, fpa), "pmFPAviewThisReadout(NULL, fpa) returned NULL"); 689 660 690 myFreeFPA(fpa);661 psFree(fpa); 691 662 psFree(camera); 692 663 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 705 676 706 677 // pmFPAviewThisReadout() tests: NULL fpa->chips input 707 // XXX: Skipping because the source code does not guard against this 708 if (0) { 678 { 709 679 psMemId id = psMemGetId(); 710 680 psMetadata *camera = psMetadataAlloc(); … … 715 685 ok(NULL == pmFPAviewThisReadout(tmpView, fpa), "pmFPAviewThisReadout(pmFPAView, fpa) returned NULL view input"); 716 686 fpa->chips = chips; 717 myFreeFPA(fpa);687 psFree(fpa); 718 688 psFree(camera); 719 689 psFree(tmpView); … … 761 731 ok(!errorFlag, "pmFPAviewThisReadout() returned the correct pmCell for all tests"); 762 732 763 myFreeFPA(fpa);733 psFree(fpa); 764 734 psFree(camera); 765 735 psFree(tmpView); … … 782 752 ok(NULL == pmFPAviewNextReadout(NULL, fpa, 0), "pmFPAviewNextReadout(NULL, fpa, 0) returned NULL"); 783 753 784 myFreeFPA(fpa);754 psFree(fpa); 785 755 psFree(camera); 786 756 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 857 827 ok(!errorFlag, "pmFPAviewNextReadout() returned the correct pmCell for all tests (step = 1)"); 858 828 859 myFreeFPA(fpa);829 psFree(fpa); 860 830 psFree(camera); 861 831 psFree(tmpView); … … 877 847 ok(cell != NULL, "Allocated a pmCell successfully"); 878 848 ok(NULL == pmFPAviewThisHDU(NULL, fpa), "pmFPAviewThisHDU(NULL, fpa) returned NULL"); 879 myFreeFPA(fpa);849 psFree(fpa); 880 850 psFree(camera); 881 851 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 893 863 894 864 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 948 865 // pmFPAviewThisHDU() tests: acceptable input 949 // pmHDU *pmFPAviewThisHDU(const pmFPAview *view, const pmFPA *fpa)950 866 { 951 867 psMemId id = psMemGetId(); … … 963 879 ok(hdu, "pmFPAviewThisHDU() returned non-NULL with tmpView->chip = -1"); 964 880 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 968 883 tmpView->cell = -1; 969 884 hdu = pmFPAviewThisHDU(tmpView, fpa); 970 885 ok(hdu, "pmFPAviewThisHDU() returned non-NULL with tmpView->cell = -1"); 971 886 ok(hdu == pmHDUFromChip(pmFPAviewThisChip(tmpView, fpa)), "pmFPAviewThisHDU() returned the correct HDU"); 972 tmpView->cell = 16;887 tmpView->cell = NUM_CELLS/2; 973 888 974 889 tmpView->readout = -1; … … 976 891 ok(hdu, "pmFPAviewThisHDU() returned non-NULL with tmpView->readout = -1"); 977 892 ok(hdu == pmHDUFromCell(pmFPAviewThisCell(tmpView, fpa)), "pmFPAviewThisHDU() returned the correct HDU"); 978 tmpView->readout = 16;893 tmpView->readout = NUM_READOUTS/2; 979 894 980 895 hdu = pmFPAviewThisHDU(tmpView, fpa); … … 982 897 ok(hdu == pmHDUFromReadout(pmFPAviewThisReadout(tmpView, fpa)), "pmFPAviewThisHDU() returned the correct HDU"); 983 898 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); 987 1019 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 988 1020 } 989 1021 } 1022 -
trunk/psModules/test/camera/tap_pmHDU.c
r14881 r15987 5 5 #include "tap.h" 6 6 #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. 17 9 */ 18 10 … … 26 18 psTraceSetLevel("err", 0); 27 19 plan_tests(159); 20 28 21 29 22 // ---------------------------------------------------------------------- … … 93 86 hdu->header = psMetadataAlloc(); 94 87 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 } 96 92 ok(rc == true, "pmConfigFileRead() was successful"); 97 93 rc = pmHDUWrite(hdu, NULL); … … 105 101 { 106 102 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 } 108 107 ok(fitsFile != NULL, "psFitsOpen() was successful"); 109 108 bool rc = pmHDURead(NULL, fitsFile); … … 147 146 // Set hdu->images 148 147 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 } 150 152 ok(rc, "pmConfigFileRead() was successful"); 151 153 hdu->images = psArrayAlloc(NUM_HDUS); … … 219 221 hdu->header = psMetadataAlloc(); 220 222 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 } 222 227 ok(rc == true, "pmConfigFileRead() was successful"); 223 228 rc = pmHDUWriteWeight(hdu, NULL); … … 231 236 { 232 237 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 } 234 242 ok(fitsFile != NULL, "psFitsOpen() was successful"); 235 243 bool rc = pmHDUReadWeight(NULL, fitsFile); … … 273 281 // Set hdu->images 274 282 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 } 276 287 ok(rc, "pmConfigFileRead() was successful"); 277 288 hdu->weights = psArrayAlloc(NUM_HDUS); … … 345 356 hdu->header = psMetadataAlloc(); 346 357 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 } 348 362 ok(rc == true, "pmConfigFileRead() was successful"); 349 363 rc = pmHDUWriteMask(hdu, NULL); … … 357 371 { 358 372 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 } 360 377 ok(fitsFile != NULL, "psFitsOpen() was successful"); 361 378 bool rc = pmHDUReadMask(NULL, fitsFile); … … 399 416 // Set hdu->images 400 417 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 } 402 422 ok(rc, "pmConfigFileRead() was successful"); 403 423 hdu->masks = psArrayAlloc(NUM_HDUS); … … 450 470 { 451 471 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 } 453 476 ok(fitsFile != NULL, "psFitsOpen() was successful"); 454 477 bool rc = pmHDUReadHeader(NULL, fitsFile); … … 490 513 "psBool Item", (lcv%2 == 0)); 491 514 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 } 494 521 ok(rc == true, "pmConfigFileRead() was successful"); 495 522 rc = pmHDUWrite(hdu, fitsFileW); -
trunk/psModules/test/camera/tap_pmHDUUtils.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: This simpleFPA() requires that the HDUs be allocated. 13 7 /* STATUS: 8 All functions are tested. 9 */ 14 10 15 11 #define CHIP_ALLOC_NAME "ChipName" … … 80 76 cell->hdu = pmHDUAlloc("cellExtName"); 81 77 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"); 86 83 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 } 88 88 } 89 89 … … 101 101 102 102 //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);104 103 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 105 104 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value. … … 123 122 chip->hdu = pmHDUAlloc("chipExtName"); 124 123 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"); 126 125 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 } 128 130 } 129 131 130 132 psArrayRealloc(chip->cells, NUM_CELLS); 131 133 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 } 138 136 return(chip); 139 137 } … … 153 151 psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 154 152 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"); 157 154 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 } 159 159 } 160 160 161 161 psArrayRealloc(fpa->chips, NUM_CHIPS); 162 162 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 } 168 165 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 174 166 return(fpa); 175 }176 177 // XXX: This should only be necessary until the psFree() functions for178 // FPA/chip/cell/readout correctly free all child chips/cells/readouts179 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);200 167 } 201 168 … … 208 175 plan_tests(73); 209 176 210 // ---------------------------------------------------------------------- 211 // pmHDU *pmHDUFromFPA(const pmFPA *fpa)177 178 // ---------------------------------------------------------------------- 212 179 // pmHDUFromFPA() tests 213 // pmHDUFromFPA() verifywith NULL input params180 // Call pmHDUFromFPA() with NULL input params 214 181 { 215 182 psMemId id = psMemGetId(); … … 219 186 } 220 187 221 //pmHDUFromFPA() verify with acceptable input params 188 189 // Call pmHDUFromFPA() with acceptable input params 222 190 { 223 191 psMemId id = psMemGetId(); … … 232 200 pmHDU *hdu = pmHDUFromFPA(fpa); 233 201 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 // ---------------------------------------------------------------------- 242 209 // pmHDUFromChip() tests 243 // pmHDUFromChip() verifywith NULL input params210 // Call pmHDUFromChip() with NULL input params 244 211 { 245 212 psMemId id = psMemGetId(); … … 249 216 } 250 217 251 //pmHDUFromChip() verify with acceptable input params 218 219 // Call pmHDUFromChip() with acceptable input params 252 220 { 253 221 psMemId id = psMemGetId(); … … 262 230 pmHDU *hdu = pmHDUFromChip(chip); 263 231 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 270 239 // Set chip->hdu to NULL, verify chip->parent->hdu is returned 271 240 { … … 283 252 pmHDU *hdu = pmHDUFromChip(chip); 284 253 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 // ---------------------------------------------------------------------- 293 261 // pmHDUFromCell() tests 294 // pmHDUFromCell() verifywith NULL input params262 // Call pmHDUFromCell() with NULL input params 295 263 { 296 264 psMemId id = psMemGetId(); … … 300 268 } 301 269 302 //pmHDUFromCell() verify with acceptable input params 270 271 // Call pmHDUFromCell() with acceptable input params 303 272 { 304 273 psMemId id = psMemGetId(); … … 313 282 pmHDU *hdu = pmHDUFromCell(cell); 314 283 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 321 291 // Set cell->hdu to NULL, verify cell->parent->hdu is returned 322 292 { … … 334 304 pmHDU *hdu = pmHDUFromCell(cell); 335 305 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 // ---------------------------------------------------------------------- 344 313 // pmHDUFromReadout() tests 345 // pmHDUFromReadout() verifywith NULL input params314 // Call pmHDUFromReadout() with NULL input params 346 315 { 347 316 psMemId id = psMemGetId(); … … 351 320 } 352 321 353 //pmHDUFromReadout() verify with acceptable input params 322 323 // Call pmHDUFromReadout() with acceptable input params 354 324 { 355 325 psMemId id = psMemGetId(); … … 366 336 pmHDU *hdu = pmHDUFromReadout(readout); 367 337 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 378 347 { 379 348 psMemId id = psMemGetId(); … … 384 353 385 354 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 389 356 { 390 357 psMemId id = psMemGetId(); … … 399 366 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); 400 367 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 410 375 { 411 376 psMemId id = psMemGetId(); … … 420 385 pmHDU *hdu = pmHDUGetLowest(fpa, chip, NULL); 421 386 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 431 394 { 432 395 psMemId id = psMemGetId(); … … 441 404 pmHDU *hdu = pmHDUGetLowest(fpa, NULL, NULL); 442 405 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 } 448 410 449 411 450 412 // ---------------------------------------------------------------------- 451 413 //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 454 415 { 455 416 psMemId id = psMemGetId(); … … 460 421 461 422 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 465 424 { 466 425 psMemId id = psMemGetId(); … … 475 434 pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); 476 435 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 486 443 { 487 444 psMemId id = psMemGetId(); … … 496 453 pmHDU *hdu = pmHDUGetHighest(NULL, chip, cell); 497 454 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 507 462 { 508 463 psMemId id = psMemGetId(); … … 517 472 pmHDU *hdu = pmHDUGetHighest(NULL, NULL, cell); 518 473 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.
