diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2000-10-19 16:42:33 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2000-10-19 16:42:33 (GMT) |
commit | 95445613ca4282b2e62fb98b832e755f79d3a968 (patch) | |
tree | eee37d5f144c7f9b0a23fecbf38fbe63b640f507 | |
parent | e5c61707549a9d193075db17f01557743b8a8407 (diff) | |
download | hdf5-95445613ca4282b2e62fb98b832e755f79d3a968.zip hdf5-95445613ca4282b2e62fb98b832e755f79d3a968.tar.gz hdf5-95445613ca4282b2e62fb98b832e755f79d3a968.tar.bz2 |
[svn-r2699] Purpose:
Bug fix
Description:
"Time" datatypes (H5T_UNIX_D*) were not being stored and retrieved in
the datatype object header message correctly.
Solution:
Store endian-ness and precision in the datatype object header message and
added test to continue to track them working correctly.
This fixes bug #512.
Platforms tested:
FreeBSD 4.1.1 (hawkwind)
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | RELEASE | 2 | ||||
-rw-r--r-- | src/H5Odtype.c | 23 | ||||
-rw-r--r-- | src/H5T.c | 2 | ||||
-rw-r--r-- | test/Makefile.in | 6 | ||||
-rw-r--r-- | test/testhdf5.c | 1 | ||||
-rw-r--r-- | test/testhdf5.h | 2 | ||||
-rw-r--r-- | test/ttime.c | 155 |
8 files changed, 188 insertions, 4 deletions
@@ -607,6 +607,7 @@ ./test/th5s.h5 ./test/titerate.c ./test/tmeta.c +./test/ttime.c ./test/trefer.c ./test/tselect.c ./test/ttbbt.c @@ -90,6 +90,8 @@ Library put an upper limit on the amount of memory used for free lists. * Checked for non-existent or deleted objects when dereferencing one with object or region references and disallow dereference. + * "Time" datatypes (H5T_UNIX_D*) were not being stored and retrieved from + object headers correctly, fixed now. Configuration diff --git a/src/H5Odtype.c b/src/H5Odtype.c index ad7faa0..b4ff181 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -322,6 +322,11 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) "invalid VL location"); break; + case H5T_TIME: /* Time datatypes */ + dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + UINT16DECODE(*pp, dt->u.atomic.prec); + break; + default: if (flags) { HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, @@ -656,6 +661,20 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) } break; + case H5T_TIME: /* Time datatypes... */ + switch (dt->u.atomic.order) { + case H5T_ORDER_LE: + break; /*nothing */ + case H5T_ORDER_BE: + flags |= 0x01; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet"); + } + UINT16ENCODE(*pp, dt->u.atomic.prec); + break; + default: /*nothing */ break; @@ -859,6 +878,10 @@ H5O_dtype_size(H5F_t *f, const void *mesg) ret_value += H5O_dtype_size(f, dt->parent); break; + case H5T_TIME: + ret_value += 2; + break; + default: /*no properties */ break; @@ -6426,7 +6426,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) break; - case H5T_TIME: + case H5T_TIME: /* order and precision are checked above */ /*void */ break; diff --git a/test/Makefile.in b/test/Makefile.in index 062b46d..fd97c82 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -46,7 +46,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ gheap1.h5 gheap2.h5 gheap3.h5 gheap4.h5 links.h5 chunk.h5 \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 dtypes1.h5 dtypes2.h5 \ tattr.h5 tselect.h5 mtime.h5 ragged.h5 unlink.h5 overhead.h5 \ - fillval_[0-9].h5 fillval.raw mount_[0-9].h5 trefer[12].h5 \ + fillval_[0-9].h5 fillval.raw mount_[0-9].h5 ttime.h5 trefer[12].h5 \ tvltypes.h5 tvlstr.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 CLEAN=$(TIMINGS) @@ -59,7 +59,7 @@ TEST_SRC=big.c bittests.c chunk.c cmpd_dset.c dsets.c dtypes.c extend.c \ external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \ iopipe.c istore.c lheap.c links.c mount.c mtime.c ohdr.c overhead.c \ ragged.c stab.c tattr.c testhdf5.c tfile.c th5s.c titerate.c tmeta.c \ - trefer.c tselect.c ttbbt.c tvltypes.c tvlstr.c unlink.c enum.c \ + ttime.c trefer.c tselect.c ttbbt.c tvltypes.c tvlstr.c unlink.c enum.c \ ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c \ gass_write.c gass_read.c gass_append.c dpss_read.c dpss_write.c \ @@ -83,7 +83,7 @@ timings _timings: $(TIMINGS) ## How to build the tests... They all depend on the test and hdf5 libraries. $(TEST_PROGS): $(LIB) $(LIBHDF5) -TESTHDF5_OBJ=testhdf5.lo tattr.lo tfile.lo titerate.lo tmeta.lo trefer.lo tselect.lo ttbbt.lo tvltypes.lo tvlstr.lo th5s.lo +TESTHDF5_OBJ=testhdf5.lo tattr.lo tfile.lo titerate.lo tmeta.lo ttime.lo trefer.lo tselect.lo ttbbt.lo tvltypes.lo tvlstr.lo th5s.lo TTS_OBJ=ttsafe.lo ttsafe_dcreate.lo ttsafe_error.lo ttsafe_cancel.lo \ ttsafe_acreate.lo diff --git a/test/testhdf5.c b/test/testhdf5.c index ea88a7c..2b79074 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -168,6 +168,7 @@ main(int argc, char *argv[]) InitTest("h5s", test_h5s, cleanup_h5s, "Dataspaces"); InitTest("attr", test_attr, cleanup_attr, "Attributes"); InitTest("select", test_select, cleanup_select, "Selections"); + InitTest("time", test_time, cleanup_time, "Time Datatypes"); InitTest("reference", test_reference, cleanup_reference, "References"); InitTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes"); InitTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings"); diff --git a/test/testhdf5.h b/test/testhdf5.h index ad0d19b..93b3398 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -125,6 +125,7 @@ void test_h5s(void); void test_h5d(void); void test_attr(void); void test_select(void); +void test_time(void); void test_reference(void); void test_vltypes(void); void test_vlstrings(void); @@ -136,6 +137,7 @@ void cleanup_file(void); void cleanup_h5s(void); void cleanup_attr(void); void cleanup_select(void); +void cleanup_time(void); void cleanup_reference(void); void cleanup_vltypes(void); void cleanup_vlstrings(void); diff --git a/test/ttime.c b/test/ttime.c new file mode 100644 index 0000000..2ff5426 --- /dev/null +++ b/test/ttime.c @@ -0,0 +1,155 @@ +/**************************************************************************** + * NCSA HDF * + * Software Development Group * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ + +#ifdef RCSID +static char RcsId[] = "$Revision$"; +#endif + +/* $Id$ */ + +/*********************************************************** +* +* Test program: ttime +* +* Test the Time Datatype functionality +* +*************************************************************/ + +#include <testhdf5.h> + +#include <hdf5.h> + +#define FILE "ttime.h5" + +/**************************************************************** +** +** test_time(): Main time datatype testing routine. +** +****************************************************************/ +void +test_time(void) +{ + hid_t file_id, tid; /* identifiers */ + herr_t status; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Time Datatypes\n")); + + /* Create a new file using default properties. */ + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fcreate"); + + tid = H5Tcopy (H5T_UNIX_D32LE); + CHECK(tid, FAIL, "H5Tcopy"); + status = H5Tcommit(file_id, "Committed D32LE type", tid); + CHECK(status, FAIL, "H5Tcommit"); + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + tid = H5Tcopy (H5T_UNIX_D32BE); + CHECK(tid, FAIL, "H5Tcopy"); + status = H5Tcommit(file_id, "Committed D32BE type", tid); + CHECK(status, FAIL, "H5Tcommit"); + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + tid = H5Tcopy (H5T_UNIX_D64LE); + CHECK(tid, FAIL, "H5Tcopy"); + status = H5Tcommit(file_id, "Committed D64LE type", tid); + CHECK(status, FAIL, "H5Tcommit"); + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + tid = H5Tcopy (H5T_UNIX_D64BE); + CHECK(tid, FAIL, "H5Tcopy"); + status = H5Tcommit(file_id, "Committed D64BE type", tid); + CHECK(status, FAIL, "H5Tcommit"); + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + /* Close the file. */ + status = H5Fclose(file_id); + CHECK(status, FAIL, "H5Fclose"); + + file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fopen"); + + tid = H5Topen(file_id, "Committed D32LE type"); + CHECK(tid, FAIL, "H5Topen"); + + if(!H5Tequal(tid, H5T_UNIX_D32LE)) { + num_errs++; + MESSAGE(0, ("H5T_UNIX_D32LE datatype not found")); + } /* end if */ + + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + tid = H5Topen(file_id, "Committed D32BE type"); + CHECK(tid, FAIL, "H5Topen"); + + if(!H5Tequal(tid, H5T_UNIX_D32BE)) { + num_errs++; + MESSAGE(0, ("H5T_UNIX_D32BE datatype not found")); + } /* end if */ + + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + tid = H5Topen(file_id, "Committed D64LE type"); + CHECK(tid, FAIL, "H5Topen"); + + if(!H5Tequal(tid, H5T_UNIX_D64LE)) { + num_errs++; + MESSAGE(0, ("H5T_UNIX_D64LE datatype not found")); + } /* end if */ + + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + tid = H5Topen(file_id, "Committed D64BE type"); + CHECK(tid, FAIL, "H5Topen"); + + if(!H5Tequal(tid, H5T_UNIX_D64BE)) { + num_errs++; + MESSAGE(0, ("H5T_UNIX_D64BE datatype not found")); + } /* end if */ + + status = H5Tclose (tid); + CHECK(status, FAIL, "H5Tclose"); + + status = H5Fclose(file_id); + CHECK(status, FAIL, "H5Fclose"); + +} /* test_reference() */ + + +/*------------------------------------------------------------------------- + * Function: cleanup_time + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Quincey Koziol + * October 19, 2000 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void +cleanup_time(void) +{ + remove(FILE); +} + |