diff options
Diffstat (limited to 'test/vfd.c')
-rw-r--r-- | test/vfd.c | 142 |
1 files changed, 71 insertions, 71 deletions
@@ -12,35 +12,35 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu<slu@ncsa.uiuc.edu> - * Tuesday, Sept 24, 2002 - * +/* + * Programmer: Raymond Lu<slu@ncsa.uiuc.edu> + * Tuesday, Sept 24, 2002 + * * Purpose: Tests the basic features of Virtual File Drivers */ - + #include "h5test.h" #define KB 1024 #define FAMILY_NUMBER 4 #define FAMILY_SIZE (1*KB) #define FAMILY_SIZE2 (5*KB) -#define MULTI_SIZE 128 +#define MULTI_SIZE 128 #define CORE_INCREMENT (4*KB) -const char *FILENAME[] = { +const char *FILENAME[] = { "sec2_file", "core_file", "family_file", "multi_file", - NULL + NULL }; - + #define COMPAT_BASENAME "family_v1.6_" - + /*------------------------------------------------------------------------- - * Function: test_sec2 + * Function: test_sec2 * * Purpose: Tests the file handle interface for SEC2 driver * @@ -59,16 +59,16 @@ const char *FILENAME[] = { * *------------------------------------------------------------------------- */ -static herr_t +static herr_t test_sec2(void) { hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; int *fhandle=NULL; hsize_t file_size; - + TESTING("SEC2 file driver"); - + /* Set property list and file name for SEC2 driver. */ fapl = h5_fileaccess(); if(H5Pset_fapl_sec2(fapl)<0) @@ -96,9 +96,9 @@ test_sec2(void) if(H5Fget_filesize(file, &file_size) < 0) goto error; - /* There is no garantee the size of metadata in file is constant. + /* 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; @@ -107,7 +107,7 @@ test_sec2(void) h5_cleanup(FILENAME, fapl); PASSED(); return 0; - + error: H5E_BEGIN_TRY { H5Pclose (fapl); @@ -118,23 +118,23 @@ error: /*------------------------------------------------------------------------- - * Function: test_core - * + * 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: * * Raymond Lu * Wednesday, June 23, 2004 * Added test for H5Fget_filesize. - * + * *------------------------------------------------------------------------- */ static herr_t @@ -152,7 +152,7 @@ test_core(void) 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; @@ -176,9 +176,9 @@ test_core(void) if(H5Fget_filesize(file, &file_size) < 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? - */ + /* 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; @@ -187,7 +187,7 @@ test_core(void) h5_cleanup(FILENAME, fapl); PASSED(); return 0; - + error: H5E_BEGIN_TRY { H5Pclose (fapl); @@ -221,9 +221,9 @@ test_family_opens(char *fname, hid_t fa_pl) char wrong_name[1024]; int i; - /* Case 1: reopen file with 1st member file name and default property list */ + /* Case 1: reopen file with 1st member file name and default property list */ sprintf(first_name, fname, 0); - + H5E_BEGIN_TRY { file=H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT); } H5E_END_TRY; @@ -240,7 +240,7 @@ test_family_opens(char *fname, hid_t fa_pl) H5E_BEGIN_TRY { file=H5Fopen(fname, H5F_ACC_RDWR, fa_pl); } H5E_END_TRY; - + /* Case 4: reopen file with wrong name template */ strcpy(wrong_name, fname); for(i=0; i<1024; i++) { @@ -283,7 +283,7 @@ error: * * Raymond Lu * June 2, 2005 - * Added a function test_family_opens() to test different + * Added a function test_family_opens() to test different * wrong way to reopen family files. * *------------------------------------------------------------------------- @@ -316,7 +316,7 @@ test_family(void) if(H5Fclose(file)<0) goto error; - /* Test different wrong ways to reopen family files where there's only + /* Test different wrong ways to reopen family files where there's only * one member file existing. */ if(test_family_opens(filename, fapl)<0) goto error; @@ -354,7 +354,7 @@ test_family(void) for(i=0; i<FAMILY_NUMBER; i++) for(j=0; j<FAMILY_SIZE; j++) buf[i][j] = i*10000+j; - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) goto error; /* check file handle API */ @@ -379,8 +379,8 @@ test_family(void) if(H5Fget_filesize(file, &file_size) < 0) goto error; - /* Some data has been written. The file size should be bigger(18KB+976 - * bytes if int size is 4 bytes) now. */ + /* Some data has been written. The file size should be bigger(18KB+976 + * bytes if int size is 4 bytes) now. */ if(sizeof(int)<=4) { if(file_size<18*KB || file_size>20*KB) goto error; @@ -388,7 +388,7 @@ test_family(void) if(file_size<32*KB || file_size>40*KB) goto error; } - + if(H5Sclose(space)<0) goto error; if(H5Dclose(dset)<0) @@ -412,7 +412,7 @@ test_family(void) if(H5Fclose(file)<0) goto error; - + h5_cleanup(FILENAME, fapl); PASSED(); return 0; @@ -431,7 +431,7 @@ error: /*------------------------------------------------------------------------- * Function: test_family_compat * - * Purpose: Tests the backward compatibility for FAMILY driver. + * Purpose: Tests the backward compatibility for FAMILY driver. * See if we can open files created with v1.6 library. * The source file was created by the test/file_handle.c * of the v1.6 library. Then tools/misc/h5repart.c was @@ -448,14 +448,14 @@ error: * Modifications: *------------------------------------------------------------------------- */ -static herr_t +static herr_t test_family_compat(void) { #ifdef H5_WANT_H5_V1_6_COMPAT hid_t file=(-1), fapl; char filename[1024]; char pathname[1024]; - char *srcdir = getenv("srcdir"); /*where the src code is located*/ + char *srcdir = getenv("srcdir"); /*where the src code is located*/ #endif /*H5_WANT_H5_V1_6_COMPAT*/ TESTING("FAMILY file driver backward compatibility"); @@ -477,7 +477,7 @@ test_family_compat(void) if(srcdir && ((strlen(srcdir) + strlen(filename) + 1) < sizeof(pathname))) { strcpy(pathname, srcdir); strcat(pathname, "/"); - } + } strcat(pathname, filename); if((file=H5Fopen(pathname, H5F_ACC_RDONLY, fapl))<0) @@ -524,7 +524,7 @@ test_multi_opens(char *fname, hid_t fa_pl) char super_name[1024]; /*name string "%%s-s.h5"*/ char sf_name[1024]; /*name string "multi_file-s.h5"*/ - /* Case: reopen with the name of super file and default property list */ + /* Case: reopen with the name of super file and default property list */ sprintf(super_name, "%%s-%c.h5", 's'); sprintf(sf_name, super_name, fname); @@ -553,7 +553,7 @@ test_multi_opens(char *fname, hid_t fa_pl) * Raymond Lu * Wednesday, June 23, 2004 * Added test for H5Fget_filesize. - * + * *------------------------------------------------------------------------- */ static herr_t @@ -593,7 +593,7 @@ test_multi(void) memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; memb_addr[H5FD_MEM_SUPER] = 0; - memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; + memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2; @@ -605,9 +605,9 @@ test_multi(void) if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; - if(H5Fclose(file)<0) + if(H5Fclose(file)<0) goto error; - + /* Test wrong ways to reopen multi files */ if(test_multi_opens(filename, fapl)<0) goto error; @@ -635,13 +635,13 @@ test_multi(void) /* 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; @@ -668,9 +668,9 @@ test_multi(void) if(H5Fget_filesize(file, &file_size) < 0) goto error; - /* After the data is written, the file size is huge because the + /* 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) + * to be (HADDR_MAX/2 + 128*128*4) */ if(file_size < HADDR_MAX/2 || file_size > HADDR_MAX) goto error; @@ -681,48 +681,48 @@ test_multi(void) goto error; if(H5Pclose(fapl2)<0) goto error; - if(H5Fclose(file)<0) - goto error; + if(H5Fclose(file)<0) + goto error; + + h5_cleanup(FILENAME, fapl); + PASSED(); - h5_cleanup(FILENAME, fapl); - PASSED(); + return 0; - return 0; - -error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY { H5Sclose(space); H5Dclose(dset); H5Pclose(fapl); H5Pclose(fapl2); - H5Fclose(file); - } H5E_END_TRY; - return -1; + H5Fclose(file); + } H5E_END_TRY; + return -1; } /*------------------------------------------------------------------------- * Function: main - * + * * Purpose: Tests the basic features of Virtual File Drivers - * + * * Return: Success: exit(0) - * + * * Failure: exit(1) - * + * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 - * + * * Modifications: * *------------------------------------------------------------------------- */ int main(void) -{ +{ int nerrors=0; - - h5_reset(); + + h5_reset(); nerrors += test_sec2()<0 ?1:0; nerrors += test_core()<0 ?1:0; |