summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2008-11-03 20:54:19 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2008-11-03 20:54:19 (GMT)
commit780999deee27ee44f5311be57c4153c5a231f183 (patch)
treeaa93fafca08efda3d9d2c2aaa468aa4057913972 /test
parentd2980de247abb12e0e75a0ce71dd2a95048d1a19 (diff)
downloadhdf5-780999deee27ee44f5311be57c4153c5a231f183.zip
hdf5-780999deee27ee44f5311be57c4153c5a231f183.tar.gz
hdf5-780999deee27ee44f5311be57c4153c5a231f183.tar.bz2
[svn-r16021] Purpose: Fix behaviour of H5Ovisit
Description: H5Ovisit and H5Ovisit by name will now check for a positive return value from the first callback. Test added for this case. Tested: kagiso
Diffstat (limited to 'test')
-rw-r--r--test/links.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/links.c b/test/links.c
index d57615a..cfbfde6 100644
--- a/test/links.c
+++ b/test/links.c
@@ -7755,6 +7755,90 @@ error:
/*-------------------------------------------------------------------------
+ * Function: visit_obj_stop_cb
+ *
+ * Purpose: Callback routine for visiting objects in a file
+ *
+ * Return: 1 (H5_ITER_STOP)
+ *
+ * Programmer: Neil Fortner
+ * Sunday, November 2, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+visit_obj_stop_cb(hid_t UNUSED group_id, const char UNUSED *name, const H5O_info_t UNUSED *oinfo,
+ void *_op_data)
+{
+ unsigned *op_data = (unsigned *)_op_data;
+
+ /* Increment the number of visited objects */
+ (*op_data)++;
+
+ return(H5_ITER_STOP);
+} /* end visit_obj_stop_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: obj_visit_stop
+ *
+ * Purpose: Test that the object visiting routine stops iteration
+ * properly on the starting object.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Sunday, November 2, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+obj_visit_stop(hid_t fapl, hbool_t new_format)
+{
+ unsigned nvisited; /* User-data for visiting */
+ hid_t fid = -1;
+ herr_t ret; /* Return value */
+
+ if(new_format)
+ TESTING("stopping object iteration (w/new group format)")
+ else
+ TESTING("stopping object iteration")
+
+ /* Construct "interesting" file to visit */
+ if((fid = build_visit_file(fapl)) < 0) TEST_ERROR
+
+ /* Start iteration. The callback should only be called once because it
+ * returns H5_ITER_STOP
+ */
+ nvisited = 0;
+ if((ret = H5Ovisit(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, &nvisited)) < 0)
+ FAIL_STACK_ERROR
+ if(ret != H5_ITER_STOP) TEST_ERROR
+ if(nvisited != 1) TEST_ERROR
+
+ /* Same test with H5Ovisit_by_name */
+ nvisited = 0;
+ if((ret = H5Ovisit_by_name(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb,
+ &nvisited, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(ret != H5_ITER_STOP) TEST_ERROR
+ if(nvisited != 1) TEST_ERROR
+
+ /* Close file created */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end obj_visit_stop() */
+
+
+/*-------------------------------------------------------------------------
* Function: corder_create_empty
*
* Purpose: Create an empty group with creation order indices
@@ -12286,6 +12370,7 @@ main(void)
nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit_stop(my_fapl, new_format) < 0 ? 1 : 0;
/* Keep this test last, it's testing files that are used above */
/* do not do this for files used by external link tests */