From 3dc1e6dd38d665409560f79af6863019ebaa91d8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 22 Apr 2014 17:25:51 -0500 Subject: [svn-r25081] Bug HDFFV-8625, HDFFV-8639, HDFFV-8745: h5diff issues "unable to read attribute" error message when comparing two files Description: h5diff did not handle attributes of variable length strings correctly. It created the wrong memory type if one but not both compared attributes are of the variable strings type. It ended in H5Aread() failure. Solution: We decided to treat the case when one type is variable length string and the other is not as incomparable. That bypassed the above error. We still need to figure out the proper way, if possible, to compare variable string with non-variable string types. Tested: h5committested plus tested in Swallow (OS X 10.8). --- MANIFEST | 6 ++++ tools/h5diff/h5diff_common.c | 7 +++++ tools/h5diff/ph5diff_main.c | 5 +--- tools/h5diff/testfiles/h5diff_tmp1.txt | 5 ++++ tools/h5diff/testfiles/h5diff_tmp2.txt | 13 +++++++++ .../h5diff/testfiles/tmpSingleSiteBethe.output.h5 | Bin 0 -> 124440 bytes .../testfiles/tmpSingleSiteBethe.reference.h5 | Bin 0 -> 119464 bytes tools/h5diff/testfiles/tmptest.he5 | Bin 0 -> 4740424 bytes tools/h5diff/testfiles/tmptest2.he5 | Bin 0 -> 4734280 bytes tools/h5diff/testh5diff.sh.in | 10 +++++++ tools/lib/h5diff_attr.c | 31 ++++++++++++++++----- 11 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 tools/h5diff/testfiles/h5diff_tmp1.txt create mode 100644 tools/h5diff/testfiles/h5diff_tmp2.txt create mode 100644 tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 create mode 100644 tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 create mode 100644 tools/h5diff/testfiles/tmptest.he5 create mode 100644 tools/h5diff/testfiles/tmptest2.he5 diff --git a/MANIFEST b/MANIFEST index 8a39836..b5a5b1a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2136,6 +2136,12 @@ ./tools/h5diff/testfiles/compounds_array_vlen2.h5 ./tools/h5diff/testfiles/non_comparables1.h5 ./tools/h5diff/testfiles/non_comparables2.h5 +./tools/h5diff/testfiles/tmptest2.he5 +./tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 +./tools/h5diff/testfiles/h5diff_tmp1.txt +./tools/h5diff/testfiles/tmptest.he5 +./tools/h5diff/testfiles/h5diff_tmp2.txt +./tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 #test files for h5repack ./tools/h5repack/testfiles/h5repack_attr.h5 diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index 59cab0d..a371cc0 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -103,6 +103,13 @@ void parse_command_line(int argc, /* NaNs are handled by default */ options->do_nans = 1; + /* not Listing objects that are not comparable */ + options->m_list_not_cmp = 0; + + /* initially no not-comparable. */ + /**this is bad in mixing option with results**/ + options->not_cmp=0; + /* init for exclude-path option */ exclude_head = NULL; diff --git a/tools/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c index a26b6e9..62e1e73 100644 --- a/tools/h5diff/ph5diff_main.c +++ b/tools/h5diff/ph5diff_main.c @@ -321,9 +321,6 @@ void h5diff_exit(int status) status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure status */ } - /* Always exit(0), since MPI implementations do weird stuff when they - * receive a non-zero exit value. - QAK - */ - exit(0); + exit(status); } diff --git a/tools/h5diff/testfiles/h5diff_tmp1.txt b/tools/h5diff/testfiles/h5diff_tmp1.txt new file mode 100644 index 0000000..40e3fb6 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_tmp1.txt @@ -0,0 +1,5 @@ +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects. +EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_tmp2.txt b/tools/h5diff/testfiles/h5diff_tmp2.txt new file mode 100644 index 0000000..a2d6da6 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_tmp2.txt @@ -0,0 +1,13 @@ +dataset: and +1599 differences found +dataset: and +8 differences found +dataset: and +1845 differences found +dataset: and +10 differences found +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects. +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 b/tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 new file mode 100644 index 0000000..bbcfb63 Binary files /dev/null and b/tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 differ diff --git a/tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 b/tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 new file mode 100644 index 0000000..6b19ed7 Binary files /dev/null and b/tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 differ diff --git a/tools/h5diff/testfiles/tmptest.he5 b/tools/h5diff/testfiles/tmptest.he5 new file mode 100644 index 0000000..edcfcd2 Binary files /dev/null and b/tools/h5diff/testfiles/tmptest.he5 differ diff --git a/tools/h5diff/testfiles/tmptest2.he5 b/tools/h5diff/testfiles/tmptest2.he5 new file mode 100644 index 0000000..a6ab02b Binary files /dev/null and b/tools/h5diff/testfiles/tmptest2.he5 differ diff --git a/tools/h5diff/testh5diff.sh.in b/tools/h5diff/testh5diff.sh.in index 549da49..ee8a09b 100644 --- a/tools/h5diff/testh5diff.sh.in +++ b/tools/h5diff/testh5diff.sh.in @@ -302,6 +302,12 @@ $SRC_H5DIFF_TESTFILES/h5diff_709.txt $SRC_H5DIFF_TESTFILES/h5diff_710.txt $SRC_H5DIFF_TESTFILES/h5diff_80.txt $SRC_H5DIFF_TESTFILES/h5diff_90.txt +$SRC_H5DIFF_TESTFILES/h5diff_tmp1.txt +$SRC_H5DIFF_TESTFILES/h5diff_tmp2.txt +$SRC_H5DIFF_TESTFILES/tmptest.he5 +$SRC_H5DIFF_TESTFILES/tmptest2.he5 +$SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.reference.h5 +$SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.output.h5 " # @@ -757,6 +763,10 @@ TOOLTEST h5diff_631.txt -v --use-system-epsilon h5diff_basic1.h5 h5diff_basic1.h # 7. attributes # ############################################################################## TOOLTEST h5diff_70.txt -v h5diff_attr1.h5 h5diff_attr2.h5 +# temporary test to verify HDF5-8625 +TOOLTEST h5diff_tmp1.txt tmptest2.he5 tmptest.he5 +# temporary test to verify HDF5-8639 +TOOLTEST h5diff_tmp2.txt tmpSingleSiteBethe.output.h5 tmpSingleSiteBethe.reference.h5 # ################################################## # attrs with verbose option level diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 3078369..6474082 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -326,6 +326,8 @@ hsize_t diff_attr(hid_t loc1_id, hid_t space2_id=-1; /* space ID */ hid_t ftype1_id=-1; /* file data type ID */ hid_t ftype2_id=-1; /* file data type ID */ + int vstrtype1=0; /* ftype1 is a variable string */ + int vstrtype2=0; /* ftype2 is a variable string */ hid_t mtype1_id=-1; /* memory data type ID */ hid_t mtype2_id=-1; /* memory data type ID */ size_t msize1; /* memory size of memory type */ @@ -378,8 +380,19 @@ hsize_t diff_attr(hid_t loc1_id, /* get the datatypes */ if((ftype1_id = H5Aget_type(attr1_id)) < 0) goto error; + vstrtype1 = H5Tis_variable_str(ftype1_id); if((ftype2_id = H5Aget_type(attr2_id)) < 0) goto error; + vstrtype2 = H5Tis_variable_str(ftype2_id); + /* no compare if either one but not both are variable string type */ + if (vstrtype1 != vstrtype2){ + if ((options->m_verbose||options->m_list_not_cmp)) + parallel_print("Not comparable: one of attribute <%s/%s> or <%s/%s> is of variable length type\n", + path1, name1, path2, name2); + options->not_cmp = 1; + return 0; + } + if((mtype1_id = h5tools_get_native_type(ftype1_id))<0) goto error; if((mtype2_id = h5tools_get_native_type(ftype2_id))<0) @@ -451,16 +464,20 @@ hsize_t diff_attr(hid_t loc1_id, buf1 = (void *)HDmalloc((size_t)(nelmts1 * msize1)); buf2 = (void *)HDmalloc((size_t)(nelmts1 * msize2)); - if(buf1 == NULL || buf2 == NULL) { + if(buf1 == NULL || buf2 == NULL){ parallel_print( "cannot read into memory\n" ); goto error; } - if(H5Aread(attr1_id,mtype1_id,buf1) < 0) - goto error; - buf1hasdata = 1; - if(H5Aread(attr2_id,mtype2_id,buf2) < 0) - goto error; - buf2hasdata = 1; + if(H5Aread(attr1_id,mtype1_id,buf1) < 0){ + parallel_print("Failed reading attribute1 %s/%s\n", path1, name1); + goto error; + }else + buf1hasdata = 1; + if(H5Aread(attr2_id,mtype2_id,buf2) < 0){ + parallel_print("Failed reading attribute2 %s/%s\n", path2, name2); + goto error; + }else + buf2hasdata = 1; /* format output string */ HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1); -- cgit v0.12