diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-01-26 19:29:22 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-01-26 19:29:22 (GMT) |
commit | 120350c39588d57d6b89bd99569a7fa34b4de59f (patch) | |
tree | dda9cdb9248d698832c0bd25425029634cfd2d7e /tools/lib/h5diff_dset.c | |
parent | 0682bfceb764bd4f4b4fb61695ca8d99440f39b1 (diff) | |
download | hdf5-120350c39588d57d6b89bd99569a7fa34b4de59f.zip hdf5-120350c39588d57d6b89bd99569a7fa34b4de59f.tar.gz hdf5-120350c39588d57d6b89bd99569a7fa34b4de59f.tar.bz2 |
[svn-r16348] #1368 (E1) h5diff: implement "not comparable" messages. Implemented RFC. The new option is <-c, --compare List objects that are not comparable>
added some test cases
tested: windows, linux
Diffstat (limited to 'tools/lib/h5diff_dset.c')
-rw-r--r-- | tools/lib/h5diff_dset.c | 123 |
1 files changed, 76 insertions, 47 deletions
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 212f089..d36c65c 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -44,7 +44,7 @@ hsize_t diff_dataset( hid_t file1_id, hid_t dcpl1 = -1; hid_t dcpl2 = -1; hsize_t nfound = 0; - + /*------------------------------------------------------------------------- * open the handles *------------------------------------------------------------------------- @@ -102,7 +102,8 @@ hsize_t diff_dataset( hid_t file1_id, H5Dclose(did2); /* enable error reporting */ } H5E_END_TRY; - + + return nfound; error: @@ -206,7 +207,7 @@ hsize_t diff_datasetid( hid_t did1, hsize_t storage_size1; hsize_t storage_size2; hsize_t nfound=0; /* number of differences found */ - int cmp=1; /* do diff or not */ + int can_compare=1; /* do diff or not */ void *buf1=NULL; void *buf2=NULL; void *sm_buf1=NULL; @@ -265,9 +266,9 @@ hsize_t diff_datasetid( hid_t did1, if (storage_size1==0 || storage_size2==0) { - if (options->m_verbose && obj1_name && obj2_name) + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) parallel_print("<%s> or <%s> are empty datasets\n", obj1_name, obj2_name); - cmp=0; + can_compare=0; options->not_cmp=1; } @@ -288,8 +289,7 @@ hsize_t diff_datasetid( hid_t did1, obj2_name, options)!=1) { - cmp=0; - options->not_cmp=1; + can_compare=0; } /*------------------------------------------------------------------------- @@ -314,12 +314,13 @@ hsize_t diff_datasetid( hid_t did1, sign2=H5Tget_sign(m_tid2); if ( sign1 != sign2 ) { - if (options->m_verbose && obj1_name) { - parallel_print("Comparison not supported: <%s> has sign %s ", obj1_name, get_sign(sign1)); + if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) + { + parallel_print("<%s> has sign %s ", obj1_name, get_sign(sign1)); parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); } - cmp=0; + can_compare=0; options->not_cmp=1; } @@ -327,7 +328,7 @@ hsize_t diff_datasetid( hid_t did1, * only attempt to compare if possible *------------------------------------------------------------------------- */ - if (cmp) + if (can_compare ) /* it is possible to compare */ { /*------------------------------------------------------------------------- @@ -543,7 +544,7 @@ hsize_t diff_datasetid( hid_t did1, } } /* hyperslab read */ - }/*cmp*/ + }/*can_compare*/ /*------------------------------------------------------------------------- * compare attributes @@ -669,6 +670,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ int maxdim_diff=0; /* maximum dimensions are different */ int dim_diff=0; /* current dimensions are different */ int i; + int can_compare = 1; /* return value */ /*------------------------------------------------------------------------- * check for the same class @@ -683,13 +685,15 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( tclass1 != tclass2 ) { - if (options->m_verbose && obj1_name) + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { - printf("Comparison not possible: <%s> is of class %s and <%s> is of class %s\n", + parallel_print("<%s> is of class %s and <%s> is of class %s\n", obj1_name, get_class(tclass1), obj2_name, get_class(tclass2) ); } - return 0; + can_compare = 0; + options->not_cmp = 1; + return can_compare; } /*------------------------------------------------------------------------- @@ -714,10 +718,16 @@ int diff_can_type( hid_t f_tid1, /* file data type */ break; default: /*H5T_TIME */ - if (options->m_verbose && obj1_name ) - printf("Comparison not supported: <%s> and <%s> are of class %s\n", - obj1_name,obj2_name,get_class(tclass2) ); - return 0; + + + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) + { + parallel_print("<%s> and <%s> are of class %s\n", + obj1_name,obj2_name,get_class(tclass2) ); + } + can_compare = 0; + options->not_cmp = 1; + return can_compare; } /*------------------------------------------------------------------------- @@ -725,21 +735,26 @@ int diff_can_type( hid_t f_tid1, /* file data type */ *------------------------------------------------------------------------- */ - if ( (H5Tequal(f_tid1, f_tid2)==0) && options->m_verbose && obj1_name) + if ( (H5Tequal(f_tid1, f_tid2)==0) && + (options->m_verbose) && obj1_name && obj2_name) { H5T_class_t cl = H5Tget_class(f_tid1); - - printf("Warning: different storage datatype\n"); + + + parallel_print("Warning: different storage datatype\n"); if ( cl == H5T_INTEGER || cl == H5T_FLOAT ) { - printf("<%s> has file datatype ", obj1_name); + parallel_print("<%s> has file datatype ", obj1_name); print_type(f_tid1); - printf("\n"); - printf("<%s> has file datatype ", obj2_name); + parallel_print("\n"); + parallel_print("<%s> has file datatype ", obj2_name); print_type(f_tid2); - printf("\n"); + parallel_print("\n"); } + + + } /*------------------------------------------------------------------------- @@ -749,18 +764,23 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( rank1 != rank2 ) { - if (options->m_verbose && obj1_name) { - printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1); + + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) + { + parallel_print("<%s> has rank %d, dimensions ", obj1_name, rank1); print_dimensions(rank1,dims1); - printf(", max dimensions "); + parallel_print(", max dimensions "); print_dimensions(rank1,maxdim1); - printf("\n" ); - printf("<%s> has rank %d, dimensions ", obj2_name, rank2); + parallel_print("\n" ); + parallel_print("<%s> has rank %d, dimensions ", obj2_name, rank2); print_dimensions(rank2,dims2); - printf(", max dimensions "); + parallel_print(", max dimensions "); print_dimensions(rank2,maxdim2); } - return 0; + + can_compare = 0; + options->not_cmp = 1; + return can_compare; } /*------------------------------------------------------------------------- @@ -787,20 +807,29 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if (dim_diff==1) { - if (options->m_verbose && obj1_name) { - printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1); + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) + { + parallel_print("<%s> has rank %d, dimensions ", obj1_name, rank1); print_dimensions(rank1,dims1); - if (maxdim1 && maxdim2) { - printf(", max dimensions "); + if (maxdim1 && maxdim2) + { + parallel_print(", max dimensions "); print_dimensions(rank1,maxdim1); - printf("\n" ); - printf("<%s> has rank %d, dimensions ", obj2_name, rank2); + parallel_print("\n" ); + parallel_print("<%s> has rank %d, dimensions ", obj2_name, rank2); print_dimensions(rank2,dims2); - printf(", max dimensions "); + parallel_print(", max dimensions "); print_dimensions(rank2,maxdim2); } } - return 0; + + + can_compare = 0; + options->not_cmp = 1; + return can_compare; + + + } /*------------------------------------------------------------------------- @@ -810,17 +839,17 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name ) { if (options->m_verbose) { - printf( "Warning: different maximum dimensions\n"); - printf("<%s> has max dimensions ", obj1_name); + parallel_print( "Warning: different maximum dimensions\n"); + parallel_print("<%s> has max dimensions ", obj1_name); print_dimensions(rank1,maxdim1); - printf("\n"); - printf("<%s> has max dimensions ", obj2_name); + parallel_print("\n"); + parallel_print("<%s> has max dimensions ", obj2_name); print_dimensions(rank2,maxdim2); - printf("\n"); + parallel_print("\n"); } } - return 1; + return can_compare; } |