diff options
Diffstat (limited to 'tools')
59 files changed, 705 insertions, 572 deletions
diff --git a/tools/COPYING b/tools/COPYING index 6903daf..6903daf 100755..100644 --- a/tools/COPYING +++ b/tools/COPYING 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_101w.txt b/tools/h5diff/testfiles/h5diff_101w.txt index d1f49da..d1f49da 100755..100644 --- a/tools/h5diff/testfiles/h5diff_101w.txt +++ b/tools/h5diff/testfiles/h5diff_101w.txt diff --git a/tools/h5diff/testfiles/h5diff_102w.txt b/tools/h5diff/testfiles/h5diff_102w.txt index dda3581..dda3581 100755..100644 --- a/tools/h5diff/testfiles/h5diff_102w.txt +++ b/tools/h5diff/testfiles/h5diff_102w.txt 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_300.txt b/tools/h5diff/testfiles/h5diff_300.txt index e51643f..e51643f 100755..100644 --- a/tools/h5diff/testfiles/h5diff_300.txt +++ b/tools/h5diff/testfiles/h5diff_300.txt 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/h5diff_enum_invalid_values.h5 b/tools/h5diff/testfiles/h5diff_enum_invalid_values.h5 Binary files differindex dd02db9..dd02db9 100755..100644 --- a/tools/h5diff/testfiles/h5diff_enum_invalid_values.h5 +++ b/tools/h5diff/testfiles/h5diff_enum_invalid_values.h5 diff --git a/tools/h5diff/testfiles/h5diff_links.h5 b/tools/h5diff/testfiles/h5diff_links.h5 Binary files differindex 8af66a6..8af66a6 100755..100644 --- a/tools/h5diff/testfiles/h5diff_links.h5 +++ b/tools/h5diff/testfiles/h5diff_links.h5 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 27fb253..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 @@ -212,6 +214,9 @@ $SRC_H5DIFF_TESTFILES/h5diff_481.txt $SRC_H5DIFF_TESTFILES/h5diff_482.txt $SRC_H5DIFF_TESTFILES/h5diff_483.txt $SRC_H5DIFF_TESTFILES/h5diff_484.txt +$SRC_H5DIFF_TESTFILES/h5diff_485.txt +$SRC_H5DIFF_TESTFILES/h5diff_486.txt +$SRC_H5DIFF_TESTFILES/h5diff_487.txt $SRC_H5DIFF_TESTFILES/h5diff_50.txt $SRC_H5DIFF_TESTFILES/h5diff_51.txt $SRC_H5DIFF_TESTFILES/h5diff_52.txt @@ -824,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 diff --git a/tools/h5dump/testh5dumpxml.sh.in b/tools/h5dump/testh5dumpxml.sh.in index 1bbf232..1bbf232 100755..100644 --- a/tools/h5dump/testh5dumpxml.sh.in +++ b/tools/h5dump/testh5dumpxml.sh.in diff --git a/tools/h5import/Makefile.in b/tools/h5import/Makefile.in index b2a90ff..b2a90ff 100755..100644 --- a/tools/h5import/Makefile.in +++ b/tools/h5import/Makefile.in diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index 56dc5ab..56dc5ab 100755..100644 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c diff --git a/tools/h5import/h5import.h b/tools/h5import/h5import.h index dbc6844..dbc6844 100755..100644 --- a/tools/h5import/h5import.h +++ b/tools/h5import/h5import.h diff --git a/tools/h5import/h5importtest.c b/tools/h5import/h5importtest.c index 434cba7..434cba7 100755..100644 --- a/tools/h5import/h5importtest.c +++ b/tools/h5import/h5importtest.c diff --git a/tools/h5import/testfiles/binfp64.conf b/tools/h5import/testfiles/binfp64.conf index 6b4c361..6b4c361 100755..100644 --- a/tools/h5import/testfiles/binfp64.conf +++ b/tools/h5import/testfiles/binfp64.conf diff --git a/tools/h5import/testfiles/binin16.conf b/tools/h5import/testfiles/binin16.conf index 06869cb..06869cb 100755..100644 --- a/tools/h5import/testfiles/binin16.conf +++ b/tools/h5import/testfiles/binin16.conf diff --git a/tools/h5import/testfiles/binin32.conf b/tools/h5import/testfiles/binin32.conf index 11996ef..11996ef 100755..100644 --- a/tools/h5import/testfiles/binin32.conf +++ b/tools/h5import/testfiles/binin32.conf diff --git a/tools/h5import/testfiles/binin8.conf b/tools/h5import/testfiles/binin8.conf index 1edd80a..1edd80a 100755..100644 --- a/tools/h5import/testfiles/binin8.conf +++ b/tools/h5import/testfiles/binin8.conf diff --git a/tools/h5import/testfiles/binuin16.conf b/tools/h5import/testfiles/binuin16.conf index a4603df..a4603df 100755..100644 --- a/tools/h5import/testfiles/binuin16.conf +++ b/tools/h5import/testfiles/binuin16.conf diff --git a/tools/h5import/testfiles/binuin32.conf b/tools/h5import/testfiles/binuin32.conf index a649e97..a649e97 100755..100644 --- a/tools/h5import/testfiles/binuin32.conf +++ b/tools/h5import/testfiles/binuin32.conf diff --git a/tools/h5import/testfiles/txtfp32.conf b/tools/h5import/testfiles/txtfp32.conf index 9696a7f..9696a7f 100755..100644 --- a/tools/h5import/testfiles/txtfp32.conf +++ b/tools/h5import/testfiles/txtfp32.conf diff --git a/tools/h5import/testfiles/txtfp32.txt b/tools/h5import/testfiles/txtfp32.txt index 142c94f..142c94f 100755..100644 --- a/tools/h5import/testfiles/txtfp32.txt +++ b/tools/h5import/testfiles/txtfp32.txt diff --git a/tools/h5import/testfiles/txtfp64.conf b/tools/h5import/testfiles/txtfp64.conf index fbab6a6..fbab6a6 100755..100644 --- a/tools/h5import/testfiles/txtfp64.conf +++ b/tools/h5import/testfiles/txtfp64.conf diff --git a/tools/h5import/testfiles/txtfp64.txt b/tools/h5import/testfiles/txtfp64.txt index 6c83dc3..6c83dc3 100755..100644 --- a/tools/h5import/testfiles/txtfp64.txt +++ b/tools/h5import/testfiles/txtfp64.txt diff --git a/tools/h5import/testfiles/txtin16.conf b/tools/h5import/testfiles/txtin16.conf index d2d11c3..d2d11c3 100755..100644 --- a/tools/h5import/testfiles/txtin16.conf +++ b/tools/h5import/testfiles/txtin16.conf diff --git a/tools/h5import/testfiles/txtin32.conf b/tools/h5import/testfiles/txtin32.conf index ca4802a..ca4802a 100755..100644 --- a/tools/h5import/testfiles/txtin32.conf +++ b/tools/h5import/testfiles/txtin32.conf diff --git a/tools/h5import/testfiles/txtin8.conf b/tools/h5import/testfiles/txtin8.conf index 9dbfd2b..9dbfd2b 100755..100644 --- a/tools/h5import/testfiles/txtin8.conf +++ b/tools/h5import/testfiles/txtin8.conf diff --git a/tools/h5import/testfiles/txtuin16.conf b/tools/h5import/testfiles/txtuin16.conf index 753e6e8..753e6e8 100755..100644 --- a/tools/h5import/testfiles/txtuin16.conf +++ b/tools/h5import/testfiles/txtuin16.conf diff --git a/tools/h5import/testfiles/txtuin32.conf b/tools/h5import/testfiles/txtuin32.conf index d61e1a1..d61e1a1 100755..100644 --- a/tools/h5import/testfiles/txtuin32.conf +++ b/tools/h5import/testfiles/txtuin32.conf diff --git a/tools/h5import/testfiles/txtuin32.txt b/tools/h5import/testfiles/txtuin32.txt index 0688e9b..0688e9b 100755..100644 --- a/tools/h5import/testfiles/txtuin32.txt +++ b/tools/h5import/testfiles/txtuin32.txt diff --git a/tools/h5jam/testfiles/u10.txt b/tools/h5jam/testfiles/u10.txt index c76a964..c76a964 100755..100644 --- a/tools/h5jam/testfiles/u10.txt +++ b/tools/h5jam/testfiles/u10.txt diff --git a/tools/h5jam/testfiles/u511.txt b/tools/h5jam/testfiles/u511.txt index bff1736..bff1736 100755..100644 --- a/tools/h5jam/testfiles/u511.txt +++ b/tools/h5jam/testfiles/u511.txt diff --git a/tools/h5jam/testfiles/u512.txt b/tools/h5jam/testfiles/u512.txt index 33a36c9..33a36c9 100755..100644 --- a/tools/h5jam/testfiles/u512.txt +++ b/tools/h5jam/testfiles/u512.txt diff --git a/tools/h5jam/testfiles/u513.txt b/tools/h5jam/testfiles/u513.txt index 6b46ebf..6b46ebf 100755..100644 --- a/tools/h5jam/testfiles/u513.txt +++ b/tools/h5jam/testfiles/u513.txt diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 6460375..ae7a658 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -145,6 +145,31 @@ IF (BUILD_TESTING) ############################################################################## ############################################################################## + MACRO (ADD_H5_TEST_OLD testname testtype testfile) + IF (${testtype} STREQUAL "SKIP") + IF (NOT HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST ( + NAME H5REPACK-${testname}-SKIPPED + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out.${testfile}" + ) + ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) + ELSE (${testtype} STREQUAL "SKIP") + ADD_TEST ( + NAME H5REPACK-${testname} + COMMAND $<TARGET_FILE:h5repack> ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out.${testfile} + ) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5REPACK-${testname} PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + ADD_TEST ( + NAME H5REPACK-DIFF_${testname} + COMMAND $<TARGET_FILE:h5diff> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out.${testfile} + ) + SET_TESTS_PROPERTIES (H5REPACK-DIFF_${testname} PROPERTIES DEPENDS H5REPACK-${testname}) + SET (last_test "H5REPACK-DIFF_${testname}") + ENDIF (${testtype} STREQUAL "SKIP") + ENDMACRO (ADD_H5_TEST_OLD) + MACRO (ADD_H5_TEST testname testtype testfile) IF (${testtype} STREQUAL "SKIP") IF (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -261,6 +286,29 @@ IF (BUILD_TESTING) ENDIF (${testtype} STREQUAL "SKIP") ENDMACRO (ADD_H5_VERIFY_TEST) + MACRO (ADD_H5_TEST_META testname testfile) + ADD_TEST ( + NAME H5REPACK-${testname}_N + COMMAND $<TARGET_FILE:h5repack> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out_N.${testname}.h5 + ) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5REPACK-${testname}_N PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + ADD_TEST ( + NAME H5REPACK-${testname}_M + COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out_M.${testname}.h5 + ) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5REPACK-${testname}_M PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + ADD_TEST (NAME H5REPACK-${testname} COMMAND ${CMAKE_COMMAND} -E compare_files ${PROJECT_BINARY_DIR}/testfiles/out_N.${testname}.h5 ${PROJECT_BINARY_DIR}/testfiles/out_M.${testname}.h5) + SET_TESTS_PROPERTIES (H5REPACK-${testname} PROPERTIES WILL_FAIL "true") + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5REPACK-${testname} PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + SET (last_test "H5REPACK-${testname}") + ENDMACRO (ADD_H5_TEST_META) + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -278,8 +326,10 @@ IF (BUILD_TESTING) ./testfiles/h5repack_layout2.h5-v.out.err ./testfiles/h5repack_layout.h5-v.out ./testfiles/h5repack_layout.h5-v.out.err + ./testfiles/out.tfamily%05d.h5 ./testfiles/out.h5diff_attr1.h5 ./testfiles/out.h5repack_attr.h5 + ./testfiles/out.h5repack_attr_refs.h5 ./testfiles/out.h5repack_deflate.h5 ./testfiles/out.h5repack_early.h5 ./testfiles/out.h5repack_fill.h5 @@ -295,6 +345,10 @@ IF (BUILD_TESTING) ./testfiles/out.h5repack_refs.h5 ./testfiles/out.h5repack_shuffle.h5 ./testfiles/out.h5repack_soffset.h5 + ./testfiles/out_M.meta_short.h5 + ./testfiles/out_N.meta_short.h5 + ./testfiles/out_M.meta_long.h5 + ./testfiles/out_N.meta_long.h5 # from the h5repacktst h5repack_attr.h5 h5repack_attr_out.h5 @@ -762,7 +816,7 @@ IF (BUILD_TESTING) IF (NOT USE_FILTER_DEFLATE) SET (TESTTYPE "SKIP") ENDIF (NOT USE_FILTER_DEFLATE) -# ADD_H5_TEST (old_style_layout_short_switches ${TESTTYPE} ${arg}) + ADD_H5_TEST_OLD (old_style_layout_short_switches ${TESTTYPE} ${arg}) # add a userblock to file SET (arg ${FILE1} -u ${PROJECT_BINARY_DIR}/testfiles/ublock.bin -b 2048) @@ -783,16 +837,14 @@ IF (BUILD_TESTING) ADD_H5_TEST (committed_dt "TEST" ${FILE15}) # tests family driver (file is located in common testfiles folder, uses TOOLTEST1 -# ADD_H5_TEST ( family "FAMILY" ${FILE16}) + ADD_H5_TEST (family "TEST" ${FILE16}) # test various references (bug 1814 and 1726) ADD_H5_TEST (bug1814 "TEST" ${FILE_REF}) -# test attribute with various references in attribute of compund -# or vlen datatype -# (HDFFV-2605, 7513) -# TODO: include this test when code portion is completed. - ADD_H5_TEST (HDFFV-2605 "SKIP" ${FILE_ATTR_REF}) +# test attribute with various references (bug1797 / HDFFV-5932) +# the references in attribute of compund or vlen datatype + ADD_H5_TEST (HDFFV-5932 "TEST" ${FILE_ATTR_REF}) # Add test for memory leak in attirbute. This test is verified by CTEST. # 1. leak from vlen string @@ -801,6 +853,10 @@ IF (BUILD_TESTING) # Note: this test is experimental for sharing test file among tools ADD_H5_TEST (HDFFV-7840 "TEST" h5diff_attr1.h5) +# tests for metadata block size option ('-M') + ADD_H5_TEST_META (meta_short h5repack_layout.h5 -M 8192) + ADD_H5_TEST_META (meta_long h5repack_layout.h5 --metadata_block_size=8192) + IF (HDF5_TEST_VFD) # Run test with different Virtual File Driver FOREACH (vfd ${VFD_LIST}) diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 28d66c5..9778fdd 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -87,10 +87,12 @@ int h5repack(const char* infile, */ int -h5repack_init(pack_opt_t *options, int verbose, H5F_file_space_type_t strategy, hsize_t threshold) +h5repack_init(pack_opt_t *options, int verbose, H5F_file_space_type_t strategy, + hsize_t threshold) { int k, n; - HDmemset(options,0,sizeof(pack_opt_t)); + + HDmemset(options, 0, sizeof(pack_opt_t)); options->min_comp = 1024; options->verbose = verbose; diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 6415d3a..3907178 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -111,6 +111,7 @@ typedef struct { datatype, fill value, filter pipleline, attribute */ const char *ublock_filename; /* user block file name */ hsize_t ublock_size; /* user block size */ + hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ hsize_t threshold; /* alignment threshold for H5Pset_alignment */ hsize_t alignment ; /* alignment for H5Pset_alignment */ H5F_file_space_type_t fs_strategy; /* File space handling strategy */ diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index c1cbba1..236c555 100755..100644 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -147,20 +147,25 @@ COPY_TESTFILES_TO_TESTDIR() done } +# Print a $* message left justified in a field of 70 characters +# +MESSAGE() { + SPACES=" " + echo "$* $SPACES" | cut -c1-70 | tr -d '\012' +} + # Print a line-line message left justified in a field of 70 characters # beginning with the word "Testing". # TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' + MESSAGE "Testing $*" } # Print a line-line message left justified in a field of 70 characters # beginning with the word "Verifying". # VERIFY() { - SPACES=" " - echo "Verifying h5diff output $* $SPACES" | cut -c1-70 | tr -d '\012' + MESSAGE "Verifying h5diff output $*" } # Print a message that a test has been skipped (because a required filter @@ -385,6 +390,49 @@ TOOLTESTV() rm -f $actual $actual_err $actual_sav } +# TOOLTEST_META: +# Test metadata block size option. +# Reason to create a function here is to localize all special steps related to +# metadata block size option in one place. This is a quick solution. More +# thought out solution needed when there is more time. +# +# $1: test input file +# $2:$: metadata options (either "-M size" or "--metadata_block_size=size") +# +# Algorithm: +# Run it once without the metadata option ($2-$); +# Save the result output file; +# Run it second time with the metadata option; +# Verify the output file of second run is larger than the one of 1st run. +TOOLTEST_META() +{ + input_file=$1 + outfile="$TESTDIR/out.$1" + + # Use TOOLTEST_MAIN to run because it does not remove the output file. + # 1st run, without metadata option + TOOLTEST_MAIN $1 + # get the size of the first output file + size1=`wc -c $outfile | cut -d' ' -f1` + + # 2nd run with metadata option + TOOLTEST_MAIN $* + # get the size of the second output file + size2=`wc -c $outfile | cut -d' ' -f1` + + # verify sizes. + MESSAGE "Verify the sizes of both output files ($size1 vs $size2)" + if [ $size1 -lt $size2 ]; then + # pass + echo " PASSED" + else + #fail + echo "*FAILED*" + fi + + rm -f $outfile +} + # This is different from $srcdir/../../bin/output_filter.sh STDOUT_FILTER() { result_file=$1 @@ -801,7 +849,6 @@ TOOLTEST h5repack_refs.h5 # the references in attribute of compund or vlen datatype TOOLTEST h5repack_attr_refs.h5 - # Add test for memory leak in attirbute. This test is verified by CTEST. # 1. leak from vlen string # 2. leak from compound type without reference member @@ -809,6 +856,10 @@ TOOLTEST h5repack_attr_refs.h5 # Note: this test is experimental for sharing test file among tools TOOLTEST h5diff_attr1.h5 +# tests for metadata block size option ('-M') +TOOLTEST_META h5repack_layout.h5 -M 8192 +TOOLTEST_META h5repack_layout.h5 --metadata_block_size=8192 + if test $nerrors -eq 0 ; then echo "All $TESTNAME tests passed." exit $EXIT_SUCCESS diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 55cf932..d38a15c 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -42,7 +42,7 @@ int _err_num = 0; \ char _msg[80]; \ H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &_err_num); \ - H5Eget_msg(_err_num, NULL, _msg, 80); \ + H5Eget_msg(_err_num, NULL, _msg, (size_t)80); \ error_msg("%s %s -- %s\n", #_fun, "failed", _msg); \ goto error; \ } \ @@ -132,23 +132,23 @@ int copy_objects(const char* fnamein, goto out; } - if(!options->fs_strategy) - { - if(H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) - { - error_msg("failed to retrieve file space strategy\n"); - goto out; - } - } - - if(!options->fs_threshold) - { - if(H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) - { - error_msg("failed to retrieve file space threshold\n"); - goto out; - } - } + if(!options->fs_strategy) + { + if(H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) + { + error_msg("failed to retrieve file space strategy\n"); + goto out; + } + } + + if(!options->fs_threshold) + { + if(H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) + { + error_msg("failed to retrieve file space threshold\n"); + goto out; + } + } if(H5Pclose(fcpl_in) < 0) { @@ -254,135 +254,113 @@ int copy_objects(const char* fnamein, } /* end if */ } /* end if */ } /* end if */ - - - - #if defined (H5REPACK_DEBUG_USER_BLOCK) - print_user_block(fnamein,fidin); + print_user_block(fnamein, fidin); #endif - /*------------------------------------------------------------------------- * set the new user userblock options in the FCPL (before H5Fcreate ) *------------------------------------------------------------------------- */ - if ( options->ublock_size > 0 ) { /* either use the FCPL already created or create a new one */ - if(fcpl != H5P_DEFAULT) + if(fcpl == H5P_DEFAULT) { - /* set user block size */ - if(H5Pset_userblock(fcpl, options->ublock_size) < 0) - { - error_msg("failed to set userblock size\n"); - goto out; - } - - } - - else - { - /* create a file creation property list */ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { error_msg("fail to create a file creation property list\n"); goto out; } - - /* set user block size */ - if(H5Pset_userblock(fcpl, options->ublock_size) < 0) - { - error_msg("failed to set userblock size\n"); - goto out; - } - } - - + /* set user block size */ + if(H5Pset_userblock(fcpl, options->ublock_size) < 0) + { + error_msg("failed to set userblock size\n"); + goto out; + } } - /*------------------------------------------------------------------------- * set alignment options *------------------------------------------------------------------------- */ - - if ( options->alignment > 0 ) { /* either use the FAPL already created or create a new one */ - if (fapl != H5P_DEFAULT) + if (fapl == H5P_DEFAULT) { - - if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) + /* create a file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - error_msg("failed to set alignment\n"); + error_msg("Could not create file access property list\n"); goto out; } - } - else + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { + error_msg("failed to set alignment\n"); + goto out; + } + } + /*------------------------------------------------------------------------- + * set metadata block size option + *------------------------------------------------------------------------- + */ + if ( options->meta_block_size > 0 ) + { + /* either use the FAPL already created or create a new one */ + if (fapl == H5P_DEFAULT) + { /* create a file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg("Could not create file access property list\n"); goto out; } - - if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) - { - error_msg("failed to set alignment\n"); - goto out; - } - } + if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) + { + error_msg("failed to set metadata block size\n"); + goto out; + } } + /*------------------------------------------------------------------------- + * set free-space strategy options + *------------------------------------------------------------------------- + */ + /* either use the FCPL already created or create a new one */ - if(fcpl != H5P_DEFAULT) + if(fcpl == H5P_DEFAULT) { - /* set file space strategy and free space threshold */ - if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) - { - error_msg("failed to set file space strategy & threshold\n"); - goto out; - } + /* create a file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + { + error_msg("fail to create a file creation property list\n"); + goto out; + } } - else + + /* set file space strategy and free space threshold */ + if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) { - /* create a file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - { - error_msg("fail to create a file creation property list\n"); - goto out; - } - - /* set file space strategy and free space threshold */ - if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) - { - error_msg("failed to set file space strategy & threshold \n"); - goto out; - } + error_msg("failed to set file space strategy & threshold \n"); + goto out; } /*------------------------------------------------------------------------- * create the output file *------------------------------------------------------------------------- */ - - if(options->verbose) printf("Making file <%s>...\n",fnameout); - if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0) { error_msg("<%s>: Could not create file\n", fnameout ); diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index e1697ab..6004084 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -35,7 +35,7 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:t:a:i:o:S:T:"; +static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:T:"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "version", no_arg, 'V' }, @@ -51,6 +51,7 @@ static struct long_options l_opts[] = { { "ssize", require_arg, 's' }, { "ublock", require_arg, 'u' }, { "block", require_arg, 'b' }, + { "metadata_block_size", require_arg, 'M' }, { "threshold", require_arg, 't' }, { "alignment", require_arg, 'a' }, { "infile", require_arg, 'i' }, /* -i for backward compability */ @@ -78,24 +79,6 @@ static struct long_options l_opts[] = { * * Comments: * - * Modifications: - * July 2004: Introduced the extra EC or NN option for SZIP - * October 2006: Added a new switch -n, that allows to write the dataset - * using a native type. The default to write is the file type. - * - * Modification: - * Peter Cao, June 13, 2007 - * Add "-L, --latest" option to pack a file with the latest file format - * PVN, November 19, 2007 - * adopted the syntax h5repack [OPTIONS] file1 file2 - * PVN, November 28, 2007 - * added support for multiple global filters - * PVN, May 16, 2008 - * added backward compatibility for -i infile -o outfile - * PVN, August 20, 2008 - * add a user block to repacked file (switches -u -b) - * PVN, August 28, 2008 - * add options to set alignment (H5Pset_alignment) (switches -t -a) *------------------------------------------------------------------------- */ int main(int argc, const char **argv) @@ -115,7 +98,7 @@ int main(int argc, const char **argv) HDexit(EXIT_FAILURE); /* initialize options */ - h5repack_init(&options, 0, 0, (hsize_t)0); + h5repack_init(&options, 0, H5F_FILE_SPACE_DEFAULT, (hsize_t)0); parse_command_line(argc, argv, &options); @@ -187,6 +170,7 @@ static void usage(const char *prog) printf(" -e E, --file=E Name of file E with the -f and -l options\n"); printf(" -u U, --ublock=U Name of file U with user block data to be added\n"); printf(" -b B, --block=B Size of user block to be added\n"); + printf(" -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); printf(" -t T, --threshold=T Threshold value for H5Pset_alignment\n"); printf(" -a A, --alignment=A Alignment value for H5Pset_alignment\n"); printf(" -f FILT, --filter=FILT Filter type\n"); @@ -428,7 +412,6 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) break; - case 'u': options->ublock_filename = opt_arg; @@ -439,6 +422,11 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) options->ublock_size = (hsize_t)HDatol( opt_arg ); break; + case 'M': + + options->meta_block_size = (hsize_t)HDatol( opt_arg ); + break; + case 't': options->threshold = (hsize_t)HDatol( opt_arg ); @@ -455,7 +443,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'S': - { + { char strategy[MAX_NC_NAME]; HDstrcpy(strategy, opt_arg); @@ -472,7 +460,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) HDexit(EXIT_FAILURE); } break; - } + } case 'T': diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 17a6190..6b15f0a 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -78,7 +78,6 @@ #define FNAME17OUT "h5repack_named_dtypes_out.h5" #define FNAME18 "h5repack_layout2.h5" -#define FNAME18OUT "h5repack_layout2_out.h5" #define FNAME_UB "ublock.bin" @@ -172,6 +171,8 @@ int main (void) diff_opt_t diff_options; hsize_t fs_size = 0; /* free space section threshold */ H5F_file_space_type_t fs_type = H5F_FILE_SPACE_DEFAULT; /* file space handling strategy */ + h5_stat_t file_stat; + h5_stat_size_t fsize1, fsize2; /* file sizes */ #if defined (H5_HAVE_FILTER_SZIP) int szip_can_encode = 0; #endif @@ -1561,6 +1562,50 @@ int main (void) PASSED(); /*------------------------------------------------------------------------- + * test --metadata_block_size option + * Also verify that output file using the metadata_block_size option is + * larger than the output file one not using it. + * FNAME4 is used because it is the same as the test file used for the + * shell script version of this test (h5repack.sh). + *------------------------------------------------------------------------- + */ + TESTING(" metadata block size option"); + /* First run without metadata option. No need to verify the correctness */ + /* since this has been verified by earlier tests. Just record the file */ + /* size of the output file. */ + if(h5repack_init(&pack_options, 0, H5F_FILE_SPACE_DEFAULT, (hsize_t)0) < 0) + GOERROR; + if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + GOERROR; + if(HDstat(FNAME4OUT, &file_stat) < 0) + GOERROR; + fsize1 = file_stat.st_size; + if(h5repack_end(&pack_options) < 0) + GOERROR; + + /* run it again with metadata option */ + if(h5repack_init(&pack_options, 0, H5F_FILE_SPACE_DEFAULT, (hsize_t)0) < 0) + GOERROR; + pack_options.meta_block_size = 8192; + if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + GOERROR; + if(h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) + GOERROR; + /* record the file size of the output file */ + if(HDstat(FNAME4OUT, &file_stat) < 0) + GOERROR; + fsize2 = file_stat.st_size; + /* verify second file size is larger than the first one */ + if(fsize2 <= fsize1) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + + + /*------------------------------------------------------------------------- * clean temporary test files *------------------------------------------------------------------------- */ @@ -3253,7 +3298,7 @@ make_userblock(void) /* Initialize userblock data */ for(u = 0; u < USERBLOCK_SIZE; u++) - ub[u] = 'a' + (u % 26); + ub[u] = 'a' + (char)(u % 26); /* Re-open HDF5 file, as "plain" file */ if((fd = HDopen(FNAME16, O_WRONLY, 0644)) < 0) @@ -3366,7 +3411,7 @@ make_userblock_file(void) /* initialize userblock data */ for(u = 0; u < USERBLOCK_SIZE; u++) - ub[u] = 'a' + (u % 26); + ub[u] = 'a' + (char)(u % 26); /* open file */ if((fd = HDopen(FNAME_UB,O_WRONLY|O_CREAT|O_TRUNC, 0644 )) < 0) @@ -3842,7 +3887,7 @@ int write_dset_in(hid_t loc_id, int l; buf52[i][j].p = malloc((i + 1) * sizeof(int)); - buf52[i][j].len = i + 1; + buf52[i][j].len = (size_t)(i + 1); for(l = 0; l < i + 1; l++) { if(make_diffs) @@ -4063,7 +4108,7 @@ int write_dset_in(hid_t loc_id, int l; buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); - buf53[i][j][k].len = i + 1; + buf53[i][j][k].len = (size_t)(i + 1); for(l = 0; l < i + 1; l++) { if(make_diffs) @@ -4854,7 +4899,7 @@ int write_attr_in(hid_t loc_id, { int l; buf52[i][j].p = malloc((i + 1) * sizeof(int)); - buf52[i][j].len = i + 1; + buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs)((int *)buf52[i][j].p)[l] = 0; else ((int *)buf52[i][j].p)[l] = n++; @@ -5320,7 +5365,7 @@ int write_attr_in(hid_t loc_id, { int l; buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); - buf53[i][j][k].len = i + 1; + buf53[i][j][k].len = (size_t)i + 1; for (l = 0; l < i + 1; l++) if (make_diffs) { @@ -5819,7 +5864,7 @@ static herr_t add_attr_with_regref(hid_t file_id, hid_t obj_id) } /* select elements space for reference */ - status = H5Sselect_elements (sid_regrefed_dset, H5S_SELECT_SET, 3, coords_regrefed_dset[0]); + status = H5Sselect_elements (sid_regrefed_dset, H5S_SELECT_SET, (size_t)3, coords_regrefed_dset[0]); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); @@ -6141,7 +6186,7 @@ static herr_t gen_region_ref(hid_t loc_id) } /* select elements space for reference */ - status = H5Sselect_elements (sid_trg, H5S_SELECT_SET, 4, coords[0]); + status = H5Sselect_elements (sid_trg, H5S_SELECT_SET, (size_t)4, coords[0]); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); @@ -6508,7 +6553,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create the region reference */ - status = H5Sselect_elements (objsid, H5S_SELECT_SET, 4, coords[0]); + status = H5Sselect_elements (objsid, H5S_SELECT_SET, (size_t)4, coords[0]); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); @@ -6619,7 +6664,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create region reference */ - status = H5Sselect_elements(objsid, H5S_SELECT_SET, 4, coords[0]); + status = H5Sselect_elements(objsid, H5S_SELECT_SET, (size_t)4, coords[0]); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index e206f4f..99ea688 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -99,17 +99,17 @@ typedef struct iter_t { hsize_t attrs_heap_storage_size; /* fractal heap size for attributes (1.8) */ hsize_t SM_hdr_storage_size; /* header size for SOHM table (1.8) */ hsize_t SM_index_storage_size; /* index (btree & list) size for SOHM table (1.8) */ - hsize_t SM_heap_storage_size; /* fractal heap size for SOHM table (1.8) */ - hsize_t super_size; /* superblock size */ - hsize_t super_ext_size; /* superblock extension size */ - hsize_t ublk_size; /* user block size (if exists) */ - H5F_file_space_type_t fs_strategy; /* File space management strategy */ - hsize_t fs_threshold; /* Free-space section threshold */ - hsize_t free_space; /* amount of freespace in the file */ - hsize_t free_hdr; /* size of free space manager metadata in the file */ + hsize_t SM_heap_storage_size; /* fractal heap size for SOHM table (1.8) */ + hsize_t super_size; /* superblock size */ + hsize_t super_ext_size; /* superblock extension size */ + hsize_t ublk_size; /* user block size (if exists) */ + H5F_file_space_type_t fs_strategy; /* File space management strategy */ + hsize_t fs_threshold; /* Free-space section threshold */ + hsize_t free_space; /* amount of freespace in the file */ + hsize_t free_hdr; /* size of free space manager metadata in the file */ unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */ - unsigned sect_nbins; /* Number of bins for free-space section sizes */ - unsigned long *sect_bins; /* Pointer to array of bins for free-space section sizes */ + unsigned sect_nbins; /* Number of bins for free-space section sizes */ + unsigned long *sect_bins; /* Pointer to array of bins for free-space section sizes */ hsize_t datasets_index_storage_size;/* meta size for chunked dataset's indexing type */ hsize_t datasets_heap_storage_size; /* heap size for dataset with external storage */ unsigned long nexternal; /* Number of external files for a dataset */ @@ -120,11 +120,11 @@ typedef struct iter_t { static int display_all = TRUE; /* Enable the printing of selected statistics */ -static int display_file = FALSE; /* display file information */ -static int display_group = FALSE; /* display groups information */ -static int display_dset = FALSE; /* display datasets information */ +static int display_file = FALSE; /* display file information */ +static int display_group = FALSE; /* display groups information */ +static int display_dset = FALSE; /* display datasets information */ static int display_dset_dtype_meta = FALSE; /* display datasets' datatype information */ -static int display_attr = FALSE; /* display attributes information */ +static int display_attr = FALSE; /* display attributes information */ static int display_free_sections = FALSE; /* display free space information */ static int display_summary = FALSE; /* display summary of file space information */ @@ -283,7 +283,7 @@ ceil_log10(unsigned long x) } /* end while */ return(ret); -} +} /* ceil_log10() */ /*------------------------------------------------------------------------- @@ -481,7 +481,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) /* Object header's total size for H5D_COMPACT layout includes raw data size */ /* "storage" also includes H5D_COMPACT raw data size */ if(lout == H5D_COMPACT) - iter->dset_ohdr_info.total_size -= storage; + iter->dset_ohdr_info.total_size -= storage; /* Track the layout type for dataset */ (iter->dset_layouts[lout])++; @@ -495,7 +495,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) iter->nexternal += (unsigned long)num_ext; iter->dset_external_storage_size += (unsigned long)storage; } else - iter->dset_storage_size += storage; + iter->dset_storage_size += storage; /* Gather dataspace statistics */ sid = H5Dget_space(did); @@ -602,6 +602,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) return 0; } /* end dataset_stats() */ + /*------------------------------------------------------------------------- * Function: datatype_stats * @@ -791,11 +792,6 @@ freespace_stats(hid_t fid, iter_t *iter) * Programmer: Elena Pourmal * Saturday, August 12, 2006 * - * Modifications: - * Vailin Choi; October 2009 - * Turn on display_group_metadata, display_dset_metadata - * Add 'S' & 's' for printing free space info (previous checkin) - * *------------------------------------------------------------------------- */ static struct handler_t * @@ -812,103 +808,103 @@ parse_command_line(int argc, const char *argv[]) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch ((char) opt) { - case 'h': - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } - goto done; - break; + switch ((char)opt) { + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + if (hand) { + for (i = 0; i < argc; i++) + if(hand[i].obj) { + free(hand[i].obj); + hand[i].obj=NULL; + } + + free(hand); + hand = NULL; + } + goto done; + break; - case 'V': - print_version(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } - goto done; - break; + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + if (hand) { + for (i = 0; i < argc; i++) + if(hand[i].obj) { + free(hand[i].obj); + hand[i].obj=NULL; + } + + free(hand); + hand = NULL; + } + goto done; + break; - case 'F': - display_all = FALSE; - display_file_metadata = TRUE; - break; + case 'F': + display_all = FALSE; + display_file_metadata = TRUE; + break; - case 'f': - display_all = FALSE; - display_file = TRUE; - break; + case 'f': + display_all = FALSE; + display_file = TRUE; + break; - case 'G': - display_all = FALSE; - display_group_metadata = TRUE; - break; + case 'G': + display_all = FALSE; + display_group_metadata = TRUE; + break; - case 'g': - display_all = FALSE; - display_group = TRUE; - break; + case 'g': + display_all = FALSE; + display_group = TRUE; + break; - case 'D': - display_all = FALSE; - display_dset_metadata = TRUE; - break; + case 'D': + display_all = FALSE; + display_dset_metadata = TRUE; + break; - case 'd': - display_all = FALSE; - display_dset = TRUE; - break; + case 'd': + display_all = FALSE; + display_dset = TRUE; + break; - case 'T': - display_all = FALSE; - display_dset_dtype_meta = TRUE; - break; + case 'T': + display_all = FALSE; + display_dset_dtype_meta = TRUE; + break; - case 'A': - display_all = FALSE; - display_attr = TRUE; - break; + case 'A': + display_all = FALSE; + display_attr = TRUE; + break; - case 's': - display_all = FALSE; - display_free_sections = TRUE; - break; + case 's': + display_all = FALSE; + display_free_sections = TRUE; + break; - case 'S': - display_all = FALSE; - display_summary = TRUE; - break; + case 'S': + display_all = FALSE; + display_summary = TRUE; + break; - case 'O': - display_all = FALSE; - display_object = TRUE; - for (i = 0; i < argc; i++) - if (!hand[i].obj) { - hand[i].obj = HDstrdup(opt_arg); - break; - } /* end if */ - break; + case 'O': + display_all = FALSE; + display_object = TRUE; + for(i = 0; i < argc; i++) + if(!hand[i].obj) { + hand[i].obj = HDstrdup(opt_arg); + break; + } /* end if */ + break; - default: - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto error; + default: + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto error; } /* end switch */ } /* end while */ @@ -964,7 +960,7 @@ iter_init(iter_t *iter, hid_t fid) iter->fid = fid; return 0; -} +} /* iter_init() */ /*------------------------------------------------------------------------- @@ -1174,7 +1170,7 @@ print_group_metadata(const iter_t *iter) printf("File space information for groups' metadata (in bytes):\n"); HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n", - iter->group_ohdr_info.total_size, iter->group_ohdr_info.free_size); + iter->group_ohdr_info.total_size, iter->group_ohdr_info.free_size); HDfprintf(stdout, "\tB-tree/List: %Hu\n", iter->groups_btree_storage_size); HDfprintf(stdout, "\tHeap: %Hu\n", iter->groups_heap_storage_size); @@ -1195,8 +1191,6 @@ print_group_metadata(const iter_t *iter) * Programmer: Elena Pourmal * Saturday, August 12, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1292,10 +1286,10 @@ print_dset_metadata(const iter_t *iter) printf("File space information for datasets' metadata (in bytes):\n"); HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n", - iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size); + iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size); HDfprintf(stdout, "\tIndex for Chunked datasets: %Hu\n", - iter->datasets_index_storage_size); + iter->datasets_index_storage_size); HDfprintf(stdout, "\tHeap: %Hu\n", iter->datasets_heap_storage_size); return 0; @@ -1311,11 +1305,7 @@ print_dset_metadata(const iter_t *iter) * * Failure: Never fails * - * Programmer: - * - * Modifications: - * Vailin Choi; October 2009 - * Moved from print_dataset_info() + * Programmer: Vailin Choi; October 2009 * *------------------------------------------------------------------------- */ @@ -1327,21 +1317,21 @@ print_dset_dtype_meta(const iter_t *iter) unsigned u; /* Local index variable */ if(iter->dset_ntypes) { - printf("Dataset datatype information:\n"); - printf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes); - total = 0; - for(u = 0; u < iter->dset_ntypes; u++) { - H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size); - printf("\tDataset datatype #%u:\n", u); - printf("\t\tCount (total/named) = (%lu/%lu)\n", - iter->dset_type_info[u].count, iter->dset_type_info[u].named); - printf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size, - (unsigned long)H5Tget_size(iter->dset_type_info[u].tid)); - H5Tclose(iter->dset_type_info[u].tid); - total += iter->dset_type_info[u].count; - } /* end for */ - printf("\tTotal dataset datatype count: %lu\n", total); - } + printf("Dataset datatype information:\n"); + printf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes); + total = 0; + for(u = 0; u < iter->dset_ntypes; u++) { + H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size); + printf("\tDataset datatype #%u:\n", u); + printf("\t\tCount (total/named) = (%lu/%lu)\n", + iter->dset_type_info[u].count, iter->dset_type_info[u].named); + printf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size, + (unsigned long)H5Tget_size(iter->dset_type_info[u].tid)); + H5Tclose(iter->dset_type_info[u].tid); + total += iter->dset_type_info[u].count; + } /* end for */ + printf("\tTotal dataset datatype count: %lu\n", total); + } /* end if */ return 0; } /* print_dset_dtype_meta() */ @@ -1446,7 +1436,7 @@ print_freespace_info(const iter_t *iter) return 0; } /* print_freespace_info() */ - + /*------------------------------------------------------------------------- * Function: print_storage_summary * @@ -1492,7 +1482,7 @@ print_storage_summary(const iter_t *iter) HDfprintf(stdout, " Amount/Percent of tracked free space: %Hu bytes/%3.1f%\n", iter->free_space, percent); - if(iter->filesize < (total_meta+iter->dset_storage_size+iter->free_space)) { + if(iter->filesize < (total_meta + iter->dset_storage_size + iter->free_space)) { unaccount = (total_meta + iter->dset_storage_size + iter->free_space) - iter->filesize; HDfprintf(stdout, " ??? File has %Hu more bytes accounted for than its size! ???\n", unaccount); } @@ -1501,12 +1491,11 @@ print_storage_summary(const iter_t *iter) HDfprintf(stdout, " Unaccounted space: %Hu bytes\n", unaccount); } - HDfprintf(stdout, "Total space: %Hu bytes\n", total_meta+iter->dset_storage_size+iter->free_space+unaccount); + HDfprintf(stdout, "Total space: %Hu bytes\n", total_meta + iter->dset_storage_size + iter->free_space + unaccount); if(iter->nexternal) HDfprintf(stdout, "External raw data: %Hu bytes\n", iter->dset_external_storage_size); - return 0; } /* print_storage_summary() */ @@ -1523,11 +1512,6 @@ print_storage_summary(const iter_t *iter) * Programmer: Elena Pourmal * Saturday, August 12, 2006 * - * Modifications: - * Vailin Choi; October 2009 - * Activate "display_group_metadata", "dislay_dset_metadata" and - * "display_dset_dtype_info". - * *------------------------------------------------------------------------- */ static void @@ -1560,7 +1544,7 @@ print_file_statistics(const iter_t *iter) if(display_attr) print_attr_info(iter); if(display_free_sections) print_freespace_info(iter); if(display_summary) print_storage_summary(iter); -} +} /* print_file_statistics() */ /*------------------------------------------------------------------------- @@ -1583,7 +1567,7 @@ static void print_object_statistics(const char *name) { printf("Object name %s\n", name); -} +} /* print_object_statistics() */ /*------------------------------------------------------------------------- @@ -1609,9 +1593,18 @@ print_statistics(const char *name, const iter_t *iter) print_object_statistics(name); else print_file_statistics(iter); -} +} /* print_statistics() */ +/*------------------------------------------------------------------------- + * Function: main + * + * Modifications: + * 2/2010; Vailin Choi + * Get the size of user block + * + *------------------------------------------------------------------------- + */ int main(int argc, const char *argv[]) { diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index cef30dd..306f914 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -1121,6 +1121,8 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, char * obj2_fullpath = NULL; h5trav_type_t objtype; diff_args_t argdata; + size_t idx1 = 0; + size_t idx2 = 0; /* @@ -1160,17 +1162,6 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } } - /* objects with the same name but different HDF5 types */ - for( i = 0; i < table->nobjs; i++) - { - if ( table->objs[i].flags[0] && table->objs[i].flags[1] ) - { - if ( table->objs[i].type != table->objs[i].type ) - { - options->contents = 0; - } - } - } /*------------------------------------------------------------------------- * do the diff for common objects @@ -1205,8 +1196,18 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDstrcpy(obj2_fullpath, grp2_path); HDstrcat(obj2_fullpath, table->objs[i].name); + /* get index to figure out type of the object in file1 */ + while ( info1->paths[idx1].path && + (HDstrcmp (obj1_fullpath, info1->paths[idx1].path) != 0) ) + idx1++; + /* get index to figure out type of the object in file2 */ + while ( info2->paths[idx2].path && + (HDstrcmp (obj2_fullpath, info2->paths[idx2].path) != 0) ) + idx2++; + /* Set argdata to pass other args into diff() */ - argdata.type = objtype; + argdata.type[0] = info1->paths[idx1].type; + argdata.type[1] = info2->paths[idx2].type; argdata.is_same_trgobj = table->objs[i].is_same_trgobj; options->cmn_objs = 1; @@ -1242,7 +1243,8 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDstrcpy(args.name1, obj1_fullpath); HDstrcpy(args.name2, obj2_fullpath); args.options = *options; - args.argdata.type = objtype; + args.argdata.type[0] = info1->paths[idx1].type; + args.argdata.type[1] = info2->paths[idx2].type; args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj; h5diffdebug2("busyTasks=%d\n", busyTasks); @@ -1576,176 +1578,9 @@ hsize_t diff_compare(hid_t file1_id, obj1type = info1->paths[i].type; obj2type = info2->paths[j].type; - /*----------------------------------------------------------------- - * follow link option, compare with target object - */ - if (options->follow_links) - { - /* pass how to handle printing warning to linkinfo option */ - if(print_warn(options)) - linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1; - - /*------------------------------------------------------------ - * Soft links - *------------------------------------------------------------*/ - - /*-------------------------- - * if object1 soft link */ - if (obj1type == H5TRAV_TYPE_LINK) - { - /* get type of target object */ - l_ret = H5tools_get_symlink_info(file1_id, obj1name, &linkinfo1, TRUE); - /* dangling link */ - if (l_ret == 0) - { - if (options->no_dangle_links) - { - /* gangling link is error */ - if(options->m_verbose) - parallel_print("Warning: <%s> is a dangling link.\n", obj1name); - options->err_stat = 1; - goto out; - } - else - is_dangle_link1 = 1; - } - /* fail */ - else if(l_ret < 0) - { - options->err_stat = 1; - goto out; - } - else /* OK */ - { - /* target type for diff() */ - obj1type = linkinfo1.trg_type; - } - } - - /*----------------------------- - * if object2 is soft link */ - if (obj2type == H5TRAV_TYPE_LINK) - { - /* get type target object */ - l_ret = H5tools_get_symlink_info(file2_id, obj2name, &linkinfo2, TRUE); - /* dangling link */ - if (l_ret == 0) - { - if (options->no_dangle_links) - { - /* gangling link is error */ - if(options->m_verbose) - parallel_print("Warning: <%s> is a dangling link.\n", obj2name); - options->err_stat = 1; - goto out; - } - else - is_dangle_link2=1; - } - /* fail */ - else if(l_ret < 0) - { - options->err_stat = 1; - goto out; - } - else /* OK */ - { - /* target type for diff() */ - obj2type = linkinfo2.trg_type; - } - } - - /*------------------------------------------------------------ - * External links - *------------------------------------------------------------*/ - - /*-------------------------------- - * if object1 is external link */ - if (obj1type == H5TRAV_TYPE_UDLINK) - { - /* get type and name of target object */ - l_ret = H5tools_get_symlink_info(file1_id, obj1name, &linkinfo1, TRUE); - /* dangling link */ - if (l_ret == 0) - { - if (options->no_dangle_links) - { - /* gangling link is error */ - if(options->m_verbose) - parallel_print("Warning: <%s> is a dangling link.\n", obj1name); - options->err_stat = 1; - goto out; - } - else - is_dangle_link1 = 1; - } - /* fail */ - else if(l_ret < 0) - { - options->err_stat = 1; - goto out; - } - else /* OK */ - { - /* for external link */ - if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) - obj1type = linkinfo1.trg_type; - } - } - - /*-------------------------------- - * if object2 is external link */ - if (obj2type == H5TRAV_TYPE_UDLINK) - { - /* get type and name of target object */ - l_ret = H5tools_get_symlink_info(file2_id, obj2name, &linkinfo2, TRUE); - /* dangling link */ - if (l_ret == 0) - { - if (options->no_dangle_links) - { - /* gangling link is error */ - if(options->m_verbose) - parallel_print("Warning: <%s> is a dangling link.\n", obj2name); - options->err_stat = 1; - goto out; - } - else - is_dangle_link2 = 1; - } - /* fail */ - else if(l_ret < 0) - { - options->err_stat = 1; - goto out; - } - else /* OK */ - { - /* for external link */ - if(linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) - obj2type = linkinfo2.trg_type; - } - } - /* found dangling link */ - if (is_dangle_link1 || is_dangle_link2) - goto out; - } /* end of follow_links */ - - /* objects are not the same type */ - if (obj1type != obj2type) - { - if (options->m_verbose||options->m_list_not_cmp) - { - parallel_print("<%s> is of type %s and <%s> is of type %s\n", - obj1name, get_type(obj1type), - obj2name, get_type(obj2type)); - } - options->not_cmp=1; - goto out; - } - /* Set argdata to pass other args into diff() */ - argdata.type = obj1type; + argdata.type[0] = obj1type; + argdata.type[1] = obj2type; argdata.is_same_trgobj = 0; nfound = diff(file1_id, obj1name, @@ -1806,7 +1641,8 @@ out: * Return: Number of differences found * * Programmer: Jonathan Kim - * - add following links feature (Feb 11,2010) + * - Move follow symlinks code toward top. (March 2812) + * - Add following symlinks feature (Feb 11,2010) * - Change to use diff_args_t to pass the rest of args. * Passing through it instead of individual args provides smoother * extensibility through its members along with MPI code update for ph5diff @@ -1834,6 +1670,7 @@ hsize_t diff(hid_t file1_id, int is_dangle_link2 = 0; int is_hard_link = 0; hsize_t nfound = 0; + h5trav_type_t object_type; /* to get link info */ @@ -1848,52 +1685,86 @@ hsize_t diff(hid_t file1_id, if(print_warn(options)) linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1; - /* - * Get target object info for obj1 and obj2 and check dangling links. - * (for hard-linked-objects, because diff() only get the obj1's type, - * so obj2's type should be check here when diff() is called from - * diff_match() for same-named objects with dangling link only one side.) - */ - - /* target object1 - get type and name */ - ret = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, TRUE); - /* dangling link */ - if (ret == 0) + /* for symbolic links, take care follow symlink and no dangling link + * options */ + if (argdata->type[0] == H5TRAV_TYPE_LINK || + argdata->type[0] == H5TRAV_TYPE_UDLINK || + argdata->type[1] == H5TRAV_TYPE_LINK || + argdata->type[1] == H5TRAV_TYPE_UDLINK ) { - if (options->no_dangle_links) + /* + * check dangling links for path1 and path2 + */ + + /* target object1 - get type and name */ + ret = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, TRUE); + /* dangling link */ + if (ret == 0) { - /* gangling link is error */ - if(options->m_verbose) - parallel_print("Warning: <%s> is a dangling link.\n", path1); - goto out; + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", path1); + goto out; + } + else + is_dangle_link1 = 1; } - else - is_dangle_link1 = 1; - } - else if (ret < 0) - goto out; + else if (ret < 0) + goto out; - /* target object2 - get type and name */ - ret = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, TRUE); - /* dangling link */ - if (ret == 0) - { - if (options->no_dangle_links) + /* target object2 - get type and name */ + ret = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, TRUE); + /* dangling link */ + if (ret == 0) { - /* gangling link is error */ - if(options->m_verbose) - parallel_print("Warning: <%s> is a dangling link.\n", path2); + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", path2); + goto out; + } + else + is_dangle_link2 = 1; + } + else if (ret < 0) goto out; + + /* found dangling link */ + if (is_dangle_link1 || is_dangle_link2) + goto out2; + + /* follow symbolic link option */ + if (options->follow_links) + { + if (linkinfo1.linfo.type == H5L_TYPE_SOFT || + linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) + argdata->type[0] = linkinfo1.trg_type; + + if (linkinfo2.linfo.type == H5L_TYPE_SOFT || + linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) + argdata->type[1] = linkinfo2.trg_type; } - else - is_dangle_link2 = 1; } - else if (ret < 0) - goto out; - - /* found dangling link */ - if (is_dangle_link1 || is_dangle_link2) + /* if objects are not the same type */ + if (argdata->type[0] != argdata->type[1]) + { + if (options->m_verbose||options->m_list_not_cmp) + { + parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", + path1, get_type(argdata->type[0]), + path2, get_type(argdata->type[1])); + } + options->not_cmp=1; + /* TODO: will need to update non-comparable is different + * options->contents = 0; + */ goto out2; + } + else /* now both object types are same */ + object_type = argdata->type[0]; /* * If both points to the same target object, skip comparing details inside @@ -1903,17 +1774,17 @@ hsize_t diff(hid_t file1_id, * * Perform this to match the outputs as bypassing. */ - is_hard_link = (argdata->type == H5TRAV_TYPE_DATASET || - argdata->type == H5TRAV_TYPE_NAMED_DATATYPE || - argdata->type == H5TRAV_TYPE_GROUP); - if (options->follow_links || is_hard_link) + if (argdata->is_same_trgobj) { - if (argdata->is_same_trgobj) + is_hard_link = (object_type == H5TRAV_TYPE_DATASET || + object_type == H5TRAV_TYPE_NAMED_DATATYPE || + object_type == H5TRAV_TYPE_GROUP); + if (options->follow_links || is_hard_link) { /* print information is only verbose option is used */ if(options->m_verbose || options->m_report) { - switch(argdata->type) + switch(object_type) { case H5TRAV_TYPE_DATASET: do_print_objname("dataset", path1, path2, options); @@ -1935,7 +1806,7 @@ hsize_t diff(hid_t file1_id, break; default: parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(argdata->type) ); + path1, path2, get_type(object_type) ); options->not_cmp = 1; break; } /* switch(type)*/ @@ -1943,11 +1814,12 @@ hsize_t diff(hid_t file1_id, print_found(nfound); } /* if(options->m_verbose || options->m_report) */ + /* exact same, so comparison is done */ goto out2; } } - switch(argdata->type) + switch(object_type) { /*---------------------------------------------------------------------- * H5TRAV_TYPE_DATASET @@ -2064,30 +1936,6 @@ hsize_t diff(hid_t file1_id, if(print_objname(options, nfound)) do_print_objname("link", path1, path2, options); - if (options->follow_links) - { - /* objects are not the same type */ - if (linkinfo1.trg_type != linkinfo2.trg_type) - { - if (options->m_verbose||options->m_list_not_cmp) - { - parallel_print("<%s> is of type %s and <%s> is of type %s\n", path1, get_type(linkinfo1.trg_type), path2, get_type(linkinfo2.trg_type)); - } - options->not_cmp=1; - goto out; - } - - /* Renew type in argdata to pass into diff(). - * For recursive call, argdata.is_same_trgobj is already - * set from initial call, so don't reset here */ - argdata->type = linkinfo1.trg_type; - - /* call self to compare target object */ - nfound += diff(file1_id, path1, - file2_id, path2, - options, argdata); - } - /* always print the number of differences found in verbose mode */ if(options->m_verbose) print_found(nfound); @@ -2121,28 +1969,6 @@ hsize_t diff(hid_t file1_id, if(print_objname(options, nfound)) do_print_objname("external link", path1, path2, options); - if (options->follow_links) - { - /* objects are not the same type */ - if (linkinfo1.trg_type != linkinfo2.trg_type) - { - if (options->m_verbose||options->m_list_not_cmp) - { - parallel_print("<%s> is of type %s and <%s> is of type %s\n", path1, get_type(linkinfo1.trg_type), path2, get_type(linkinfo2.trg_type)); - } - options->not_cmp=1; - goto out; - } - - /* Renew type in argdata to pass into diff(). - * For recursive call, argdata.is_same_trgobj is already - * set from initial call, so don't reset here */ - argdata->type = linkinfo1.trg_type; - - nfound = diff(file1_id, path1, - file2_id, path2, - options, argdata); - } } /* end if */ else { @@ -2172,7 +1998,7 @@ hsize_t diff(hid_t file1_id, default: if(options->m_verbose) parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(argdata->type) ); + path1, path2, get_type(object_type) ); options->not_cmp = 1; break; } diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 1ff4402..6985b68 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -28,7 +28,7 @@ * as it doesn't require interface change. *------------------------------------------------------------------------*/ typedef struct { - h5trav_type_t type; + h5trav_type_t type[2]; hbool_t is_same_trgobj; } diff_args_t; /*------------------------------------------------------------------------- diff --git a/tools/misc/h5cc.in b/tools/misc/h5cc.in index a1421a2..233c80a 100755..100644 --- a/tools/misc/h5cc.in +++ b/tools/misc/h5cc.in @@ -220,7 +220,7 @@ for arg in $@ ; do get_output_file="yes" fi ;; - -E|-M) + -E|-M|-MT) allargs="$allargs $arg" compile_args="$compile_args $arg" dash_c="yes" diff --git a/tools/misc/h5redeploy.in b/tools/misc/h5redeploy.in index ae79b70..ae79b70 100755..100644 --- a/tools/misc/h5redeploy.in +++ b/tools/misc/h5redeploy.in |