summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2007-03-05 16:26:50 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2007-03-05 16:26:50 (GMT)
commitbd01f34589a4d3d790312a844bfd0cce28721f31 (patch)
tree75517f698815cf1a71af8eda28055cf8c75cd585 /tools/lib/h5diff.c
parent44f312b183305cf37295595bfd3f5df40fc637be (diff)
downloadhdf5-bd01f34589a4d3d790312a844bfd0cce28721f31.zip
hdf5-bd01f34589a4d3d790312a844bfd0cce28721f31.tar.gz
hdf5-bd01f34589a4d3d790312a844bfd0cce28721f31.tar.bz2
[svn-r13451]
h5diff bug fix, attributes differences were not being count for total differences Revision of H5Ocopy call in h5repack
Diffstat (limited to 'tools/lib/h5diff.c')
-rw-r--r--tools/lib/h5diff.c571
1 files changed, 285 insertions, 286 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;
}