summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-05-15 17:33:58 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-05-15 17:33:58 (GMT)
commit56c3ec98207bb6c4b3e6a7b9523c2a1e849879c3 (patch)
tree6d76921d8b37e6286c1a8432588dc2336468a7d8
parent7078993d63aab4e239e4ae9c970b4b19d38352fa (diff)
downloadhdf5-56c3ec98207bb6c4b3e6a7b9523c2a1e849879c3.zip
hdf5-56c3ec98207bb6c4b3e6a7b9523c2a1e849879c3.tar.gz
hdf5-56c3ec98207bb6c4b3e6a7b9523c2a1e849879c3.tar.bz2
HDFFV-10128 add test to check null term
Test is another dataset
-rw-r--r--tools/lib/h5diff_array.c87
-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, 94 insertions, 37 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index bb2cd8a..0a9d18a 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -658,16 +658,17 @@ static hsize_t diff_datum(void *_mem1,
case H5T_STRING:
h5difftrace("diff_datum H5T_STRING\n");
{
- char *s;
- char *s1;
- char *s2;
- size_t size1;
- size_t size2;
- H5T_str_t pad = H5Tget_strpad(m_type);
-
+ 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;
@@ -685,8 +686,7 @@ static hsize_t diff_datum(void *_mem1,
s2 = (char*) mem2;
size2 = HDstrlen(s2);
}
- else
- {
+ else {
/* Get pointer to first string */
s1 = (char *)mem1;
size1 = H5Tget_size(m_type);
@@ -703,42 +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;
- 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);
}
}
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