summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2017-05-15 22:12:57 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2017-05-15 22:12:57 (GMT)
commit3e1a06e6494c9dd9a6f4b39e702949159e803283 (patch)
tree80ec8a1bd193fab101590a32e0b305488392c6d2
parent8e8a30bdd4d01cfcabdebee41bd43159b1645a0a (diff)
parent56c3ec98207bb6c4b3e6a7b9523c2a1e849879c3 (diff)
downloadhdf5-3e1a06e6494c9dd9a6f4b39e702949159e803283.zip
hdf5-3e1a06e6494c9dd9a6f4b39e702949159e803283.tar.gz
hdf5-3e1a06e6494c9dd9a6f4b39e702949159e803283.tar.bz2
Merge pull request #516 in HDFFV/hdf5 from ~BYRN/hdf5_adb:develop to develop
* commit '56c3ec98207bb6c4b3e6a7b9523c2a1e849879c3': HDFFV-10128 add test to check null term Test is another dataset HDFFV-10128 Fix null term strings
-rw-r--r--tools/lib/h5diff_array.c105
-rw-r--r--tools/test/h5diff/CMakeTests.cmake2
-rw-r--r--tools/test/h5diff/h5diffgentest.c28
-rw-r--r--tools/test/h5diff/testfiles/diff_strings1.h5bin4464 -> 4640 bytes
-rw-r--r--tools/test/h5diff/testfiles/diff_strings2.h5bin4464 -> 4640 bytes
-rw-r--r--tools/test/h5diff/testfiles/h5diff_tmp1.txt14
6 files changed, 108 insertions, 41 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 49f41dc..0a9d18a 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -623,6 +623,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_COMPOUND:
+ h5difftrace("diff_datum H5T_COMPOUND\n");
nmembs = members->n;
@@ -655,18 +656,20 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_STRING:
-
+ h5difftrace("diff_datum H5T_STRING\n");
{
- H5T_str_t pad;
- char *s;
- char *s1;
- char *s2;
- size_t size1;
- size_t size2;
+ char *s = NULL;
+ char *sx = NULL;
+ char *s1 = NULL;
+ char *s2 = NULL;
+ size_t size1;
+ size_t size2;
+ size_t sizex;
+ H5T_str_t pad = H5Tget_strpad(m_type);
/* if variable length string */
- if(H5Tis_variable_str(m_type))
- {
+ if(H5Tis_variable_str(m_type)) {
+ h5difftrace("diff_datum H5T_STRING variable\n");
/* Get pointer to first string */
s1 = *(char**) mem1;
size1 = HDstrlen(s1);
@@ -674,8 +677,16 @@ static hsize_t diff_datum(void *_mem1,
s2 = *(char**) mem2;
size2 = HDstrlen(s2);
}
- else
- {
+ else if (H5T_STR_NULLTERM == pad) {
+ h5difftrace("diff_datum H5T_STRING null term\n");
+ /* Get pointer to first string */
+ s1 = (char*) mem1;
+ size1 = HDstrlen(s1);
+ /* Get pointer to second string */
+ s2 = (char*) mem2;
+ size2 = HDstrlen(s2);
+ }
+ else {
/* Get pointer to first string */
s1 = (char *)mem1;
size1 = H5Tget_size(m_type);
@@ -692,45 +703,59 @@ static hsize_t diff_datum(void *_mem1,
*/
h5diffdebug2("diff_datum string size:%d\n",size1);
h5diffdebug2("diff_datum string size:%d\n",size2);
- if(size1 != size2)
- {
+ if(size1 != size2) {
h5difftrace("diff_datum string sizes\n");
nfound++;
}
- if(size1 < size2)
- {
+ if(size1 < size2) {
size = size1;
s = s1;
+ sizex = size2;
+ sx = s2;
}
- else
- {
+ else {
size = size2;
s = s2;
+ sizex = size1;
+ sx = s1;
}
/* check for NULL pointer for string */
- if(s!=NULL)
- {
+ if(s!=NULL) {
/* try fast compare first */
- if (HDmemcmp(s1, s2, size)==0)
- break;
-
- pad = H5Tget_strpad(m_type);
-
- for (u=0; u<size; u++)
- nfound+=character_compare(
- s1 + u,
- s2 + u, /* offset */
- i, /* index position */
- u, /* string character position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
+ if(HDmemcmp(s1, s2, size)==0) {
+ if(size1 != size2)
+ if(print_data(options))
+ for (u=size; u<sizex; u++)
+ character_compare(
+ s1 + u,
+ s2 + u, /* offset */
+ i, /* index position */
+ u, /* string character position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+ }
+ else
+ for (u=0; u<size; u++)
+ nfound+=character_compare(
+ s1 + u,
+ s2 + u, /* offset */
+ i, /* index position */
+ u, /* string character position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
}
}
@@ -741,6 +766,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_BITFIELD:
+ h5difftrace("diff_datum H5T_BITFIELD\n");
/* byte-by-byte comparison */
for (u=0; u<type_size; u++)
@@ -764,7 +790,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_OPAQUE:
-
+ h5difftrace("diff_datum H5T_OPAQUE\n");
/* byte-by-byte comparison */
for (u=0; u<type_size; u++)
nfound+=character_compare_opt(
@@ -788,6 +814,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_ENUM:
+ h5difftrace("diff_datum H5T_ENUM\n");
/* For enumeration types we compare the names instead of the
integer values. For each pair of elements being
diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake
index f6cd2dd..5759c2b 100644
--- a/tools/test/h5diff/CMakeTests.cmake
+++ b/tools/test/h5diff/CMakeTests.cmake
@@ -1130,7 +1130,7 @@ ADD_H5_TEST (h5diff_631 0 -v --use-system-epsilon ${FILE1} ${FILE1} g1/fp18 g1/f
# ##############################################################################
ADD_H5_TEST (h5diff_70 1 -v ${FILE5} ${FILE6})
# temporary test to verify HDF5-8625
-ADD_H5_TEST (h5diff_tmp1 0 tmptest2.he5 tmptest.he5)
+ADD_H5_TEST (h5diff_tmp1 1 tmptest2.he5 tmptest.he5)
# temporary test to verify HDF5-8639
ADD_H5_TEST (h5diff_tmp2 1 tmpSingleSiteBethe.output.h5 tmpSingleSiteBethe.reference.h5)
diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c
index cc7b057..4a929ae 100644
--- a/tools/test/h5diff/h5diffgentest.c
+++ b/tools/test/h5diff/h5diffgentest.c
@@ -5466,6 +5466,34 @@ static void test_objs_strings(const char *fname1, const char *fname2)
H5Sclose(space);
H5Dclose(dataset);
+ /* string 5 : early term long string */
+ string4A[0][10] = 0;
+ string4A[0][11] = 0;
+ string4B[0][10] = 0;
+
+ string4A[1][10] = 0;
+ string4A[1][11] = 'Z';
+ string4B[1][10] = 0;
+ string4B[1][11] = 'x';
+
+ string4A[2][10] = 0;
+ string4B[2][10] = 0;
+ string4B[2][11] = 'a';
+ string4B[2][12] = 'B';
+ string4B[2][13] = 'c';
+ space = H5Screate_simple(1, dims4, NULL);
+ f_type = mkstr(168, H5T_STR_NULLTERM);
+ m_type = mkstr(21, H5T_STR_NULLTERM);
+ dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A);
+ H5Dclose(dataset);
+ dataset = H5Dcreate2(fid2, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4B);
+ H5Tclose(m_type);
+ H5Tclose(f_type);
+ H5Sclose(space);
+ H5Dclose(dataset);
+
out:
/*-----------------------------------------------------------------------
* Close IDs
diff --git a/tools/test/h5diff/testfiles/diff_strings1.h5 b/tools/test/h5diff/testfiles/diff_strings1.h5
index 8839f5a..0f8b380 100644
--- a/tools/test/h5diff/testfiles/diff_strings1.h5
+++ b/tools/test/h5diff/testfiles/diff_strings1.h5
Binary files differ
diff --git a/tools/test/h5diff/testfiles/diff_strings2.h5 b/tools/test/h5diff/testfiles/diff_strings2.h5
index 810278c..e8520ae 100644
--- a/tools/test/h5diff/testfiles/diff_strings2.h5
+++ b/tools/test/h5diff/testfiles/diff_strings2.h5
Binary files differ
diff --git a/tools/test/h5diff/testfiles/h5diff_tmp1.txt b/tools/test/h5diff/testfiles/h5diff_tmp1.txt
index 40e3fb6..e2bb247 100644
--- a/tools/test/h5diff/testfiles/h5diff_tmp1.txt
+++ b/tools/test/h5diff/testfiles/h5diff_tmp1.txt
@@ -1,5 +1,17 @@
+attribute: <EndDate of </HDFEOS/ADDITIONAL/FILE_ATTRIBUTES>> and <EndDate of </HDFEOS/ADDITIONAL/FILE_ATTRIBUTES>>
+3 differences found
+attribute: <Set2eqSet1 of </HDFEOS/ADDITIONAL/FILE_ATTRIBUTES>> and <Set2eqSet1 of </HDFEOS/ADDITIONAL/FILE_ATTRIBUTES>>
+1 differences found
+attribute: <VersionID of </HDFEOS/ADDITIONAL/FILE_ATTRIBUTES>> and <VersionID of </HDFEOS/ADDITIONAL/FILE_ATTRIBUTES>>
+1 differences found
+attribute: <LongName of </HDFEOS/GRIDS/SET1/Data Fields/STv>> and <LongName of </HDFEOS/GRIDS/SET1/Data Fields/STv>>
+1 differences found
+attribute: <LongName of </HDFEOS/GRIDS/SET1/Data Fields/Tot_Precip_Water>> and <LongName of </HDFEOS/GRIDS/SET1/Data Fields/Tot_Precip_Water>>
+1 differences found
+attribute: <LongName of </HDFEOS/GRIDS/SET2/Data Fields/STv>> and <LongName of </HDFEOS/GRIDS/SET2/Data Fields/STv>>
+1 differences found
--------------------------------
Some objects are not comparable
--------------------------------
Use -c for a list of objects.
-EXIT CODE: 0
+EXIT CODE: 1