summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2003-04-10 03:16:17 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2003-04-10 03:16:17 (GMT)
commit2596820e38f3e0325102e7a7adfa854a49f18d59 (patch)
tree616659f92cc453e32fa370c9e9ad9aa119395390
parent9a30f6f020a8dc222ef972e55d330c65f3f9324e (diff)
downloadhdf5-2596820e38f3e0325102e7a7adfa854a49f18d59.zip
hdf5-2596820e38f3e0325102e7a7adfa854a49f18d59.tar.gz
hdf5-2596820e38f3e0325102e7a7adfa854a49f18d59.tar.bz2
[svn-r6626] Purpose:
added new tests removed compiler warnings from unix platforms changed usage message Description: Solution: Platforms tested: w2000, linux, arabica, modi4 Misc. update:
-rw-r--r--tools/h5diff/h5diff.c224
-rw-r--r--tools/h5diff/h5difftst.c282
-rwxr-xr-xtools/h5diff/testh5diff.sh87
3 files changed, 471 insertions, 122 deletions
diff --git a/tools/h5diff/h5diff.c b/tools/h5diff/h5diff.c
index f5d89de..63251cd 100644
--- a/tools/h5diff/h5diff.c
+++ b/tools/h5diff/h5diff.c
@@ -13,19 +13,16 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-
#include <assert.h>
-
-
#include "hdf5.h"
#include "h5trav.h"
#define FFORMAT "%-15g %-15g %-15g\n"
#define IFORMAT "%-15d %-15d %-15d\n"
+#define LIFORMAT "%-15ld %-15ld %-15d\n"
#define SPACES " "
@@ -41,26 +38,40 @@ typedef struct options_t
int n_number_count; /* value */
} options_t;
-int do_test_files();
-int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
- char *obj2_name, options_t options );
+/*-------------------------------------------------------------------------
+ * prototypes
+ *-------------------------------------------------------------------------
+ */
+
+int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
+ const char *obj2_name, options_t options );
int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank,
- hsize_t *dims, options_t options, char *obj1, char *obj2 );
-void print_pos( int *ph, int curr_pos, int *acc,
- int *pos, int rank, char *obj1, char *obj2 );
+ hsize_t *dims, options_t options, const char *obj1, const char *obj2 );
void print_class( H5T_class_t tclass, char *sclass );
-hid_t fixtype( hid_t f_type );
void list( const char *filename, int nobjects, info_t *info );
-void diff( hid_t file1_id, char *obj1_name, hid_t file2_id, char *obj2_name,
+void diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj2_name,
options_t options, int type );
-void compare( hid_t file1_id, char *obj1_name, int nobjects1, info_t *info1,
- hid_t file2_id, char *obj2_name, int nobjects2, info_t *info2,
+void compare( hid_t file1_id, const char *obj1_name, int nobjects1, info_t *info1,
+ hid_t file2_id, const char *obj2_name, int nobjects2, info_t *info2,
options_t options );
-void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1,
- hid_t file2_id, char *file2_name, int nobjects2, info_t *info2,
+void match( hid_t file1_id, const char *file1_name, int nobjects1, info_t *info1,
+ hid_t file2_id, const char *file2_name, int nobjects2, info_t *info2,
options_t options );
-int check_n_input( char * );
-int check_f_input( char * );
+void print_pos( int *ph, unsigned int curr_pos, int *acc,
+ int *pos, int rank, const char *obj1, const char *obj2 );
+
+/*-------------------------------------------------------------------------
+ * utility functions
+ *-------------------------------------------------------------------------
+ */
+
+hid_t fixtype( hid_t f_type );
+int check_n_input( const char* );
+int check_f_input( const char* );
+int get_index( const char *obj, int nobjects, info_t *info );
+int compare_object( char *obj1, char *obj2 );
+void usage(void);
+
/*-------------------------------------------------------------------------
@@ -72,34 +83,28 @@ int check_f_input( char * );
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Date: October 8, 2002
- *
- * Comments:
- *
- * Modifications:
+ * Date: April 9, 2003
*
*-------------------------------------------------------------------------
*/
-
-void usage( const char *progname )
+void usage(void)
{
-#define USAGE "\n\
- [OBJ1_NAME] Name of an HDF5 object\n\
- [OBJ2_NAME] Name of an HDF5 object\n\
- [-h ] Print a basic help message (this message)\n\
- [-l ] List contents of file\n\
- [-r ] Print only what objects differ\n\
- [-n count] Print difference up to count number for each variable\n\
- [-d delta] Print difference when it is greater than limit delta\n\
- [-p relative] Print differences which are within a relative error value\n\
- FILE1_NAME File name of the first HDF5 file\n\
- FILE2_NAME File name of the second HDF5 file\n"
-
- fprintf(stderr,
- "h5diff [OBJ1_NAME] [OBJ2_NAME] [-h] [-l] [-r] [-d] [-n count] [-d delta] [-p relative] FILE1_NAME FILE2_NAME\n%s",
- USAGE);
- fprintf(stderr,"\n");
- fprintf(stderr,"Items in [ ] are optional \n");
+ printf("Usage: h5diff [obj1_name] [obj2_name] [OPTIONS] file1_name [file2_name]\n");
+ printf("Items in [ ] are optional\n");
+ printf("\n");
+ printf("[obj1_name] Name of an HDF5 object\n");
+ printf("[obj2_name] Name of an HDF5 object\n");
+ printf("file1_name File name of the first HDF5 file\n");
+ printf("file2_name File name of the second HDF5 file\n");
+ printf("[OPTIONS] are:\n");
+ printf("[-h ] Print out this information\n");
+ printf("[-l ] List contents of file\n");
+ printf("[-r ] Print only what objects differ\n");
+ printf("[-n count] Print difference up to count number for each variable\n");
+ printf("[-d delta] Print difference when it is greater than limit delta\n");
+ printf("[-p relative] Print differences which are within a relative error value\n");
+ printf("\n");
+
}
@@ -123,8 +128,6 @@ void usage( const char *progname )
int main(int argc, const char *argv[])
{
-
- const char *progname = argv[0];
int argno;
const char *s = NULL;
hid_t file1_id, file2_id;
@@ -132,16 +135,18 @@ int main(int argc, const char *argv[])
int nobjects1, nobjects2;
info_t *info1=NULL;
info_t *info2=NULL;
- int obj1_found = 0;
- int obj2_found = 0;
+ /*int obj1_found = 0;
+ int obj2_found = 0;*/
options_t options = {0,0,0,0,0,0,0,0};
void *edata;
hid_t (*func)(void*);
- char *file1_name;
- char *file2_name;
- char *obj1_name = NULL;
- char *obj2_name = NULL;
+ const char *file1_name;
+ const char *file2_name;
+ const char *obj1_name = NULL;
+ const char *obj2_name = NULL;
+
+ /*do_test_files();*/
/*-------------------------------------------------------------------------
* parse command line options
@@ -149,7 +154,7 @@ int main(int argc, const char *argv[])
*/
if (argc < 3) {
- usage( progname );
+ usage();
exit(EXIT_FAILURE);
}
@@ -166,11 +171,11 @@ int main(int argc, const char *argv[])
switch (*s) {
default:
printf("-%s is an invalid option\n", s );
- usage(progname);
+ usage();
exit(EXIT_SUCCESS);
break;
case 'h':
- usage(progname);
+ usage();
exit(EXIT_SUCCESS);
case 'l':
options.l_ = 1;
@@ -184,10 +189,10 @@ int main(int argc, const char *argv[])
{
options.d_ = 1;
- if ( check_f_input(argv[argno+1])==-1 )
+ if ( check_f_input(argv[argno+1])==-1)
{
printf("<-d %s> is not a valid option\n", argv[argno+1] );
- usage(progname);
+ usage();
exit(EXIT_SUCCESS);
}
@@ -196,7 +201,7 @@ int main(int argc, const char *argv[])
else
{
printf("<-d %s> is not a valid option\n", argv[argno+1] );
- usage(progname);
+ usage();
exit(EXIT_SUCCESS);
}
break;
@@ -205,10 +210,10 @@ int main(int argc, const char *argv[])
{
options.p_ = 1;
- if ( check_f_input(argv[argno+1])==-1 )
+ if ( check_f_input(argv[argno+1])==-1)
{
printf("<-p %s> is not a valid option\n", argv[argno+1] );
- usage(progname);
+ usage();
exit(EXIT_SUCCESS);
}
@@ -220,10 +225,10 @@ int main(int argc, const char *argv[])
{
options.n_ = 1;
- if ( check_n_input(argv[argno+1])==-1 )
+ if ( check_n_input(argv[argno+1])==-1)
{
printf("<-n %s> is not a valid option\n", argv[argno+1] );
- usage(progname);
+ usage();
exit(EXIT_SUCCESS);
}
options.n_number_count = atoi(argv[argno+1]);
@@ -373,7 +378,7 @@ int main(int argc, const char *argv[])
*-------------------------------------------------------------------------
*/
-int check_n_input( char *str )
+int check_n_input( const char *str )
{
unsigned i;
char c;
@@ -405,7 +410,7 @@ int check_n_input( char *str )
*-------------------------------------------------------------------------
*/
-int check_f_input( char *str )
+int check_f_input( const char *str )
{
unsigned i;
char c;
@@ -483,8 +488,7 @@ void list( const char *filename, int nobjects, info_t *info )
*-------------------------------------------------------------------------
*/
-
-int get_index( char *obj, int nobjects, info_t *info )
+int get_index( const char *obj, int nobjects, info_t *info )
{
char *pdest;
int result;
@@ -497,7 +501,7 @@ int get_index( char *obj, int nobjects, info_t *info )
return i;
pdest = strstr( info[i].name, obj );
- result = pdest - info[i].name;
+ result = (int)(pdest - info[i].name);
/* found at position 1, meaning without '/' */
if( pdest != NULL && result==1 )
@@ -525,8 +529,8 @@ int get_index( char *obj, int nobjects, info_t *info )
*/
-void compare( hid_t file1_id, char *obj1_name, int nobjects1, info_t *info1,
- hid_t file2_id, char *obj2_name, int nobjects2, info_t *info2,
+void compare( hid_t file1_id, const char *obj1_name, int nobjects1, info_t *info1,
+ hid_t file2_id, const char *obj2_name, int nobjects2, info_t *info2,
options_t options )
{
@@ -576,7 +580,7 @@ void compare( hid_t file1_id, char *obj1_name, int nobjects1, info_t *info1,
*/
-void diff( hid_t file1_id, char *obj1_name, hid_t file2_id, char *obj2_name,
+void diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj2_name,
options_t options, int type )
{
@@ -589,7 +593,7 @@ void diff( hid_t file1_id, char *obj1_name, hid_t file2_id, char *obj2_name,
*/
case H5G_GROUP:
-
+ printf( "<%s> and <%s> are of type H5G_GROUP\n", obj1_name, obj2_name );
break;
/*-------------------------------------------------------------------------
@@ -598,7 +602,6 @@ void diff( hid_t file1_id, char *obj1_name, hid_t file2_id, char *obj2_name,
*/
case H5G_DATASET:
-
diff_dataset(file1_id,file2_id,obj1_name,obj2_name,options);
break;
@@ -608,17 +611,13 @@ void diff( hid_t file1_id, char *obj1_name, hid_t file2_id, char *obj2_name,
*/
case H5G_TYPE:
-
+ printf( "<%s> and <%s> are of type H5G_TYPE\n", obj1_name, obj2_name );
break;
} /* switch */
-
-
+
}
-
-
-
/*-------------------------------------------------------------------------
* Function: compare_object
*
@@ -664,8 +663,8 @@ int compare_object( char *obj1, char *obj2 )
*-------------------------------------------------------------------------
*/
-void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1,
- hid_t file2_id, char *file2_name, int nobjects2, info_t *info2,
+void match( hid_t file1_id, const char *file1_name, int nobjects1, info_t *info1,
+ hid_t file2_id, const char *file2_name, int nobjects2, info_t *info2,
options_t options )
{
int cmp;
@@ -752,8 +751,8 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1,
*-------------------------------------------------------------------------
*/
-int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
- char *obj2_name, options_t options )
+int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
+ const char *obj2_name, options_t options )
{
hid_t dset1_id, dset2_id;
@@ -770,7 +769,7 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
char sclass1[20];
char sclass2[20];
int nfound;
- size_t type1_size, type2_size;
+ /*size_t type1_size, type2_size;*/
hid_t type_mem =-1; /* read to memory type */
void *edata;
hid_t (*func)(void*);
@@ -811,8 +810,8 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
goto out;
/* Get the size */
- type1_size = H5Tget_size( type1_id );
- type2_size = H5Tget_size( type2_id );
+ /*type1_size = H5Tget_size( type1_id );
+ type2_size = H5Tget_size( type2_id );*/
/* Get the dataspace handle */
if ( (space1_id = H5Dget_space(dset1_id)) < 0 )
@@ -893,6 +892,8 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
case H5T_ARRAY:
printf( "H5T_ARRAY comparison is not supported\n");
goto out;
+ default:
+ break;
}
/*-------------------------------------------------------------------------
@@ -907,12 +908,12 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
printf( "<%s>: ", obj1_name );
printf("[ " );
for (j = 0; j < rank1; j++)
- printf("%d ", dims1[j] );
+ printf("%d ", (int)dims1[j] );
printf("]\n" );
printf( "<%s>: ", obj2_name );
printf("[ " );
for (j = 0; j < rank1; j++)
- printf("%d ", dims2[j] );
+ printf("%d ", (int)dims2[j] );
printf("]\n" );
goto out;
}
@@ -930,12 +931,12 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name,
printf( "<%s>: ", obj1_name );
printf("[ " );
for (j = 0; j < rank1; j++)
- printf("%d ", dims1[j] );
+ printf("%d ", (int)dims1[j] );
printf("]\n" );
printf( "<%s>: ", obj2_name );
printf("[ " );
for (j = 0; j < rank1; j++)
- printf("%d ", dims2[j] );
+ printf("%d ", (int)dims2[j] );
printf("]\n" );
goto out;
}
@@ -1033,7 +1034,7 @@ out:
*/
int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank,
- hsize_t *dims, options_t options, char *obj1, char *obj2 )
+ hsize_t *dims, options_t options, const char *obj1, const char *obj2 )
{
char *i1ptr1, *i1ptr2;
short *i2ptr1, *i2ptr2;
@@ -1042,20 +1043,21 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
float *fptr1, *fptr2;
double *dptr1, *dptr2;
int nfound=0; /* number of differences found */
- int ph=1; /* print header /*
+ int ph=1; /* print header */
+ int i8diff;
/* accumulator and matrix position */
- int acc[32];
- int pos[32];
- int i;
+ int acc[32];
+ int pos[32];
+ unsigned int i; int j;
H5T_class_t type_class;
size_t type_size;
acc[rank-1]=1;
- for(i=(rank-2); i>=0; i--)
+ for(j=(rank-2); j>=0; j--)
{
- acc[i]=acc[i+1]*(int)dims[i+1];
+ acc[j]=acc[j+1]*(int)dims[j+1];
}
/* Get the class. */
@@ -1067,6 +1069,10 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
switch(type_class)
{
+ default:
+ return -1;
+ /*break;*/
+
case H5T_INTEGER:
@@ -1122,7 +1128,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
else if ( options.d_ && options.p_ )
{
if ( abs(1 - *i1ptr1 / *i1ptr2) > options.p_relative &&
- fabs(*i1ptr1 - *i1ptr2) > options.d_delta )
+ abs(*i1ptr1 - *i1ptr2) > options.d_delta )
{
if ( options.n_ && nfound>=options.n_number_count)
return nfound;
@@ -1329,6 +1335,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
case 8:
i8ptr1 = (long *) buf1;
i8ptr2 = (long *) buf2;
+ i8diff = (int)(*i8ptr1 - *i8ptr2);
for ( i = 0; i < tot_cnt; i++)
{
@@ -1337,13 +1344,13 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
{
if ( options.n_ && nfound>=options.n_number_count)
return nfound;
- if ( abs(*i8ptr1 - *i8ptr2) > options.d_delta )
+ if ( abs(i8diff) > options.d_delta )
{
if ( options.r_==0 )
{
print_pos( &ph, i, acc, pos, rank, obj1, obj2 );
printf(SPACES);
- printf(IFORMAT, *i8ptr1, *i8ptr2, abs(*i8ptr1 - *i8ptr2));
+ printf(LIFORMAT, *i8ptr1, *i8ptr2, i8diff);
}
nfound++;
}
@@ -1352,7 +1359,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
/* percentage but not delta */
else if ( !options.d_ && options.p_ )
{
- if ( abs(1 - *i8ptr1 / *i8ptr2) > options.p_relative )
+ if ( abs((int)(1 - *i8ptr1 / *i8ptr2)) > options.p_relative )
{
if ( options.n_ && nfound>=options.n_number_count)
return nfound;
@@ -1360,7 +1367,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
{
print_pos( &ph, i, acc, pos, rank, obj1, obj2 );
printf(SPACES);
- printf(IFORMAT, *i8ptr1, *i8ptr2, abs(*i8ptr1 - *i8ptr2));
+ printf(LIFORMAT, *i8ptr1, *i8ptr2, i8diff);
}
nfound++;
}
@@ -1369,8 +1376,8 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
/* percentage and delta */
else if ( options.d_ && options.p_ )
{
- if ( abs(1 - *i8ptr1 / *i8ptr2) > options.p_relative &&
- abs(*i8ptr1 - *i8ptr2) > options.d_delta )
+ if ( abs((int)(1 - *i8ptr1 / *i8ptr2)) > options.p_relative &&
+ abs(i8diff) > options.d_delta )
{
if ( options.n_ && nfound>=options.n_number_count)
return nfound;
@@ -1378,7 +1385,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
{
print_pos( &ph, i, acc, pos, rank, obj1, obj2 );
printf(SPACES);
- printf(IFORMAT, *i8ptr1, *i8ptr2, abs(*i8ptr1 - *i8ptr2));
+ printf(LIFORMAT, *i8ptr1, *i8ptr2, i8diff);
}
nfound++;
}
@@ -1394,7 +1401,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
{
print_pos( &ph, i, acc, pos, rank, obj1, obj2 );
printf(SPACES);
- printf(IFORMAT, *i8ptr1, *i8ptr2, abs(*i8ptr1 - *i8ptr2));
+ printf(LIFORMAT, *i8ptr1, *i8ptr2, i8diff);
}
nfound++;
@@ -1617,8 +1624,8 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank
*-------------------------------------------------------------------------
*/
-void print_pos( int *ph, int curr_pos, int *acc,
- int *pos, int rank, char *obj1, char *obj2 )
+void print_pos( int *ph, unsigned int curr_pos, int *acc,
+ int *pos, int rank, const char *obj1, const char *obj2 )
{
int i;
@@ -1670,6 +1677,9 @@ void print_class( H5T_class_t tclass, char *sclass )
{
switch (tclass)
{
+ default:
+ printf("Invalid class");
+ break;
case H5T_TIME:
strcpy(sclass,"H5T_TIME");
break;
@@ -1734,6 +1744,9 @@ hid_t fixtype(hid_t f_type)
switch (H5Tget_class(f_type))
{
+ default:
+ return -1;
+ /*break;*/
case H5T_INTEGER:
/*
* Use the smallest native integer type of the same sign as the file
@@ -1785,3 +1798,4 @@ hid_t fixtype(hid_t f_type)
}
+
diff --git a/tools/h5diff/h5difftst.c b/tools/h5diff/h5difftst.c
index 6e2b54f..41e5da6 100644
--- a/tools/h5diff/h5difftst.c
+++ b/tools/h5diff/h5difftst.c
@@ -17,7 +17,12 @@
#include "hdf5.h"
-int do_test_files();
+
+
+/* diff tst*/
+int do_test_files(void);
+int write_dataset( hid_t file_id, int rank, hsize_t *dims, const char *dset_name,
+ hid_t type_id, void *data );
int main(int argc, const char *argv[])
@@ -28,13 +33,283 @@ int main(int argc, const char *argv[])
}
+/*-------------------------------------------------------------------------
+ * these command line options are tested in ./testh5diff.sh
+ *-------------------------------------------------------------------------
+ */
+
+/*
+# test 1.1
+dset1.1 g1.1 h5diff_test1.h5 h5diff_test2.h5
+g1.1 g1.1 h5diff_test1.h5 h5diff_test2.h5
+# test 1.2
+compound h5diff_test1.h5 h5diff_test2.h5
+enum h5diff_test1.h5 h5diff_test2.h5
+# test 1.3
+dset1.3 h5diff_test1.h5 h5diff_test2.h5
+# test 1.4
+dset1.1 dset1.4 h5diff_test1.h5 h5diff_test2.h5
+# test 1.5
+dset1.1 dset1.5 h5diff_test1.h5 h5diff_test2.h5
+# test 1.6
+dset1.1 dset1.6 h5diff_test1.h5 h5diff_test2.h5
+
+# Different datatype sizes and different mix of options
+# test 2.1.0
+dset2.1 dset2.2 h5diff_test1.h5 h5diff_test2.h5
+# test 2.1.1
+dset2.1 dset2.2 -n 2 h5diff_test1.h5 h5diff_test2.h5
+# test 2.1.2
+dset2.1 dset2.2 -d 3 h5diff_test1.h5 h5diff_test2.h5
+
+
+*/
+
+
+int do_test_files(void)
+{
+
+ hid_t file1_id, file2_id;
+ hid_t dataset_id;
+ hid_t space_id;
+ hid_t group_id;
+ hid_t type_id, type2_id;
+ herr_t status;
+ int val;
+
+ /* Test 1. */
+ hsize_t dims1 [1] = { 7 };
+ hsize_t dims1_1[1] = { 8 };
+ hsize_t dims2 [2] = { 3,2 };
+ char data1_3[] = {"A string"};
+ float data1_4[7] = {1,1,3,4,5,6,7};
+
+ /* Test 2. */
+ char data2_1[3][2] = {{1,1},{1,1},{1,1}};
+ char data2_2[3][2] = {{1,1},{3,4},{5,6}};
+
+/*
+ float data5[3][2] = {{1,1},{3,4},{5,6}};
+ float data6[3][2] = {{1,1.1f},{3.02f,4.002f},{5.00002f,6}};
+ double data8[3][2] = {{1,1},{3.40505e-9,4},{5,6}};
+ double data9[3][2] = {{1,1},{3.58911e-9,4},{5,6}};*/
+
+ /* Compound datatype */
+ typedef struct s_t
+ {
+ int a;
+ float b;
+ } s_t;
+
+ typedef enum
+ {
+ E_RED,
+ E_GREEN
+} e_t;
+
+/*-------------------------------------------------------------------------
+ * Create two files
+ *-------------------------------------------------------------------------
+ */
+
+ /* Create a file */
+ file1_id = H5Fcreate ("h5diff_test1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create a file */
+ file2_id = H5Fcreate ("h5diff_test2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+/*-------------------------------------------------------------------------
+ * Test 1.1
+ * Objects are not the same type (e.g try to compare a group with a dataset)
+ *-------------------------------------------------------------------------
+ */
+
+ /* Create a data space */
+ space_id = H5Screate_simple(1,dims1,NULL);
+
+ /* Create a dataset "dset1.1" */
+ dataset_id = H5Dcreate(file1_id,"dset1.1",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
+
+ /* Close */
+ status = H5Dclose(dataset_id);
+ status = H5Sclose(space_id);
+
+ /* Create a group "g1.1" on file2 */
+ group_id = H5Gcreate(file2_id, "g1.1", 0);
+
+ /* Close */
+ status = H5Gclose(group_id);
+
+/*-------------------------------------------------------------------------
+ * Test 1.2
+ * Objects are of classes H5G_TYPE and H5G_GROUP and their name is supplied
+ *-------------------------------------------------------------------------
+ */
+
+ /* Create a group "g1.1" on file1 */
+ group_id = H5Gcreate(file1_id, "g1.1", 0);
+
+ /* Close */
+ status = H5Gclose(group_id);
+
+ /* Create a memory compound datatype on file1 */
+ type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_INT);
+ H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT);
+ /* Commit compound datatype and close it */
+ H5Tcommit(file1_id, "compound", type_id);
+ type2_id = H5Tcopy(type_id);
+ H5Tcommit(file2_id, "compound", type2_id);
+ H5Tclose(type_id);
+ H5Tclose(type2_id);
+
+ /* Create a memory enum datatype on file1 */
+ type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(type_id, "RED", (val = 0, &val));
+ H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
+ type2_id = H5Tcopy(type_id);
+
+ /* Commit enumeration datatype and close it */
+ H5Tcommit(file1_id, "enum", type_id);
+ H5Tcommit(file2_id, "enum", type2_id);
+ H5Tclose(type_id);
+ H5Tclose(type2_id);
+
+/*-------------------------------------------------------------------------
+ * Test 1.3
+ * Check for non supported classes. Supported classes are H5T_INTEGER and H5T_FLOAT
+ * Non supported classes are
+ * H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE,
+ * H5T_ENUM, H5T_VLEN, H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+/*-------------------------------------------------------------------------
+ * Write two string datatypes
+ *-------------------------------------------------------------------------
+ */
+
+ /* Create a data space */
+ space_id = H5Screate(H5S_SCALAR);
+
+ /* Make a string type */
+ type_id = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size (type_id, strlen(data1_3));
+
+ /* Create a dataset "dset1.3" on file 1 */
+ dataset_id = H5Dcreate(file1_id,"dset1.3",type_id,space_id,H5P_DEFAULT);
+
+ /* Write the data */
+ status = H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,data1_3);
+
+ /* Close */
+ status = H5Dclose(dataset_id);
+
+ /* Create a dataset "dset1.3" on file 2 */
+ dataset_id = H5Dcreate(file2_id,"dset1.3",type_id,space_id,H5P_DEFAULT);
+
+ /* Write the data */
+ status = H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,data1_3);
+
+ /* Close */
+ status = H5Dclose(dataset_id);
+ status = H5Sclose(space_id);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * Test 1.4
+ * Datasets are not the same class type
+ * Write a float dataset and compare with integer "dset1.1"
+ *-------------------------------------------------------------------------
+ */
+
+ write_dataset(file2_id,1,dims1,"dset1.4",H5T_NATIVE_FLOAT,data1_4);
+
+/*-------------------------------------------------------------------------
+ * Test 1.5
+ * Datasets are not the same rank
+ *-------------------------------------------------------------------------
+ */
+
+ write_dataset(file2_id,2,dims2,"dset1.5",H5T_NATIVE_INT,NULL);
+
+/*-------------------------------------------------------------------------
+ * Test 1.6
+ * Check for the same current dimensions. Only compare if they are the same.
+ *-------------------------------------------------------------------------
+ */
+ write_dataset(file2_id,1,dims1_1,"dset1.6",H5T_NATIVE_INT,NULL);
/*-------------------------------------------------------------------------
- * do some test files
+ * Test 2.1
+ * Check for the same current dimensions. Only compare if they are the same.
*-------------------------------------------------------------------------
*/
+ write_dataset(file1_id,2,dims2,"dset2.1",H5T_NATIVE_CHAR,data2_1);
+ write_dataset(file2_id,2,dims2,"dset2.2",H5T_NATIVE_CHAR,data2_2);
+
+
+
+/*-------------------------------------------------------------------------
+ * Close files
+ *-------------------------------------------------------------------------
+ */
+ status = H5Fclose(file1_id);
+ status = H5Fclose(file2_id);
+
+
+ return 0;
+
+
+}
+
+/*-------------------------------------------------------------------------
+ * Function: write_dataset
+ *
+ * Purpose: utility function to write a dataset
+ *
+ * Return:
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: April 7, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+
+int write_dataset( hid_t file_id, int rank, hsize_t *dims, const char *dset_name,
+ hid_t type_id, void *data )
+{
+ hid_t dataset_id;
+ hid_t space_id;
+ herr_t status;
+
+ /* Create a data space */
+ space_id = H5Screate_simple(rank,dims,NULL);
+
+ /* Create a dataset "dset" */
+ dataset_id = H5Dcreate(file_id,dset_name,type_id,space_id,H5P_DEFAULT);
+
+ /* Write the data */
+ if ( data )
+ status = H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,data);
+
+ /* Close */
+ status = H5Dclose(dataset_id);
+ status = H5Sclose(space_id);
+
+ return 0;
+
+}
+
+
+
+
+#if 0
+
+
/*
dset1 dset2 h5diff_test1.h5 h5diff_test2.h5
dset1 dset2 -l h5diff_test1.h5 h5diff_test2.h5
@@ -48,7 +323,6 @@ dset8 dset9 h5diff_test2.h5 h5diff_test2.h5
dset11 dset12 h5diff_test1.h5 h5diff_test2.h5
*/
-
int do_test_files()
{
@@ -399,4 +673,4 @@ int do_test_files()
}
-
+#endif \ No newline at end of file
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index c106059..f225901 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -79,9 +79,9 @@ TOOLTEST() {
fi
# Clean up output file
- if test -z "$HDF5_NOCLEANUP"; then
- rm -f $actual $actual_err
- fi
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err
+ fi
}
##############################################################################
@@ -90,20 +90,81 @@ TOOLTEST() {
##############################################################################
##############################################################################
-# test1: Check if the command line number of arguments is less than 3
-TOOLTEST h5diff_1.txt h5diff_test1.h5
+##############################################################################
+# tests 0., check for bad input values
+##############################################################################
+
+# test 0.1: Check if the command line number of arguments is less than 3
+TOOLTEST h5diff_01.txt h5diff_test1.h5
+
+# test 0.2: Check for invalid options
+TOOLTEST h5diff_02.txt -x h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.3: Check for -h option
+TOOLTEST h5diff_03.txt -h h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.4: Check for invalid -d options
+TOOLTEST h5diff_04.txt -d h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.5: Check for invalid -d options
+TOOLTEST h5diff_05.txt -d -4 h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.6: Check for invalid -p options
+TOOLTEST h5diff_06.txt -p h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.7: Check for invalid -p options
+TOOLTEST h5diff_07.txt -p -4 h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.8: Check for invalid -n options
+TOOLTEST h5diff_08.txt -n h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.9: Check for invalid -n options
+TOOLTEST h5diff_09.txt -n 0 h5diff_test1.h5 h5diff_test2.h5
+
+# test 0.10: Check if the file names supplied are valid files
+TOOLTEST h5diff_010.txt h5diff_test1.h6 h5diff_test2.h6
+
+##############################################################################
+# tests 1., Check for not comparable issues
+##############################################################################
+
+# test 1.1.1: Objects are not the same type (e.g try to compare a group with a dataset)
+TOOLTEST h5diff_111.txt dset1.1 g1.1 h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.1.2: Objects are not the same type (e.g try to compare a group with a dataset)
+TOOLTEST h5diff_112.txt g1.1 g1.1 h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.2.1: Objects are of classes H5G_TYPE and H5G_GROUP and their name is supplied
+TOOLTEST h5diff_121.txt compound h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.2.2: Objects are of classes H5G_TYPE and H5G_GROUP and their name is supplied
+TOOLTEST h5diff_122.txt enum h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.3: Check for non supported classes. Supported classes are H5T_INTEGER and H5T_FLOAT
+TOOLTEST h5diff_13.txt dset1.3 h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.4: Objects are not the same dataset class type
+TOOLTEST h5diff_14.txt dset1.1 dset1.4 h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.5: Check for the same rank, for datasets
+TOOLTEST h5diff_15.txt dset1.1 dset1.5 h5diff_test1.h5 h5diff_test2.h5
+
+# test 1.6: Check for the same current dimensions
+TOOLTEST h5diff_16.txt dset1.1 dset1.6 h5diff_test1.h5 h5diff_test2.h5
+
+##############################################################################
+# tests 2., Different datatype sizes and different mix of options
+##############################################################################
-# test2: Check for invalid options
-TOOLTEST h5diff_2.txt -x h5diff_test1.h5 h5diff_test2.h5
+# test 2.1.0: H5T_INTEGER size 1 
+TOOLTEST h5diff_210.txt dset2.1 dset2.2 h5diff_test1.h5 h5diff_test2.h5
-# test3: Check for -h option
-TOOLTEST h5diff_3.txt -h h5diff_test1.h5 h5diff_test2.h5
+# test 2.1.1: H5T_INTEGER size 1 
+TOOLTEST h5diff_211.txt dset2.1 dset2.2 -n 2 h5diff_test1.h5 h5diff_test2.h5
-# test4: Check for invalid -d options
-TOOLTEST h5diff_4.txt -d h5diff_test1.h5 h5diff_test2.h5
+# test 2.1.2: H5T_INTEGER size 1 
+TOOLTEST h5diff_212.txt dset2.1 dset2.2 -d 3 h5diff_test1.h5 h5diff_test2.h5
-# test5: Check for invalid -d options
-TOOLTEST h5diff_5.txt -d -4 h5diff_test1.h5 h5diff_test2.h5
if test $nerrors -eq 0 ; then
echo "All $H5DIFF tests passed."