summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-07-20 19:21:03 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-07-20 19:21:03 (GMT)
commit4cb6c01d7f59be968649e36a61346be044f76345 (patch)
treee0a0b81e542768b75d5bbb2de8afc1abfb8c4370 /tools/h5diff
parent00909f278d64017c21c8348537231daba97be9dd (diff)
downloadhdf5-4cb6c01d7f59be968649e36a61346be044f76345.zip
hdf5-4cb6c01d7f59be968649e36a61346be044f76345.tar.gz
hdf5-4cb6c01d7f59be968649e36a61346be044f76345.tar.bz2
[svn-r8904] Purpose:
h5diff and h5repack changes Description: h5diff introduced the following four modes of output: Normal mode: print the number of differences found and where they occured Report mode: print the above plus the differences Verbose mode: print the above plus a list of objects and warnings Quiet mode: do not print output (h5diff always returns an exit code of 1 when differences are found) h5repack added an extra parameter for SZIP filter (coding method) the new syntax is -f SZIP=<pixels per block,coding> (pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN') Example of use: ./h5repack -i file1 -o file2 -f SZIP=8,NN -v updated usage messages, test scripts and files accordingly Solution: Platforms tested: linux AIX solaris Misc. update:
Diffstat (limited to 'tools/h5diff')
-rw-r--r--tools/h5diff/h5diff_main.c88
-rwxr-xr-xtools/h5diff/testh5diff.sh54
-rw-r--r--tools/h5diff/testh5diff_attr.c44
-rw-r--r--tools/h5diff/testh5diff_dset.c37
4 files changed, 98 insertions, 125 deletions
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c
index 8dbce22..ff3b2e1 100644
--- a/tools/h5diff/h5diff_main.c
+++ b/tools/h5diff/h5diff_main.c
@@ -16,11 +16,6 @@
#include <stdlib.h>
#include <assert.h>
-/* Due to alignment issue in Alpha clusters, options must be declared here
- * not as a local variable in main().
- */
-diff_opt_t options = {0,0,0,0,0,0,0,0};
-
static void usage(void);
static int check_n_input( const char* );
static int check_f_input( const char* );
@@ -40,7 +35,12 @@ static int check_f_input( const char* );
*
* Comments:
*
- * Modifications:
+ * Modifications: July 2004
+ * Introduced the four modes:
+ * Normal mode: print the number of differences found and where they occured
+ * Report mode: print the above plus the differences
+ * Verbose mode: print the above plus a list of objects and warnings
+ * Quiet mode: do not print output
*
*-------------------------------------------------------------------------
*/
@@ -53,7 +53,11 @@ int main(int argc, const char *argv[])
const char *fname2 = NULL;
const char *objname1 = NULL;
const char *objname2 = NULL;
- int nfound=0, ret;
+ hsize_t nfound=0;
+ int ret;
+ diff_opt_t options;
+
+ memset(&options, 0, sizeof (diff_opt_t));
/*-------------------------------------------------------------------------
* initial check of command line options
@@ -98,10 +102,14 @@ int main(int argc, const char *argv[])
usage();
break;
case 'v':
- options.verbose = 1;
+ options.m_verbose = 1;
+ break;
+ case 'q':
+ /* use quiet mode; supress the message "0 differences found" */
+ options.m_quiet = 1;
break;
case 'r':
- options.r = 1;
+ options.m_report = 1;
break;
case 'd':
/* if it is not another option */
@@ -189,24 +197,36 @@ int main(int argc, const char *argv[])
}/*for*/
+ nfound = h5diff(fname1,fname2,objname1,objname2,&options);
+
/*-------------------------------------------------------------------------
- * print the command line options
+ * print how many differences were found
*-------------------------------------------------------------------------
*/
-
- if (options.verbose)
+ if (!options.m_quiet)
{
- printf("$h5diff");
- for (i=1; i<argc ; i++)
+ if (options.cmn_objs==0)
+ {
+ printf("No common objects found. Files are not comparable.\n");
+ if (!options.m_verbose)
+ printf("Use -v for a list of objects.\n");
+ }
+ else
{
- printf(" %s", argv[i] );
+ if (!options.err_stat)
+ print_found(nfound);
}
- printf("\n");
}
- nfound = h5diff(fname1,fname2,objname1,objname2,&options);
- if (options.verbose) printf("\n");
+/*-------------------------------------------------------------------------
+ * exit code
+ * >0 if differences, 0 if no differences, <0 if error
+ *-------------------------------------------------------------------------
+ */
+
ret= (nfound==0 ? 0 : 1 );
+ if (options.err_stat)
+ ret=-1;
return ret;
}
@@ -256,8 +276,6 @@ int check_n_input( const char *str )
*
* Return: 1 for ok, -1 for fail
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
* Date: May 9, 2003
*
* Comments:
@@ -292,10 +310,6 @@ int check_f_input( const char *str )
*
* Return: void
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
*-------------------------------------------------------------------------
*/
static
@@ -309,8 +323,9 @@ void usage(void)
printf("[obj2] Name of an HDF5 object, in absolute path\n");
printf("[OPTIONS] are:\n");
printf("[-h] Print out this information\n");
- printf("[-v] Verbose mode\n");
- printf("[-r] Print only what objects differ, not the differences\n");
+ printf("[-r] Report mode. Print the differences\n");
+ printf("[-v] Verbose mode. Print the differences, list of objects, warnings\n");
+ printf("[-q] Quiet mode. Do not do output\n");
printf("[-n count] Print difference up to count number\n");
printf("[-d delta] Print difference when it is greater than limit delta\n");
printf("[-p relative] Print difference when it is greater than a relative limit\n");
@@ -322,20 +337,31 @@ void usage(void)
printf("The -d compare criteria is |a - b| > delta\n");
printf("The -p compare criteria is |1 - b/a| > relative\n");
printf("\n");
- printf("Examples:\n");
+ printf("h5diff has four modes of output:\n");
+ printf(" Normal mode: print the number of differences found and where they occured\n");
+ printf(" Report mode: print the above plus the differences\n");
+ printf(" Verbose mode: print the above plus a list of objects and warnings\n");
+ printf(" Quiet mode: do not print output (h5diff always returns an exit code of 1 when differences are found)\n");
printf("\n");
- printf("1) h5diff file1 file2 /a/b /a/c\n");
+ printf("Examples of use:\n");
printf("\n");
- printf(" Compares object '/a/b' in file1 with '/a/c' in file2\n");
+ printf("1) h5diff file1 file2 /g1/dset1 /g1/dset2\n");
printf("\n");
- printf("2) h5diff file1 file2 /a/b\n");
+ printf(" Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n");
printf("\n");
- printf(" Compares object '/a/b' in both files\n");
+ printf("2) h5diff file1 file2 /g1/dset1\n");
+ printf("\n");
+ printf(" Compares object '/g1/dset1' in both files\n");
printf("\n");
printf("3) h5diff file1 file2\n");
printf("\n");
printf(" Compares all objects in both files\n");
printf("\n");
+ printf("Note) file1 and file2 can be the same file. Use\n");
+ printf("\n");
+ printf(" h5diff file1 file1 /g1/dset1 /g1/dset2\n");
+ printf("\n");
+ printf(" to compare '/g1/dset1' and '/g1/dset2' in the same file\n");
exit(0);
}
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index f9392fe..91a2eb5 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -102,23 +102,29 @@ TOOLTEST() {
# 1.0
TOOLTEST h5diff_10.txt -h
-# 1.1
-TOOLTEST h5diff_11.txt file1.h5 file2.h5 g1/dset1 g1/dset2
+# 1.1 normal mode
+TOOLTEST h5diff_11.txt file1.h5 file2.h5
-# 1.2
-TOOLTEST h5diff_12.txt file1.h5 file2.h5 -v -n 2 g1/dset1 g1/dset2
+# 1.2 normal mode with objects
+TOOLTEST h5diff_12.txt file1.h5 file2.h5 g1/dset1 g1/dset2
-# 1.3
-TOOLTEST h5diff_13.txt file1.h5 file2.h5 -v -d 5 g1/dset3 g1/dset4
+# 1.3 report mode
+TOOLTEST h5diff_13.txt file1.h5 file2.h5 -r
-# 1.4
-TOOLTEST h5diff_14.txt file1.h5 file2.h5 -v -p 0.05 g1/dset3 g1/dset4
+# 1.4 report mode with objects
+TOOLTEST h5diff_14.txt file1.h5 file2.h5 -r g1/dset1 g1/dset2
-# 1.5
-TOOLTEST h5diff_15.txt file1.h5 file2.h5 -v -r g1/dset1 g1/dset2
+# 1.5 with -d
+TOOLTEST h5diff_15.txt file1.h5 file2.h5 -r -d 5 g1/dset3 g1/dset4
-# 1.6
-TOOLTEST h5diff_16.txt file1.h5 file2.h5
+# 1.6 with -p
+TOOLTEST h5diff_16.txt file1.h5 file2.h5 -r -p 0.05 g1/dset3 g1/dset4
+
+# 1.7 verbose mode
+TOOLTEST h5diff_17.txt file1.h5 file2.h5 -v
+
+# 1.8 quiet mode
+TOOLTEST h5diff_18.txt file1.h5 file2.h5 -q
# ##############################################################################
# # not comparable types
@@ -190,31 +196,31 @@ TOOLTEST h5diff_601.txt file1.h5 file2.h5 -x
# ##############################################################################
# 6.2: no value
-TOOLTEST h5diff_602.txt file1.h5 file2.h5 -d g1/dset3 g1/dset4
+TOOLTEST h5diff_602.txt file1.h5 file2.h5 -d g1/dset3 g1/dset4
# 6.3: negative value
-TOOLTEST h5diff_603.txt file1.h5 file2.h5 -d -4 g1/dset3 g1/dset4
+TOOLTEST h5diff_603.txt file1.h5 file2.h5 -d -4 g1/dset3 g1/dset4
# 6.4: zero
-TOOLTEST h5diff_604.txt file1.h5 file2.h5 -d 0 g1/dset3 g1/dset4
+TOOLTEST h5diff_604.txt file1.h5 file2.h5 -d 0 g1/dset3 g1/dset4
# 6.5: non number
-TOOLTEST h5diff_605.txt file1.h5 file2.h5 -d u g1/dset3 g1/dset4
+TOOLTEST h5diff_605.txt file1.h5 file2.h5 -d u g1/dset3 g1/dset4
# 6.6: hexadecimal
TOOLTEST h5diff_606.txt file1.h5 file2.h5 -d 0x1 g1/dset3 g1/dset4
# 6.7: string
-TOOLTEST h5diff_607.txt file1.h5 file2.h5 -d "1" g1/dset3 g1/dset4
+TOOLTEST h5diff_607.txt file1.h5 file2.h5 -d "1" g1/dset3 g1/dset4
# 6.8: repeated option
-TOOLTEST h5diff_608.txt file1.h5 file2.h5 -d 1 -d 2 g1/dset3 g1/dset4
+TOOLTEST h5diff_608.txt file1.h5 file2.h5 -d 1 -d 2 g1/dset3 g1/dset4
# 6.9: number larger than biggest difference
-TOOLTEST h5diff_609.txt file1.h5 file2.h5 -d 200 g1/dset3 g1/dset4
+TOOLTEST h5diff_609.txt file1.h5 file2.h5 -d 200 g1/dset3 g1/dset4
# 6.10: number smaller than smallest difference
-TOOLTEST h5diff_610.txt file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4
+TOOLTEST h5diff_610.txt file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4
# ##############################################################################
@@ -223,7 +229,7 @@ TOOLTEST h5diff_610.txt file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4
# 6.11: no value
-TOOLTEST h5diff_611.txt file1.h5 file2.h5 -p g1/dset3 g1/dset4
+TOOLTEST h5diff_611.txt file1.h5 file2.h5 -r -p g1/dset3 g1/dset4
# 6.12: negative value
TOOLTEST h5diff_612.txt file1.h5 file2.h5 -p -4 g1/dset3 g1/dset4
@@ -293,15 +299,13 @@ TOOLTEST h5diff_629.txt file1.h6 file2.h6
# # attributes
# ##############################################################################
-TOOLTEST h5diff_70.txt file5.h5 file6.h5
+TOOLTEST h5diff_70.txt file5.h5 file6.h5 -v
# ##############################################################################
# # all dataset datatypes
# ##############################################################################
-TOOLTEST h5diff_80.txt file7.h5 file8.h5
-
-TOOLTEST h5diff_81.txt file7.h5 file8.h5 -v
+TOOLTEST h5diff_80.txt file7.h5 file8.h5 -v
diff --git a/tools/h5diff/testh5diff_attr.c b/tools/h5diff/testh5diff_attr.c
index bc88431..fb6dc39 100644
--- a/tools/h5diff/testh5diff_attr.c
+++ b/tools/h5diff/testh5diff_attr.c
@@ -27,6 +27,8 @@
*
*-------------------------------------------------------------------------
*/
+
+
static void write_attr_in(hid_t loc_id,
const char* dset_name, /* for saving reference to dataset*/
hid_t file_id,
@@ -1025,42 +1027,7 @@ etc
write_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83);
}
-/*-------------------------------------------------------------------------
- * Function: write_null_attr
- *
- * Purpose: write null attribute in LOC_ID (dataset, group, named datatype)
- *
- * Programmer: Raymond Lu, slu@ncsa.uiuc.edu
- *
- * Date: May 24, 2004
- *
- *-------------------------------------------------------------------------
- */
-static void write_null_attr(hid_t loc_id,
- int make_diffs /* flag to modify data buffers */)
-{
- hid_t sid, attr_id;
- int val = 2;
- unsigned uval = 7;
-
- /* Create the null attribute */
- sid = H5Screate(H5S_NULL);
- if(make_diffs) {
- attr_id = H5Acreate(loc_id, "null_attr", H5T_NATIVE_INT, sid, H5P_DEFAULT);
-
- /* Not supposed to write anything */
- H5Awrite(attr_id, H5T_NATIVE_INT, &val);
- } else {
- attr_id = H5Acreate(loc_id, "null_attr", H5T_NATIVE_UINT, sid, H5P_DEFAULT);
-
- /* Not supposed to write anything */
- H5Awrite(attr_id, H5T_NATIVE_INT, &uval);
- }
-
- /* Close */
- H5Aclose(attr_id);
- H5Sclose(sid);
-}
+
/*-------------------------------------------------------------------------
* Check all HDF5 classes
@@ -1069,6 +1036,8 @@ static void write_null_attr(hid_t loc_id,
* H5T_ENUM, H5T_VLEN, H5T_ARRAY
*-------------------------------------------------------------------------
*/
+
+
int test_attr(const char *file,
int make_diffs /* flag to modify data buffers */)
{
@@ -1098,10 +1067,11 @@ int test_attr(const char *file,
* write a series of attributes on the dataset, group, and root group
*-------------------------------------------------------------------------
*/
+
write_attr_in(dset_id,"dset",file_id,make_diffs);
write_attr_in(group_id,NULL,0,make_diffs);
write_attr_in(root_id,NULL,0,make_diffs);
- write_null_attr(root_id,make_diffs);
+
/* Close */
status = H5Dclose(dset_id);
diff --git a/tools/h5diff/testh5diff_dset.c b/tools/h5diff/testh5diff_dset.c
index 242f5d7..8158c5e 100644
--- a/tools/h5diff/testh5diff_dset.c
+++ b/tools/h5diff/testh5diff_dset.c
@@ -602,37 +602,6 @@ static void write_dset_in(hid_t loc_id,
write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83);
}
-/*-------------------------------------------------------------------------
- * Function: write_null_dset
- *
- * Purpose: write null dataset in LOC_ID
- *
- * Programmer: Raymond Lu, slu@ncsa.uiuc.edu
- *
- * Date: May 24, 2004
- *
- *-------------------------------------------------------------------------
- */
-static void write_null_dset(hid_t loc_id, int make_diffs)
-{
- hid_t sid, dset_id;
- int val = 2;
- double dval = 7.8;
-
- /* Create the null dataset */
- sid = H5Screate(H5S_NULL);
- if(make_diffs) {
- dset_id = H5Dcreate(loc_id,"null_dset",H5T_NATIVE_INT,sid,H5P_DEFAULT);
- H5Dwrite(dset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,&val);
- } else {
- dset_id = H5Dcreate(loc_id,"null_dset",H5T_NATIVE_DOUBLE,sid,H5P_DEFAULT);
- H5Dwrite(dset_id,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,&dval);
- }
-
- /* Close */
- H5Dclose(dset_id);
- H5Sclose(sid);
-}
/*-------------------------------------------------------------------------
* Check all HDF5 classes
@@ -641,6 +610,8 @@ static void write_null_dset(hid_t loc_id, int make_diffs)
* H5T_ENUM, H5T_VLEN, H5T_ARRAY
*-------------------------------------------------------------------------
*/
+
+
int test_dsetall(const char *file,
int make_diffs /* flag to modify data buffers */)
{
@@ -677,7 +648,6 @@ int test_dsetall(const char *file,
*/
write_dset_in(group_id,"/dset",file_id,make_diffs);
- write_null_dset(file_id, make_diffs);
/* Close */
status = H5Dclose(dset_id);
@@ -690,3 +660,6 @@ int test_dsetall(const char *file,
assert(status>=0);
return status;
}
+
+
+