diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-10-31 21:18:09 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-10-31 21:18:09 (GMT) |
commit | 61d964625ebb39af5326bc11dc52790ab39c8202 (patch) | |
tree | 107f4e7aef1693e372c95ea8cd34eac80d384bcc /tools | |
parent | 0b8b8df0e0e9e8dbf3eb5a9e03035094dd5c49d9 (diff) | |
download | hdf5-61d964625ebb39af5326bc11dc52790ab39c8202.zip hdf5-61d964625ebb39af5326bc11dc52790ab39c8202.tar.gz hdf5-61d964625ebb39af5326bc11dc52790ab39c8202.tar.bz2 |
[svn-r7804] Purpose:
h5diff new feature
Description:
added diff for the class ENUM
Solution:
Platforms tested:
linux
solaris 2.7
IRIX
Misc. update:
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5diff/test_h5diff.c | 2 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 80 | ||||
-rw-r--r-- | tools/lib/h5diff_dset.c | 34 |
3 files changed, 92 insertions, 24 deletions
diff --git a/tools/h5diff/test_h5diff.c b/tools/h5diff/test_h5diff.c index 783eb42..7247fcd 100644 --- a/tools/h5diff/test_h5diff.c +++ b/tools/h5diff/test_h5diff.c @@ -74,7 +74,7 @@ int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, /* Write the buf */ if ( buf ) - assert(H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)>=0); + H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf); /* Close */ status = H5Dclose(dataset_id); diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index e65ae83..0a2eb41 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -175,21 +175,20 @@ int diff_array_mem( void *_mem1, { char fmt_llong[255], fmt_ullong[255]; char fmt_llongp[255], fmt_ullongp[255]; - size_t type_size; - static int ph=1; /* print header */ - int nfound=0; /* differences found */ + hsize_t dims[H5S_MAX_RANK]; unsigned char *mem1 = (unsigned char*)_mem1; unsigned char *mem2 = (unsigned char*)_mem2; unsigned u; hid_t memb_type; + size_t type_size; size_t offset; int nmembs; int j; - hsize_t dims[H5S_MAX_RANK]; hsize_t nelmts; hsize_t ndims; size_t size; - + static int ph=1; /* print header */ + int nfound=0; /* differences found */ /* Build default formats for long long types */ sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n", @@ -271,13 +270,35 @@ int diff_array_mem( void *_mem1, break; /*------------------------------------------------------------------------- - * H5T_BITFIELD, H5T_OPAQUE, H5T_ENUM + * H5T_BITFIELD *------------------------------------------------------------------------- */ case H5T_BITFIELD: + { + /* byte-by-byte comparison */ + for (u=0; u<type_size; u++) + nfound+=diff_native_uchar( + mem1 + u, + mem2 + u, /* offset */ + type_size, + u, + rank, + acc, + pos, + options, + obj1, + obj2, + ph); + + } + break; +/*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ case H5T_OPAQUE: - case H5T_ENUM: + /* byte-by-byte comparison */ for (u=0; u<type_size; u++) nfound+=diff_native_uchar( mem1 + u, @@ -292,6 +313,48 @@ int diff_array_mem( void *_mem1, obj2, ph); + break; + + +/*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- + */ + case H5T_ENUM: + +/* For enumeration types we compare the names instead of the + integer values. For each pair of elements being + compared, we convert both bit patterns to their corresponding + enumeration constant and do a string comparison */ + + { + char enum_name1[1024]; + char enum_name2[1024]; + + if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) && + (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0)) + { + if (HDstrcmp(enum_name1,enum_name2)!=0) + nfound=1; + } + else + { + for (u=0; u<type_size; u++) + nfound+=diff_native_uchar( + mem1 + u, + mem2 + u, /* offset */ + type_size, + u, + rank, + acc, + pos, + options, + obj1, + obj2, + ph); + + } + } break; /*------------------------------------------------------------------------- @@ -1278,8 +1341,7 @@ int diff_array_mem( void *_mem1, /*------------------------------------------------------------------------- * Function: diff_native_uchar * - * Purpose: compare H5T_NATIVE_UCHAR (used in H5T_NATIVE_UCHAR - * and H5T_STRING class) + * Purpose: do a byte-by-byte comparison * * Return: number of differences found * diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index f40122e..b676129 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -65,7 +65,7 @@ int diff_dataset( hid_t file1_id, int can1, can2; /* supported diff */ hsize_t storage_size1; hsize_t storage_size2; - int i; + int i, gout=0; /* disable error reporting */ @@ -80,15 +80,17 @@ int diff_dataset( hid_t file1_id, if ( (dset1_id = H5Dopen(file1_id,obj1_name)) < 0 ) { printf("Cannot open dataset <%s>\n", obj1_name ); - goto out; + gout=1; } if ( (dset2_id = H5Dopen(file2_id,obj2_name)) < 0 ) { printf("Cannot open dataset <%s>\n", obj2_name ); - goto out; + gout=1; } /* enable error reporting */ } H5E_END_TRY; + if (gout) + goto out; /* Get the dataspace handle */ if ( (space1_id = H5Dget_space(dset1_id)) < 0 ) @@ -373,13 +375,13 @@ int diff_dataset( hid_t file1_id, { if ( m_size1 < m_size2 ) { - assert( (H5Tclose(m_type1)) >=0); + H5Tclose(m_type1); m_type1 = H5Tget_native_type( f_type2 , H5T_DIR_DEFAULT); m_size1 = H5Tget_size( m_type1 ); } else { - assert( (H5Tclose(m_type2)) >=0); + H5Tclose(m_type2); m_type2 = H5Tget_native_type( f_type1 , H5T_DIR_DEFAULT); m_size2 = H5Tget_size( m_type2 ); } @@ -434,15 +436,19 @@ out: if ( buf1) HDfree(buf1); if ( buf2) HDfree(buf2); - /* Close */ - if ( dset1_id!=-1 ) assert( (H5Dclose(dset1_id)) >=0); - if ( dset2_id!=-1 ) assert( (H5Dclose(dset2_id)) >=0); - if ( space1_id!=-1 ) assert( (H5Sclose(space1_id)) >=0); - if ( space2_id!=-1 ) assert( (H5Sclose(space2_id)) >=0); - if ( f_type1!=-1 ) assert( (H5Tclose(f_type1)) >=0); - if ( f_type2!=-1 ) assert( (H5Tclose(f_type2)) >=0); - if ( m_type1!=-1 ) assert( (H5Tclose(m_type1)) >=0); - if ( m_type2!=-1 ) assert( (H5Tclose(m_type2)) >=0); + /* close */ + /* disable error reporting */ + H5E_BEGIN_TRY { + H5Dclose(dset1_id); + H5Dclose(dset2_id); + H5Sclose(space1_id); + H5Sclose(space2_id); + H5Tclose(f_type1); + H5Tclose(f_type2); + H5Tclose(m_type1); + H5Tclose(m_type2); + /* enable error reporting */ + } H5E_END_TRY; return nfound; |