[svn-r16461] Bug fix: for compound types, the not comparable test for members was not done

Solution: for compound types, recursively apply that check
Two new cases are added
1) the compound type has a different number of members. Message printed is
<obj1> has X members <obj2> has Y members
Where X and Y are the number of members of each compound type being compared
2) the compound type has not comparable types (for example a double and an int at the same index)
In this case the message
Comparison not possible: object1 is of class1 and object2 is of class2
Is replaced with
Comparison not possible: object1 has a  class1 and object2 has a  class2
Modified the test generator program to have these 2  cases
Added a shell run for these 2  cases


Tested: windows, h5committest
This commit is contained in:
Pedro Vicente Nunes 2009-02-11 10:57:25 -05:00
parent d4ea5fbfb2
commit 96a0892ba8
11 changed files with 175 additions and 9 deletions

View File

@ -1478,6 +1478,8 @@
./tools/h5diff/testfiles/h5diff_203.txt ./tools/h5diff/testfiles/h5diff_203.txt
./tools/h5diff/testfiles/h5diff_204.txt ./tools/h5diff/testfiles/h5diff_204.txt
./tools/h5diff/testfiles/h5diff_205.txt ./tools/h5diff/testfiles/h5diff_205.txt
./tools/h5diff/testfiles/h5diff_206.txt
./tools/h5diff/testfiles/h5diff_207.txt
./tools/h5diff/testfiles/h5diff_basic1.h5 ./tools/h5diff/testfiles/h5diff_basic1.h5

View File

@ -331,12 +331,37 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3)
/* not comparable objects */ /* not comparable objects */
{ {
typedef struct cmp1_t
{
double d;
int i;
} cmp1_t;
typedef struct cmp2_t
{
int i;
double d;
} cmp2_t;
typedef struct cmp3_t
{
int i;
} cmp3_t;
double data2[6] = {0,0,0,0,0,0}; double data2[6] = {0,0,0,0,0,0};
int data3[6] = {0,0,0,0,0,0}; int data3[6] = {0,0,0,0,0,0};
int data4[3][2] = {{0,0},{0,0},{0,0}}; int data4[3][2] = {{0,0},{0,0},{0,0}};
hsize_t dims3[2] = { 2,2 };
int data5[2][2] = {{0,0},{0,0}}; int data5[2][2] = {{0,0},{0,0}};
unsigned int data6[3][2] = {{0,0},{0,0},{0,0}}; unsigned int data6[3][2] = {{0,0},{0,0},{0,0}};
cmp1_t data7[1] = {1,2};
cmp2_t data8[1] = {1,2};
hsize_t dims3[2] = { 2,2 };
hsize_t dims4[1] = { 1 };
size_t type_size;
hid_t tid;
write_dset(gid3,1,dims1,"dset1",H5T_NATIVE_DOUBLE,NULL); write_dset(gid3,1,dims1,"dset1",H5T_NATIVE_DOUBLE,NULL);
write_dset(gid3,1,dims1,"dset2",H5T_NATIVE_DOUBLE,data2); write_dset(gid3,1,dims1,"dset2",H5T_NATIVE_DOUBLE,data2);
@ -344,7 +369,28 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3)
write_dset(gid3,2,dims2,"dset4",H5T_NATIVE_INT,data4); write_dset(gid3,2,dims2,"dset4",H5T_NATIVE_INT,data4);
write_dset(gid3,2,dims3,"dset5",H5T_NATIVE_INT,data5); write_dset(gid3,2,dims3,"dset5",H5T_NATIVE_INT,data5);
write_dset(gid3,2,dims2,"dset6",H5T_NATIVE_UINT,data6); write_dset(gid3,2,dims2,"dset6",H5T_NATIVE_UINT,data6);
/* case of compound with different type members */
type_size = sizeof( cmp1_t );
tid = H5Tcreate (H5T_COMPOUND, type_size );
H5Tinsert(tid, "d", HOFFSET( cmp1_t, d ), H5T_NATIVE_DOUBLE );
H5Tinsert(tid, "i", HOFFSET( cmp1_t, i ), H5T_NATIVE_INT );
write_dset(gid3,1,dims4,"dset7",tid,data7);
H5Tclose(tid);
type_size = sizeof( cmp2_t );
tid = H5Tcreate (H5T_COMPOUND, type_size );
H5Tinsert(tid, "i", HOFFSET( cmp2_t, i ), H5T_NATIVE_INT );
H5Tinsert(tid, "d", HOFFSET( cmp2_t, d ), H5T_NATIVE_DOUBLE );
write_dset(gid3,1,dims4,"dset8",tid,data8);
H5Tclose(tid);
/* case of compound with different number of members */
type_size = sizeof( cmp3_t );
tid = H5Tcreate (H5T_COMPOUND, type_size );
H5Tinsert(tid, "i", HOFFSET( cmp2_t, i ), H5T_NATIVE_INT );
write_dset(gid3,1,dims4,"dset9",tid,NULL);
H5Tclose(tid);
} }

View File

@ -29,6 +29,9 @@ file1 file2
x /g2/dset4 x /g2/dset4
x /g2/dset5 x /g2/dset5
x /g2/dset6 x /g2/dset6
x /g2/dset7
x /g2/dset8
x /g2/dset9
group : </> and </> group : </> and </>
0 differences found 0 differences found

View File

@ -0,0 +1 @@
</g2/dset7> has a class H5T_FLOAT and </g2/dset8> has a class H5T_INTEGER

View File

@ -0,0 +1,2 @@
</g2/dset8> or </g2/dset9> are empty datasets
</g2/dset8> has 2 members </g2/dset9> has 1 members

View File

@ -13,6 +13,9 @@ file1 file2
x x /g2/dset4 x x /g2/dset4
x x /g2/dset5 x x /g2/dset5
x x /g2/dset6 x x /g2/dset6
x x /g2/dset7
x x /g2/dset8
x x /g2/dset9
group : </> and </> group : </> and </>
0 differences found 0 differences found
@ -39,6 +42,13 @@ dataset: </g2/dset5> and </g2/dset5>
0 differences found 0 differences found
dataset: </g2/dset6> and </g2/dset6> dataset: </g2/dset6> and </g2/dset6>
0 differences found 0 differences found
dataset: </g2/dset7> and </g2/dset7>
0 differences found
dataset: </g2/dset8> and </g2/dset8>
0 differences found
dataset: </g2/dset9> and </g2/dset9>
</g2/dset9> or </g2/dset9> are empty datasets
0 differences found
-------------------------------- --------------------------------
Some objects are not comparable Some objects are not comparable
-------------------------------- --------------------------------

View File

@ -598,6 +598,16 @@ TESTING $H5DIFF -c $SRCFILE2 $SRCFILE2 g2/dset5 g2/dset6
TOOLTEST h5diff_205.txt -c $FILE2 $FILE2 g2/dset5 g2/dset6 TOOLTEST h5diff_205.txt -c $FILE2 $FILE2 g2/dset5 g2/dset6
# not comparable in compound
TESTING $H5DIFF -c $SRCFILE2 $SRCFILE2 g2/dset7 g2/dset8
TOOLTEST h5diff_206.txt -c $FILE2 $FILE2 g2/dset7 g2/dset8
TESTING $H5DIFF -c $SRCFILE2 $SRCFILE2 g2/dset8 g2/dset9
TOOLTEST h5diff_207.txt -c $FILE2 $FILE2 g2/dset8 g2/dset9
# ############################################################################## # ##############################################################################
# # END # # END
# ############################################################################## # ##############################################################################

View File

@ -134,7 +134,8 @@ int diff_can_type( hid_t f_type1, /* file data type */
hsize_t *maxdim2, hsize_t *maxdim2,
const char *obj1_name, const char *obj1_name,
const char *obj2_name, const char *obj2_name,
diff_opt_t *options ); diff_opt_t *options,
int is_compound);
hsize_t diff_attr(hid_t loc1_id, hsize_t diff_attr(hid_t loc1_id,

View File

@ -147,7 +147,8 @@ hsize_t diff_attr(hid_t loc1_id,
NULL, NULL,
name1, name1,
name2, name2,
options)!=1) options,
0)!=1)
{ {

View File

@ -287,7 +287,8 @@ hsize_t diff_datasetid( hid_t did1,
maxdim2, maxdim2,
obj1_name, obj1_name,
obj2_name, obj2_name,
options)!=1) options,
0)!=1)
{ {
can_compare=0; can_compare=0;
} }
@ -661,7 +662,8 @@ int diff_can_type( hid_t f_tid1, /* file data type */
hsize_t *maxdim2, hsize_t *maxdim2,
const char *obj1_name, const char *obj1_name,
const char *obj2_name, const char *obj2_name,
diff_opt_t *options ) diff_opt_t *options,
int is_compound)
{ {
@ -685,12 +687,32 @@ int diff_can_type( hid_t f_tid1, /* file data type */
if ( tclass1 != tclass2 ) if ( tclass1 != tclass2 )
{ {
if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
{ {
parallel_print("<%s> is of class %s and <%s> is of class %s\n",
obj1_name, get_class(tclass1), if ( is_compound )
obj2_name, get_class(tclass2) ); {
parallel_print("<%s> has a class %s and <%s> has a class %s\n",
obj1_name, get_class(tclass1),
obj2_name, get_class(tclass2) );
}
else
{
parallel_print("<%s> is of class %s and <%s> is of class %s\n",
obj1_name, get_class(tclass1),
obj2_name, get_class(tclass2) );
}
} }
can_compare = 0; can_compare = 0;
options->not_cmp = 1; options->not_cmp = 1;
return can_compare; return can_compare;
@ -850,6 +872,74 @@ int diff_can_type( hid_t f_tid1, /* file data type */
parallel_print("\n"); parallel_print("\n");
} }
} }
if ( tclass1 == H5T_COMPOUND )
{
int nmembs1;
int nmembs2;
int j;
hid_t memb_type1;
hid_t memb_type2;
nmembs1 = H5Tget_nmembers(f_tid1);
nmembs2 = H5Tget_nmembers(f_tid2);
if ( nmembs1 != nmembs2 )
{
if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
{
parallel_print("<%s> has %d members ", obj1_name, nmembs1);
parallel_print("<%s> has %d members ", obj2_name, nmembs2);
parallel_print("\n");
}
can_compare = 0;
options->not_cmp = 1;
return can_compare;
}
for (j = 0; j < nmembs1; j++)
{
memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j);
memb_type2 = H5Tget_member_type(f_tid2, (unsigned)j);
if (diff_can_type(memb_type1,
memb_type2,
rank1,
rank2,
dims1,
dims2,
maxdim1,
maxdim2,
obj1_name,
obj2_name,
options,
1)!=1)
{
can_compare = 0;
options->not_cmp = 1;
H5Tclose(memb_type1);
H5Tclose(memb_type2);
return can_compare;
}
H5Tclose(memb_type1);
H5Tclose(memb_type2);
}
}
return can_compare; return can_compare;
} }