summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-04-06 02:57:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-04-06 02:57:06 (GMT)
commitd5a62239587f7cc5de301fa5c6b0919807689818 (patch)
tree40a36d60dd8ac2d10a45886869cc53d3fdc9181e /test
parentebf3d99b955c705217227fb7f8ae4405e941399a (diff)
downloadhdf5-d5a62239587f7cc5de301fa5c6b0919807689818.zip
hdf5-d5a62239587f7cc5de301fa5c6b0919807689818.tar.gz
hdf5-d5a62239587f7cc5de301fa5c6b0919807689818.tar.bz2
[svn-r22254] Description:
Bring r22085:22251 from trunk to revise_chunks branch. Also tackle some testing issues in test/objcopy.c test and clean up some warnings. Tested on: FreeBSD/32 8.2 (loyalty) w/gcc4.6, w/C++ & FORTRAN, in debug mode FreeBSD/64 8.2 (freedom) w/gcc4.6, w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (koala) 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, w/threadsafe, in production mode Linux/PPC 2.6 (ostrich) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (ember) w/Intel compilers, w/paralle, C++ & FORTRAN, in production mode Mac OS X/32 10.7.3 (amazon) in debug mode Mac OS X/32 10.7.3 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.7.3 (amazon) w/parallel, in debug mode
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--[-rwxr-xr-x]test/COPYING0
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in69
-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/fheap.c145
-rw-r--r--test/file_image.c1335
-rw-r--r--test/file_image_core_test.h5bin0 -> 18528 bytes
-rw-r--r--[-rwxr-xr-x]test/gen_cross.c0
-rw-r--r--test/gen_file_image.c91
-rw-r--r--test/istore.c71
-rw-r--r--[-rwxr-xr-x]test/objcopy.c3738
-rw-r--r--[-rwxr-xr-x]test/reserved.c0
-rw-r--r--test/swmr_sparse_writer.c2
15 files changed, 5405 insertions, 53 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a2577b9..a6ff10b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -87,6 +87,7 @@ SET (HDF5_REFERENCE_TEST_FILES
family_v16_00003.h5
filespace_1_6.h5
filespace_1_8.h5
+ file_image_core_test.h5
fill_old.h5
filter_error.h5
group_old.h5
@@ -307,6 +308,7 @@ SET (H5_TESTS
tcheck_version
testmeta
#links_env
+ file_image
)
FOREACH (test ${H5_TESTS})
@@ -630,6 +632,7 @@ IF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS)
gen_filespace
gen_specmetaread
gen_sizes_lheap
+ gen_file_image
)
FOREACH (gen ${H5_GENERATORS})
diff --git a/test/COPYING b/test/COPYING
index 6903daf..6903daf 100755..100644
--- a/test/COPYING
+++ b/test/COPYING
diff --git a/test/Makefile.am b/test/Makefile.am
index df093b7..d5cd2b5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -43,7 +43,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe \
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf farray earray btree2 fheap
+ freespace mf farray earray btree2 fheap file_image
bin_PROGRAMS=swmr_generator swmr_reader swmr_writer swmr_remove_reader \
swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer
@@ -68,7 +68,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta links_
BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \
gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \
gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \
- gen_sizes_lheap
+ gen_sizes_lheap gen_file_image
if BUILD_ALL_CONDITIONAL
noinst_PROGRAMS=$(BUILD_ALL_PROGS)
diff --git a/test/Makefile.in b/test/Makefile.in
index d462da7..d7467f1 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -100,7 +100,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
ttsafe$(EXEEXT) getname$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) \
dangle$(EXEEXT) dtransform$(EXEEXT) reserved$(EXEEXT) \
cross_read$(EXEEXT) freespace$(EXEEXT) mf$(EXEEXT) \
- farray$(EXEEXT) earray$(EXEEXT) btree2$(EXEEXT) fheap$(EXEEXT)
+ farray$(EXEEXT) earray$(EXEEXT) btree2$(EXEEXT) fheap$(EXEEXT) \
+ file_image$(EXEEXT)
am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \
gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \
gen_idx$(EXEEXT) gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \
@@ -108,7 +109,8 @@ am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \
gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \
gen_nullspace$(EXEEXT) gen_udlinks$(EXEEXT) \
space_overflow$(EXEEXT) gen_filespace$(EXEEXT) \
- gen_specmetaread$(EXEEXT) gen_sizes_lheap$(EXEEXT)
+ gen_specmetaread$(EXEEXT) gen_sizes_lheap$(EXEEXT) \
+ gen_file_image$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
accum_SOURCES = accum.c
accum_OBJECTS = accum.$(OBJEXT)
@@ -206,6 +208,10 @@ fheap_SOURCES = fheap.c
fheap_OBJECTS = fheap.$(OBJEXT)
fheap_LDADD = $(LDADD)
fheap_DEPENDENCIES = libh5test.la $(LIBHDF5)
+file_image_SOURCES = file_image.c
+file_image_OBJECTS = file_image.$(OBJEXT)
+file_image_LDADD = $(LDADD)
+file_image_DEPENDENCIES = libh5test.la $(LIBHDF5)
fillval_SOURCES = fillval.c
fillval_OBJECTS = fillval.$(OBJEXT)
fillval_LDADD = $(LDADD)
@@ -246,6 +252,10 @@ gen_deflate_SOURCES = gen_deflate.c
gen_deflate_OBJECTS = gen_deflate.$(OBJEXT)
gen_deflate_LDADD = $(LDADD)
gen_deflate_DEPENDENCIES = libh5test.la $(LIBHDF5)
+gen_file_image_SOURCES = gen_file_image.c
+gen_file_image_OBJECTS = gen_file_image.$(OBJEXT)
+gen_file_image_LDADD = $(LDADD)
+gen_file_image_DEPENDENCIES = libh5test.la $(LIBHDF5)
gen_filespace_SOURCES = gen_filespace.c
gen_filespace_OBJECTS = gen_filespace.$(OBJEXT)
gen_filespace_LDADD = $(LDADD)
@@ -466,9 +476,28 @@ SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \
cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \
earray.c efc.c enum.c err_compat.c error_test.c extend.c \
- external.c farray.c fheap.c fillval.c filter_fail.c flush1.c \
- flush2.c flushrefresh.c freespace.c gen_bad_ohdr.c gen_bogus.c \
- gen_cross.c gen_deflate.c gen_filespace.c gen_filters.c \
+ external.c farray.c fheap.c file_image.c fillval.c \
+ filter_fail.c flush1.c flush2.c flushrefresh.c freespace.c \
+ gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \
+ gen_file_image.c gen_filespace.c gen_filters.c gen_idx.c \
+ gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
+ gen_new_super.c gen_noencoder.c gen_nullspace.c \
+ gen_sizes_lheap.c gen_specmetaread.c gen_udlinks.c getname.c \
+ gheap.c hyperslab.c istore.c lheap.c links.c links_env.c mf.c \
+ mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \
+ set_extent.c space_overflow.c stab.c swmr_addrem_writer.c \
+ swmr_generator.c swmr_reader.c swmr_remove_reader.c \
+ swmr_remove_writer.c swmr_sparse_reader.c swmr_sparse_writer.c \
+ swmr_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
+ $(ttsafe_SOURCES) unlink.c vfd.c
+DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \
+ bittests.c btree2.c cache.c cache_api.c cache_tagging.c \
+ cmpd_dset.c cross_read.c dangle.c dsets.c dt_arith.c \
+ dtransform.c dtypes.c earray.c efc.c enum.c err_compat.c \
+ error_test.c extend.c external.c farray.c fheap.c file_image.c \
+ fillval.c filter_fail.c flush1.c flush2.c flushrefresh.c \
+ freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \
+ gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \
gen_idx.c gen_new_array.c gen_new_fill.c gen_new_group.c \
gen_new_mtime.c gen_new_super.c gen_noencoder.c \
gen_nullspace.c gen_sizes_lheap.c gen_specmetaread.c \
@@ -480,24 +509,6 @@ SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
swmr_sparse_writer.c swmr_writer.c tcheck_version.c \
$(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
vfd.c
-DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \
- bittests.c btree2.c cache.c cache_api.c cache_tagging.c \
- cmpd_dset.c cross_read.c dangle.c dsets.c dt_arith.c \
- dtransform.c dtypes.c earray.c efc.c enum.c err_compat.c \
- error_test.c extend.c external.c farray.c fheap.c fillval.c \
- filter_fail.c flush1.c flush2.c flushrefresh.c freespace.c \
- gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \
- gen_filespace.c gen_filters.c gen_idx.c gen_new_array.c \
- gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \
- gen_noencoder.c gen_nullspace.c gen_sizes_lheap.c \
- gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
- istore.c lheap.c links.c links_env.c mf.c mount.c mtime.c \
- ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c \
- space_overflow.c stab.c swmr_addrem_writer.c swmr_generator.c \
- swmr_reader.c swmr_remove_reader.c swmr_remove_writer.c \
- swmr_sparse_reader.c swmr_sparse_writer.c swmr_writer.c \
- tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
- $(ttsafe_SOURCES) unlink.c vfd.c
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -839,7 +850,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe \
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf farray earray btree2 fheap
+ freespace mf farray earray btree2 fheap file_image
# These programs generate test files for the tests. They don't need to be
@@ -852,7 +863,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \
gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \
gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \
- gen_sizes_lheap
+ gen_sizes_lheap gen_file_image
# The libh5test library provides common support code for the tests.
@@ -1086,6 +1097,9 @@ farray$(EXEEXT): $(farray_OBJECTS) $(farray_DEPENDENCIES)
fheap$(EXEEXT): $(fheap_OBJECTS) $(fheap_DEPENDENCIES)
@rm -f fheap$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(fheap_OBJECTS) $(fheap_LDADD) $(LIBS)
+file_image$(EXEEXT): $(file_image_OBJECTS) $(file_image_DEPENDENCIES)
+ @rm -f file_image$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(file_image_OBJECTS) $(file_image_LDADD) $(LIBS)
fillval$(EXEEXT): $(fillval_OBJECTS) $(fillval_DEPENDENCIES)
@rm -f fillval$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(fillval_OBJECTS) $(fillval_LDADD) $(LIBS)
@@ -1116,6 +1130,9 @@ gen_cross$(EXEEXT): $(gen_cross_OBJECTS) $(gen_cross_DEPENDENCIES)
gen_deflate$(EXEEXT): $(gen_deflate_OBJECTS) $(gen_deflate_DEPENDENCIES)
@rm -f gen_deflate$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gen_deflate_OBJECTS) $(gen_deflate_LDADD) $(LIBS)
+gen_file_image$(EXEEXT): $(gen_file_image_OBJECTS) $(gen_file_image_DEPENDENCIES)
+ @rm -f gen_file_image$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(gen_file_image_OBJECTS) $(gen_file_image_LDADD) $(LIBS)
gen_filespace$(EXEEXT): $(gen_filespace_OBJECTS) $(gen_filespace_DEPENDENCIES)
@rm -f gen_filespace$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gen_filespace_OBJECTS) $(gen_filespace_LDADD) $(LIBS)
@@ -1283,6 +1300,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/external.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fheap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_image.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filter_fail.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@
@@ -1293,6 +1311,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_bogus.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_cross.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_deflate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_file_image.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_filespace.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_filters.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_idx.Po@am__quote@
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/fheap.c b/test/fheap.c
index 2cb8796..e4aa137 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 */
@@ -501,6 +508,7 @@ get_fill_size(const fheap_test_param_t *tparam)
case FHEAP_TEST_FILL_SINGLE:
return((size_t)0);
+ case FHEAP_TEST_FILL_N:
default:
HDassert(0 && "Unknown bulk fill type?!?");
} /* end switch */
@@ -6446,7 +6454,7 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
/* seed = (unsigned long)1155438845; */
HDfprintf(stderr, "Random # seed was: %lu\n", seed);
#endif /* QAK */
- HDsrandom(seed);
+ HDsrandom((unsigned)seed);
/* Set heap ID to random (non-null) value */
heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN;
@@ -7587,6 +7595,117 @@ error:
} H5E_END_TRY;
return(1);
} /* test_man_remove_three_larger() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_man_incr_insert_remove
+ *
+ * Purpose: Test incremental insert & removal of objects in heap
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Sunday, April 1, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ char filename[FHEAP_FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5HF_t *fh = NULL; /* Fractal heap wrapper */
+ haddr_t fh_addr; /* Address of fractal heap */
+ unsigned char heap_id[100][MAX_HEAP_ID_LEN]; /* Heap ID for object inserted */
+ struct a_type_t1 {
+ char a[10];
+ char b[29];
+ } obj1, obj2; /* Objects to insert/remove */
+ size_t id_len; /* Size of fractal heap IDs */
+ fheap_heap_state_t state; /* State of fractal heap */
+ int i, j;
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ 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
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ STACK_ERROR
+
+ /* Ignore metadata tags in the file's cache */
+ if(H5AC_ignore_tags(f) < 0)
+ STACK_ERROR
+
+ /* Create absolute heap */
+ if(NULL == (fh = H5HF_create(f, dxpl, cparam)))
+ FAIL_STACK_ERROR
+ if(H5HF_get_id_len(fh, &id_len) < 0)
+ FAIL_STACK_ERROR
+ if(id_len > HEAP_ID_LEN)
+ FAIL_STACK_ERROR
+ if(H5HF_get_heap_addr(fh, &fh_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(fh_addr))
+ FAIL_STACK_ERROR
+ HDmemset(&state, 0, sizeof(fheap_heap_state_t));
+ if(check_stats(fh, &state))
+ FAIL_STACK_ERROR
+
+ /*
+ * Test incremental insert and removal
+ */
+ TESTING("incremental object insertion and removal")
+
+ for(i = 0; i < 100; i++) {
+ sprintf(obj1.b, "%s%d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i);
+
+ for(j = 0; j < i; j++) {
+ sprintf(obj2.b, "%s%d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", j);
+
+ if(H5HF_remove(fh, dxpl, heap_id[j]) < 0)
+ FAIL_STACK_ERROR
+ if(H5HF_insert(fh, dxpl, (sizeof(obj2)), &obj2, heap_id[j]) < 0)
+ FAIL_STACK_ERROR
+ } /* end for */
+
+ /* Check for closing & re-opening the heap */
+ if(reopen_heap(f, dxpl, &fh, fh_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Insert object */
+ HDmemset(heap_id[i], 0, id_len);
+ if(H5HF_insert(fh, dxpl, (sizeof(obj1)), &obj1, heap_id[i]) < 0)
+ FAIL_STACK_ERROR
+ } /* end for */
+
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(fh)
+ H5HF_close(fh, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_man_incr_insert_remove() */
#endif /* QAK */
#ifndef QAK
@@ -15413,7 +15532,7 @@ test_random(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
/* seed = (unsigned long)1156158635; */
HDfprintf(stderr, "Random # seed was: %lu\n", seed);
#endif /* QAK */
- HDsrandom(seed);
+ HDsrandom((unsigned)seed);
/* Loop over adding objects to the heap, until the size limit is reached */
total_obj_added = 0;
@@ -15617,7 +15736,7 @@ test_random_pow2(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_te
/* seed = (unsigned long)1155181717; */
HDfprintf(stderr, "Random # seed was: %lu\n", seed);
#endif /* QAK */
- HDsrandom(seed);
+ HDsrandom((unsigned)seed);
/* Loop over adding objects to the heap, until the size limit is reached */
total_obj_added = 0;
@@ -15831,7 +15950,7 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
filter_class.set_local = NULL;
filter_class.filter = test_write_filter;
if(H5Zregister(&filter_class) < 0) TEST_ERROR
- if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_RESERVED + 43, 0, 0, NULL) < 0)
+ if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_RESERVED + 43, 0, (size_t)0, NULL) < 0)
FAIL_STACK_ERROR
test_write_filter_called = FALSE;
} /* end if */
@@ -16285,6 +16404,7 @@ curr_test = FHEAP_TEST_NORMAL;
break;
/* An unknown test? */
+ case FHEAP_TEST_NTESTS:
default:
goto error;
} /* end switch */
@@ -16333,6 +16453,7 @@ fill = FHEAP_TEST_FILL_LARGE;
break;
/* An unknown test? */
+ case FHEAP_TEST_FILL_N:
default:
goto error;
} /* end switch */
@@ -16341,8 +16462,12 @@ fill = FHEAP_TEST_FILL_LARGE;
* Test fractal heap managed object insertion
*/
+#ifndef QAK
/* "Weird" sized objects */
nerrors += test_man_insert_weird(fapl, &small_cparam, &tparam);
+#else /* QAK */
+HDfprintf(stderr, "Uncomment tests!\n");
+#endif /* QAK */
#ifdef ALL_INSERT_TESTS
/* "Standard" sized objects, building from simple to complex heaps */
@@ -16404,6 +16529,10 @@ HDfprintf(stderr, "Uncomment tests!\n");
nerrors += test_man_remove_three_larger(fapl, &small_cparam, &tparam);
tparam.del_dir = FHEAP_DEL_REVERSE;
nerrors += test_man_remove_three_larger(fapl, &small_cparam, &tparam);
+
+ /* Incremental insert & removal */
+ tparam.del_dir = FHEAP_DEL_FORWARD;
+ nerrors += test_man_incr_insert_remove(fapl, &small_cparam, &tparam);
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
@@ -16445,6 +16574,8 @@ tparam.drain_half = FHEAP_DEL_DRAIN_ALL;
nerrors += test_man_remove_2nd_indirect(fapl, &small_cparam, &tparam);
nerrors += test_man_remove_3rd_indirect(fapl, &small_cparam, &tparam);
} /* end else */
+#else /* QAK */
+HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
#ifndef QAK
diff --git a/test/file_image.c b/test/file_image.c
new file mode 100644
index 0000000..7c2c3ff
--- /dev/null
+++ b/test/file_image.c
@@ -0,0 +1,1335 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/***********************************************************
+*
+* Test program: file_image
+*
+* Test setting file images
+*
+*************************************************************/
+
+#include "h5test.h"
+#include "H5srcdir.h"
+#include "H5Fprivate.h" /* required to test property removals */
+#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0)
+
+/* Values for callback bit field */
+#define MALLOC 0x01
+#define MEMCPY 0x02
+#define REALLOC 0x04
+#define FREE 0x08
+#define UDATA_COPY 0x10
+#define UDATA_FREE 0x20
+
+#define RANK 2
+#define DIM0 1024
+#define DIM1 32
+#define DSET_NAME "test_dset"
+
+#define FAMILY_SIZE (2 * 1024)
+
+const char *FILENAME[] = {
+ "file_image_core_test",
+ NULL
+};
+
+/* need a second file name array, as the first file name array contains
+ * files we don't want to delete on cleanup.
+ */
+const char *FILENAME2[] = {
+ "sec2_get_file_image_test",
+ "stdio_get_file_image_test",
+ "core_get_file_image_test",
+ "family_get_file_image_test",
+ "multi_get_file_image_test",
+ "split_get_file_image_test",
+ "get_file_image_error_rejection_test",
+ NULL
+};
+
+typedef struct {
+ unsigned char used_callbacks; /* Bitfield for tracking callbacks */
+ H5FD_file_image_op_t malloc_src; /* Source of file image callbacks */
+ H5FD_file_image_op_t memcpy_src;
+ H5FD_file_image_op_t realloc_src;
+ H5FD_file_image_op_t free_src;
+} udata_t;
+
+
+/******************************************************************************
+ * Function: test_properties
+ *
+ * Purpose: Tests that the file image properties (buffer pointer and length)
+ * are set properly. Image callbacks are not set in this test.
+ *
+ * Returns: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static int
+test_properties(void)
+{
+ hid_t fapl_1;
+ hid_t fapl_2;
+ char *buffer;
+ int count = 10;
+ void *temp;
+ char *temp2;
+ int i;
+ size_t size;
+ size_t temp_size;
+
+ TESTING("File image property list functions");
+
+ /* Initialize file image buffer
+ *
+ * Note: this image will not contain a valid HDF5 file, as it complicates testing
+ * property list functions. In the file driver tests further down, this will
+ * not be the case.
+ */
+ size = (size_t)count * sizeof(char);
+ buffer = (char *)HDmalloc(size);
+ for(i = 0; i < count - 1; i++)
+ buffer[i] = (char)(65 + i);
+ buffer[count] = '\0';
+
+ /* Create fapl */
+ if((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR
+
+ /* Get file image stuff */
+ if(H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) FAIL_STACK_ERROR
+
+ /* Check default values */
+ VERIFY(temp == NULL, "Default pointer is wrong");
+ VERIFY(temp_size == 0, "Default size is wrong");
+
+ /* Set file image stuff */
+ if(H5Pset_file_image(fapl_1, (void *)buffer, size) < 0) FAIL_STACK_ERROR
+
+ /* Get the same */
+ if(H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) FAIL_STACK_ERROR
+
+ /* Check that sizes are the same, and that the buffers are identical but separate */
+ VERIFY(temp != NULL, "temp is null!");
+ VERIFY(temp_size == size, "Sizes of buffers don't match");
+ VERIFY(temp != buffer, "Retrieved buffer is the same as original");
+ VERIFY(0 == HDmemcmp(temp, buffer, size), "Buffers contain different data");
+
+ /* Copy the fapl */
+ if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR
+
+ /* Get values from the new fapl */
+ if(H5Pget_file_image(fapl_2, (void **)&temp2, &temp_size) < 0) FAIL_STACK_ERROR
+
+ /* Check that sizes are the same, and that the buffers are identical but separate */
+ VERIFY(temp_size == size,"Sizes of buffers don't match");
+ VERIFY(temp2 != NULL,"Recieved buffer not set");
+ VERIFY(temp2 != buffer, "Retrieved buffer is the same as original");
+ VERIFY(temp2 != temp, "Retrieved buffer is the same as previously retrieved buffer");
+ VERIFY(0 == HDmemcmp(temp2, buffer, size),"Buffers contain different data");
+
+ /* Close everything */
+ if(H5Pclose(fapl_1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR
+ HDfree(buffer);
+ HDfree(temp);
+ HDfree(temp2);
+
+ PASSED();
+ return 0;
+
+error:
+ return 1;
+} /* end test_properties() */
+
+/******************************************************************************
+ * Function: malloc_cb
+ *
+ * Purpose: This function allows calls to the malloc callback to be tracked.
+ *
+ * Returns: The result of a standard malloc
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static void *
+malloc_cb(size_t size, H5FD_file_image_op_t op, void *udata)
+{
+ udata_t *u = (udata_t *)udata;
+
+ u->used_callbacks |= MALLOC;
+ u->malloc_src = op;
+ return HDmalloc(size);
+}
+
+/******************************************************************************
+ * Function: memcpy_cb
+ *
+ * Purpose: This function allows calls to the memcpy callback to be tracked.
+ *
+ * Returns: The result of a standard memcpy
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static void *
+memcpy_cb(void *dest, const void *src, size_t size, H5FD_file_image_op_t op, void *udata)
+{
+ udata_t *u = (udata_t *)udata;
+
+ u->used_callbacks |= MEMCPY;
+ u->memcpy_src = op;
+ return HDmemcpy(dest, src, size);
+}
+
+/******************************************************************************
+ * Function: realloc_cb
+ *
+ * Purpose: This function allows calls to the realloc callback to be tracked.
+ *
+ * Returns: The result of a standard realloc
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static void *
+realloc_cb(void *ptr, size_t size, H5FD_file_image_op_t op, void *udata)
+{
+ udata_t *u = (udata_t *)udata;
+
+ u->used_callbacks |= REALLOC;
+ u->realloc_src = op;
+ return HDrealloc(ptr,size);
+}
+
+/******************************************************************************
+ * Function: free_cb
+ *
+ * Purpose: This function allows calls to the free callback to be tracked.
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static herr_t
+free_cb(void *ptr, H5FD_file_image_op_t op, void *udata)
+{
+ udata_t *u = (udata_t *)udata;
+
+ u->used_callbacks |= FREE;
+ u->free_src = op;
+ HDfree(ptr);
+ return(SUCCEED);
+}
+
+/******************************************************************************
+ * Function: udata_copy_cb
+ *
+ * Purpose: This function allows calls to the udata_copy callback to be tracked.
+ * No copying actualy takes place; it is easier to deal with only one
+ * instance of the udata.
+ *
+ * Returns: A pointer to the same udata that was passed in.
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static void *
+udata_copy_cb(void *udata)
+{
+ udata_t *u = (udata_t *)udata;
+
+ u->used_callbacks |= UDATA_COPY;
+ return udata;
+}
+
+/******************************************************************************
+ * Function: udata_free_cb
+ *
+ * Purpose: This function allows calls to the udata_free callback to be tracked.
+ *
+ * Note: this callback doesn't actually do anything. Since the
+ * udata_copy callback doesn't copy, only one instance of the udata
+ * is kept alive and such it must be freed explicitly at the end of the tests.
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static herr_t
+udata_free_cb(void *udata)
+{
+ udata_t *u = (udata_t *)udata;
+
+ u->used_callbacks |= UDATA_FREE;
+ return(SUCCEED);
+}
+
+/******************************************************************************
+ * Function: reset_udata
+ *
+ * Purpose: Resets the udata to default values. This facilitates storing only
+ * the results of a single operation in the udata.
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static void
+reset_udata(udata_t *u)
+{
+ u->used_callbacks = 0;
+ u->malloc_src = u->memcpy_src = u->realloc_src = u->free_src = H5FD_FILE_IMAGE_OP_NO_OP;
+}
+
+/******************************************************************************
+ * Function: test_callbacks
+ *
+ * Purpose: Tests that callbacks are called properly in property list functions.
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static int
+test_callbacks(void)
+{
+ H5FD_file_image_callbacks_t real_callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb,
+ &free_cb, &udata_copy_cb, &udata_free_cb, NULL};
+ H5FD_file_image_callbacks_t null_callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+ H5FD_file_image_callbacks_t callbacks;
+ hid_t fapl_1;
+ hid_t fapl_2;
+ udata_t *udata;
+ char *file_image;
+ char *temp_file_image;
+ int count = 10;
+ int i;
+ size_t size;
+ size_t temp_size;
+
+ TESTING("Callback use in property list operations");
+
+ /* Allocate and initialize udata */
+ udata = (udata_t *)HDmalloc(sizeof(udata_t));
+ reset_udata(udata);
+
+ /* copy the address of the user data into read_callbacks */
+ real_callbacks.udata = (void *)udata;
+
+ /* Allocate and initialize file image buffer */
+ size = (size_t)count * sizeof(char);
+ file_image = (char *)HDmalloc(size);
+ for(i = 0; i < count - 1; i++)
+ file_image[i] = (char)(65 + i);
+ file_image[count] = '\0';
+
+ /* Create fapl */
+ if((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR
+
+ /* Get file image stuff */
+ callbacks = real_callbacks;
+ if(H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR
+
+ /* Check default values */
+ VERIFY(callbacks.image_malloc == NULL, "Default malloc callback is wrong");
+ VERIFY(callbacks.image_memcpy == NULL, "Default memcpy callback is wrong");
+ VERIFY(callbacks.image_realloc == NULL, "Default realloc callback is wrong");
+ VERIFY(callbacks.image_free == NULL, "Default free callback is wrong");
+ VERIFY(callbacks.udata_copy == NULL, "Default udata copy callback is wrong");
+ VERIFY(callbacks.udata_free == NULL, "Default udata free callback is wrong");
+ VERIFY(callbacks.udata == NULL, "Default udata is wrong");
+
+
+ /* Set file image callbacks */
+ callbacks = real_callbacks;
+ if(H5Pset_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR
+
+ /* Get file image callbacks */
+ callbacks = null_callbacks;
+ if(H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR
+
+ /* Verify values */
+ VERIFY(callbacks.image_malloc == &malloc_cb, "malloc callback was not set or retrieved properly");
+ VERIFY(callbacks.image_memcpy == &memcpy_cb, "memcpy callback was not set or retrieved properly");
+ VERIFY(callbacks.image_realloc == &realloc_cb, "realloc callback was not set or retrieved properly");
+ VERIFY(callbacks.image_free == &free_cb, "free callback was not set or retrieved properly");
+ VERIFY(callbacks.udata_copy == &udata_copy_cb, "udata copy callback was not set or retrieved properly");
+ VERIFY(callbacks.udata_free == &udata_free_cb, "udata free callback was not set or retrieved properly");
+ VERIFY(callbacks.udata == udata, "udata was not set or retrieved properly");
+
+
+ /*
+ * Check callbacks in internal function without a previously set file image
+ */
+
+ /* Copy fapl */
+ reset_udata(udata);
+ if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the property's copy callback used the correct image callbacks */
+ VERIFY(udata->used_callbacks == (UDATA_COPY), "Copying a fapl with no image used incorrect callbacks");
+
+ /* Close fapl */
+ reset_udata(udata);
+ if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the udata free callback was used */
+ VERIFY(udata->used_callbacks == (UDATA_FREE), "Closing a fapl with no image used incorrect callbacks");
+
+ /* Copy again */
+ if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR
+
+ /* Remove property from fapl */
+ reset_udata(udata);
+ if(H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the property's delete callback was called using the correct image callbacks */
+ VERIFY(udata->used_callbacks == (UDATA_FREE), "Removing a property from a fapl with no image used incorrect callbacks");
+
+ /* Close it again */
+ if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR
+
+ /* Get file image */
+ reset_udata(udata);
+ if(H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct callbacks were used */
+ VERIFY(udata->used_callbacks == 0, "attempting to retrieve the image from a fapl without an image has an unexpected callback");
+
+ /* Set file image */
+ reset_udata(udata);
+ if(H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) FAIL_STACK_ERROR
+
+ VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), "Setting a file image (first time) used incorrect callbacks");
+
+ /*
+ * Check callbacks in internal functions with a previously set file image
+ */
+
+ /* Copy fapl */
+ reset_udata(udata);
+ if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the property's copy callback used the correct image callbacks */
+ VERIFY(udata->used_callbacks == (MALLOC | MEMCPY | UDATA_COPY), "Copying a fapl with an image used incorrect callbacks");
+ VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, "malloc callback has wrong source");
+ VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, "memcpy callback has wrong source");
+
+ /* Close fapl */
+ reset_udata(udata);
+ if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the udata free callback was used */
+ VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), "Closing a fapl with an image used incorrect callbacks");
+ VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, "free callback has wrong source");
+
+ /* Copy again */
+ if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR
+
+ /* Remove property from fapl */
+ reset_udata(udata);
+ if(H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the property's delete callback was called using the correct image callbacks */
+ VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), "Removing a property from a fapl with an image used incorrect callbacks");
+ VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, "free callback has wrong source");
+
+ /* Close it again */
+ if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR
+
+ /* Get file image */
+ reset_udata(udata);
+ if(H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct callbacks were used */
+ VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), "attempting to retrieve the image from a fapl with an image has an unexpected callback");
+ VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, "malloc callback has wrong source");
+ VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, "memcpy callback has wrong source");
+
+ /* Set file image */
+ reset_udata(udata);
+ if(H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) FAIL_STACK_ERROR
+
+ VERIFY(udata->used_callbacks == (FREE | MALLOC | MEMCPY), "Setting a file image (second time) used incorrect callbacks");
+ VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "malloc callback has wrong source");
+ VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "memcpy callback has wrong source");
+ VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "freec callback has wrong source");
+
+ /* Close stuff */
+ if(H5Pclose(fapl_1) < 0) FAIL_STACK_ERROR
+ HDfree(file_image);
+ HDfree(temp_file_image);
+ HDfree(udata);
+
+ PASSED();
+ return 0;
+
+error:
+ return 1;
+} /* test_callbacks() */
+
+/******************************************************************************
+ * Function: test_core
+ *
+ * Purpose: Tests that callbacks are called properly in the core VFD and
+ * that the initial file image works properly.
+ *
+ * Programmer: Jacob Gruber
+ * Monday, August 22, 2011
+ *
+ ******************************************************************************
+ */
+static int
+test_core(void)
+{
+ hid_t fapl;
+ hid_t file;
+ hid_t dset;
+ hid_t space;
+ udata_t *udata;
+ unsigned char *file_image;
+ char filename[1024];
+ char src_dir_filename[1024];
+ const char *tmp = NULL;
+ size_t size;
+ hsize_t dims[2];
+ int fd;
+ h5_stat_t sb;
+ herr_t ret;
+ H5FD_file_image_callbacks_t callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb,
+ &free_cb, &udata_copy_cb, &udata_free_cb, NULL};
+
+ TESTING("Initial file image and callbacks in Core VFD");
+
+ /* Create fapl */
+ fapl = h5_fileaccess();
+ VERIFY(fapl >= 0, "fapl creation failed");
+
+ /* Set up the core VFD */
+ ret = H5Pset_fapl_core(fapl, 0, 0);
+ VERIFY(ret >= 0, "setting core driver in fapl failed");
+
+ tmp = h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+ VERIFY(tmp != NULL, "h5_fixname failed");
+
+ /* convert file name to srcdir file name. Make a copy as
+ * H5_get_srcdir_filename() simply sets up the file name in its
+ * own buffer each time it is called -- overwriting the previous
+ * value.
+ */
+ tmp = H5_get_srcdir_filename(filename);
+ VERIFY(tmp != NULL, "H5_get_srcdir_filename failed");
+ VERIFY(strlen(tmp) < 1023, "srcdir file name too long.");
+ HDstrncpy(src_dir_filename, tmp, 1023);
+ src_dir_filename[1023] = '\0';
+
+ /* Allocate and initialize udata */
+ udata = (udata_t *)HDmalloc(sizeof(udata_t));
+ VERIFY(udata != NULL, "udata malloc failed");
+
+ /* copy the address of the udata into the callbacks structure */
+ callbacks.udata = (void *)udata;
+
+ /* Set file image callbacks */
+ ret = H5Pset_file_image_callbacks(fapl, &callbacks);
+ VERIFY(ret >= 0, "set image callbacks failed");
+
+ /* Test open (no file image) */
+ reset_udata(udata);
+ file = H5Fopen(src_dir_filename, H5F_ACC_RDWR, fapl);
+ VERIFY(file >= 0, "H5Fopen failed");
+ VERIFY(udata->used_callbacks == MALLOC, "opening a core file used the wrong callbacks");
+ VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_FILE_OPEN, "Malloc callback came from wrong sourc in core open");
+
+ /* Close file */
+ reset_udata(udata);
+ ret = H5Fclose(file);
+ VERIFY(ret >= 0, "H5Fclose failed");
+ VERIFY(udata->used_callbacks == FREE, "Closing a core file used the wrong callbacks");
+ VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close");
+
+ /* Reopen file */
+ file = H5Fopen(src_dir_filename, H5F_ACC_RDWR, fapl);
+ VERIFY(file >= 0, "H5Fopen failed");
+
+ /* Set up a new dset */
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ space = H5Screate_simple(RANK, dims, dims);
+ VERIFY(space >= 0, "H5Screate failed");
+
+ /* Create new dset, invoking H5FD_core_write */
+ reset_udata(udata);
+ dset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(dset >=0, "H5Dcreate failed");
+
+ /* Flush the write and check the realloc callback */
+ ret = H5Fflush(file, H5F_SCOPE_LOCAL);
+ VERIFY(ret >= 0, "H5Fflush failed");
+ VERIFY(udata->used_callbacks == (REALLOC), "core write used the wrong callbacks");
+ VERIFY(udata->realloc_src == H5FD_FILE_IMAGE_OP_FILE_RESIZE, "Realloc callback came from wrong source in core write");
+
+ /* Close dset and space */
+ ret = H5Dclose(dset);
+ VERIFY(ret >= 0, "H5Dclose failed");
+ ret = H5Sclose(space);
+ VERIFY(ret >= 0, "H5Sclose failed");
+
+ /* Test file close */
+ reset_udata(udata);
+ ret = H5Fclose(file);
+ VERIFY(ret >= 0, "H5Fclose failed");
+ VERIFY(udata->used_callbacks == (FREE), "Closing a core file used the wrong callbacks");
+ VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close");
+
+ /* Create file image buffer */
+ fd = HDopen(src_dir_filename, O_RDONLY, 0666);
+ VERIFY(fd > 0, "open failed");
+ ret = HDfstat(fd, &sb);
+ VERIFY(ret == 0, "fstat failed");
+ size = (size_t)sb.st_size;
+ file_image = (unsigned char *)HDmalloc(size);
+ HDread(fd, file_image, size);
+ ret = HDclose(fd);
+ VERIFY(ret == 0, "close failed");
+
+ /* Set file image in plist */
+ if(H5Pset_file_image(fapl, file_image, size) < 0) FAIL_STACK_ERROR
+
+ /* Test open with file image */
+ if((file = H5Fopen("dne.h5", H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file) < 0) FAIL_STACK_ERROR
+
+ /* Release resources */
+ h5_cleanup(FILENAME, fapl);
+ HDfree(udata);
+ HDfree(file_image);
+
+ PASSED();
+
+ return 0;
+
+error:
+ return 1;
+} /* end test_core() */
+
+/******************************************************************************
+ * Function: test_get_file_image
+ *
+ * Purpose: Test the H5Fget_file_image() call.
+ *
+ * Programmer: John Mainzer
+ * Tuesday, November 15, 2011
+ *
+ ******************************************************************************
+ */
+static int
+test_get_file_image(const char * test_banner,
+ const int file_name_num,
+ hid_t fapl)
+{
+ char file_name[1024] = "\0";
+ void * insertion_ptr = NULL;
+ void * image_ptr = NULL;
+ void * file_image_ptr = NULL;
+ hbool_t is_family_file = FALSE;
+ hbool_t identical;
+ int data[100];
+ int i;
+ int fd = -1;
+ int result;
+ hid_t driver = -1;
+ hid_t file_id = -1;
+ hid_t dset_id = -1;
+ hid_t space_id = -1;
+ hid_t core_fapl_id = -1;
+ hid_t core_file_id = -1;
+ herr_t err;
+ hsize_t dims[2];
+ ssize_t bytes_read;
+ ssize_t image_size;
+ ssize_t file_size;
+ h5_stat_t stat_buf;
+
+ TESTING(test_banner);
+
+ /* set flag if we are dealing with a family file */
+ driver = H5Pget_driver(fapl);
+ VERIFY(driver >= 0, "H5Pget_driver(fapl) failed");
+
+ if(driver == H5FD_FAMILY)
+ is_family_file = TRUE;
+
+ /* setup the file name */
+ h5_fixname(FILENAME2[file_name_num], fapl, file_name, sizeof(file_name));
+ VERIFY(HDstrlen(file_name)>0, "h5_fixname failed");
+
+ /* create the file */
+ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl);
+ VERIFY(file_id >= 0, "H5Fcreate() failed.");
+
+ /* Set up data space for new new data set */
+ dims[0] = 10;
+ dims[1] = 10;
+ space_id = H5Screate_simple(2, dims, dims);
+ VERIFY(space_id >= 0, "H5Screate() failed");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(dset_id >=0, "H5Dcreate() failed");
+
+ /* write some data to the data set */
+ for (i = 0; i < 100; i++)
+ data[i] = i;
+ err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data);
+ VERIFY(err >= 0, "H5Dwrite() failed.");
+
+ /* Flush the file */
+ err = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ VERIFY(err >= 0, "H5Fflush failed");
+
+ /* get the size of the file */
+ image_size = H5Fget_file_image(file_id, NULL, (size_t)0);
+ VERIFY(image_size > 0, "H5Fget_file_image(1) failed.");
+
+ /* allocate a buffer of the appropriate size */
+ image_ptr = HDmalloc((size_t)image_size);
+ VERIFY(image_ptr != NULL, "HDmalloc(1) failed.");
+
+ /* load the image of the file into the buffer */
+ bytes_read = H5Fget_file_image(file_id, image_ptr, (size_t)image_size);
+ VERIFY(bytes_read == image_size, "H5Fget_file_image(2) failed.");
+
+ /* Close dset and space */
+ err = H5Dclose(dset_id);
+ VERIFY(err >= 0, "H5Dclose failed");
+ err = H5Sclose(space_id);
+ VERIFY(err >= 0, "H5Sclose failed");
+
+ /* close the test file */
+ err = H5Fclose(file_id);
+ VERIFY(err == SUCCEED, "H5Fclose(file_id) failed.");
+
+ if(is_family_file) {
+ char member_file_name[1024];
+ ssize_t bytes_to_read;
+ ssize_t member_size;
+ ssize_t size_remaining;
+
+ i = 0;
+ file_size = 0;
+
+ do {
+ HDsnprintf(member_file_name, 1024, file_name, i);
+
+ /* get the size of the member file */
+ result = HDstat(member_file_name, &stat_buf);
+ VERIFY(result == 0, "HDstat() failed.");
+
+ member_size = (ssize_t)stat_buf.st_size;
+
+ i++;
+ file_size += member_size;
+ } while(member_size > 0);
+
+ /* Since we use the eoa to calculate the image size, the file size
+ * may be larger. This is OK, as long as (in this specialized instance)
+ * the remainder of the file is all '\0's.
+ */
+ VERIFY(file_size >= image_size, "file size != image size.");
+
+ /* allocate a buffer for the test file image */
+ file_image_ptr = HDmalloc((size_t)file_size);
+ VERIFY(file_image_ptr != NULL, "HDmalloc(2f) failed.");
+
+ size_remaining = image_size;
+ insertion_ptr = file_image_ptr;
+ i = 0;
+
+ while(size_remaining > 0) {
+ /* construct the member file name */
+ HDsnprintf(member_file_name, 1024, file_name, i);
+
+ /* open the test file using standard I/O calls */
+ fd = HDopen(member_file_name, O_RDONLY, 0666);
+ VERIFY(fd >= 0, "HDopen() failed.");
+
+ if(size_remaining >= FAMILY_SIZE ){
+ bytes_to_read = FAMILY_SIZE;
+ size_remaining -= FAMILY_SIZE;
+ } else {
+ bytes_to_read = size_remaining;
+ size_remaining = 0;
+ }
+
+ /* read the member file from disk into the buffer */
+ bytes_read = HDread(fd, insertion_ptr, (size_t)bytes_to_read);
+ VERIFY(bytes_read == bytes_to_read, "HDread() failed.");
+
+ insertion_ptr = (void *)(((char *)insertion_ptr) + bytes_to_read);
+
+ i++;
+
+ /* close the test file */
+ result = HDclose(fd);
+ VERIFY(result == 0, "HDclose() failed.");
+ }
+ } else {
+ /* get the size of the test file */
+ result = HDstat(file_name, &stat_buf);
+ VERIFY(result == 0, "HDstat() failed.");
+
+ /* Since we use the eoa to calculate the image size, the file size
+ * may be larger. This is OK, as long as (in this specialized instance)
+ * the remainder of the file is all '\0's.
+ */
+ file_size = (ssize_t)stat_buf.st_size;
+
+ /* with latest mods to truncate call in core file drive,
+ * file size should match image size
+ */
+ VERIFY(file_size == image_size, "file size != image size.");
+
+ /* allocate a buffer for the test file image */
+ file_image_ptr = HDmalloc((size_t)file_size);
+ VERIFY(file_image_ptr != NULL, "HDmalloc(2) failed.");
+
+ /* open the test file using standard I/O calls */
+ fd = HDopen(file_name, O_RDONLY, 0666);
+ VERIFY(fd >= 0, "HDopen() failed.");
+
+ /* read the test file from disk into the buffer */
+ bytes_read = HDread(fd, file_image_ptr, (size_t)file_size);
+ VERIFY(bytes_read == file_size, "HDread() failed.");
+
+ /* close the test file */
+ result = HDclose(fd);
+ VERIFY(result == 0, "HDclose() failed.");
+ }
+
+ /* verify that the file and the image contain the same data */
+ identical = TRUE;
+ i = 0;
+ while((i < (int)image_size) && identical) {
+ if(((char *)image_ptr)[i] != ((char *)file_image_ptr)[i])
+ identical = FALSE;
+ i++;
+ }
+ VERIFY(identical, "file and image differ.");
+
+
+ /* finally, verify that we can use the core file driver to open the image */
+
+ /* create fapl for core file driver */
+ core_fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ VERIFY(core_fapl_id >=0, "H5Pcreate() failed");
+
+ /* setup core_fapl_id to use the core file driver */
+ err = H5Pset_fapl_core(core_fapl_id, (size_t)(64 * 1024), FALSE);
+ VERIFY(err == SUCCEED, "H5Pset_fapl_core() failed.");
+
+ /* Set file image in core fapl */
+ err = H5Pset_file_image(core_fapl_id, image_ptr, (size_t)image_size);
+ VERIFY(err == SUCCEED, "H5Pset_file_image() failed.");
+
+ /* open the file image with the core file driver */
+ core_file_id = H5Fopen("nonesuch", H5F_ACC_RDWR, core_fapl_id);
+ VERIFY(core_file_id >= 0, "H5Fopen() of file image failed.");
+
+ /* close the file image with the core file driver */
+ err = H5Fclose(core_file_id);
+ VERIFY(err == SUCCEED, "H5Fclose(core_file_id) failed.");
+
+ /* dicard core fapl */
+ err = H5Pclose(core_fapl_id);
+ VERIFY(err == SUCCEED, "H5Pclose(core_fapl_id) failed.");
+
+ /* tidy up */
+ result = h5_cleanup(FILENAME2, fapl);
+ VERIFY(result != 0, "h5_cleanup() failed.");
+
+ /* discard the image buffer if it exists */
+ if(image_ptr != NULL)
+ HDfree(image_ptr);
+
+ /* discard the image buffer if it exists */
+ if(file_image_ptr != NULL)
+ HDfree(file_image_ptr);
+
+ PASSED();
+
+ return 0;
+
+error:
+ return 1;
+} /* end test_get_file_image() */
+
+/******************************************************************************
+ * Function: test_get_file_image_error_rejection
+ *
+ * Purpose: Verify that H5Fget_file_image() rejects invalid input.
+ *
+ * Programmer: John Mainzer
+ * Tuesday, November 22, 2011
+ *
+ ******************************************************************************
+ */
+
+#define TYPE_SLICE ((haddr_t)0x10000LL)
+
+static int
+test_get_file_image_error_rejection(void)
+{
+ const char *memb_name[H5FD_MEM_NTYPES];
+ char file_name[1024] = "\0";
+ void * image_ptr = NULL;
+ int data[100];
+ int i;
+ int result;
+ hid_t fapl_id = -1;
+ hid_t file_id = -1;
+ hid_t dset_id = -1;
+ hid_t space_id = -1;
+ herr_t err;
+ hsize_t dims[2];
+ ssize_t bytes_read;
+ ssize_t image_size;
+ hid_t memb_fapl[H5FD_MEM_NTYPES];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+ H5FD_mem_t mt;
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
+
+
+ TESTING("H5Fget_file_image() error rejection");
+
+ /************************ Sub-Test #1 ********************************/
+ /* set up a test file, and try to get its image with a buffer that is
+ * too small. Call to H5Fget_file_image() should fail.
+ *
+ * Since we have already done the necessary setup, verify that
+ * H5Fget_file_image() will fail with:
+ *
+ * bad file id, or
+ *
+ * good id, but not a file id
+ */
+
+
+ /* setup fapl -- driver type doesn't matter much, so make it stdio */
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ VERIFY(fapl_id >= 0, "H5Pcreate(1) failed");
+
+ err = H5Pset_fapl_stdio(fapl_id);
+ VERIFY(err >= 0, "H5Pset_fapl_stdio() failed");
+
+ /* setup the file name */
+ h5_fixname(FILENAME2[6], fapl_id, file_name, sizeof(file_name));
+ VERIFY(HDstrlen(file_name)>0, "h5_fixname failed");
+
+ /* create the file */
+ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id);
+ VERIFY(file_id >= 0, "H5Fcreate() failed.");
+
+ /* Set up data space for new new data set */
+ dims[0] = 10;
+ dims[1] = 10;
+ space_id = H5Screate_simple(2, dims, dims);
+ VERIFY(space_id >= 0, "H5Screate() failed");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(dset_id >=0, "H5Dcreate() failed");
+
+ /* write some data to the data set */
+ for (i = 0; i < 100; i++)
+ data[i] = i;
+ err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, (void *)data);
+ VERIFY(err >= 0, "H5Dwrite() failed.");
+
+ /* Flush the file */
+ err = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ VERIFY(err >= 0, "H5Fflush failed");
+
+ /* get the size of the file */
+ image_size = H5Fget_file_image(file_id, NULL, (size_t)0);
+ VERIFY(image_size > 0, "H5Fget_file_image(1 -- test 1) failed.");
+
+ /* allocate a buffer of the appropriate size */
+ image_ptr = HDmalloc((size_t)image_size);
+ VERIFY(image_ptr != NULL, "HDmalloc(1) failed.");
+
+ /* load the image of the file into the buffer */
+ H5E_BEGIN_TRY {
+ bytes_read = H5Fget_file_image(file_id, image_ptr, (size_t)(image_size - 1));
+ } H5E_END_TRY;
+ VERIFY(bytes_read < 0, "H5Fget_file_image(2 -- test 1) succeeded.");
+
+ /* Call H5Fget_file_image() with good buffer and buffer size,
+ * but non-existant file_id. Should fail.
+ */
+ H5E_BEGIN_TRY {
+ bytes_read = H5Fget_file_image((hid_t)0, image_ptr, (size_t)(image_size));
+ } H5E_END_TRY;
+ VERIFY(bytes_read < 0, "H5Fget_file_image(3 -- test 1) succeeded.");
+
+ /* Call H5Fget_file_image() with good buffer and buffer size,
+ * but a file_id of the wrong type. Should fail.
+ */
+ H5E_BEGIN_TRY {
+ bytes_read = H5Fget_file_image(dset_id, image_ptr, (size_t)(image_size));
+ } H5E_END_TRY;
+ VERIFY(bytes_read < 0, "H5Fget_file_image(4 -- test 1) succeeded.");
+
+ /* Close dset and space */
+ err = H5Dclose(dset_id);
+ VERIFY(err >= 0, "H5Dclose failed");
+ err = H5Sclose(space_id);
+ VERIFY(err >= 0, "H5Sclose failed");
+
+ /* close the test file */
+ err = H5Fclose(file_id);
+ VERIFY(err == SUCCEED, "H5Fclose(file_id) failed.");
+
+ /* tidy up */
+ result = h5_cleanup(FILENAME2, fapl_id);
+ VERIFY(result != 0, "h5_cleanup(1) failed.");
+
+ /* discard the image buffer if it exists */
+ if(image_ptr != NULL)
+ HDfree(image_ptr);
+
+ /************************** Test #2 **********************************/
+ /* set up a multi file driver test file, and try to get its image
+ * with H5Fget_file_image(). Attempt should fail.
+ */
+
+ /* setup parameters for multi file driver */
+ for(mt = (H5FD_mem_t)0; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) {
+ memb_addr[mt] = HADDR_UNDEF;
+ memb_fapl[mt] = H5P_DEFAULT;
+ memb_map[mt] = H5FD_MEM_DRAW;
+ memb_name[mt] = NULL;
+ }
+
+ memb_map[H5FD_MEM_SUPER] = H5FD_MEM_SUPER;
+ memb_fapl[H5FD_MEM_SUPER] = H5P_DEFAULT;
+ memb_name[H5FD_MEM_SUPER] = "%s-s.h5";
+ memb_addr[H5FD_MEM_SUPER] = 0;
+
+ memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE;
+ memb_fapl[H5FD_MEM_BTREE] = H5P_DEFAULT;
+ memb_name[H5FD_MEM_BTREE] = "%s-b.h5";
+ memb_addr[H5FD_MEM_BTREE] = memb_addr[H5FD_MEM_SUPER] + TYPE_SLICE;
+
+ memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW;
+ memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT;
+ memb_name[H5FD_MEM_DRAW] = "%s-r.h5";
+ memb_addr[H5FD_MEM_DRAW] = memb_addr[H5FD_MEM_BTREE] + TYPE_SLICE;
+
+ memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP;
+ memb_fapl[H5FD_MEM_GHEAP] = H5P_DEFAULT;
+ memb_name[H5FD_MEM_GHEAP] = "%s-g.h5";
+ memb_addr[H5FD_MEM_GHEAP] = memb_addr[H5FD_MEM_DRAW] + TYPE_SLICE;
+
+ memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP;
+ memb_fapl[H5FD_MEM_LHEAP] = H5P_DEFAULT;
+ memb_name[H5FD_MEM_LHEAP] = "%s-l.h5";
+ memb_addr[H5FD_MEM_LHEAP] = memb_addr[H5FD_MEM_GHEAP] + TYPE_SLICE;
+
+ memb_map[H5FD_MEM_OHDR] = H5FD_MEM_OHDR;
+ memb_fapl[H5FD_MEM_OHDR] = H5P_DEFAULT;
+ memb_name[H5FD_MEM_OHDR] = "%s-o.h5";
+ memb_addr[H5FD_MEM_OHDR] = memb_addr[H5FD_MEM_LHEAP] + TYPE_SLICE;
+
+ /* setup fapl */
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ VERIFY(fapl_id >= 0, "H5Pcreate(2) failed");
+
+ /* setup the fapl for the multi file driver */
+ err = H5Pset_fapl_multi(fapl_id, memb_map, memb_fapl, memb_name,
+ memb_addr, FALSE);
+ VERIFY(err >= 0, "H5Pset_fapl_multi failed");
+
+ /* setup the file name */
+ h5_fixname(FILENAME2[4], fapl_id, file_name, sizeof(file_name));
+ VERIFY(HDstrlen(file_name)>0, "h5_fixname failed");
+
+ /* create the file */
+ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id);
+ VERIFY(file_id >= 0, "H5Fcreate() failed.");
+
+ /* Set up data space for new new data set */
+ dims[0] = 10;
+ dims[1] = 10;
+ space_id = H5Screate_simple(2, dims, dims);
+ VERIFY(space_id >= 0, "H5Screate() failed");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(dset_id >=0, "H5Dcreate() failed");
+
+ /* write some data to the data set */
+ for (i = 0; i < 100; i++)
+ data[i] = i;
+ err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, (void *)data);
+ VERIFY(err >= 0, "H5Dwrite() failed.");
+
+ /* Flush the file */
+ err = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ VERIFY(err >= 0, "H5Fflush failed");
+
+ /* attempt to get the size of the file -- should fail */
+ H5E_BEGIN_TRY {
+ image_size = H5Fget_file_image(file_id, NULL, (size_t)0);
+ } H5E_END_TRY;
+ VERIFY(image_size == -1, "H5Fget_file_image(5) succeeded.");
+
+ /* Close dset and space */
+ err = H5Dclose(dset_id);
+ VERIFY(err >= 0, "H5Dclose failed");
+ err = H5Sclose(space_id);
+ VERIFY(err >= 0, "H5Sclose failed");
+
+ /* close the test file */
+ err = H5Fclose(file_id);
+ VERIFY(err == SUCCEED, "H5Fclose(2) failed.");
+
+ /* tidy up */
+ result = h5_cleanup(FILENAME2, fapl_id);
+ VERIFY(result != 0, "h5_cleanup(2 failed.");
+
+ /************************** Test #3 **********************************/
+ /* set up a split file driver test file, and try to get its image
+ * with H5Fget_file_image(). Attempt should fail.
+ */
+
+ /* create fapl */
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ VERIFY(fapl_id >= 0, "H5Pcreate(3) failed");
+
+ /* setup the fapl for the split file driver */
+ err = H5Pset_fapl_split(fapl_id, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT);
+ VERIFY(err >= 0, "H5Pset_fapl_split failed");
+
+ /* setup the file name */
+ h5_fixname(FILENAME2[5], fapl_id, file_name, sizeof(file_name));
+ VERIFY(HDstrlen(file_name)>0, "h5_fixname failed");
+
+ /* create the file */
+ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id);
+ VERIFY(file_id >= 0, "H5Fcreate() failed.");
+
+ /* Set up data space for new new data set */
+ dims[0] = 10;
+ dims[1] = 10;
+ space_id = H5Screate_simple(2, dims, dims);
+ VERIFY(space_id >= 0, "H5Screate() failed");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(dset_id >=0, "H5Dcreate() failed");
+
+ /* write some data to the data set */
+ for (i = 0; i < 100; i++)
+ data[i] = i;
+ err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, (void *)data);
+ VERIFY(err >= 0, "H5Dwrite() failed.");
+
+ /* Flush the file */
+ err = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ VERIFY(err >= 0, "H5Fflush failed");
+
+ /* attempt to get the size of the file -- should fail */
+ H5E_BEGIN_TRY {
+ image_size = H5Fget_file_image(file_id, NULL, (size_t)0);
+ } H5E_END_TRY;
+ VERIFY(image_size == -1, "H5Fget_file_image(6) succeeded.");
+
+ /* Close dset and space */
+ err = H5Dclose(dset_id);
+ VERIFY(err >= 0, "H5Dclose failed");
+ err = H5Sclose(space_id);
+ VERIFY(err >= 0, "H5Sclose failed");
+
+ /* close the test file */
+ err = H5Fclose(file_id);
+ VERIFY(err == SUCCEED, "H5Fclose(2) failed.");
+
+
+ /************************** Test #4 **********************************/
+ /* set up a family file driver test file, and try to get its image
+ * with H5Fget_file_image(). Attempt should fail.
+ */
+
+ /* create fapl */
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ VERIFY(fapl_id >= 0, "H5Pcreate(3) failed");
+
+ err = H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, H5P_DEFAULT);
+ VERIFY(err >= 0, "H5Pset_fapl_family failed");
+
+ h5_fixname(FILENAME2[3], fapl_id, file_name, sizeof(file_name));
+ VERIFY(HDstrlen(file_name)>0, "h5_fixname failed");
+
+ /* create the file */
+ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id);
+ VERIFY(file_id >= 0, "H5Fcreate() failed.");
+
+ /* Set up data space for new new data set */
+ dims[0] = 10;
+ dims[1] = 10;
+ space_id = H5Screate_simple(2, dims, dims);
+ VERIFY(space_id >= 0, "H5Screate() failed");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(dset_id >=0, "H5Dcreate() failed");
+
+ /* write some data to the data set */
+ for (i = 0; i < 100; i++)
+ data[i] = i;
+ err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, (void *)data);
+ VERIFY(err >= 0, "H5Dwrite() failed.");
+
+ /* Flush the file */
+ err = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ VERIFY(err >= 0, "H5Fflush failed");
+
+ /* attempt to get the size of the file -- should fail */
+ H5E_BEGIN_TRY {
+ image_size = H5Fget_file_image(file_id, NULL, (size_t)0);
+ } H5E_END_TRY;
+ VERIFY(image_size == -1, "H5Fget_file_image(7) succeeded.");
+
+ /* Close dset and space */
+ err = H5Dclose(dset_id);
+ VERIFY(err >= 0, "H5Dclose failed");
+ err = H5Sclose(space_id);
+ VERIFY(err >= 0, "H5Sclose failed");
+
+ /* close the test file */
+ err = H5Fclose(file_id);
+ VERIFY(err == SUCCEED, "H5Fclose(2) failed.");
+
+ /* tidy up */
+ result = h5_cleanup(FILENAME2, fapl_id);
+ VERIFY(result != 0, "h5_cleanup(2 failed.");
+
+ PASSED();
+
+ return 0;
+
+error:
+ return 1;
+}
+
+int
+main(void)
+{
+ int errors = 0;
+ hid_t fapl;
+
+ h5_reset();
+
+ printf("Testing File Image Functionality.\n");
+
+ errors += test_properties();
+ errors += test_callbacks();
+ errors += test_core();
+
+ /* test H5Fget_file_image() with sec2 driver */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ if(0 > H5Pset_fapl_sec2(fapl))
+ errors++;
+ else
+ errors += test_get_file_image("H5Fget_file_image() with sec2 driver",
+ 0, fapl);
+
+ /* test H5Fget_file_image() with stdio driver */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ if(0 > H5Pset_fapl_stdio(fapl))
+ errors++;
+ else
+ errors += test_get_file_image("H5Fget_file_image() with stdio driver",
+ 1, fapl);
+
+ /* test H5Fget_file_image() with core driver */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ if(0 > H5Pset_fapl_core(fapl, (size_t)(64 *1024), TRUE))
+ errors++;
+ else
+ errors += test_get_file_image("H5Fget_file_image() with core driver",
+ 2, fapl);
+
+#if 0
+ /* at present, H5Fget_file_image() rejects files opened with the
+ * family file driver, due to the addition of a driver info message
+ * in the super block. This message prevents the image being opened
+ * with any driver other than the family file driver, which sort of
+ * defeats the purpose of the get file image operation.
+ *
+ * While this issues is quite fixable, we don't have time or resources
+ * for this right now. Once we do, the following code should be
+ * suitable for testing the fix.
+ */
+ /* test H5Fget_file_image() with family file driver */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
+ errors++;
+ else
+ errors += test_get_file_image("H5Fget_file_image() with family driver",
+ 3, fapl);
+#endif
+
+ errors += test_get_file_image_error_rejection();
+
+
+ if(errors) {
+ printf("***** %d File Image TEST%s FAILED! *****\n",
+ errors, errors > 1 ? "S" : "");
+ return 1;
+ }
+
+ printf("All File Image tests passed.\n");
+ return 0;
+}
+
diff --git a/test/file_image_core_test.h5 b/test/file_image_core_test.h5
new file mode 100644
index 0000000..1cc5130
--- /dev/null
+++ b/test/file_image_core_test.h5
Binary files differ
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/gen_file_image.c b/test/gen_file_image.c
new file mode 100644
index 0000000..bc9de29
--- /dev/null
+++ b/test/gen_file_image.c
@@ -0,0 +1,91 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Friday, March 30, 2012
+ *
+ * Purpose: Create a simple file for use with the file image tests.
+ *
+ */
+#include "hdf5.h"
+
+#define TESTFILE "file_image_core_test.h5"
+
+/* 2-D dataset with fixed dimensions */
+#define SPACE_RANK 2
+#define SPACE_DIM1 128
+#define SPACE_DIM2 32
+
+/* Dataset data */
+int data[SPACE_DIM1][SPACE_DIM2];
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Quincey Koziol
+ * Friday, March 30, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t file, space, dset;
+ hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2};
+ size_t i, j; /* Local index variables */
+
+ /* Initialize the data */
+ for(i = 0; i < SPACE_DIM1; i++)
+ for(j = 0; j < SPACE_DIM2; j++)
+ data[i][j] = (int)(j % 5);
+
+ /* Create the file */
+ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if(file < 0)
+ printf("file < 0!\n");
+
+ /* Create the dataspace */
+ space = H5Screate_simple(SPACE_RANK, dims, NULL);
+ if(space < 0)
+ printf("space < 0!\n");
+
+ /* Create the compressed dataset */
+ dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if(dset < 0)
+ printf("dset < 0!\n");
+
+ /* Write the data to the dataset */
+ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ printf("H5Dwrite() failed!\n");
+
+ /* Close everything */
+ if(H5Dclose(dset) < 0)
+ printf("H5Dclose() failed!\n");
+ if(H5Sclose(space) < 0)
+ printf("H5Sclose() failed!\n");
+ if(H5Fclose(file) < 0)
+ printf("H5Fclose() failed!\n");
+
+ return 0;
+}
+
diff --git a/test/istore.c b/test/istore.c
index 3ae8da7..f99e835 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
@@ -431,7 +467,7 @@ error:
*/
static herr_t
test_sparse(hid_t f, const char *prefix, size_t nblocks,
- size_t nx, size_t ny, size_t nz)
+ size_t nx, size_t ny, size_t nz, int skip_test)
{
hid_t dataset; /* Dataset ID */
hid_t fspace; /* Dataset's file dataspace */
@@ -463,6 +499,10 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks,
sprintf(s, "istore sparse: %s", dims);
TESTING(s);
+ if(skip_test){
+ SKIPPED()
+ return SUCCEED;
+ }
buf = (uint8_t *)HDmalloc(nx * ny * nz);
HDmemset(buf, 128, nx * ny * nz);
@@ -565,6 +605,8 @@ main(int argc, char *argv[])
unsigned size_of_test;
unsigned u; /* Local index variable */
char filename[1024];
+ int skip_test = 0;
+ int has_sparse_support = 0;
/* Parse arguments or assume these tests (`small', `medium' ) */
if (1 == argc) {
@@ -598,6 +640,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();
@@ -640,24 +688,31 @@ main(int argc, char *argv[])
status = test_extend(file, "extend", (size_t)10, (size_t)400, (size_t)10);
nerrors += status < 0 ? 1 : 0;
}
+ skip_test = 0;
if (size_of_test & TEST_SMALL) {
- status = test_sparse(file, "sparse", (size_t)100, (size_t)5, (size_t)0, (size_t)0);
+ status = test_sparse(file, "sparse", (size_t)100, (size_t)5, (size_t)0, (size_t)0, skip_test);
nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)100, (size_t)3, (size_t)4, (size_t)0);
+ status = test_sparse(file, "sparse", (size_t)100, (size_t)3, (size_t)4, (size_t)0, skip_test);
nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)100, (size_t)2, (size_t)3, (size_t)4);
+ status = test_sparse(file, "sparse", (size_t)100, (size_t)2, (size_t)3, (size_t)4, skip_test);
nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_sparse(file, "sparse", (size_t)1000, (size_t)30, (size_t)0, (size_t)0);
+ status = test_sparse(file, "sparse", (size_t)1000, (size_t)30, (size_t)0, (size_t)0, skip_test);
nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)2000, (size_t)7, (size_t)3, (size_t)0);
+ status = test_sparse(file, "sparse", (size_t)2000, (size_t)7, (size_t)3, (size_t)0, skip_test);
nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)2000, (size_t)4, (size_t)2, (size_t)3);
+ status = test_sparse(file, "sparse", (size_t)2000, (size_t)4, (size_t)2, (size_t)3, skip_test);
nerrors += status < 0 ? 1 : 0;
}
+ skip_test = !has_sparse_support;
if (size_of_test & TEST_LARGE) {
- status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50);
+ /* 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, skip_test);
+ if(skip_test)
+ printf(" The current VFD does not support sparse files on this platform.\n");
nerrors += status < 0 ? 1 : 0;
}
diff --git a/test/objcopy.c b/test/objcopy.c
index 8fb8bbe..f5555e8 100755..100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -53,6 +53,7 @@ const char *FILENAME[] = {
"objcopy_src",
"objcopy_dst",
"objcopy_ext",
+ "objcopy_src2",
NULL
};
@@ -79,6 +80,7 @@ const char *FILENAME[] = {
#define NAME_DATATYPE_VL_VL "vlen of vlen of int"
#define NAME_DATASET_SIMPLE "dataset_simple"
#define NAME_DATASET_SIMPLE2 "dataset_simple_copy"
+#define NAME_DATASET_SIMPLE3 "dataset_simple_another_copy"
#define NAME_DATASET_COMPOUND "dataset_compound"
#define NAME_DATASET_CHUNKED "dataset_chunked"
#define NAME_DATASET_CHUNKED2 "dataset_chunked2"
@@ -99,6 +101,9 @@ const char *FILENAME[] = {
#define NAME_GROUP_UNCOPIED "/uncopied"
#define NAME_GROUP_EMPTY "/empty"
#define NAME_GROUP_TOP "/g0"
+#define NAME_GROUP_TOP2 "/g1"
+#define NAME_GROUP_TOP3 "/g2"
+#define NAME_GROUP_TOP4 "/g3"
#define NAME_GROUP_SUB "/g0/g00"
#define NAME_GROUP_SUB_2 "/g0/g01"
#define NAME_GROUP_SUB_SUB "/g0/g00/g000"
@@ -134,6 +139,9 @@ const char *FILENAME[] = {
#define NUM_WIDE_LOOP_GROUPS 10
#define NUM_DATASETS 10
+#define COPY_OPEN_OBJ_NAME "CopyOpenObj"
+#define COPY_OPEN_OBJ_SIZE sizeof(hbool_t)
+
char src_obj_full_name[215]; /* the full path + name of the object to be copied */
unsigned num_attributes_g; /* Number of attributes created */
@@ -554,12 +562,17 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id)
char attr_name[ATTR_NAME_LEN];
int attr_data[2];
hsize_t dim1 = 2;
+ hid_t acpl = -1;
unsigned u;
int ret_value = -1;
if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 )
goto done;
+ /* Create attribute creation plist */
+ if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0)
+ goto done;
+
for(u = 0; u < num_attributes_g; u++) {
sprintf(attr_name, "%u attr", u);
@@ -567,7 +580,16 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id)
attr_data[0] = (int)(100 * u);
attr_data[1] = (int)(200 * u);
- if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ /* Set attribute character set (alternate) */
+ if(u % 2) {
+ if(H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0)
+ goto done;
+ } /* end if */
+ else
+ if(H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)
+ goto done;
+
+ if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, acpl, H5P_DEFAULT)) < 0)
goto done;
if(H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0)
@@ -586,6 +608,8 @@ done:
H5Sclose(sid);
if(aid > 0)
H5Aclose(aid);
+ if(acpl > 0)
+ H5Pclose(acpl);
return ret_value;
}
@@ -609,11 +633,15 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id)
hid_t aid = -1, sid = -1;
char attr_name[ATTR_NAME_LEN];
int attr_data[2];
+ hid_t acpl = -1;
unsigned u;
hsize_t dim1 = 2;
if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) goto done;
+ /* Create attribute creation plist */
+ if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) goto done;
+
for(u = 0; u < num_attributes_g; u++) {
sprintf(attr_name, "%u attr", u);
@@ -621,6 +649,13 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id)
attr_data[0] = (int)(100 * u);
attr_data[1] = (int)(200 * u);
+ /* Set attribute character set (alternate) */
+ if(u % 2) {
+ if(H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) goto done;
+ } /* end if */
+ else
+ if(H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) goto done;
+
/* Add attribute to first object */
if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto done;
if(H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) goto done;
@@ -633,6 +668,7 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id)
}
if(H5Sclose(sid) < 0) goto done;
+ if(H5Pclose(acpl) < 0) goto done;
return 0;
@@ -641,6 +677,8 @@ done:
H5Sclose(sid);
if(aid > 0)
H5Aclose(aid);
+ if(acpl > 0)
+ H5Pclose(acpl);
return -1;
} /* end test_copy_attach_paired_attributes() */
@@ -666,10 +704,22 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
size_t elmt_size; /* Size of datatype */
htri_t is_committed; /* If the datatype is committed */
htri_t is_committed2; /* If the datatype is committed */
+ H5A_info_t ainfo; /* Attribute info */
+ H5A_info_t ainfo2; /* Attribute info */
hssize_t nelmts; /* # of elements in dataspace */
void *rbuf = NULL; /* Buffer for reading raw data */
void *rbuf2 = NULL; /* Buffer for reading raw data */
+ /* Check the character sets are equal */
+ if(H5Aget_info(aid, &ainfo) < 0) TEST_ERROR
+ if(H5Aget_info(aid2, &ainfo2) < 0) TEST_ERROR
+ if(ainfo.cset != ainfo2.cset) TEST_ERROR
+
+ /* Check the creation orders are equal (if appropriate) */
+ if(ainfo.corder_valid != ainfo2.corder_valid) TEST_ERROR
+ if(ainfo.corder_valid)
+ if(ainfo.corder != ainfo2.corder) TEST_ERROR
+
/* Check the datatypes are equal */
/* Open the datatype for the source attribute */
@@ -1138,6 +1188,18 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf)
void *rbuf2 = NULL; /* Buffer for reading raw data */
H5D_space_status_t space_status; /* Dataset's raw data space status */
H5D_space_status_t space_status2; /* Dataset's raw data space status */
+ hbool_t copy_open_obj = FALSE; /* Indicate if we are copying open objects */
+
+ /* Retrieve the private "copy open object" property from the property list, if it's non-DEFAULT */
+ if(pid != H5P_DEFAULT) {
+ htri_t copy_open_obj_exists;
+
+ if((copy_open_obj_exists = H5Pexist(pid, COPY_OPEN_OBJ_NAME)) < 0) TEST_ERROR
+ if(copy_open_obj_exists) {
+ if(H5Pget(pid, COPY_OPEN_OBJ_NAME, &copy_open_obj) < 0)
+ TEST_ERROR
+ } /* end if */
+ } /* end if */
/* Check the datatypes are equal */
@@ -1210,20 +1272,22 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf)
if(offset1 != offset2) TEST_ERROR
if(size1 != size2) TEST_ERROR
- if(strcmp(name1, name2) != 0) TEST_ERROR
+ if(HDstrcmp(name1, name2) != 0) TEST_ERROR
}
- /* Remove external file information from the dcpls */
- /* Remove default property causes memory leak
- if(H5Premove(dcpl, H5D_CRT_EXT_FILE_LIST_NAME) < 0) TEST_ERROR
- if(H5Premove(dcpl2, H5D_CRT_EXT_FILE_LIST_NAME) < 0) TEST_ERROR
- */
-
- /* reset external file information from the dcpls */
+ /* Reset external file information from the dcpls */
+ /* (Directly removing default property causes memory leak) */
if (H5P_reset_external_file_test(dcpl) < 0) TEST_ERROR
if (H5P_reset_external_file_test(dcpl2) < 0) TEST_ERROR
}
+ /* Check for copying open objects */
+ if(copy_open_obj) {
+ /* Reset layout information from the dcpls */
+ if(H5P_reset_layout_test(dcpl) < 0) TEST_ERROR
+ if(H5P_reset_layout_test(dcpl2) < 0) TEST_ERROR
+ } /* end if */
+
/* Compare the rest of the dataset creation property lists */
if(H5Pequal(dcpl, dcpl2) != TRUE) TEST_ERROR
@@ -1285,7 +1349,9 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf)
/* Release raw data buffers */
HDfree(rbuf);
+ rbuf = NULL;
HDfree(rbuf2);
+ rbuf2 = NULL;
/* close the source dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
@@ -8628,6 +8694,3294 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_attr_crt_order
+ *
+ * Purpose: Tests copying attributes with creation order tracked, with
+ * and without creation order being indexed.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Friday, January 20, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_attr_crt_order(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
+{
+ hid_t fid1 = -1, fid2 = -1; /* File IDs */
+ hid_t gcplid = -1; /* Group creation property list ID */
+ hid_t gid1 = -1, gid2 = -1; /* Group IDs */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): attributes with creation order");
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], src_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* Create source file */
+ if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0)
+ TEST_ERROR
+
+ /* Create GCPL */
+ if((gcplid = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR
+
+ /* Create group with creation order tracked */
+ if(H5Pset_attr_creation_order(gcplid, H5P_CRT_ORDER_TRACKED) < 0) TEST_ERROR
+ if((gid1 = H5Gcreate2(fid1, NAME_GROUP_TOP, H5P_DEFAULT, gcplid, H5P_DEFAULT))
+ < 0)
+ TEST_ERROR
+
+ /* Add attributes to group */
+ if(test_copy_attach_attributes(gid1, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* Close group */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+
+ /* Create group with creation order tracked and indexed */
+ if(H5Pset_attr_creation_order(gcplid, H5P_CRT_ORDER_TRACKED
+ | H5P_CRT_ORDER_INDEXED) < 0)
+ TEST_ERROR
+ if((gid1 = H5Gcreate2(fid1, NAME_GROUP_TOP2, H5P_DEFAULT, gcplid,
+ H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Add attributes to group */
+ if(test_copy_attach_attributes(gid1, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* Close group */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+
+ /* Close GCPL */
+ if(H5Pclose(gcplid) < 0) TEST_ERROR
+
+
+ /* Create destination file */
+ if((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0)
+ TEST_ERROR
+
+ /* Copy the groups to the destination file */
+ if(H5Ocopy(fid1, NAME_GROUP_TOP, fid2, NAME_GROUP_TOP, H5P_DEFAULT,
+ H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Ocopy(fid1, NAME_GROUP_TOP2, fid2, NAME_GROUP_TOP2, H5P_DEFAULT,
+ H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Open groups with creation order tracked */
+ if((gid1 = H5Gopen2(fid1, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gid2 = H5Gopen2(fid2, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Compare the attributes */
+ if(compare_std_attributes(gid1, gid2, H5P_DEFAULT) != TRUE) TEST_ERROR
+
+ /* Close groups */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+
+ /* Open groups with creation order tracked and indexed */
+ if((gid1 = H5Gopen2(fid1, NAME_GROUP_TOP2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gid2 = H5Gopen2(fid2, NAME_GROUP_TOP2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Compare the attributes */
+ if(compare_std_attributes(gid1, gid2, H5P_DEFAULT) != TRUE) TEST_ERROR
+
+ /* Close groups */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+
+ /* Close */
+ if(H5Fclose(fid1) < 0) TEST_ERROR
+ if(H5Fclose(fid2) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid1);
+ H5Gclose(gid2);
+ H5Pclose(gcplid);
+ H5Fclose(fid1);
+ H5Fclose(fid2);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_attr_crt_order */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_committed_datatype_merge
+ *
+ * Purpose: Tests the "merge committed datatypes" feature of H5Ocopy.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Tuesday, October 11, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_committed_datatype_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src1 = -1, fid_src2 = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char src1_filename[NAME_BUF_SIZE];
+ char src2_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ if(reopen) {
+ TESTING("H5Ocopy(): merging committed datatypes with reopen")
+ } /* end if */
+ else
+ TESTING("H5Ocopy(): merging committed datatypes")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src1_filename, sizeof src1_filename);
+ h5_fixname(FILENAME[3], src_fapl, src2_filename, sizeof src2_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source files */
+ if((fid_src1 = H5Fcreate(src1_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+ if((fid_src2 = H5Fcreate(src2_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /*
+ * Populate source file 1
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid_src1, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src1, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file 1 */
+ if(H5Fclose(fid_src1) < 0) TEST_ERROR
+
+ /*
+ * Populate source file 2
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid_src2, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src2, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file 1 */
+ if(H5Fclose(fid_src2) < 0) TEST_ERROR
+
+
+ /* open the source files with read-only */
+ if((fid_src1 = H5Fopen(src1_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+ if((fid_src2 = H5Fopen(src2_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge named dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * First copy each entire file to the destination file (each with their own
+ * group), and verify the committed datatypes are merged
+ */
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* copy SRC1 to DST */
+ if(H5Ocopy(fid_src1, "/", fid_dst, NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy SRC2 to DST */
+ if(H5Ocopy(fid_src2, "/", fid_dst, NAME_GROUP_TOP2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open SRC1 committed dtype, get address */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open SRC1 dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open SRC2 committed dtype, check address */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open SRC2 dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Now copy only the datasets to the destination file, and verify the committed
+ * datatypes are merged
+ */
+ /* recreate destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* copy SRC1 to DST */
+ if(H5Ocopy(fid_src1, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy SRC2 to DST */
+ if(H5Ocopy(fid_src2, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open SRC1 dset dtype, get address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open SRC2 dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC files */
+ if(H5Fclose(fid_src1) < 0) TEST_ERROR
+ if(H5Fclose(fid_src2) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src1);
+ H5Fclose(fid_src2);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_committed_datatype_merge */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_committed_datatype_merge_same_file
+ *
+ * Purpose: Tests the "merge committed datatypes" feature of H5Ocopy,
+ * while copying to the same file.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Tuesday, October 11, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_committed_datatype_merge_same_file(hid_t fcpl, hid_t fapl, hbool_t reopen)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t gid = -1; /* Group ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char filename[NAME_BUF_SIZE];
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging committed datatypes to the source file with reopen")
+ else
+ TESTING("H5Ocopy(): merging committed datatypes to the source file")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filename */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /*
+ * Populate first group
+ */
+ /* Create group */
+ if((gid = H5Gcreate2(fid, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset */
+ if((did = H5Dcreate2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the group */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /*
+ * Populate second group
+ */
+ /* Create group */
+ if((gid = H5Gcreate2(fid, NAME_GROUP_TOP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset */
+ if((did = H5Dcreate2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the group */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * First copy each group to the destination group 3 (each with their own
+ * group), and verify the committed datatypes are merged as expected. All
+ * datatypes copied should reference (share an address with) the
+ * corresponding source datatype.
+ */
+ /* Create destination group */
+ if((gid = H5Gcreate2(fid, NAME_GROUP_TOP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* copy group 1 to DST */
+ if(H5Ocopy(fid, NAME_GROUP_TOP, fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy group 2 to DST */
+ if(H5Ocopy(fid, NAME_GROUP_TOP2, fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open group 1 source committed dtype, get address */
+ if((tid = H5Topen2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open group 1 source dset dtype, check address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open group 1 committed dtype, check address */
+ if((tid = H5Topen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open group 1 dset dtype, check address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open group 2 source committed dtype, get address and make sure it is
+ * different from group 1 source committed dtype */
+ if((tid = H5Topen2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr == exp_addr) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open group 2 source dset dtype, check address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open group 2 committed dtype, check address */
+ if((tid = H5Topen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open group 2 dset dtype, check address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /*
+ * Now copy only the datasets to the destination group, and verify the committed
+ * datatypes are merged as expected
+ */
+ /* Create destination group */
+ if((gid = H5Gcreate2(fid, NAME_GROUP_TOP4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* copy SRC1 to DST */
+ if(H5Ocopy(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy SRC2 to DST */
+ if(H5Ocopy(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open group 1 source dset dtype, get address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open group 1 dset dtype, check address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open group 2 source dset dtype, get address and make sure it is
+ * different from group 1 source dset dtype */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr == exp_addr) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open group 2 dset dtype, check address */
+ if((did = H5Dopen2(fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_committed_datatype_merge_same_file */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_committed_dt_merge_sugg
+ *
+ * Purpose: Tests the "merge committed datatypes" feature of H5Ocopy, and
+ * uses the suggestion list feature
+ * (H5Padd_merge_committed_dtype_path).
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Thursday, November 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging committed datatypes with suggestions and reopen")
+ else
+ TESTING("H5Ocopy(): merging committed datatypes with suggestions")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /*
+ * Populate source file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type "a" */
+ if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type "b" */
+ if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * First copy dataset using "/b" as a suggestion, and verify that it uses
+ * datatype "b" in the destination file
+ */
+ /* Add datatype suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "b", get address */
+ if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Now free suggestions, copy dataset without any suggestions, and verify
+ * that it uses datatype "a" in the destination file
+ */
+ /* Free suggestions */
+ if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Delete destination dataset */
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "a", get address */
+ if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open dset 2 dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open committed dtype "b", get address */
+ if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_committed_dt_merge_sugg */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_committed_dt_merge_attr
+ *
+ * Purpose: Tests the "merge committed datatypes" feature of H5Ocopy, with
+ * an attribute using an anonymous committed type in the
+ * destination.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Thursday, November 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_committed_dt_merge_attr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t gid = -1; /* Group ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging committed datatypes with attributes and reopen")
+ else
+ TESTING("H5Ocopy(): merging committed datatypes with attributes")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /*
+ * Populate source file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ /* Create group */
+ if((gid = H5Gcreate2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* create anonymous committed data type */
+ if((H5Tcommit_anon(fid_dst, tid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create attribute at SRC file */
+ if((aid = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Awrite(aid, tid, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the attribute */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* close the group */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * Copy dataset and verify that it uses the same committed datatype as the
+ * already existing attribute in the destination file.
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open attribute dtype, get address */
+ if((aid = H5Aopen_by_name(fid_dst, NAME_GROUP_TOP, "attr", H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Aget_type(aid)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* Open dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Aclose(aid);
+ H5Gclose(gid);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_committed_dt_merge_attr */
+
+/*
+ * Defines used for the committed datatype tests
+ */
+#define SRC_ROOT_GROUP "src_root"
+#define ROOT_NDT_INT "root_ndt_int"
+#define GROUP_NDT_SHORT "group_ndt_short"
+
+#define SRC_GRP "src_grp"
+#define DST_GRP "dst_grp"
+#define DST_GRP2 "dst_grp2"
+
+#define SRC_NDT_SHORT "src_ndt_short"
+#define SRC_NDT_INT "src_ndt_int"
+#define SRC_NDT_INT2 "src_ndt_int2"
+#define SRC_NDT_FLOAT "src_ndt_float"
+#define SRC_NDT_DOUBLE "src_ndt_double"
+
+#define DST_NDT_SHORT "dst_ndt_short"
+#define DST_NDT_INT "dst_ndt_int"
+#define DST_NDT_FLOAT "dst_ndt_float"
+#define DST_NDT_DOUBLE "dst_ndt_double"
+
+#define SRC_NDT_DSET "src_ndt_dset"
+#define SRC_NDT_DSET2 "src_ndt_dset2"
+#define SRC_NDT_DSET3 "src_ndt_dset3"
+
+#define SRC_DSET "src_dset"
+#define SRC_DSET1 "src_dset1"
+
+#define SRC_ATTR "src_attr"
+
+#define DST_ATTR_ANON_SHORT "dst_attr_anon_short"
+#define DST_ATTR_ANON_INT "dst_attr_anon_int"
+
+#define DST_ATTR "dst_attr"
+#define DST_ATTR2 "dst_attr2"
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_cdt_hier_merge
+ *
+ * Purpose: Tests the "merge committed datatypes" feature of H5Ocopy:
+ * SRC file:
+ * Create committed datatypes at / and /g0
+ * Create datasets with native type and committed datatypes at /g0
+ * DST file:
+ * Create attributes with anonymous committed datatypes at /uncopied
+ *
+ * Copy / at SRC to DST
+ * Copy /g0 at SRC to DST
+ * Copy the datasets in /g0 at SRC to DST /uncopied
+ * Verify that committed datatypes are copied and merged correctly
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; January 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_cdt_hier_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t gid = -1; /* Group IDs */
+ hid_t f_tid = -1; /* Datatype ID for root group */
+ hid_t g_tid = -1; /* Datatype ID for group */
+ hid_t anon_tid = -1; /* Anonymous datatype */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ int i; /* Local index variable */
+ hsize_t dim1d[1]; /* dimension sizes */
+ int buf[DIM_SIZE_1]; /* Buffer for data */
+ haddr_t exp_addr_int, exp_addr_short; /* Expected object addresses */
+ H5O_info_t oinfo; /* Object info */
+ char src_filename[NAME_BUF_SIZE]; /* Source file name */
+ char dst_filename[NAME_BUF_SIZE]; /* Destination file name */
+
+ if(reopen)
+ TESTING("H5Ocopy(): hier. of committed datatypes and merging with reopen")
+ else
+ TESTING("H5Ocopy(): hier. of committed datatypes and merging ")
+
+ /* set initial data values */
+ for (i=0; i<DIM_SIZE_1; i++)
+ buf[i] = i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /*
+ * Populate source file
+ */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* create and commit committed datatype (int) to root group */
+ if((f_tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_src, ROOT_NDT_INT, f_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create group /g0 */
+ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create and commit committed datatype (short) to group /g0 */
+ if((g_tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR
+ if((H5Tcommit2(gid, GROUP_NDT_SHORT, g_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create dataset of native int in /g0 */
+ if((did = H5Dcreate2(gid, SRC_DSET1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* create dataset of committed datatype (short) in /g0 */
+ if((did = H5Dcreate2(gid, SRC_NDT_DSET2, g_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* create dataset of committed datatype (int) in /g0 */
+ if((did = H5Dcreate2(gid, SRC_NDT_DSET3, f_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the datatypes */
+ if(H5Tclose(f_tid) < 0) TEST_ERROR
+ if(H5Tclose(g_tid) < 0) TEST_ERROR
+
+ /* close group */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* create group /uncopied */
+ if((gid = H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create and commit anonymous datatype (short) to /uncopied */
+ if((anon_tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR
+ if((H5Tcommit_anon(gid, anon_tid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create attribute of anon ndt (short) in /uncopied */
+ if((aid = H5Acreate2(gid, DST_ATTR_ANON_SHORT, anon_tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* close the attribute */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(anon_tid) < 0) TEST_ERROR
+
+ /* create and commit anonymous datatype (int) to /uncopied */
+ if((anon_tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit_anon(gid, anon_tid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create attribute of anon ndt (int) in /uncopied */
+ if((aid = H5Acreate2(gid, DST_ATTR_ANON_INT, anon_tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* close the attribute */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(anon_tid) < 0) TEST_ERROR
+
+ /* close the group */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+ }
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* create ocpl and set merge committed datatype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * Test 1 : copy / in SRC file to DST file
+ */
+ if(H5Ocopy(fid_src, "/", fid_dst, SRC_ROOT_GROUP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* get address of committed datatype at root group */
+ if((tid = H5Topen2(fid_dst, SRC_ROOT_GROUP "/" ROOT_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr_int = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype at /g0 */
+ if((tid = H5Topen2(fid_dst, SRC_ROOT_GROUP NAME_GROUP_TOP "/" GROUP_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr_short = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* verify the datatype of first dataset is not committed */
+ if((did = H5Dopen2(fid_dst, SRC_ROOT_GROUP NAME_GROUP_TOP "/" SRC_DSET1, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Tcommitted(tid)) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for second dataset */
+ if((did = H5Dopen2(fid_dst, SRC_ROOT_GROUP NAME_GROUP_TOP "/" SRC_NDT_DSET2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_short) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for third dataset */
+ if((did = H5Dopen2(fid_dst, SRC_ROOT_GROUP NAME_GROUP_TOP "/" SRC_NDT_DSET3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_int) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /*
+ * Test 2: copy /g0 in SRC to DST
+ */
+ if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* get address of committed datatype at /g0 */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_TOP "/" GROUP_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_short) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* verify the datatype of first dataset is not committed */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP "/" SRC_DSET1, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Tcommitted(tid)) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for second dataset */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP "/" SRC_NDT_DSET2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_short) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for third dataset */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP "/" SRC_NDT_DSET3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_int) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /*
+ * Test 3: copy datsets in /g0 at SRC to DST group /uncopied
+ */
+ if(H5Ocopy(fid_src, NAME_GROUP_TOP "/" SRC_DSET1, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_DSET1, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ocopy(fid_src, NAME_GROUP_TOP "/" SRC_NDT_DSET2, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ocopy(fid_src, NAME_GROUP_TOP "/" SRC_NDT_DSET3, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open attribute with anon ndt (short), get address */
+ if((aid = H5Aopen_by_name(fid_dst, NAME_GROUP_UNCOPIED, DST_ATTR_ANON_SHORT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Aget_type(aid)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_short) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* Open attribute with anon ndt (int), get address */
+ if((aid = H5Aopen_by_name(fid_dst, NAME_GROUP_UNCOPIED, DST_ATTR_ANON_INT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Aget_type(aid)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_int) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* verify the datatype of first dataset is not committed */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_DSET1, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Tcommitted(tid)) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for second dataset */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_short) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for third dataset */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr_int) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Tclose(f_tid);
+ H5Tclose(g_tid);
+ H5Tclose(anon_tid);
+ H5Pclose(ocpypl_id);
+ H5Aclose(aid);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Gclose(gid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_cdt_hier_merge */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_cdt_merge_cdt
+ *
+ * Purpose: Tests the "merge committed datatypes" feature of H5Ocopy:
+ * SRC file:
+ * Create committed datatype (short)
+ * Create committed datatype (float)
+ * Create committed datatype (int), with attribute of ndt int
+ * Create committed datatype (double), with attribute of anon ndt short
+ * DST file:
+ * Create committed datatype (int)
+ * Create committed datatype (float), with attribute of native int
+ * Create committed datatype (double), with attribute of anon ndt short
+ *
+ * Copy / at SRC to DST
+ * Verify that committed datatypes are copied and merged correctly
+ *
+ * NOTE:
+ * Comparison of attributes are not implemented yet.
+ * Further tests will be added in the future.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; January 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */
+ hid_t tid3 = -1, tid4 = -1; /* Datatype IDs */
+ hid_t tid5 = -1, tid = -1; /* Datatype IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ hsize_t dim1d[1]; /* dimension sizes */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object addresses */
+ char src_filename[NAME_BUF_SIZE]; /* Source file name */
+ char dst_filename[NAME_BUF_SIZE]; /* Destination file name */
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging various committed datatypes with reopen")
+ else
+ TESTING("H5Ocopy(): merging various committed datatypes")
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /*
+ * Populate source file
+ */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* create committed datatype (short) */
+ if((tid1 = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_src, SRC_NDT_SHORT, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create committed datatype (float) */
+ if((tid2 = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_src, SRC_NDT_FLOAT, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create committed datatype (int) */
+ if((tid3 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_src, SRC_NDT_INT, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create an attribute of committed datatype (int); attach to committed datatype (int) */
+ if((aid = H5Acreate2(tid3, SRC_ATTR, tid3, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* create committed datatype (double) */
+ if((tid4 = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_src, SRC_NDT_DOUBLE, tid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an anonymous committed datatype (short) */
+ if((tid5 = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR
+ if((H5Tcommit_anon(fid_src, tid5, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute of anon ndt (short); attach to committed datatype (double) */
+ if((aid = H5Acreate2(tid4, SRC_ATTR, tid5, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* close the committed datatypes */
+ if(H5Tclose(tid1) < 0) TEST_ERROR
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+ if(H5Tclose(tid3) < 0) TEST_ERROR
+ if(H5Tclose(tid4) < 0) TEST_ERROR
+ if(H5Tclose(tid5) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* create committed datatype (integer) */
+ if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_INT, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create committed datatype (float) */
+ if((tid2 = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_FLOAT, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute of native integer; attach to committed datatype (float) */
+ if((aid = H5Acreate2(tid2, DST_ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* create committed datatype (double) */
+ if((tid3 = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_DOUBLE, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create anonymous committed datatype (short) */
+ if((tid4 = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR
+ if((H5Tcommit_anon(fid_dst, tid4, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute of anon ndt (short); attach to ndt (double) */
+ if((aid = H5Acreate2(tid3, DST_ATTR, tid4, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* close the committed datatypes */
+ if(H5Tclose(tid1) < 0) TEST_ERROR
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+ if(H5Tclose(tid3) < 0) TEST_ERROR
+ if(H5Tclose(tid4) < 0) TEST_ERROR
+
+ /* close the dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /* copy everything in SRC to DST */
+ if(H5Ocopy(fid_src, "/", fid_dst, SRC_ROOT_GROUP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /*
+ * Verification
+ */
+ /* get address of committed datatype: /src_root/src_ndt_double */
+ if((tid = H5Topen2(fid_dst, "/" SRC_ROOT_GROUP "/" SRC_NDT_DOUBLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype: /dst_ndt_double */
+ if((tid = H5Topen2(fid_dst, "/" DST_NDT_DOUBLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype: /src_root/src_ndt_float */
+ if((tid = H5Topen2(fid_dst, "/" SRC_ROOT_GROUP "/" SRC_NDT_FLOAT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype: /dst_ndt_float */
+ if((tid = H5Topen2(fid_dst, "/" DST_NDT_FLOAT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype: /src_root/src_ndt_int */
+ if((tid = H5Topen2(fid_dst, "/" SRC_ROOT_GROUP "/" SRC_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype: /dst_ndt_int */
+ if((tid = H5Topen2(fid_dst, "/" DST_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* get address of committed datatype: /src_root/src_ndt_short */
+ if((tid = H5Topen2(fid_dst, "/" SRC_ROOT_GROUP "/" SRC_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* open attribute; get its dtype; get dtype's address: /src_root/src_ndt_double/dst_attr */
+ if((aid = H5Aopen_by_name(fid_dst, "/" SRC_ROOT_GROUP "/" SRC_NDT_DOUBLE, DST_ATTR, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Aget_type(aid)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+
+ /* close the files */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the object copy property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(ocpypl_id);
+ H5Tclose(tid);
+ H5Tclose(tid1);
+ H5Tclose(tid2);
+ H5Tclose(tid3);
+ H5Tclose(tid4);
+ H5Tclose(tid5);
+ H5Aclose(aid);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_cdt_merge_cdt */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_cdt_merge_suggs
+ *
+ * Purpose: Tests the suggested searching paths feature (H5Padd_merge_committed_dtype_path)
+ * is correctly applied in merging the committed datatypes.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; January 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_cdt_merge_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging committed datatypes with suggestions and reopen")
+ else
+ TESTING("H5Ocopy(): merging committed datatypes with suggestions")
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /*
+ * Populate source file
+ */
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* create committed datatype: "/src_ndt_int" */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_src, SRC_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* create committed datatype: "/dst_ndt_int" */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Create a group /uncopied */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 1
+ */
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /* copy "/src_ndt_int" from SRC file to "/uncopied/src_ndt_int" at DST file */
+ if(H5Ocopy(fid_src, SRC_NDT_INT, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open committed dtype "/dst_ndt_int", get its address */
+ if((tid = H5Topen2(fid_dst, DST_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* check address of "/uncopied/src_ndt_int" */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 2
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* add committed datatype search suggestion: "/uncopied/src_ndt_int" */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT) < 0) TEST_ERROR
+
+ /* copy "/src_ndt_int" from SRC file to "/src_ndt_int" at DST file */
+ if(H5Ocopy(fid_src, SRC_NDT_INT, fid_dst, SRC_NDT_INT, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open committed dtype "/uncopied/src_ndt_int", get its address */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* check address of "/src_ndt_int" */
+ if((tid = H5Topen2(fid_dst, SRC_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 3
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* remove "/uncopied/src_ndt_int" from DST file */
+ if(H5Ldelete(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy "/src_ndt_int" from SRC file to "/uncopied/src_ndt_int" at DST file */
+ /* use default ocpypl_id -- without merging and suggestion */
+ if(H5Ocopy(fid_src, SRC_NDT_INT, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy "/src_ndt_int" from SRC file to "/src_ndt_int2" at DST file */
+ /* copy with merging and search suggestion: "/uncopied/src_ndt_int" */
+ if(H5Ocopy(fid_src, SRC_NDT_INT, fid_dst, SRC_NDT_INT2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "/uncopied/src_ndt_int", get its address */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* check address of "/src_ndt_int2" */
+ if((tid = H5Topen2(fid_dst, SRC_NDT_INT2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 4
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* add committed datatype search suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, DST_NDT_INT) < 0) TEST_ERROR
+
+ /* copy "src_ndt_int" from SRC file to "/uncopied/src_ndt_int2" at DST file */
+ /* copy with merging and search suggestion: "/dst_ndt_int, /uncopied/src_ndt_int" */
+ if(H5Ocopy(fid_src, SRC_NDT_INT, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "/dst_dt_int", get its address */
+ if((tid = H5Topen2(fid_dst, DST_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* check address of "/uncopied/src_ndt_int2" */
+ if((tid = H5Topen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_INT2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_cdt_merge_suggs */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_cdt_merge_dset_suggs
+ *
+ * Purpose: Tests the suggested searching paths feature (H5Padd_merge_committed_dtype_path)
+ * is correctly applied in merging the committed datatypes of datasets.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; Dec 12, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_cdt_merge_dset_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging committed datatypes of datasets with suggestions and reopen")
+ else
+ TESTING("H5Ocopy(): merging committed datatypes of datasets with suggestions")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /*
+ * Populate source file
+ */
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* create committed datatype: "/src_ndt_int" */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_src, SRC_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0] = DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create dataset */
+ if((did = H5Dcreate2(fid_src, SRC_NDT_DSET, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to dataset */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* create committed datatype: "/dst_ndt_int" */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create a group "/uncopied" */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /*
+ * Test 1
+ */
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /* copy "/src_ndt_dset" from SRC file to "/uncopied/src_ndt_dset" at DST file */
+ if(H5Ocopy(fid_src, SRC_NDT_DSET, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "/dst_ndt_int", get its address */
+ if((tid = H5Topen2(fid_dst, DST_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* check address of datatype for the copied dataset: "/uncopied/src_ndt_dset" */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 2
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* add committed datatype search suggestion: "/uncopied/src_ndt_dset" */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET) < 0) TEST_ERROR
+
+ /* copy "/src_ndt_dset" from SRC file to "/src_ndt_dset" at DST file */
+ if(H5Ocopy(fid_src, SRC_NDT_DSET, fid_dst, SRC_NDT_DSET, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype dataset "/uncopied/src_ndt_dset", get its datatype address */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for the copied dataset: "/src_ndt_dset" */
+ if((did = H5Dopen2(fid_dst, SRC_NDT_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 3
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* remove "/uncopied/src_ndt_dset" */
+ if(H5Ldelete(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy "src_ndt_dset" from SRC file to "/uncopied/src_ndt_dset" at DST file */
+ /* use default ocpypl_id -- without merging and suggestion */
+ if(H5Ocopy(fid_src, SRC_NDT_DSET, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy "src_ndt_dset" from SRC file to "/src_ndt_dset2" at DST file */
+ /* use merging and suggested searching path: "/uncopied/src_ndt_dset" */
+ if(H5Ocopy(fid_src, SRC_NDT_DSET, fid_dst, SRC_NDT_DSET2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open the copied dataset: /uncopied/src_ndt_dset", get its address */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for the copied dataset: "/src_ndt_dset2" */
+ if((did = H5Dopen2(fid_dst, SRC_NDT_DSET2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 4
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* add committed datatype search suggestion: "/src_ndt_dset" */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, SRC_NDT_DSET) < 0) TEST_ERROR
+
+ /* copy /src_ndt_dset from SRC file to /uncopied/src_ndt_dset2 at DST */
+ /* use merging and suggested search paths: "/src_ndt_dset, /uncopied/src_ndt_dset" */
+ if(H5Ocopy(fid_src, SRC_NDT_DSET, fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open the copied dataset: "/src_ndt_dset", get its datatype address */
+ if((did = H5Dopen2(fid_dst, SRC_NDT_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* check address of datatype for the copied dataset: /uncopied/src_ndt_dset2 */
+ if((did = H5Dopen2(fid_dst, NAME_GROUP_UNCOPIED "/" SRC_NDT_DSET2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_cdt_merge_dset_suggs */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_cdt_merge_all_suggs
+ *
+ * Purpose: Tests the merging committed datatype + search suggestion feature.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; January 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_cdt_merge_all_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t gid = -1; /* Group ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t exp_did = -1; /* Dataset ID */
+ hid_t tid_short = -1; /* Datatype ID */
+ hid_t exp_tid; /* Expected datatype ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ if(reopen)
+ TESTING("H5Ocopy(): merging different committed datatypes with suggestions and reopen")
+ else
+ TESTING("H5Ocopy(): merging different committed datatypes with suggestions")
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /*
+ * Populate source file
+ */
+
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* set dataspace dimension, create dataspace */
+ dim1d[0] = DIM_SIZE_1;
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create a group */
+ if((gid = H5Gcreate2(fid_src, SRC_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create committed datatype in group */
+ if((tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR
+ if((H5Tcommit2(gid, SRC_NDT_SHORT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create first dataset in group */
+ if((did = H5Dcreate2(gid, SRC_NDT_DSET, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing */
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create committed datatype in group */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit2(gid, SRC_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create second dataset in group */
+ if((did = H5Dcreate2(gid, SRC_NDT_DSET2, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing */
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create third dataset in group */
+ if((did = H5Dcreate2(gid, SRC_DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* get datatype */
+ if((tid_short = H5Topen2(fid_src, "/" SRC_GRP "/" SRC_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute attached to the dataset */
+ if((aid = H5Acreate2(did, SRC_ATTR, tid_short, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Tclose(tid_short) < 0) TEST_ERROR
+
+ /* close the group */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* close the dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /*
+ * Populate DST file
+ */
+
+ /* create DST file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* set dataspace dimension, create dataspace */
+ dim1d[0] = DIM_SIZE_2;
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create committed datatype in root group */
+ if((tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_SHORT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create committed datatype in root group */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute attached to committed datatype */
+ if((aid = H5Acreate2(tid, DST_ATTR, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+
+ /* create committed datatype in root group */
+ if((tid = H5Tcopy(H5T_NATIVE_FLOAT)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_FLOAT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute attached to committed datatype */
+ if((aid = H5Acreate2(tid, DST_ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create a group */
+ if((gid = H5Gcreate2(fid_dst, DST_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create a committed datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((H5Tcommit2(gid, DST_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute attached to committed datatype */
+ if((aid = H5Acreate2(gid, DST_ATTR, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create an attribute attached to group */
+ if((aid = H5Acreate2(gid, DST_ATTR2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* create a group */
+ if((gid = H5Gcreate2(fid_dst, DST_GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create a committed datatype in group */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+ if((H5Tcommit2(gid, DST_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute attached to group */
+ if((aid = H5Acreate2(gid, DST_ATTR, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create a committed datatype in group */
+ if((tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0)TEST_ERROR
+ if((H5Tcommit2(gid, DST_NDT_SHORT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* create a committed datatype at root group */
+ if((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0)TEST_ERROR
+ if((H5Tcommit2(fid_dst, DST_NDT_DOUBLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* get datatype */
+ if((tid_short = H5Topen2(fid_dst, "/" DST_GRP2 "/" DST_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create an attribute attached to committed datatype */
+ if((aid = H5Acreate2(tid, DST_ATTR, tid_short, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing */
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid_short) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 1
+ */
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /* copy "/src_grp/src_ndt_dset2" from SRC file to DST file */
+ if(H5Ocopy(fid_src, "/" SRC_GRP "/" SRC_NDT_DSET2, fid_dst, "A_src_dset2", ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* get datatype for attribute attached to the group */
+ if((aid = H5Aopen_by_name(fid_dst, DST_GRP, DST_ATTR, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((exp_tid = H5Aget_type(aid)) < 0) TEST_ERROR
+
+ /* open datatype of dataset */
+ if((did = H5Dopen2(fid_dst, "A_src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(exp_tid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 2
+ */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* add committed datatype search suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/" DST_GRP2) < 0) TEST_ERROR
+
+ /* copy "/src_grp/src_ndt_dset2" from SRC file to DST file */
+ if(H5Ocopy(fid_src, "/" SRC_GRP "/" SRC_NDT_DSET2, fid_dst, "B_src_dset2", ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* get datatype for attribute attached to the group */
+ if((aid = H5Aopen_by_name(fid_dst, DST_GRP2, DST_ATTR, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((exp_tid = H5Aget_type(aid)) < 0) TEST_ERROR
+
+ /* open datatype of dataset */
+ if((did = H5Dopen2(fid_dst, "B_src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(exp_tid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 3
+ */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* add another committed datatype search suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/" DST_GRP "/" DST_NDT_INT) < 0) TEST_ERROR
+
+ /* copy "/src_grp/src_ndt_dset2" from SRC file to DST file */
+ if(H5Ocopy(fid_src, "/" SRC_GRP "/" SRC_NDT_DSET2, fid_dst, "C_src_dset2", ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open committed dtype "/dst_grp/dst_dt_int", get its address */
+ if((exp_tid = H5Topen2(fid_dst, "/" DST_GRP "/" DST_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open datatype of dataset */
+ if((did = H5Dopen2(fid_dst, "C_src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(exp_tid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 4
+ */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* delete the group */
+ if(H5Ldelete(fid_dst, "/" DST_GRP, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* free the search suggestion paths */
+ if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR
+
+ /* copy "/src_grp/src_ndt_dset2" from SRC file to DST file */
+ if(H5Ocopy(fid_src, "/" SRC_GRP "/" SRC_NDT_DSET2, fid_dst, "D_src_dset2", ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open datatype of dataset */
+ if((exp_did = H5Dopen2(fid_dst, "A_src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((exp_tid = H5Dget_type(exp_did)) < 0) TEST_ERROR
+
+ /* Open datatype of dataset */
+ if((did = H5Dopen2(fid_dst, "C_src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* open datatype of dataset */
+ if((did = H5Dopen2(fid_dst, "D_src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(exp_tid) < 0) TEST_ERROR
+ if(H5Dclose(exp_did) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 5
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Add committed datatype search suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/" DST_NDT_DOUBLE) < 0) TEST_ERROR
+
+ /* copy "/src_grp/src_ndt_dset" from SRC file to DST file */
+ if(H5Ocopy(fid_src, "/" SRC_GRP "/" SRC_NDT_DSET, fid_dst, "A_src_dset", ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open attribute's dtype attached to committed datatype /dst_ndt_double */
+ if((aid = H5Aopen_by_name(fid_dst, DST_NDT_DOUBLE, DST_ATTR, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((exp_tid = H5Aget_type(aid)) < 0) TEST_ERROR
+
+ /* Open datatype of dataset, check address */
+ if((did = H5Dopen2(fid_dst, "A_src_dset", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Tclose(exp_tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Test 6
+ */
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Add committed datatype search suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/" DST_NDT_SHORT) < 0) TEST_ERROR
+
+ /* copy "/src_grp/src_ndt_dset" from SRC file to DST file */
+ if(H5Ocopy(fid_src, "/" SRC_GRP "/" SRC_NDT_DSET, fid_dst, "B_src_dset", ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* open committed dtype "/dst_ndt_short" */
+ if((exp_tid = H5Topen2(fid_dst, "/" DST_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open datatype of dataset, check address */
+ if((did = H5Dopen2(fid_dst, "B_src_dset", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+
+ /* should be the same */
+ if(!H5Tequal(exp_tid, tid)) TEST_ERROR
+
+ /* closing */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Tclose(exp_tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Tclose(tid_short);
+ H5Tclose(exp_tid);
+ H5Dclose(did);
+ H5Dclose(exp_did);
+ H5Aclose(aid);
+ H5Sclose(sid);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_cdt_merge_all_suggs */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_set_mcdt_search_cb
+ *
+ * Purpose: Tests the "H5Pset_mcdt_search_cb" feature of H5Ocopy to
+ * stop or continue the search of global list
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; January 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+/* User data struct for the callback */
+typedef struct mcdt_search_cb_ud {
+ H5O_mcdt_search_ret_t search_action; /* Return value for callback */
+ unsigned called; /* # of times callback has been called */
+} mcdt_search_cb_ud;
+
+/* The user callback function */
+static H5O_mcdt_search_ret_t
+mcdt_search_cb(void *_udata)
+{
+ mcdt_search_cb_ud *udata = (mcdt_search_cb_ud *)_udata;
+
+ udata->called++;
+ return(udata->search_action);
+} /* mcdt_search_cb() */
+
+static int
+test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ H5O_info_t oinfo; /* Object info */
+ haddr_t exp_addr; /* Expected object address */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+ mcdt_search_cb_ud cb_udata; /* User data for callback */
+
+ if(reopen)
+ TESTING("H5Ocopy(): H5Pset_mcdt_search_cb and reopen")
+ else
+ TESTING("H5Ocopy(): H5Pset_mcdt_search_cb")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /*
+ * Populate source file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* named data type */
+ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create an uncopied group in destination file */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type "a" */
+ if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type "b" */
+ if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * First copy dataset using "/b" as a suggestion, and verify that it uses
+ * datatype "b" in the destination file
+ */
+ /* Add datatype suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "b", get address */
+ if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open dset dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Set callback to continue the search
+ */
+ cb_udata.search_action = H5O_MCDT_SEARCH_CONT;
+ cb_udata.called = 0;
+
+ /* Free suggestions */
+ if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR
+
+ /* Add datatype suggestion to group "/uncopied" */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED) < 0) TEST_ERROR
+
+ /* Continue the global search */
+ if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cb, &cb_udata) < 0)
+ TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Verify callback has been called exactly once */
+ if(cb_udata.called != 1) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "a", get address */
+ if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open copied dataset and its dtype, check address */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr != exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /*
+ * Stop the search, default action is to create an anonymous committed datatype
+ */
+ cb_udata.search_action = H5O_MCDT_SEARCH_STOP;
+ cb_udata.called = 0;
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Verify callback has been called exactly once */
+ if(cb_udata.called != 1) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "a", get address */
+ if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open the copied dataset and get its dtype, addresses should not be equal */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr == exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open committed dtype "b", get address */
+ if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open the copied dataset and get its dtype, addresses should not be equal */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr == exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /*
+ * Stop the search, default action is to create an anonymous committed datatype.
+ * Disable suggestion list.
+ */
+ cb_udata.search_action = H5O_MCDT_SEARCH_STOP;
+ cb_udata.called = 0;
+
+ /* Free suggestions */
+ if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Delete dataset */
+ if(H5Ldelete(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Verify callback has been called exactly once */
+ if(cb_udata.called != 1) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Open committed dtype "a", get address */
+ if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open the copied dataset and get its dtype, addresses should not be equal */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr == exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Open committed dtype "b", get address */
+ if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ exp_addr = oinfo.addr;
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* Open the copied dataset and get its dtype, addresses should not be equal */
+ if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Dget_type(did)) < 0) TEST_ERROR
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR
+ if(oinfo.addr == exp_addr) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_set_mcdt_search_cb */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_set_get_mcdt_cb
+ *
+ * Purpose: Tests for the "H5Pset/get_mcdt_search_cb" feature of H5Ocopy.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi; January 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/* The user callback functions */
+static H5O_mcdt_search_ret_t
+mcdt_search_cbA(void *_udata)
+{
+ H5O_mcdt_search_ret_t *action = (H5O_mcdt_search_ret_t *)_udata;
+
+ return(*action);
+} /* mcdt_search_cb() */
+
+static H5O_mcdt_search_ret_t
+mcdt_search_cbB(void *_udata)
+{
+ H5O_mcdt_search_ret_t *action = (H5O_mcdt_search_ret_t *)_udata;
+
+ return(*action);
+} /* mnt_search_cb() */
+
+/* The main test function */
+static int
+test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
+ hid_t dst_fapl, hbool_t reopen)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t ocpypl_id = -1; /* Object copy plist ID */
+ unsigned int i; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ int buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+ H5O_mcdt_search_cb_t mcdt_cb = NULL; /* The callback function */
+ H5O_mcdt_search_ret_t mcdt_udataA; /* User data for callback */
+ H5O_mcdt_search_ret_t mcdt_udataB; /* User data for callback */
+ H5O_mcdt_search_ret_t *mcdt_udata_p = NULL; /* Pointer to user data for callback */
+
+ if(reopen)
+ TESTING("H5Ocopy(): H5Pset/get_mcdt_search_cb and reopen")
+ else
+ TESTING("H5Ocopy(): H5Pset/get_mcdt_search_cb")
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++)
+ buf[i] = (int)i;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /*
+ * Populate source file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type */
+ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create an uncopied group in destination file */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /*
+ * Populate destination file
+ */
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type "a" */
+ if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* committed data type "b" */
+ if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
+
+ /* Create ocpl and set merge committed dtype flag */
+ if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+ if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR
+
+ /*
+ * First copy dataset using "/b" as a suggestion, and verify that it uses
+ * datatype "b" in the destination file
+ */
+ /* Add datatype suggestion */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ /* Verify "get" routine functionality */
+ if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR
+
+ if(mcdt_cb != NULL) TEST_ERROR
+ if(mcdt_udata_p != NULL) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /*
+ * Set callback to continue the search
+ */
+ mcdt_udataA = H5O_MCDT_SEARCH_CONT;
+
+ /* Free suggestions */
+ if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR
+
+ /* Add datatype suggestion to group "/uncopied" */
+ if(H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED) < 0) TEST_ERROR
+
+ /* Continue the global search */
+ if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbA, &mcdt_udataA) < 0)
+ TEST_ERROR
+
+ /* open the destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ mcdt_cb = NULL;
+ mcdt_udata_p = NULL;
+
+ /* Verify "get" routine functionality */
+ if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR
+
+ if(mcdt_cb != mcdt_search_cbA) TEST_ERROR
+ if(mcdt_udata_p != &mcdt_udataA) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+
+ /*
+ * Stop the search, default action is to create an anonymous committed datatype
+ */
+ mcdt_udataB = H5O_MCDT_SEARCH_STOP;
+
+ if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbA, &mcdt_udataB) < 0)
+ TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ mcdt_cb = NULL;
+ mcdt_udata_p = NULL;
+
+ /* Verify "get" routine functionality */
+ if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR
+
+ if(mcdt_cb != mcdt_search_cbA) TEST_ERROR
+ if(mcdt_udata_p != &mcdt_udataB) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* Free suggestions */
+ if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR
+
+ if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbB, &mcdt_udataB) < 0)
+ TEST_ERROR
+
+ /* open destination file */
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR
+
+ /* Delete dataset */
+ if(H5Ldelete(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* copy SRC dset to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ if(reopen) {
+ /* Reopen file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR
+ } /* end if */
+
+ mcdt_cb = NULL;
+ mcdt_udata_p = NULL;
+
+ /* Verify "get" routine functionality */
+ if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR
+
+ if(mcdt_cb != mcdt_search_cbB) TEST_ERROR
+ if(mcdt_udata_p != &mcdt_udataB) TEST_ERROR
+
+ /* Close destination file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close property list */
+ if(H5Pclose(ocpypl_id) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid_src);
+ H5Fclose(fid_dst);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(ocpypl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_set_get_mcdt_search_cb */
+
+
+/*-------------------------------------------------------------------------
* Function: test_copy_option
*
* Purpose: Create a group in SRC file and copy it to DST file
@@ -8919,6 +12273,337 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_open
+ *
+ * Purpose: To ensure that H5Ocopy() copies data of opened dataset correctly.
+ * This is for bug fix HDFFV-7853.
+ *
+ * Test Case 1:
+ * Create a dataset with attributes in SRC file
+ * Copy the opened dataset to another location in the same file
+ * Copy the opened dataset to DST file
+ * Close the dataset
+ *
+ * Test Case 2:
+ * Reopen the dataset, write new data to the dataset
+ * Copy the opened dataset to another location in the same file
+ * Copy the opened dataset to to DST file
+ * Close the dataset
+ *
+ * Test Case 3:
+ * Create a committed datatype
+ * Create a dataset with the committed datatype in SRC file
+ * Open the committed datatype
+ * Copy the opened dataset (with the opened committed datatype) to another location in the same file
+ * Copy the opened dataset (with the opened committed datatype) to DST file
+ * Close the dataset and the committed datatype
+ *
+ * Test Case 4:
+ * Create a group with attributes, create a dataset in the group
+ * Copy the opened group (together with the opened dataset) to another location in the same file
+ * Copy the opened group (together with the opened dataset) to DST file
+ * Close the group and the dataset
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Vailin Choi
+ * Feb 7, 2012
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hid_t gid = -1, gid2 = -1; /* Group IDs */
+ hid_t ocpl = -1; /* Object copy property list ID */
+ int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ int newbuf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ hsize_t dim2d[2]; /* Dataset dimensions */
+ hbool_t copy_open_obj = TRUE; /* Property to indicate we are copying open objects */
+ int i, j; /* local index variables */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): copying objects while opened");
+
+ /* Initialize write buffer */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ buf[i][j] = 10000 + 100*i+j;
+
+ /* Initialize another write buffer */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ newbuf[i][j] = 100*i+j;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim2d[0] = DIM_SIZE_1;
+ dim2d[1] = DIM_SIZE_2;
+
+ /* create 2D dataspace */
+ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR
+
+ /* create 2D int dataset in SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* attach attributes to the dataset */
+ if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+
+ /* Create object copy property list, for passing private property to
+ * dataset comparison routine
+ */
+ /* Create the object copy plist */
+ if((ocpl = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
+
+ /* Set the private property */
+ if(H5Pinsert2(ocpl, COPY_OPEN_OBJ_NAME, COPY_OPEN_OBJ_SIZE, &copy_open_obj, NULL, NULL, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
+
+
+
+ /*
+ * Test case 1
+ */
+
+ /*
+ * Copy within the same file
+ */
+ /* copy the opened dataset to another location in SRC file */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_src, NAME_DATASET_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied dataset */
+ if((did2 = H5Dopen2(fid_src, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, ocpl, buf) != TRUE) TEST_ERROR
+
+ /* close the copied dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /*
+ * Copy to another file
+ */
+ /* copy the opened dataset from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied dataset in DST file */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, ocpl, buf) != TRUE) TEST_ERROR
+
+ /* close the copied dataset in DST file */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the dataset in SRC file */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /*
+ * Test case 2
+ */
+ /* reopen the dataset in SRC file */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write another set of data to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, newbuf) < 0) TEST_ERROR
+
+ /*
+ * Copy within the same file
+ */
+ /* copy the opened dataset to another location in SRC file */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_src, "NEW_DATASET", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied dataset */
+ if((did2 = H5Dopen2(fid_src, "NEW_DATASET", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, ocpl, newbuf) != TRUE) TEST_ERROR
+
+ /* close the copied dataset in SRC file */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+ /*
+ * Copy to another file
+ */
+ /* copy the opened dataset from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, "NEW_DATASET", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied dataset in DST file */
+ if((did2 = H5Dopen2(fid_dst, "NEW_DATASET", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, ocpl, newbuf) != TRUE) TEST_ERROR
+
+ /* close the copied dataset in DST file */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the dataset at SRC file */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /*
+ * Test case 3
+ */
+
+ /* make a copy of the datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR
+
+ /* commit the datatype */
+ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close the datatype */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* open the committed datatype */
+ tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT);
+
+ /* create 2D dataset with the opened committed datatype in SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_NAMED_DTYPE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to the dataset */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /*
+ * Copy within the same file
+ */
+ /* copy the opened dataset (with the opened committed datatype) to another location in SRC file */
+ if(H5Ocopy(fid_src, NAME_DATASET_NAMED_DTYPE, fid_src, NAME_DATASET_NAMED_DTYPE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied dataset */
+ if((did2 = H5Dopen2(fid_src, NAME_DATASET_NAMED_DTYPE2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, ocpl, buf) != TRUE) TEST_ERROR
+
+ /* close the copied dataset in SRC file */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /*
+ * Copy to another file
+ */
+ /* copy the opened dataset (with the opened committed datatype) from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_NAMED_DTYPE, fid_dst, NAME_DATASET_NAMED_DTYPE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied dataset in DST file */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_NAMED_DTYPE2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, ocpl, buf) != TRUE) TEST_ERROR
+
+ /* close the copied dataset in DST file */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the dataset at SRC file */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the committed datatype at SRC file */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /*
+ * Test case 4
+ */
+ /* create a group in SRC file */
+ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* attach attributes to the group */
+ if(test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* create 2D int dataset in the group at SRC file */
+ if((did = H5Dcreate2(gid, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+ /*
+ * Copy within the same file
+ */
+ /* copy the opened group (together with opened dataset) to another location in SRC file */
+ if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_src, "COPIED_GROUP", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied group at SRC */
+ if((gid2 = H5Gopen2(fid_src, "COPIED_GROUP", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the groups are equal */
+ if(compare_groups(gid, gid2, ocpl, -1, 0) != TRUE) TEST_ERROR
+
+ /* close the DST dataset */
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+
+ /*
+ * Copy to another file
+ */
+ /* copy the opened group (together with opened dataset) to DST file */
+ if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, "COPIED_GROUP", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the copied group at DST */
+ if((gid2 = H5Gopen2(fid_dst, "COPIED_GROUP", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the groups are equal */
+ if(compare_groups(gid, gid2, ocpl, -1, 0) != TRUE) TEST_ERROR
+
+ /* close the group in DST file */
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+
+ /* close the group in SRC file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* close the dataset in SRC file */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* close the object copy property list */
+ if(H5Pclose(ocpl) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Dclose(did2);
+ H5Sclose(sid);
+ H5Gclose(gid);
+ H5Gclose(gid2);
+ H5Pclose(ocpl);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_open */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test H5Ocopy()
@@ -8945,6 +12630,7 @@ main(void)
unsigned max_compact, min_dense;
int configuration; /* Configuration of tests. */
int ExpressMode;
+ hbool_t same_file; /* Whether to run tests that only use one file */
/* Setup */
h5_reset();
@@ -8977,6 +12663,11 @@ main(void)
hid_t fcpl_src;
hid_t fcpl_dst;
+ /* Start with same_file == TRUE. Use source file settings for these
+ * tests. Don't run with a non-default destination file setting, as
+ * destination settings have no effect. */
+ same_file = TRUE;
+
/* No need to test dense attributes with old format */
if(!(configuration & CONFIG_SRC_NEW_FORMAT) && (configuration & CONFIG_DENSE))
continue;
@@ -8993,6 +12684,7 @@ main(void)
if(configuration & CONFIG_SHARE_DST) {
puts("Testing with shared dst messages:");
fcpl_dst = fcpl_shared;
+ same_file = FALSE;
}
else {
puts("Testing without shared dst messages:");
@@ -9015,7 +12707,7 @@ main(void)
}
} /* end if */
else {
- puts("Testing with oldest file format for source file:");
+ puts("Testing with oldest file format for source file:");
src_fapl = fapl;
num_attributes_g = 4;
} /* end else */
@@ -9024,6 +12716,7 @@ main(void)
if(configuration & CONFIG_DST_NEW_FORMAT) {
puts("Testing with latest format for destination file:");
dst_fapl = fapl2;
+ same_file = FALSE;
} /* end if */
else {
puts("Testing with oldest file format for destination file:");
@@ -9060,6 +12753,8 @@ main(void)
nerrors += test_copy_named_datatype_attr_self(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
+ nerrors += test_copy_attr_crt_order(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
+
nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl,
H5O_COPY_WITHOUT_ATTR_FLAG,
FALSE, "H5Ocopy(): without attributes");
@@ -9087,14 +12782,37 @@ main(void)
nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl,
H5O_COPY_WITHOUT_ATTR_FLAG | H5O_COPY_PRESERVE_NULL_FLAG,
TRUE, "H5Ocopy(): preserve NULL messages");
+ nerrors += test_copy_dataset_open(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Tests that do not use attributes and do not need to be tested
* multiple times for different attribute configurations */
if(configuration < CONFIG_DENSE) {
+ hbool_t reopen;
+
nerrors += test_copy_named_datatype(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_named_datatype_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_named_datatype_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
+ /* Loop over reopening the file */
+ for(reopen = FALSE; reopen <= TRUE; reopen++) {
+ nerrors += test_copy_committed_datatype_merge(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+
+ if(same_file)
+ nerrors += test_copy_committed_datatype_merge_same_file(fcpl_src, src_fapl, reopen);
+
+ nerrors += test_copy_committed_dt_merge_sugg(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_committed_dt_merge_attr(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+
+ /* tests added for merging committed datatypes + suggestions + callback */
+ nerrors += test_copy_cdt_hier_merge(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_cdt_merge_cdt(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_cdt_merge_suggs(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_cdt_merge_dset_suggs(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_cdt_merge_all_suggs(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_set_mcdt_search_cb(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ nerrors += test_copy_set_get_mcdt_search_cb(fcpl_src, fcpl_dst, src_fapl, dst_fapl, reopen);
+ } /* end for */
+
nerrors += test_copy_dataset_external(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_named_dtype(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_named_dtype_hier(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
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/swmr_sparse_writer.c b/test/swmr_sparse_writer.c
index 97e2674..7af71ba 100644
--- a/test/swmr_sparse_writer.c
+++ b/test/swmr_sparse_writer.c
@@ -237,7 +237,7 @@ usage(void)
int main(int argc, const char *argv[])
{
- hid_t fid; /* File ID for file opened */\
+ hid_t fid; /* File ID for file opened */
long nrecords = 0; /* # of records to append */
long flush_count = 1000; /* # of records to write between flushing file */
unsigned verbose = 1; /* Whether to emit some informational messages */