diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/cache.c | 4 | ||||
-rw-r--r-- | test/dtransform.c | 2 | ||||
-rw-r--r-- | test/dtypes.c | 32 | ||||
-rw-r--r-- | test/lheap.c | 1 | ||||
-rw-r--r-- | test/ohdr.c | 1 | ||||
-rwxr-xr-x | test/reserved.c | 273 | ||||
-rw-r--r-- | test/tid.c | 12 | ||||
-rw-r--r-- | test/titerate.c | 12 | ||||
-rw-r--r-- | test/unlink.c | 2 |
9 files changed, 186 insertions, 153 deletions
diff --git a/test/cache.c b/test/cache.c index ac73fcd..dcc2395 100644 --- a/test/cache.c +++ b/test/cache.c @@ -1839,8 +1839,8 @@ rename_entry(H5C_t * cache_ptr, { herr_t result; hbool_t done = TRUE; /* will set to FALSE if we have work to do */ - haddr_t old_addr; - haddr_t new_addr; + haddr_t old_addr = HADDR_UNDEF; + haddr_t new_addr = HADDR_UNDEF; test_entry_t * base_addr; test_entry_t * entry_ptr; diff --git a/test/dtransform.c b/test/dtransform.c index 9d1665b..c12530a 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -6,7 +6,7 @@ int compare_int(int* a, int* b, int tol); int compare_float(float* a, float* b, float tol); -int main() +int main(void) { hid_t file_id, dxpl_id_f_to_c, dxpl_id_c_to_f, dxpl_id_simple, dset_id_int, dset_id_float, datatype, dataspace; hsize_t dim[2] = {ROWS, COLS}; diff --git a/test/dtypes.c b/test/dtypes.c index dcc14bd..e0fc7be 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1885,13 +1885,13 @@ test_encode(void) double d; }; hid_t file=-1, tid1=-1, tid2=-1; - hid_t decoded_tid1, decoded_tid2; + hid_t decoded_tid1=-1, decoded_tid2=-1; char filename[1024]; char compnd_type[]="Compound_type", enum_type[]="Enum_type"; short enum_val; size_t cmpd_buf_size = 0; size_t enum_buf_size = 0; - unsigned char *cmpd_buf, *enum_buf; + unsigned char *cmpd_buf=NULL, *enum_buf=NULL; TESTING("functions of encoding and decoding data types"); @@ -1990,6 +1990,13 @@ test_encode(void) goto error; } /* end if */ + /* Verify that the datatype was copied exactly */ + if(H5Tequal(decoded_tid1, tid1)<=0) { + H5_FAILED(); + printf("Datatype wasn't encoded & decoded identically\n"); + goto error; + } /* end if */ + /* Query member number and member index by name, for compound type. */ if(H5Tget_nmembers(decoded_tid1)!=4) { H5_FAILED(); @@ -2026,6 +2033,13 @@ test_encode(void) goto error; } /* end if */ + /* Verify that the datatype was copied exactly */ + if(H5Tequal(decoded_tid2, tid2)<=0) { + H5_FAILED(); + printf("Datatype wasn't encoded & decoded identically\n"); + goto error; + } /* end if */ + /* Query member number and member index by name, for enumeration type. */ if(H5Tget_nmembers(decoded_tid2)!=5) { H5_FAILED(); @@ -2116,6 +2130,13 @@ test_encode(void) goto error; } /* end if */ + /* Verify that the datatype was copied exactly */ + if(H5Tequal(decoded_tid1, tid1)<=0) { + H5_FAILED(); + printf("Datatype wasn't encoded & decoded identically\n"); + goto error; + } /* end if */ + /* Query member number and member index by name, for compound type. */ if(H5Tget_nmembers(decoded_tid1)!=4) { H5_FAILED(); @@ -2155,6 +2176,13 @@ test_encode(void) goto error; } /* end if */ + /* Verify that the datatype was copied exactly */ + if(H5Tequal(decoded_tid2, tid2)<=0) { + H5_FAILED(); + printf("Datatype wasn't encoded & decoded identically\n"); + goto error; + } /* end if */ + /* Query member number and member index by name, for enumeration type. */ if(H5Tget_nmembers(decoded_tid2)!=5) { H5_FAILED(); diff --git a/test/lheap.c b/test/lheap.c index 5fe6c1f..e1694ba 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -29,6 +29,7 @@ const char *FILENAME[] = { #define NOBJS 40 + /*------------------------------------------------------------------------- * Function: main * diff --git a/test/ohdr.c b/test/ohdr.c index aa9259c..a893d08 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -39,6 +39,7 @@ const char *FILENAME[] = { * the library and simply compile gen_bogus.c with that HDF5 library and run it. */ #define FILE_BOGUS "tbogus.h5" + /*------------------------------------------------------------------------- * Function: main * diff --git a/test/reserved.c b/test/reserved.c index 3fb5827..ff2315b 100755 --- a/test/reserved.c +++ b/test/reserved.c @@ -34,88 +34,90 @@ * *------------------------------------------------------------------------- */ -herr_t rsrv_heap() +static herr_t +rsrv_heap(void) { - hid_t file_id, dataset_id, dataspace_id; - hid_t pfc_id; - hsize_t dims[1] = {1}; - herr_t ret_value = 0; - char dset_name[10]; - int i; + hid_t file_id, dataset_id, dataspace_id; + hid_t pfc_id; + hsize_t dims[1] = {1}; + herr_t ret_value = 0; + char dset_name[10]; + int i; TESTING("Reserving file space for heap"); - /* Create a new file. */ - pfc_id = H5Pcreate(H5P_FILE_CREATE); - H5Pset_userblock(pfc_id, (int)0); - H5Pset_sym_k(pfc_id, (int)1, (int)1); - H5Pset_istore_k(pfc_id, (int)1); - /* Set file address sizes to be very small. */ + /* Create a new file. */ + pfc_id = H5Pcreate(H5P_FILE_CREATE); + H5Pset_userblock(pfc_id, (hsize_t)0); + H5Pset_sym_k(pfc_id, 1, 1); + H5Pset_istore_k(pfc_id, 1); + + /* Set file address sizes to be very small. */ H5Pset_sizes(pfc_id, (size_t)2,(size_t)2); - file_id = H5Fcreate("rsrv_heap", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT); + file_id = H5Fcreate("rsrv_heap", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT); - /* Write datasets until the file is full, at which point HDF5 - * should throw an error. - */ - for (i = 0; i < 200; i++) - { - H5E_BEGIN_TRY { - dataspace_id = H5Screate_simple(1, dims, dims); - } H5E_END_TRY + /* Write datasets until the file is full, at which point HDF5 + * should throw an error. + */ + for (i = 0; i < 200; i++) + { + H5E_BEGIN_TRY { + dataspace_id = H5Screate_simple(1, dims, dims); + } H5E_END_TRY - sprintf(dset_name, "Dset %d", i); + sprintf(dset_name, "Dset %d", i); - H5E_BEGIN_TRY { - dataset_id = H5Dcreate(file_id, dset_name, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT); - } H5E_END_TRY + H5E_BEGIN_TRY { + dataset_id = H5Dcreate(file_id, dset_name, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT); + } H5E_END_TRY - if(dataset_id < 0) - break; + if(dataset_id < 0) + break; - H5E_BEGIN_TRY { - H5Dwrite(dataset_id, H5T_NATIVE_INT, dataspace_id, dataspace_id, H5P_DEFAULT, &i); - } H5E_END_TRY + H5E_BEGIN_TRY { + H5Dwrite(dataset_id, H5T_NATIVE_INT, dataspace_id, dataspace_id, H5P_DEFAULT, &i); + } H5E_END_TRY - H5Dclose(dataset_id); - H5Sclose(dataspace_id); - } + H5Dclose(dataset_id); + H5Sclose(dataspace_id); + } - /* Close the file, property lists, and library */ + /* Close the file, property lists, and library */ H5Fclose(file_id); - H5Pclose (pfc_id); - H5close(); + H5Pclose(pfc_id); + H5close(); - /* The loop should have broken before completing--the file should not have had - * enough address space to hold 200 datasets (or this test needs to be updated!). - */ - if(i == 200) + /* The loop should have broken before completing--the file should not have had + * enough address space to hold 200 datasets (or this test needs to be updated!). + */ + if(i == 200) { - ret_value = -1; - H5_FAILED(); + ret_value = 1; + H5_FAILED(); } - /* Re-open the library and try to read a dataset from the file we created */ - H5open(); + /* Re-open the library and try to read a dataset from the file we created */ + H5open(); - sprintf(dset_name, "Dset %d", i - 2); + sprintf(dset_name, "Dset %d", i - 2); - file_id = H5Fopen("rsrv_heap", H5F_ACC_RDONLY, H5P_DEFAULT); + file_id = H5Fopen("rsrv_heap", H5F_ACC_RDONLY, H5P_DEFAULT); - dataset_id = H5Dopen(file_id, dset_name); + dataset_id = H5Dopen(file_id, dset_name); - /* If we can read a dataset from the file, the file has been flushed to disk - * (if the heap or object headers weren't flushed, the file would be empty). - */ - if(dataset_id == H5I_BADID) - { - ret_value = -1; - H5_FAILED(); - } + /* If we can read a dataset from the file, the file has been flushed to disk + * (if the heap or object headers weren't flushed, the file would be empty). + */ + if(dataset_id == H5I_BADID) + { + ret_value = 1; + H5_FAILED(); + } - H5Dclose(dataset_id); - H5Fclose(file_id); - remove("rsrv_heap"); + H5Dclose(dataset_id); + H5Fclose(file_id); + HDremove("rsrv_heap"); if(ret_value == 0) { @@ -145,35 +147,35 @@ herr_t rsrv_heap() * *------------------------------------------------------------------------- */ -herr_t rsrv_ohdr() +static herr_t +rsrv_ohdr(void) { - hid_t file_id, dataset_id, dataspace_id; - hid_t pfc_id, aid, attr_id; - hsize_t dims[2]; - herr_t status, ret_value = 0; - int attrval[4][6]; - char *basenm = "attr"; - char attrname[20], nm_suf[10]; - int i; + hid_t file_id, dataset_id, dataspace_id; + hid_t pfc_id, aid, attr_id; + hsize_t dims[2]; + herr_t status, ret_value = 0; + int attrval[4][6]; + char attrname[20]; + int i; TESTING("Reserving file space for object headers"); - /* Create a new file using default properties. */ - pfc_id = H5Pcreate(H5P_FILE_CREATE); - H5Pset_userblock(pfc_id, (int)0); - H5Pset_sym_k(pfc_id, (int)1, (int)1); - H5Pset_istore_k(pfc_id, (int)1); - H5Pset_sizes(pfc_id, (size_t)2,(size_t)2); + /* Create a new file using default properties. */ + pfc_id = H5Pcreate(H5P_FILE_CREATE); + H5Pset_userblock(pfc_id, (hsize_t)0); + H5Pset_sym_k(pfc_id, 1, 1); + H5Pset_istore_k(pfc_id, 1); + H5Pset_sizes(pfc_id, (size_t)2,(size_t)2); - file_id = H5Fcreate("rsrv_ohdr", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT); + file_id = H5Fcreate("rsrv_ohdr", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT); - /* Create the data space for the dataset. */ - dims[0] = 4; - dims[1] = 6; - dataspace_id = H5Screate_simple(2, dims, NULL); + /* Create the data space for the dataset. */ + dims[0] = 4; + dims[1] = 6; + dataspace_id = H5Screate_simple(2, dims, NULL); - /* Create the dataset. */ - dataset_id = H5Dcreate(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT); + /* Create the dataset. */ + dataset_id = H5Dcreate(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT); for(i=0; i<6; i++) { @@ -183,63 +185,61 @@ herr_t rsrv_ohdr() attrval[3][i] = 3; } - for (i = 0; i< 2000; i++) - { - strcpy(attrname, basenm); - sprintf(nm_suf, "%d", i); - strcat(attrname, nm_suf); - H5E_BEGIN_TRY{ - aid = H5Screate_simple(2, dims, NULL); - attr_id = H5Acreate (dataset_id, attrname, H5T_STD_I32BE, aid, H5P_DEFAULT); - status = H5Awrite(attr_id, H5T_NATIVE_INT, attrval); - status = H5Aclose(attr_id); - }H5E_END_TRY + for (i = 0; i< 2000; i++) + { + sprintf(attrname, "attr %d", i); + H5E_BEGIN_TRY{ + aid = H5Screate_simple(2, dims, NULL); + attr_id = H5Acreate (dataset_id, attrname, H5T_STD_I32BE, aid, H5P_DEFAULT); + status = H5Awrite(attr_id, H5T_NATIVE_INT, attrval); + status = H5Aclose(attr_id); + } H5E_END_TRY if(status < 0) break; - } + } - /* End access to the dataset and dataspace and release resources. */ - H5Dclose(dataset_id); - H5Pclose (pfc_id); - H5Sclose(dataspace_id); + /* End access to the dataset and dataspace and release resources. */ + H5Dclose(dataset_id); + H5Pclose (pfc_id); + H5Sclose(dataspace_id); - /* Close the file and the library. */ - H5Fclose(file_id); - H5close(); + /* Close the file and the library. */ + H5Fclose(file_id); + H5close(); - /* The loop should have broken before completing--the file should not have had - * enough address space to hold 2000 attributes (or this test needs to be updated!). - */ + /* The loop should have broken before completing--the file should not have had + * enough address space to hold 2000 attributes (or this test needs to be updated!). + */ if(i == 2000) { - ret_value = -1; + ret_value = 1; H5_FAILED(); } - /* Re-open the library and try to read a dataset from the file we created */ - H5open(); + /* Re-open the library and try to read a dataset from the file we created */ + H5open(); - file_id = H5Fopen("rsrv_ohdr", H5F_ACC_RDONLY, H5P_DEFAULT); + file_id = H5Fopen("rsrv_ohdr", H5F_ACC_RDONLY, H5P_DEFAULT); - dataset_id = H5Dopen(file_id, "/dset"); + dataset_id = H5Dopen(file_id, "/dset"); - /* If we can read the dataset from the file, the file has been flushed to disk - * (if the heap or object headers weren't flushed, the file would be empty). - */ - if(dataset_id == H5I_BADID) - { - H5_FAILED(); - ret_value = -1; - } + /* If we can read the dataset from the file, the file has been flushed to disk + * (if the heap or object headers weren't flushed, the file would be empty). + */ + if(dataset_id == H5I_BADID) + { + ret_value = 1; + H5_FAILED(); + } if(ret_value == 0) PASSED(); - H5Dclose(dataset_id); - H5Fclose(file_id); + H5Dclose(dataset_id); + H5Fclose(file_id); - remove("rsrv_ohdr"); + HDremove("rsrv_ohdr"); return ret_value; } @@ -266,11 +266,14 @@ herr_t rsrv_ohdr() * *------------------------------------------------------------------------- */ -herr_t rsrv_vlen() +static herr_t +rsrv_vlen(void) { hid_t file_id, dataset_id, dataspace_id, type_id; hid_t pfc_id, mem_space_id; - hsize_t dims[1], start[1], count[1]; + hssize_t offset[1]; + hssize_t start[1]; + hsize_t dims[1], count[1]; herr_t status, ret_value = 0; int i; int write_buf[20]; @@ -280,9 +283,9 @@ herr_t rsrv_vlen() /* Create a new file using default properties. */ pfc_id = H5Pcreate(H5P_FILE_CREATE); - H5Pset_userblock(pfc_id, (int)0); - H5Pset_sym_k(pfc_id, (int)1, (int)1); - H5Pset_istore_k(pfc_id, (int)1); + H5Pset_userblock(pfc_id, (hsize_t)0); + H5Pset_sym_k(pfc_id, 1, 1); + H5Pset_istore_k(pfc_id, 1); H5Pset_sizes(pfc_id, (size_t)2,(size_t)2); file_id = H5Fcreate("rsrv_vlen", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT); @@ -315,11 +318,11 @@ herr_t rsrv_vlen() { vlen_data.len = (i%20) + 1; - dims[0] = i; - H5Soffset_simple(dataspace_id, dims); + offset[0] = i; + H5Soffset_simple(dataspace_id, offset); H5E_BEGIN_TRY - status = H5Dwrite(dataset_id, type_id, mem_space_id, dataspace_id, H5P_DEFAULT, &vlen_data); + status = H5Dwrite(dataset_id, type_id, mem_space_id, dataspace_id, H5P_DEFAULT, &vlen_data); H5E_END_TRY if(status < 0) @@ -342,7 +345,7 @@ herr_t rsrv_vlen() */ if(i == 2000) { - ret_value = -1; + ret_value = 1; H5_FAILED(); } @@ -358,8 +361,8 @@ herr_t rsrv_vlen() */ if(dataset_id == H5I_BADID) { + ret_value = 1; H5_FAILED(); - ret_value = -1; } if(ret_value == 0) @@ -368,7 +371,7 @@ herr_t rsrv_vlen() H5Dclose(dataset_id); H5Fclose(file_id); - remove("rsrv_vlen"); + HDremove("rsrv_vlen"); return ret_value; } @@ -392,10 +395,12 @@ herr_t rsrv_vlen() int main(void) { - rsrv_ohdr(); - rsrv_heap(); - rsrv_vlen(); + int num_errs=0; + + num_errs+=rsrv_ohdr(); + num_errs+=rsrv_heap(); + num_errs+=rsrv_vlen(); - return 0; + return num_errs; } @@ -7,7 +7,7 @@ #include "H5Ipkg.h" /* Test basic functionality of registering and deleting types and IDs */ -int id_test() +static int id_test(void) { H5I_type_t myType = H5I_BADID; hid_t arrayID = H5I_INVALID_HID; @@ -183,16 +183,14 @@ out: /* A dummy search function for the next test */ -int test_search_func(void * ptr1, void * ptr2); -int test_search_func(void * ptr1, void * ptr2) { return 0; } +static int test_search_func(void UNUSED * ptr1, void UNUSED * ptr2) { return 0; } /* Ensure that public functions cannot access "predefined" ID types */ -int id_predefined_test() +static int id_predefined_test(void ) { void * testObj; hid_t testID; hid_t typeID = H5I_INVALID_HID; - int testInt; void * testPtr; herr_t testErr; @@ -289,7 +287,7 @@ out: /* destroy it, this test will mysteriously fail (because it will expect there to */ /* be one more "free" type ID than there is). */ /* H5I_NTYPES is defined in h5public.h, MAX_NUM_TYPES is defined in h5pkg.h */ -int test_id_type_list() +static int test_id_type_list(void) { H5I_type_t startType; /* The first type ID we were assigned in this test */ H5I_type_t currentType; @@ -358,7 +356,7 @@ out: return -1; } -void test_ids() +void test_ids(void) { id_test(); id_predefined_test(); diff --git a/test/titerate.c b/test/titerate.c index 652771a..b883ba3 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -756,7 +756,7 @@ static void test_grp_memb_funcs(void) CHECK(ret, FAIL, "H5Fclose"); /* Sort the dataset names */ - qsort(dnames,NDATASETS+2,sizeof(char *),iter_strcmp); + HDqsort(dnames,NDATASETS+2,sizeof(char *),iter_strcmp); /* Iterate through the datasets in the root group in various ways */ file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -779,7 +779,7 @@ static void test_grp_memb_funcs(void) name_len = H5Gget_objname_by_idx(root_group, (hsize_t)i, NULL, NAMELEN); CHECK(name_len, FAIL, "H5Gget_objname_by_idx"); - ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, name_len+1); + ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)(name_len+1)); CHECK(ret, FAIL, "H5Gget_objname_by_idx"); /* Double-check that the length is the same */ @@ -841,7 +841,7 @@ static void test_links(void) ssize_t name_len; /* Length of object's name */ herr_t ret; /* Generic return value */ hid_t gid, gid1; - int i; + hsize_t i; H5G_obj_t obj_type; /* Type of object */ hsize_t nobjs; /* Number of objects */ @@ -873,10 +873,10 @@ static void test_links(void) /* Test these two functions, H5Gget_num_objs and H5Gget_objname_by_idx */ for(i=0; i<nobjs; i++) { /* Get object name */ - name_len = H5Gget_objname_by_idx(gid, (hsize_t)i, obj_name, NAMELEN); + name_len = H5Gget_objname_by_idx(gid, i, obj_name, NAMELEN); CHECK(name_len, FAIL, "H5Gget_objname_by_idx"); - obj_type = H5Gget_objtype_by_idx(gid, (hsize_t)i); + obj_type = H5Gget_objtype_by_idx(gid, i); CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx"); if(!HDstrcmp(obj_name, "g1.1")) @@ -898,7 +898,7 @@ static void test_links(void) ret=H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); } /* test_links() */ - + /**************************************************************** ** ** test_iterate(): Main iteration testing routine. diff --git a/test/unlink.c b/test/unlink.c index 9f8e5b2..59e0633 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -1816,7 +1816,7 @@ error: static int test_resurrect_dataset(void) { - hid_t f, s, d, fapl; + hid_t f=-1, s=-1, d=-1, fapl=-1; char filename[1024]; TESTING("Resurrecting dataset after deletion"); |