diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2012-03-29 16:57:01 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2012-03-29 16:57:01 (GMT) |
commit | 646374e701e5fb7e07274712617af5868859d303 (patch) | |
tree | e166ec3e63e00caa02593230c518ec45727cf717 /tools/h5diff | |
parent | b8cb145bdfc10c7b3fcaf7a05bda4605a7d32533 (diff) | |
download | hdf5-646374e701e5fb7e07274712617af5868859d303.zip hdf5-646374e701e5fb7e07274712617af5868859d303.tar.gz hdf5-646374e701e5fb7e07274712617af5868859d303.tar.bz2 |
[svn-r22188] Purpose:
Fix for HDFFV-7644 GMQS: h5diff - incorrect behaviors when comparing HDF5 files with different type of objects (dataset, group, type) as common objects
Description:
Fixed failure for comparing same named object with different object types in comparing groups. (common object comparison)
Prior to the fix, h5diff resulted in error. After the fix, h5diff detects such case as non-comparable and display messages accordingly.
Test cases were added and tagged with jira#.
Merged from HDF5 trunk 22176.
Tested:
jam (linux32-LE), koala (linux64-LE), ostrich (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Cmake (jam)
Diffstat (limited to 'tools/h5diff')
-rw-r--r-- | tools/h5diff/CMakeLists.txt | 12 | ||||
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 163 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_20.txt | 2 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_21.txt | 2 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_22.txt | 2 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_222.txt | 3 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_223.txt | 4 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_224.txt | 4 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_505.txt | 2 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_507.txt | 2 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_509.txt | 2 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_515.txt | 7 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_517.txt | 7 | ||||
-rw-r--r-- | tools/h5diff/testfiles/non_comparables1.h5 | bin | 6568 -> 8628 bytes | |||
-rw-r--r-- | tools/h5diff/testfiles/non_comparables2.h5 | bin | 6584 -> 8644 bytes | |||
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 8 |
16 files changed, 205 insertions, 15 deletions
diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index dfd1800..da2aaf9 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -84,6 +84,8 @@ IF (BUILD_TESTING) h5diff_220.txt h5diff_221.txt h5diff_222.txt + h5diff_223.txt + h5diff_224.txt h5diff_21.txt h5diff_22.txt h5diff_23.txt @@ -577,6 +579,10 @@ IF (BUILD_TESTING) h5diff_221.out.err h5diff_222.out h5diff_222.out.err + h5diff_223.out + h5diff_223.out.err + h5diff_224.out + h5diff_224.out.err h5diff_21.out h5diff_21.out.err h5diff_22.out @@ -1164,6 +1170,12 @@ ADD_H5_TEST (h5diff_221 1 -c non_comparables1.h5 non_comparables2.h5 /g2) # All the rest comparables should display differences ADD_H5_TEST (h5diff_222 1 -c non_comparables1.h5 non_comparables2.h5) +# non-comparable test for common objects (same name) with different object types +# (HDFFV-7644) +ADD_H5_TEST (h5diff_223 0 -c non_comparables1.h5 non_comparables2.h5 /diffobjtypes) +# swap files +ADD_H5_TEST (h5diff_224 0 -c non_comparables2.h5 non_comparables1.h5 /diffobjtypes) + # ############################################################################## # # Links compare without --follow-symlinks nor --no-dangling-links # ############################################################################## diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index b57c98a..0b8b4cf 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -155,7 +155,8 @@ static void test_comps_array (const char *fname, const char *dset, const char *a static void test_comps_vlen (const char *fname, const char *dset,const char *attr, int diff, int is_file_new); static void test_comps_array_vlen (const char *fname, const char *dset, const char *attr, int diff, int is_file_new); static void test_comps_vlen_arry (const char *fname, const char *dset,const char *attr, int diff, int is_file_new); -static void test_non_comparables (const char *fname, int diff); +static void test_data_nocomparables (const char *fname, int diff); +static void test_objs_nocomparables (const char *fname1, const char *fname2); /* called by test_attributes() and test_datasets() */ static void write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs); @@ -250,8 +251,11 @@ int main(void) * comparable datasets and attributes. All the comparables should display * differences. */ - test_non_comparables(NON_COMPARBLES1,0); - test_non_comparables(NON_COMPARBLES2,5); + test_data_nocomparables(NON_COMPARBLES1,0); + test_data_nocomparables(NON_COMPARBLES2,5); + + /* common objects (same name) with different object types. HDFFV-7644 */ + test_objs_nocomparables(NON_COMPARBLES1, NON_COMPARBLES2); return 0; } @@ -4787,7 +4791,7 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch /*------------------------------------------------------------------------- -* Function: test_non_comparables +* Function: test_data_nocomparables * * Purpose: * Create test files with non-comparable dataset and attributes with @@ -4796,7 +4800,7 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch * *-------------------------------------------------------------------------*/ #define DIM_ARRY 3 -static void test_non_comparables (const char * fname, int make_diffs) +static void test_data_nocomparables (const char * fname, int make_diffs) { hid_t fid=0; hid_t gid1=0; @@ -4998,6 +5002,155 @@ out: } /*------------------------------------------------------------------------- +* Function: test_objs_nocomparables +* +* Purpose: +* Create test files with common objects (same name) but different object +* types. +* h5diff should show non-comparable output from these common objects. +*-------------------------------------------------------------------------*/ +static void test_objs_nocomparables(const char *fname1, const char *fname2) +{ + herr_t status = SUCCEED; + hid_t fid1=0; + hid_t fid2=0; + hid_t topgid1=0; + hid_t topgid2=0; + hid_t gid1=0; + hid_t did1=0; + hid_t tid1=0; + hid_t gid2=0; + hid_t did2=0; + hid_t tid2=0; + hsize_t dims[1] = {DIM_ARRY}; + int data1[DIM_ARRY] = {1,1,1}; + int data2[DIM_ARRY] = {2,2,2}; + + /*----------------------------------------------------------------------- + * Open file(s) to add objects + *------------------------------------------------------------------------*/ + /* file1 */ + fid1 = H5Fopen (fname1, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid1 < 0) + { + fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname1); + status = FAIL; + goto out; + } + + /* file2 */ + fid2 = H5Fopen (fname2, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid2 < 0) + { + fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname2); + status = FAIL; + goto out; + } + + /*----------------------------------------------------------------------- + * in file1 : add member objects + *------------------------------------------------------------------------*/ + /* parent group */ + topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (topgid1 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + status = FAIL; + goto out; + } + + /* dataset */ + status = write_dset(topgid1, 1, dims,"obj1", H5T_NATIVE_INT, data1); + if (status == FAIL) + { + fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + goto out; + } + + /* group */ + gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (gid1 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + status = FAIL; + goto out; + } + + /* committed type */ + tid1 = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) + { + fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname1); + goto out; + } + + /*----------------------------------------------------------------------- + * in file2 : add member objects + *------------------------------------------------------------------------*/ + /* parent group */ + topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (topgid2 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + status = FAIL; + goto out; + } + + /* group */ + gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (gid2 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + status = FAIL; + goto out; + } + + /* committed type */ + tid2 = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) + { + fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname2); + goto out; + } + + /* dataset */ + status = write_dset(topgid2, 1, dims,"obj3", H5T_NATIVE_INT, data2); + if (status == FAIL) + { + fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + goto out; + } + +out: + /*----------------------------------------------------------------------- + * Close IDs + *-----------------------------------------------------------------------*/ + if(fid1) + H5Fclose(fid1); + if(fid2) + H5Fclose(fid2); + if(topgid1) + H5Gclose(topgid1); + if(topgid2) + H5Gclose(topgid2); + if(did1) + H5Dclose(did1); + if(did2) + H5Dclose(did2); + if(gid1) + H5Gclose(gid1); + if(gid2) + H5Gclose(gid2); + if(tid1) + H5Tclose(tid1); + if(tid2) + H5Tclose(tid2); + +} + +/*------------------------------------------------------------------------- * Function: write_attr_in * * Purpose: write attributes in LOC_ID (dataset, group, named datatype) diff --git a/tools/h5diff/testfiles/h5diff_20.txt b/tools/h5diff/testfiles/h5diff_20.txt index 3edb543..09c20cb 100644 --- a/tools/h5diff/testfiles/h5diff_20.txt +++ b/tools/h5diff/testfiles/h5diff_20.txt @@ -1,4 +1,4 @@ -</dset> is of type H5G_DATASET and </g1> is of type H5G_GROUP +Not comparable: </dset> is of type H5G_DATASET and </g1> is of type H5G_GROUP -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_21.txt b/tools/h5diff/testfiles/h5diff_21.txt index 1479457..1c625fe 100644 --- a/tools/h5diff/testfiles/h5diff_21.txt +++ b/tools/h5diff/testfiles/h5diff_21.txt @@ -1,4 +1,4 @@ -</dset> is of type H5G_DATASET and </l1> is of type H5G_LINK +Not comparable: </dset> is of type H5G_DATASET and </l1> is of type H5G_LINK -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_22.txt b/tools/h5diff/testfiles/h5diff_22.txt index 3ccb06b..2ef22d0 100644 --- a/tools/h5diff/testfiles/h5diff_22.txt +++ b/tools/h5diff/testfiles/h5diff_22.txt @@ -1,4 +1,4 @@ -</dset> is of type H5G_DATASET and </t1> is of type H5G_TYPE +Not comparable: </dset> is of type H5G_DATASET and </t1> is of type H5G_TYPE -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_222.txt b/tools/h5diff/testfiles/h5diff_222.txt index bdecb8a..53c9464 100644 --- a/tools/h5diff/testfiles/h5diff_222.txt +++ b/tools/h5diff/testfiles/h5diff_222.txt @@ -1,3 +1,6 @@ +Not comparable: </diffobjtypes/obj1> is of type H5G_DATASET and </diffobjtypes/obj1> is of type H5G_GROUP +Not comparable: </diffobjtypes/obj2> is of type H5G_GROUP and </diffobjtypes/obj2> is of type H5G_TYPE +Not comparable: </diffobjtypes/obj3> is of type H5G_TYPE and </diffobjtypes/obj3> is of type H5G_DATASET Not comparable: </g1/dset1> is of class H5T_INTEGER and </g1/dset1> is of class H5T_STRING attribute: <attr of </g1/dset1>> and <attr of </g1/dset1>> 3 differences found diff --git a/tools/h5diff/testfiles/h5diff_223.txt b/tools/h5diff/testfiles/h5diff_223.txt new file mode 100644 index 0000000..c8e0f65 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_223.txt @@ -0,0 +1,4 @@ +Not comparable: </diffobjtypes/obj1> is of type H5G_DATASET and </diffobjtypes/obj1> is of type H5G_GROUP +Not comparable: </diffobjtypes/obj2> is of type H5G_GROUP and </diffobjtypes/obj2> is of type H5G_TYPE +Not comparable: </diffobjtypes/obj3> is of type H5G_TYPE and </diffobjtypes/obj3> is of type H5G_DATASET +EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_224.txt b/tools/h5diff/testfiles/h5diff_224.txt new file mode 100644 index 0000000..a4ebedb --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_224.txt @@ -0,0 +1,4 @@ +Not comparable: </diffobjtypes/obj1> is of type H5G_GROUP and </diffobjtypes/obj1> is of type H5G_DATASET +Not comparable: </diffobjtypes/obj2> is of type H5G_TYPE and </diffobjtypes/obj2> is of type H5G_GROUP +Not comparable: </diffobjtypes/obj3> is of type H5G_DATASET and </diffobjtypes/obj3> is of type H5G_TYPE +EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_505.txt b/tools/h5diff/testfiles/h5diff_505.txt index a220730..607b99b 100644 --- a/tools/h5diff/testfiles/h5diff_505.txt +++ b/tools/h5diff/testfiles/h5diff_505.txt @@ -1,4 +1,4 @@ -</grp1> is of type H5G_GROUP and </slink_grp1> is of type H5G_LINK +Not comparable: </grp1> is of type H5G_GROUP and </slink_grp1> is of type H5G_LINK -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_507.txt b/tools/h5diff/testfiles/h5diff_507.txt index 6176f3f..06b7fe6 100644 --- a/tools/h5diff/testfiles/h5diff_507.txt +++ b/tools/h5diff/testfiles/h5diff_507.txt @@ -1,4 +1,4 @@ -</grp1> is of type H5G_GROUP and </elink_grp1> is of type H5G_UDLINK +Not comparable: </grp1> is of type H5G_GROUP and </elink_grp1> is of type H5G_UDLINK -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_509.txt b/tools/h5diff/testfiles/h5diff_509.txt index a51ab35..2e3e87a 100644 --- a/tools/h5diff/testfiles/h5diff_509.txt +++ b/tools/h5diff/testfiles/h5diff_509.txt @@ -1,4 +1,4 @@ -</slink_grp1> is of type H5G_LINK and </elink_grp1> is of type H5G_UDLINK +Not comparable: </slink_grp1> is of type H5G_LINK and </elink_grp1> is of type H5G_UDLINK -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_515.txt b/tools/h5diff/testfiles/h5diff_515.txt index 077d463..263441d 100644 --- a/tools/h5diff/testfiles/h5diff_515.txt +++ b/tools/h5diff/testfiles/h5diff_515.txt @@ -17,8 +17,11 @@ dataset: </dset1> and </dset1> 0 differences found group : </g1> and </g1> 0 differences found -group : </g1/g2> and </g1/g2> -0 differences found +Not comparable: </g1/g2> is of type H5G_GROUP and </g1/g2> is of type H5G_UDLINK link : </soft_dset1> and </soft_dset1> 0 differences found +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_517.txt b/tools/h5diff/testfiles/h5diff_517.txt index 1b6e24f..91c69fb 100644 --- a/tools/h5diff/testfiles/h5diff_517.txt +++ b/tools/h5diff/testfiles/h5diff_517.txt @@ -10,6 +10,9 @@ group1 group2 group : </g1> and </g1> 0 differences found -group : </g1/g2> and </g1/g2> -0 differences found +Not comparable: </g1/g2> is of type H5G_GROUP and </g1/g2> is of type H5G_UDLINK +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/non_comparables1.h5 b/tools/h5diff/testfiles/non_comparables1.h5 Binary files differindex 71b65c8..7dbb45d 100644 --- a/tools/h5diff/testfiles/non_comparables1.h5 +++ b/tools/h5diff/testfiles/non_comparables1.h5 diff --git a/tools/h5diff/testfiles/non_comparables2.h5 b/tools/h5diff/testfiles/non_comparables2.h5 Binary files differindex 188ceb9..a5e7014 100644 --- a/tools/h5diff/testfiles/non_comparables2.h5 +++ b/tools/h5diff/testfiles/non_comparables2.h5 diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index 3eb3306..dfea6f7 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -156,6 +156,8 @@ $SRC_H5DIFF_TESTFILES/h5diff_208.txt $SRC_H5DIFF_TESTFILES/h5diff_220.txt $SRC_H5DIFF_TESTFILES/h5diff_221.txt $SRC_H5DIFF_TESTFILES/h5diff_222.txt +$SRC_H5DIFF_TESTFILES/h5diff_223.txt +$SRC_H5DIFF_TESTFILES/h5diff_224.txt $SRC_H5DIFF_TESTFILES/h5diff_21.txt $SRC_H5DIFF_TESTFILES/h5diff_22.txt $SRC_H5DIFF_TESTFILES/h5diff_23.txt @@ -827,6 +829,12 @@ if test -n "$pmode" -a "$mydomainname" = hdfgroup.uiuc.edu; then else TOOLTEST h5diff_222.txt -c non_comparables1.h5 non_comparables2.h5 fi + +# non-comparable test for common objects (same name) with different object types +# (HDFFV-7644) +TOOLTEST h5diff_223.txt -c non_comparables1.h5 non_comparables2.h5 /diffobjtypes +# swap files +TOOLTEST h5diff_224.txt -c non_comparables2.h5 non_comparables1.h5 /diffobjtypes # ############################################################################## # # Links compare without --follow-symlinks nor --no-dangling-links |