summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-09-25 15:49:26 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-09-25 15:49:26 (GMT)
commitc439d91f811d91df590996cff2d3162c541bb1cf (patch)
tree2f4d529d110b2cb54bacc823795a38a5fa8bd137 /tools/lib
parentafcf6b7608a2468a6d5b01bad23d427312cf45ae (diff)
downloadhdf5-c439d91f811d91df590996cff2d3162c541bb1cf.zip
hdf5-c439d91f811d91df590996cff2d3162c541bb1cf.tar.gz
hdf5-c439d91f811d91df590996cff2d3162c541bb1cf.tar.bz2
[svn-r12678] bug fix
the number of atribute differences was not added to the total sum of differences
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c4
-rw-r--r--tools/lib/h5diff.h13
-rw-r--r--tools/lib/h5diff_attr.c345
-rw-r--r--tools/lib/h5diff_dset.c2
4 files changed, 187 insertions, 177 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 4fed814..c8d5e1f 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -982,7 +982,7 @@ hsize_t diff (hid_t file1_id,
*-------------------------------------------------------------------------
*/
if (path1)
- diff_attr (type1_id, type2_id, path1, path2, options);
+ nfound += diff_attr (type1_id, type2_id, path1, path2, options);
if (H5Tclose (type1_id) < 0)
goto out;
@@ -1019,7 +1019,7 @@ hsize_t diff (hid_t file1_id,
*-------------------------------------------------------------------------
*/
if (path1)
- diff_attr (grp1_id, grp2_id, path1, path2, options);
+ nfound += diff_attr (grp1_id, grp2_id, path1, path2, options);
if (H5Gclose (grp1_id) < 0)
goto out;
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 7320a63..a01684d 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -138,12 +138,13 @@ int diff_can_type( hid_t f_type1, /* file data type */
diff_opt_t *options );
-int diff_attr(hid_t loc1_id,
- hid_t loc2_id,
- const char *path1,
- const char *path2,
- diff_opt_t *options
- );
+hsize_t
+diff_attr(hid_t loc1_id,
+ hid_t loc2_id,
+ const char *path1,
+ const char *path2,
+ diff_opt_t *options
+ );
/*-------------------------------------------------------------------------
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 785b345..222775e 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -16,6 +16,7 @@
#include "h5diff.h"
#include "H5private.h"
+
/*-------------------------------------------------------------------------
* Function: diff_attr
*
@@ -26,8 +27,7 @@
* loc_id = H5Topen( fid, name);
*
* Return:
- * 0 : no differences found
- * 1 : differences found
+ * number of differences found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -36,20 +36,22 @@
*-------------------------------------------------------------------------
*/
-int diff_attr(hid_t loc1_id,
- hid_t loc2_id,
- const char *path1,
- const char *path2,
- diff_opt_t *options)
+hsize_t
+diff_attr(hid_t loc1_id,
+ hid_t loc2_id,
+ const char *path1,
+ const char *path2,
+ diff_opt_t *options
+ )
{
- hid_t attr1_id=-1; /* attr ID */
- hid_t attr2_id=-1; /* attr ID */
- hid_t space1_id=-1; /* space ID */
- hid_t space2_id=-1; /* space ID */
- hid_t ftype1_id=-1; /* file data type ID */
- hid_t ftype2_id=-1; /* file data type ID */
- hid_t mtype1_id=-1; /* memory data type ID */
- hid_t mtype2_id=-1; /* memory data type ID */
+ hid_t attr1_id; /* attr ID */
+ hid_t attr2_id; /* attr ID */
+ hid_t space1_id; /* space ID */
+ hid_t space2_id; /* space ID */
+ hid_t ftype1_id; /* file data type ID */
+ hid_t ftype2_id; /* file data type ID */
+ hid_t mtype1_id; /* memory data type ID */
+ hid_t mtype2_id; /* memory data type ID */
size_t msize1; /* memory size of memory type */
size_t msize2; /* memory size of memory type */
void *buf1=NULL; /* data buffer */
@@ -64,8 +66,7 @@ int diff_attr(hid_t loc1_id,
char np1[512];
char np2[512];
int n1, n2, i, j;
- int ret=0;
- hsize_t nfound;
+ hsize_t found, nfound=0;
int cmp=1;
if ((n1 = H5Aget_num_attrs(loc1_id))<0)
@@ -74,18 +75,19 @@ int diff_attr(hid_t loc1_id,
goto error;
if (n1!=n2)
- return 1;
+ return nfound;
for ( i = 0; i < n1; i++)
{
+
/* reset buffers for every attribute, we might goto out and call free */
buf1=NULL;
buf2=NULL;
- /*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
+/*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
/* open attribute */
if ((attr1_id = H5Aopen_idx(loc1_id, (unsigned)i))<0)
goto error;
@@ -102,11 +104,10 @@ int diff_attr(hid_t loc1_id,
{
if (options->m_verbose)
{
- parallel_print("Different name for attributes: <%s> and <%s>\n", name1, name2);
+ printf("Different name for attributes: <%s> and <%s>\n", name1, name2);
}
H5Aclose(attr1_id);
H5Aclose(attr2_id);
- ret=1;
continue;
}
@@ -128,168 +129,176 @@ int diff_attr(hid_t loc1_id,
if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
goto error;
- /*-------------------------------------------------------------------------
- * check for comparable TYPE and SPACE
- *-------------------------------------------------------------------------
- */
-
- if (diff_can_type(ftype1_id,
- ftype2_id,
- rank1,
- rank2,
- dims1,
- dims2,
- NULL,
- NULL,
- name1,
- name2,
- options)!=1)
- {
- cmp=0;
- options->not_cmp=1;
- }
- /*-------------------------------------------------------------------------
- * only attempt to compare if possible
- *-------------------------------------------------------------------------
- */
- if (cmp)
- {
- /*-------------------------------------------------------------------------
- * read to memory
- *-------------------------------------------------------------------------
- */
- nelmts1=1;
- for (j=0; j<rank1; j++)
- nelmts1*=dims1[j];
+/*-------------------------------------------------------------------------
+ * check for comparable TYPE and SPACE
+ *-------------------------------------------------------------------------
+ */
- if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
- goto error;
+ if (diff_can_type(ftype1_id,
+ ftype2_id,
+ rank1,
+ rank2,
+ dims1,
+ dims2,
+ NULL,
+ NULL,
+ name1,
+ name2,
+ options)!=1)
+ {
+ cmp=0;
+ options->not_cmp=1;
+ }
- if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
- goto error;
- if ((msize1=H5Tget_size(mtype1_id))==0)
- goto error;
- if ((msize2=H5Tget_size(mtype2_id))==0)
- goto error;
+/*-------------------------------------------------------------------------
+ * only attempt to compare if possible
+ *-------------------------------------------------------------------------
+ */
+ if (cmp)
+ {
- assert(msize1==msize2);
+/*-------------------------------------------------------------------------
+ * read to memory
+ *-------------------------------------------------------------------------
+ */
+ nelmts1=1;
+ for (j=0; j<rank1; j++)
+ nelmts1*=dims1[j];
- buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
- buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
- if ( buf1==NULL || buf2==NULL){
- parallel_print( "cannot read into memory\n" );
+ if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
goto error;
- }
- if (H5Aread(attr1_id,mtype1_id,buf1)<0)
- goto error;
- if (H5Aread(attr2_id,mtype2_id,buf2)<0)
+
+ if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
goto error;
- /* format output string */
- sprintf(np1,"%s of <%s>",name1,path1);
- sprintf(np2,"%s of <%s>",name2,path2);
+ if ((msize1=H5Tget_size(mtype1_id))==0)
+ goto error;
+ if ((msize2=H5Tget_size(mtype2_id))==0)
+ goto error;
- /*-------------------------------------------------------------------------
- * array compare
- *-------------------------------------------------------------------------
- */
+ assert(msize1==msize2);
- /* always print name */
- if (options->m_verbose)
- {
- parallel_print( "Attribute: <%s> and <%s>\n",np1,np2);
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
- print_found(nfound);
+ buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
+ buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
+ if ( buf1==NULL || buf2==NULL){
+ printf( "cannot read into memory\n" );
+ goto error;
+ }
+ if (H5Aread(attr1_id,mtype1_id,buf1)<0)
+ goto error;
+ if (H5Aread(attr2_id,mtype2_id,buf2)<0)
+ goto error;
- }
- /* check first if we have differences */
- else
+
+ /* format output string */
+ sprintf(np1,"%s of <%s>",name1,path1);
+ sprintf(np2,"%s of <%s>",name2,path2);
+
+/*-------------------------------------------------------------------------
+ * array compare
+ *-------------------------------------------------------------------------
+ */
+
+ /* always print name */
+ if (options->m_verbose)
+ {
+ printf( "Attribute: <%s> and <%s>\n",np1,np2);
+ found = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ np1,
+ np2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ print_found(found);
+ nfound += found;
+
+ }
+ /* check first if we have differences */
+ else
+ {
+ if (options->m_quiet==0)
+ {
+ /* shut up temporarily */
+ options->m_quiet=1;
+ found = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ np1,
+ np2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ /* print again */
+ options->m_quiet=0;
+ if (found)
{
- if (options->m_quiet==0)
- {
- /* shut up temporarily */
- options->m_quiet=1;
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
- /* print again */
- options->m_quiet=0;
- if (nfound)
- {
- parallel_print( "Attribute: <%s> and <%s>\n",np1,np2);
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
- print_found(nfound);
- } /*if*/
- } /*if*/
- /* in quiet mode, just count differences */
- else
- {
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
- } /*else quiet */
- } /*else verbose */
+ printf( "Attribute: <%s> and <%s>\n",np1,np2);
+ found = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ np1,
+ np2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ print_found(found);
+ nfound += found;
+ } /*if*/
+ } /*if*/
+ /* in quiet mode, just count differences */
+ else
+ {
+ found = diff_array(buf1,
+ buf2,
+ nelmts1,
+ rank1,
+ dims1,
+ options,
+ np1,
+ np2,
+ mtype1_id,
+ attr1_id,
+ attr2_id);
+ nfound += found;
+ } /*else quiet */
+ } /*else verbose */
}/*cmp*/
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Tclose(ftype1_id)<0) goto error;
- if (H5Tclose(ftype2_id)<0) goto error;
- if (H5Tclose(mtype1_id)<0) goto error;
- if (H5Tclose(mtype2_id)<0) goto error;
- if (H5Sclose(space1_id)<0) goto error;
- if (H5Sclose(space2_id)<0) goto error;
- if (H5Aclose(attr1_id)<0) goto error;
- if (H5Aclose(attr2_id)<0) goto error;
- if (buf1)
- HDfree(buf1);
- if (buf2)
- HDfree(buf2);
+/*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Tclose(ftype1_id)<0) goto error;
+ if (H5Tclose(ftype2_id)<0) goto error;
+ if (H5Tclose(mtype1_id)<0) goto error;
+ if (H5Tclose(mtype2_id)<0) goto error;
+ if (H5Sclose(space1_id)<0) goto error;
+ if (H5Sclose(space2_id)<0) goto error;
+ if (H5Aclose(attr1_id)<0) goto error;
+ if (H5Aclose(attr2_id)<0) goto error;
+ if (buf1)
+ HDfree(buf1);
+ if (buf2)
+ HDfree(buf2);
} /* i */
- return ret;
+ return nfound;
error:
H5E_BEGIN_TRY {
@@ -308,7 +317,7 @@ error:
} H5E_END_TRY;
options->err_stat=1;
- return 0;
+ return nfound;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 012552f..a11f06d 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -438,7 +438,7 @@ hsize_t diff_datasetid( hid_t did1,
*/
if (obj1_name)
- diff_attr(did1,did2,obj1_name,obj2_name,options);
+ nfound += diff_attr(did1,did2,obj1_name,obj2_name,options);
}/*cmp*/