summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/h5diff/h5diff.c161
-rw-r--r--tools/h5diff/h5difftst.c72
-rwxr-xr-xtools/h5diff/testh5diff.sh3
-rw-r--r--tools/testfiles/file1.h5bin6240 -> 6240 bytes
-rw-r--r--tools/testfiles/file2.h5bin6288 -> 6288 bytes
-rw-r--r--tools/testfiles/file3.h5bin4352 -> 4352 bytes
-rw-r--r--tools/testfiles/file4.h5bin4352 -> 4352 bytes
-rw-r--r--tools/testfiles/file5.h5bin2936 -> 2936 bytes
-rw-r--r--tools/testfiles/file6.h5bin8016 -> 9432 bytes
-rw-r--r--tools/testfiles/h5diff_16.txt16
-rw-r--r--tools/testfiles/h5diff_57.txt11
11 files changed, 188 insertions, 75 deletions
diff --git a/tools/h5diff/h5diff.c b/tools/h5diff/h5diff.c
index d399871..6867b2e 100644
--- a/tools/h5diff/h5diff.c
+++ b/tools/h5diff/h5diff.c
@@ -51,44 +51,46 @@ typedef struct options_t
*-------------------------------------------------------------------------
*/
-int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
- const char *obj2_name, options_t options );
-int diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj2_name,
- options_t options, int type );
-int compare( hid_t file1_id, const char *file1_name, const char *obj1_name,
- int nobjects1, info_t *info1,
- hid_t file2_id, const char *file2_name, const char *obj2_name,
- int nobjects2, info_t *info2,
- options_t options );
-int 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 array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims,
- options_t options, const char *obj1, const char *obj2,
- hid_t m_type );
+static int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
+ const char *obj2_name, options_t options );
+static int diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj2_name,
+ options_t options, int type );
+static int compare( hid_t file1_id, const char *file1_name, const char *obj1_name,
+ int nobjects1, info_t *info1,
+ hid_t file2_id, const char *file2_name, const char *obj2_name,
+ int nobjects2, info_t *info2,
+ options_t options );
+static int match( hid_t file1_id, int nobjects1, info_t *info1,
+ hid_t file2_id, int nobjects2, info_t *info2, options_t options );
+static int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims,
+ options_t options, const char *obj1, const char *obj2,
+ hid_t m_type );
/*-------------------------------------------------------------------------
* utility functions
*-------------------------------------------------------------------------
*/
-void list( const char *filename, int nobjects, info_t *info );
-void print_pos( int *ph, int p, unsigned int curr_pos, int *acc,
- int *pos, int rank, const char *obj1, const char *obj2 );
-hid_t fixtype( hid_t f_type );
-void print_datatype(hid_t 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);
-const char* h5diff_basename(const char *name);
-const char* get_type(int type);
-const char* get_class(H5T_class_t tclass);
-void print_dims( int r, hsize_t *d );
-void print_sizes( const char *obj1, const char *obj2,
- hid_t f_type1, hid_t f_type2,
- hid_t m_type1, hid_t m_type2 );
+static void list( const char *filename, int nobjects, info_t *info );
+static hid_t fixtype( hid_t f_type );
+static void print_datatype(hid_t type);
+static int check_n_input( const char* );
+static int check_f_input( const char* );
+static int get_index( const char *obj, int nobjects, info_t *info );
+static int compare_object( char *obj1, char *obj2 );
+static void usage(void);
+static const char* h5diff_basename(const char *name);
+static const char* get_type(int type);
+static const char* get_class(H5T_class_t tclass);
+static const char* get_sign(H5T_sign_t sign);
+static void print_dims( int r, hsize_t *d );
+static void print_pos( int *ph, int p, unsigned int curr_pos, int *acc,
+ int *pos, int rank, const char *obj1, const char *obj2 );
+#if defined (H5DIFF_DEBUG)
+static void print_sizes( const char *obj1, const char *obj2,
+ hid_t f_type1, hid_t f_type2,
+ hid_t m_type1, hid_t m_type2 );
+#endif
/*-------------------------------------------------------------------------
@@ -104,6 +106,7 @@ void print_sizes( const char *obj1, const char *obj2,
*
*-------------------------------------------------------------------------
*/
+static
void usage(void)
{
printf("Usage: h5diff file1 file2 [OPTIONS] [obj1[obj2]] \n");
@@ -371,8 +374,8 @@ int main(int argc, const char *argv[])
else
{
- nfound=match(file1_id,file1_name,nobjects1,info1,
- file2_id,file2_name,nobjects2,info2,options);
+ nfound=match(file1_id,nobjects1,info1,
+ file2_id,nobjects2,info2,options);
}
/* close */
@@ -405,7 +408,7 @@ int main(int argc, const char *argv[])
*
*-------------------------------------------------------------------------
*/
-
+static
int check_n_input( const char *str )
{
unsigned i;
@@ -443,7 +446,7 @@ int check_n_input( const char *str )
*
*-------------------------------------------------------------------------
*/
-
+static
int check_f_input( const char *str )
{
unsigned i;
@@ -480,7 +483,7 @@ int check_f_input( const char *str )
*
*-------------------------------------------------------------------------
*/
-
+static
void list( const char *filename, int nobjects, info_t *info )
{
int i;
@@ -528,7 +531,7 @@ void list( const char *filename, int nobjects, info_t *info )
*
*-------------------------------------------------------------------------
*/
-
+static
int compare_object( char *obj1, char *obj2 )
{
int cmp;
@@ -557,10 +560,9 @@ int compare_object( char *obj1, char *obj2 )
*
*-------------------------------------------------------------------------
*/
-
-int 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 )
+static
+int match( hid_t file1_id, int nobjects1, info_t *info1,
+ hid_t file2_id, int nobjects2, info_t *info2, options_t options )
{
int cmp;
int more_names_exist = (nobjects1>0 && nobjects2>0) ? 1 : 0;
@@ -724,7 +726,7 @@ int get_index( const char *obj, int nobjects, info_t *info )
*-------------------------------------------------------------------------
*/
-
+static
int compare( hid_t file1_id, const char *file1_name, const char *obj1_name,
int nobjects1, info_t *info1,
hid_t file2_id, const char *file2_name, const char *obj2_name,
@@ -789,7 +791,7 @@ int compare( hid_t file1_id, const char *file1_name, const char *obj1_name,
*-------------------------------------------------------------------------
*/
-
+static
int diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj2_name,
options_t options, int type )
{
@@ -831,7 +833,7 @@ int diff( hid_t file1_id, const char *obj1_name, hid_t file2_id, const char *obj
*
*-------------------------------------------------------------------------
*/
-
+static
int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
const char *obj2_name, options_t options )
{
@@ -844,6 +846,7 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
hid_t m_type1=-1, m_type2=-1; /* memory data type */
size_t f_size1, f_size2; /* size of type in file */
size_t m_size1, m_size2; /* size of type in memory */
+ H5T_sign_t sign1, sign2; /* sign of type */
int rank1, rank2;
void *buf1=NULL, *buf2=NULL;
hsize_t tot_cnt1, tot_cnt2;
@@ -1090,6 +1093,21 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name,
print_sizes(obj1_name,obj2_name,f_type1,f_type2,m_type1,m_type2);
#endif
+/*-------------------------------------------------------------------------
+ * check for different signed/unsigned types
+ *-------------------------------------------------------------------------
+ */
+
+ sign1=H5Tget_sign(m_type1);
+ sign2=H5Tget_sign(m_type2);
+ if ( sign1 != sign2 )
+ {
+ printf("Comparison not supported\n");
+ printf("<%s> has sign %s\n", obj1_name, get_sign(sign1));
+ printf("<%s> has sign %s", obj2_name, get_sign(sign2));
+ goto out;
+ }
+
/*-------------------------------------------------------------------------
* "upgrade" the smaller memory size
@@ -1191,7 +1209,7 @@ out:
*
*-------------------------------------------------------------------------
*/
-
+static
int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims,
options_t options, const char *obj1, const char *obj2,
hid_t m_type )
@@ -1247,7 +1265,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims
*-------------------------------------------------------------------------
*/
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
+ if (H5Tequal(m_type, H5T_NATIVE_SCHAR)||H5Tequal(m_type, H5T_NATIVE_UCHAR))
{
assert(type_size==sizeof(char));
for ( i = 0; i < tot_cnt; i++)
@@ -1330,7 +1348,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
+ else if (H5Tequal(m_type, H5T_NATIVE_SHORT)||H5Tequal(m_type, H5T_NATIVE_USHORT))
{
assert(type_size==sizeof(short));
for ( i = 0; i < tot_cnt; i++)
@@ -1413,7 +1431,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
+ else if (H5Tequal(m_type, H5T_NATIVE_INT)||H5Tequal(m_type, H5T_NATIVE_UINT))
{
assert(type_size==sizeof(int));
for ( i = 0; i < tot_cnt; i++)
@@ -1495,7 +1513,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
+ else if (H5Tequal(m_type, H5T_NATIVE_LONG)||H5Tequal(m_type, H5T_NATIVE_ULONG))
{
assert(type_size==sizeof(long));
for ( i = 0; i < tot_cnt; i++)
@@ -1771,6 +1789,7 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, int rank, hsize_t *dims
*
*-------------------------------------------------------------------------
*/
+static
hid_t fixtype(hid_t f_type)
{
hid_t m_type = -1;
@@ -1883,7 +1902,7 @@ hid_t fixtype(hid_t f_type)
*
*-------------------------------------------------------------------------
*/
-
+static
void print_pos( int *ph, int p, unsigned int curr_pos, int *acc,
int *pos, int rank, const char *obj1, const char *obj2 )
{
@@ -1937,6 +1956,7 @@ void print_pos( int *ph, int p, unsigned int curr_pos, int *acc,
*
*-------------------------------------------------------------------------
*/
+static
void print_dims( int r, hsize_t *d )
{
int i;
@@ -1962,7 +1982,7 @@ void print_dims( int r, hsize_t *d )
*
*-------------------------------------------------------------------------
*/
-
+static
void print_datatype(hid_t type)
{
switch (H5Tget_class(type))
@@ -2065,7 +2085,7 @@ void print_datatype(hid_t type)
*
*-------------------------------------------------------------------------
*/
-
+static
const char*
h5diff_basename(const char *name)
{
@@ -2096,7 +2116,7 @@ h5diff_basename(const char *name)
*
*-------------------------------------------------------------------------
*/
-
+static
const char*
get_type(int type)
{
@@ -2116,6 +2136,35 @@ get_type(int type)
}
/*-------------------------------------------------------------------------
+ * Function: get_sign
+ *
+ * Purpose: Returns the sign as a string
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: May 9, 2003
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+const char*
+get_sign(H5T_sign_t sign)
+{
+ switch (sign)
+ {
+ default:
+ return("H5T_SGN_ERROR");
+ case H5T_SGN_NONE:
+ return("H5T_SGN_NONE");
+ case H5T_SGN_2:
+ return("H5T_SGN_2");
+ }
+}
+
+
+/*-------------------------------------------------------------------------
* Function: get_class
*
* Purpose: Returns the class as a string
@@ -2128,7 +2177,7 @@ get_type(int type)
*
*-------------------------------------------------------------------------
*/
-
+static
const char*
get_class(H5T_class_t tclass)
{
@@ -2169,7 +2218,7 @@ get_class(H5T_class_t tclass)
*
*-------------------------------------------------------------------------
*/
-
+static
void print_sizes( const char *obj1, const char *obj2,
hid_t f_type1, hid_t f_type2,
hid_t m_type1, hid_t m_type2 )
diff --git a/tools/h5diff/h5difftst.c b/tools/h5diff/h5difftst.c
index 844d534..968365b 100644
--- a/tools/h5diff/h5difftst.c
+++ b/tools/h5diff/h5difftst.c
@@ -17,19 +17,27 @@
#include "hdf5.h"
+#if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus
+# undef __attribute__
+# define __attribute__(X) /*void*/
+# define UNUSED /*void*/
+#else
+# define UNUSED __attribute__((unused))
+#endif
+
/* diff test*/
-int do_test_1(const char *file1, const char *file2);
-int do_test_2(const char *file1, const char *file2);
-int do_test_3(const char *file1, const char *file2);
-int do_test_4(const char *file1, const char *file2);
-int do_test_5(const char *file1, const char *file2);
-int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
- hid_t type_id, void *buf );
+static int do_test_1(const char *file1, const char *file2);
+static int do_test_2(const char *file1, const char *file2);
+static int do_test_3(const char *file1, const char *file2);
+static int do_test_4(const char *file1, const char *file2);
+static int do_test_5(const char *file1, const char *file2);
+static int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
+ hid_t type_id, void *buf );
-int main(int argc, const char *argv[])
+int main(int UNUSED argc, const UNUSED char *argv[])
{
do_test_1("file1.h5","file2.h5");
@@ -56,6 +64,7 @@ int main(int argc, const char *argv[])
*-------------------------------------------------------------------------
*/
+static
int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
hid_t type_id, void *buf )
{
@@ -317,14 +326,14 @@ int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
file1.h6 file2.h6
-/*
+*/
/*-------------------------------------------------------------------------
* Basic review tests
*-------------------------------------------------------------------------
*/
-
+static
int do_test_1(const char *file1, const char *file2)
{
@@ -374,8 +383,8 @@ int do_test_1(const char *file1, const char *file2)
* Compare different types: H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK
*-------------------------------------------------------------------------
*/
-
-int do_test_2(const char *file1, const char *file2)
+static
+int do_test_2(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
@@ -447,8 +456,8 @@ int do_test_2(const char *file1, const char *file2)
* H5T_ENUM, H5T_VLEN, H5T_ARRAY
*-------------------------------------------------------------------------
*/
-
-int do_test_3(const char *file1, const char *file2)
+static
+int do_test_3(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
@@ -573,8 +582,8 @@ int do_test_3(const char *file1, const char *file2)
* Dimension issues
*-------------------------------------------------------------------------
*/
-
-int do_test_4(const char *file1, const char *file2)
+static
+int do_test_4(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
@@ -637,8 +646,8 @@ int do_test_4(const char *file1, const char *file2)
* Datasets datatypes
*-------------------------------------------------------------------------
*/
-
-int do_test_5(const char *file1, const char *file2)
+static
+int do_test_5(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
@@ -657,7 +666,16 @@ int do_test_5(const char *file1, const char *file2)
double buf6a[3][2] = {{1,1},{1,1},{1,1}};
double buf6b[3][2] = {{1,1},{3,4},{5,6}};
-
+ /*unsigned/signed test
+ signed char -128 to 127
+ unsigned char 0 to 255
+ */
+ char buf7a[3][2] = {{-1,-128},{-1,-1},{-1,-1}};
+ unsigned char buf7b[3][2] = {{1,128},{1,1},{1,1}};
+ unsigned char buf8a[3][2] = {{1,1},{1,1},{1,1}};
+ unsigned char buf8b[3][2] = {{1,1},{3,4},{5,6}};
+
+
/*-------------------------------------------------------------------------
* Create a file
*-------------------------------------------------------------------------
@@ -716,6 +734,22 @@ int do_test_5(const char *file1, const char *file2)
write_dataset(file1_id,2,dims,"dset6b",H5T_NATIVE_DOUBLE,buf6b);
/*-------------------------------------------------------------------------
+ * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR
+ *-------------------------------------------------------------------------
+ */
+
+ write_dataset(file1_id,2,dims,"dset7a",H5T_NATIVE_CHAR,buf7a);
+ write_dataset(file1_id,2,dims,"dset7b",H5T_NATIVE_UCHAR,buf7b);
+
+/*-------------------------------------------------------------------------
+ * H5T_NATIVE_UCHAR
+ *-------------------------------------------------------------------------
+ */
+
+ write_dataset(file1_id,2,dims,"dset8a",H5T_NATIVE_UCHAR,buf8a);
+ write_dataset(file1_id,2,dims,"dset8b",H5T_NATIVE_UCHAR,buf8b);
+
+/*-------------------------------------------------------------------------
* Close
*-------------------------------------------------------------------------
*/
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index e39ebc4..aa31ab6 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -213,6 +213,9 @@ TOOLTEST h5diff_55.txt file6.h5 file6.h5 dset5a dset5b
# 5.6
TOOLTEST h5diff_56.txt file6.h5 file6.h5 dset6a dset6b
+# 5.7
+TOOLTEST h5diff_57.txt file6.h5 file6.h5 dset7a dset7b
+
# ##############################################################################
# # Error messages
# ##############################################################################
diff --git a/tools/testfiles/file1.h5 b/tools/testfiles/file1.h5
index e6f2863..f8e68b5 100644
--- a/tools/testfiles/file1.h5
+++ b/tools/testfiles/file1.h5
Binary files differ
diff --git a/tools/testfiles/file2.h5 b/tools/testfiles/file2.h5
index 4db567a..0c7c71a 100644
--- a/tools/testfiles/file2.h5
+++ b/tools/testfiles/file2.h5
Binary files differ
diff --git a/tools/testfiles/file3.h5 b/tools/testfiles/file3.h5
index 2586dd2..bf23130 100644
--- a/tools/testfiles/file3.h5
+++ b/tools/testfiles/file3.h5
Binary files differ
diff --git a/tools/testfiles/file4.h5 b/tools/testfiles/file4.h5
index 64a5c35..e79ab78 100644
--- a/tools/testfiles/file4.h5
+++ b/tools/testfiles/file4.h5
Binary files differ
diff --git a/tools/testfiles/file5.h5 b/tools/testfiles/file5.h5
index 57bd916..0ac661e 100644
--- a/tools/testfiles/file5.h5
+++ b/tools/testfiles/file5.h5
Binary files differ
diff --git a/tools/testfiles/file6.h5 b/tools/testfiles/file6.h5
index 473ab3e..ec6768d 100644
--- a/tools/testfiles/file6.h5
+++ b/tools/testfiles/file6.h5
Binary files differ
diff --git a/tools/testfiles/h5diff_16.txt b/tools/testfiles/h5diff_16.txt
index 45c9302..288fb65 100644
--- a/tools/testfiles/h5diff_16.txt
+++ b/tools/testfiles/h5diff_16.txt
@@ -18,6 +18,10 @@ file1 file2
x x /dset5b
x x /dset6a
x x /dset6b
+ x x /dset7a
+ x x /dset7b
+ x x /dset8a
+ x x /dset8b
Comparing </dset0a> with </dset0a>
0 differences found
@@ -61,4 +65,16 @@ Comparing </dset6a> with </dset6a>
Comparing </dset6b> with </dset6b>
0 differences found
+Comparing </dset7a> with </dset7a>
+0 differences found
+
+Comparing </dset7b> with </dset7b>
+0 differences found
+
+Comparing </dset8a> with </dset8a>
+0 differences found
+
+Comparing </dset8b> with </dset8b>
+0 differences found
+
diff --git a/tools/testfiles/h5diff_57.txt b/tools/testfiles/h5diff_57.txt
new file mode 100644
index 0000000..783621b
--- /dev/null
+++ b/tools/testfiles/h5diff_57.txt
@@ -0,0 +1,11 @@
+#############################
+Expected output for 'h5diff file6.h5 file6.h5 dset7a dset7b'
+#############################
+$h5diff file6.h5 file6.h5 dset7a dset7b
+Warning: Different storage datatype
+</dset7a> has file datatype H5T_STD_I8LE
+</dset7b> has file datatype H5T_STD_U8LE
+Comparison not supported
+</dset7a> has sign H5T_SGN_2
+</dset7b> has sign H5T_SGN_NONE
+