summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c571
-rw-r--r--tools/lib/h5diff.h11
-rw-r--r--tools/lib/h5diff_attr.c28
-rw-r--r--tools/lib/h5diff_dset.c7
-rw-r--r--tools/lib/h5trav.h5
5 files changed, 313 insertions, 309 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index d770769..205f45f 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -882,11 +882,10 @@ hsize_t diff_compare (hid_t file1_id,
*
* Purpose: switch between types and choose the diff function
* TYPE is either
- * H5G_GROUP Object is a group
- * H5G_DATASET Object is a dataset
- * H5G_TYPE Object is a named data type
- * H5G_LINK Object is a symbolic link
- * H5G_UDLINK Object is a user-defined link
+ * H5G_GROUP Object is a group
+ * H5G_DATASET Object is a dataset
+ * H5G_TYPE Object is a named data type
+ * H5G_LINK Object is a symbolic link
*
* Return: Number of differences found
*
@@ -899,301 +898,301 @@ hsize_t diff_compare (hid_t file1_id,
hsize_t diff (hid_t file1_id,
const char *path1,
- hid_t file2_id,
- const char *path2,
- diff_opt_t * options,
- H5G_obj_t type)
+ hid_t file2_id,
+ const char *path2,
+ diff_opt_t * options,
+ H5G_obj_t1 type)
{
- hid_t type1_id=(-1);
- hid_t type2_id=(-1);
- hid_t grp1_id=(-1);
- hid_t grp2_id=(-1);
- int ret;
- H5G_stat_t sb1;
- H5G_stat_t sb2;
- hsize_t nfound=0;
-
- switch (type)
- {
-/*-------------------------------------------------------------------------
- * H5G_DATASET
- *-------------------------------------------------------------------------
- */
- case H5G_DATASET:
-
-/*-------------------------------------------------------------------------
- * verbose, always print name
- *-------------------------------------------------------------------------
- */
- if (options->m_verbose)
- {
- if (print_objname (options, (hsize_t)1))
- do_print_objname ("dataset", path1, path2);
- nfound = diff_dataset (file1_id, file2_id, path1, path2, options);
- /* always print the number of differences found */
- print_found(nfound);
- }
- /*-------------------------------------------------------------------------
- * non verbose, check first if we have differences
- *-------------------------------------------------------------------------
- */
- else
- {
- if (options->m_quiet == 0)
- {
- /* shut up temporarily */
- options->m_quiet = 1;
- nfound = diff_dataset (file1_id, file2_id, path1, path2, options);
- /* print again */
- options->m_quiet = 0;
- if (nfound)
+ hid_t type1_id=(-1);
+ hid_t type2_id=(-1);
+ hid_t grp1_id=(-1);
+ hid_t grp2_id=(-1);
+ int ret;
+ H5G_stat_t sb1;
+ H5G_stat_t sb2;
+ hsize_t nfound = 0;
+
+ switch (type)
{
- if (print_objname (options, nfound))
- do_print_objname ("dataset", path1, path2);
- nfound = diff_dataset (file1_id, file2_id, path1, path2, options);
- /* print the number of differences found only when found
- this is valid for the default mode and report mode */
- print_found(nfound);
- } /*if nfound */
- } /*if quiet */
-
- /*-------------------------------------------------------------------------
- * quiet mode, just count differences
- *-------------------------------------------------------------------------
- */
- else
- {
- nfound = diff_dataset (file1_id, file2_id, path1, path2, options);
- }
- } /*else verbose */
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_TYPE
- *-------------------------------------------------------------------------
- */
- case H5G_TYPE:
- if ((type1_id = H5Topen (file1_id, path1)) < 0)
- goto out;
- if ((type2_id = H5Topen (file2_id, path2)) < 0)
- goto out;
-
- if ((ret = H5Tequal (type1_id, type2_id)) < 0)
- goto out;
-
- /* if H5Tequal is > 0 then the datatypes refer to the same datatype */
- nfound = (ret > 0) ? 0 : 1;
-
- if (print_objname (options, nfound))
- do_print_objname ("datatype", path1, path2);
-
- /* always print the number of differences found in verbose mode */
- if (options->m_verbose)
- print_found(nfound);
-
- /*-------------------------------------------------------------------------
- * compare attributes
- * the if condition refers to cases when the dataset is a referenced object
- *-------------------------------------------------------------------------
- */
- if (path1)
- diff_attr (type1_id, type2_id, path1, path2, options);
-
- if (H5Tclose (type1_id) < 0)
- goto out;
- if (H5Tclose (type2_id) < 0)
- goto out;
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_GROUP
- *-------------------------------------------------------------------------
- */
- case H5G_GROUP:
- if ((grp1_id = H5Gopen (file1_id, path1)) < 0)
- goto out;
- if ((grp2_id = H5Gopen (file2_id, path2)) < 0)
- goto out;
-
- ret = HDstrcmp (path1, path2);
-
- /* if "path1" != "path2" then the groups are "different" */
- nfound = (ret != 0) ? 1 : 0;
-
- if (print_objname (options, nfound))
- do_print_objname ("group", path1, path2);
-
- /* always print the number of differences found in verbose mode */
- if (options->m_verbose)
- print_found(nfound);
-
- /*-------------------------------------------------------------------------
- * compare attributes
- * the if condition refers to cases when the dataset is a referenced object
- *-------------------------------------------------------------------------
- */
- if (path1)
- diff_attr (grp1_id, grp2_id, path1, path2, options);
-
- if (H5Gclose (grp1_id) < 0)
- goto out;
- if (H5Gclose (grp2_id) < 0)
- goto out;
-
- break;
-
-
- /*-------------------------------------------------------------------------
- * H5G_LINK
- *-------------------------------------------------------------------------
- */
- case H5G_LINK:
- {
- char *buf1 = NULL;
- char *buf2 = NULL;
-
- if (H5Gget_objinfo (file1_id, path1, FALSE, &sb1) < 0)
- goto out;
- if (H5Gget_objinfo (file1_id, path1, FALSE, &sb2) < 0)
- goto out;
-
- buf1 = HDmalloc (sb1.linklen);
- buf2 = HDmalloc (sb2.linklen);
-
- if (H5Gget_linkval (file1_id, path1, sb1.linklen, buf1) < 0)
- goto out;
- if (H5Gget_linkval (file2_id, path2, sb1.linklen, buf2) < 0)
- goto out;
-
- ret = HDstrcmp (buf1, buf2);
-
- /* if "buf1" != "buf2" then the links are "different" */
- nfound = (ret != 0) ? 1 : 0;
-
- if (print_objname (options, nfound))
- do_print_objname ("soft link", path1, path2);
-
- /* always print the number of differences found in verbose mode */
- if (options->m_verbose)
- print_found(nfound);
-
- HDfree (buf1);
- HDfree (buf2);
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_UDLINK
- *-------------------------------------------------------------------------
- */
- case H5G_UDLINK:
- {
- char *buf1 = NULL;
- char *buf2 = NULL;
- H5L_info_t li1;
- H5L_info_t li2;
-
- if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0)
- goto out;
- if(H5Lget_info(file1_id, path1, &li2, H5P_DEFAULT) < 0)
- goto out;
-
- /* Only external links will have a query function registered */
- if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL)
- {
- buf1 = HDmalloc (li1.u.val_size);
- buf2 = HDmalloc (li2.u.val_size);
-
- if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0)
- {
- HDfree (buf1); HDfree (buf2);
- goto out;
- }
- if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0)
- {
- HDfree (buf1); HDfree (buf2);
- goto out;
- }
-
- /* If the buffers are the same size, compare them */
- if(li1.u.val_size == li2.u.val_size)
- {
- if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0)
+
+ /*-------------------------------------------------------------------------
+ * H5G_DATASET
+ *-------------------------------------------------------------------------
+ */
+ case H5G_DATASET:
+
+ /*-------------------------------------------------------------------------
+ * verbose, always print name
+ *-------------------------------------------------------------------------
+ */
+ if (options->m_verbose)
{
- HDfree (buf1); HDfree (buf2);
- goto out;
+ if (print_objname(options,(hsize_t)1))
+ do_print_objname ("dataset", path1, path2);
+ nfound=diff_dataset(file1_id,file2_id,path1,path2,options);
+ print_found(nfound);
+
}
- if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0)
+ /*-------------------------------------------------------------------------
+ * non verbose, check first if we have differences by enabling quiet mode
+ * so that printing is off, and compare again if differences found,
+ * disabling quite mode
+ *-------------------------------------------------------------------------
+ */
+ else
{
- HDfree (buf1); HDfree (buf2);
- goto out;
+ if (options->m_quiet==0)
+ {
+ /* shut up temporarily */
+ options->m_quiet=1;
+ nfound=diff_dataset(file1_id,file2_id,path1,path2,options);
+ /* print again */
+ options->m_quiet=0;
+ if (nfound)
+ {
+ if (print_objname(options,nfound))
+ do_print_objname ("dataset", path1, path2);
+ nfound=diff_dataset(file1_id,file2_id,path1,path2,options);
+ print_found(nfound);
+ }
+ }
+ /* in quiet mode, just count differences */
+ else
+ {
+ nfound=diff_dataset(file1_id,file2_id,path1,path2,options);
+ }
}
- ret = HDmemcmp (buf1, buf2, li1.u.val_size);
- }
- else
- ret = 1;
-
- /* if "buf1" != "buf2" then the links are "different" */
- nfound = (ret != 0) ? 1 : 0;
-
- if (print_objname (options, nfound))
- do_print_objname ("external link", path1, path2);
- }
- else
- {
- /* If one or both of these links isn't an external link, we can only
- * compare information from H5Lget_info since we don't have a query
- * function registered for them. */
-
- /* If the link classes or the buffer length are not the
- * same, the links are "different"
- */
- if((li1.type != li2.type) || (li1.u.val_size != li2.u.val_size))
- nfound = 1;
- else
- nfound = 0;
-
- if (print_objname (options, nfound))
- do_print_objname ("user defined link", path1, path2);
- }
-
- /* always print the number of differences found in verbose mode */
- if (options->m_verbose)
- print_found(nfound);
-
- HDfree (buf1);
- HDfree (buf2);
- }
- break;
-
- default:
- nfound = 0;
- if (options->m_verbose)
- {
- parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
- path1, path2, get_type (type));
- options->not_cmp=1;
- }
-
- break;
- } /* switch */
-
-
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_TYPE
+ *-------------------------------------------------------------------------
+ */
+ case H5G_TYPE:
+
+ if ((type1_id = H5Topen(file1_id, path1))<0)
+ goto out;
+ if ((type2_id = H5Topen(file2_id, path2))<0)
+ goto out;
+
+ if ((ret = H5Tequal(type1_id,type2_id))<0)
+ goto out;
+
+ /* if H5Tequal is > 0 then the datatypes refer to the same datatype */
+ nfound = (ret>0) ? 0 : 1;
+
+ if (print_objname(options,nfound))
+ do_print_objname ("datatype", path1, path2);
+
+ /* always print the number of differences found in verbose mode */
+ if (options->m_verbose)
+ print_found(nfound);
+
+ /*-------------------------------------------------------------------------
+ * compare attributes
+ * the if condition refers to cases when the dataset is a referenced object
+ *-------------------------------------------------------------------------
+ */
+ if (path1)
+ nfound += diff_attr(type1_id,type2_id,path1,path2,options);
+
+ if ( H5Tclose(type1_id)<0)
+ goto out;
+ if ( H5Tclose(type2_id)<0)
+ goto out;
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_GROUP
+ *-------------------------------------------------------------------------
+ */
+ case H5G_GROUP:
+
+ ret = HDstrcmp(path1,path2);
+
+ /* if "path1" != "path2" then the groups are "different" */
+ nfound = (ret!=0) ? 1 : 0;
+
+ if (print_objname(options,nfound))
+ do_print_objname ("group", path1, path2);
+
+ /* always print the number of differences found in verbose mode */
+ if (options->m_verbose)
+ print_found(nfound);
+
+ if ((grp1_id = H5Gopen(file1_id, path1))<0)
+ goto out;
+ if ((grp2_id = H5Gopen(file2_id, path2))<0)
+ goto out;
+ /*-------------------------------------------------------------------------
+ * compare attributes
+ * the if condition refers to cases when the dataset is a referenced object
+ *-------------------------------------------------------------------------
+ */
+ if (path1)
+ nfound += diff_attr(grp1_id,grp2_id,path1,path2,options);
+
+ if ( H5Gclose(grp1_id)<0)
+ goto out;
+ if ( H5Gclose(grp2_id)<0)
+ goto out;
+
+ break;
+
+
+ /*-------------------------------------------------------------------------
+ * H5G_LINK
+ *-------------------------------------------------------------------------
+ */
+ case H5G_LINK:
+ {
+ char *buf1 = NULL;
+ char *buf2 = NULL;
+
+ if (H5Gget_objinfo (file1_id, path1, FALSE, &sb1) < 0)
+ goto out;
+ if (H5Gget_objinfo (file1_id, path1, FALSE, &sb2) < 0)
+ goto out;
+
+ buf1 = HDmalloc (sb1.linklen);
+ buf2 = HDmalloc (sb2.linklen);
+
+ if (H5Gget_linkval (file1_id, path1, sb1.linklen, buf1) < 0)
+ goto out;
+ if (H5Gget_linkval (file2_id, path2, sb1.linklen, buf2) < 0)
+ goto out;
+
+ ret = HDstrcmp (buf1, buf2);
+
+ /* if "buf1" != "buf2" then the links are "different" */
+ nfound = (ret != 0) ? 1 : 0;
+
+ if (print_objname (options, nfound))
+ do_print_objname ("link", path1, path2);
+
+ /* always print the number of differences found in verbose mode */
+ if (options->m_verbose)
+ print_found(nfound);
+
+ HDfree (buf1);
+ HDfree (buf2);
+ }
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
+ case H5G_UDLINK:
+ {
+ char *buf1 = NULL;
+ char *buf2 = NULL;
+ H5L_info_t li1;
+ H5L_info_t li2;
+
+ if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0)
+ goto out;
+ if(H5Lget_info(file1_id, path1, &li2, H5P_DEFAULT) < 0)
+ goto out;
+
+ /* Only external links will have a query function registered */
+ if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL)
+ {
+ buf1 = HDmalloc (li1.u.val_size);
+ buf2 = HDmalloc (li2.u.val_size);
+
+ if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+ if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+
+ /* If the buffers are the same size, compare them */
+ if(li1.u.val_size == li2.u.val_size)
+ {
+ if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+ if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+ ret = HDmemcmp (buf1, buf2, li1.u.val_size);
+ }
+ else
+ ret = 1;
+
+ /* if "buf1" != "buf2" then the links are "different" */
+ nfound = (ret != 0) ? 1 : 0;
+
+ if (print_objname (options, nfound))
+ do_print_objname ("external link", path1, path2);
+ }
+ else
+ {
+ /* If one or both of these links isn't an external link, we can only
+ * compare information from H5Lget_info since we don't have a query
+ * function registered for them.
+ /* If the link classes or the buffer length are not the
+ * same, the links are "different"
+ */
+ if((li1.type != li2.type) || (li1.u.val_size != li2.u.val_size))
+ nfound = 1;
+ else
+ nfound = 0;
+
+ if (print_objname (options, nfound))
+ do_print_objname ("user defined link", path1, path2);
+ }
+
+ /* always print the number of differences found in verbose mode */
+ if (options->m_verbose)
+ print_found(nfound);
+
+ HDfree (buf1);
+ HDfree (buf2);
+ }
+ break;
+
+ default:
+ if (options->m_verbose)
+ {
+ printf("Comparison not supported: <%s> and <%s> are of type %s\n",
+ path1, path2, get_type(type) );
+ }
+ options->not_cmp=1;
+ break;
+ }
+
+
+ return nfound;
+
out:
+ options->err_stat=1;
+
/* close */
/* disable error reporting */
H5E_BEGIN_TRY
{
- H5Tclose (type1_id);
- H5Tclose (type2_id);
- H5Gclose (grp1_id);
- H5Tclose (grp2_id);
- /* enable error reporting */
+ H5Tclose (type1_id);
+ H5Tclose (type2_id);
+ H5Gclose (grp1_id);
+ H5Tclose (grp2_id);
+ /* enable error reporting */
}
H5E_END_TRY;
+
return nfound;
}
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index d154fc8..9125d7c 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -138,12 +138,11 @@ 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 c99a1ae..37bef3e 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -26,22 +26,23 @@
* loc_id = H5Dopen( fid, name);
* loc_id = H5Topen( fid, name);
*
- * Return:
- * 0 : no differences found
- * 1 : differences found
+ * Return: number of differences found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November, 03, 2003
*
+ * Modifications:
+ * March, 02, 2007: return the number of differences found
+ *
*-------------------------------------------------------------------------
*/
-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 */
@@ -65,9 +66,9 @@ int diff_attr(hid_t loc1_id,
char np1[512];
char np2[512];
int n1, n2, i, j;
- hsize_t nfound;
+ hsize_t nfound=0;
+ hsize_t nfound_total=0;
int cmp=1;
- int ret=0;
if ((n1 = H5Aget_num_attrs(loc1_id))<0)
goto error;
@@ -95,7 +96,6 @@ int diff_attr(hid_t loc1_id,
{
if ((attr2_id = H5Aopen_name(loc2_id, name1))<0)
{
- ret = 1;
goto error;
}
} H5E_END_TRY;
@@ -285,9 +285,11 @@ int diff_attr(hid_t loc1_id,
HDfree(buf1);
if (buf2)
HDfree(buf2);
+
+ nfound_total += nfound;
} /* i */
- return ret;
+ return nfound_total;
error:
H5E_BEGIN_TRY {
@@ -306,7 +308,7 @@ error:
} H5E_END_TRY;
options->err_stat=1;
- return ret;
+ return nfound_total;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 993a00f..602cce7 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -515,7 +515,8 @@ hsize_t diff_datasetid( hid_t did1,
}
} /* hyperslab read */
-
+ }/*cmp*/
+
/*-------------------------------------------------------------------------
* compare attributes
* the if condition refers to cases when the dataset is a referenced object
@@ -523,9 +524,7 @@ hsize_t diff_datasetid( hid_t did1,
*/
if (obj1_name)
- diff_attr(did1,did2,obj1_name,obj2_name,options);
-
- }/*cmp*/
+ nfound += diff_attr(did1,did2,obj1_name,obj2_name,options);
/*-------------------------------------------------------------------------
* close
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 07801da..c11d835 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -29,6 +29,9 @@
*-------------------------------------------------------------------------
*/
+typedef H5G_obj_t H5G_obj_t1;
+
+
typedef struct trav_info_t {
char *name;
H5G_obj_t type;
@@ -133,3 +136,5 @@ void trav_table_addlink(trav_table_t *table,
#endif /* H5TRAV_H__ */
+
+