diff options
author | Robb Matzke <matzke@llnl.gov> | 2000-05-18 16:40:20 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 2000-05-18 16:40:20 (GMT) |
commit | bc520e88b4ad3b175c0aeca2c90e021956676533 (patch) | |
tree | 814fa010e05cff2b586c3b947616f4af8b363cf4 /test | |
parent | 356495d12608a896fdc67bef0ab446cb1a74f8f8 (diff) | |
download | hdf5-bc520e88b4ad3b175c0aeca2c90e021956676533.zip hdf5-bc520e88b4ad3b175c0aeca2c90e021956676533.tar.gz hdf5-bc520e88b4ad3b175c0aeca2c90e021956676533.tar.bz2 |
[svn-r2262] * 2000-05-18
** src/H5Tconv.c
** src/H5Tpkg.h
** src/H5Tpublic.h
The H5T_conv_struct_opt() function had a design flaw -- it
didn't keep information about the stride to use to step
through the temporary/background-value buffer and thus nested
invocations would clobber each other's temp buffers. This was
fixed by splitting the `stride' argument into `buf_stride' and
`bkg_stride' arguments for all the conversion functions. THIS
IS AN API CHANGE, but users will get a compiler warning when
they pass their conversion function pointer to H5Tregister().
** src/H5T.c
** src/H5Tprivate.h
Added a bkg_stride argument to the H5T_convert() definition in
order to fix a bug related to the optimized compound datatype
conversion function.
** src/H5T.c
** src/H5A.c
** src/H5D.c
** src/H5Ofill.c
** src/H5P.c
Added bkg_stride=0 argument to the H5T_convert() calls.
** test/dtypes.c
Added a test for the H5T_conv_struct_opt() bug fixed above.
** src/H5FL.c
The H5FL_term() function should return non-zero even when it
couldn't free all the free lists do to their being used by
some other package. When that other package terminates it
will return non-zero, causing H5FL_term() to be called
again. This fixes some of the `infinite loop closing library'
messages.
** tools/pdb2hdf
Uses print_version() instead of doing that itself.
** src/H5Ppublic.h
Renamed H5Pget_gc_reference() declaration to make it match the
definition.
** src/H5FDlog.c
Added API tracing macros.
Removed `const' qualifier from a `char*' member of a struct
which was allocated on the heap.
** src/H5TB.c
Added curly braces to a couple deeply-nested `if' statements
to make them clearer and to shut up the increadibly stupid and
just plain incorrect gcc warning about ambiguous `else'.
** test/titerate.c
Removed incomplete initialization in favor of memset() for one
auto variable to stop compiler warnings.
** tools/Depencencies
Regenerated to remove references to h5dumputil.c
Diffstat (limited to 'test')
-rw-r--r-- | test/dtypes.c | 102 | ||||
-rw-r--r-- | test/titerate.c | 4 |
2 files changed, 104 insertions, 2 deletions
diff --git a/test/dtypes.c b/test/dtypes.c index 285a174..035e755 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -751,7 +751,105 @@ test_compound_4(void) error: return 1; } + + +/*------------------------------------------------------------------------- + * Function: test_compound_5 + * + * Purpose: Many versions of HDF5 have a bug in the optimized compound + * datatype conversion function, H5T_conv_struct_opt(), which + * is triggered when the top-level type contains a struct + * which must undergo a conversion. + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Robb Matzke + * Thursday, June 17, 1999 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_compound_5(void) +{ + typedef struct { + char name[16]; + short tdim; + short coll_ids[4]; + } src_type_t; + + typedef struct { + char name[16]; + short tdim; + int coll_ids[4]; + } dst_type_t; + + hsize_t dims[1] = {4}; + hid_t src_type, dst_type, short_array, int_array, string; + src_type_t src[2] = {{"one", 102, {104, 105, 106, 107}}, + {"two", 202, {204, 205, 206, 207}}}; + dst_type_t *dst; + void *buf = calloc(2, sizeof(dst_type_t)); + void *bkg = calloc(2, sizeof(dst_type_t)); + +#if 1 + TESTING("optimized struct converter"); +#else + /* Turn off optimized compound conversion function to work around + * the problem. */ + TESTING("optimized struct converter bug workaround"); + H5Tunregister(H5T_PERS_DONTCARE, "struct(opt)", -1, -1, NULL); +#endif + + /* Build datatypes */ + short_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(short)); + H5Tinsert_array(short_array, "_", 0, 1, dims, NULL, H5T_NATIVE_SHORT); + + int_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(int)); + H5Tinsert_array(int_array, "_", 0, 1, dims, NULL, H5T_NATIVE_INT); + + string = H5Tcopy(H5T_C_S1); + H5Tset_size(string, 16); + + src_type = H5Tcreate(H5T_COMPOUND, sizeof(src_type_t)); + H5Tinsert(src_type, "name", HOFFSET(src_type_t, name), string ); + H5Tinsert(src_type, "tdim", HOFFSET(src_type_t, tdim), H5T_NATIVE_SHORT); + H5Tinsert(src_type, "coll_ids", HOFFSET(src_type_t, coll_ids), short_array ); + + dst_type = H5Tcreate(H5T_COMPOUND, sizeof(dst_type_t)); + H5Tinsert(dst_type, "name", HOFFSET(dst_type_t, name), string ); + H5Tinsert(dst_type, "tdim", HOFFSET(dst_type_t, tdim), H5T_NATIVE_SHORT); + H5Tinsert(dst_type, "coll_ids", HOFFSET(dst_type_t, coll_ids), int_array ); + + /* Convert data */ + memcpy(buf, src, sizeof(src)); + H5Tconvert(src_type, dst_type, 2, buf, bkg, H5P_DEFAULT); + dst = (dst_type_t*)buf; + + /* Cleanup */ + H5Tclose(src_type); + H5Tclose(dst_type); + H5Tclose(string); + H5Tclose(short_array); + H5Tclose(int_array); + + /* Check results */ + if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || + src[1].tdim!=dst[1].tdim || + src[1].coll_ids[0]!=dst[1].coll_ids[0] || + src[1].coll_ids[1]!=dst[1].coll_ids[1] || + src[1].coll_ids[2]!=dst[1].coll_ids[2] || + src[1].coll_ids[3]!=dst[1].coll_ids[3]) { + FAILED(); + return 1; + } + PASSED(); + return 0; +} /*------------------------------------------------------------------------- @@ -1589,7 +1687,8 @@ test_conv_bitfield(void) */ static herr_t convert_opaque(hid_t UNUSED st, hid_t UNUSED dt, H5T_cdata_t *cdata, - size_t UNUSED nelmts, size_t UNUSED stride, void UNUSED *_buf, + size_t UNUSED nelmts, size_t UNUSED buf_stride, + size_t UNUSED bkg_stride, void UNUSED *_buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plid) { if (H5T_CONV_CONV==cdata->command) num_opaque_conversions_g++; @@ -3570,6 +3669,7 @@ main(void) nerrors += test_compound_2(); nerrors += test_compound_3(); nerrors += test_compound_4(); + nerrors += test_compound_5(); nerrors += test_conv_int (); nerrors += test_conv_enum_1(); nerrors += test_conv_bitfield(); diff --git a/test/titerate.c b/test/titerate.c index 751f090..5e56001 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -425,7 +425,7 @@ static void test_iter_group_large(void) hsize_t dims[] = {SPACE1_DIM1}; herr_t ret; /* Generic return value */ char gname[20]; /* Temporary group name */ - iter_info names[NGROUPS+2]={0}; /* Names of objects in the root group */ + iter_info names[NGROUPS+2]; /* Names of objects in the root group */ iter_info *curr_name; /* Pointer to the current name in the root group */ int i; @@ -436,6 +436,8 @@ static void test_iter_group_large(void) float c; } s1_t; + memset(names, 0, sizeof names); + /* Output message about test being performed */ MESSAGE(5, ("Testing Large Group Iteration Functionality\n")); |