summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-03-06 19:32:42 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-03-06 19:32:42 (GMT)
commit0c25a705bab5f2e06bfba0cfa285874d071e2bed (patch)
tree434c787784c49a25348bbb09ed3322c06ec513cb /tools/h5diff
parent7cbf17a03f4131c65453e8d54bae0cc0737f8929 (diff)
downloadhdf5-0c25a705bab5f2e06bfba0cfa285874d071e2bed.zip
hdf5-0c25a705bab5f2e06bfba0cfa285874d071e2bed.tar.gz
hdf5-0c25a705bab5f2e06bfba0cfa285874d071e2bed.tar.bz2
HDFFV-10128 merge from develop
Diffstat (limited to 'tools/h5diff')
-rw-r--r--tools/h5diff/CMakeTests.cmake22
-rw-r--r--tools/h5diff/h5diffgentest.c161
-rw-r--r--tools/h5diff/testfiles/diff_strings1.h5bin0 -> 4464 bytes
-rw-r--r--tools/h5diff/testfiles/diff_strings2.h5bin0 -> 4464 bytes
-rw-r--r--tools/h5diff/testh5diff.sh.in17
5 files changed, 185 insertions, 15 deletions
diff --git a/tools/h5diff/CMakeTests.cmake b/tools/h5diff/CMakeTests.cmake
index a9ec683..93fdd55 100644
--- a/tools/h5diff/CMakeTests.cmake
+++ b/tools/h5diff/CMakeTests.cmake
@@ -286,7 +286,7 @@
##############################################################################
##############################################################################
- MACRO (ADD_H5_TEST resultfile resultcode)
+ macro (ADD_H5_TEST resultfile resultcode)
# If using memchecker add tests without using scripts
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME H5DIFF-${resultfile} COMMAND $<TARGET_FILE:h5diff> ${ARGN})
@@ -314,9 +314,9 @@
if (H5_HAVE_PARALLEL)
ADD_PH5_TEST (${resultfile} ${resultcode} ${ARGN})
endif ()
- ENDMACRO ()
+ endmacro ()
- MACRO (ADD_PH5_TEST resultfile resultcode)
+ macro (ADD_PH5_TEST resultfile resultcode)
# If using memchecker add tests without using scripts
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME PH5DIFF-${resultfile} COMMAND $<TARGET_FILE:ph5diff> ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} ${ARGN})
@@ -348,9 +348,9 @@
endif ()
set (last_test "PH5DIFF-${resultfile}")
endif ()
- ENDMACRO ()
+ endmacro ()
- MACRO (ADD_H5_UD_TEST testname resultcode resultfile)
+ macro (ADD_H5_UD_TEST testname resultcode resultfile)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
# Remove any output file left over from previous test run
add_test (
@@ -393,7 +393,7 @@
endif ()
set_tests_properties (H5DIFF_UD-${testname} PROPERTIES DEPENDS H5DIFF_UD-${testname}-clearall-objects)
endif ()
- ENDMACRO ()
+ endmacro ()
##############################################################################
##############################################################################
@@ -450,6 +450,9 @@
# attrs with verbose option level
set (ATTR_VERBOSE_LEVEL_FILE1 h5diff_attr_v_level1.h5)
set (ATTR_VERBOSE_LEVEL_FILE2 h5diff_attr_v_level2.h5)
+ # strings
+ set (STRINGS1 diff_strings1.h5)
+ set (STRINGS2 diff_strings2.h5)
if (HDF5_ENABLE_USING_MEMCHECKER)
# Remove any output file left over from previous test run
@@ -1089,8 +1092,7 @@ ADD_H5_TEST (h5diff_103 1 -v --use-system-epsilon ${FILE1} ${FILE1} g1/d1
g1/d2)
# with --use-system-epsilon for float value. expect less differences
-ADD_H5_TEST (h5diff_104 1 -v --use-system-epsilon ${FILE1} ${FILE1} g1/fp1
-g1/fp2)
+ADD_H5_TEST (h5diff_104 1 -v --use-system-epsilon ${FILE1} ${FILE1} g1/fp1 g1/fp2)
# not comparable -c flag
ADD_H5_TEST (h5diff_200 0 ${FILE2} ${FILE2} g2/dset1 g2/dset2)
@@ -1386,3 +1388,7 @@ ADD_H5_TEST (h5diff_646 1 -v --use-system-epsilon -p 0.05 ${FILE1} ${FILE2} /g1/
##############################################################################
ADD_H5_UD_TEST (h5diff_plugin_test 0 h5diff_ud -v tudfilter.h5 tudfilter2.h5)
ADD_H5_UD_TEST (h5diff_plugin_fail 2 h5diff_udfail -v tudfilter.h5 tudfilter2.h5)
+
+# ##############################################################################
+# # END
+# ##############################################################################
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index cfaffe6..50b32aa 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -93,6 +93,9 @@ hsize_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024);
/* non-comparable dataset and attribute */
#define NON_COMPARBLES1 "non_comparables1.h5"
#define NON_COMPARBLES2 "non_comparables2.h5"
+/* string dataset and attribute */
+#define DIFF_STRINGS1 "diff_strings1.h5"
+#define DIFF_STRINGS2 "diff_strings2.h5"
#define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */
#define STR_SIZE 3
@@ -157,6 +160,7 @@ static void test_comps_array_vlen (const char *fname, const char *dset, const ch
static void test_comps_vlen_arry (const char *fname, const char *dset,const char *attr, int diff, int is_file_new);
static void test_data_nocomparables (const char *fname, int diff);
static void test_objs_nocomparables (const char *fname1, const char *fname2);
+static void test_objs_strings (const char *fname, const char *fname2);
/* called by test_attributes() and test_datasets() */
static void write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs);
@@ -257,6 +261,9 @@ int main(void)
/* common objects (same name) with different object types. HDFFV-7644 */
test_objs_nocomparables(NON_COMPARBLES1, NON_COMPARBLES2);
+ /* string dataset and attribute. HDFFV-10028 */
+ test_objs_strings(DIFF_STRINGS1, DIFF_STRINGS2);
+
return 0;
}
@@ -5214,6 +5221,160 @@ out:
}
+static hid_t mkstr(int size, H5T_str_t pad) {
+ hid_t type;
+
+ if((type=H5Tcopy(H5T_C_S1)) < 0) return -1;
+ if(H5Tset_size(type, (size_t)size) < 0) return -1;
+ if(H5Tset_strpad(type, pad) < 0) return -1;
+
+ return type;
+}
+
+/*-------------------------------------------------------------------------
+* Function: test_objs_strings
+*
+* Purpose:
+* Create test files with common objects (same name) but different string
+* types.
+* h5diff should show differences output from these common objects.
+*-------------------------------------------------------------------------*/
+static void test_objs_strings(const char *fname1, const char *fname2)
+{
+ herr_t status = SUCCEED;
+ hid_t fid1=0;
+ hid_t fid2=0;
+ hid_t dataset=0;
+ hid_t space=0;
+ hid_t f_type=0;
+ hid_t m_type=0;
+ hsize_t dims1[] = {3, 4};
+ char string1A[12][3] = {"s1","s2","s3","s4","s5","s6","s","s","s9",
+ "s0","s1","s2"};
+ char string1B[12][3] = {"s1","s2","s3","s4","s","s","s7","s8","s9",
+ "s0","s1","s2"};
+
+ hsize_t dims2[]={20};
+ char string2A[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4",
+ "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8",
+ "ab cd 9", "ab cd 0", "ab cd 1", "ab cd 2",
+ "ab cd ef3", "ab cd ef4", "ab cd ef5", "ab cd ef6",
+ "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"};
+ char string2B[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4",
+ "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8",
+ "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2",
+ "ab cd 3", "ab cd 4", "ab cd 5", "ab cd 6",
+ "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"};
+
+ hsize_t dims3[] = {27};
+ char string3A[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3",
+ "abcd4", "abcd5", "abcd6", "abcd7",
+ "abcd8", "abcd9", "abcd0", "abcd1",
+ "abd2", "abc3", "bcd4", "acd5",
+ "abcd6", "abcd7", "abcd8", "abcd9",
+ "abcd0", "abcd1", "abcd2", "abcd3",
+ "abc4", "abc5", "abc6"};
+ char string3B[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3",
+ "abcd4", "abcd5", "abcd6", "abcd7",
+ "abcd8", "abcd9", "abcd0", "abcd1",
+ "abcd2", "abcd3", "abcd4", "abcd5",
+ "abd6", "abc7", "bcd8", "acd9",
+ "abcd0", "abcd1", "abcd2", "abcd3",
+ "abd4", "abd5", "abd6"};
+
+ hsize_t dims4[] = {3};
+ char string4A[3][21] = { "s1234567890123456789", "s1234567890123456789",
+ "s12345678901234567"};
+ char string4B[3][21] = { "s1234567890123456789", "s12345678901234567",
+ "s1234567890123456789"};
+
+ /*-----------------------------------------------------------------------
+ * Create file(s)
+ *------------------------------------------------------------------------*/
+ /* file1 */
+ fid1 = H5Fcreate (fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid1 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ /* file2 */
+ fid2 = H5Fcreate (fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid2 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2);
+ status = FAIL;
+ goto out;
+ }
+
+ /* string 1 : nullterm string */
+ space = H5Screate_simple(2, dims1, NULL);
+ f_type = mkstr(5, H5T_STR_NULLTERM);
+ m_type = mkstr(3, H5T_STR_NULLTERM);
+ dataset = H5Dcreate2(fid1, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1A);
+ H5Dclose(dataset);
+ dataset = H5Dcreate2(fid2, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1B);
+ H5Tclose(m_type);
+ H5Tclose(f_type);
+ H5Sclose(space);
+ H5Dclose(dataset);
+
+ /* string 2 : space pad string */
+ space = H5Screate_simple(1, dims2, NULL);
+ f_type = mkstr(11, H5T_STR_SPACEPAD);
+ m_type = mkstr(10, H5T_STR_NULLTERM);
+ dataset = H5Dcreate2(fid1, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2A);
+ H5Dclose(dataset);
+ dataset = H5Dcreate2(fid2, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2B);
+ H5Tclose(m_type);
+ H5Tclose(f_type);
+ H5Sclose(space);
+ H5Dclose(dataset);
+
+ /* string 3 : null pad string */
+ space = H5Screate_simple(1, dims3, NULL);
+ f_type = mkstr(8, H5T_STR_NULLPAD);
+ m_type = mkstr(6, H5T_STR_NULLTERM);
+ dataset = H5Dcreate2(fid1, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3A);
+ H5Dclose(dataset);
+ dataset = H5Dcreate2(fid2, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3B);
+ H5Tclose(m_type);
+ H5Tclose(f_type);
+ H5Sclose(space);
+ H5Dclose(dataset);
+
+ /* string 4 : space pad long string */
+ space = H5Screate_simple(1, dims4, NULL);
+ f_type = mkstr(168, H5T_STR_SPACEPAD);
+ m_type = mkstr(21, H5T_STR_NULLTERM);
+ dataset = H5Dcreate2(fid1, "/string4", 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, "/string4", 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
+ *-----------------------------------------------------------------------*/
+ if(fid1)
+ H5Fclose(fid1);
+ if(fid2)
+ H5Fclose(fid2);
+}
+
/*-------------------------------------------------------------------------
* Function: write_attr_in
*
diff --git a/tools/h5diff/testfiles/diff_strings1.h5 b/tools/h5diff/testfiles/diff_strings1.h5
new file mode 100644
index 0000000..8839f5a
--- /dev/null
+++ b/tools/h5diff/testfiles/diff_strings1.h5
Binary files differ
diff --git a/tools/h5diff/testfiles/diff_strings2.h5 b/tools/h5diff/testfiles/diff_strings2.h5
new file mode 100644
index 0000000..810278c
--- /dev/null
+++ b/tools/h5diff/testfiles/diff_strings2.h5
Binary files differ
diff --git a/tools/h5diff/testh5diff.sh.in b/tools/h5diff/testh5diff.sh.in
index 5748128..dedeb15 100644
--- a/tools/h5diff/testh5diff.sh.in
+++ b/tools/h5diff/testh5diff.sh.in
@@ -120,6 +120,8 @@ $SRC_H5DIFF_TESTFILES/h5diff_attr_v_level2.h5
$SRC_H5DIFF_TESTFILES/h5diff_enum_invalid_values.h5
$SRC_H5DIFF_TESTFILES/non_comparables1.h5
$SRC_H5DIFF_TESTFILES/non_comparables2.h5
+$SRC_H5DIFF_TESTFILES/diff_strings1.h5
+$SRC_H5DIFF_TESTFILES/diff_strings2.h5
"
LIST_OTHER_TEST_FILES="
@@ -609,8 +611,6 @@ TOOLTEST h5diff_28.txt -v h5diff_types.h5 h5diff_types.h5 l1 l2
TOOLTEST h5diff_30.txt -v h5diff_enum_invalid_values.h5 h5diff_enum_invalid_values.h5 dset1 dset2
-
-
# ##############################################################################
# # Dataset datatypes
# ##############################################################################
@@ -646,6 +646,13 @@ TOOLTEST h5diff_58.txt -v h5diff_dset1.h5 h5diff_dset2.h5 refreg
# ( HDDFV-7942 )
TOOLTEST h5diff_59.txt -v h5diff_dtypes.h5 h5diff_dtypes.h5 dset11a dset11b
+# Strings
+# ( HDFFV-10128 )
+TOOLTEST h5diff_60.txt -v diff_strings1 diff_strings2 string1 string1
+TOOLTEST h5diff_61.txt -v diff_strings1 diff_strings2 string2 string2
+TOOLTEST h5diff_62.txt -v diff_strings1 diff_strings2 string3 string3
+TOOLTEST h5diff_63.txt -v diff_strings1 diff_strings2 string4 string4
+
# ##############################################################################
# # Error messages
# ##############################################################################
@@ -717,8 +724,6 @@ TOOLTEST h5diff_618.txt -p 2 h5diff_basic1.h5 h5diff_basic2.h5 g1/dset3 g1/dset4
# 6.19: number smaller than smallest difference
TOOLTEST h5diff_619.txt -p 0.005 h5diff_basic1.h5 h5diff_basic2.h5 g1/dset3 g1/dset4
-
-
# ##############################################################################
# # -n
# ##############################################################################
@@ -771,7 +776,6 @@ TOOLTEST h5diff_tmp2.txt tmpSingleSiteBethe.output.h5 tmpSingleSiteBethe.referen
# ##################################################
# attrs with verbose option level
# ##################################################
-
TOOLTEST h5diff_700.txt -v1 h5diff_attr1.h5 h5diff_attr2.h5
TOOLTEST h5diff_701.txt -v2 h5diff_attr1.h5 h5diff_attr2.h5
TOOLTEST h5diff_702.txt --verbose=1 h5diff_attr1.h5 h5diff_attr2.h5
@@ -822,7 +826,6 @@ TOOLTEST h5diff_103.txt -v --use-system-epsilon h5diff_basic1.h5 h5diff_basic1.h
# with --use-system-epsilon for float value
TOOLTEST h5diff_104.txt -v --use-system-epsilon h5diff_basic1.h5 h5diff_basic1.h5 g1/fp1 g1/fp2
-
# not comparable -c flag
TOOLTEST h5diff_200.txt h5diff_basic2.h5 h5diff_basic2.h5 g2/dset1 g2/dset2
@@ -950,7 +953,6 @@ TOOLTEST h5diff_424.txt --follow-symlinks -v h5diff_ext2softlink_trg.h5 h5diff_e
# extlink_to_softlink_to_dset1 vs extlink_to_softlink_to_dset2"
TOOLTEST h5diff_425.txt --follow-symlinks -v h5diff_ext2softlink_src.h5 h5diff_ext2softlink_src.h5 /ext_link_to_slink1 /ext_link_to_slink2
-
# ##############################################################################
# # Dangling links compare (--follow-symlinks and --no-dangling-links)
# ##############################################################################
@@ -1101,6 +1103,7 @@ TOOLTEST h5diff_540.txt -v compounds_array_vlen1.h5 compounds_array_vlen2.h5
# ##############################################################################
# # Test mutually exclusive options
# ##############################################################################
+#
# Test with -d , -p and --use-system-epsilon.
TOOLTEST h5diff_640.txt -v -d 5 -p 0.05 --use-system-epsilon h5diff_basic1.h5 h5diff_basic2.h5 /g1/dset3 /g1/dset4
TOOLTEST h5diff_641.txt -v -d 5 -p 0.05 h5diff_basic1.h5 h5diff_basic2.h5 /g1/dset3 /g1/dset4