summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-03-22 14:51:11 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-03-22 14:51:11 (GMT)
commit77a3e8e5c9401e2c7872d850d8d03a1947775f29 (patch)
tree3a72d2fac766688fb8fcf908366af6e6f0d5b73f /test
parentd17a7fa26e972714082c5061f29f6b9335e189f4 (diff)
parent0d2f2074cb64114fdd8aea5164e114d08d621f1b (diff)
downloadhdf5-77a3e8e5c9401e2c7872d850d8d03a1947775f29.zip
hdf5-77a3e8e5c9401e2c7872d850d8d03a1947775f29.tar.gz
hdf5-77a3e8e5c9401e2c7872d850d8d03a1947775f29.tar.bz2
[svn-r22120] merge from trunk
Diffstat (limited to 'test')
-rw-r--r--[-rwxr-xr-x]test/COPYING0
-rw-r--r--[-rwxr-xr-x]test/corrupt_stab_msg.h5bin2928 -> 2928 bytes
-rw-r--r--[-rwxr-xr-x]test/cross_read.c0
-rw-r--r--test/dtransform.c180
-rw-r--r--test/fheap.c13
-rw-r--r--[-rwxr-xr-x]test/gen_cross.c0
-rw-r--r--test/istore.c48
-rw-r--r--[-rwxr-xr-x]test/objcopy.c0
-rw-r--r--[-rwxr-xr-x]test/reserved.c0
-rw-r--r--test/tattr.c342
-rw-r--r--test/th5s.c966
11 files changed, 1068 insertions, 481 deletions
diff --git a/test/COPYING b/test/COPYING
index 6903daf..6903daf 100755..100644
--- a/test/COPYING
+++ b/test/COPYING
diff --git a/test/corrupt_stab_msg.h5 b/test/corrupt_stab_msg.h5
index 4fa287c..4fa287c 100755..100644
--- a/test/corrupt_stab_msg.h5
+++ b/test/corrupt_stab_msg.h5
Binary files differ
diff --git a/test/cross_read.c b/test/cross_read.c
index 308a0c1..308a0c1 100755..100644
--- a/test/cross_read.c
+++ b/test/cross_read.c
diff --git a/test/dtransform.c b/test/dtransform.c
index 5d5cefe..2bcbe8c 100644
--- a/test/dtransform.c
+++ b/test/dtransform.c
@@ -23,6 +23,7 @@ static int init_test(hid_t file_id);
static int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy);
static int test_trivial(const hid_t dxpl_id_simple);
static int test_poly(const hid_t dxpl_id_polynomial);
+static int test_specials(hid_t file);
static int test_set(void);
static int test_getset(const hid_t dxpl_id_simple);
@@ -50,14 +51,14 @@ const float windchillFfloat[ROWS][COLS] =
const int transformData[ROWS][COLS] =
{ {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 },
- {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 0 } ,
- {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 },
+ {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 1 } ,
+ {32, 25, 19, 13, 6, 2, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 },
{30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 },
{29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 },
{28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 },
- {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 },
+ {28, 21, 14, 7, 6, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 },
{27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 },
- {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 0, 7, 14, 21 },
+ {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 5, 7, 14, 21 },
{26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23},
{25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25},
{25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26}
@@ -97,6 +98,22 @@ const int transformData[ROWS][COLS] =
PASSED(); \
}
+#define COMPARE_INT(VAR1,VAR2) \
+{ \
+ size_t i,j; \
+ \
+ for(i=0; i<ROWS; i++) \
+ for(j=0; j<COLS; j++) \
+ { \
+ if( (VAR1)[i][j] != (VAR2)[i][j] ) \
+ { \
+ H5_FAILED(); \
+ fprintf(stderr, " ERROR: data failed to match computed data\n"); \
+ goto error; \
+ } \
+ } \
+}
+
#define TEST_TYPE_CONTIG(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \
{ \
TYPE array[ROWS][COLS]; \
@@ -332,6 +349,7 @@ int main(void)
if(test_trivial(dxpl_id_simple) < 0) TEST_ERROR;
if(test_poly(dxpl_id_polynomial) < 0) TEST_ERROR;
if(test_getset(dxpl_id_c_to_f) < 0) TEST_ERROR;
+ if(test_specials(file_id) < 0) TEST_ERROR;
/* Close the objects we opened/created */
if(H5Dclose(dset_id_int) < 0) TEST_ERROR;
@@ -502,6 +520,160 @@ error:
}
static int
+test_specials(hid_t file)
+{
+ hid_t dxpl_id, dset_id, dataspace;
+ hsize_t dim[2] = { ROWS, COLS };
+ int read_buf[ROWS][COLS];
+ int data_res[ROWS][COLS];
+ int row, col;
+ const char* special1 = "x*-100";
+ const char* special2 = "100-x";
+ const char* special3 = "1000/x";
+ const char* special4 = "-x";
+ const char* special5 = "+x";
+
+ TESTING("data transform of some special cases")
+
+ if((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
+ TEST_ERROR
+
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
+
+ /*-----------------------------
+ * Operation 1: x*-100
+ *----------------------------*/
+ if(H5Pset_data_transform(dxpl_id, special1) < 0) TEST_ERROR;
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++)
+ data_res[row][col] = transformData[row][col] * -100;
+
+ if((dset_id = H5Dcreate2(file, "/special1", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id, transformData) < 0)
+ TEST_ERROR
+ if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, read_buf) < 0)
+ TEST_ERROR
+
+ COMPARE_INT(read_buf, data_res)
+
+ if(H5Dclose(dset_id) < 0)
+ TEST_ERROR
+
+ /*-----------------------------
+ * Operation 2: 100-x
+ *----------------------------*/
+ if(H5Pset_data_transform(dxpl_id, special2) < 0) TEST_ERROR;
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++)
+ data_res[row][col] = 100 - transformData[row][col];
+
+ if((dset_id = H5Dcreate2(file, "/special2", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id, transformData) < 0)
+ TEST_ERROR
+ if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, read_buf) < 0)
+ TEST_ERROR
+
+ COMPARE_INT(read_buf, data_res)
+
+ if(H5Dclose(dset_id) < 0)
+ TEST_ERROR
+
+ /*-----------------------------
+ * Operation 3: 1000/x
+ *----------------------------*/
+ if(H5Pset_data_transform(dxpl_id, special3) < 0) TEST_ERROR;
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++)
+ data_res[row][col] = 1000 / transformData[row][col];
+
+ if((dset_id = H5Dcreate2(file, "/special3", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id, transformData) < 0)
+ TEST_ERROR
+ if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, read_buf) < 0)
+ TEST_ERROR
+
+ COMPARE_INT(read_buf, data_res)
+
+ if(H5Dclose(dset_id) < 0)
+ TEST_ERROR
+
+ /*-----------------------------
+ * Operation 4: -x
+ *----------------------------*/
+ if(H5Pset_data_transform(dxpl_id, special4) < 0) TEST_ERROR;
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++)
+ data_res[row][col] = -1 * transformData[row][col];
+
+ if((dset_id = H5Dcreate2(file, "/special4", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id, transformData) < 0)
+ TEST_ERROR
+ if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, read_buf) < 0)
+ TEST_ERROR
+
+ COMPARE_INT(read_buf, data_res)
+
+ if(H5Dclose(dset_id) < 0)
+ TEST_ERROR
+
+ /*-----------------------------
+ * Operation 5: +x
+ *----------------------------*/
+ if(H5Pset_data_transform(dxpl_id, special5) < 0) TEST_ERROR;
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++)
+ data_res[row][col] = transformData[row][col];
+
+ if((dset_id = H5Dcreate2(file, "/special5", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id, transformData) < 0)
+ TEST_ERROR
+ if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, read_buf) < 0)
+ TEST_ERROR
+
+ COMPARE_INT(read_buf, data_res)
+
+ if(H5Dclose(dset_id) < 0)
+ TEST_ERROR
+
+
+ if(H5Pclose(dxpl_id) < 0)
+ TEST_ERROR
+ if(H5Sclose(dataspace) < 0)
+ TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ return -1;
+}
+
+static int
test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
{
int windchillC;
diff --git a/test/fheap.c b/test/fheap.c
index f2960a3..b55c60b 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -415,13 +415,20 @@ add_obj(H5HF_t *fh, hid_t dxpl, size_t obj_off,
if(keep_ids) {
/* Check for needing to increase size of heap ID array */
if(keep_ids->num_ids + 1 > keep_ids->alloc_ids) {
+ unsigned char *tmp_ids;
+ size_t *tmp_lens;
+ size_t *tmp_offs;
+
keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2));
- if(NULL == (keep_ids->ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids)))
+ if(NULL == (tmp_ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids)))
TEST_ERROR
- if(NULL == (keep_ids->lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
+ keep_ids->ids = tmp_ids;
+ if(NULL == (tmp_lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
TEST_ERROR
- if(NULL == (keep_ids->offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
+ keep_ids->lens = tmp_lens;
+ if(NULL == (tmp_offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
TEST_ERROR
+ keep_ids->offs = tmp_offs;
} /* end if */
/* Append the object info onto the array */
diff --git a/test/gen_cross.c b/test/gen_cross.c
index d960499..d960499 100755..100644
--- a/test/gen_cross.c
+++ b/test/gen_cross.c
diff --git a/test/istore.c b/test/istore.c
index 3ae8da7..0c970bc 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -54,6 +54,42 @@ hsize_t zero[H5O_LAYOUT_NDIMS];
/*-------------------------------------------------------------------------
+ * Function: is_sparse
+ *
+ * Purpose: Determines if the file system of the current working
+ * directory supports holes.
+ *
+ * Return: Success: Non-zero if holes are supported; zero
+ * otherwise.
+ *
+ * Failure: zero
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, July 15, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+is_sparse(void)
+{
+ int fd;
+ h5_stat_t sb;
+
+ if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) return 0;
+ if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0;
+ if (5!=HDwrite(fd, "hello", (size_t)5)) return 0;
+ if (HDclose(fd) < 0) return 0;
+ if (HDstat("x.h5", &sb) < 0) return 0;
+ if (HDremove("x.h5") < 0) return 0;
+#ifdef H5_HAVE_STAT_ST_BLOCKS
+ return ((unsigned long)sb.st_blocks*512 < (unsigned long)sb.st_size);
+#else
+ return (0);
+#endif
+}
+
+
+/*-------------------------------------------------------------------------
* Function: print_array
*
* Purpose: Prints the values in an array
@@ -565,6 +601,7 @@ main(int argc, char *argv[])
unsigned size_of_test;
unsigned u; /* Local index variable */
char filename[1024];
+ int has_sparse_support = 0;
/* Parse arguments or assume these tests (`small', `medium' ) */
if (1 == argc) {
@@ -598,6 +635,12 @@ main(int argc, char *argv[])
/* Set the random # seed */
HDsrandom((unsigned)HDtime(NULL));
+ /* Check to see if the file system supports POSIX-style sparse files.
+ * Windows NTFS does not, so we want to avoid tests which create
+ * very large files.
+ */
+ has_sparse_support = is_sparse();
+
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
@@ -656,7 +699,10 @@ main(int argc, char *argv[])
status = test_sparse(file, "sparse", (size_t)2000, (size_t)4, (size_t)2, (size_t)3);
nerrors += status < 0 ? 1 : 0;
}
- if (size_of_test & TEST_LARGE) {
+ if (has_sparse_support && size_of_test & TEST_LARGE) {
+ /* This test is skipped if there is no POSIX-style sparse file support
+ * e.g.: Windows NTFS filesystems
+ */
status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50);
nerrors += status < 0 ? 1 : 0;
}
diff --git a/test/objcopy.c b/test/objcopy.c
index 5c20ee8..5c20ee8 100755..100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
diff --git a/test/reserved.c b/test/reserved.c
index bb6d328..bb6d328 100755..100644
--- a/test/reserved.c
+++ b/test/reserved.c
diff --git a/test/tattr.c b/test/tattr.c
index 60d4ddb..1285f0e 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -128,6 +128,8 @@ float attr_data5=(float)-5.123; /* Test data for 5th attribute */
#define ATTR7_NAME "attr 1 - 000000"
#define ATTR8_NAME "attr 2"
+#define LINK1_NAME "Link1"
+
#define NATTR_MANY_OLD 350
#define NATTR_MANY_NEW 35000
@@ -10216,7 +10218,339 @@ test_attr_bug6(hid_t fcpl, hid_t fapl)
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-}
+} /* test_attr_bug6() */
+
+/****************************************************************
+**
+** test_attr_bug7(): Test basic H5A (attribute) code.
+** (Really tests object header allocation code).
+** Tests creating and deleting attributes in such a way as
+** to change the size of the "chunk #0 size" field.
+** Includes testing "skipping" a possible size of the
+** field, i.e. going from 1 to 4 bytes or 4 to 1 byte.
+**
+****************************************************************/
+static void
+test_attr_bug7(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hsize_t dims_s = 140; /* Small attribute dimensions */
+ hsize_t dims_l = 65480; /* Large attribute dimensions */
+ H5A_info_t ainfo; /* Attribute info */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing adding and deleting large attributes\n"));
+
+
+ /* Create committed datatype to operate on. Use a committed datatype so that
+ * there is nothing after the object header and the first chunk can expand and
+ * contract as necessary. */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+ tid = H5Tcopy(H5T_STD_I32LE);
+ CHECK(tid, FAIL, "H5Tcopy");
+ ret = H5Tcommit2(fid, TYPE1_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit2");
+
+ /*
+ * Create small attribute
+ */
+ sid = H5Screate_simple(1, &dims_s, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+ aid = H5Acreate2(tid, ATTR1_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Close file */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check attribute */
+ tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT);
+ CHECK(tid, FAIL, "H5Topen2");
+ ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+
+ /*
+ * Create another small attribute. Should cause chunk size field to expand by
+ * 1 byte (1->2).
+ */
+ aid = H5Acreate2(tid, ATTR2_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Close file */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check attributes */
+ tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT);
+ CHECK(tid, FAIL, "H5Topen2");
+ ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+
+ /*
+ * Create large attribute. Should cause chunk size field to expand by 2 bytes
+ * (2->4).
+ */
+ ret = H5Sset_extent_simple(sid, 1, &dims_l, NULL);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+ aid = H5Acreate2(tid, ATTR3_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Close file */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check attributes */
+ tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT);
+ CHECK(tid, FAIL, "H5Topen2");
+ ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ ret = H5Aget_info_by_name(tid, ".", ATTR3_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_l)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_l);
+
+ /*
+ * Delete last two attributes - should merge into a null message that is too
+ * large, causing the chunk size field to shrink by 3 bytes (4->1).
+ */
+ ret = H5Sset_extent_simple(sid, 1, &dims_l, NULL);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+ ret = H5Adelete(tid, ATTR2_NAME);
+ CHECK(ret, FAIL, "H5Adelete");
+ ret = H5Adelete(tid, ATTR3_NAME);
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check attribute */
+ tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT);
+ CHECK(tid, FAIL, "H5Topen2");
+ ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+
+ /*
+ * Create large attribute. Should cause chunk size field to expand by 3 bytes
+ * (1->4).
+ */
+ aid = H5Acreate2(tid, ATTR2_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Close file */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check attributes */
+ tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT);
+ CHECK(tid, FAIL, "H5Topen2");
+ ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims_l)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_l);
+
+ /* Close IDs */
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_attr_bug7() */
+
+/****************************************************************
+**
+** test_attr_bug8(): Test basic H5A (attribute) code.
+** (Really tests object header code).
+** Tests adding a link and attribute to a group in such a
+** way as to cause the "chunk #0 size" field to expand
+** when some object header messages are not loaded into
+** cache. Before the bug was fixed, this would prevent
+** these messages from being shifted to the correct
+** position as the expansion algorithm marked them dirty,
+** invalidating the raw form, when there was no native
+** form to encode.
+**
+****************************************************************/
+static void
+test_attr_bug8(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t gid; /* Group ID */
+ hid_t oid; /* Object ID */
+ hsize_t dims = 256; /* Attribute dimensions */
+ H5O_info_t oinfo; /* Object info */
+ H5A_info_t ainfo; /* Attribute info */
+ haddr_t root_addr; /* Root group address */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing attribute expanding object header with undecoded messages\n"));
+
+
+ /* Create committed datatype to operate on. Use a committed datatype so that
+ * there is nothing after the object header and the first chunk can expand and
+ * contract as necessary. */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+ gid = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Get root group address */
+ ret = H5Oget_info(fid, &oinfo);
+ CHECK(ret, FAIL, "H5Oget_info");
+ root_addr = oinfo.addr;
+
+ /*
+ * Create link to root group
+ */
+ ret = H5Lcreate_hard(fid, "/", gid, LINK1_NAME, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Lcreate_hard");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check link */
+ gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+ oid = H5Oopen(gid, LINK1_NAME, H5P_DEFAULT);
+ CHECK(oid, FAIL, "H5Oopen");
+ ret = H5Oget_info(oid, &oinfo);
+ CHECK(ret, FAIL, "H5Oget_info");
+ if(oinfo.addr != root_addr)
+ TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n", (long long unsigned)oinfo.addr, (long long unsigned)root_addr);
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Oclose(oid);
+ CHECK(ret, FAIL, "H5Oclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /*
+ * Create attribute. Should cause chunk size field to expand by 1 byte
+ * (1->2).
+ */
+ gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+ sid = H5Screate_simple(1, &dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+ aid = H5Acreate2(gid, ATTR1_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Close file */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Check link and attribute */
+ gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+ oid = H5Oopen(gid, LINK1_NAME, H5P_DEFAULT);
+ CHECK(oid, FAIL, "H5Oopen");
+ ret = H5Oget_info(oid, &oinfo);
+ CHECK(ret, FAIL, "H5Oget_info");
+ if(oinfo.addr != root_addr)
+ TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n", (long long unsigned)oinfo.addr, (long long unsigned)root_addr);
+ ret = H5Aget_info_by_name(gid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
+ if(ainfo.data_size != dims)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims);
+
+ /* Close IDs */
+ ret = H5Oclose(oid);
+ CHECK(ret, FAIL, "H5Oclose");
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_attr_bug8() */
/****************************************************************
**
@@ -10364,6 +10698,8 @@ test_attr(void)
test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */
test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */
+ test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */
+ test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
} /* end for */
} /* end if */
else {
@@ -10388,6 +10724,10 @@ test_attr(void)
test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */
test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */
+ /* Skip test_attr_bug7 because it is specific to the new object
+ * header format and in fact fails if used with the old format, due
+ * to the attributes being larger than 64K */
+ test_attr_bug8(fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
} /* end else */
} /* end for */
diff --git a/test/th5s.c b/test/th5s.c
index c17d96e..87aa0f1 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -544,70 +544,13 @@ test_h5s_zero_dim(void)
hssize_t nelem; /* Number of elements */
H5S_sel_type sel_type; /* Type of selection currently */
H5S_class_t stype; /* dataspace type */
+ H5D_alloc_time_t alloc_time; /* Space allocation time */
herr_t ret; /* Generic return value */
unsigned int i, j, k;
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataspace with zero dimension size\n"));
- /* Make sure we can create the space with the dimension size 0 (starting from v1.8.7).
- * The dimension doesn't need to be unlimited. */
- sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
- CHECK(sid1, FAIL, "H5Screate_simple");
-
- ret = H5Sclose(sid1);
- CHECK(ret, FAIL, "H5Sclose");
-
- sid1 = H5Screate(H5S_SIMPLE);
- CHECK(sid1, FAIL, "H5Screate");
-
- /* SID1 has the 1st dimension size as zero. The maximal dimension will be
- * the same as the dimension because of the NULL passed in. */
- ret = H5Sset_extent_simple(sid1,SPACE1_RANK,dims1,NULL);
- CHECK(ret, FAIL, "H5Sset_extent_simple");
-
- /* Check that the dataspace actually has 0 elements */
- nelem = H5Sget_simple_extent_npoints(sid1);
- VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
-
- /* Check that the dataspace was created with an "all" selection */
- sel_type = H5Sget_select_type(sid1);
- VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type");
-
- /* Check that the dataspace has 0 elements selected */
- nelem = H5Sget_select_npoints(sid1);
- VERIFY(nelem, 0, "H5Sget_select_npoints");
-
- /* Change to "none" selection */
- ret = H5Sselect_none(sid1);
- CHECK(ret, FAIL, "H5Sselect_none");
-
- /* Check that the dataspace has 0 elements selected */
- nelem = H5Sget_select_npoints(sid1);
- VERIFY(nelem, 0, "H5Sget_select_npoints");
-
- /* Try to select all dataspace */
- ret = H5Sselect_all(sid1);
- CHECK(ret, FAIL, "H5Sselect_all");
-
- /* Check that the dataspace has 0 elements selected */
- nelem = H5Sget_select_npoints(sid1);
- VERIFY(nelem, 0, "H5Sget_select_npoints");
-
- /* Create the dataspace for chunked dataset with the first dimension size as zero.
- * The maximal dimensions are bigger than the dimensions for later expansion. */
- sid_chunk = H5Screate_simple(SPACE1_RANK, dims1, max_dims);
- CHECK(sid_chunk, FAIL, "H5Screate_simple");
-
- /*============================================
- * Make sure we can use 0-dimension to create
- * contiguous, chunked, compact, and external
- * datasets, and also attribute.
- *============================================
- */
- fid1 = H5Fcreate(ZEROFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(fid1, FAIL, "H5Fcreate");
-
/* Initialize the data */
for(i=0; i<SPACE1_DIM2; i++)
for(j=0; j<SPACE1_DIM3; j++) {
@@ -622,509 +565,588 @@ test_h5s_zero_dim(void)
for(k=0; k<SPACE1_DIM3; k++)
wdata_real[i][j][k] = i + j + k;
-
- /*===================== Contiguous dataset =======================*/
- dset1 = H5Dcreate2(fid1, BASICDATASET, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset1, FAIL, "H5Dcreate2");
-
- /* Write "nothing" to the dataset */
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata);
- CHECK(ret, FAIL, "H5Dwrite");
-
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
-
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
+ /* Test with different space allocation times */
+ for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) {
+
+ /* Make sure we can create the space with the dimension size 0 (starting from v1.8.7).
+ * The dimension doesn't need to be unlimited. */
+ dims1[0] = 0;
+ dims1[1] = SPACE1_DIM2;
+ dims1[2] = SPACE1_DIM3;
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ sid1 = H5Screate(H5S_SIMPLE);
+ CHECK(sid1, FAIL, "H5Screate");
+
+ /* SID1 has the 1st dimension size as zero. The maximal dimension will be
+ * the same as the dimension because of the NULL passed in. */
+ ret = H5Sset_extent_simple(sid1,SPACE1_RANK,dims1,NULL);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check that the dataspace actually has 0 elements */
+ nelem = H5Sget_simple_extent_npoints(sid1);
+ VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
+
+ /* Check that the dataspace was created with an "all" selection */
+ sel_type = H5Sget_select_type(sid1);
+ VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type");
+
+ /* Check that the dataspace has 0 elements selected */
+ nelem = H5Sget_select_npoints(sid1);
+ VERIFY(nelem, 0, "H5Sget_select_npoints");
+
+ /* Change to "none" selection */
+ ret = H5Sselect_none(sid1);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+ /* Check that the dataspace has 0 elements selected */
+ nelem = H5Sget_select_npoints(sid1);
+ VERIFY(nelem, 0, "H5Sget_select_npoints");
+
+ /* Try to select all dataspace */
+ ret = H5Sselect_all(sid1);
+ CHECK(ret, FAIL, "H5Sselect_all");
+
+ /* Check that the dataspace has 0 elements selected */
+ nelem = H5Sget_select_npoints(sid1);
+ VERIFY(nelem, 0, "H5Sget_select_npoints");
+
+ /* Create the dataspace for chunked dataset with the first dimension size as zero.
+ * The maximal dimensions are bigger than the dimensions for later expansion. */
+ sid_chunk = H5Screate_simple(SPACE1_RANK, dims1, max_dims);
+ CHECK(sid_chunk, FAIL, "H5Screate_simple");
+
+ /*============================================
+ * Make sure we can use 0-dimension to create
+ * contiguous, chunked, compact, and external
+ * datasets, and also attribute.
+ *============================================
+ */
+ fid1 = H5Fcreate(ZEROFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /*===================== Contiguous dataset =======================*/
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(plist_id, FAIL, "H5Pcreate");
+
+ ret = H5Pset_alloc_time(plist_id, alloc_time);
+ CHECK(ret, FAIL, "H5Pset_alloc_time");
+
+ dset1 = H5Dcreate2(fid1, BASICDATASET, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT);
+ CHECK(dset1, FAIL, "H5Dcreate2");
+
+ ret = H5Pclose(plist_id);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Write "nothing" to the dataset */
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
+
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
+ }
}
}
- }
- /* Write "nothing" to the dataset (with type conversion :-) */
- ret = H5Dwrite(dset1, H5T_NATIVE_SHORT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_short);
- CHECK(ret, FAIL, "H5Dwrite");
+ /* Write "nothing" to the dataset (with type conversion :-) */
+ ret = H5Dwrite(dset1, H5T_NATIVE_SHORT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_short);
+ CHECK(ret, FAIL, "H5Dwrite");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata_short);
- CHECK(ret, FAIL, "H5Dread");
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata_short);
+ CHECK(ret, FAIL, "H5Dread");
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata_short[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata_short[i][j]);
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata_short[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata_short[i][j]);
+ }
}
}
- }
-
- /* Select a hyperslab beyond its current dimension sizes, then try to write
- * the data. It should fail. */
- ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL);
- CHECK(ret, FAIL, "H5Sselect_hyperslab");
-
- H5E_BEGIN_TRY {
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, wdata);
- } H5E_END_TRY;
- VERIFY(ret, FAIL, "H5Dwrite");
-
- /* Change to "none" selection */
- ret = H5Sselect_none(sid1);
- CHECK(ret, FAIL, "H5Sselect_none");
-
- /* Select a point beyond the dimension size, then try to write the data.
- * It should fail. */
- coord[0][0]=2; coord[0][1]=5; coord[0][2]=3;
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord);
- CHECK(ret, FAIL, "H5Sselect_elements");
- H5E_BEGIN_TRY {
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &val);
- } H5E_END_TRY;
- VERIFY(ret, FAIL, "H5Dwrite");
+ /* Select a hyperslab beyond its current dimension sizes, then try to write
+ * the data. It should fail. */
+ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
- /* Restore the selection to all */
- ret = H5Sselect_all(sid1);
- CHECK(ret, FAIL, "H5Sselect_all");
+ H5E_BEGIN_TRY {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, wdata);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Dwrite");
- ret = H5Dclose(dset1);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Change to "none" selection */
+ ret = H5Sselect_none(sid1);
+ CHECK(ret, FAIL, "H5Sselect_none");
- /*=================== Chunked dataset ====================*/
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(plist_id, FAIL, "H5Pcreate");
+ /* Select a point beyond the dimension size, then try to write the data.
+ * It should fail. */
+ coord[0][0]=2; coord[0][1]=5; coord[0][2]=3;
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
- ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims);
- CHECK(ret, FAIL, "H5Pset_chunk");
+ H5E_BEGIN_TRY {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &val);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Dwrite");
- dset1 = H5Dcreate2(fid1, BASICDATASET1, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT);
- CHECK(dset1, FAIL, "H5Dcreate2");
+ /* Restore the selection to all */
+ ret = H5Sselect_all(sid1);
+ CHECK(ret, FAIL, "H5Sselect_all");
- /* Write "nothing" to the dataset */
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- CHECK(ret, FAIL, "H5Dwrite");
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ /*=================== Chunked dataset ====================*/
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(plist_id, FAIL, "H5Pcreate");
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
+ ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++)
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
- }
- }
+ // ret = H5Pset_alloc_time(plist_id, alloc_time);
+ // CHECK(ret, FAIL, "H5Pset_alloc_time");
- /* Now extend the dataset to SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3 and make sure
- * we can write data to it */
- ret = H5Dset_extent(dset1, extend_dims);
- CHECK(ret, FAIL, "H5Dset_extent");
+ dset1 = H5Dcreate2(fid1, BASICDATASET1, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT);
+ CHECK(dset1, FAIL, "H5Dcreate2");
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real);
- CHECK(ret, FAIL, "H5Dwrite");
+ /* Write "nothing" to the dataset */
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real);
- CHECK(ret, FAIL, "H5Dread");
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
- /* Check results */
- for(i=0; i<SPACE1_DIM1; i++) {
- for(j=0; j<SPACE1_DIM2; j++) {
- for(k=0; k<SPACE1_DIM3; k++) {
- if(rdata_real[i][j][k] != wdata_real[i][j][k]) {
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++)
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
H5_FAILED();
- printf("element [%d][%d][%d] is %d but should have been %d\n",
- i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]);
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
}
- }
}
- }
-
- /* Now shrink the first dimension size of the dataset to 0 and make sure no data is in it */
- extend_dims[0] = 0;
- ret = H5Dset_extent(dset1, extend_dims);
- CHECK(ret, FAIL, "H5Dset_extent");
-
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++)
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
+ /* Now extend the dataset to SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3 and make sure
+ * we can write data to it */
+ extend_dims[0] = SPACE1_DIM1;
+ ret = H5Dset_extent(dset1, extend_dims);
+ CHECK(ret, FAIL, "H5Dset_extent");
+
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
+
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check results */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<SPACE1_DIM2; j++) {
+ for(k=0; k<SPACE1_DIM3; k++) {
+ if(rdata_real[i][j][k] != wdata_real[i][j][k]) {
+ H5_FAILED();
+ printf("element [%d][%d][%d] is %d but should have been %d\n",
+ i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]);
+ }
+ }
}
- }
+ }
- /* Now extend the first dimension size of the dataset to SPACE1_DIM1*3 past the maximal size.
- * It is supposed to fail. */
- extend_dims[0] = SPACE1_DIM1*3;
- H5E_BEGIN_TRY {
+ /* Now shrink the first dimension size of the dataset to 0 and make sure no data is in it */
+ extend_dims[0] = 0;
ret = H5Dset_extent(dset1, extend_dims);
- } H5E_END_TRY;
- VERIFY(ret, FAIL, "H5Dset_extent");
-
- ret = H5Pclose(plist_id);
- CHECK(ret, FAIL, "H5Pclose");
-
- ret = H5Dclose(dset1);
- CHECK(ret, FAIL, "H5Dclose");
-
- /*=================== Compact dataset =====================*/
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(plist_id, FAIL, "H5Pcreate");
-
- ret = H5Pset_layout(plist_id, H5D_COMPACT);
- CHECK(ret, FAIL, "H5Pset_layout");
-
- ret = H5Pset_alloc_time(plist_id, H5D_ALLOC_TIME_EARLY);
- CHECK(ret, FAIL, "H5Pset_alloc_time");
+ CHECK(ret, FAIL, "H5Dset_extent");
- dset1 = H5Dcreate2(fid1, BASICDATASET2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT);
- CHECK(dset1, FAIL, "H5Dcreate2");
-
- /* Write "nothing" to the dataset */
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- CHECK(ret, FAIL, "H5Dwrite");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++)
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
+ }
+ }
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++)
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
- }
- }
+ /* Now extend the first dimension size of the dataset to SPACE1_DIM1*3 past the maximal size.
+ * It is supposed to fail. */
+ extend_dims[0] = SPACE1_DIM1*3;
+ H5E_BEGIN_TRY {
+ ret = H5Dset_extent(dset1, extend_dims);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Dset_extent");
- ret = H5Pclose(plist_id);
- CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(plist_id);
+ CHECK(ret, FAIL, "H5Pclose");
- ret = H5Dclose(dset1);
- CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
- /*=========== Contiguous dataset with external storage ============*/
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(plist_id, FAIL, "H5Pcreate");
+ /*=================== Compact dataset =====================*/
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(plist_id, FAIL, "H5Pcreate");
- ret = H5Pset_layout(plist_id, H5D_CONTIGUOUS);
- CHECK(ret, FAIL, "H5Pset_layout");
+ ret = H5Pset_layout(plist_id, H5D_COMPACT);
+ CHECK(ret, FAIL, "H5Pset_layout");
- /* Change the DCPL for contiguous layout with external storage. The size of the reserved
- * space in the external file is the size of the dataset (zero because one dimension size is zero).
- * There's no need to clean up the external file since the library doesn't create it
- * until the data is written to it. */
- ret = H5Pset_external(plist_id, EXTFILE_NAME, (off_t)0, (hsize_t)0);
- CHECK(ret, FAIL, "H5Pset_external");
+ /* Don't set the allocation time for compact storage datasets (must be early) */
- dset1 = H5Dcreate2(fid1, BASICDATASET3, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT);
- CHECK(dset1, FAIL, "H5Dcreate2");
+ dset1 = H5Dcreate2(fid1, BASICDATASET2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT);
+ CHECK(dset1, FAIL, "H5Dcreate2");
- /* Write "nothing" to the dataset */
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata);
- CHECK(ret, FAIL, "H5Dwrite");
+ /* Write "nothing" to the dataset */
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
- }
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++)
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
+ }
}
- }
-
- ret = H5Pclose(plist_id);
- CHECK(ret, FAIL, "H5Pclose");
- ret = H5Dclose(dset1);
- CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Pclose(plist_id);
+ CHECK(ret, FAIL, "H5Pclose");
- /*=============== Create an attribute for the file ================*/
- attr = H5Acreate2(fid1, NULLATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate2");
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
- /* Write "nothing" to the attribute */
- ret = H5Awrite(attr, H5T_NATIVE_INT, wdata);
- CHECK(ret, FAIL, "H5Awrite");
+ /*=========== Contiguous dataset with external storage ============*/
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(plist_id, FAIL, "H5Pcreate");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ /* Change the DCPL for contiguous layout with external storage. The size of the reserved
+ * space in the external file is the size of the dataset (zero because one dimension size is zero).
+ * There's no need to clean up the external file since the library doesn't create it
+ * until the data is written to it. */
+ ret = H5Pset_external(plist_id, EXTFILE_NAME, (off_t)0, (hsize_t)0);
+ CHECK(ret, FAIL, "H5Pset_external");
- /* Try reading from the attribute (make certain our buffer is unmodified) */
- ret = H5Aread(attr, H5T_NATIVE_INT, rdata);
- CHECK(ret, FAIL, "H5Aread");
+ ret = H5Pset_alloc_time(plist_id, alloc_time);
+ CHECK(ret, FAIL, "H5Pset_alloc_time");
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
- }
- }
- }
+ dset1 = H5Dcreate2(fid1, BASICDATASET3, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT);
+ CHECK(dset1, FAIL, "H5Dcreate2");
- /* Write "nothing" to the attribute (with type conversion :-) */
- ret = H5Awrite(attr, H5T_NATIVE_SHORT, wdata_short);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Write "nothing" to the dataset */
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- /* Try reading from the attribute (with type conversion :-) (make certain our buffer is unmodified) */
- ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short);
- CHECK(ret, FAIL, "H5Aread");
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata_short[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata_short[i][j]);
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
+ }
}
}
- }
-
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
-
- /*===============================================================
- * Extend the dimension to make it a normal dataspace (3x15x13).
- * Verify that data can be written to and read from the chunked
- * dataset now.
- *===============================================================
- */
- dims1[0]=SPACE1_DIM1;
- ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,max_dims);
- CHECK(ret, FAIL, "H5Sset_extent_simple");
-
- nelem = H5Sget_simple_extent_npoints(sid_chunk);
- CHECK(nelem, FAIL, "H5Sget_simple_extent_npoints");
- VERIFY(nelem, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3,
- "H5Sget_simple_extent_npoints");
-
- rank = H5Sget_simple_extent_ndims(sid_chunk);
- CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
- VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims");
-
- rank = H5Sget_simple_extent_dims(sid_chunk, tdims, NULL);
- CHECK(rank, FAIL, "H5Sget_simple_extent_dims");
- VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0,
- "H5Sget_simple_extent_dims");
- /* Set it to chunked dataset */
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(plist_id, FAIL, "H5Pcreate");
+ ret = H5Pclose(plist_id);
+ CHECK(ret, FAIL, "H5Pclose");
- ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims);
- CHECK(ret, FAIL, "H5Pset_chunk");
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
- dset1 = H5Dcreate2(fid1, BASICDATASET4, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT);
- CHECK(dset1, FAIL, "H5Dcreate2");
+ /*=============== Create an attribute for the file ================*/
+ attr = H5Acreate2(fid1, NULLATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
- ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real);
- CHECK(ret, FAIL, "H5Dwrite");
+ /* Write "nothing" to the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_INT, wdata);
+ CHECK(ret, FAIL, "H5Awrite");
- ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
- CHECK(ret, FAIL, "H5Fflush");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real);
- CHECK(ret, FAIL, "H5Dread");
+ /* Try reading from the attribute (make certain our buffer is unmodified) */
+ ret = H5Aread(attr, H5T_NATIVE_INT, rdata);
+ CHECK(ret, FAIL, "H5Aread");
- /* Check results */
- for(i=0; i<SPACE1_DIM1; i++) {
- for(j=0; j<SPACE1_DIM2; j++) {
- for(k=0; k<SPACE1_DIM3; k++) {
- if(rdata_real[i][j][k] != wdata_real[i][j][k]) {
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
H5_FAILED();
- printf("element [%d][%d][%d] is %d but should have been %d\n",
- i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]);
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
}
}
}
- }
-
- ret = H5Pclose(plist_id);
- CHECK(ret, FAIL, "H5Pclose");
-
- ret = H5Dclose(dset1);
- CHECK(ret, FAIL, "H5Dclose");
-
- /* Change the dimensions to make them zero size again (0x0x0). Verify that
- * no element is in the dataspace. */
- dims1[0]=dims1[1]=dims1[2]=0;
- ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,NULL);
- CHECK(ret, FAIL, "H5Sset_extent_simple");
-
- /* Check that the dataspace actually has 0 elements */
- nelem = H5Sget_simple_extent_npoints(sid_chunk);
- VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
-
- /* Check that the dataspace was created with an "all" selection */
- sel_type = H5Sget_select_type(sid_chunk);
- VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type");
-
- /* Check that the dataspace has 0 elements selected */
- nelem = H5Sget_select_npoints(sid_chunk);
- VERIFY(nelem, 0, "H5Sget_select_npoints");
-
- /* Change to "none" selection */
- ret = H5Sselect_none(sid_chunk);
- CHECK(ret, FAIL, "H5Sselect_none");
-
- /* Check that the dataspace has 0 elements selected */
- nelem = H5Sget_select_npoints(sid_chunk);
- VERIFY(nelem, 0, "H5Sget_select_npoints");
-
- ret = H5Sclose(sid_chunk);
- CHECK(ret, FAIL, "H5Sclose");
-
- ret = H5Sclose(sid1);
- CHECK(ret, FAIL, "H5Sclose");
-
- ret = H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*============================================
- * Reopen the file to check the data space
- *============================================
- */
- fid1 = H5Fopen(ZEROFILE, H5F_ACC_RDONLY, H5P_DEFAULT);
- CHECK(fid1, FAIL, "H5Fopen");
-
- /* Reopen the chunked dataset */
- dset1 = H5Dopen2(fid1, BASICDATASET1, H5P_DEFAULT);
- CHECK(dset1, FAIL, "H5Dopen2");
- /* Get the space of the dataset and querry it */
- sid1 = H5Dget_space(dset1);
- CHECK(sid1, FAIL, "H5Dget_space");
+ /* Write "nothing" to the attribute (with type conversion :-) */
+ ret = H5Awrite(attr, H5T_NATIVE_SHORT, wdata_short);
+ CHECK(ret, FAIL, "H5Awrite");
- /* Verify the class type of dataspace */
- stype = H5Sget_simple_extent_type(sid1);
- VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type");
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
- /* Verify there is zero element in the dataspace */
- nelem = H5Sget_simple_extent_npoints(sid1);
- VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
+ /* Try reading from the attribute (with type conversion :-) (make certain our buffer is unmodified) */
+ ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short);
+ CHECK(ret, FAIL, "H5Aread");
- /* Verify the dimension sizes are correct */
- rank = H5Sget_simple_extent_dims(sid1, tdims, NULL);
- CHECK(rank, FAIL, "H5Sget_simple_extent_dims");
- VERIFY(tdims[0], 0, "H5Sget_simple_extent_dims");
- VERIFY(tdims[1], SPACE1_DIM2, "H5Sget_simple_extent_dims");
- VERIFY(tdims[2], SPACE1_DIM3, "H5Sget_simple_extent_dims");
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata_short[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata_short[i][j]);
+ }
+ }
+ }
- /* Try reading from the dataset (make certain our buffer is unmodified) */
- ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /*===============================================================
+ * Extend the dimension to make it a normal dataspace (3x15x13).
+ * Verify that data can be written to and read from the chunked
+ * dataset now.
+ *===============================================================
+ */
+ dims1[0]=SPACE1_DIM1;
+ ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,max_dims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ nelem = H5Sget_simple_extent_npoints(sid_chunk);
+ CHECK(nelem, FAIL, "H5Sget_simple_extent_npoints");
+ VERIFY(nelem, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3,
+ "H5Sget_simple_extent_npoints");
+
+ rank = H5Sget_simple_extent_ndims(sid_chunk);
+ CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
+ VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims");
+
+ rank = H5Sget_simple_extent_dims(sid_chunk, tdims, NULL);
+ CHECK(rank, FAIL, "H5Sget_simple_extent_dims");
+ VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0,
+ "H5Sget_simple_extent_dims");
+
+ /* Set it to chunked dataset */
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(plist_id, FAIL, "H5Pcreate");
+
+ ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+
+ ret = H5Pset_alloc_time(plist_id, alloc_time);
+ CHECK(ret, FAIL, "H5Pset_alloc_time");
+
+ dset1 = H5Dcreate2(fid1, BASICDATASET4, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT);
+ CHECK(dset1, FAIL, "H5Dcreate2");
+
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
+
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check results */
+ for(i=0; i<SPACE1_DIM1; i++) {
+ for(j=0; j<SPACE1_DIM2; j++) {
+ for(k=0; k<SPACE1_DIM3; k++) {
+ if(rdata_real[i][j][k] != wdata_real[i][j][k]) {
+ H5_FAILED();
+ printf("element [%d][%d][%d] is %d but should have been %d\n",
+ i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]);
+ }
+ }
+ }
+ }
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata[i][j]);
+ ret = H5Pclose(plist_id);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Change the dimensions to make them zero size again (0x0x0). Verify that
+ * no element is in the dataspace. */
+ dims1[0]=dims1[1]=dims1[2]=0;
+ ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,NULL);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check that the dataspace actually has 0 elements */
+ nelem = H5Sget_simple_extent_npoints(sid_chunk);
+ VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
+
+ /* Check that the dataspace was created with an "all" selection */
+ sel_type = H5Sget_select_type(sid_chunk);
+ VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type");
+
+ /* Check that the dataspace has 0 elements selected */
+ nelem = H5Sget_select_npoints(sid_chunk);
+ VERIFY(nelem, 0, "H5Sget_select_npoints");
+
+ /* Change to "none" selection */
+ ret = H5Sselect_none(sid_chunk);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+ /* Check that the dataspace has 0 elements selected */
+ nelem = H5Sget_select_npoints(sid_chunk);
+ VERIFY(nelem, 0, "H5Sget_select_npoints");
+
+ ret = H5Sclose(sid_chunk);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /*============================================
+ * Reopen the file to check the data space
+ *============================================
+ */
+ fid1 = H5Fopen(ZEROFILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+
+ /* Reopen the chunked dataset */
+ dset1 = H5Dopen2(fid1, BASICDATASET1, H5P_DEFAULT);
+ CHECK(dset1, FAIL, "H5Dopen2");
+
+ /* Get the space of the dataset and querry it */
+ sid1 = H5Dget_space(dset1);
+ CHECK(sid1, FAIL, "H5Dget_space");
+
+ /* Verify the class type of dataspace */
+ stype = H5Sget_simple_extent_type(sid1);
+ VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type");
+
+ /* Verify there is zero element in the dataspace */
+ nelem = H5Sget_simple_extent_npoints(sid1);
+ VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
+
+ /* Verify the dimension sizes are correct */
+ rank = H5Sget_simple_extent_dims(sid1, tdims, NULL);
+ CHECK(rank, FAIL, "H5Sget_simple_extent_dims");
+ VERIFY(tdims[0], 0, "H5Sget_simple_extent_dims");
+ VERIFY(tdims[1], SPACE1_DIM2, "H5Sget_simple_extent_dims");
+ VERIFY(tdims[2], SPACE1_DIM3, "H5Sget_simple_extent_dims");
+
+ /* Try reading from the dataset (make certain our buffer is unmodified) */
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata[i][j]);
+ }
}
}
- }
- /* Close the dataset and its dataspace */
- ret = H5Dclose(dset1);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Close the dataset and its dataspace */
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
- ret = H5Sclose(sid1);
- CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
- /* Open the attribute for the file */
- attr = H5Aopen(fid1, NULLATTR, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Aopen");
+ /* Open the attribute for the file */
+ attr = H5Aopen(fid1, NULLATTR, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Aopen");
- /* Get the space of the dataset */
- attr_sid = H5Aget_space(attr);
- CHECK(attr_sid, FAIL, "H5Aget_space");
+ /* Get the space of the dataset */
+ attr_sid = H5Aget_space(attr);
+ CHECK(attr_sid, FAIL, "H5Aget_space");
- /* Verify the class type of dataspace */
- stype = H5Sget_simple_extent_type(attr_sid);
- VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type");
+ /* Verify the class type of dataspace */
+ stype = H5Sget_simple_extent_type(attr_sid);
+ VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type");
- /* Verify there is zero element in the dataspace */
- nelem = H5Sget_simple_extent_npoints(attr_sid);
- VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
+ /* Verify there is zero element in the dataspace */
+ nelem = H5Sget_simple_extent_npoints(attr_sid);
+ VERIFY(nelem, 0, "H5Sget_simple_extent_npoints");
- /* Try reading from the attribute (make certain our buffer is unmodified) */
- ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short);
- CHECK(ret, FAIL, "H5Aread");
+ /* Try reading from the attribute (make certain our buffer is unmodified) */
+ ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short);
+ CHECK(ret, FAIL, "H5Aread");
- /* Check results */
- for(i=0; i<SPACE1_DIM2; i++) {
- for(j=0; j<SPACE1_DIM3; j++) {
- if(rdata_short[i][j] != 7) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been 7\n",
- i, j, rdata_short[i][j]);
+ /* Check results */
+ for(i=0; i<SPACE1_DIM2; i++) {
+ for(j=0; j<SPACE1_DIM3; j++) {
+ if(rdata_short[i][j] != 7) {
+ H5_FAILED();
+ printf("element [%d][%d] is %d but should have been 7\n",
+ i, j, rdata_short[i][j]);
+ }
}
}
- }
- /* Close attribute */
- ret=H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Close attribute */
+ ret=H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Close the dataspace */
- ret = H5Sclose(attr_sid);
- CHECK(ret, FAIL, "H5Sclose");
+ /* Close the dataspace */
+ ret = H5Sclose(attr_sid);
+ CHECK(ret, FAIL, "H5Sclose");
- ret = H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
-} /* test_h5s_zero_dim() */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
+} /* test_h5s_zero_dim() */
/****************************************************************