From 9e75847d67d02c597c49a6f96e905ab90c94f7b4 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 3 Mar 2017 14:47:59 -0600 Subject: HDFFV-10128 fix string compare and add tests --- MANIFEST | 6 + tools/lib/h5diff_array.c | 25 ++- tools/test/h5diff/CMakeTests.cmake | 25 +++ tools/test/h5diff/h5diffgentest.c | 263 +++++++++++++++++++++------ tools/test/h5diff/testfiles/diff_strings1.h5 | Bin 0 -> 4464 bytes tools/test/h5diff/testfiles/diff_strings2.h5 | Bin 0 -> 4464 bytes tools/test/h5diff/testfiles/h5diff_60.txt | 10 + tools/test/h5diff/testfiles/h5diff_61.txt | 30 +++ tools/test/h5diff/testfiles/h5diff_62.txt | 37 ++++ tools/test/h5diff/testfiles/h5diff_63.txt | 10 + tools/test/h5diff/testh5diff.sh.in | 13 ++ 11 files changed, 359 insertions(+), 60 deletions(-) create mode 100644 tools/test/h5diff/testfiles/diff_strings1.h5 create mode 100644 tools/test/h5diff/testfiles/diff_strings2.h5 create mode 100644 tools/test/h5diff/testfiles/h5diff_60.txt create mode 100644 tools/test/h5diff/testfiles/h5diff_61.txt create mode 100644 tools/test/h5diff/testfiles/h5diff_62.txt create mode 100644 tools/test/h5diff/testfiles/h5diff_63.txt diff --git a/MANIFEST b/MANIFEST index 925ea3a..95c9bbd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2155,6 +2155,10 @@ ./tools/test/h5diff/testfiles/h5diff_57.txt ./tools/test/h5diff/testfiles/h5diff_58.txt ./tools/test/h5diff/testfiles/h5diff_59.txt +./tools/test/h5diff/testfiles/h5diff_60.txt +./tools/test/h5diff/testfiles/h5diff_61.txt +./tools/test/h5diff/testfiles/h5diff_62.txt +./tools/test/h5diff/testfiles/h5diff_63.txt ./tools/test/h5diff/testfiles/h5diff_600.txt ./tools/test/h5diff/testfiles/h5diff_601.txt ./tools/test/h5diff/testfiles/h5diff_603.txt @@ -2361,6 +2365,8 @@ ./tools/test/h5diff/testfiles/tudfilter2.h5 ./tools/test/h5diff/testfiles/h5diff_ud.txt ./tools/test/h5diff/testfiles/h5diff_udfail.txt +./tools/test/h5diff/testfiles/diff_strings1.h5 +./tools/test/h5diff/testfiles/diff_strings2.h5 #vds ./tools/test/h5diff/testfiles/h5diff_v1.txt ./tools/test/h5diff/testfiles/h5diff_v2.txt diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 9aadffe..e066937 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -130,7 +130,7 @@ typedef struct mcomp_t { unsigned n; /* number of members */ hid_t *ids; /* member type id */ - size_t *offsets; + size_t *offsets; struct mcomp_t **m; /* members */ }mcomp_t; @@ -546,7 +546,7 @@ hsize_t diff_array( void *_mem1, * Recursively call this function for each element * H5T_STRING * compare byte by byte in a cycle from 0 to type_size. this type_size is the - * value obtained by the get_size function but it is the string lenght for + * value obtained by the get_size function but it is the string length for * variable sized strings * H5T_OPAQUE * compare byte by byte in a cycle from 0 to type_size @@ -602,7 +602,7 @@ static hsize_t diff_datum(void *_mem1, /* Fast comparison first for atomic type by memcmp(). * It is OK not to list non-atomic type here because it will not be caught - * by the confition, but it gives more clarity for code planning + * by the condition, but it gives more clarity for code planning */ if (type_class != H5T_REFERENCE && type_class != H5T_COMPOUND && @@ -692,6 +692,13 @@ static hsize_t diff_datum(void *_mem1, * of length of strings. * For now mimic the previous way. */ + h5diffdebug2("diff_datum string size:%d\n",size1); + h5diffdebug2("diff_datum string size:%d\n",size2); + if(size1 != size2) + { + h5difftrace("diff_datum string sizes\n"); + nfound++; + } if(size1 < size2) { size = size1; @@ -712,7 +719,7 @@ static hsize_t diff_datum(void *_mem1, pad = H5Tget_strpad(m_type); - for (u=0; um[u] = (mcomp_t *)HDmalloc(sizeof(mcomp_t)); HDmemset(members->m[u], 0, sizeof(mcomp_t)); get_member_types(members->ids[u], members->m[u]); - } + } } - + return; diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index a8d6356..1d76b9b 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -57,6 +57,8 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmpSingleSiteBethe.output.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/diff_strings1.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/diff_strings2.h5 # tools/testfiles/vds ${HDF5_TOOLS_DIR}/testfiles/vds/1_a.h5 ${HDF5_TOOLS_DIR}/testfiles/vds/1_b.h5 @@ -209,6 +211,10 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_518.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_530.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_540.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_60.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_61.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_62.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_63.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_600.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_603.txt @@ -485,6 +491,10 @@ # 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) + # VDS tests set (FILEV1 1_vds.h5) set (FILEV2 2_vds.h5) @@ -749,6 +759,14 @@ h5diff_530.out.err h5diff_540.out h5diff_540.out.err + h5diff_60.out + h5diff_60.out.err + h5diff_61.out + h5diff_61.out.err + h5diff_62.out + h5diff_62.out.err + h5diff_63.out + h5diff_63.out.err h5diff_600.out h5diff_600.out.err h5diff_601.out @@ -984,6 +1002,13 @@ ADD_H5_TEST (h5diff_58 1 -v ${FILE7} ${FILE8} refreg) # ( HDDFV-7942 ) ADD_H5_TEST (h5diff_59 0 -v ${FILE4} ${FILE4} dset11a dset11b) +# Strings +# ( HDFFV-10128 ) +ADD_H5_TEST (h5diff_60 0 -v ${STRINGS1} ${STRINGS2} string1 string1) +ADD_H5_TEST (h5diff_61 0 -v ${STRINGS1} ${STRINGS2} string2 string2) +ADD_H5_TEST (h5diff_62 0 -v ${STRINGS1} ${STRINGS2} string3 string3) +ADD_H5_TEST (h5diff_63 0 -v ${STRINGS1} ${STRINGS2} string4 string4) + # ############################################################################## # # Error messages # ############################################################################## diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c index 339ff6c..c3b45bc 100644 --- a/tools/test/h5diff/h5diffgentest.c +++ b/tools/test/h5diff/h5diffgentest.c @@ -24,9 +24,9 @@ * size of that temporary buffer in bytes. For efficiency's sake, choose the * largest value suitable for your machine (for testing use a small value). */ -/* Maximum size used in a call to malloc for a dataset +/* Maximum size used in a call to malloc for a dataset * NOTE: this value should stay in sync with the value defined in the tools - * library file: h5tools_utils.h + * library file: h5tools_utils.h */ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); @@ -95,6 +95,9 @@ size_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 @@ -159,6 +162,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); @@ -214,11 +218,11 @@ int main(void) test_special_datasets(FILE19,0); test_special_datasets(FILE20,1); - /* + /* * Generate 2 files: FILE21 with old format; FILE22 with new format - * Create 2 datasets in each file: - * One dataset: chunked layout, w/o filters, fixed dimension - * One dataset: chunked layout, w/ filters, fixed dimension + * Create 2 datasets in each file: + * One dataset: chunked layout, w/o filters, fixed dimension + * One dataset: chunked layout, w/ filters, fixed dimension */ gen_dataset_idx(FILE21, 0); gen_dataset_idx(FILE22, 1); @@ -244,7 +248,7 @@ int main(void) test_enums(ENUM_INVALID_VALUES); /* ------------------------------------------------- - * Create test files with dataset and attribute with container types + * Create test files with dataset and attribute with container types * (array, vlen) with multiple nested compound types. */ /* file1 */ @@ -259,8 +263,8 @@ int main(void) test_comps_vlen_arry(COMPS_COMPLEX2,"dset4", "attr4", 5, 0); /*------------------------------------------------- - * Create test files with non-comparable dataset and attributes with - * comparable datasets and attributes. All the comparables should display + * Create test files with non-comparable dataset and attributes with + * comparable datasets and attributes. All the comparables should display * differences. */ test_data_nocomparables(NON_COMPARBLES1,0); @@ -269,6 +273,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; } @@ -2120,33 +2127,33 @@ out: * Function: gen_dataset_idx * * Purpose: Create a file with either the new or old format -* Create two datasets in the file: -* one dataset: fixed dimension, chunked layout, w/o filters -* one dataset: fixed dimension, chunked layout, w/ filters +* Create two datasets in the file: +* one dataset: fixed dimension, chunked layout, w/o filters +* one dataset: fixed dimension, chunked layout, w/ filters * *------------------------------------------------------------------------- */ static int gen_dataset_idx(const char *file, int format) { - hid_t fid; /* file id */ - hid_t did, did2; /* dataset id */ - hid_t sid; /* space id */ - hid_t fapl; /* file access property id */ - hid_t dcpl; /* dataset creation property id */ - hsize_t dims[1] = {10}; /* dataset dimension */ - hsize_t c_dims[1] = {2}; /* chunk dimension */ - herr_t status; /* return status */ - int buf[10]; /* data buffer */ - int i; /* local index variable */ + hid_t fid; /* file id */ + hid_t did, did2; /* dataset id */ + hid_t sid; /* space id */ + hid_t fapl; /* file access property id */ + hid_t dcpl; /* dataset creation property id */ + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + herr_t status; /* return status */ + int buf[10]; /* data buffer */ + int i; /* local index variable */ /* Get a copy of the file aaccess property */ fapl = H5Pcreate(H5P_FILE_ACCESS); /* Set the "use the latest format" bounds for creating objects in the file */ if(format) { - status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - assert(status >= 0); + status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + assert(status >= 0); } /* Create a file */ @@ -2155,7 +2162,7 @@ int gen_dataset_idx(const char *file, int format) /* Create data */ for(i = 0; i < 10; i++) - buf[i] = i; + buf[i] = i; /* Set chunk */ dcpl = H5Pcreate(H5P_DATASET_CREATE); @@ -2165,7 +2172,7 @@ int gen_dataset_idx(const char *file, int format) /* Create a 1D dataset */ sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - + /* Write to the dataset */ status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); assert(status >= 0); @@ -4422,8 +4429,8 @@ out: /*------------------------------------------------------------------------- * -* Purpose: -* Create test files with dataset and attribute with container types +* Purpose: +* Create test files with dataset and attribute with container types * (array, vlen) with multiple nested compound types. * * Function: test_comps_array() @@ -4447,7 +4454,7 @@ out: static void test_comps_array (const char *fname, const char *dset, const char *attr,int diff, int is_file_new) { /* sub compound 2 */ - typedef struct { + typedef struct { int i2; float f2; } cmpd2_t; @@ -4469,14 +4476,14 @@ static void test_comps_array (const char *fname, const char *dset, const char *a hid_t tid_attr; hsize_t sdims_dset[] = {SDIM_DSET}; hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; - int i,j; + int i,j; herr_t ret; /* Generic return value */ /* Initialize array data to write */ for(i=0; i < SDIM_DSET; i++) { wdata[i].i1 = i; - for(j=0; j < SDIM_CMPD_ARRAY; j++) + for(j=0; j < SDIM_CMPD_ARRAY; j++) { wdata[i].cmpd2[j].i2 = i * 10 + diff; wdata[i].cmpd2[j].f2 = (float)i * 10.5F + (float)diff; @@ -4520,7 +4527,7 @@ static void test_comps_array (const char *fname, const char *dset, const char *a /* ------------------- - * Create a dataset + * Create a dataset */ /* Create dataspace for datasets */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4562,18 +4569,18 @@ static void test_comps_array (const char *fname, const char *dset, const char *a static void test_comps_vlen (const char * fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ - typedef struct { + typedef struct { int i2; float f2; } cmpd2_t; /* top compound 1 */ - typedef struct { + typedef struct { int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; - cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ + cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ hid_t fid; /* HDF5 File ID */ hid_t did_dset; /* dataset ID */ @@ -4629,7 +4636,7 @@ static void test_comps_vlen (const char * fname, const char *dset, const char *a assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 + * Create dataset with compound1 */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4674,11 +4681,11 @@ static void test_comps_vlen (const char * fname, const char *dset, const char *a static void test_comps_array_vlen (const char * fname, const char *dset,const char *attr, int diff, int is_file_new) { - typedef struct { + typedef struct { int i3; float f3; } cmpd3_t; - + typedef struct { /* Typedef for compound datatype */ int i2; hvl_t vl; /* VL information to write */ @@ -4817,19 +4824,19 @@ 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) { /* sub compound 3 */ - typedef struct { + typedef struct { int i3; float f3; } cmpd3_t; /* sub compound 2 */ - typedef struct { + typedef struct { int i2; cmpd3_t cmpd3[SDIM_CMPD_ARRAY]; } cmpd2_t; /* top compound 1 */ - typedef struct { + typedef struct { int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; @@ -4910,7 +4917,7 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 + * Create dataset with compound1 */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4960,9 +4967,9 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch /*------------------------------------------------------------------------- * Function: test_data_nocomparables * -* Purpose: -* Create test files with non-comparable dataset and attributes with -* comparable datasets and attributes. All the comparables should display +* Purpose: +* Create test files with non-comparable dataset and attributes with +* comparable datasets and attributes. All the comparables should display * differences. * *-------------------------------------------------------------------------*/ @@ -5020,8 +5027,8 @@ static void test_data_nocomparables (const char * fname, int make_diffs) dset_data_ptr2=(int*)&data2; attr_data_ptr1=(int*)&data2; - /* ----------- - * group2 + /* ----------- + * group2 */ dset_data_ptr3=(int*)&data2; /* dset1/attr1 */ @@ -5143,10 +5150,10 @@ static void test_data_nocomparables (const char * fname, int make_diffs) goto out; } - + out: - + /*----------------------------------------------------------------------- * Close IDs *-----------------------------------------------------------------------*/ @@ -5171,9 +5178,9 @@ out: /*------------------------------------------------------------------------- * Function: test_objs_nocomparables * -* Purpose: +* Purpose: * Create test files with common objects (same name) but different object -* types. +* types. * h5diff should show non-comparable output from these common objects. *-------------------------------------------------------------------------*/ static void test_objs_nocomparables(const char *fname1, const char *fname2) @@ -5317,6 +5324,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/test/h5diff/testfiles/diff_strings1.h5 b/tools/test/h5diff/testfiles/diff_strings1.h5 new file mode 100644 index 0000000..8839f5a Binary files /dev/null and b/tools/test/h5diff/testfiles/diff_strings1.h5 differ diff --git a/tools/test/h5diff/testfiles/diff_strings2.h5 b/tools/test/h5diff/testfiles/diff_strings2.h5 new file mode 100644 index 0000000..810278c Binary files /dev/null and b/tools/test/h5diff/testfiles/diff_strings2.h5 differ diff --git a/tools/test/h5diff/testfiles/h5diff_60.txt b/tools/test/h5diff/testfiles/h5diff_60.txt new file mode 100644 index 0000000..938f279 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_60.txt @@ -0,0 +1,10 @@ +dataset: and +size: [3x4] [3x4] +position string1 string1 difference +------------------------------------------------------------ +[ 1 0 ] 5 \000 +[ 1 1 ] 6 \000 +[ 1 2 ] \000 7 +[ 1 3 ] \000 8 +4 differences found +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_61.txt b/tools/test/h5diff/testfiles/h5diff_61.txt new file mode 100644 index 0000000..1f238b1 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_61.txt @@ -0,0 +1,30 @@ +dataset: and +size: [20] [20] +position string2 string2 difference +------------------------------------------------------------ +[ 8 ] 9 e +[ 8 ] f +[ 8 ] 9 +[ 9 ] 0 e +[ 9 ] f +[ 9 ] 0 +[ 10 ] 1 e +[ 10 ] f +[ 10 ] 1 +[ 11 ] 2 e +[ 11 ] f +[ 11 ] 2 +[ 12 ] e 3 +[ 12 ] f +[ 12 ] 3 +[ 13 ] e 4 +[ 13 ] f +[ 13 ] 4 +[ 14 ] e 5 +[ 14 ] f +[ 14 ] 5 +[ 15 ] e 6 +[ 15 ] f +[ 15 ] 6 +24 differences found +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_62.txt b/tools/test/h5diff/testfiles/h5diff_62.txt new file mode 100644 index 0000000..0cc0947 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_62.txt @@ -0,0 +1,37 @@ +dataset: and +size: [27] [27] +position string3 string3 difference +------------------------------------------------------------ +[ 12 ] d c +[ 12 ] 2 d +[ 12 ] \000 2 +[ 13 ] 3 d +[ 13 ] \000 3 +[ 14 ] b a +[ 14 ] c b +[ 14 ] d c +[ 14 ] 4 d +[ 14 ] \000 4 +[ 15 ] c b +[ 15 ] d c +[ 15 ] 5 d +[ 15 ] \000 5 +[ 16 ] c d +[ 16 ] d 6 +[ 16 ] 6 \000 +[ 17 ] d 7 +[ 17 ] 7 \000 +[ 18 ] a b +[ 18 ] b c +[ 18 ] c d +[ 18 ] d 8 +[ 18 ] 8 \000 +[ 19 ] b c +[ 19 ] c d +[ 19 ] d 9 +[ 19 ] 9 \000 +[ 24 ] c d +[ 25 ] c d +[ 26 ] c d +31 differences found +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_63.txt b/tools/test/h5diff/testfiles/h5diff_63.txt new file mode 100644 index 0000000..043da16 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_63.txt @@ -0,0 +1,10 @@ +dataset: and +size: [3] [3] +position string4 string4 difference +------------------------------------------------------------ +[ 1 ] 8 +[ 1 ] 9 +[ 2 ] 8 +[ 2 ] 9 +4 differences found +EXIT CODE: 1 diff --git a/tools/test/h5diff/testh5diff.sh.in b/tools/test/h5diff/testh5diff.sh.in index cc92e22..5a614ad 100644 --- a/tools/test/h5diff/testh5diff.sh.in +++ b/tools/test/h5diff/testh5diff.sh.in @@ -124,6 +124,8 @@ $SRC_H5DIFF_TESTFILES/tmptest.he5 $SRC_H5DIFF_TESTFILES/tmptest2.he5 $SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.reference.h5 $SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.output.h5 +$SRC_H5DIFF_TESTFILES/diff_strings1.h5 +$SRC_H5DIFF_TESTFILES/diff_strings2.h5 " LIST_HDF5_VDS_TEST_FILES=" @@ -282,6 +284,10 @@ $SRC_H5DIFF_TESTFILES/h5diff_517.txt $SRC_H5DIFF_TESTFILES/h5diff_518.txt $SRC_H5DIFF_TESTFILES/h5diff_530.txt $SRC_H5DIFF_TESTFILES/h5diff_540.txt +$SRC_H5DIFF_TESTFILES/h5diff_60.txt +$SRC_H5DIFF_TESTFILES/h5diff_61.txt +$SRC_H5DIFF_TESTFILES/h5diff_62.txt +$SRC_H5DIFF_TESTFILES/h5diff_63.txt $SRC_H5DIFF_TESTFILES/h5diff_600.txt $SRC_H5DIFF_TESTFILES/h5diff_601.txt $SRC_H5DIFF_TESTFILES/h5diff_603.txt @@ -688,6 +694,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 # ############################################################################## -- cgit v0.12