[svn-r21396] Purpose:

HDFFV-7693 - h5diff produces different behavior between versions: 1.8.3 and 1.8.6

Description:
    There were two issues on this. 
    One was not displaying all the comparable objects if non-comparable 
    object/attribute exist and compared before comparables ones. This issue
    occurred after 1.8.4 release. This is the issue from user.
    The other issue was not displaying all the comparable attributes, 
    if non-comparable object/attribute exist and compared ahead. This issue 
    were exist even before 1.8.4 release. So it's possible some attribute 
    comparison may have not displayed correctly in the past, if non-comparable 
    data were exist in common object.
    Fixed h5diff to display all the comparable object and attribute regardless 
    of non-comparables. 

Tested:
 jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Cmake (jam, Windows)
This commit is contained in:
Jonathan Kim 2011-09-16 14:29:03 -05:00
parent 35d9b34621
commit 86faf0b302
29 changed files with 313 additions and 40 deletions

View File

@ -1794,6 +1794,9 @@
./tools/h5diff/testfiles/h5diff_206.txt
./tools/h5diff/testfiles/h5diff_207.txt
./tools/h5diff/testfiles/h5diff_208.txt
./tools/h5diff/testfiles/h5diff_220.txt
./tools/h5diff/testfiles/h5diff_221.txt
./tools/h5diff/testfiles/h5diff_222.txt
./tools/h5diff/testfiles/h5diff_300.txt
./tools/h5diff/testfiles/h5diff_400.txt
./tools/h5diff/testfiles/h5diff_401.txt
@ -1896,6 +1899,8 @@
./tools/h5diff/testfiles/h5diff_enum_invalid_values.h5
./tools/h5diff/testfiles/compounds_array_vlen1.h5
./tools/h5diff/testfiles/compounds_array_vlen2.h5
./tools/h5diff/testfiles/non_comparables1.h
./tools/h5diff/testfiles/non_comparables2.h
#test files for h5repack
./tools/h5repack/testfiles/h5repack_fill.h5

View File

@ -573,6 +573,8 @@ Bug Fixes since HDF5-1.8.0 release
Tools
-----
- Fixed h5diff to display all the comparable object and attribute
regardless of non-comparables. HDFFV-7693 (JKM 09/16/2011)
- Fixed h5repack to update values of references(object and region) of
attributes in h5repack for 1) references, 2) ARRAY of references,
3) VLEN of references, and 4) COMPOUND of references.

View File

@ -79,6 +79,9 @@ IF (BUILD_TESTING)
h5diff_206.txt
h5diff_207.txt
h5diff_208.txt
h5diff_220.txt
h5diff_221.txt
h5diff_222.txt
h5diff_21.txt
h5diff_22.txt
h5diff_23.txt
@ -248,6 +251,8 @@ IF (BUILD_TESTING)
h5diff_attr_v_level2.h5
compounds_array_vlen1.h5
compounds_array_vlen2.h5
non_comparables1.h5
non_comparables2.h5
)
FOREACH (txt_file ${HDF5_REFERENCE_FILES})
@ -551,6 +556,12 @@ IF (BUILD_TESTING)
h5diff_207.out.err
h5diff_208.out
h5diff_208.out.err
h5diff_220.out
h5diff_220.out.err
h5diff_221.out
h5diff_221.out.err
h5diff_222.out
h5diff_222.out.err
h5diff_21.out
h5diff_21.out.err
h5diff_22.out
@ -1115,6 +1126,18 @@ ADD_H5_TEST (h5diff_207 0 -c ${FILE2} ${FILE2} g2/dset8 g2/dset9)
# not comparable in dataspace of zero dimension size
ADD_H5_TEST (h5diff_208 0 -c ${FILE19} ${FILE20})
# non-comparable dataset with comparable attribute, and other comparable datasets.
# All the rest comparables should display differences.
ADD_H5_TEST (h5diff_220 1 -c non_comparables1.h5 non_comparables2.h5 /g1)
# comparable dataset with non-comparable attribute and other comparable attributes.
# All the rest comparables should display differences.
ADD_H5_TEST (h5diff_221 1 -c non_comparables1.h5 non_comparables2.h5 /g2)
# entire file
# All the rest comparables should display differences
ADD_H5_TEST (h5diff_222 1 -c non_comparables1.h5 non_comparables2.h5)
# ##############################################################################
# # Links compare without --follow-symlinks nor --no-dangling-links
# ##############################################################################

View File

@ -321,7 +321,10 @@ void parse_command_line(int argc,
printf("--------------------------------\n");
printf("Some objects are not comparable\n");
printf("--------------------------------\n");
printf("Use -c for a list of objects.\n");
if (options->m_verbose)
printf("Use -c for a list of objects without details of differences.\n");
else
printf("Use -c for a list of objects.\n");
}

View File

@ -80,6 +80,9 @@
/* file with container types (array,vlen) with multiple compounds */
#define COMPS_COMPLEX1 "compounds_array_vlen1.h5"
#define COMPS_COMPLEX2 "compounds_array_vlen2.h5"
/* non-comparable dataset and attribute */
#define NON_COMPARBLES1 "non_comparables1.h5"
#define NON_COMPARBLES2 "non_comparables2.h5"
#define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */
#define STR_SIZE 3
@ -141,6 +144,7 @@ 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);
/* 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);
@ -229,6 +233,14 @@ int main(void)
test_comps_array_vlen(COMPS_COMPLEX2,"dset3", "attr3", 5, 0);
test_comps_vlen_arry(COMPS_COMPLEX2,"dset4", "attr4", 5, 0);
/*-------------------------------------------------
* Create test files with non-comparable dataset and attributes with
* comparable datasets and attributes. All the comparables should display
* differences.
*/
test_non_comparables(NON_COMPARBLES1,0);
test_non_comparables(NON_COMPARBLES2,5);
return 0;
}
@ -4668,6 +4680,187 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch
}
/*-------------------------------------------------------------------------
* Function: test_non_comparables
*
* Purpose:
* Create test files with non-comparable dataset and attributes with
* comparable datasets and attributes. All the comparables should display
* differences.
*
*-------------------------------------------------------------------------*/
#define DIM_ARRY 3
static void test_non_comparables (const char * fname, int make_diffs)
{
hid_t fid=0;
hid_t gid1=0;
hid_t gid2=0;
hid_t did1=0;
hid_t did2=0;
hid_t sid1=0;
hid_t tid_dset1=0;
hid_t tid_attr1=0;
hsize_t dims1[1] = {DIM_ARRY};
int data1[DIM_ARRY] = {0,0,0};
int data2[DIM_ARRY] = {1,1,1};
char data1_str[DIM_ARRY][STR_SIZE]= {"ab","cd","ef"};
herr_t status = SUCCEED;
int i;
void *dset_data_ptr1=NULL;
void *dset_data_ptr2=NULL;
void *dset_data_ptr3=NULL;
void *attr_data_ptr1=NULL;
void *attr_data_ptr2=NULL;
void *attr_data_ptr3=NULL;
/* init */
tid_dset1=H5Tcopy(H5T_NATIVE_INT);
dset_data_ptr1=(int*)&data1;
dset_data_ptr2=(int*)&data1;
dset_data_ptr3=(int*)&data1;
tid_attr1=H5Tcopy(H5T_NATIVE_INT);
attr_data_ptr1=(int*)&data1;
attr_data_ptr3=(int*)&data1;
if (make_diffs)
{
/* ------------
* group1 */
tid_dset1=H5Tcopy(H5T_C_S1);
H5Tset_size(tid_dset1, (size_t)STR_SIZE);
dset_data_ptr1=(char*)&data1_str;
dset_data_ptr2=(int*)&data2;
attr_data_ptr1=(int*)&data2;
/* -----------
* group2
*/
dset_data_ptr3=(int*)&data2;
/* attr1 */
tid_attr1=H5Tcopy(H5T_C_S1);
H5Tset_size(tid_attr1, (size_t)STR_SIZE);
attr_data_ptr2=(char*)&data1_str;
/* attr2 */
attr_data_ptr3=(int*)&data2;
}
/*-----------------------------------------------------------------------
* Create file(s)
*------------------------------------------------------------------------*/
fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid < 0)
{
fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname);
status = FAIL;
goto out;
}
/*-----------------------------------------------------------------------
* Groups
*------------------------------------------------------------------------*/
gid1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (gid1 < 0)
{
fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname);
status = FAIL;
goto out;
}
gid2 = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (gid2 < 0)
{
fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname);
status = FAIL;
goto out;
}
/*-----------------------------------------------------------------------
* Datasets in /g1
*------------------------------------------------------------------------*/
if((sid1 = H5Screate_simple(1, dims1, NULL)) < 0)
goto out;
/* dset1 */
if((did1 = H5Dcreate2(gid1, "dset1", tid_dset1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
{
fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1");
status = FAIL;
goto out;
}
if(H5Dwrite(did1, tid_dset1, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data_ptr1) < 0)
{
fprintf(stderr, "Error: %s> H5Dwrite failed.\n", "dset1");
status = FAIL;
goto out;
}
write_attr(did1,1,dims1,"attr", H5T_NATIVE_INT, attr_data_ptr1);
/* dset2 */
status = write_dset(gid1, 1, dims1,"dset2", H5T_NATIVE_INT, dset_data_ptr2);
if (status == FAIL)
{
fprintf(stderr, "Error: %s> write_dset failed\n", fname);
goto out;
}
/*-----------------------------------------------------------------------
* Datasets in /g2
*------------------------------------------------------------------------*/
/* dset1 */
if((did2 = H5Dcreate2(gid2, "dset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
{
fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1");
status = FAIL;
goto out;
}
if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data_ptr3) < 0)
{
fprintf(stderr, "Error: %s> H5Dwrite failed.\n", "dset1");
status = FAIL;
goto out;
}
/* attr1 */
write_attr(did2,1,dims1,"attr1", tid_attr1, attr_data_ptr2);
/* attr2 */
write_attr(did2,1,dims1,"attr2", H5T_NATIVE_INT, attr_data_ptr3);
/* dset2 */
status = write_dset(gid2, 1, dims1,"dset2", H5T_NATIVE_INT, dset_data_ptr3);
if (status == FAIL)
{
fprintf(stderr, "Error: %s> write_dset failed\n", fname);
goto out;
}
out:
/*-----------------------------------------------------------------------
* Close IDs
*-----------------------------------------------------------------------*/
if(fid)
H5Fclose(fid);
if(gid1)
H5Gclose(gid1);
if(gid2)
H5Gclose(gid2);
if(did1)
H5Dclose(did1);
if(did2)
H5Dclose(did2);
if(sid1)
H5Sclose(sid1);
if(tid_dset1)
H5Tclose(tid_dset1);
if(tid_attr1)
H5Tclose(tid_attr1);
}
/*-------------------------------------------------------------------------
* Function: write_attr_in
*

View File

@ -2,5 +2,5 @@
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -1,3 +1,2 @@
Not comparable: </g2/dset2> is of class H5T_FLOAT and </g2/dset3> is of class H5T_INTEGER
Not comparable: </g2/dset2> has sign H5T_SGN_ERROR and </g2/dset3> has sign H5T_SGN_2
EXIT CODE: 0

View File

@ -1,4 +1,3 @@
Not comparable: </g2/dset5> has rank 2, dimensions [2x2], max dimensions [2x2]
and </g2/dset6> has rank 2, dimensions [3x2], max dimensions [3x2]
Not comparable: </g2/dset5> has sign H5T_SGN_2 and </g2/dset6> has sign H5T_SGN_NONE
EXIT CODE: 0

View File

@ -2,5 +2,5 @@
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -2,5 +2,5 @@
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -0,0 +1,8 @@
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
dataset: </g1/dset1> and </g1/dset1>
3 differences found
dataset: </g1/dset2> and </g1/dset2>
3 differences found
EXIT CODE: 1

View File

@ -0,0 +1,8 @@
Not comparable: <attr1> is of class H5T_INTEGER and <attr1> is of class H5T_STRING
attribute: <attr2 of </g2/dset1>> and <attr2 of </g2/dset1>>
3 differences found
dataset: </g2/dset1> and </g2/dset1>
6 differences found
dataset: </g2/dset2> and </g2/dset2>
3 differences found
EXIT CODE: 1

View File

@ -0,0 +1,15 @@
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
dataset: </g1/dset1> and </g1/dset1>
3 differences found
dataset: </g1/dset2> and </g1/dset2>
3 differences found
Not comparable: <attr1> is of class H5T_INTEGER and <attr1> is of class H5T_STRING
attribute: <attr2 of </g2/dset1>> and <attr2 of </g2/dset1>>
3 differences found
dataset: </g2/dset1> and </g2/dset1>
6 differences found
dataset: </g2/dset2> and </g2/dset2>
3 differences found
EXIT CODE: 1

View File

@ -2,5 +2,5 @@
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -2,5 +2,5 @@
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -2,5 +2,5 @@
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -7,5 +7,5 @@ Not comparable: </dset7a> has sign H5T_SGN_2 and </dset7b> has sign H5T_SGN_NONE
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 0

View File

@ -2028,5 +2028,5 @@ position vlen3D of </g1> vlen3D of </g1> difference
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 1

View File

@ -2034,5 +2034,5 @@ position vlen3D of </g1> vlen3D of </g1> difference
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 1

View File

@ -2133,5 +2133,5 @@ position vlen3D of </g1> vlen3D of </g1> difference
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 1

View File

@ -2034,5 +2034,5 @@ position vlen3D of </g1> vlen3D of </g1> difference
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 1

View File

@ -2133,5 +2133,5 @@ position vlen3D of </g1> vlen3D of </g1> difference
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 1

View File

@ -877,5 +877,5 @@ point #4 (2,8) (1,7)
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
Use -c for a list of objects without details of differences.
EXIT CODE: 1

Binary file not shown.

Binary file not shown.

View File

@ -117,6 +117,8 @@ $SRC_H5DIFF_TESTFILES/compounds_array_vlen2.h5
$SRC_H5DIFF_TESTFILES/h5diff_attr_v_level1.h5
$SRC_H5DIFF_TESTFILES/h5diff_attr_v_level2.h5
$SRC_H5DIFF_TESTFILES/h5diff_enum_invalid_values.h5
$SRC_H5DIFF_TESTFILES/non_comparables1.h5
$SRC_H5DIFF_TESTFILES/non_comparables2.h5
"
LIST_OTHER_TEST_FILES="
@ -149,6 +151,9 @@ $SRC_H5DIFF_TESTFILES/h5diff_205.txt
$SRC_H5DIFF_TESTFILES/h5diff_206.txt
$SRC_H5DIFF_TESTFILES/h5diff_207.txt
$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_21.txt
$SRC_H5DIFF_TESTFILES/h5diff_22.txt
$SRC_H5DIFF_TESTFILES/h5diff_23.txt
@ -794,6 +799,18 @@ TOOLTEST h5diff_207.txt -c h5diff_basic2.h5 h5diff_basic2.h5 g2/dset8 g2/dset9
# not comparable in dataspace of zero dimension size
TOOLTEST h5diff_208.txt -c h5diff_dset_zero_dim_size1.h5 h5diff_dset_zero_dim_size2.h5
# non-comparable dataset with comparable attribute, and other comparable datasets.
# All the comparables should display differences.
TOOLTEST h5diff_220.txt -c non_comparables1.h5 non_comparables2.h5 /g1
# comparable dataset with non-comparable attribute and other comparable attributes.
# All the comparables should display differences.
TOOLTEST h5diff_221.txt -c non_comparables1.h5 non_comparables2.h5 /g2
# entire file
# All the comparables should display differences.
TOOLTEST h5diff_222.txt -c non_comparables1.h5 non_comparables2.h5
# ##############################################################################
# # Links compare without --follow-symlinks nor --no-dangling-links
# ##############################################################################

View File

@ -1952,8 +1952,8 @@ hsize_t diff(hid_t file1_id,
else
{
nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
/* print info if compatible and difference found */
if (!options->not_cmp && nfound)
/* print info if difference found */
if (nfound)
{
do_print_objname("dataset", path1, path2, options);
print_found(nfound);

View File

@ -380,9 +380,8 @@ hsize_t diff_attr(hid_t loc1_id,
*----------------------------------------------------------------------
*/
if(msize1 != msize2 ||
diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1,
dims2, NULL, NULL, name1, name2, options, 0) != 1)
if( diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2,
NULL, NULL, name1, name2, options, 0) != 1 )
{
if(H5Tclose(ftype1_id) < 0)
goto error;
@ -452,8 +451,8 @@ hsize_t diff_attr(hid_t loc1_id,
nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
options, np1, np2, mtype1_id, attr1_id, attr2_id);
/* not comparable, no display the different number */
if(!options->not_cmp && nfound) {
/* print info if compatible and difference found */
if(nfound) {
do_print_attrname("attribute", np1, np2);
print_found(nfound);
} /* end if */

View File

@ -313,19 +313,21 @@ hsize_t diff_datasetid( hid_t did1,
* check for different signed/unsigned types
*-------------------------------------------------------------------------
*/
sign1=H5Tget_sign(m_tid1);
sign2=H5Tget_sign(m_tid2);
if ( sign1 != sign2 )
if (can_compare)
{
if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
sign1=H5Tget_sign(m_tid1);
sign2=H5Tget_sign(m_tid2);
if ( sign1 != sign2 )
{
parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1));
parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
{
parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1));
parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
}
can_compare=0;
options->not_cmp=1;
}
can_compare=0;
options->not_cmp=1;
}
/* Check if type is either VLEN-data or VLEN-string to reclaim any
@ -333,16 +335,16 @@ hsize_t diff_datasetid( hid_t did1,
if( TRUE == h5tools_detect_vlen(m_tid1) )
vl_data = TRUE;
/*-------------------------------------------------------------------------
/*------------------------------------------------------------------------
* only attempt to compare if possible
*-------------------------------------------------------------------------
*/
if(can_compare) /* it is possible to compare */
{
/*-------------------------------------------------------------------------
/*-----------------------------------------------------------------
* get number of elements
*-------------------------------------------------------------------------
*------------------------------------------------------------------
*/
nelmts1 = 1;
for(i = 0; i < rank1; i++)
@ -354,9 +356,9 @@ hsize_t diff_datasetid( hid_t did1,
HDassert(nelmts1 == nelmts2);
/*-------------------------------------------------------------------------
/*-----------------------------------------------------------------
* "upgrade" the smaller memory size
*-------------------------------------------------------------------------
*------------------------------------------------------------------
*/
if(m_size1 != m_size2) {
@ -386,9 +388,9 @@ hsize_t diff_datasetid( hid_t did1,
name2 = diff_basename(obj2_name);
/*-------------------------------------------------------------------------
/*----------------------------------------------------------------
* read/compare
*-------------------------------------------------------------------------
*-----------------------------------------------------------------
*/
need = (size_t)(nelmts1 * m_size1); /* bytes needed */
if(need < H5TOOLS_MALLOCSIZE) {