summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dtypes.c86
-rw-r--r--test/tvltypes.c482
2 files changed, 519 insertions, 49 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 5325260..d3c73ae 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -481,7 +481,7 @@ test_compound_2(void)
goto error;
/* Perform the conversion */
- if (H5Tconvert(st, dt, nelmts, buf, bkg)<0) goto error;
+ if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error;
/* Compare results */
for (i=0; i<nelmts; i++) {
@@ -593,7 +593,7 @@ test_compound_3(void)
goto error;
/* Perform the conversion */
- if (H5Tconvert(st, dt, nelmts, buf, bkg)<0) goto error;
+ if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error;
/* Compare results */
for (i=0; i<nelmts; i++) {
@@ -709,7 +709,7 @@ test_compound_4(void)
goto error;
/* Perform the conversion */
- if (H5Tconvert(st, dt, nelmts, buf, bkg)<0) goto error;
+ if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error;
/* Compare results */
for (i=0; i<nelmts; i++) {
@@ -1122,13 +1122,13 @@ test_conv_str_1(void)
dst_type = mkstr(5, H5T_STR_NULLTERM);
buf = calloc(2, 10);
memcpy(buf, "abcdefghi\0abcdefghi\0", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcdefghi\0", 20)) {
FAILED();
puts(" Truncated C-string test failed");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd\0\0\0\0\0\0abcd\0\0\0\0\0\0", 20)) {
FAILED();
puts(" Extended C-string test failed");
@@ -1145,13 +1145,13 @@ test_conv_str_1(void)
dst_type = mkstr(5, H5T_STR_NULLPAD);
buf = calloc(2, 10);
memcpy(buf, "abcdefghijabcdefghij", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) {
FAILED();
puts(" Truncated C buffer test failed");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
FAILED();
puts(" Extended C buffer test failed");
@@ -1168,13 +1168,13 @@ test_conv_str_1(void)
dst_type = mkstr(5, H5T_STR_SPACEPAD);
buf = calloc(2, 10);
memcpy(buf, "abcdefghijabcdefghij", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) {
FAILED();
puts(" Truncated Fortran-string test failed");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcde abcde ", 20)) {
FAILED();
puts(" Extended Fortran-string test failed");
@@ -1194,7 +1194,7 @@ test_conv_str_1(void)
dst_type = mkstr(10, H5T_STR_NULLTERM);
buf = calloc(2, 10);
memcpy(buf, "abcdefghijabcdefghij", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdefghijabcdefghij", 20)) {
FAILED();
puts(" Non-terminated string test 1");
@@ -1203,14 +1203,14 @@ test_conv_str_1(void)
H5Tclose(dst_type);
dst_type = mkstr(5, H5T_STR_NULLTERM);
memcpy(buf, "abcdefghijabcdefghij", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcdefghij", 20)) {
FAILED();
puts(" Non-terminated string test 2");
goto error;
}
memcpy(buf, "abcdeabcdexxxxxxxxxx", 20);
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
FAILED();
puts(" Non-terminated string test 2");
@@ -1227,13 +1227,13 @@ test_conv_str_1(void)
dst_type = mkstr(10, H5T_STR_SPACEPAD);
buf = calloc(2, 10);
memcpy(buf, "abcdefghi\0abcdefghi\0", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdefghi abcdefghi ", 20)) {
FAILED();
puts(" C string to Fortran test 1");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdefghi\0abcdefghi\0", 20)) {
FAILED();
puts(" Fortran to C string test 1");
@@ -1242,13 +1242,13 @@ test_conv_str_1(void)
if (H5Tclose(dst_type)<0) goto error;
dst_type = mkstr(5, H5T_STR_SPACEPAD);
memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) {
FAILED();
puts(" C string to Fortran test 2");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
FAILED();
puts(" Fortran to C string test 2");
@@ -1259,13 +1259,13 @@ test_conv_str_1(void)
src_type = mkstr(5, H5T_STR_NULLTERM);
dst_type = mkstr(10, H5T_STR_SPACEPAD);
memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd abcd ", 20)) {
FAILED();
puts(" C string to Fortran test 3");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) {
FAILED();
puts(" Fortran to C string test 3");
@@ -1282,13 +1282,13 @@ test_conv_str_1(void)
dst_type = mkstr(10, H5T_STR_SPACEPAD);
buf = calloc(2, 10);
memcpy(buf, "abcdefghijabcdefghij", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdefghijabcdefghij", 20)) {
FAILED();
puts(" C buffer to Fortran test 1");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdefghijabcdefghij", 20)) {
FAILED();
puts(" Fortran to C buffer test 1");
@@ -1297,13 +1297,13 @@ test_conv_str_1(void)
if (H5Tclose(dst_type)<0) goto error;
dst_type = mkstr(5, H5T_STR_SPACEPAD);
memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) {
FAILED();
puts(" C buffer to Fortran test 2");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
FAILED();
puts(" Fortran to C buffer test 2");
@@ -1314,13 +1314,13 @@ test_conv_str_1(void)
src_type = mkstr(5, H5T_STR_NULLPAD);
dst_type = mkstr(10, H5T_STR_SPACEPAD);
memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20);
- if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd abcd ", 20)) {
FAILED();
puts(" C buffer to Fortran test 3");
goto error;
}
- if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
+ if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) {
FAILED();
puts(" Fortran to C buffer test 3");
@@ -1389,8 +1389,8 @@ test_conv_str_2(void)
}
printf("%-70s", s);
fflush(stdout);
- if (H5Tconvert(c_type, f_type, nelmts, buf, NULL)<0) goto error;
- if (H5Tconvert(f_type, c_type, nelmts, buf, NULL)<0) goto error;
+ if (H5Tconvert(c_type, f_type, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
+ if (H5Tconvert(f_type, c_type, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
PASSED();
}
ret_value = 0;
@@ -1451,7 +1451,7 @@ test_conv_enum_1(void)
}
printf("%-70s", s);
fflush(stdout);
- if (H5Tconvert(t1, t2, nelmts, buf, NULL)<0) goto error;
+ if (H5Tconvert(t1, t2, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
PASSED();
}
@@ -1464,7 +1464,7 @@ test_conv_enum_1(void)
}
printf("%-70s", s);
fflush(stdout);
- if (H5Tconvert(t2, t1, nelmts, buf, NULL)<0) goto error;
+ if (H5Tconvert(t2, t1, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
PASSED();
}
ret_value = 0;
@@ -1511,7 +1511,7 @@ test_conv_bitfield(void)
dt = H5Tcopy(H5T_STD_B32LE);
buf[0] = buf[1] = 0xAA;
buf[2] = buf[3] = 0x55; /*irrelevant*/
- if (H5Tconvert(st, dt, 1, buf, NULL)<0) goto error;
+ if (H5Tconvert(st, dt, 1, buf, NULL, H5P_DEFAULT)<0) goto error;
if (buf[0]!=0xAA || buf[1]!=0xAA || buf[2]!=0 || buf[3]!=0) {
FAILED();
printf(" s=0xaaaa, d=0x%02x%02x%02x%02x (test 1)\n",
@@ -1530,7 +1530,7 @@ test_conv_bitfield(void)
H5Tset_precision(dt, 12);
H5Tset_offset(dt, 10);
buf[0] = 0xA8; buf[1] = 0x2A; buf[2] = buf[3] = 0;
- if (H5Tconvert(st, dt, 1, buf, NULL)<0) goto error;
+ if (H5Tconvert(st, dt, 1, buf, NULL, H5P_DEFAULT)<0) goto error;
if (buf[0]!=0 || buf[1]!=0xA8 || buf[2]!=0x2A || buf[3]!=0) {
FAILED();
printf(" s=0x2AA8 d=0x%02x%02x%02x%02x (test 2)\n",
@@ -1544,7 +1544,7 @@ test_conv_bitfield(void)
*/
H5Tset_pad(dt, H5T_PAD_ONE, H5T_PAD_ONE);
buf[0] = 0xA8; buf[1] = 0x2A; buf[2] = buf[3] = 0;
- if (H5Tconvert(st, dt, 1, buf, NULL)<0) goto error;
+ if (H5Tconvert(st, dt, 1, buf, NULL, H5P_DEFAULT)<0) goto error;
if (buf[0]!=0xff || buf[1]!=0xAB || buf[2]!=0xEA || buf[3]!=0xff) {
FAILED();
printf(" s=0x2AA8 d=0x%02x%02x%02x%02x (test 3)\n",
@@ -1585,7 +1585,7 @@ 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,
- void UNUSED *bkg)
+ void UNUSED *bkg, hid_t dset_xfer_plid)
{
if (H5T_CONV_CONV==cdata->command) num_opaque_conversions_g++;
return 0;
@@ -1627,7 +1627,7 @@ test_opaque(void)
/* Make sure that we can't convert between the types yet */
H5E_BEGIN_TRY {
- status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL);
+ status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT);
} H5E_END_TRY;
if (status>=0) {
FAILED();
@@ -1640,7 +1640,7 @@ test_opaque(void)
goto error;
/* Try the conversion again, this time it should work */
- if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL)<0) goto error;
+ if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT)<0) goto error;
if (saved+1 != num_opaque_conversions_g) {
FAILED();
printf(" unexpected number of opaque conversions\n");
@@ -1690,7 +1690,7 @@ test_conv_int (void)
/* (unsigned)0x80000000 -> (unsigned)0xffff */
byte[0] = byte[1] = byte[2] = 0;
byte[3] = 0x80;
- if (H5Tconvert (H5T_STD_U32LE, H5T_STD_U16LE, 1, byte, NULL)<0) {
+ if (H5Tconvert (H5T_STD_U32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) {
goto error;
}
if (byte[0]!=0xff || byte[1]!=0xff) {
@@ -1703,7 +1703,7 @@ test_conv_int (void)
/* (unsigned)0xffffffff -> (signed)0x7fff */
byte[0] = byte[1] = byte[2] = byte[3] = 0xff;
- if (H5Tconvert (H5T_STD_U32LE, H5T_STD_I16LE, 1, byte, NULL)<0) {
+ if (H5Tconvert (H5T_STD_U32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) {
goto error;
}
if (byte[0]!=0xff || byte[1]!=0x7f) {
@@ -1716,7 +1716,7 @@ test_conv_int (void)
/* (signed)0xffffffff -> (unsigned)0x0000 */
byte[0] = byte[1] = byte[2] = byte[3] = 0xff;
- if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL)<0) {
+ if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) {
goto error;
}
if (byte[0]!=0x00 || byte[1]!=0x00) {
@@ -1730,7 +1730,7 @@ test_conv_int (void)
/* (signed)0x7fffffff -> (unsigned)0xffff */
byte[0] = byte[1] = byte[2] = 0xff;
byte[3] = 0x7f;
- if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL)<0) {
+ if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) {
goto error;
}
if (byte[0]!=0xff || byte[1]!=0xff) {
@@ -1744,7 +1744,7 @@ test_conv_int (void)
/* (signed)0x7fffffff -> (signed)0x7fff */
byte[0] = byte[1] = byte[2] = 0xff;
byte[3] = 0x7f;
- if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL)<0) {
+ if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) {
goto error;
}
if (byte[0]!=0xff || byte[1]!=0x7f) {
@@ -1758,7 +1758,7 @@ test_conv_int (void)
/* (signed)0xbfffffff -> (signed)0x8000 */
byte[0] = byte[1] = byte[2] = 0xff;
byte[3] = 0xbf;
- if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL)<0) {
+ if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) {
goto error;
}
if (byte[0]!=0x00 || byte[1]!=0x80) {
@@ -1951,7 +1951,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
for (j=0; j<nelmts*src_size; j++) buf[j] = saved[j] = rand();
/* Perform the conversion */
- if (H5Tconvert(src, dst, nelmts, buf, NULL)<0) goto error;
+ if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
/* Check the results from the library against hardware */
for (j=0; j<nelmts; j++) {
@@ -2837,7 +2837,7 @@ test_conv_int_2(void)
* Conversion. If overlap calculations aren't right then an
* assertion will fail in H5T_conv_i_i()
*/
- H5Tconvert(src_type, dst_type, 100, buf, NULL);
+ H5Tconvert(src_type, dst_type, 100, buf, NULL, H5P_DEFAULT);
H5Tclose(src_type);
H5Tclose(dst_type);
}
@@ -3104,7 +3104,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
}
/* Perform the conversion in software */
- if (H5Tconvert(src, dst, nelmts, buf, NULL)<0) goto error;
+ if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
/* Check the software results against the hardware */
for (j=0; j<nelmts; j++) {
diff --git a/test/tvltypes.c b/test/tvltypes.c
index 22f490b..08272f2 100644
--- a/test/tvltypes.c
+++ b/test/tvltypes.c
@@ -41,14 +41,58 @@ static char RcsId[] = "$Revision$";
#define SPACE2_DIM1 10
#define SPACE2_DIM2 10
+void *test_vltypes_alloc_custom(size_t size, void *info);
+void test_vltypes_free_custom(void *mem, void *info);
+
+/****************************************************************
+**
+** test_vltypes_alloc_custom(): Test VL datatype custom memory
+** allocation routines. This routine just uses malloc to
+** allocate the memory and increments the amount of memory
+** allocated.
+**
+****************************************************************/
+void *test_vltypes_alloc_custom(size_t size, void *info)
+{
+ void *ret_value=NULL; /* Pointer to return */
+ int *mem_used=(int *)info; /* Get the pointer to the memory used */
+
+ if((ret_value=HDmalloc(sizeof(int)+size))!=NULL) {
+ *(int *)ret_value=size;
+ *mem_used+=size;
+ } /* end if */
+ ret_value=((unsigned char *)ret_value)+sizeof(int);
+ return(ret_value);
+}
+
/****************************************************************
**
-** test_vltypes_atomic(): Test basic VL datatype code.
+** test_vltypes_free_custom(): Test VL datatype custom memory
+** allocation routines. This routine just uses free to
+** release the memory and decrements the amount of memory
+** allocated.
+**
+****************************************************************/
+void test_vltypes_free_custom(void *_mem, void *info)
+{
+ unsigned char *mem;
+ int *mem_used=(int *)info; /* Get the pointer to the memory used */
+
+ if(_mem!=NULL) {
+ mem=((unsigned char *)_mem)-sizeof(int);
+ *mem_used-=*(int *)mem;
+ HDfree(mem);
+ } /* end if */
+}
+
+/****************************************************************
+**
+** test_vltypes_vlen_atomic(): Test basic VL datatype code.
** Tests VL datatypes of atomic datatypes
**
****************************************************************/
static void
-test_vltypes_atomic(void)
+test_vltypes_vlen_atomic(void)
{
hvl_t wdata[SPACE1_DIM1]; /* Information to write */
hvl_t rdata[SPACE1_DIM1]; /* Information read in */
@@ -56,12 +100,14 @@ test_vltypes_atomic(void)
hid_t dataset; /* Dataset ID */
hid_t sid1; /* Dataspace ID */
hid_t tid1; /* Datatype ID */
+ hid_t xfer_pid; /* Dataset transfer property list ID */
hsize_t dims1[] = {SPACE1_DIM1};
uintn i,j; /* counting variables */
+ int mem_used=0; /* Memory used during allocation */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
- MESSAGE(5, ("Testing Basic VL Datatype Functionality\n"));
+ MESSAGE(5, ("Testing Basic Atomic VL Datatype Functionality\n"));
/* Allocate and initialize VL data to write */
for(i=0; i<SPACE1_DIM1; i++) {
@@ -91,10 +137,21 @@ test_vltypes_atomic(void)
ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dwrite");
+ /* Change to the custom memory allocation routines for reading VL data */
+ xfer_pid=H5Pcreate(H5P_DATASET_XFER);
+ CHECK(xfer_pid, FAIL, "H5Pcreate");
+
+ ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used);
+ CHECK(ret, FAIL, "H5Pset_vlen_mem_manager");
+
/* Read dataset from disk */
- ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata);
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dread");
+ /* Make certain the correct amount of memory has been used */
+ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */
+ VERIFY(mem_used,10*sizeof(uint32_t),"H5Dread");
+
/* Compare data read in */
for(i=0; i<SPACE1_DIM1; i++) {
if(wdata[i].len!=rdata[i].len) {
@@ -111,6 +168,142 @@ test_vltypes_atomic(void)
} /* end for */
} /* end for */
+ /* Reclaim the VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Make certain the VL memory has been freed */
+ VERIFY(mem_used,0,"H5Dvlen_reclaim");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_vltypes_vlen_atomic() */
+
+/****************************************************************
+**
+** test_vltypes_vlen_compound(): Test basic VL datatype code.
+** Tests VL datatypes of compound datatypes
+**
+****************************************************************/
+static void
+test_vltypes_vlen_compound(void)
+{
+ typedef struct { /* Struct that the VL sequences are composed of */
+ int i;
+ float f;
+ } s1;
+ hvl_t wdata[SPACE1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t xfer_pid; /* Dataset transfer property list ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ uintn i,j; /* counting variables */
+ int mem_used=0; /* Memory used during allocation */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Basic Compound VL Datatype Functionality\n"));
+
+ /* Allocate and initialize VL data to write */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ wdata[i].p=malloc((i+1)*sizeof(s1));
+ wdata[i].len=i+1;
+ for(j=0; j<(i+1); j++) {
+ ((s1 *)wdata[i].p)[j].i=i*10+j;
+ ((s1 *)wdata[i].p)[j].f=(i*20+j)/3.0;
+ } /* end for */
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create the base compound type */
+ tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1));
+ CHECK(tid2, FAIL, "H5Tcreate");
+
+ /* Insert fields */
+ ret=H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_INT);
+ CHECK(ret, FAIL, "H5Tinsert");
+ ret=H5Tinsert(tid2, "f", HOFFSET(s1, f), H5T_NATIVE_FLOAT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Create a datatype to refer to */
+ tid1 = H5Tvlen_create (tid2);
+ CHECK(tid1, FAIL, "H5Tvlen_create");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Change to the custom memory allocation routines for reading VL data */
+ xfer_pid=H5Pcreate(H5P_DATASET_XFER);
+ CHECK(xfer_pid, FAIL, "H5Pcreate");
+
+ ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used);
+ CHECK(ret, FAIL, "H5Pset_vlen_mem_manager");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Make certain the correct amount of memory has been used */
+ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */
+ VERIFY(mem_used,10*sizeof(s1),"H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ if(wdata[i].len!=rdata[i].len) {
+ num_errs++;
+ printf("VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
+ continue;
+ } /* end if */
+ for(j=0; j<rdata[i].len; j++) {
+ if( ((s1 *)wdata[i].p)[j].i != ((s1 *)rdata[i].p)[j].i ) {
+ num_errs++;
+ printf("VL data values don't match!, wdata[%d].p[%d].i=%d, rdata[%d].p[%d].i=%d\n",(int)i,(int)j, (int)((s1 *)wdata[i].p)[j].i, (int)i,(int)j, (int)((s1 *)rdata[i].p)[j].i);
+ continue;
+ } /* end if */
+ if( ((s1 *)wdata[i].p)[j].f != ((s1 *)rdata[i].p)[j].f ) {
+ num_errs++;
+ printf("VL data values don't match!, wdata[%d].p[%d].f=%f, rdata[%d].p[%d].f=%f\n",(int)i,(int)j, (double)((s1 *)wdata[i].p)[j].f, (int)i,(int)j, (double)((s1 *)rdata[i].p)[j].f);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+
+ /* Reclaim the VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Make certain the VL memory has been freed */
+ VERIFY(mem_used,0,"H5Dvlen_reclaim");
+
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
@@ -119,6 +312,280 @@ test_vltypes_atomic(void)
ret = H5Tclose(tid1);
CHECK(ret, FAIL, "H5Tclose");
+ /* Close datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_vltypes_vlen_compound() */
+
+/****************************************************************
+**
+** test_vltypes_compound_vlen_atomic(): Test basic VL datatype code.
+** Tests compound datatypes with VL datatypes of atomic datatypes.
+**
+****************************************************************/
+static void
+test_vltypes_compound_vlen_atomic(void)
+{
+ typedef struct { /* Struct that the VL sequences are composed of */
+ int i;
+ float f;
+ hvl_t v;
+ } s1;
+ s1 wdata[SPACE1_DIM1]; /* Information to write */
+ s1 rdata[SPACE1_DIM1]; /* Information read in */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t xfer_pid; /* Dataset transfer property list ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ uintn i,j; /* counting variables */
+ int mem_used=0; /* Memory used during allocation */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Compound Datatypes with VL Atomic Datatype Component Functionality\n"));
+
+ /* Allocate and initialize VL data to write */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ wdata[i].i=i*10;
+ wdata[i].f=(i*20)/3.0;
+ wdata[i].v.p=malloc((i+1)*sizeof(uint32_t));
+ wdata[i].v.len=i+1;
+ for(j=0; j<(i+1); j++)
+ ((uint32_t *)wdata[i].v.p)[j]=i*10+j;
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create a VL datatype to refer to */
+ tid1 = H5Tvlen_create (H5T_NATIVE_UINT);
+ CHECK(tid1, FAIL, "H5Tvlen_create");
+
+ /* Create the base compound type */
+ tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1));
+ CHECK(tid2, FAIL, "H5Tcreate");
+
+ /* Insert fields */
+ ret=H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_INT);
+ CHECK(ret, FAIL, "H5Tinsert");
+ ret=H5Tinsert(tid2, "f", HOFFSET(s1, f), H5T_NATIVE_FLOAT);
+ CHECK(ret, FAIL, "H5Tinsert");
+ ret=H5Tinsert(tid2, "v", HOFFSET(s1, v), tid1);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid2,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Change to the custom memory allocation routines for reading VL data */
+ xfer_pid=H5Pcreate(H5P_DATASET_XFER);
+ CHECK(xfer_pid, FAIL, "H5Pcreate");
+
+ ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used);
+ CHECK(ret, FAIL, "H5Pset_vlen_mem_manager");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Make certain the correct amount of memory has been used */
+ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */
+ VERIFY(mem_used,10*sizeof(uint32_t),"H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ if(wdata[i].i!=rdata[i].i) {
+ num_errs++;
+ printf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n",(int)i,(int)wdata[i].i,(int)i,(int)rdata[i].i);
+ continue;
+ } /* end if */
+ if(wdata[i].f!=rdata[i].f) {
+ num_errs++;
+ printf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n",(int)i,(double)wdata[i].f,(int)i,(double)rdata[i].f);
+ continue;
+ } /* end if */
+ if(wdata[i].v.len!=rdata[i].v.len) {
+ num_errs++;
+ printf("VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len);
+ continue;
+ } /* end if */
+ for(j=0; j<rdata[i].v.len; j++) {
+ if( ((uint32_t *)wdata[i].v.p)[j] != ((uint32_t *)rdata[i].v.p)[j] ) {
+ num_errs++;
+ printf("VL data values don't match!, wdata[%d].v.p[%d]=%d, rdata[%d].v.p[%d]=%d\n",(int)i,(int)j, (int)((uint32_t *)wdata[i].v.p)[j], (int)i,(int)j, (int)((uint32_t *)rdata[i].v.p)[j]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+
+ /* Reclaim the VL data */
+ ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Make certain the VL memory has been freed */
+ VERIFY(mem_used,0,"H5Dvlen_reclaim");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_vltypes_compound_vlen_atomic() */
+
+/****************************************************************
+**
+** test_vltypes_vlen_vlen_atomic(): Test basic VL datatype code.
+** Tests VL datatype with VL datatypes of atomic datatypes.
+**
+****************************************************************/
+static void
+test_vltypes_vlen_vlen_atomic(void)
+{
+ hvl_t wdata[SPACE1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1]; /* Information read in */
+ hvl_t *t1, *t2; /* Temporary pointer to VL information */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t xfer_pid; /* Dataset transfer property list ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ uintn i,j,k; /* counting variables */
+ int mem_used=0; /* Memory used during allocation */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing VL Datatypes with VL Atomic Datatype Component Functionality\n"));
+
+ /* Allocate and initialize VL data to write */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ wdata[i].p=malloc((i+1)*sizeof(hvl_t));
+ wdata[i].len=i+1;
+ for(t1=wdata[i].p,j=0; j<(i+1); j++, t1++) {
+ t1->p=malloc((j+1)*sizeof(uint32_t));
+ t1->len=j+1;
+ for(k=0; k<(j+1); k++)
+ ((uint32_t *)t1->p)[k]=i*100+j*10+k;
+ } /* end for */
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create a VL datatype to refer to */
+ tid1 = H5Tvlen_create (H5T_NATIVE_UINT);
+ CHECK(tid1, FAIL, "H5Tvlen_create");
+
+ /* Create the base VL type */
+ tid2 = H5Tvlen_create (tid1);
+ CHECK(tid2, FAIL, "H5Tvlen_create");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",tid2,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Write dataset to disk */
+ ret=H5Dwrite(dataset,tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Change to the custom memory allocation routines for reading VL data */
+ xfer_pid=H5Pcreate(H5P_DATASET_XFER);
+ CHECK(xfer_pid, FAIL, "H5Pcreate");
+
+ ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used);
+ CHECK(ret, FAIL, "H5Pset_vlen_mem_manager");
+
+ /* Read dataset from disk */
+ ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Make certain the correct amount of memory has been used */
+ /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */
+ /* 20 uint32_t elements allocated = 1 + 3 + 6 + 10 elements */
+ VERIFY(mem_used,10*sizeof(hvl_t)+20*sizeof(uint32_t),"H5Dread");
+
+ /* Compare data read in */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ if(wdata[i].len!=rdata[i].len) {
+ num_errs++;
+ printf("VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
+ continue;
+ } /* end if */
+ for(t1=wdata[i].p, t2=rdata[i].p, j=0; j<rdata[i].len; j++, t1++, t2++) {
+ if(t1->len!=t2->len) {
+ num_errs++;
+ printf("VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",(int)i,(int)j,(int)t1->len,(int)t2->len);
+ continue;
+ } /* end if */
+ for(k=0; k<t2->len; k++) {
+ if( ((uint32_t *)t1->p)[k] != ((uint32_t *)t2->p)[k] ) {
+ num_errs++;
+ printf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((uint32_t *)t1->p)[k], (int)k, (int)((uint32_t *)t2->p)[k]);
+ continue;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+
+ /* Reclaim all the (nested) VL data */
+ ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Make certain the VL memory has been freed */
+ VERIFY(mem_used,0,"H5Dvlen_reclaim");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+
/* Close disk dataspace */
ret = H5Sclose(sid1);
CHECK(ret, FAIL, "H5Sclose");
@@ -127,7 +594,7 @@ test_vltypes_atomic(void)
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* end test_vltypes_atomic() */
+} /* end test_vltypes_vlen_vlen_atomic() */
/****************************************************************
**
@@ -141,7 +608,10 @@ test_vltypes(void)
MESSAGE(5, ("Testing Variable-Length Datatypes\n"));
/* These next tests use the same file */
- test_vltypes_atomic(); /* Test basic VL datatype code */
+ test_vltypes_vlen_atomic(); /* Test VL atomic datatypes */
+ test_vltypes_vlen_compound(); /* Test VL compound datatypes */
+ test_vltypes_compound_vlen_atomic(); /* Test compound datatypes with VL atomic components */
+ test_vltypes_vlen_vlen_atomic(); /* Test VL datatype with VL atomic components */
} /* test_vltypes() */