[svn-r14122] Description:

Move H5Gmove() to deprecated code section, replacing with H5Lmove()
in source files.

Tested on:
	FreeBSD/32 6.2 (duty)
	FreeBSD/64 6.2 (liberty)
	Linux/32 2.6 (kagiso)
	Linux/64 2.6 (smirom)
	Solaris/32 5.10 (linew)
	Mac OS X/32 10.4.10 (amazon)
This commit is contained in:
Quincey Koziol 2007-08-28 17:30:13 -05:00
parent 518e0ede77
commit cae55b647d
11 changed files with 207 additions and 207 deletions

View File

@ -322,10 +322,10 @@ void CommonFG::unlink( const H5std_string& name ) const
//--------------------------------------------------------------------------
void CommonFG::move( const char* src, const char* dst ) const
{
herr_t ret_value = H5Gmove( getLocId(), src, dst );
herr_t ret_value = H5Lmove( getLocId(), src, H5L_SAME_LOC, dst, H5P_DEFAULT, H5P_DEFAULT );
if( ret_value < 0 )
{
throwException("move", "H5Gmove failed");
throwException("move", "H5Lmove failed");
}
}

View File

@ -438,36 +438,31 @@ DONE:
int_f
nh5gmove_c(hid_t_f *loc_id, _fcd src_name, int_f *src_namelen, _fcd dst_name, int_f*dst_namelen)
{
int ret_value = -1;
hid_t c_loc_id;
char *c_src_name, *c_dst_name;
size_t c_src_namelen, c_dst_namelen;
herr_t c_ret_value;
/*
* Convert Fortran name to C name
*/
c_src_namelen = *src_namelen;
c_dst_namelen = *dst_namelen;
c_src_name = (char *)HD5f2cstring(src_name, c_src_namelen);
if(c_src_name == NULL) return ret_value;
char *c_src_name = NULL, *c_dst_name = NULL;
int ret_value = -1;
c_dst_name = (char *)HD5f2cstring(dst_name, c_dst_namelen);
if(c_dst_name == NULL) { HDfree(c_src_name);
return ret_value;
}
/*
* Call H5Gmove function
*/
c_loc_id = (hid_t)*loc_id;
c_ret_value = H5Gmove(c_loc_id, c_src_name, c_dst_name);
if(c_ret_value < 0) goto DONE;
/*
* Convert Fortran name to C name
*/
if(NULL == (c_src_name = (char *)HD5f2cstring(src_name, (size_t)*src_namelen)))
goto DONE;
if(NULL == (c_dst_name = (char *)HD5f2cstring(dst_name, (size_t)*dst_namelen)))
goto DONE;
ret_value = 0;
/*
* Call H5Gmove function
*/
if(H5Lmove((hid_t)*loc_id, c_src_name, H5L_SAME_LOC, c_dst_name, H5P_DEFAULT, H5P_DEFAULT) < 0)
goto DONE;
ret_value = 0;
DONE:
HDfree(c_src_name);
HDfree(c_dst_name);
return ret_value ;
if(c_src_name)
HDfree(c_src_name);
if(c_dst_name)
HDfree(c_dst_name);
return ret_value ;
}
/*----------------------------------------------------------------------------

View File

@ -2516,7 +2516,7 @@ herr_t H5TBinsert_field( hid_t loc_id,
*-------------------------------------------------------------------------
*/
if ( H5Gmove( loc_id, "new", dset_name ) < 0 )
if ( H5Lmove( loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT ) < 0 )
return -1;
/*-------------------------------------------------------------------------
@ -3001,7 +3001,7 @@ herr_t H5TBdelete_field( hid_t loc_id,
*-------------------------------------------------------------------------
*/
if ( H5Gmove( loc_id, "new", dset_name ) < 0 )
if ( H5Lmove( loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT ) < 0 )
return -1;
/*-------------------------------------------------------------------------

View File

@ -416,7 +416,6 @@ H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id,
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_link_hard() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
@ -441,6 +440,7 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gmove() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------

View File

@ -843,7 +843,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
* H5G_NAME_MOVE
*-------------------------------------------------------------------------
*/
case H5G_NAME_MOVE: /* H5Gmove case, check for relative names case */
case H5G_NAME_MOVE: /* Link move case, check for relative names case */
/* Check if the src object moved is in the current object's path */
if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) {
const char *full_path; /* Full path of current object */

View File

@ -137,8 +137,6 @@ H5_DLL herr_t H5Gclose(hid_t group_id);
*
* Use of these functions and variables is deprecated.
*/
H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name,
const char *dst_name);
H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name);
H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name);
@ -170,6 +168,8 @@ H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5L_type_t type, const char *cur_name,
const char *new_name);
H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5L_type_t type,
hid_t new_loc_id, const char *new_name);
H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name,
const char *dst_name);
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -333,17 +333,17 @@ test_main(hid_t file_id, hid_t fapl)
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gmove and H5Gopen2
* Test H5Iget_name with H5Lmove and H5Gopen2
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Gmove and H5Gopen2");
TESTING("H5Iget_name with H5Lmove and H5Gopen2");
/* Reopen the group */
if((group_id = H5Gopen2(file_id, "/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Rename group */
if(H5Gmove(file_id, "/g1", "/g1a") < 0) FAIL_STACK_ERROR
if(H5Lmove(file_id, "/g1", H5L_SAME_LOC, "/g1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group_id, "/g1a", "/g1a") < 0) TEST_ERROR
@ -355,58 +355,57 @@ test_main(hid_t file_id, hid_t fapl)
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gmove and H5Dopen
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Lmove and H5Dopen
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Gmove and H5Dopen");
TESTING("H5Iget_name with H5Lmove and H5Dopen");
/* Reopen the dataset */
if((dataset_id = H5Dopen(file_id, "/d1")) < 0) TEST_ERROR
if((dataset_id = H5Dopen(file_id, "/d1")) < 0) FAIL_STACK_ERROR
/* Rename dataset */
if(H5Gmove(file_id, "/d1", "/d1a") < 0) TEST_ERROR
if(H5Lmove(file_id, "/d1", H5L_SAME_LOC, "/d1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(dataset_id, "/d1a", "/d1a") < 0) TEST_ERROR
if(check_name(dataset_id, "/d1a", "/d1a") < 0) FAIL_STACK_ERROR
/* Close */
H5Dclose(dataset_id);
if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR
PASSED();
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gmove and H5Topen
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Lmove and H5Topen
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Gmove and H5Topen");
TESTING("H5Iget_name with H5Lmove and H5Topen");
/* Open the named datatype */
if((type_id=H5Topen(file_id, "/t1")) < 0) TEST_ERROR
if((type_id = H5Topen(file_id, "/t1")) < 0) FAIL_STACK_ERROR
/* Rename datatype */
if(H5Gmove(file_id, "/t1", "/t1a") < 0) TEST_ERROR
if(H5Lmove(file_id, "/t1", H5L_SAME_LOC, "/t1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(type_id, "/t1a", "/t1a") < 0) TEST_ERROR
if(check_name(type_id, "/t1a", "/t1a") < 0) FAIL_STACK_ERROR
/* Close datatype */
H5Tclose(type_id);
if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR
PASSED();
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gmove and relative names
* Test H5Iget_name with H5Lmove and relative names
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Gmove and relative names");
TESTING("H5Iget_name with H5Lmove and relative names");
/* Create group "/g3" */
if((group_id = H5Gcreate2(file_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -418,7 +417,7 @@ test_main(hid_t file_id, hid_t fapl)
if((group3_id = H5Gopen2(file_id, "/g3/foo1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Rename group */
if(H5Gmove(group_id, "foo1", "foo2") < 0) FAIL_STACK_ERROR
if(H5Lmove(group_id, "foo1", H5L_SAME_LOC, "foo2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group_id, "/g3", "/g3") < 0) TEST_ERROR
@ -430,7 +429,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group3_id, "/g3/foo2", "/g3/foo2") < 0) TEST_ERROR
/* Rename group again */
if(H5Gmove(file_id, "g3/foo2", "g3/foo1") < 0) FAIL_STACK_ERROR
if(H5Lmove(file_id, "g3/foo2", H5L_SAME_LOC, "g3/foo1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group_id, "/g3", "/g3") < 0) TEST_ERROR
@ -442,21 +441,20 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group3_id, "/g3/foo1", "/g3/foo1") < 0) TEST_ERROR
/* Close */
H5Gclose(group_id);
H5Gclose(group2_id);
H5Gclose(group3_id);
if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR
PASSED();
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gmove and a long path
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Lmove and a long path
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Gmove and a long path");
TESTING("H5Iget_name with H5Lmove and a long path");
/* Create group "g4/A/B" */
if((group_id = H5Gcreate2(file_id, "g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -471,19 +469,19 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR
/* Move group "B" to "D"*/
if(H5Gmove(file_id, "/g4/A/B", "/g5/C/D") < 0) TEST_ERROR
if(H5Lmove(file_id, "/g4/A/B", H5L_SAME_LOC, "/g5/C/D", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group3_id, "/g5/C/D", "/g5/C/D") < 0) TEST_ERROR
/* Move group "/g5/C/D" back to "/g4/A/B" using relative name */
if(H5Gmove2(group5_id, "D", group2_id, "B") < 0) TEST_ERROR
if(H5Gmove2(group5_id, "D", group2_id, "B") < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR
/* Move group "/g4/A/B" to "/g4/F/B" using relative name */
if(H5Gmove2(group_id, "A", group_id, "F") < 0) TEST_ERROR
if(H5Gmove2(group_id, "A", group_id, "F") < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group3_id, "/g4/F/B", "/g4/F/B") < 0) TEST_ERROR
@ -492,21 +490,21 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group2_id, "/g4/F", "/g4/F") < 0) TEST_ERROR
/* Close */
H5Gclose(group_id);
H5Gclose(group2_id);
H5Gclose(group3_id);
H5Gclose(group4_id);
H5Gclose(group5_id);
if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR
PASSED();
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gmove and a long path #2
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Lmove and a long path #2
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Gmove and a long path #2");
TESTING("H5Iget_name with H5Lmove and a long path #2");
/* Create group "g6/A/B" and "g7" */
if((group_id = H5Gcreate2(file_id, "g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -518,7 +516,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group3_id, "/g6/A/B", "/g6/A/B") < 0) TEST_ERROR
/* Move group "A" to "C"*/
if(H5Gmove(file_id, "/g6/A", "/g7/C") < 0) TEST_ERROR
if(H5Lmove(file_id, "/g6/A", H5L_SAME_LOC, "/g7/C", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group2_id, "/g7/C", "/g7/C") < 0) TEST_ERROR
@ -527,14 +525,15 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group3_id, "/g7/C/B", "/g7/C/B") < 0) TEST_ERROR
/* Close */
H5Gclose(group_id);
H5Gclose(group2_id);
H5Gclose(group3_id);
H5Gclose(group4_id);
if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR
PASSED();
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Gunlink
*-------------------------------------------------------------------------
*/
@ -1397,15 +1396,15 @@ test_main(hid_t file_id, hid_t fapl)
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Fmount and H5Gmove
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Fmount and H5Lmove
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name with H5Fmount and H5Gmove");
TESTING("H5Iget_name with H5Fmount and H5Lmove");
/* Create a file and group "/g1/g2" in it */
file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
if((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -1415,7 +1414,7 @@ test_main(hid_t file_id, hid_t fapl)
if((group4_id = H5Gcreate2(file2_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Mount first file at "g3/g4" in the second file */
if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g3/g4", "/g3/g4") < 0) TEST_ERROR
@ -1433,14 +1432,14 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR
/* Rename group */
if(H5Gmove(file2_id, "/g3/g4/g1/g2", "/g3/g4/g1/g5") < 0) TEST_ERROR
if(H5Lmove(file2_id, "/g3/g4/g1/g2", H5L_SAME_LOC, "/g3/g4/g1/g5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) TEST_ERROR
if(check_name(group2_id, "/g1/g5", "/g1/g5") < 0) TEST_ERROR
/* Rename group */
if(H5Gmove(file2_id, "/g3/g4/g1", "/g3/g4/g1a") < 0) TEST_ERROR
if(H5Lmove(file2_id, "/g3/g4/g1", H5L_SAME_LOC, "/g3/g4/g1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group5_id, "/g3/g4/g1a/g5", "/g3/g4/g1a/g5") < 0) TEST_ERROR
@ -1451,7 +1450,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group_id, "/g1a", "/g1a") < 0) TEST_ERROR
/* Rename middle group back, using relative path */
if(H5Gmove(group3_id, "g4/g1a", "g4/g1") < 0) TEST_ERROR
if(H5Lmove(group3_id, "g4/g1a", H5L_SAME_LOC, "g4/g1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) TEST_ERROR
@ -1460,7 +1459,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR
/* Rename end group back, using relative path */
if(H5Gmove(group3_id, "g4/g1/g5", "g4/g1/g2") < 0) TEST_ERROR
if(H5Lmove(group3_id, "g4/g1/g5", H5L_SAME_LOC, "g4/g1/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR
@ -1469,7 +1468,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR
/* Rename mount point */
if(H5Gmove(file2_id, "/g3/g4", "/g3/g4a") < 0) TEST_ERROR
if(H5Lmove(file2_id, "/g3/g4", H5L_SAME_LOC, "/g3/g4a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g3/g4a", "/g3/g4a") < 0) TEST_ERROR
@ -1477,7 +1476,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group6_id, "/g3/g4a/g1", "/g3/g4a/g1") < 0) TEST_ERROR
/* Rename mount point back, using relative path*/
if(H5Gmove(group3_id, "g4a", "g4") < 0) TEST_ERROR
if(H5Lmove(group3_id, "g4a", H5L_SAME_LOC, "g4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g3/g4", "/g3/g4") < 0) TEST_ERROR
@ -1485,17 +1484,18 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR
/* Close */
H5Gclose(group_id);
H5Gclose(group2_id);
H5Gclose(group3_id);
H5Gclose(group4_id);
H5Gclose(group5_id);
H5Gclose(group6_id);
H5Fclose(file1_id);
H5Fclose(file2_id);
if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group6_id) < 0) FAIL_STACK_ERROR
if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR
if(H5Fclose(file2_id) < 0) FAIL_STACK_ERROR
PASSED();
/*-------------------------------------------------------------------------
* Test H5Iget_name with H5Lcreate_hard
*-------------------------------------------------------------------------
@ -1520,14 +1520,14 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR
/* Rename original group */
if(H5Gmove(file_id, "/g19/g1", "/g19/g3") < 0) FAIL_STACK_ERROR
if(H5Lmove(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group2_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR
if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR
/* Rename original group back, using relative path */
if(H5Gmove(group_id, "g3", "g1") < 0) FAIL_STACK_ERROR
if(H5Lmove(group_id, "g3", H5L_SAME_LOC, "g1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR
@ -1543,7 +1543,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group4_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR
/* Delete group */
if(H5Gunlink(file_id, "/g19/g3") < 0) TEST_ERROR
if(H5Gunlink(file_id, "/g19/g3") < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g19/g1", "") < 0) TEST_ERROR
@ -1563,7 +1563,7 @@ test_main(hid_t file_id, hid_t fapl)
if(check_name(group4_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR
/* Delete group, using relative path */
if(H5Gunlink(group_id, "g3") < 0) TEST_ERROR
if(H5Gunlink(group_id, "g3") < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g19/g1", "") < 0) TEST_ERROR
@ -1634,7 +1634,7 @@ test_main(hid_t file_id, hid_t fapl)
if((group3_id = H5Gopen2(file_id, "/g21/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Rename group */
if(H5Gmove(file_id, "/g21/g1", "/g21/g3") < 0) FAIL_STACK_ERROR
if(H5Lmove(file_id, "/g21/g1", H5L_SAME_LOC, "/g21/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group2_id, "/g21/g3", "/g21/g3") < 0) TEST_ERROR
@ -1669,14 +1669,14 @@ test_main(hid_t file_id, hid_t fapl)
if((group3_id = H5Gopen2(file_id, "/g22/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Rename soft link */
if(H5Gmove(file_id, "/g22/g2", "/g22/g3") < 0) FAIL_STACK_ERROR
if(H5Lmove(file_id, "/g22/g2", H5L_SAME_LOC, "/g22/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR
if(check_name(group3_id, "/g22/g3", "/g22/g3") < 0) TEST_ERROR
/* Rename soft link, using relative paths */
if(H5Gmove(group_id, "g3", "g2") < 0) FAIL_STACK_ERROR
if(H5Lmove(group_id, "g3", H5L_SAME_LOC, "g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR
@ -1890,12 +1890,12 @@ test_main(hid_t file_id, hid_t fapl)
PASSED();
/*-------------------------------------------------------------------------
* Test H5Iget_name and H5Gmove with repeated path components
/*-------------------------------------------------------------------------
* Test H5Iget_name and H5Lmove with repeated path components
*-------------------------------------------------------------------------
*/
TESTING("H5Iget_name and H5Gmove with repeated path components");
TESTING("H5Iget_name and H5Lmove with repeated path components");
/* Create a group "g29/g1/g2/g1/g2" in a file */
if((group_id = H5Gcreate2(file_id, "/g29", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -1905,31 +1905,31 @@ test_main(hid_t file_id, hid_t fapl)
if((group5_id = H5Gcreate2(file_id, "/g29/g1/g2/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Rename group */
if(H5Gmove(file_id, "/g29/g1/g2/g1/g2", "/g29/g1/g2/g1/g3") < 0) TEST_ERROR
if(H5Lmove(file_id, "/g29/g1/g2/g1/g2", H5L_SAME_LOC, "/g29/g1/g2/g1/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group5_id, "/g29/g1/g2/g1/g3", "/g29/g1/g2/g1/g3") < 0) TEST_ERROR
/* Rename group in middle of path, keeping within the same group */
if(H5Gmove(file_id, "/g29/g1/g2/g1", "/g29/g1/g2/g3") < 0) TEST_ERROR
if(H5Lmove(file_id, "/g29/g1/g2/g1", H5L_SAME_LOC, "/g29/g1/g2/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g29/g1/g2/g3", "/g29/g1/g2/g3") < 0) TEST_ERROR
if(check_name(group5_id, "/g29/g1/g2/g3/g3", "/g29/g1/g2/g3/g3") < 0) TEST_ERROR
/* Rename group in middle of path, moving to another group in file */
if(H5Gmove(file_id, "/g29/g1/g2/g3", "/g29/g3") < 0) TEST_ERROR
if(H5Lmove(file_id, "/g29/g1/g2/g3", H5L_SAME_LOC, "/g29/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Verify */
if(check_name(group4_id, "/g29/g3", "/g29/g3") < 0) TEST_ERROR
if(check_name(group5_id, "/g29/g3/g3", "/g29/g3/g3") < 0) TEST_ERROR
/* Close */
H5Gclose(group_id);
H5Gclose(group2_id);
H5Gclose(group3_id);
H5Gclose(group4_id);
H5Gclose(group5_id);
if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR
if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR
PASSED();

View File

@ -2982,129 +2982,129 @@ external_link_move(hid_t fapl, hbool_t new_format)
/* Move external link to different name within same group */
/* Open first file */
if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
/* Move external link within same group */
if(H5Gmove(fid, "src", "src2") < 0) TEST_ERROR
if(H5Lmove(fid, "src", H5L_SAME_LOC, "src2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Open object through external link */
if((gid = H5Gopen2(fid, "src2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close group in external file */
if(H5Gclose(gid2) < 0) TEST_ERROR
if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR
/* Close external object */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Close first file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Open second file */
if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR
/* Open group created through external link */
if((gid = H5Gopen2(fid, "dst/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close group */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Move external link to different group */
/* Open first file */
if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
/* Create another group, to move the external link into */
if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Move external link to different group */
if(H5Gmove2(fid, "src2", gid, "src3") < 0) TEST_ERROR
if(H5Gmove2(fid, "src2", gid, "src3") < 0) FAIL_STACK_ERROR
/* Close new group */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Open object through external link */
if((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
if((gid2 = H5Gcreate2(gid, "new_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((gid2 = H5Gcreate2(gid, "new_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close group in external file */
if(H5Gclose(gid2) < 0) TEST_ERROR
if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR
/* Close external object */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Close first file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Open second file */
if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR
/* Open group created through external link */
if((gid = H5Gopen2(fid, "dst/new_group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close group */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Move external link back to original group */
/* Open first file */
if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
/* Open object through external link */
if((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Move external link back to original location */
if(H5Gmove(fid, "/group2/src3", "/src") < 0) TEST_ERROR
if(H5Lmove(fid, "/group2/src3", H5L_SAME_LOC, "/src", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Check name */
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
if((gid2 = H5Gcreate2(gid, "new_group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((gid2 = H5Gcreate2(gid, "new_group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close group in external file */
if(H5Gclose(gid2) < 0) TEST_ERROR
if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR
/* Close external object */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Close first file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Open second file */
if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR
/* Open group created through external link */
if((gid = H5Gopen2(fid, "dst/new_group3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close group */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
@ -4365,62 +4365,62 @@ ud_callbacks(hid_t fapl, hbool_t new_format)
}
/* Fill the query buffer */
if(H5Gget_linkval(fid, UD_CB_LINK_NAME, (size_t)NAME_BUF_SIZE, query_buf) < 0) TEST_ERROR
if(H5Gget_linkval(fid, UD_CB_LINK_NAME, (size_t)NAME_BUF_SIZE, query_buf) < 0) FAIL_STACK_ERROR
if(HDstrcmp(query_buf, "query succeeded") != 0) TEST_ERROR
/* Move the link */
if(H5Gmove(fid, UD_CB_LINK_NAME, NEW_UD_CB_LINK_NAME) < 0) TEST_ERROR
if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Re-open group to ensure that move worked */
if((gid = H5Gopen2(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Remove UD link */
if(H5Gunlink(fid, NEW_UD_CB_LINK_NAME) < 0) TEST_ERROR
if(H5Gunlink(fid, NEW_UD_CB_LINK_NAME) < 0) FAIL_STACK_ERROR
/* Test that the callbacks don't work if the link class is not registered */
/* Create a new link. Just for fun, give it a non-default character
* encoding (to test that LAPLs work) */
if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
if(H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) TEST_ERROR
if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, lcpl, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Pclose(lcpl) < 0) TEST_ERROR
if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) FAIL_STACK_ERROR
if(H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) FAIL_STACK_ERROR
if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, lcpl, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(H5Pclose(lcpl) < 0) FAIL_STACK_ERROR
/* Check its character encoding */
if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(li.cset != H5T_CSET_UTF8) TEST_ERROR
/* Unregister the link class so the library forgets what its callbacks do */
if(H5Lunregister(UD_CB_TYPE) < 0) TEST_ERROR
if(H5Lunregister(UD_CB_TYPE) < 0) FAIL_STACK_ERROR
/* Now test that each of the callbacks fails */
H5E_BEGIN_TRY {
if(H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
if(H5Gmove(fid, UD_CB_LINK_NAME, NEW_UD_CB_LINK_NAME) >= 0) TEST_ERROR
if(H5Gunlink(fid, UD_CB_LINK_NAME) >= 0) TEST_ERROR
if(H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR
if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR
if(H5Gunlink(fid, UD_CB_LINK_NAME) >= 0) FAIL_STACK_ERROR
if((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR
if(H5Gunlink(fid, UD_CB_LINK_NAME) >= 0) TEST_ERROR
if(H5Gunlink(fid, UD_CB_LINK_NAME) >= 0) FAIL_STACK_ERROR
} H5E_END_TRY
/* The query callback should NOT fail, but should be unable to give a linklen */
if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(li.u.val_size != 0) TEST_ERROR
if(li.type != UD_CB_TYPE) TEST_ERROR
if(H5Gget_objinfo(fid, UD_CB_LINK_NAME, FALSE, &sb) < 0) TEST_ERROR
if(H5Gget_objinfo(fid, UD_CB_LINK_NAME, FALSE, &sb) < 0) FAIL_STACK_ERROR
if(sb.type != H5G_UDLINK) TEST_ERROR
/* Unregister the UD hard links */
if(H5Lunregister(UD_HARD_TYPE) < 0) TEST_ERROR
if(H5Lunregister(UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
error:
H5E_BEGIN_TRY {
H5Pclose (lcpl);
H5Gclose (gid);
@ -4809,47 +4809,51 @@ ud_link_errors(hid_t fapl, hbool_t new_format)
if(H5Lregister(UD_plist_class) < 0) TEST_ERROR
/* Now register the first class we'll be using.
* It has the same ID as the plist class, and should replace it. */
if(H5Lregister(UD_cbfail_class1) < 0) TEST_ERROR
if(H5Lregister(UD_cbfail_class1) < 0) FAIL_STACK_ERROR
/* Create a group for the UD link to point to */
if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Create a user-defined link to the group. */
strcpy(group_name, "/group");
if(H5Lcreate_ud(fid, "/ud_link", UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lcreate_ud(fid, "/ud_link", UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Open the group through the ud link */
if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* Now test that each of the callbacks will cause a failure if it returns -1 */
H5E_BEGIN_TRY {
/* The create callback will fail if we pass in no udata */
if(H5Lcreate_ud(fid, "fail", UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
/* The move and copy callbacks will fail */
if(H5Gmove(fid, "ud_link", "move_fail") >= 0) TEST_ERROR
if(H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
if(H5Lcopy(fid, "ud_link", fid, "copy_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
/* The traversal callback will fail if we remove its target */
if(H5Gunlink(fid, "group") < 0) TEST_ERROR
if((gid = H5Gopen2(gid, "ud_link", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR
if((gid = H5Gopen2(gid, "ud_link", H5P_DEFAULT)) >= 0) TEST_ERROR
/* The deletion callback will always fail */
if(H5Gunlink(fid, "ud_link") >= 0) TEST_ERROR
/* The query callback will fail */
if(H5Lget_info(fid, "ud_link", &li, H5P_DEFAULT) >=0) TEST_ERROR
} H5E_END_TRY
/* Now use a class with different callback functions */
if(H5Lregister(UD_cbfail_class2) < 0) TEST_ERROR
if(H5Lregister(UD_cbfail_class2) < 0) FAIL_STACK_ERROR
/* Moving should still fail, but copying will succeed */
H5E_BEGIN_TRY {
if(H5Gmove(fid, "ud_link", "move_fail") >= 0) TEST_ERROR
if(H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
} H5E_END_TRY
if(H5Lcopy(fid, "ud_link", fid, "copy_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lcopy(fid, "ud_link", fid, "copy_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* The query callback will succeed when we only want to get the size of the buffer... */
if(H5Lget_info(fid, "ud_link", &li, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_info(fid, "ud_link", &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(li.u.val_size != 0) TEST_ERROR
/* ...but fail when we try to write data to the buffer itself*/
H5E_BEGIN_TRY {
@ -4857,34 +4861,34 @@ ud_link_errors(hid_t fapl, hbool_t new_format)
} H5E_END_TRY
/* Register a new class */
if(H5Lregister(UD_cbfail_class3) < 0) TEST_ERROR
if(H5Lregister(UD_cbfail_class3) < 0) FAIL_STACK_ERROR
/* Now querying should succeed */
if(H5Lget_info(fid, "ud_link", &li, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_info(fid, "ud_link", &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(li.u.val_size != 8) TEST_ERROR
if(H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(HDstrcmp(query_buf, "succeed") != 0) TEST_ERROR
/* Moving and copying should both succeed */
if(H5Gmove(fid, "copy_succ", "move_succ") < 0) TEST_ERROR
if(H5Lcopy(fid, "ud_link", fid, "copy_succ2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lmove(fid, "copy_succ", H5L_SAME_LOC, "move_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(H5Lcopy(fid, "ud_link", fid, "copy_succ2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Delete link (this callback should work now) */
if(H5Gunlink(fid, "ud_link") < 0) TEST_ERROR
if(H5Gunlink(fid, "ud_link") < 0) FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(fid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
error:
H5E_BEGIN_TRY {
H5Gclose (gid);
H5Fclose (fid);
} H5E_END_TRY;
return -1;
}
} /* end ud_link_errors() */
/*-------------------------------------------------------------------------

View File

@ -442,7 +442,7 @@ error:
/*-------------------------------------------------------------------------
* Function: test_move
*
* Purpose: An object cannot be moved or renamed with H5Gmove() in such a
* Purpose: An object cannot be moved or renamed with H5Lmove() in such a
* way that the new location would be in a different file than
* the original location.
*

View File

@ -4725,8 +4725,8 @@ test_misc25c(void)
CHECK(gid, FAIL, "H5Gopen2");
/* Rename the dataset */
ret = H5Gmove(gid, MISC25C_DSETNAME, MISC25C_DSETNAME2);
CHECK(ret, FAIL, "H5Gmove");
ret = H5Lmove(gid, MISC25C_DSETNAME, H5L_SAME_LOC, MISC25C_DSETNAME2, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lmove");
/* Delete the first attribute */
ret = H5Adelete(gid, MISC25C_ATTRNAME);

View File

@ -286,7 +286,7 @@ test_symlink(hid_t file)
/*-------------------------------------------------------------------------
* Function: test_rename
*
* Purpose: Tests H5Gmove()
* Purpose: Tests H5Lmove()
*
* Return: Success: 0
*
@ -306,34 +306,35 @@ test_rename(hid_t file)
/* Create a test group and rename something */
TESTING("object renaming");
if((work = H5Gcreate2(file, "/test_rename", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((foo = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gmove(work, "foo", "bar") < 0) TEST_ERROR
if((inner = H5Gcreate2(foo, "inner", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Gclose(inner) < 0) TEST_ERROR
if(H5Gclose(foo) < 0) TEST_ERROR
if((work = H5Gcreate2(file, "/test_rename", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if((foo = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Lmove(work, "foo", H5L_SAME_LOC, "bar", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if((inner = H5Gcreate2(foo, "inner", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(inner) < 0) FAIL_STACK_ERROR
if(H5Gclose(foo) < 0) FAIL_STACK_ERROR
if((inner = H5Gopen2(work, "bar/inner", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(inner) < 0) TEST_ERROR
if(H5Gclose(inner) < 0) FAIL_STACK_ERROR
PASSED();
/* Try renaming a symlink */
TESTING("symlink renaming");
if(H5Lcreate_soft("link_value", work, "link_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Gmove(work, "link_one", "link_two") < 0) TEST_ERROR
PASSED();
if(H5Lcreate_soft("link_value", work, "link_one", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(H5Lmove(work, "link_one", H5L_SAME_LOC, "link_two", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Cleanup */
if (H5Gclose(work) < 0) goto error;
if (H5Gclose(work) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
error:
H5E_BEGIN_TRY {
H5Gclose(work);
H5Gclose(foo);
H5Gclose(inner);
} H5E_END_TRY;
return 1;
}
} /* end test_rename() */
/*-------------------------------------------------------------------------