summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1999-06-07 15:05:02 (GMT)
committerRobb Matzke <matzke@llnl.gov>1999-06-07 15:05:02 (GMT)
commitb98fcbf5926e81f2e4ead8daa46e650566719e1c (patch)
tree1653e8084aff321512fb2d2bc842573fef62f220 /test
parent2a10e682a13244d5c61982445f2d6ec5bc990a36 (diff)
downloadhdf5-b98fcbf5926e81f2e4ead8daa46e650566719e1c.zip
hdf5-b98fcbf5926e81f2e4ead8daa46e650566719e1c.tar.gz
hdf5-b98fcbf5926e81f2e4ead8daa46e650566719e1c.tar.bz2
[svn-r1306] Changes since 19990602
---------------------- ./doc/html/Datatypes.html ./test/dtypes.c Added documentation and tests for opaque types. ./tools/h5ls.c Added a `-x' or `--hexdump' argument which is not fully implemented (because I want to synchronize h5tools.c first) but which will eventually print raw data in hexadecimal format without any translation from disk. This would be useful for debugging references and VL types. ./tools/h5tools.c Added support for references (not quite finished yet, but compiles -- I wanted to sync up this file before Patrick and I got too far apart...) ./src/H5R.c Checked for error return value from H5R_get_object_type() ./src/H5A.c ./src/H5D.c Changed error return values from NULL to FAIL ./test/Makefile.in ./test/trefer.c Creates trefer1.h5 and trefer2.h5 so that the second test doesn't clobber the first file since the files might be useful for debugging.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in4
-rw-r--r--test/dtypes.c61
-rw-r--r--test/trefer.c14
3 files changed, 70 insertions, 9 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index f535942..ead1c3c 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -45,8 +45,8 @@ 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.h5 flush.h5 \
- enum1.h5
+ fillval_[0-9].h5 fillval.raw mount_[0-9].h5 trefer[12].h5 \
+ flush.h5 enum1.h5
CLEAN=$(TIMINGS)
# Source and object files for programs... The TEST_SRC list contains all the
diff --git a/test/dtypes.c b/test/dtypes.c
index eaff31d..484ca24 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -76,6 +76,9 @@ static int skip_overflow_tests_g = 0;
/* Don't use hardware conversions if set */
static int without_hardware_g = 0;
+/* Count opaque conversions */
+static int num_opaque_conversions_g = 0;
+
/*
* Although we check whether a floating point overflow generates a SIGFPE and
* turn off overflow tests in that case, it might still be possible for an
@@ -1221,6 +1224,31 @@ test_conv_bitfield(void)
/*-------------------------------------------------------------------------
+ * Function: convert_opaque
+ *
+ * Purpose: A fake opaque conversion functions
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Friday, June 4, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+convert_opaque(hid_t UNUSED st, hid_t UNUSED dt, H5T_cdata_t *cdata,
+ size_t UNUSED nelmts, void UNUSED *_buf, void UNUSED *bkg)
+{
+ if (H5T_CONV_CONV==cdata->command) num_opaque_conversions_g++;
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
* Function: test_opaque
*
* Purpose: Test opaque datatypes
@@ -1239,13 +1267,44 @@ test_conv_bitfield(void)
static int
test_opaque(void)
{
+#define OPAQUE_NELMTS 1000
hid_t st=-1, dt=-1;
+ herr_t status;
+ char buf[1]; /*not really used*/
+ int saved = num_opaque_conversions_g;
TESTING("opaque datatypes");
-
+
+ /* Build source and destination types */
if ((st=H5Tcreate(H5T_OPAQUE, 4))<0) goto error;
+ if (H5Tset_tag(st, "opaque source type")<0) goto error;
+ if ((dt=H5Tcreate(H5T_OPAQUE, 4))<0) goto error;
+ if (H5Tset_tag(dt, "opaque destination type")<0) goto error;
+
+ /* Make sure that we can't convert between the types yet */
+ H5E_BEGIN_TRY {
+ status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL);
+ } H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ printf(" opaque conversion should have failed but succeeded\n");
+ goto error;
+ }
+ /* Register a conversion function */
+ if (H5Tregister(H5T_PERS_HARD, "o_test", st, dt, convert_opaque)<0)
+ goto error;
+
+ /* Try the conversion again, this time it should work */
+ if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL)<0) goto error;
+ if (saved+1 != num_opaque_conversions_g) {
+ FAILED();
+ printf(" unexpected number of opaque conversions\n");
+ goto error;
+ }
+
H5Tclose(st);
+ H5Tclose(dt);
PASSED();
return 0;
diff --git a/test/trefer.c b/test/trefer.c
index f9d5ef7..651557f 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -28,7 +28,8 @@ static char RcsId[] = "$Revision$";
#include <hdf5.h>
-#define FILE "trefer.h5"
+#define FILE1 "trefer1.h5"
+#define FILE2 "trefer2.h5"
/* 1-D dataset with fixed dimensions */
#define SPACE1_NAME "Space1"
@@ -86,7 +87,7 @@ test_reference_obj(void)
tbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1);
/* Create file */
- fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fcreate");
/* Create dataspace for datasets */
@@ -195,7 +196,7 @@ test_reference_obj(void)
CHECK(ret, FAIL, "H5Fclose");
/* Re-open the file */
- fid1 = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ fid1 = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fopen");
/* Open the dataset */
@@ -321,7 +322,7 @@ test_reference_region(void)
drbuf=calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
/* Create file */
- fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ fid1 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fcreate");
/* Create dataspace for datasets */
@@ -410,7 +411,7 @@ test_reference_region(void)
CHECK(ret, FAIL, "H5Fclose");
/* Re-open the file */
- fid1 = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fopen");
/* Open the dataset */
@@ -569,6 +570,7 @@ test_reference(void)
void
cleanup_reference(void)
{
- remove(FILE);
+ remove(FILE1);
+ remove(FILE2);
}