mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-18 17:40:55 +08:00
[svn-r26767] Added test to address HDFFV-3065:
H5Iget_name on datatype that is not named returns no error Tested: h5committest
This commit is contained in:
parent
4662835250
commit
1215ef0370
@ -103,7 +103,11 @@ test_main(hid_t file_id, hid_t fapl)
|
||||
hid_t space_id;
|
||||
hid_t type_id, type2_id;
|
||||
hsize_t dims[1] = { 5 };
|
||||
size_t name_len; /* Name length */
|
||||
size_t name_len; /* Name length */
|
||||
H5O_info_t oinfo; /* Object info structs */
|
||||
hid_t dtype; /* Object identifier for testing */
|
||||
hid_t dtype_anon; /* Object identifier for testing anonymous */
|
||||
ssize_t size; /* Size returned by H5Iget_name */
|
||||
|
||||
/* Initialize the file names */
|
||||
h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
|
||||
@ -2355,7 +2359,58 @@ test_main(hid_t file_id, hid_t fapl)
|
||||
H5Gclose(group_id);
|
||||
H5Gclose(group2_id);
|
||||
H5Fclose(file1_id);
|
||||
H5Fclose(file2_id);
|
||||
|
||||
PASSED();
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Test H5Iget_name with anonymous datatypes
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
TESTING("H5Iget_name with anonymous datatypes");
|
||||
|
||||
/* Commit the type anonymously and link it in */
|
||||
if((dtype = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
|
||||
/* Test H5Iget_name with created datatype, should fail because not committed */
|
||||
H5E_BEGIN_TRY {
|
||||
if((size = H5Iget_name(dtype, NULL, 0)) >= 0) TEST_ERROR
|
||||
} H5E_END_TRY;
|
||||
|
||||
if(H5Tcommit_anon(file2_id, dtype, H5P_DEFAULT, H5P_DEFAULT)) TEST_ERROR
|
||||
|
||||
/* Test H5Iget_name with anonymously created datatype, should pass because committed */
|
||||
if((size = H5Iget_name(dtype, NULL, 0)) != 0) TEST_ERROR
|
||||
|
||||
/* Create a link to the object */
|
||||
if( H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
|
||||
|
||||
/* Commit a second datatype with no links to it and commit it */
|
||||
if((dtype_anon = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
|
||||
if(H5Tcommit_anon(file2_id, dtype_anon, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
|
||||
|
||||
/* Test H5Iget_name with anonymously created datatype, should pass because committed */
|
||||
if((size = H5Iget_name(dtype_anon, NULL,0)) != 0) TEST_ERROR
|
||||
|
||||
/* Store the address of the datatype for later use */
|
||||
if(H5Oget_info(dtype_anon, &oinfo) < 0) TEST_ERROR
|
||||
|
||||
/* Update the reference count to dtype_anon to preserve the datatype */
|
||||
if(H5Oincr_refcount(dtype_anon) < 0) TEST_ERROR
|
||||
|
||||
if(H5Tclose(dtype) < 0) TEST_ERROR
|
||||
if(H5Tclose(dtype_anon) < 0) TEST_ERROR
|
||||
if(H5Fclose(file2_id) < 0) TEST_ERROR
|
||||
|
||||
/* Re-open the file and check that the anonymous datatypes persist */
|
||||
if( (file2_id = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
|
||||
/* Check the H5Iget_name does not return an error for anon committed datatypes */
|
||||
if((dtype_anon = H5Oopen_by_addr(file2_id, oinfo.addr)) < 0) TEST_ERROR
|
||||
|
||||
if((size = H5Iget_name(dtype_anon,NULL,0)) != 0) TEST_ERROR
|
||||
|
||||
if(H5Tclose(dtype_anon) < 0) TEST_ERROR
|
||||
if(H5Fclose(file2_id) < 0) TEST_ERROR
|
||||
|
||||
PASSED();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user