summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-07-21 19:39:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-07-21 19:39:40 (GMT)
commit0c8e622e1acfe4dbf0d8dd25a514a231c08d388d (patch)
tree19388a211f93c4fd6135cad4ad9d25f41def7ab6 /test
parentf383c2a622990b3164c45ac09dc9e8f2f64fe7dd (diff)
downloadhdf5-0c8e622e1acfe4dbf0d8dd25a514a231c08d388d.zip
hdf5-0c8e622e1acfe4dbf0d8dd25a514a231c08d388d.tar.gz
hdf5-0c8e622e1acfe4dbf0d8dd25a514a231c08d388d.tar.bz2
[svn-r17210] Description:
Bring r17157:17209 from trunk to revise_chunks branch. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test')
-rw-r--r--test/dtypes.c144
-rw-r--r--test/fheap.c61
-rw-r--r--test/testhdf5.h1
3 files changed, 192 insertions, 14 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index c83cdfd..9138b50 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -4903,8 +4903,9 @@ opaque_funcs(void)
* Programmer: Raymond Lu
* July 14, 2004
*
- * Modifications:
- *
+ * Modifications: Raymond Lu
+ * July 13, 2009
+ * Added the test for VL string types.
*-------------------------------------------------------------------------
*/
static int
@@ -4916,14 +4917,16 @@ test_encode(void)
long c;
double d;
};
- hid_t file=-1, tid1=-1, tid2=-1;
- hid_t decoded_tid1=-1, decoded_tid2=-1;
+ hid_t file=-1, tid1=-1, tid2=-1, tid3=-1;
+ hid_t decoded_tid1=-1, decoded_tid2=-1, decoded_tid3=-1;
char filename[1024];
char compnd_type[]="Compound_type", enum_type[]="Enum_type";
+ char vlstr_type[]="VLstring_type";
short enum_val;
size_t cmpd_buf_size = 0;
size_t enum_buf_size = 0;
- unsigned char *cmpd_buf=NULL, *enum_buf=NULL;
+ size_t vlstr_buf_size = 0;
+ unsigned char *cmpd_buf=NULL, *enum_buf=NULL, *vlstr_buf=NULL;
herr_t ret;
TESTING("functions of encoding and decoding datatypes");
@@ -4934,7 +4937,7 @@ test_encode(void)
goto error;
/*-----------------------------------------------------------------------
- * Create compound and enumerate datatypes
+ * Create compound, enumerate, and VL string datatypes
*-----------------------------------------------------------------------
*/
/* Create a compound datatype */
@@ -4996,8 +4999,20 @@ test_encode(void)
goto error;
} /* end if */
+ /* Create a variable-length string type */
+ if((tid3 = H5Tcopy(H5T_C_S1)) < 0) {
+ H5_FAILED();
+ printf("Can't copy a string type\n");
+ goto error;
+ } /* end if */
+ if(H5Tset_size(tid3, H5T_VARIABLE) < 0) {
+ H5_FAILED();
+ printf("Can't the string type to be variable-length\n");
+ goto error;
+ } /* end if */
+
/*-----------------------------------------------------------------------
- * Test encoding and decoding compound and enumerate datatypes
+ * Test encoding and decoding compound, enumerate, and VL string datatypes
*-----------------------------------------------------------------------
*/
/* Encode compound type in a buffer */
@@ -5092,8 +5107,44 @@ test_encode(void)
goto error;
} /* end if */
+
+ /* Encode VL string type in a buffer */
+ if(H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ if(vlstr_buf_size>0)
+ vlstr_buf = (unsigned char*)calloc(1, vlstr_buf_size);
+
+ if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Decode from the VL string buffer and return an object handle */
+ if((decoded_tid3=H5Tdecode(vlstr_buf)) < 0) {
+ H5_FAILED();
+ printf("Can't decode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid3, tid3)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+ if(!H5Tis_variable_str(decoded_tid3)) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/*-----------------------------------------------------------------------
- * Commit and reopen the compound and enumerate datatypes
+ * Commit and reopen the compound, enumerate, VL string datatypes
*-----------------------------------------------------------------------
*/
/* Commit compound datatype and close it */
@@ -5134,13 +5185,37 @@ test_encode(void)
free(enum_buf);
enum_buf_size = 0;
+ /* Commit enumeration datatype and close it */
+ if(H5Tcommit2(file, vlstr_type, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) {
+ H5_FAILED();
+ printf("Can't commit vl string datatype\n");
+ goto error;
+ } /* end if */
+ if(H5Tclose(tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
+ if(H5Tclose(decoded_tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
+ free(vlstr_buf);
+ vlstr_buf_size = 0;
+
/* Open the dataytpe for query */
if((tid1 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if((tid2 = H5Topen2(file, enum_type, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
+ if((tid3 = H5Topen2(file, vlstr_type, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
-
+ /*-----------------------------------------------------------------------
+ * Test encoding and decoding compound, enumerate, and vl string datatypes
+ *-----------------------------------------------------------------------
+ */
/* Encode compound type in a buffer */
if(H5Tencode(tid1, NULL, &cmpd_buf_size) < 0) {
H5_FAILED();
@@ -5180,10 +5255,6 @@ test_encode(void)
goto error;
} /* end if */
- /*-----------------------------------------------------------------------
- * Test encoding and decoding compound and enumerate datatypes
- *-----------------------------------------------------------------------
- */
/* Encode enumerate type in a buffer */
if(H5Tencode(tid2, NULL, &enum_buf_size) < 0) {
H5_FAILED();
@@ -5226,6 +5297,41 @@ test_encode(void)
goto error;
} /* end if */
+ /* Encode VL string type in a buffer */
+ if(H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ if(vlstr_buf_size>0)
+ vlstr_buf = (unsigned char*)calloc(1, vlstr_buf_size);
+
+ if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Decode from the VL string buffer and return an object handle */
+ if((decoded_tid3=H5Tdecode(vlstr_buf)) < 0) {
+ H5_FAILED();
+ printf("Can't decode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid3, tid3)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+ if(!H5Tis_variable_str(decoded_tid3)) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/*-----------------------------------------------------------------------
* Close and release
*-----------------------------------------------------------------------
@@ -5241,6 +5347,11 @@ test_encode(void)
printf("Can't close datatype\n");
goto error;
} /* end if */
+ if(H5Tclose(tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
if(H5Tclose(decoded_tid1) < 0) {
H5_FAILED();
@@ -5252,6 +5363,11 @@ test_encode(void)
printf("Can't close datatype\n");
goto error;
} /* end if */
+ if(H5Tclose(decoded_tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
if(H5Fclose(file) < 0) {
H5_FAILED();
@@ -5269,8 +5385,10 @@ test_encode(void)
H5E_BEGIN_TRY {
H5Tclose (tid1);
H5Tclose (tid2);
+ H5Tclose (tid3);
H5Tclose (decoded_tid1);
H5Tclose (decoded_tid2);
+ H5Tclose (decoded_tid3);
H5Fclose (file);
} H5E_END_TRY;
return 1;
diff --git a/test/fheap.c b/test/fheap.c
index 953a849..33614c2 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -15377,6 +15377,18 @@ error:
*
*-------------------------------------------------------------------------
*/
+/* Custom filter used to verify that the filters are actually called and do not
+ * just silently fail */
+static hbool_t test_write_filter_called;
+static size_t test_write_filter(unsigned int UNUSED flags, size_t UNUSED cd_nelmts,
+ const unsigned int UNUSED cd_values[], size_t nbytes, size_t UNUSED *buf_size,
+ void UNUSED **buf)
+{
+ test_write_filter_called = TRUE;
+
+ return nbytes;
+} /* end link_filter_filter */
+
static unsigned
test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
@@ -15413,12 +15425,27 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
/* Check if we are compressing the blocks */
if(tparam->comp == FHEAP_TEST_COMPRESS) {
+ H5Z_class2_t filter_class; /* Custom filter */
unsigned deflate_level; /* Deflation level */
/* Set an I/O filter for heap data */
deflate_level = 6;
if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0)
FAIL_STACK_ERROR
+
+ /* Register and append custom filter */
+ filter_class.version = H5Z_CLASS_T_VERS;
+ filter_class.id = H5Z_FILTER_RESERVED + 43;
+ filter_class.encoder_present = TRUE;
+ filter_class.decoder_present = TRUE;
+ filter_class.name = "custom_fheap_filter";
+ filter_class.can_apply = NULL;
+ filter_class.set_local = NULL;
+ filter_class.filter = test_write_filter;
+ if(H5Zregister(&filter_class) < 0) TEST_ERROR
+ if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_RESERVED + 43, 0, 0, NULL) < 0)
+ FAIL_STACK_ERROR
+ test_write_filter_called = FALSE;
} /* end if */
/* Perform common file & heap open operations */
@@ -15466,6 +15493,35 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
if(ret >= 0)
TEST_ERROR
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ FAIL_STACK_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the custom filter has been applied for the huge object (if
+ * applicable) */
+ if(tparam->comp == FHEAP_TEST_COMPRESS) {
+ if(!test_write_filter_called) TEST_ERROR
+ test_write_filter_called = FALSE;
+ } /* end if */
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open the heap */
+ if(NULL == (fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr)))
+ FAIL_STACK_ERROR
+
/* Initialize data to overwrite with */
rewrite_obj = (unsigned char *)H5MM_malloc(shared_obj_size_g);
for(u = 0; u < shared_obj_size_g; u++)
@@ -15511,6 +15567,11 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
+ /* Verify that the custom filter has been applied to the managed objects (if
+ * applicable) */
+ if(tparam->comp == FHEAP_TEST_COMPRESS)
+ if(!test_write_filter_called) TEST_ERROR
+
/* Re-open the file */
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
diff --git a/test/testhdf5.h b/test/testhdf5.h
index ed8b049..86333d3 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -25,7 +25,6 @@
* so we include the private headers here.
*/
#include "H5private.h"
-#include "H5Eprivate.h"
/* Include generic testing header also */
#include "h5test.h"