From 0ea9a38644765aa4045b9110e86c5e50a5f24dac Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 26 Jul 2012 13:12:00 -0500 Subject: [svn-r22607] Port test from r22601 from trunk to 1.8 branch. Also remove spurious FUNC_ENTER_PACKAGE_TAG and FUNC_ENTER_STATIC_TAG macros. Tested: jam, koala, ostrich (h5committest), durandal --- src/H5private.h | 24 -------------- test/objcopy.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 24 deletions(-) diff --git a/src/H5private.h b/src/H5private.h index ef6c9d8..32c3aad 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1899,18 +1899,6 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); H5_PUSH_FUNC \ { -/* Use the following macro as replacement for the FUNC_ENTER_PACKAGE - * macro when the function needs to set up a metadata tag. */ -#define FUNC_ENTER_PACKAGE_TAG(dxpl_id, tag, err) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - hid_t tag_dxpl_id = dxpl_id; \ - \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - if(H5AC_tag(tag_dxpl_id, tag, &prev_tag) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ - H5_PUSH_FUNC \ - { - /* Use this macro for all "normal" staticly-scoped functions */ #define FUNC_ENTER_STATIC { \ FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ @@ -1923,18 +1911,6 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); H5_PUSH_FUNC \ { -/* Use the following macro as replacement for the FUNC_ENTER_STATIC - * macro when the function needs to set up a metadata tag. */ -#define FUNC_ENTER_STATIC_TAG(dxpl_id, tag, err) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - hid_t tag_dxpl_id = dxpl_id; \ - \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - if(H5AC_tag(tag_dxpl_id, tag, &prev_tag) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ - H5_PUSH_FUNC \ - { - /* Use this macro for all non-API functions, which propagate errors, but don't issue them */ #define FUNC_ENTER_NOAPI_NOERR { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ diff --git a/test/objcopy.c b/test/objcopy.c index 3c1f876..1306524 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -11460,6 +11460,104 @@ error: /*------------------------------------------------------------------------- + * Function: test_copy_iterate + * + * Purpose: Tests iterating over objects in the root group, copying + * all of them. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Neil Fortner + * Thursday, July 12, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy_iterate_cb(hid_t loc_id, const char *name, + const H5L_info_t UNUSED *link_info, void *op_data) +{ + hid_t dst_loc_id = *((hid_t *)op_data); + + if(H5Ocopy(loc_id, name, dst_loc_id, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + + return(H5_ITER_CONT); + +error: + return(H5_ITER_ERROR); +} /* end test_copy_iterate_cb */ + +static int +test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) +{ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1; /* Group ID */ + int i; + char grp_name[8]; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + TESTING("H5Ocopy(): inside H5Literate() callback"); + + /* Initialize the filenames */ + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], src_fapl, dst_filename, sizeof dst_filename); + + /* Reset file address checking info */ + addr_reset(); + + /* Create source file */ + if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR + + /* Create groups */ + for(i=0; i<9; i++) { + HDsnprintf(grp_name, sizeof(grp_name), "grp%d", i); + if((gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Gclose(gid) < 0) + TEST_ERROR + } /* end for */ + + /* Create destination file */ + if((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR + + /* Close files */ + if(H5Fclose(fid1) < 0) TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + + /* Reopen files */ + if((fid1 = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + + /* Iterate over links in the root group, copying each object */ + if((gid = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Literate(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, + &fid2) < 0) + TEST_ERROR + + /* Close */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Fclose(fid1); + H5Fclose(fid2); + } H5E_END_TRY; + return 1; +} /* end test_copy_iterate */ + + +/*------------------------------------------------------------------------- * Function: test_copy_option * * Purpose: Create a group in SRC file and copy it to DST file @@ -12297,6 +12395,7 @@ main(void) nerrors += test_copy_same_file_named_datatype(fcpl_src, src_fapl); nerrors += test_copy_old_layout(fcpl_dst, dst_fapl); nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_iterate(fcpl_src, fcpl_dst, src_fapl, dst_fapl); } /* TODO: not implemented -- cgit v0.12