/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * * Purpose: Tests the file handle interface */ #include "h5test.h" #define FAMILY_NUMBER 4 #define FAMILY_SIZE 128 #define MULTI_SIZE 128 #define CORE_INCREMENT 4096 const char *FILENAME[] = { "sec2_file", "core_file", "family_file", "multi_file", NULL }; /*------------------------------------------------------------------------- * Function: test_sec2 * * Purpose: Tests the file handle interface for SEC2 driver * * Return: Success: exit(0) * * Failure: exit(1) * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t test_sec2(void) { hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; int *fhandle=NULL; TESTING("SEC2 file driver"); /* Set property list and file name for SEC2 driver. */ fapl = h5_fileaccess(); if(H5Pset_fapl_sec2(fapl)<0) goto error; h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) goto error; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) goto error; /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle)<0) goto error; if(*fhandle<0) goto error; if(H5Fclose(file)<0) goto error; h5_cleanup(FILENAME, fapl); PASSED(); return 0; error: H5E_BEGIN_TRY { H5Pclose (fapl); H5Fclose(file); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * Function: test_core * * Purpose: Tests the file handle interface for CORE driver * * Return: Success: exit(0) * * Failure: exit(1) * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t test_core(void) { hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; void *fhandle=NULL; TESTING("CORE file driver"); /* Set property list and file name for CORE driver */ fapl = h5_fileaccess(); if(H5Pset_fapl_core(fapl, CORE_INCREMENT, TRUE)<0) goto error; h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) goto error; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) goto error; if(H5Fget_vfd_handle(file, H5P_DEFAULT, &fhandle)<0) goto error; if(fhandle==NULL) { printf("fhandle==NULL\n"); goto error; } if(H5Fclose(file)<0) goto error; h5_cleanup(FILENAME, fapl); PASSED(); return 0; error: H5E_BEGIN_TRY { H5Pclose (fapl); H5Fclose(file); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * Function: test_family * * Purpose: Tests the file handle interface for FAMILY driver * * Return: Success: exit(0) * * Failure: exit(1) * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t test_family(void) { hid_t file=(-1), fapl, fapl2=(-1), space=(-1), dset=(-1); hid_t access_fapl = -1; char filename[1024]; char dname[]="dataset"; int i, j; int *fhandle=NULL, *fhandle2=NULL; int buf[FAMILY_NUMBER][FAMILY_SIZE]; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; TESTING("FAMILY file driver"); /* Set property list and file name for FAMILY driver */ fapl = h5_fileaccess(); if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT)<0) goto error; h5_fixname(FILENAME[2], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; /* Create and write dataset */ if((space=H5Screate_simple(2, dims, NULL))<0) goto error; /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) goto error; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) goto error; if((dset=H5Dcreate(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT))<0) goto error; for(i=0; i