/* $Id: cpl_dfs-test.c,v 1.35 2008/02/07 10:54:01 llundin Exp $ * * This file is part of the ESO Common Pipeline Library * Copyright (C) 2001-2004 European Southern Observatory * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * $Author: llundin $ * $Date: 2008/02/07 10:54:01 $ * $Revision: 1.35 $ * $Name: $ */ /*----------------------------------------------------------------------------- Includes -----------------------------------------------------------------------------*/ #ifdef HAVE_CONFIG_H #include #endif #include #include "cpl_dfs.h" #include "cpl_memory.h" #include "cpl_tools.h" #include "cpl_image.h" /*----------------------------------------------------------------------------- Defines -----------------------------------------------------------------------------*/ #define IMAGE_SIZE_X 1009 #define IMAGE_SIZE_Y 1031 #define IMAGE_NEXT 32 #define CPL_DFS_RAW_ASCII "ascii.txt" /*----------------------------------------------------------------------------- Private declarations -----------------------------------------------------------------------------*/ static void cpl_dfs_product_tests(const char *); static void cpl_dfs_save_tests(const char *); static void cpl_dfs_save_txt(const char *); /*----------------------------------------------------------------------------- Main -----------------------------------------------------------------------------*/ int main(void) { cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING); cpl_dfs_save_txt(CPL_DFS_RAW_ASCII); /* Insert tests here */ cpl_dfs_product_tests(CPL_DFS_RAW_ASCII); cpl_dfs_save_tests(CPL_DFS_RAW_ASCII); remove(CPL_DFS_RAW_ASCII); /* Testing finished */ return cpl_test_end(0); } static void cpl_dfs_product_tests(const char * rawname) { const char * filename = "product.fits"; cpl_frame * rawframe; cpl_frame * proframe; cpl_frameset * frameset = NULL; cpl_propertylist * plist = NULL; cpl_parameterlist * parlist = NULL; cpl_image * image; const char * md5sum; cpl_error_code error; const int next = IMAGE_NEXT; int i; /* Test 1: Check the error handling of NULL-pointer(s) */ error = cpl_dfs_setup_product_header(NULL, NULL, NULL, NULL, NULL, NULL, NULL); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_eq( error, CPL_ERROR_NULL_INPUT); /* Test 1a: Check the error handling of NULL-pointer(s) */ error = cpl_dfs_update_product_header(NULL); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_eq( error, CPL_ERROR_NULL_INPUT); /* Test 2: Check the error handling of an empty frame/frameset */ proframe = cpl_frame_new(); frameset = cpl_frameset_new(); plist = cpl_propertylist_new(); parlist = cpl_parameterlist_new(); error = cpl_dfs_setup_product_header(plist, proframe, frameset, parlist, "Recipe", "Pipeline", "PRO-1.15"); cpl_test_error(CPL_ERROR_DATA_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_DATA_NOT_FOUND); /* Test 2a: Check the handling of an empty frameset */ error = cpl_dfs_update_product_header(frameset); cpl_test_eq( error, CPL_ERROR_NONE); /* Test 3: Check the error handling of a rawframe without a filename */ rawframe = cpl_frame_new(); cpl_test_zero(cpl_frame_set_tag(rawframe, "TAG")); cpl_test_zero(cpl_frame_set_group(rawframe, CPL_FRAME_GROUP_RAW)); cpl_test_zero(cpl_frameset_insert(frameset, rawframe)); error = cpl_dfs_setup_product_header(plist, proframe, frameset, parlist, "Recipe", "Pipeline", "PRO-1.15"); cpl_test_error(CPL_ERROR_DATA_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_DATA_NOT_FOUND); cpl_frameset_delete(frameset); /* Test 4: Check the error handling of an empty product frame (and a valid, non-fits rawframe) - should fail on missing filename */ frameset = cpl_frameset_new(); rawframe = cpl_frame_new(); cpl_test_zero(cpl_frame_set_tag(rawframe, "TAG")); cpl_test_zero(cpl_frame_set_group(rawframe, CPL_FRAME_GROUP_RAW)); cpl_test_zero(cpl_frame_set_filename(rawframe, rawname)); cpl_test_zero(cpl_frameset_insert(frameset, rawframe)); error = cpl_dfs_setup_product_header(plist, proframe, frameset, parlist, "Recipe", "Pipeline", "PRO-1.15"); cpl_test_error(CPL_ERROR_DATA_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_DATA_NOT_FOUND); /* Test 4c: Check the error handling of an product frame with a (non-fits) filename as the only attribute (and a valid, non-fits rawframe) - should fail on missing tag */ cpl_test_zero(cpl_frame_set_filename(proframe, filename)); error = cpl_dfs_setup_product_header(plist, proframe, frameset, parlist, "Recipe", "Pipeline", "PRO-1.15"); cpl_test_error(CPL_ERROR_ILLEGAL_INPUT); cpl_test_eq( error, CPL_ERROR_ILLEGAL_INPUT); /* Test 4d: Check the error handling of an product frame with a filename and tagged (and a valid, non-fits rawframe) - should fail on missing group */ cpl_test_zero(cpl_frame_set_tag(proframe, "PRODUCT")); error = cpl_dfs_setup_product_header(plist, proframe, frameset, parlist, "Recipe", "Pipeline", "PRO-1.15"); cpl_test_error(CPL_ERROR_ILLEGAL_INPUT); cpl_test_eq( error, CPL_ERROR_ILLEGAL_INPUT); /* Test 5: A simple successful call */ cpl_test_zero(cpl_frame_set_group(proframe, CPL_FRAME_GROUP_PRODUCT)); cpl_test_zero(cpl_dfs_setup_product_header(plist, proframe, frameset, parlist, "Recipe", "Pipeline", "PRO-1.15")); cpl_msg_debug("","Size of product header: %ld", cpl_propertylist_get_size(plist)); /* Test 5a: A failure due to a missing product file */ cpl_test_zero(cpl_frameset_insert(frameset, proframe)); error = cpl_dfs_update_product_header(frameset); cpl_test_error(CPL_ERROR_BAD_FILE_FORMAT); cpl_test_eq( error, CPL_ERROR_BAD_FILE_FORMAT); /* Test 6a: A failure on file format (missing file) */ /* Make sure file does not exist (from a previously failed test) */ (void)remove(filename); cpl_test_zero(cpl_frame_set_type(proframe, CPL_FRAME_TYPE_IMAGE)); error = cpl_dfs_update_product_header(frameset); cpl_test_error(CPL_ERROR_BAD_FILE_FORMAT); cpl_test_eq( error, CPL_ERROR_BAD_FILE_FORMAT); /* Test 6a: A failure on file format (non-fits) */ cpl_dfs_save_txt(filename); error = cpl_dfs_update_product_header(frameset); cpl_test_error(CPL_ERROR_BAD_FILE_FORMAT); cpl_test_eq( error, CPL_ERROR_BAD_FILE_FORMAT); /* Test 7a: A successful call of cpl_dfs_update_product_header() with an empty data-unit */ cpl_test_zero(cpl_image_save(NULL, filename, CPL_BPP_8_UNSIGNED, plist, CPL_IO_DEFAULT)); cpl_test_zero(cpl_dfs_update_product_header(frameset)); cpl_propertylist_delete(plist); plist = cpl_propertylist_load(filename, 0); cpl_test_nonnull(plist); md5sum = cpl_propertylist_get_string(plist, "DATAMD5"); cpl_test_nonnull(md5sum); /* The created Data Unit is empty */ /* The corresponding 32-byte reference MD5 sum is found with: md5sum - < /dev/null */ cpl_test_eq_string(md5sum, "d41d8cd98f00b204e9800998ecf8427e"); /* Test 7b: A successful call of cpl_dfs_update_product_header() */ image = cpl_image_new(2, 3, CPL_TYPE_INT); cpl_test_zero(cpl_image_save(image, filename, CPL_BPP_8_UNSIGNED, plist, CPL_IO_DEFAULT)); cpl_test_zero(cpl_dfs_update_product_header(frameset)); cpl_propertylist_delete(plist); plist = cpl_propertylist_load(filename, 0); cpl_test_nonnull(plist); md5sum = cpl_propertylist_get_string(plist, "DATAMD5"); cpl_test_nonnull(md5sum); /* The created Data Unit consists of one FITS block of zero-bytes */ /* The 32-byte reference MD5 sum of such a string is found with: perl -e 'print "\0" x 2880' | md5sum - */ cpl_test_eq_string(md5sum, "b4a11922757e107a2c10306867f52601"); /* Test 7c: A successful call of cpl_dfs_update_product_header() with a main HDU and one data-less extension */ cpl_test_zero(cpl_image_save(NULL, filename, CPL_BPP_8_UNSIGNED, plist, CPL_IO_EXTEND)); cpl_test_zero(cpl_dfs_update_product_header(frameset)); cpl_propertylist_delete(plist); plist = cpl_propertylist_load(filename, 0); cpl_test_nonnull(plist); md5sum = cpl_propertylist_get_string(plist, "DATAMD5"); cpl_test_nonnull(md5sum); /* The created Data Unit consists of one FITS block of zero-bytes */ /* The 32-byte reference MD5 sum of such a string is found with: perl -e 'print "\0" x 2880' | md5sum - */ cpl_test_eq_string(md5sum, "b4a11922757e107a2c10306867f52601"); /* Test 7d: A successful call of cpl_dfs_update_product_header() with a main HDU, one data-less extension and one non-empty extension. */ cpl_test_zero(cpl_image_save(image, filename, CPL_BPP_8_UNSIGNED, plist, CPL_IO_EXTEND)); cpl_test_zero(cpl_dfs_update_product_header(frameset)); cpl_propertylist_delete(plist); plist = cpl_propertylist_load(filename, 0); cpl_test_nonnull(plist); md5sum = cpl_propertylist_get_string(plist, "DATAMD5"); cpl_test_nonnull(md5sum); /* The created Data Unit consists of two FITS blocks of zero-bytes */ /* The 32-byte reference MD5 sum of such a string is found with: perl -e 'print "\0" x (2880*2)' | md5sum - */ cpl_test_eq_string(md5sum, "1c94f1009ff65c0a499040c0d1ae082f"); cpl_image_delete(image); /* Test 8: A successful call of cpl_dfs_update_product_header() - on a multi-extension file of flat integer images*/ image = cpl_image_new(IMAGE_SIZE_X, IMAGE_SIZE_Y, CPL_TYPE_INT); for (i = 0; i < next; i++) { cpl_test_zero(cpl_image_add_scalar(image, 1.0)); cpl_test_zero(cpl_image_save(image, filename, CPL_BPP_8_UNSIGNED, plist, CPL_IO_EXTEND)); } cpl_test_zero(cpl_dfs_update_product_header(frameset)); cpl_propertylist_delete(plist); plist = cpl_propertylist_load(filename, 0); cpl_test_nonnull(plist); md5sum = cpl_propertylist_get_string(plist, "DATAMD5"); cpl_test_nonnull(md5sum); /* The created Data Units are two FITS blocks of zero-bytes, and 32 each with a BITPIX-8 1009 by 1031 flat image with values 1 through 32 */ /* The 32-byte reference MD5 sum of such a string is found with: perl -e 'print "\0" x ( 2880*2);' -e 'grep(print(sprintf("%c",$_) x (1009*1031)."\0"x(1042560-1009*1031)),' -e '1..32)' | md5sum - */ cpl_test_eq_string(md5sum, "503bcbb6fd6606ac1d035e2a43f0229c"); cpl_image_delete(image); /* Test 9: A successful call of cpl_dfs_update_product_header() - after renaming the file */ do { /* Renaming the file attribute of a frame belonging to a frameset is not allowed. This strange limitation requires a cumbersome work-around :-( */ cpl_frameset * newframes = cpl_frameset_new(); const cpl_frame * frame; const char * newformat = "newname_%04d.fits"; cpl_frame * newframe; /* Create new frameset of products with new filenames - and rename product files */ for (frame = cpl_frameset_get_first(frameset), i = 0; frame != NULL; frame = cpl_frameset_get_next(frameset)) { if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_PRODUCT) { const cpl_frame_type type = cpl_frame_get_type(frame); if (type == CPL_FRAME_TYPE_TABLE || type == CPL_FRAME_TYPE_IMAGE) { const char * oldname = cpl_frame_get_filename(frame); char * newname = cpl_sprintf(newformat, ++i); /* Rename product */ cpl_test_zero(rename(oldname, newname)); newframe = cpl_frame_duplicate(frame); cpl_test_zero(cpl_frame_set_filename(newframe, newname)); cpl_free(newname); cpl_test_zero(cpl_frameset_insert(newframes, newframe)); } } } cpl_msg_info("", "Renamed %d product(s)", i); cpl_test_zero(cpl_dfs_update_product_header(newframes)); cpl_frameset_delete(newframes); /* Do not remove file(s) if there was a failure */ if (cpl_error_get_code() == CPL_ERROR_NONE) { for (; i; i--) { char * newname = cpl_sprintf(newformat, i); error = remove(newname); cpl_free(newname); if (error) break; } cpl_test_zero(i); } } while (0); cpl_frameset_delete(frameset); cpl_propertylist_delete(plist); cpl_parameterlist_delete(parlist); return; } static void cpl_dfs_save_tests(const char * rawname) { const cpl_boolean is_debug = cpl_msg_get_level() <= CPL_MSG_DEBUG? CPL_TRUE : CPL_FALSE; cpl_error_code error; const char * filename = "product.fits"; const char * remregexp = "DROP"; cpl_frameset * frames = NULL; cpl_propertylist * tlist = NULL; cpl_propertylist * qclist = NULL; cpl_parameterlist * parlist = NULL; cpl_image * image = NULL; cpl_imagelist * imlist = NULL; cpl_table * table = NULL; cpl_frame * rawframe = cpl_frame_new(); int framesetsize; /* Test 1: Check the error handling of NULL-pointer(s) */ error = cpl_dfs_save_image(frames, parlist, frames, image, CPL_BPP_8_UNSIGNED, "recipe", "procat", qclist, "none", "pipe_id", filename); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_eq( error, CPL_ERROR_NULL_INPUT); error = cpl_dfs_save_imagelist(frames, parlist, frames, imlist, CPL_BPP_8_UNSIGNED, "recipe", "procat", qclist, "none", "pipe_id", filename); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_eq( error, CPL_ERROR_NULL_INPUT); error = cpl_dfs_save_table(frames, parlist, frames, table, tlist, "recipe", "procat", qclist, "none", "pipe_id", filename); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_eq( error, CPL_ERROR_NULL_INPUT); error = cpl_dfs_save_paf("INSTRUME", "recipe", qclist, filename); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_eq( error, CPL_ERROR_NULL_INPUT); frames = cpl_frameset_new(); tlist = cpl_propertylist_new(); qclist = cpl_propertylist_new(); parlist = cpl_parameterlist_new(); table = cpl_table_new(1); imlist = cpl_imagelist_new(); /* Test 2: Check handling of empty objects (frameset) */ error = cpl_dfs_save_image(frames, parlist, frames, image, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMAGE", qclist, "none", "pipe_id", "image" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_DATA_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_DATA_NOT_FOUND); error = cpl_dfs_save_imagelist(frames, parlist, frames, imlist, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMLIST", qclist, "none", "pipe_id", "imlist" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_DATA_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_DATA_NOT_FOUND); error = cpl_dfs_save_table(frames, parlist, frames, table, tlist, "recipe", "TESTTABLE", qclist, "none", "pipe_id", "table" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_DATA_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_DATA_NOT_FOUND); /* Test 3A: Check handling of empty objects (except frameset) - using a non-existing input file */ /* Make sure file does not exist */ (void)remove("table" CPL_DFS_FITS); cpl_test_zero(cpl_frame_set_tag(rawframe, "TAG")); cpl_test_zero(cpl_frame_set_group(rawframe, CPL_FRAME_GROUP_RAW)); cpl_test_zero(cpl_frame_set_filename(rawframe, "table" CPL_DFS_FITS)); cpl_test_zero(cpl_frameset_insert(frames, rawframe)); framesetsize = cpl_frameset_get_size(frames); error = cpl_dfs_save_image(frames, parlist, frames, image, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMAGE", qclist, "none", "pipe_id", "image" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_FILE_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_FILE_NOT_FOUND); cpl_test_eq( cpl_frameset_get_size(frames), framesetsize); error = cpl_dfs_save_imagelist(frames, parlist, frames, imlist, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMLIST", qclist, "none", "pipe_id", "imlist" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_FILE_NOT_FOUND); cpl_test_eq( error, CPL_ERROR_FILE_NOT_FOUND); cpl_test_eq( cpl_frameset_get_size(frames), framesetsize); /* Test 3B: Check handling of empty objects (except frameset) */ cpl_frameset_delete(frames); frames = cpl_frameset_new(); rawframe = cpl_frame_new(); cpl_test_zero(cpl_frame_set_tag(rawframe, "TAG")); cpl_test_zero(cpl_frame_set_group(rawframe, CPL_FRAME_GROUP_RAW)); cpl_test_zero(cpl_frame_set_filename(rawframe, rawname)); cpl_test_zero(cpl_frameset_insert(frames, rawframe)); framesetsize = cpl_frameset_get_size(frames); /* Make sure file does not exist */ (void)remove("imlist" CPL_DFS_FITS); error = cpl_dfs_save_imagelist(frames, parlist, frames, imlist, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMAGE", qclist, "none", "pipe_id", "imlist" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_ILLEGAL_INPUT); cpl_test_eq(error, CPL_ERROR_ILLEGAL_INPUT); cpl_test_eq( cpl_frameset_get_size(frames), framesetsize); /* Test 3: Check handling of empty objects (except frameset + imagelist) */ /* Insert an image into the imagelist */ cpl_test_zero(cpl_imagelist_set(imlist, cpl_image_new(3, 2, CPL_TYPE_INT), 0)); /* Make sure file does not exist */ (void)remove("image" CPL_DFS_FITS); error = cpl_dfs_save_image(frames, parlist, frames, image, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMAGE", qclist, "none", "pipe_id", "image" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); cpl_test_eq( cpl_frameset_get_size(frames), ++framesetsize); /* Make sure file does not exist */ (void)remove("imlist" CPL_DFS_FITS); error = cpl_dfs_save_imagelist(frames, parlist, frames, imlist, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMLIST", qclist, "none", "pipe_id", "imlist" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); cpl_test_eq( cpl_frameset_get_size(frames), ++framesetsize); /* Make sure file does not exist */ (void)remove("table" CPL_DFS_FITS); error = cpl_dfs_save_table(frames, parlist, frames, table, tlist, "recipe", "TESTTABLE", qclist, "none", "pipe_id", "table" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); cpl_test_eq( cpl_frameset_get_size(frames), ++framesetsize); /* Make sure file does not exist */ (void)remove("recipe" CPL_DFS_PAF); error = cpl_dfs_save_paf("INSTRUME", "recipe", qclist, "recipe" CPL_DFS_PAF); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); cpl_test_zero(cpl_dfs_update_product_header(frames)); /* Test 4: Check handling of empty objects (except frameset and qclist) */ /* And remove one property */ cpl_test_zero(cpl_propertylist_append_string(qclist, "ESO QC STRING", "'Lorem ipsum'")); cpl_test_zero(cpl_propertylist_append_int(qclist, "ESO QC INT", 42)); cpl_test_zero(cpl_propertylist_append_float(qclist, "ESO QC FLOAT", 42.0)); cpl_test_zero(cpl_propertylist_append_double(qclist, "ESO QC DOUBLE", 42.0)); cpl_test_zero(cpl_propertylist_append_string(qclist, "ESO QC DROP", "image")); cpl_test_zero(cpl_propertylist_set_comment(qclist, "ESO QC STRING", "string")); cpl_test_zero(cpl_propertylist_set_comment(qclist, "ESO QC INT", "int")); cpl_test_zero(cpl_propertylist_set_comment(qclist, "ESO QC FLOAT", "float")); cpl_test_zero(cpl_propertylist_set_comment(qclist, "ESO QC DOUBLE", "double")); /* Make sure file does not exist */ (void)remove("image" CPL_DFS_FITS); image = cpl_image_new(1, 41, CPL_TYPE_FLOAT); error = cpl_dfs_save_image(frames, parlist, frames, image, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMAGE", qclist, remregexp, "pipe_id", "image" CPL_DFS_FITS); cpl_test( error == CPL_ERROR_NONE); cpl_test( cpl_frameset_get_size(frames) == ++framesetsize); /* Insert the image also as a calibration frame */ rawframe = cpl_frame_new(); cpl_test_zero(cpl_frame_set_tag(rawframe, "IMAGECALIB")); cpl_test_zero(cpl_frame_set_group(rawframe, CPL_FRAME_GROUP_CALIB)); cpl_test_zero(cpl_frame_set_filename(rawframe, "image" CPL_DFS_FITS)); cpl_test_zero(cpl_frameset_insert(frames, rawframe)); framesetsize++; /* Make sure file does not exist */ (void)remove("table" CPL_DFS_FITS); error = cpl_dfs_save_table(frames, parlist, frames, table, tlist, "recipe", "TESTTABLE", qclist, "none", "pipe_id", "table" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); cpl_test_eq( cpl_frameset_get_size(frames), ++framesetsize); /* Make sure file does not exist */ (void)remove("imlist" CPL_DFS_FITS); error = cpl_dfs_save_imagelist(frames, parlist, frames, imlist, CPL_BPP_8_UNSIGNED, "recipe", "TESTIMLIST", qclist, "none", "pipe_id", "imlist" CPL_DFS_FITS); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); cpl_test_eq( cpl_frameset_get_size(frames), ++framesetsize); /* Make sure file does not exist */ (void)remove("recipe" CPL_DFS_PAF); error = cpl_dfs_save_paf("INSTRUME", "recipe", qclist, "recipe" CPL_DFS_PAF); cpl_test_error(CPL_ERROR_NONE); cpl_test_eq( error, CPL_ERROR_NONE); /* Final test: Update the headers as well */ cpl_test_zero(cpl_dfs_update_product_header(frames)); cpl_msg_info(cpl_func, "New size of frameset: %d", framesetsize); if (cpl_error_get_code() == CPL_ERROR_NONE && !is_debug) { cpl_test(remove("image" CPL_DFS_FITS) == 0); cpl_test(remove("table" CPL_DFS_FITS) == 0); cpl_test(remove("recipe" CPL_DFS_PAF) == 0); } cpl_frameset_delete(frames); cpl_propertylist_delete(tlist); cpl_propertylist_delete(qclist); cpl_parameterlist_delete(parlist); cpl_image_delete(image); cpl_imagelist_delete(imlist); cpl_table_delete(table); return; } static void cpl_dfs_save_txt(const char * self) { FILE * stream = fopen(self, "w"); cpl_test_nonnull( stream ); cpl_test( fprintf(stream, self, "SIMPLE ASCII file - not FITS\n") > 0); cpl_test( fclose(stream) == 0); }