summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am14
-rw-r--r--test/btree2.c182
-rw-r--r--test/dsets.c67
-rw-r--r--test/earray.c197
-rw-r--r--test/farray.c163
5 files changed, 518 insertions, 105 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index d9c53d4..8389cc4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -37,16 +37,14 @@ check_SCRIPTS = $(TEST_SCRIPT)
# executed, generally most specific tests to least specific tests.
# As an exception, long-running tests should occur earlier in the list.
# This gives them more time to run when tests are executing in parallel.
-# These tests (fheap, btree2) are under development and are not used by
-# the library yet. Move them to the end so that their failure do not block
-# other current library code tests.
-TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
+TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \
+ farray earray btree2 fheap \
pool accum hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf vds farray earray btree2 fheap file_image unregister
+ freespace mf vds file_image unregister
# List programs to be built when testing here. error_test and err_compat are
# built at the same time as the other tests, but executed by testerror.sh.
@@ -145,9 +143,9 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
multi_file-[rs].h5 core_file plugin.h5 \
new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \
dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \
- unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \
- objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \
- earray.h5 efc[0-5].h5 log_vfd_out.log \
+ unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \
+ objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 farray_tmp.h5 \
+ earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log \
new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \
split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \
file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \
diff --git a/test/btree2.c b/test/btree2.c
index 8f84135..7a2432c 100644
--- a/test/btree2.c
+++ b/test/btree2.c
@@ -31,6 +31,7 @@
const char *FILENAME[] = {
"btree2",
+ "btree2_tmp",
NULL
};
@@ -108,9 +109,8 @@ create_file(hid_t *file, H5F_t **f, hid_t fapl)
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(*f) < 0) {
+ if(H5AC_ignore_tags(*f) < 0)
STACK_ERROR
- }
/* Success */
return(0);
@@ -2810,9 +2810,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Create the v2 B-tree & get its address */
if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
@@ -2849,9 +2848,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Re-open v2 B-tree */
if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
@@ -4909,7 +4907,7 @@ test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam,
/* Check record values in root of B-tree */
ninfo.depth = 0;
- ninfo.nrec = INSERT_SPLIT_ROOT_NREC - u;
+ ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u);
record = 31; /* Middle record in root node */
if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
@@ -6379,9 +6377,8 @@ gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam,
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Create the v2 B-tree & get its address */
if(create_btree(f, dxpl, cparam, &bt2, bt2_addr) < 0)
@@ -6535,9 +6532,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Re-shuffle record #'s */
for(u = 0; u < INSERT_MANY; u++) {
@@ -6631,9 +6627,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Re-open v2 B-tree */
if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
@@ -6720,9 +6715,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Re-open v2 B-tree */
if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
@@ -6806,9 +6800,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Re-open v2 B-tree */
if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
@@ -7157,9 +7150,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam)
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Create the v2 B-tree & get its address */
if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
@@ -7202,9 +7194,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam)
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Create the v2 B-tree & get its address */
if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
@@ -7260,9 +7251,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam)
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Create the v2 B-tree & get its address */
if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
@@ -7318,9 +7308,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam)
STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(f) < 0) {
+ if(H5AC_ignore_tags(f) < 0)
STACK_ERROR
- }
/* Create the v2 B-tree & get its address */
if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
@@ -7605,6 +7594,146 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_open_twice_diff
+ *
+ * Purpose: Open a v2 B-tree twice, through different "top" file
+ * handles, with an intermediate file open that takes the "shared"
+ * file handle from the first B-tree's file pointer.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Friday, December 18, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam)
+{
+ char filename[1024]; /* Filename to use */
+ char filename_tmp[1024]; /* Temporary file name */
+ hid_t file = -1; /* File ID */
+ hid_t file2 = -1; /* File ID */
+ hid_t file0 = -1; /* File ID */
+ hid_t file00 = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5F_t *f2 = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
+
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+
+ /*
+ * Display testing message
+ */
+ TESTING("open B-tree twice, through different file handles");
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Ignore metadata tags in the file's cache */
+ if(H5AC_ignore_tags(f) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
+
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2_2 = H5B2_open(f, dxpl, bt2_addr, f)))
+ FAIL_STACK_ERROR
+
+ /* Close the second v2 B-tree wrapper */
+ if(H5B2_close(bt2_2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2_2 = NULL;
+
+ /* Re-open the file */
+ /* (So that there is something holding the file open when the extensible
+ * array is closed)
+ */
+ if((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the first v2 B-tree wrapper */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
+ /* Close the file */
+ /* (close before second file, to detect error on internal B-tree header's
+ * shared file information)
+ */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+ file = -1;
+
+ /* Open a different file */
+ /* (This re-allocates the 'top' file pointer and assigns it a different
+ * 'shared' file pointer, making the file pointer in the fixed array's
+ * header stale)
+ */
+ h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp));
+ if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file with the v2 B-tree array */
+ if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
+ /* Open the B-tree through the second file handle */
+ if(NULL == (bt2_2 = H5B2_open(f2, dxpl, bt2_addr, f2)))
+ FAIL_STACK_ERROR
+
+ /* Close the extra file handles */
+ if(H5Fclose(file0) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(file00) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the second v2 B-tree */
+ if(H5B2_close(bt2_2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2_2 = NULL;
+
+ /* Close file */
+ if(H5Fclose(file2) < 0)
+ FAIL_STACK_ERROR
+
+ /* All tests passed */
+ PASSED();
+
+ /* All tests passed */
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
+ if(bt2)
+ H5B2_close(bt2_2, dxpl);
+ H5Fclose(file);
+ H5Fclose(file2);
+ H5Fclose(file0);
+ H5Fclose(file00);
+ } H5E_END_TRY;
+ return(1);
+} /* test_open_twice_diff() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test the B-tree v2 code
@@ -7712,6 +7841,9 @@ main(void)
nerrors += test_modify(fapl, &cparam, &tparam);
} /* end for */
+ /* Test opening B-trees twice */
+ nerrors += test_open_twice_diff(fapl, &cparam);
+
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
diff --git a/test/dsets.c b/test/dsets.c
index c0e8702..a9cda93 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -388,14 +388,14 @@ test_create(hid_t file)
static herr_t
test_simple_io(const char *env_h5_drvr, hid_t fapl)
{
- char filename[FILENAME_BUF_SIZE];
- hid_t file = -1, dataset = -1, space = -1, xfer = -1;
- int i, j, n;
- hsize_t dims[2];
- void *tconv_buf = NULL;
- int f = -1;
- haddr_t offset;
- int rdata[DSET_DIM1][DSET_DIM2];
+ char filename[FILENAME_BUF_SIZE];
+ hid_t file = -1, dataset = -1, space = -1, xfer = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tconv_buf = NULL;
+ int f = -1;
+ haddr_t offset;
+ int rdata[DSET_DIM1][DSET_DIM2];
TESTING("simple I/O");
@@ -465,7 +465,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl)
f = HDopen(filename, O_RDONLY, 0);
HDlseek(f, (off_t)offset, SEEK_SET);
- HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2);
+ if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0)
+ goto error;
/* Check that the values read are the same as the values written */
for(i = 0; i < DSET_DIM1; i++) {
@@ -6702,7 +6703,7 @@ test_random_chunks(hid_t fapl)
if(H5Fclose(file) < 0) TEST_ERROR;
- /* Create file for second test */
+ /* Create second file */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
/* Create dataspace with unlimited maximum dimensions */
@@ -7474,7 +7475,7 @@ test_big_chunks_bypass_cache(hid_t fapl)
if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0)
for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++)
- if(rdata2[i] != i) {
+ if(rdata2[i] != i) {
printf(" Read different values than written in the chunk.\n");
printf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i);
TEST_ERROR
@@ -9145,38 +9146,38 @@ main(void)
nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0);
nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0);
nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_conv_buffer(file) < 0 ? 1 : 0);
+ nerrors += (test_conv_buffer(file) < 0 ? 1 : 0);
nerrors += (test_tconv(file) < 0 ? 1 : 0);
nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0);
nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_int(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_float(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_double(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_array(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_int(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_float(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_double(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_array(file) < 0 ? 1 : 0);
nerrors += (test_nbit_compound(file) < 0 ? 1 : 0);
nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0);
nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0);
nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0);
nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0);
nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0);
nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0);
- nerrors += (test_multiopen (file) < 0 ? 1 : 0);
- nerrors += (test_types(file) < 0 ? 1 : 0);
- nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_multiopen (file) < 0 ? 1 : 0);
+ nerrors += (test_types(file) < 0 ? 1 : 0);
+ nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0);
nerrors += (test_missing_filter(file) < 0 ? 1 : 0);
- nerrors += (test_can_apply(file) < 0 ? 1 : 0);
- nerrors += (test_can_apply2(file) < 0 ? 1 : 0);
- nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_can_apply(file) < 0 ? 1 : 0);
+ nerrors += (test_can_apply2(file) < 0 ? 1 : 0);
+ nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0);
nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0);
- nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0);
- nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0);
+ nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0);
nerrors += (test_filter_delete(file) < 0 ? 1 : 0);
- nerrors += (test_filters_endianess() < 0 ? 1 : 0);
- nerrors += (test_zero_dims(file) < 0 ? 1 : 0);
+ nerrors += (test_filters_endianess() < 0 ? 1 : 0);
+ nerrors += (test_zero_dims(file) < 0 ? 1 : 0);
nerrors += (test_missing_chunk(file) < 0 ? 1 : 0);
nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0);
#ifndef H5_NO_DEPRECATED_SYMBOLS
@@ -9186,9 +9187,9 @@ main(void)
nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0);
nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0);
nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0);
if(H5Fclose(file) < 0)
goto error;
diff --git a/test/earray.c b/test/earray.c
index 368ee42..95733e9 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -185,6 +185,7 @@ static herr_t earray_cache_test_free_icr(void *thing);
/* Local variables */
const char *FILENAME[] = {
"earray",
+ "earray_tmp",
NULL
};
@@ -332,10 +333,10 @@ finish_tparam(earray_test_param_t *tparam)
*-------------------------------------------------------------------------
*/
static int
-create_file(hid_t fapl, hid_t *file, H5F_t **f)
+create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f)
{
/* Create the file to work on */
- if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
@@ -343,9 +344,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f)
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(*f) < 0) {
+ if(H5AC_ignore_tags(*f) < 0)
FAIL_STACK_ERROR
- }
/* Success */
return(0);
@@ -454,17 +454,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
/* (actually will close & re-open the file as well) */
if(tparam->reopen_array) {
/* Close array, if given */
- if(ea) {
+ if(ea && *ea) {
if(H5EA_close(*ea, dxpl) < 0)
FAIL_STACK_ERROR
*ea = NULL;
} /* end if */
/* Close file */
- if(H5Fclose(*file) < 0)
- FAIL_STACK_ERROR
- *file = (-1);
- *f = NULL;
+ if(*file) {
+ if(H5Fclose(*file) < 0)
+ FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
+ } /* end if */
/* Re-open the file */
if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
@@ -475,15 +477,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(*f) < 0) {
+ if(H5AC_ignore_tags(*f) < 0)
FAIL_STACK_ERROR
- }
/* Re-open array, if given */
- if(ea) {
+ if(ea)
if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL)))
FAIL_STACK_ERROR
- } /* end if */
} /* end if */
/* Success */
@@ -893,7 +893,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
@@ -1008,7 +1008,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE
/* Set invalid max. # of elements per data block page bits */
if(test_cparam.idx_blk_elmts > 0) {
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
- test_cparam.max_dblk_page_nelmts_bits = H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1;
+ test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1);
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
} H5E_END_TRY;
@@ -1035,7 +1035,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE
TEST_ERROR
} /* end if */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
- test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1;
+ test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1);
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
} H5E_END_TRY;
@@ -1115,7 +1115,7 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
@@ -1188,7 +1188,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
@@ -1271,6 +1271,148 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_open_twice_diff
+ *
+ * Purpose: Open an extensible array twice, through different "top" file
+ * handles, with an intermediate file open that takes the "shared"
+ * file handle from the first extensible array's file pointer.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Friday, December 18, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */
+ hid_t file = -1; /* File ID */
+ hid_t file2 = -1; /* File ID */
+ hid_t file0 = -1; /* File ID */
+ hid_t file00 = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5F_t *f2 = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ H5EA_t *ea2 = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("open extensible array twice, through different file handles");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ /* Open the array again, through the first file handle */
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(ea2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second extensible array wrapper */
+ if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea2 = NULL;
+
+ /* Re-open the file */
+ /* (So that there is something holding the file open when the extensible
+ * array is closed)
+ */
+ if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the first extensible array wrapper */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea = NULL;
+
+ /* Close the first file */
+ /* (close before second file, to detect error on internal array header's
+ * shared file information)
+ */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+ file = -1;
+
+ /* Open a different file */
+ /* (This re-allocates the 'top' file pointer and assigns it a different
+ * 'shared' file pointer, making the file pointer in the extensible array's
+ * header stale)
+ */
+ h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp));
+ if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+
+ /* Re-open the file with the extensible array */
+ if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
+ /* Open the extensible array through the second file handle */
+ if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the extra file handles */
+ if(H5Fclose(file0) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(file00) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file2, fapl, f2, ea2, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ if(ea2)
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ H5Fclose(file2);
+ H5Fclose(file0);
+ H5Fclose(file00);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_open_twice_diff() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_delete_open
*
* Purpose: Delete opened extensible array (& open deleted array)
@@ -1294,7 +1436,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
h5_stat_size_t file_size; /* File size, after deleting array */
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
@@ -1483,7 +1625,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR
hsize_t idx; /* Index value of element */
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
@@ -1758,7 +1900,7 @@ eiter_fw_next(void *_eiter)
*
*-------------------------------------------------------------------------
*/
-static hssize_t
+static H5_ATTR_PURE hssize_t
eiter_fw_max(const void *_eiter)
{
const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter;
@@ -1976,7 +2118,7 @@ eiter_rv_next(void *_eiter)
*
*-------------------------------------------------------------------------
*/
-static hssize_t
+static H5_ATTR_PURE hssize_t
eiter_rv_max(const void *_eiter)
{
const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter;
@@ -2228,7 +2370,7 @@ eiter_rnd_next(void *_eiter)
*
*-------------------------------------------------------------------------
*/
-static hssize_t
+static H5_ATTR_PURE hssize_t
eiter_rnd_max(const void *_eiter)
{
const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter;
@@ -2449,7 +2591,7 @@ eiter_cyc_next(void *_eiter)
*
*-------------------------------------------------------------------------
*/
-static hssize_t
+static H5_ATTR_PURE hssize_t
eiter_cyc_max(const void *_eiter)
{
const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter;
@@ -2537,7 +2679,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
TESTING(test_str);
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/* Create array */
@@ -2711,7 +2853,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
TESTING(test_str);
/* Create file & retrieve pointer to internal file object */
- if(create_file(fapl, &file, &f) < 0)
+ if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/* Create array */
@@ -2871,7 +3013,7 @@ main(void)
/* Seed random #'s */
curr_time = HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create an empty file to retrieve size */
{
@@ -2922,6 +3064,7 @@ main(void)
nerrors += test_create(fapl, &cparam, &tparam);
nerrors += test_reopen(fapl, &cparam, &tparam);
nerrors += test_open_twice(fapl, &cparam, &tparam);
+ nerrors += test_open_twice_diff(fapl, &cparam, &tparam);
nerrors += test_delete_open(fapl, &cparam, &tparam);
nerrors += test_flush_depend(fapl, &cparam, &tparam);
diff --git a/test/farray.c b/test/farray.c
index e3e59da..50a9856 100644
--- a/test/farray.c
+++ b/test/farray.c
@@ -102,6 +102,7 @@ struct farray_test_param_t {
/* Local variables */
const char *FILENAME[] = {
"farray",
+ "farray_tmp",
NULL
};
@@ -159,9 +160,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f)
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(*f) < 0) {
+ if(H5AC_ignore_tags(*f) < 0)
FAIL_STACK_ERROR
- }
/* Success */
return(0);
@@ -274,17 +274,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
/* (actually will close & re-open the file as well) */
if(tparam->reopen_array) {
/* Close array, if given */
- if(fa) {
+ if(fa && *fa) {
if(H5FA_close(*fa, dxpl) < 0)
FAIL_STACK_ERROR
*fa = NULL;
} /* end if */
/* Close file */
- if(H5Fclose(*file) < 0)
- FAIL_STACK_ERROR
- *file = (-1);
- *f = NULL;
+ if(*file) {
+ if(H5Fclose(*file) < 0)
+ FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
+ } /* end if */
/* Re-open the file */
if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
@@ -295,15 +297,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
- if(H5AC_ignore_tags(*f) < 0) {
+ if(H5AC_ignore_tags(*f) < 0)
FAIL_STACK_ERROR
- }
/* Re-open array, if given */
- if(fa) {
+ if(fa)
if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL)))
FAIL_STACK_ERROR
- } /* end if */
} /* end if */
/* Success */
@@ -722,6 +722,144 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_open_twice_diff
+ *
+ * Purpose: Open a fixed array twice, through different "top" file
+ * handles, with an intermediate file open that takes the "shared"
+ * file handle from the first fixed array's file pointer.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Friday, December 18, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_open_twice_diff(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
+{
+ char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */
+ hid_t file = -1; /* File ID */
+ hid_t file2 = -1; /* File ID */
+ hid_t file0 = -1; /* File ID */
+ hid_t file00 = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5F_t *f2 = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Fixed array wrapper */
+ H5FA_t *fa2 = NULL; /* Fixed array wrapper */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+
+ /*
+ * Display testing message
+ */
+ TESTING("open fixed array twice, through different file handles");
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ /* Open the array again, through the first file handle */
+ if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(fa2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second fixed array wrapper */
+ if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ fa2 = NULL;
+
+ /* Re-open the file */
+ /* (So that there is something holding the file open when the extensible
+ * array is closed)
+ */
+ if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Close the first fixed array wrapper */
+ if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ fa = NULL;
+
+ /* Close the first file */
+ /* (close before second file, to detect error on internal array header's
+ * shared file information)
+ */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+ file = -1;
+
+ /* Open a different file */
+ /* (This re-allocates the 'top' file pointer and assigns it a different
+ * 'shared' file pointer, making the file pointer in the fixed array's
+ * header stale)
+ */
+ h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp));
+ if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+
+ /* Re-open the file with the fixed array */
+ if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
+ /* Open the fixed array through the second file handle */
+ if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the extra file handles */
+ if(H5Fclose(file0) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(file00) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file2, fapl, f2, fa2, fa_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ if(fa2)
+ H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ H5Fclose(file2);
+ H5Fclose(file0);
+ H5Fclose(file00);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_open_twice_diff() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_delete_open
*
* Purpose: Delete opened fixed array (& open deleted array)
@@ -1535,7 +1673,7 @@ main(void)
/* Seed random #'s */
curr_time = HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create an empty file to retrieve size */
{
@@ -1586,6 +1724,7 @@ main(void)
nerrors += test_create(fapl, &cparam, &tparam);
nerrors += test_reopen(fapl, &cparam, &tparam);
nerrors += test_open_twice(fapl, &cparam, &tparam);
+ nerrors += test_open_twice_diff(fapl, &cparam, &tparam);
nerrors += test_delete_open(fapl, &cparam, &tparam);
/* Iterate over the type of capacity tests */