summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-06-18 18:37:49 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-06-18 18:37:49 (GMT)
commited7658df795092d7bd50705cae4319adb5985289 (patch)
tree78f3a1eb1e2fc5da697be2655b2f824710e5a6e1 /test
parent879d58b86bacd743e75d78bed2c54f549aeb0a9d (diff)
downloadhdf5-ed7658df795092d7bd50705cae4319adb5985289.zip
hdf5-ed7658df795092d7bd50705cae4319adb5985289.tar.gz
hdf5-ed7658df795092d7bd50705cae4319adb5985289.tar.bz2
[svn-r17085] Description:
Bring r17002:17084 from trunk to revise_chunks branch. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test')
-rw-r--r--test/dtypes.c204
-rw-r--r--test/mf.c208
2 files changed, 400 insertions, 12 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 548cc59..c83cdfd 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -5805,6 +5805,209 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_named_indirect_reopen
+ *
+ * Purpose: Tests that open named datatypes can be reopened indirectly
+ * through H5Dget_type without causing problems.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Thursday, June 4, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_named_indirect_reopen(hid_t fapl)
+{
+ hid_t file=-1, type=-1, reopened_type=-1, strtype=-1, dset=-1, space=-1;
+ static hsize_t dims[1] = {3};
+ size_t dt_size;
+ int enum_value;
+ const char *tag = "opaque_tag";
+ char *tag_ret = NULL;
+ char filename[1024];
+
+ TESTING("indirectly reopening committed datatypes");
+
+ /* Create file, dataspace */
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if ((space = H5Screate_simple (1, dims, dims)) < 0) TEST_ERROR
+
+ /*
+ * Compound
+ */
+
+ /* Create compound type */
+ if((strtype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
+ if(H5Tset_size(strtype, H5T_VARIABLE) < 0) TEST_ERROR
+ if((type = H5Tcreate(H5T_COMPOUND, sizeof(char *))) < 0) TEST_ERROR
+ if(H5Tinsert(type, "vlstr", 0, strtype) < 0) TEST_ERROR
+ if(H5Tclose(strtype) < 0) TEST_ERROR
+
+ /* Get size of compound type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit compound type and verify the size doesn't change */
+ if(H5Tcommit2(file, "cmpd_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with compound type */
+ if((dset = H5Dcreate2(file, "cmpd_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Enum
+ */
+
+ /* Create enum type */
+ if((type = H5Tenum_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ enum_value = 0;
+ if(H5Tenum_insert(type, "val1", &enum_value) < 0) TEST_ERROR
+ enum_value = 1;
+ if(H5Tenum_insert(type, "val2", &enum_value) < 0) TEST_ERROR
+
+ /* Get size of enum type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit enum type and verify the size doesn't change */
+ if(H5Tcommit2(file, "enum_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with enum type */
+ if((dset = H5Dcreate2(file, "enum_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Vlen
+ */
+
+ /* Create vlen type */
+ if((type = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+
+ /* Get size of vlen type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit vlen type and verify the size doesn't change */
+ if(H5Tcommit2(file, "vlen_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with vlen type */
+ if((dset = H5Dcreate2(file, "vlen_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Opaque
+ */
+
+ /* Create opaque type */
+ if((type = H5Tcreate(H5T_OPAQUE, 13)) < 0) TEST_ERROR
+ if(H5Tset_tag(type, tag) < 0) TEST_ERROR
+
+ /* Get size of opaque type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit opaque type and verify the size and tag don't change */
+ if(H5Tcommit2(file, "opaque_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+ if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR
+ if(HDstrcmp(tag, tag_ret)) TEST_ERROR
+ HDfree(tag_ret);
+ tag_ret = NULL;
+
+ /* Create dataset with opaque type */
+ if((dset = H5Dcreate2(file, "opaque_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size and tag don't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+ if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR
+ if(HDstrcmp(tag, tag_ret)) TEST_ERROR
+ HDfree(tag_ret);
+ tag_ret = NULL;
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Array
+ */
+
+ /* Create array type */
+ if((type = H5Tarray_create2(H5T_NATIVE_INT, 1, dims)) < 0) TEST_ERROR
+
+ /* Get size of array type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit array type and verify the size doesn't change */
+ if(H5Tcommit2(file, "array_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with array type */
+ if((dset = H5Dcreate2(file, "array_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /* Close file and dataspace */
+ if(H5Sclose(space) < 0) TEST_ERROR
+ if(H5Fclose(file) < 0) TEST_ERROR
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(type);
+ H5Tclose(strtype);
+ H5Tclose(reopened_type);
+ H5Sclose(space);
+ H5Dclose(dset);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ if(tag_ret)
+ HDfree(tag_ret);
+ return 1;
+} /* end test_named_indirect_reopen() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_deprec
*
* Purpose: Tests deprecated API routines for datatypes.
@@ -5977,6 +6180,7 @@ main(void)
nerrors += test_encode();
nerrors += test_latest();
nerrors += test_int_float_except();
+ nerrors += test_named_indirect_reopen(fapl);
#ifndef H5_NO_DEPRECATED_SYMBOLS
nerrors += test_deprec(fapl);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/test/mf.c b/test/mf.c
index ff54751..5c05848 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -30,6 +30,7 @@
#include "H5FSpkg.h"
#define H5F_PACKAGE
+#define H5F_TESTING
#include "H5Fpkg.h"
#include "H5FLprivate.h"
@@ -718,6 +719,182 @@ error:
} /* test_mf_eoa_extend() */
/*
+ * To verify that temporary blocks are allocated correctly
+ *
+ * Set up:
+ * There is nothing in free-space manager
+ *
+ * Tests:
+ * Allocate a reasonable-sized temporary block
+ * Check that the temporary address is high enough
+ * Check that file I/O with the temporary address fails
+ * Check that freeing a temporary address fails
+ * Check that closing the file doesn't change the file's size
+ * Check that overlapping normal & temporary address space fails:
+ * - Reopen the file
+ * - Allocate enough temporary space to use ~1/3 of the file
+ * - Allocate enough 'normal' space to use ~1/3 of the file
+ * - Check that allocating another 1/2 of the file as temporary address
+ * space fails
+ * - Check that allocating another 1/2 of the file as normal address
+ * space fails
+ */
+static unsigned
+test_mf_tmp(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+
+ TESTING("'temporary' file space allocation");
+
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ haddr_t maxaddr; /* File's max. address */
+ haddr_t tmp_addr; /* Temporary space file address */
+ haddr_t norm_addr; /* Normal space file address */
+ haddr_t check_addr; /* File address for checking for errors */
+ unsigned char buf = 0; /* Buffer to read/write with */
+ herr_t status; /* Generic status value */
+
+ /* Set the filename to use for this test */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Retrieve the file's maxaddr */
+ if(H5F_get_maxaddr_test(file, &maxaddr) < 0)
+ FAIL_STACK_ERROR
+
+ /* Allocate some temporary address space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TEST_BLOCK_SIZE30)))
+ FAIL_STACK_ERROR
+
+ /* Check if temporary file address is valid */
+ if(!H5F_IS_TMP_ADDR(f, tmp_addr))
+ TEST_ERROR
+ if(tmp_addr < (haddr_t)(maxaddr - TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ /* Reading & writing with a temporary address value should fail */
+ H5E_BEGIN_TRY {
+ status = H5F_block_read(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), H5P_DATASET_XFER_DEFAULT, &buf);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+ H5E_BEGIN_TRY {
+ status = H5F_block_write(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), H5P_DATASET_XFER_DEFAULT, &buf);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+
+ /* Freeing a temporary address value should fail */
+ H5E_BEGIN_TRY {
+ status = H5MF_xfree(f, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, tmp_addr, (hsize_t)TEST_BLOCK_SIZE30);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(new_file_size != file_size)
+ TEST_ERROR
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 1/3 of the file as temporary address space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3))))
+ FAIL_STACK_ERROR
+ if(!H5F_IS_TMP_ADDR(f, tmp_addr))
+ TEST_ERROR
+
+ /* Allocate 1/3 of the file as normal address space */
+ if(HADDR_UNDEF == (norm_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(maxaddr / 3))))
+ FAIL_STACK_ERROR
+ if(H5F_IS_TMP_ADDR(f, norm_addr))
+ TEST_ERROR
+
+ /* Test that pushing temporary space allocation into normal space fails */
+ H5E_BEGIN_TRY {
+ check_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3));
+ } H5E_END_TRY;
+ if(H5F_addr_defined(check_addr))
+ TEST_ERROR
+
+ /* Test that pushing normal space allocation into temporary space fails */
+ H5E_BEGIN_TRY {
+ check_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(maxaddr / 3));
+ } H5E_END_TRY;
+ if(H5F_addr_defined(check_addr))
+ TEST_ERROR
+
+ /* Free the normal block (so the file doesn't blow up to a huge size) */
+ if(H5MF_xfree(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, norm_addr, (hsize_t)(maxaddr / 3)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support continuous address space");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_tmp() */
+
+/*
* To verify that the free-space manager is started up via H5MF_alloc_start()
*
* Set up:
@@ -3583,6 +3760,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
FAIL_STACK_ERROR
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
/* shrink the block */
if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE50) <= 0)
TEST_ERROR
@@ -3634,6 +3815,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
FAIL_STACK_ERROR
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
/* try to extend the block */
extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr1, (hsize_t)TEST_BLOCK_SIZE50, (hsize_t)TEST_BLOCK_SIZE30);
@@ -5625,11 +5810,6 @@ main(void)
env_h5_drvr = "nomatch";
fapl = h5_fileaccess();
- if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
-
- /* alignment is not set for the following tests */
- if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0)
- TEST_ERROR
/* meta/small data is set to 2048 for the following tests */
if(H5Pset_meta_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
@@ -5637,11 +5817,21 @@ main(void)
if(H5Pset_small_data_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
TEST_ERROR
+ /* Make a copy of the FAPL before adjusting the alignment */
+ if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* alignment is not set for the following tests */
+ if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0)
+ TEST_ERROR
+
/* interaction with file allocation */
nerrors += test_mf_eoa(env_h5_drvr, fapl);
nerrors += test_mf_eoa_shrink(env_h5_drvr, fapl);
nerrors += test_mf_eoa_extend(env_h5_drvr, fapl);
+ /* interaction with temporary file space allocation */
+ nerrors += test_mf_tmp(env_h5_drvr, fapl);
+
/* interaction with free-space manager */
nerrors += test_mf_fs_start(fapl);
nerrors += test_mf_fs_alloc_free(fapl);
@@ -5663,12 +5853,6 @@ main(void)
* tests for alignment
*/
- /* set meta/sdata block size = 2048 */
- if(H5Pset_meta_block_size(new_fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
- TEST_ERROR
- if(H5Pset_small_data_block_size(new_fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
- TEST_ERROR
-
for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) {
switch(curr_test) {
@@ -5695,7 +5879,7 @@ main(void)
nerrors += test_mf_align_alloc4(env_h5_drvr, fapl, new_fapl);
nerrors += test_mf_align_alloc5(env_h5_drvr, fapl, new_fapl);
nerrors += test_mf_align_alloc6(env_h5_drvr, fapl, new_fapl);
- }
+ } /* end if */
if(nerrors)
goto error;