summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-08-05 19:35:46 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-08-05 19:35:46 (GMT)
commite46107ca75c83c11759defaeb4d1ce5630b91656 (patch)
tree03c1a3b05d271302168e927282eba62021812686 /tools/h5diff
parentd364dc74a48d3e406d61920e1c3cccdf961b24d8 (diff)
downloadhdf5-e46107ca75c83c11759defaeb4d1ce5630b91656.zip
hdf5-e46107ca75c83c11759defaeb4d1ce5630b91656.tar.gz
hdf5-e46107ca75c83c11759defaeb4d1ce5630b91656.tar.bz2
[svn-r15433] http://bugzilla.hdfgroup.uiuc.edu/show_bug.cgi?id=1170
Summary: when using h5diff to compare the results of h5repack (or other tools that copy one HDF5 file to another), a new option is needed to allow h5diff to make an "absolute" comparison of the 2 files. This is the "contents" mode explained in the usage below. If this mode is present, objects in both files must match (must be exactly the same). If this does not happen, the tool returns an error code of 1 (instead of the success code of 0) Changes to the h5repack test script: the call to h5diff was changed to include -c (maintaining the previous -q). tested: windows, linux
Diffstat (limited to 'tools/h5diff')
-rw-r--r--tools/h5diff/h5diff_common.c34
-rw-r--r--tools/h5diff/h5diff_main.c4
-rw-r--r--tools/h5diff/h5diffgentest.c111
-rwxr-xr-xtools/h5diff/testh5diff.sh4
4 files changed, 73 insertions, 80 deletions
diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c
index 357bb32..05111a9 100644
--- a/tools/h5diff/h5diff_common.c
+++ b/tools/h5diff/h5diff_common.c
@@ -31,7 +31,7 @@ const char *progname = "h5diff";
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVrvqn:d:p:";
+static const char *s_opts = "hVrvqn:d:p:c";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "version", no_arg, 'V' },
@@ -41,6 +41,7 @@ static struct long_options l_opts[] = {
{ "count", require_arg, 'n' },
{ "delta", require_arg, 'd' },
{ "relative", require_arg, 'p' },
+ { "contents", no_arg, 'c' },
{ NULL, 0, '\0' }
};
@@ -91,6 +92,9 @@ void parse_command_line(int argc,
case 'r':
options->m_report = 1;
break;
+ case 'c':
+ options->m_contents = 1;
+ break;
case 'd':
options->d=1;
@@ -170,7 +174,7 @@ void parse_command_line(int argc,
void print_info(diff_opt_t* options)
{
- if (options->m_quiet || options->err_stat)
+ if (options->m_quiet || options->err_stat || options->m_contents)
return;
if (options->cmn_objs==0)
@@ -318,8 +322,10 @@ void usage(void)
printf(" -V, --version Print version number and exit\n");
printf(" -r, --report Report mode. Print differences\n");
printf(" -v, --verbose Verbose mode. Print differences, list of objects\n");
-
printf(" -q, --quiet Quiet mode. Do not do output\n");
+ printf(" -c, --contents Contents mode. Objects in both files must match\n");
+
+
printf(" -n C, --count=C Print differences up to C number\n");
printf(" -d D, --delta=D Print difference when greater than limit D\n");
printf(" -p R, --relative=R Print difference when greater than relative limit R\n");
@@ -339,6 +345,22 @@ void usage(void)
printf(" -r Report mode: print the above plus the differences\n");
printf(" -v Verbose mode: print the above plus a list of objects and warnings\n");
printf(" -q Quiet mode: do not print output\n");
+ printf(" -c Contents mode: objects in both files must match\n");
+
+ printf("\n");
+
+ printf(" Compare criteria\n");
+ printf("\n");
+ printf(" If no objects [obj1[obj2]] are specified, h5diff only compares objects\n");
+ printf(" with the same absolute path in both files. However,\n");
+ printf(" when the -c flag is present, (contents mode) the objects in file1\n");
+ printf(" must match exactly the objects in file2\n");
+ printf("\n");
+
+ printf(" The compare criteria is:\n");
+ printf(" 1) datasets: numerical array differences 2) groups: name string difference\n");
+ printf(" 3) datatypes: the return value of H5Tequal 2) links: name string difference\n");
+ printf(" of the linked value\n");
printf("\n");
@@ -368,11 +390,7 @@ void usage(void)
printf("\n");
printf(" to compare '/g1/dset1' and '/g1/dset2' in the same file\n");
printf("\n");
- printf(" If no objects [obj1[obj2]] are specified, h5diff only compares objects\n");
- printf(" with the same absolute path in both files. The compare criteria is:\n");
- printf(" 1) datasets: numerical array differences 2) groups: name string difference\n");
- printf(" 3) datatypes: the return value of H5Tequal 2) links: name string difference\n");
- printf(" of the linked value\n");
+
}
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c
index 54a075f..17fe275 100644
--- a/tools/h5diff/h5diff_main.c
+++ b/tools/h5diff/h5diff_main.c
@@ -89,6 +89,10 @@ int main(int argc, const char *argv[])
*/
ret = (nfound == 0 ? 0 : 1 );
+
+ if ( options.m_contents && options.contents == 0 )
+ ret = 1;
+
if(options.err_stat)
ret = -1;
return ret;
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 74b3aa2..e1a554e 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -146,7 +146,7 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3)
fprintf(stderr, "empty file (%s) close failed.\n", fname3);
goto out;
}
-
+
/*-------------------------------------------------------------------------
* create two files
*-------------------------------------------------------------------------
@@ -265,7 +265,6 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3)
*/
{
-#if 1
float data15[6];
float data16[6];
@@ -285,48 +284,9 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3)
write_dset(gid1,1,dims1,"fp15",H5T_NATIVE_FLOAT,data15);
write_dset(gid1,1,dims1,"fp16",H5T_NATIVE_FLOAT,data16);
-#else
-
-#define NU_ELMTS 1000000
-
- hsize_t i;
-
- hsize_t dims2[1] = { NU_ELMTS };
-
- float *data15 = malloc (NU_ELMTS * sizeof(float) );
- float *data16 = malloc (NU_ELMTS * sizeof(float) );
-
- data15[0] = (float) sqrt( (double)-1 );
- data15[1] = 1;
- data15[2] = (float) sqrt( (double)-1 );
- data15[3] = 1;
- data15[4] = 1;
- data15[5] = 1;
-
- data16[0] = (float) sqrt( (double)-1 );
- data16[1] = (float) sqrt( (double)-1 );
- data16[2] = 1;
- data16[3] = 1;
- data16[4] = 1;
- data16[5] = 1;
-
- for ( i = 6; i < NU_ELMTS; i++ )
- {
- data15[i] = /*data15[0];*/ 2;
- data16[i] = 1;
- }
-
- write_dset(gid1,1,dims2,"fp15",H5T_NATIVE_FLOAT,data15);
- write_dset(gid1,1,dims2,"fp16",H5T_NATIVE_FLOAT,data16);
-
- free( data15 );
- free( data16 );
-#endif
}
-
-
/*-------------------------------------------------------------------------
* NaNs in H5T_NATIVE_DOUBLE
*-------------------------------------------------------------------------
@@ -354,9 +314,7 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3)
write_dset(gid1,1,dims1,"fp18",H5T_NATIVE_DOUBLE,data18);
}
-
-
-
+
/*-------------------------------------------------------------------------
* close
@@ -783,13 +741,13 @@ int test_datasets(const char *file,
write_dset_in(gid,"/dset",fid,make_diffs);
- /* Close */
+ /* close */
status = H5Dclose(did);
assert(status >= 0);
status = H5Gclose(gid);
assert(status >= 0);
- /* Close file */
+ /* close file */
status = H5Fclose(fid);
assert(status >= 0);
return status;
@@ -2666,31 +2624,35 @@ int write_attr(hid_t loc_id,
hid_t tid,
void *buf)
{
- hid_t aid;
- hid_t sid;
-
- /* create a space */
- if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
- goto out;
-
- /* create the attribute */
- if((aid = H5Acreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
-
- /* write */
- if(buf)
- if(H5Awrite(aid, tid, buf) < 0)
- goto out;
-
- /* close */
- H5Aclose(aid);
- H5Sclose(sid);
-
- return SUCCEED;
-
+ hid_t aid=-1;
+ hid_t sid=-1;
+
+ /* create a space */
+ if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
+ goto out;
+
+ /* create the attribute */
+ if((aid = H5Acreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* write */
+ if(buf)
+ {
+ if(H5Awrite(aid, tid, buf) < 0)
+ goto out;
+ }
+
+ /* close */
+ H5Aclose(aid);
+ H5Sclose(sid);
+
+ return SUCCEED;
+
out:
-
- return FAIL;
+
+ H5Aclose(aid);
+ H5Sclose(sid);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -2708,8 +2670,8 @@ int write_dset( hid_t loc_id,
hid_t tid,
void *buf )
{
- hid_t did;
- hid_t sid;
+ hid_t did=-1;
+ hid_t sid=-1;
/* create a space */
if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
@@ -2721,8 +2683,10 @@ int write_dset( hid_t loc_id,
/* write */
if(buf)
+ {
if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
+ }
/* close */
H5Dclose(did);
@@ -2731,6 +2695,9 @@ int write_dset( hid_t loc_id,
return SUCCEED;
out:
+
+ H5Dclose(did);
+ H5Sclose(sid);
return FAIL;
}
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index 6685a66..208bb29 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -39,6 +39,7 @@ FILE7=h5diff_dset1.h5
FILE8=h5diff_dset2.h5
FILE9=h5diff_hyper1.h5
FILE10=h5diff_hyper2.h5
+FILE11=h5diff_empty.h5
H5DIFF=h5diff # The tool name
@@ -301,6 +302,9 @@ TOOLTEST h5diff_17.txt -v $FILE1 $FILE2
# 1.8 quiet mode
TOOLTEST h5diff_18.txt -q $FILE1 $FILE2
+# 1.9 contents mode
+TOOLTEST h5diff_19.txt -v -c $FILE1 $FILE11
+
# ##############################################################################
# # not comparable types
# ##############################################################################