summaryrefslogtreecommitdiffstats
path: root/tools/h5diff/h5diff_main.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-08-06 20:09:17 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-08-06 20:09:17 (GMT)
commite85c6bd28cf27d8ab934c2b39ca57eb8dac7ba77 (patch)
treeef1e09fff4a9cbfdb4d03ff1f73e0cf4c15b7931 /tools/h5diff/h5diff_main.c
parenta537dee4f88bc4e5437ba662e16f72127cbe944b (diff)
downloadhdf5-e85c6bd28cf27d8ab934c2b39ca57eb8dac7ba77.zip
hdf5-e85c6bd28cf27d8ab934c2b39ca57eb8dac7ba77.tar.gz
hdf5-e85c6bd28cf27d8ab934c2b39ca57eb8dac7ba77.tar.bz2
[svn-r15442] 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/h5diff_main.c')
-rw-r--r--tools/h5diff/h5diff_main.c106
1 files changed, 67 insertions, 39 deletions
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c
index 82c5519..286ca2ba 100644
--- a/tools/h5diff/h5diff_main.c
+++ b/tools/h5diff/h5diff_main.c
@@ -30,10 +30,10 @@ void h5diff_exit(int status);
const char *progname = "h5diff";
/*
- * command-line options: The user can specify short or long-named
+ * 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' },
@@ -43,6 +43,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' }
};
@@ -86,6 +87,12 @@ static struct long_options l_opts[] = {
* February 20, 2008
* adopted the syntax h5diff [OPTIONS] file1 file2 [obj1[obj2]]
*
+ * Aug 2008
+ * Added a "contents" mode
+ * 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)
+ *
*
*-------------------------------------------------------------------------
*/
@@ -113,6 +120,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;
@@ -136,7 +147,7 @@ void parse_command_line(int argc,
{
int opt;
-
+
/* process the command-line */
memset(options, 0, sizeof (diff_opt_t));
@@ -164,6 +175,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;
@@ -175,7 +189,7 @@ void parse_command_line(int argc,
}
options->delta = atof( opt_arg );
break;
-
+
case 'p':
options->p=1;
@@ -187,7 +201,7 @@ void parse_command_line(int argc,
}
options->percent = atof( opt_arg );
break;
-
+
case 'n':
options->n=1;
@@ -210,17 +224,17 @@ void parse_command_line(int argc,
usage();
h5diff_exit(EXIT_FAILURE);
}
-
+
*fname1 = argv[ opt_ind ];
*fname2 = argv[ opt_ind + 1 ];
*objname1 = argv[ opt_ind + 2 ];
-
+
if ( *objname1 == NULL )
{
*objname2 = NULL;
return;
}
-
+
if ( argv[ opt_ind + 3 ] != NULL)
{
*objname2 = argv[ opt_ind + 3 ];
@@ -229,13 +243,12 @@ void parse_command_line(int argc,
{
*objname2 = *objname1;
}
-
-
+
+
}
-
/*-------------------------------------------------------------------------
* Function: print_info
*
@@ -244,28 +257,28 @@ void parse_command_line(int argc,
*-------------------------------------------------------------------------
*/
- void print_info(diff_opt_t* options)
- {
- if (options->m_quiet || options->err_stat)
- return;
-
- 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");
- }
-
- if (options->not_cmp==1)
- {
- printf("--------------------------------\n");
- printf("Some objects are not comparable\n");
- printf("--------------------------------\n");
- if (!options->m_verbose)
- printf("Use -v for a list of objects.\n");
- }
-
- }
+void print_info(diff_opt_t* options)
+{
+ if (options->m_quiet || options->err_stat || options->m_contents)
+ return;
+
+ 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");
+ }
+
+ if (options->not_cmp==1)
+ {
+ printf("--------------------------------\n");
+ printf("Some objects are not comparable\n");
+ printf("--------------------------------\n");
+ if (!options->m_verbose)
+ printf("Use -v for a list of objects.\n");
+ }
+
+}
/*-------------------------------------------------------------------------
* Function: check_n_input
@@ -394,8 +407,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");
@@ -415,6 +430,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");
@@ -444,14 +475,11 @@ 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");
+
}
+
/*-------------------------------------------------------------------------
* Function: h5diff_exit
*