diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2004-06-24 22:20:08 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2004-06-24 22:20:08 (GMT) |
commit | a89057a2cd6e1f939a0021244832fa4f635790bb (patch) | |
tree | a9f91881bb59ec76945b6fac50910e999ea3bea5 /test/file_handle.c | |
parent | 705900b05cf7fc35de51991cd904629e53c983e9 (diff) | |
download | hdf5-a89057a2cd6e1f939a0021244832fa4f635790bb.zip hdf5-a89057a2cd6e1f939a0021244832fa4f635790bb.tar.gz hdf5-a89057a2cd6e1f939a0021244832fa4f635790bb.tar.bz2 |
[svn-r8741] *** empty log message ***
Diffstat (limited to 'test/file_handle.c')
-rw-r--r-- | test/file_handle.c | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/test/file_handle.c b/test/file_handle.c index cf255e8..8df8409 100644 --- a/test/file_handle.c +++ b/test/file_handle.c @@ -21,6 +21,7 @@ #include "h5test.h" +#define KB 1024 #define FAMILY_NUMBER 4 #define FAMILY_SIZE 128 #define MULTI_SIZE 128 @@ -49,6 +50,10 @@ const char *FILENAME[] = { * * Modifications: * + * Raymond Lu + * Wednesday, June 23, 2004 + * Added test for H5Fget_filesize. + * *------------------------------------------------------------------------- */ static herr_t @@ -57,7 +62,8 @@ test_sec2(void) hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; int *fhandle=NULL; - + haddr_t file_size; + TESTING("SEC2 file driver"); /* Set property list and file name for SEC2 driver. */ @@ -83,6 +89,16 @@ test_sec2(void) if(*fhandle<0) goto error; + /* Check file size API */ + if((file_size = H5Fget_filesize(file)) <= 0) + goto error; + + /* There is no garantee the size of metadata in file is constant. + * Just try to check if it's reasonable. It's 2KB right now. + */ + if(file_size<1*KB || file_size>4*KB) + goto error; + if(H5Fclose(file)<0) goto error; h5_cleanup(FILENAME, fapl); @@ -111,6 +127,10 @@ error: * Tuesday, Sept 24, 2002 * * Modifications: + * + * Raymond Lu + * Wednesday, June 23, 2004 + * Added test for H5Fget_filesize. * *------------------------------------------------------------------------- */ @@ -120,6 +140,7 @@ test_core(void) hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; void *fhandle=NULL; + haddr_t file_size; TESTING("CORE file driver"); @@ -148,6 +169,16 @@ test_core(void) goto error; } + /* Check file size API */ + if((file_size = H5Fget_filesize(file)) <= 0) + goto error; + + /* There is no garantee the size of metadata in file is constant. + * Just try to check if it's reasonable. Why is this 4KB? + */ + if(file_size<2*KB || file_size>6*KB) + goto error; + if(H5Fclose(file)<0) goto error; h5_cleanup(FILENAME, fapl); @@ -177,6 +208,10 @@ error: * * Modifications: * + * Raymond Lu + * Wednesday, June 23, 2004 + * Added test for H5Fget_filesize. + * *------------------------------------------------------------------------- */ static herr_t @@ -190,6 +225,7 @@ test_family(void) int *fhandle=NULL, *fhandle2=NULL; int buf[FAMILY_NUMBER][FAMILY_SIZE]; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; + haddr_t file_size; TESTING("FAMILY file driver"); @@ -202,6 +238,14 @@ test_family(void) if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; + /* Check file size API */ + if((file_size = H5Fget_filesize(file)) <= 0) + goto error; + + /* The file size is supposed to be 2KB right now. */ + if(file_size<1*KB || file_size>4*KB) + goto error; + /* Create and write dataset */ if((space=H5Screate_simple(2, dims, NULL))<0) goto error; @@ -241,6 +285,14 @@ test_family(void) if(*fhandle2<0) goto error; + /* Check file size API */ + if((file_size = H5Fget_filesize(file)) <= 0) + goto error; + + /* Some data has been written. The file size should be bigger(4KB) now. */ + if(file_size<2*KB || file_size>6*KB) + goto error; + if(H5Sclose(space)<0) goto error; if(H5Dclose(dset)<0) @@ -279,6 +331,10 @@ error: * * Modifications: * + * Raymond Lu + * Wednesday, June 23, 2004 + * Added test for H5Fget_filesize. + * *------------------------------------------------------------------------- */ static herr_t @@ -288,6 +344,7 @@ test_multi(void) hid_t access_fapl = -1; char filename[1024]; int *fhandle2=NULL, *fhandle=NULL; + haddr_t file_size; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; @@ -341,9 +398,20 @@ test_multi(void) if (H5Pclose(access_fapl) < 0) goto error; + /* Check file size API */ + if((file_size = H5Fget_filesize(file)) <= 0) + goto error; + + /* Before any data is written, the raw data file is empty. So + * the file size is only the size of metadata file. It's supposed + * to be 2KB. + */ + if(file_size<1*KB || file_size>4*KB) + goto error; + if((dset=H5Dcreate(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT))<0) goto error; - + for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; @@ -366,6 +434,17 @@ test_multi(void) if(*fhandle2<0) goto error; + /* Check file size API */ + if((file_size = H5Fget_filesize(file)) <= 0) + goto error; + + /* After the data is written, the file size is huge because the + * beginning of raw data file is set at HADDR_MAX/2. It's supposed + * to be (HADDR_MAX/2 + 128*128*4) + */ + if(file_size < HADDR_MAX/2 || file_size > HADDR_MAX) + goto error; + if(H5Sclose(space)<0) goto error; if(H5Dclose(dset)<0) |