From b54b3fcf290d532de381e135254dfc343d338d24 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 12 Jul 2012 10:38:44 -0500 Subject: [svn-r22563] HDFFV-8095: index order of links wrong Create setters for indexing options in h5trav.c to be set before the obj table is created. Revert h5trav_print to remove now duplicated parameters. Added test and testfiles. Tested: local linux with cmake --- MANIFEST | 4 ++++ tools/h5dump/CMakeLists.txt | 8 ++++++++ tools/h5dump/h5dump.c | 3 +++ tools/h5dump/h5dump_ddl.c | 2 +- tools/h5dump/testh5dump.sh.in | 8 ++++++++ tools/lib/h5trav.c | 22 ++++++++++++++++++---- tools/lib/h5trav.h | 3 ++- 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/MANIFEST b/MANIFEST index 50b9a74..c1c4eff 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1475,6 +1475,8 @@ ./tools/testfiles/tcontents.ddl ./tools/testfiles/tordercontents1.ddl ./tools/testfiles/tordercontents2.ddl +./tools/testfiles/torderlinks1.ddl +./tools/testfiles/torderlinks2.ddl ./tools/testfiles/tfilters.h5 ./tools/testfiles/tchunked.ddl ./tools/testfiles/tcompact.ddl @@ -1539,6 +1541,8 @@ ./tools/h5dump/errfiles/textlinksrc.err ./tools/h5dump/errfiles/tgroup-2.err ./tools/h5dump/errfiles/tnofilename-with-packed-bits.err +./tools/h5dump/errfiles/orderlinks1.err +./tools/h5dump/errfiles/orderlinks2.err ./tools/h5dump/errfiles/tpbitsCharLengthExceeded.err ./tools/h5dump/errfiles/tpbitsCharOffsetExceeded.err ./tools/h5dump/errfiles/tpbitsIncomplete.err diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 28d1ca2..b8a2d4c 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -152,6 +152,8 @@ IF (BUILD_TESTING) ${HDF5_TOOLS_SRC_DIR}/testfiles/torderattr4.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tordercontents1.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tordercontents2.ddl + ${HDF5_TOOLS_SRC_DIR}/testfiles/torderlinks1.ddl + ${HDF5_TOOLS_SRC_DIR}/testfiles/torderlinks2.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tperror.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/treference.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tsaf.ddl @@ -289,6 +291,8 @@ IF (BUILD_TESTING) ${PROJECT_SOURCE_DIR}/errfiles/textlink.err ${PROJECT_SOURCE_DIR}/errfiles/textlinkfar.err ${PROJECT_SOURCE_DIR}/errfiles/textlinksrc.err + ${PROJECT_SOURCE_DIR}/errfiles/torderlinks1.err + ${PROJECT_SOURCE_DIR}/errfiles/torderlinks2.err ${PROJECT_SOURCE_DIR}/errfiles/tgroup-2.err ${PROJECT_SOURCE_DIR}/errfiles/tperror.err ${PROJECT_SOURCE_DIR}/errfiles/tslink-D.err @@ -1436,6 +1440,10 @@ IF (BUILD_TESTING) ADD_H5_TEST (torderattr3 0 --enable-error-stack -H --sort_by=creation_order --sort_order=ascending torderattr.h5) ADD_H5_TEST (torderattr4 0 --enable-error-stack -H --sort_by=creation_order --sort_order=descending torderattr.h5) + # tests for link references and order + ADD_H5ERR_MASK_TEST (torderlinks1 0 --enable-error-stack --sort_by=name --sort_order=ascending tfcontents1.h5) + ADD_H5ERR_MASK_TEST (torderlinks2 0 --enable-error-stack --sort_by=name --sort_order=descending tfcontents1.h5) + # tests for floating point user defined printf format ADD_H5_TEST (tfpformat 0 --enable-error-stack -m %.7f tfpformat.h5) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 1a70d11..cd52743 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1464,6 +1464,9 @@ main(int argc, const char *argv[]) h5tools_setstatus(EXIT_FAILURE); goto done; } + /* Initialize indexing options */ + h5trav_set_index(sort_by, sort_order); + while(opt_ind < argc) { fname = HDstrdup(argv[opt_ind++]); diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c index c0a9884..22d2a2b 100644 --- a/tools/h5dump/h5dump_ddl.c +++ b/tools/h5dump/h5dump_ddl.c @@ -1294,7 +1294,7 @@ dump_fcontents(hid_t fid) } /* print objects in the files */ - h5trav_print(fid, sort_by, sort_order); + h5trav_print(fid); HDfprintf(rawoutstream, " %s\n",END); } diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 752bff9..612b9ab 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -277,6 +277,8 @@ $SRC_H5DUMP_TESTFILES/torderattr3.ddl $SRC_H5DUMP_TESTFILES/torderattr4.ddl $SRC_H5DUMP_TESTFILES/tordercontents1.ddl $SRC_H5DUMP_TESTFILES/tordercontents2.ddl +$SRC_H5DUMP_TESTFILES/torderlinks1.ddl +$SRC_H5DUMP_TESTFILES/torderlinks2.ddl $SRC_H5DUMP_TESTFILES/tperror.ddl $SRC_H5DUMP_TESTFILES/treference.ddl $SRC_H5DUMP_TESTFILES/tsaf.ddl @@ -326,6 +328,8 @@ ${SRC_H5DUMP_ERRORFILES}/textlink.err ${SRC_H5DUMP_ERRORFILES}/textlinkfar.err ${SRC_H5DUMP_ERRORFILES}/textlinksrc.err ${SRC_H5DUMP_ERRORFILES}/tgroup-2.err +${SRC_H5DUMP_ERRORFILES}/torderlinks1.err +${SRC_H5DUMP_ERRORFILES}/torderlinks2.err ${SRC_H5DUMP_ERRORFILES}/tperror.err ${SRC_H5DUMP_ERRORFILES}/tqmarkfile.err ${SRC_H5DUMP_ERRORFILES}/tslink-D.err @@ -989,6 +993,10 @@ TOOLTEST torderattr2.ddl --enable-error-stack -H --sort_by=name --sort_order=des TOOLTEST torderattr3.ddl --enable-error-stack -H --sort_by=creation_order --sort_order=ascending torderattr.h5 TOOLTEST torderattr4.ddl --enable-error-stack -H --sort_by=creation_order --sort_order=descending torderattr.h5 +# tests for link references and order +TOOLTEST4 torderlinks1.ddl --enable-error-stack --sort_by=name --sort_order=ascending tfcontents1.h5 +TOOLTEST4 torderlinks2.ddl --enable-error-stack --sort_by=name --sort_order=descending tfcontents1.h5 + # tests for floating point user defined printf format TOOLTEST tfpformat.ddl --enable-error-stack -m %.7f tfpformat.h5 diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 833b8c4..170e612 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -67,6 +67,23 @@ static void trav_table_addlink(trav_table_t *table, static H5_index_t trav_index_by = H5_INDEX_NAME; static H5_iter_order_t trav_index_order = H5_ITER_INC; + +/*------------------------------------------------------------------------- + * Function: h5trav_set_index + * + * Purpose: Set indexing properties for the objects & links in the file + * + * Return: none + * + *------------------------------------------------------------------------- + */ +void +h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order) +{ + trav_index_by = print_index_by; + trav_index_order = print_index_order; +} + /*------------------------------------------------------------------------- * "h5trav info" public functions. used in h5diff *------------------------------------------------------------------------- @@ -955,14 +972,11 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) */ int -h5trav_print(hid_t fid, H5_index_t print_index_by, H5_iter_order_t print_index_order) +h5trav_print(hid_t fid) { trav_print_udata_t print_udata; /* User data for traversal */ trav_visitor_t print_visitor; /* Visitor structure for printing objects */ - trav_index_by = print_index_by; - trav_index_order = print_index_order; - /* Init user data for printing */ print_udata.fid = fid; diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 7311897..ce44bc9 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -131,6 +131,7 @@ extern "C" { * "h5trav general" public functions *------------------------------------------------------------------------- */ +H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order); H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata); @@ -158,7 +159,7 @@ H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt); * "h5trav print" public functions *------------------------------------------------------------------------- */ -H5TOOLS_DLL int h5trav_print(hid_t fid, H5_index_t print_index_by, H5_iter_order_t print_index_order); +H5TOOLS_DLL int h5trav_print(hid_t fid); #ifdef __cplusplus } -- cgit v0.12