summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2012-07-26 18:12:00 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2012-07-26 18:12:00 (GMT)
commit0ea9a38644765aa4045b9110e86c5e50a5f24dac (patch)
tree023fa96d49ee39fe3b80d99a6a3e8c4cf2866fc4 /test
parent85d0f3befd5e2345ae5b7c07af5d944bcd91f656 (diff)
downloadhdf5-0ea9a38644765aa4045b9110e86c5e50a5f24dac.zip
hdf5-0ea9a38644765aa4045b9110e86c5e50a5f24dac.tar.gz
hdf5-0ea9a38644765aa4045b9110e86c5e50a5f24dac.tar.bz2
[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
Diffstat (limited to 'test')
-rw-r--r--test/objcopy.c99
1 files changed, 99 insertions, 0 deletions
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