diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 3 | ||||
-rw-r--r-- | test/Makefile.am | 14 | ||||
-rw-r--r-- | test/Makefile.in | 89 | ||||
-rw-r--r-- | test/bittests.c | 104 | ||||
-rw-r--r-- | test/cmpd_dset.c | 2 | ||||
-rw-r--r-- | test/dt_arith.c | 114 | ||||
-rw-r--r-- | test/dtypes.c | 5 | ||||
-rw-r--r-- | test/external.c | 6 | ||||
-rw-r--r-- | test/fheap.c | 132 | ||||
-rw-r--r-- | test/file_image.c | 1335 | ||||
-rw-r--r-- | test/file_image_core_test.h5 | bin | 0 -> 18528 bytes | |||
-rw-r--r-- | test/gen_file_image.c | 91 | ||||
-rw-r--r-- | test/istore.c | 27 | ||||
-rw-r--r-- | test/mf.c | 50 | ||||
-rw-r--r-- | test/objcopy.c | 3705 | ||||
-rw-r--r-- | test/testfiles/error_test_1 | 6 | ||||
-rw-r--r-- | test/tgenprop.c | 42 | ||||
-rw-r--r-- | test/tmisc.c | 84 | ||||
-rw-r--r-- | test/vfd.c | 3 |
19 files changed, 5590 insertions, 222 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/Makefile.am b/test/Makefile.am index afc1b37..cb56d52 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -42,7 +42,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 # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. @@ -63,7 +63,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_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) @@ -108,11 +108,11 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ copy_dcpl_newfile.h5 extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ - sys_file1 tfile[1-5].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \ + sys_file1 tfile[1-6].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \ stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ - stdio.h5 sec2.h5 dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 \ + stdio.h5 sec2.h5 dtypes[0-9].h5 dtypes1[0].h5 dt_arith[1-2].h5 tattr.h5 \ tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \ fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \ trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 flush.h5 \ @@ -125,8 +125,10 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \ - new_multi_file_v16-s.h5 + earray.h5 efc[0-5].h5 log_vfd_out.log \ + new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ + split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ + file_image_core_test.h5.copy # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ diff --git a/test/Makefile.in b/test/Makefile.in index 6e716bc..ede709c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -92,7 +92,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_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ @@ -100,7 +101,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 = $(noinst_PROGRAMS) accum_SOURCES = accum.c accum_OBJECTS = accum.$(OBJEXT) @@ -198,6 +200,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) @@ -234,6 +240,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) @@ -418,10 +428,11 @@ 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 freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \ - gen_deflate.c gen_filespace.c gen_filters.c gen_new_array.c \ - gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \ + external.c farray.c fheap.c file_image.c fillval.c \ + filter_fail.c flush1.c flush2.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_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 \ @@ -432,17 +443,17 @@ 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 freespace.c gen_bad_ohdr.c \ - gen_bogus.c gen_cross.c gen_deflate.c gen_filespace.c \ - gen_filters.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 \ - tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c vfd.c + error_test.c extend.c external.c farray.c fheap.c file_image.c \ + fillval.c filter_fail.c flush1.c flush2.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_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 tcheck_version.c $(testhdf5_SOURCES) \ + testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -739,25 +750,27 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ copy_dcpl_newfile.h5 extend.h5 istore.h5 extlinks*.h5 \ - frspace.h5 links*.h5 sys_file1 tfile[1-5].h5 th5s[1-4].h5 \ + frspace.h5 links*.h5 sys_file1 tfile[1-6].h5 th5s[1-4].h5 \ lheap.h5 fheap.h5 ohdr.h5 stab.h5 extern_[1-3].h5 \ extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] links.h5 \ links[0-6]*.h5 extlinks[0-15].h5 tmp big.data \ big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \ - dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \ - unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \ - mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \ - tvlstr.h5 tvlstr2.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 \ - tarray1.h5 tgenprop.h5 tmisc[0-9]*.h5 set_extent[1-5].h5 \ - ext[12].bin getname.h5 getname[1-3].h5 sec2_file.h5 \ - direct_file.h5 family_file000[0-3][0-9].h5 \ - new_family_v16_000[0-3][0-9].h5 multi_file-[rs].h5 core_file \ - new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \ - err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \ - tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \ - objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \ - app_ref.h5 farray.h5 earray.h5 efc[0-5].h5 log_vfd_out.log \ - new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 + dtypes[0-9].h5 dtypes1[0].h5 dt_arith[1-2].h5 tattr.h5 \ + tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \ + fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 \ + ttime.h5 trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 \ + flush.h5 enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \ + tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin getname.h5 \ + getname[1-3].h5 sec2_file.h5 direct_file.h5 \ + family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ + multi_file-[rs].h5 core_file new_move_[ab].h5 ntypes.h5 \ + dangle.h5 error_test.h5 err_compat.h5 dtransform.h5 \ + test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ + unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ + objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ + earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \ + new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \ + split_get_file_image_test-r.h5 file_image_core_test.h5.copy INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat @@ -778,7 +791,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 @@ -791,7 +804,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_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. @@ -978,6 +991,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) @@ -1005,6 +1021,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) @@ -1145,6 +1164,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@ @@ -1154,6 +1174,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_new_array.Po@am__quote@ diff --git a/test/bittests.c b/test/bittests.c index f063cee..c527bb8 100644 --- a/test/bittests.c +++ b/test/bittests.c @@ -56,13 +56,13 @@ test_find (void) /* The zero length buffer */ HDmemset(v1, 0xaa, sizeof v1); - n = H5T_bit_find(v1, (size_t)0, (size_t)0, H5T_BIT_LSB, TRUE); + n = H5T__bit_find(v1, (size_t)0, (size_t)0, H5T_BIT_LSB, TRUE); if(-1 != n) { H5_FAILED(); puts (" Zero length test failed (lsb)!"); goto failed; } - n = H5T_bit_find(v1, (size_t)0, (size_t)0, H5T_BIT_MSB, TRUE); + n = H5T__bit_find(v1, (size_t)0, (size_t)0, H5T_BIT_MSB, TRUE); if(-1 != n) { H5_FAILED(); puts (" Zero length test failed (msb)!"); @@ -72,13 +72,13 @@ test_find (void) /* The zero buffer */ HDmemset(v1, 0, sizeof v1); - n = H5T_bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); if(-1 != n) { H5_FAILED(); puts (" Zero buffer test failed (lsb)!"); goto failed; } - n = H5T_bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); if(-1 != n) { H5_FAILED(); puts (" Zero buffer test failed (msb)!"); @@ -89,13 +89,13 @@ test_find (void) for(i = 0; i < 8 * (int)sizeof(v1); i++) { HDmemset(v1, 0, sizeof v1); v1[i / 8] = 1 << (i % 8); - n = H5T_bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); if((ssize_t)i != n) { H5_FAILED(); printf (" Test for set bit %d failed (lsb)!\n", i); goto failed; } - n = H5T_bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); if((ssize_t)i != n) { H5_FAILED(); printf (" Test for set bit %d failed (msb)!\n", i); @@ -105,13 +105,13 @@ test_find (void) /* The one buffer */ HDmemset(v1, 0xff, sizeof v1); - n = H5T_bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, FALSE); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, FALSE); if(-1 != n) { H5_FAILED(); puts (" One buffer test failed (lsb)!"); goto failed; } - n = H5T_bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, FALSE); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, FALSE); if(-1 != n) { H5_FAILED(); puts (" One buffer test failed (msb)!"); @@ -122,13 +122,13 @@ test_find (void) for (i=0; i<8*(int)sizeof(v1); i++) { memset (v1, 0xff, sizeof v1); v1[i/8] &= ~(1<<(i%8)); - n = H5T_bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_LSB, FALSE); + n = H5T__bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_LSB, FALSE); if ((ssize_t)i!=n) { H5_FAILED(); printf (" Test for clear bit %d failed (lsb)!\n", i); goto failed; } - n = H5T_bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_MSB, FALSE); + n = H5T__bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_MSB, FALSE); if ((ssize_t)i!=n) { H5_FAILED(); printf (" Test for clear bit %d failed (lsb)!\n", i); @@ -183,7 +183,7 @@ test_copy (void) memset (v2, 0x00, sizeof v2); /* Copy some bits to v2 and make sure something was copied */ - H5T_bit_copy (v2, d_offset, v1, s_offset, size); + H5T__bit_copy (v2, d_offset, v1, s_offset, size); for (j=0; j<(int)sizeof(v2); j++) if (v2[j]) break; if (size>0 && j>=(int)sizeof(v2)) { H5_FAILED(); @@ -198,7 +198,7 @@ test_copy (void) /* Look for the zeros and ones */ - n = H5T_bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 1); + n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 1); if (size>0 && n!=(ssize_t)d_offset) { H5_FAILED(); printf (" Unable to find first copied bit in destination " @@ -210,7 +210,7 @@ test_copy (void) puts (" Found copied bits and shouldn't have!"); goto failed; } - n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); + n = H5T__bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { H5_FAILED(); printf (" Unable to find last copied bit in destination " @@ -227,7 +227,7 @@ test_copy (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 1); + n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 1); if (size>0 && (size_t)(n+1)!=d_offset+size) { H5_FAILED(); printf (" Unable to find last copied bit in destination " @@ -239,7 +239,7 @@ test_copy (void) puts (" Found copied bits but shouldn't have (reverse)!"); goto failed; } - n = H5T_bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 0); + n = H5T__bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 0); if (d_offset>0 && n+1!=(ssize_t)d_offset) { H5_FAILED(); printf (" Unable to find beginning of copied data " @@ -305,12 +305,12 @@ test_shift (void) /*-------- LEFT-shift some bits and make sure something was shifted --------*/ memset (vector, 0x00, sizeof vector); - H5T_bit_set (vector, offset, size, 1); + H5T__bit_set (vector, offset, size, 1); - H5T_bit_shift (vector, shift_dist, offset, size); + H5T__bit_shift (vector, shift_dist, offset, size); /* Look for the ones */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if ((size_t)n!=offset+shift_dist) { H5_FAILED(); printf (" Unable to find first bit in destination " @@ -322,7 +322,7 @@ test_shift (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (n!=(ssize_t)(offset+size-1)) { H5_FAILED(); printf (" Unable to find last bit in destination " @@ -332,12 +332,12 @@ test_shift (void) /*-------- RIGHT-shift some bits and make sure something was shifted --------*/ memset (vector, 0x00, sizeof vector); - H5T_bit_set (vector, offset, size, 1); + H5T__bit_set (vector, offset, size, 1); - H5T_bit_shift (vector, -shift_dist, offset, size); + H5T__bit_shift (vector, -shift_dist, offset, size); /* Look for the ones */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if ((size_t)n!=offset) { H5_FAILED(); printf (" Unable to find first bit in destination " @@ -349,7 +349,7 @@ test_shift (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (n!=(ssize_t)(offset+size-shift_dist-1)) { H5_FAILED(); printf (" Unable to find last bit in destination " @@ -367,12 +367,12 @@ test_shift (void) shift_dist = -((ssize_t)size); memset (vector, 0x00, sizeof vector); - H5T_bit_set (vector, offset, size, 1); + H5T__bit_set (vector, offset, size, 1); - H5T_bit_shift (vector, shift_dist, offset, size); + H5T__bit_shift (vector, shift_dist, offset, size); /* Supposed to fail to find any ones */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if (n >= 0) { H5_FAILED(); printf (" Unable to verify all bits are zero in destination(LSB) " @@ -381,7 +381,7 @@ test_shift (void) } /* Look from the other direction */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (n >= 0) { H5_FAILED(); printf (" Unable to verify all bits are zero in destination(MSB) " @@ -437,15 +437,15 @@ test_increment (void) memset (vector, 0x00, sizeof vector); if(size>1) /* if size=6, make a sequence like 011111 */ - H5T_bit_set (vector, offset, size-1, 1); + H5T__bit_set (vector, offset, size-1, 1); else /* if size=1, just set this one bit to 1 */ - H5T_bit_set (vector, offset, size, 1); + H5T__bit_set (vector, offset, size, 1); /* Increment the sequence by one */ - H5T_bit_inc (vector, offset, size); + H5T__bit_inc (vector, offset, size); /* Look for the one */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if (size!=1 && (size_t)n!=offset+size-1) { H5_FAILED(); printf (" Unable to find first bit in destination " @@ -463,7 +463,7 @@ test_increment (void) * Look for one in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (size!=1 && n!=(ssize_t)(offset+size-1)) { H5_FAILED(); printf (" Unable to find last bit in destination " @@ -526,10 +526,10 @@ test_decrement (void) memset (vector, 0x00, sizeof vector); /* decrement the sequence by one */ - H5T_bit_dec (vector, offset, size); + H5T__bit_dec (vector, offset, size); /* Look for the ones */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if ((size_t)n!=offset) { H5_FAILED(); printf (" Unable to find first bit in destination " @@ -541,7 +541,7 @@ test_decrement (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (n!=(ssize_t)(offset+size-1)) { H5_FAILED(); printf (" Unable to find last bit in destination " @@ -598,10 +598,10 @@ test_negate (void) memset (vector, 0x00, sizeof vector); /* negate the sequence */ - H5T_bit_neg (vector, offset, size); + H5T__bit_neg (vector, offset, size); /* Look for the ones */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if ((size_t)n!=offset) { H5_FAILED(); printf (" Unable to find first bit in destination " @@ -613,7 +613,7 @@ test_negate (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (n!=(ssize_t)(offset+size-1)) { H5_FAILED(); printf (" Unable to find last bit in destination " @@ -623,13 +623,13 @@ test_negate (void) /* All-one sequence will become 000000(size=6) after negating */ memset (vector, 0x00, sizeof vector); - H5T_bit_set (vector, offset, size, 1); + H5T__bit_set (vector, offset, size, 1); /* negate the sequence */ - H5T_bit_neg (vector, offset, size); + H5T__bit_neg (vector, offset, size); /* Look for the ones */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); if (n>=0) { H5_FAILED(); printf (" Unable to verify all-zero bits in destination " @@ -641,7 +641,7 @@ test_negate (void) * Look for ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); + n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); if (n>=0) { H5_FAILED(); printf (" Unable to verify all-zero bits in destination " @@ -695,7 +695,7 @@ test_set (void) memset (v2, 0x00, sizeof v2); /* Set some bits in v2 */ - H5T_bit_set (v2, d_offset, size, TRUE); + H5T__bit_set (v2, d_offset, size, TRUE); for (j=0; j<(int)sizeof(v2); j++) if (v2[j]) break; if (size>0 && j>=(int)sizeof(v2)) { H5_FAILED(); @@ -710,7 +710,7 @@ test_set (void) /* Look for the zeros and ones */ - n = H5T_bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 1); + n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 1); if (size>0 && n!=(ssize_t)d_offset) { H5_FAILED(); printf (" Unable to find first set bit in destination " @@ -722,7 +722,7 @@ test_set (void) puts (" Found set bits and shouldn't have!"); goto failed; } - n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); + n = H5T__bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { H5_FAILED(); printf (" Unable to find last set bit in destination " @@ -739,7 +739,7 @@ test_set (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 1); + n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 1); if (size>0 && (size_t)(n+1)!=d_offset+size) { H5_FAILED(); printf (" Unable to find last set bit in destination " @@ -751,7 +751,7 @@ test_set (void) puts (" Found set bits but shouldn't have (reverse)!"); goto failed; } - n = H5T_bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 0); + n = H5T__bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 0); if (d_offset>0 && n+1!=(ssize_t)d_offset) { H5_FAILED(); printf (" Unable to find beginning of set bit region " @@ -812,7 +812,7 @@ test_clear (void) memset (v2, 0xff, sizeof v2); /* Clear some bits in v2 */ - H5T_bit_set (v2, d_offset, size, FALSE); + H5T__bit_set (v2, d_offset, size, FALSE); for (j=0; j<(int)sizeof(v2); j++) if (0xff!=v2[j]) break; if (size>0 && j>=(int)sizeof(v2)) { H5_FAILED(); @@ -827,7 +827,7 @@ test_clear (void) /* Look for the zeros and ones */ - n = H5T_bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 0); + n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 0); if (size>0 && n!=(ssize_t)d_offset) { H5_FAILED(); printf (" Unable to find first cleared bit in destination " @@ -839,7 +839,7 @@ test_clear (void) puts (" Found cleared bits and shouldn't have!"); goto failed; } - n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1); + n = H5T__bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1); if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { H5_FAILED(); printf (" Unable to find last cleared bit in destination " @@ -856,7 +856,7 @@ test_clear (void) * Look for zeros and ones in reverse order. This is only to test * that reverse searches work as expected. */ - n = H5T_bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 0); + n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 0); if (size>0 && (size_t)(n+1)!=d_offset+size) { H5_FAILED(); printf (" Unable to find last cleared bit in destination " @@ -868,7 +868,7 @@ test_clear (void) puts (" Found cleared bits but shouldn't have (reverse)!"); goto failed; } - n = H5T_bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 1); + n = H5T__bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 1); if (d_offset>0 && n+1!=(ssize_t)d_offset) { H5_FAILED(); printf (" Unable to find beginning of cleared bit region " diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index d7f7842..433c488 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -2183,7 +2183,7 @@ main (int argc, char *argv[]) fprintf(stderr, "usage: %s [--noopt]\n", argv[0]); exit(1); } - H5Tunregister(H5T_PERS_DONTCARE, NULL, -1, -1, H5T_conv_struct_opt); + H5Tunregister(H5T_PERS_DONTCARE, NULL, -1, -1, H5T__conv_struct_opt); } /* Create the file */ diff --git a/test/dt_arith.c b/test/dt_arith.c index 054f069..0001755 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -306,9 +306,9 @@ static int without_hardware_g = 0; *00000111,..., until 11111111.*/ \ memset(tmp1, 0, SRC_SIZE); \ memset(tmp2, 0, SRC_SIZE); \ - H5T_bit_set (tmp2, SRC_PREC-1, (size_t)1, TRUE); /*the negative value*/ \ + H5T__bit_set (tmp2, SRC_PREC-1, (size_t)1, TRUE); /*the negative value*/ \ for(n=0; n<SRC_MANT_DIG-1; n++) { \ - H5T_bit_set (tmp1, n, (size_t)1, TRUE); /*turn on 1 bit each time*/ \ + H5T__bit_set (tmp1, n, (size_t)1, TRUE); /*turn on 1 bit each time*/ \ CHANGE_ORDER(tmp1, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ memcpy(buf_p, tmp1, SRC_SIZE); \ memcpy(saved_p, tmp1, SRC_SIZE); \ @@ -317,7 +317,7 @@ static int without_hardware_g = 0; saved_p += SRC_SIZE; \ \ /*negative values*/ \ - H5T_bit_set (tmp2, n, (size_t)1, TRUE); \ + H5T__bit_set (tmp2, n, (size_t)1, TRUE); \ CHANGE_ORDER(tmp2, SRC_ORDR, SRC_SIZE); \ memcpy(buf_p, tmp2, SRC_SIZE); \ memcpy(saved_p, tmp2, SRC_SIZE); \ @@ -353,7 +353,7 @@ static int without_hardware_g = 0; buf_p = BUF; \ \ /* +0 */ \ - H5T_bit_set(value, (size_t)0, SRC_PREC, FALSE); \ + H5T__bit_set(value, (size_t)0, SRC_PREC, FALSE); \ memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ buf_p += SRC_SIZE; \ \ @@ -361,7 +361,7 @@ static int without_hardware_g = 0; if(n==1) { \ memset(value, 0, SRC_SIZE*sizeof(unsigned char)); \ /* -0 */ \ - H5T_bit_set(value, (size_t)(SRC_PREC - 1), (size_t)1, TRUE); \ + H5T__bit_set(value, (size_t)(SRC_PREC - 1), (size_t)1, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE);/*change order for big endian*/ \ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE);/*change back the order for bit operation*/ \ @@ -369,21 +369,21 @@ static int without_hardware_g = 0; } \ \ /* +/-infinity */ \ - H5T_bit_set(value, (size_t)(SRC_MANT_DIG - 1), SRC_PREC-SRC_MANT_DIG, TRUE); \ + H5T__bit_set(value, (size_t)(SRC_MANT_DIG - 1), SRC_PREC-SRC_MANT_DIG, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \ buf_p += SRC_SIZE; \ \ /* +/-SNaN */ \ - H5T_bit_set(value, (size_t)0, (size_t)1, TRUE); \ + H5T__bit_set(value, (size_t)0, (size_t)1, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ HDmemcpy(buf_p, value, SRC_SIZE * sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \ buf_p += SRC_SIZE; \ \ /* +/-QNaN */ \ - H5T_bit_set(value, (size_t)(SRC_MANT_DIG - 2), (size_t)1, TRUE); \ + H5T__bit_set(value, (size_t)(SRC_MANT_DIG - 2), (size_t)1, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \ @@ -634,7 +634,7 @@ test_hard_query(void) /* Unregister the hard conversion from int to float. Verify the conversion * is a soft conversion. */ - H5Tunregister(H5T_PERS_HARD, NULL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT, H5T_conv_int_float); + H5Tunregister(H5T_PERS_HARD, NULL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT, H5T__conv_int_float); if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != FALSE) { H5_FAILED(); printf("Can't query conversion function\n"); @@ -643,7 +643,7 @@ test_hard_query(void) /* Register the hard conversion from int to float. Verify the conversion * is a hard conversion. */ - H5Tregister(H5T_PERS_HARD, "int_flt", H5T_NATIVE_INT, H5T_NATIVE_FLOAT, H5T_conv_int_float); + H5Tregister(H5T_PERS_HARD, "int_flt", H5T_NATIVE_INT, H5T_NATIVE_FLOAT, H5T__conv_int_float); if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != TRUE) { H5_FAILED(); printf("Can't query conversion function\n"); @@ -2337,92 +2337,92 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) */ if (H5T_SGN_2==src_sign && H5T_SGN_2==dst_sign) { if (src_nbits>dst_nbits) { - if(0==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && - H5T_bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits), + if(0==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1) && + H5T__bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits), H5T_BIT_MSB, 1)>=0) { /* * Source is positive and the magnitude is too large for * the destination. The destination should be set to the * maximum possible value: 0x7f...f */ - if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) + if (0==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ - } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && - H5T_bit_find(src_bits, (size_t)0, src_nbits-1, H5T_BIT_MSB, + } else if (1==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1) && + H5T__bit_find(src_bits, (size_t)0, src_nbits-1, H5T_BIT_MSB, 0)+1>=(ssize_t)dst_nbits) { /* * Source is negative but the magnitude is too large for * the destination. The destination should be set to the * smallest possible value: 0x80...0 */ - if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) + if (1==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } } else if(src_nbits<dst_nbits) { /* Source is smaller than the destination */ - if(0==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1)) { + if(0==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1)) { /* * Source is positive, so the excess bits in the * destination should be set to 0's. */ - if (0==H5T_bit_get_d(dst_bits, src_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 1) < 0) + if (0==H5T__bit_get_d(dst_bits, src_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else { /* * Source is negative, so the excess bits in the * destination should be set to 1's. */ - if (1==H5T_bit_get_d(dst_bits, src_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 0) < 0) + if (1==H5T__bit_get_d(dst_bits, src_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } } else if (H5T_SGN_2==src_sign && H5T_SGN_NONE==dst_sign) { - if (H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1)) { + if (H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1)) { /* * The source is negative so the result should be zero. * The source is negative if the most significant bit is * set. The destination is zero if all bits are zero. */ - if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else if (src_nbits>dst_nbits && - H5T_bit_find(src_bits, dst_nbits-1, + H5T__bit_find(src_bits, dst_nbits-1, src_nbits-dst_nbits, H5T_BIT_LSB, 1)>=0) { /* * The source is a value with a magnitude too large for * the destination. The destination should be the * largest possible value: 0xff...f */ - if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } else if (H5T_SGN_NONE==src_sign && H5T_SGN_2==dst_sign) { if (src_nbits>=dst_nbits && - H5T_bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits)+1, + H5T__bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits)+1, H5T_BIT_LSB, 1)>=0) { /* * The source value has a magnitude that is larger than * the destination can handle. The destination should be * set to the largest possible positive value: 0x7f...f */ - if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) + if (0==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } else { if (src_nbits>dst_nbits && - H5T_bit_find(src_bits, dst_nbits, src_nbits-dst_nbits, + H5T__bit_find(src_bits, dst_nbits, src_nbits-dst_nbits, H5T_BIT_LSB, 1)>=0) { /* * The unsigned source has a value which is too large for * the unsigned destination. The destination should be * set to the largest possible value: 0xff...f */ - if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } @@ -2610,8 +2610,8 @@ error: /*------------------------------------------------------------------------- * Function: test_conv_int_2 * - * Purpose: Tests overlap calculates in H5T_conv_i_i(), which should be - * the same as for H5T_conv_f_f() and H5T_conv_s_s(). + * Purpose: Tests overlap calculates in H5T__conv_i_i(), which should be + * the same as for H5T__conv_f_f() and H5T__conv_s_s(). * * Return: Success: 0 * @@ -2648,7 +2648,7 @@ test_conv_int_2(void) /* * Conversion. If overlap calculations aren't right then an - * assertion will fail in H5T_conv_i_i() + * assertion will fail in H5T__conv_i_i() */ H5Tconvert(src_type, dst_type, (size_t)100, buf, NULL, H5P_DEFAULT); H5Tclose(src_type); @@ -2788,8 +2788,8 @@ my_isinf(int endian, unsigned char *val, size_t size, bits[size-(i+1)] = *(val + ENDIAN(size, i, endian)); #endif /*H5_VMS*/ - if(H5T_bit_find(bits, mpos, msize, H5T_BIT_LSB, 1) < 0 && - H5T_bit_find(bits, epos, esize, H5T_BIT_LSB, 0) < 0) + if(H5T__bit_find(bits, mpos, msize, H5T_BIT_LSB, 1) < 0 && + H5T__bit_find(bits, epos, esize, H5T_BIT_LSB, 0) < 0) retval = 1; free(bits); @@ -3321,7 +3321,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) } } - expo = H5T_bit_get_d(tmp, src_epos, src_esize); + expo = H5T__bit_get_d(tmp, src_epos, src_esize); if(expo==0) continue; /* Denormalized floating-point value detected */ else { @@ -3341,7 +3341,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) } } - expo = H5T_bit_get_d(tmp, dst_epos, dst_esize); + expo = H5T__bit_get_d(tmp, dst_epos, dst_esize); if(expo==0) continue; /* Denormalized floating-point value detected */ else { @@ -4348,7 +4348,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) ) && (INT_SCHAR==dst_type || INT_SHORT==dst_type || INT_INT==dst_type || INT_LONG==dst_type || INT_LLONG==dst_type)) { - if(0==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && + if(0==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1) && overflows(src_bits, src, dst_nbits-1)) { /* * Source is positive and the magnitude is too large for @@ -4356,15 +4356,15 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * maximum possible value: 0x7f...f */ if(!except_set) { - if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) + if (0==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } else { /* fill_value is small so we know only the 1st byte is set */ if (dst_bits[0] == fill_value) continue; /*no error*/ } - } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && + } else if (1==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1) && overflows(src_bits, src, dst_nbits-1)) { /* * Source is negative but the magnitude is too large for @@ -4372,8 +4372,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * smallest possible value: 0x80...0 */ if(!except_set) { - if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) + if (1==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else { if (dst_bits[0] == fill_value) @@ -4389,14 +4389,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) ) && (INT_UCHAR==dst_type || INT_USHORT==dst_type || INT_UINT==dst_type || INT_ULONG==dst_type || INT_ULLONG==dst_type)) { - if (H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1)) { + if (H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1)) { /* * The source is negative so the result should be zero. * The source is negative if the most significant bit is * set. The destination is zero if all bits are zero. */ if(!except_set) { - if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else { if (dst_bits[0] == fill_value) @@ -4409,7 +4409,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * largest possible value: 0xff...f */ if(!except_set) { - if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } else { if (dst_bits[0] == fill_value) @@ -4757,13 +4757,13 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) HDmemcpy(bits, origin_bits, src_prec/8+1); /*Check for special cases: +Inf, -Inf*/ - if (H5T_bit_find (bits, mpos, mant_digits, H5T_BIT_LSB, TRUE) < 0) { - if (H5T_bit_find (bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { + if (H5T__bit_find (bits, mpos, mant_digits, H5T_BIT_LSB, TRUE) < 0) { + if (H5T__bit_find (bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { ret_value=TRUE; goto done; } - } else if (H5T_NORM_NONE==norm && H5T_bit_find (bits, mpos, mant_digits-1, - H5T_BIT_LSB, TRUE) < 0 && H5T_bit_find (bits, epos, expt_digits, + } else if (H5T_NORM_NONE==norm && H5T__bit_find (bits, mpos, mant_digits-1, + H5T_BIT_LSB, TRUE) < 0 && H5T__bit_find (bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa @@ -4773,7 +4773,7 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) } /* get exponent */ - expt = H5T_bit_get_d(bits, mant_digits, expt_digits) - bias; + expt = H5T__bit_get_d(bits, mant_digits, expt_digits) - bias; if(expt>=(dst_num_bits-1)) { ret_value=TRUE; @@ -4781,19 +4781,19 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) } /* get significand */ - H5T_bit_copy (mant_bits, (size_t)0, bits, (size_t)0, mant_digits); + H5T__bit_copy (mant_bits, (size_t)0, bits, (size_t)0, mant_digits); /* restore implicit bit if normalization is implied*/ if(norm == H5T_NORM_IMPLIED) { - H5T_bit_inc(mant_bits, mant_digits, (size_t)1); + H5T__bit_inc(mant_bits, mant_digits, (size_t)1); mant_digits++; } /* shift significand */ - H5T_bit_shift (mant_bits, (ssize_t)(expt-expt_digits), (size_t)0, (size_t)(32 * 8)); + H5T__bit_shift (mant_bits, (ssize_t)(expt-expt_digits), (size_t)0, (size_t)(32 * 8)); - indx = H5T_bit_find(mant_bits, (size_t)0, (size_t)(32 * 8), H5T_BIT_MSB, 1); + indx = H5T__bit_find(mant_bits, (size_t)0, (size_t)(32 * 8), H5T_BIT_MSB, 1); if((size_t)indx>=dst_num_bits) ret_value=TRUE; diff --git a/test/dtypes.c b/test/dtypes.c index 23a7bac..3db9bf8 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -3964,6 +3964,9 @@ test_str_create(void) if((query_size = H5Tget_size(fixed_str2)) == 0) goto error; if(query_size != str_size) goto error; + if(H5Tclose(fixed_str1) < 0) goto error; + if(H5Tclose(fixed_str2) < 0) goto error; + /* Create variable-length string in two ways and make sure they are the same */ if((vlen_str1 = mkstr((size_t)H5T_VARIABLE, H5T_STR_NULLTERM)) < 0) goto error; @@ -3978,6 +3981,8 @@ test_str_create(void) if((is_vl_str = H5Tis_variable_str(vlen_str2)) < 0) goto error; if(!is_vl_str) goto error; + if(H5Tclose(vlen_str1) < 0) goto error; + if(H5Tclose(vlen_str2) < 0) goto error; PASSED(); return 0; diff --git a/test/external.c b/test/external.c index 1dedeab..ae1008c 100644 --- a/test/external.c +++ b/test/external.c @@ -111,6 +111,7 @@ test_1a(hid_t file) char name[256]; /*external file name */ off_t file_offset; /*external file offset */ hsize_t file_size; /*sizeof external file segment */ + haddr_t dset_addr; /*address of dataset */ TESTING("fixed-size data space, exact storage"); @@ -130,7 +131,10 @@ test_1a(hid_t file) if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) goto error; /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dset) != HADDR_UNDEF) goto error; + H5E_BEGIN_TRY { + dset_addr = H5Dget_offset(dset); + } H5E_END_TRY; + if(dset_addr != HADDR_UNDEF) goto error; if((dcpl = H5Dget_create_plist(dset)) < 0) goto error; if((n = H5Pget_external_count(dcpl)) < 0) goto error; diff --git a/test/fheap.c b/test/fheap.c index 14cfbe8..e4aa137 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -508,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 */ @@ -6453,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; @@ -7594,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 @@ -15420,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; @@ -15624,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; @@ -15838,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 */ @@ -16292,6 +16404,7 @@ curr_test = FHEAP_TEST_NORMAL; break; /* An unknown test? */ + case FHEAP_TEST_NTESTS: default: goto error; } /* end switch */ @@ -16340,6 +16453,7 @@ fill = FHEAP_TEST_FILL_LARGE; break; /* An unknown test? */ + case FHEAP_TEST_FILL_N: default: goto error; } /* end switch */ @@ -16348,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 */ @@ -16411,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 */ @@ -16452,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..73c901e --- /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 - 1] = '\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 - 1] = '\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 copied_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"); + + /* Append ".copy" to the filename from the source directory */ + VERIFY(HDstrlen(filename) < (1023 - 5), "file name too long."); + HDstrncpy(copied_filename, filename, 1023); + copied_filename[1023] = '\0'; + HDstrcat(copied_filename, ".copy"); + + /* Make a copy of the data file from svn. */ + ret = h5_make_local_copy(filename, copied_filename); + VERIFY(ret >= 0, "h5_make_local_copy"); + + /* 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(copied_filename, H5F_ACC_RDONLY, 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(copied_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(copied_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_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if(H5Fclose(file) < 0) FAIL_STACK_ERROR + + /* Release resources */ + h5_cleanup(FILENAME, fapl); + HDfree(udata); + HDfree(file_image); + HDremove(copied_filename); + + 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 Binary files differnew file mode 100644 index 0000000..1cc5130 --- /dev/null +++ b/test/file_image_core_test.h5 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 0c970bc..f99e835 100644 --- a/test/istore.c +++ b/test/istore.c @@ -467,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 */ @@ -499,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); @@ -601,6 +605,7 @@ 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' ) */ @@ -683,27 +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; } - if (has_sparse_support && size_of_test & TEST_LARGE) { + skip_test = !has_sparse_support; + if (size_of_test & TEST_LARGE) { /* This test is skipped if there is no POSIX-style sparse file support * e.g.: Windows NTFS filesystems */ - status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50); + 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; } @@ -3184,8 +3184,13 @@ error: * To verify that a block can be extended from the aggregator * * Test 1: Allocate block A from meta_aggr which is at end of file - * Try to extend a block which adjoins the aggregator - * H5MF_try_extend() succeeds: meta_aggr is extended by extended-request and meta_aggr's info is updated + * Try to extend the block which adjoins the aggregator that is at end of file + * a. block size < (% * aggr->alloc_size) + * The block is allocated from the aggregator + * b. block size > (% * aggr->alloc_size) but block size < aggr->alloc_size + * The block is extended by aggr->alloc_size and the block is allocated from the aggregator + * c. block size > (% * aggr->alloc_size) but block size > aggr->alloc_size + * The block is extended by extended-request and the block is allocated from the aggregator * * Test 2: Allocate block A from meta_aggr * Allocate block B from sdata_aggr so that meta_aggr is not at end of file @@ -3252,7 +3257,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) new_addr = addr - 10; - /* Try to extend the block */ + /* Try to extend the block by an amount < (% * aggr->alloc_size) */ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50)); /* should succeed */ @@ -3263,15 +3268,42 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if (new_ma_addr != (addr+TEST_BLOCK_SIZE50)) TEST_ERROR - if (new_ma_size != f->shared->meta_aggr.alloc_size) TEST_ERROR + if (new_ma_size != (f->shared->meta_aggr.alloc_size - TEST_BLOCK_SIZE50)) TEST_ERROR - /* Restore info for meta_aggr */ - f->shared->meta_aggr.addr = ma_addr; - f->shared->meta_aggr.size = ma_size; + /* Free the allocated blocks */ + H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE50); + + /* Try to extend the block by an amount > (% * aggr->alloc_size) but amount < aggr->alloc_size */ + extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE700)); + + /* should succeed */ + if(!extended) + TEST_ERROR + + H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); + + if (new_ma_addr != (addr + TEST_BLOCK_SIZE700)) + TEST_ERROR + if (new_ma_size != (f->shared->meta_aggr.alloc_size * 2 - TEST_BLOCK_SIZE700)) TEST_ERROR /* Free the allocated blocks */ - H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30); - H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, (ma_addr+ma_size), (hsize_t)TEST_BLOCK_SIZE50); + H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE700); + + /* Try to extend the block by an amount > (% * aggr->alloc_size) but amount > aggr->alloc_size */ + extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE2058)); + + /* should succeed */ + if(!extended) + TEST_ERROR + + H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); + + if (new_ma_addr != (addr + TEST_BLOCK_SIZE2058)) + TEST_ERROR + if (new_ma_size != f->shared->meta_aggr.size) TEST_ERROR + + /* Free the allocated blocks */ + H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE2058); if(H5Fclose(file) < 0) FAIL_STACK_ERROR diff --git a/test/objcopy.c b/test/objcopy.c index 5c20ee8..ce0f3d3 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -47,6 +47,7 @@ const char *FILENAME[] = { "objcopy_src", "objcopy_dst", "objcopy_ext", + "objcopy_src2", NULL }; @@ -73,6 +74,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" @@ -89,6 +91,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" @@ -540,12 +545,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); @@ -553,7 +563,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) @@ -572,6 +591,8 @@ done: H5Sclose(sid); if(aid > 0) H5Aclose(aid); + if(acpl > 0) + H5Pclose(acpl); return ret_value; } @@ -595,11 +616,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); @@ -607,6 +632,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; @@ -619,6 +651,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; @@ -627,6 +660,8 @@ done: H5Sclose(sid); if(aid > 0) H5Aclose(aid); + if(acpl > 0) + H5Pclose(acpl); return -1; } /* end test_copy_attach_paired_attributes() */ @@ -652,10 +687,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 */ @@ -1271,7 +1318,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 @@ -8097,6 +8146,3312 @@ 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 */ + int i; /* Local index variable */ + hsize_t dim1d[1]; /* dimension sizes */ + int buf[DIM_SIZE_1]; /* Buffer for data */ + 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") + + /* 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 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 */ + unsigned int i; /* Local index variables */ + 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(); + + /* + * 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 */ + 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]; + + if(reopen) + TESTING("H5Ocopy(): merging different committed datatypes with suggestions and reopen") + else + TESTING("H5Ocopy(): merging different 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(); + + /* + * 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 @@ -8388,6 +11743,319 @@ 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 */ + 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 */ + 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 + + /* + * 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, H5P_DEFAULT, 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, H5P_DEFAULT, 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, H5P_DEFAULT, 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, H5P_DEFAULT, 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, H5P_DEFAULT, 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, H5P_DEFAULT, 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, H5P_DEFAULT, -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, H5P_DEFAULT, -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 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); + H5Fclose(fid_dst); + H5Fclose(fid_src); + } H5E_END_TRY; + return 1; +} /* end test_copy_dataset_open */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test H5Ocopy() @@ -8414,6 +12082,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(); @@ -8446,6 +12115,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; @@ -8462,6 +12136,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:"); @@ -8484,7 +12159,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 */ @@ -8493,6 +12168,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:"); @@ -8528,6 +12204,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"); @@ -8555,14 +12233,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/testfiles/error_test_1 b/test/testfiles/error_test_1 index 8d6e208..b322460 100644 --- a/test/testfiles/error_test_1 +++ b/test/testfiles/error_test_1 @@ -44,13 +44,13 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Dread(): can't read data major: Dataset minor: Read failed - #001: (file name) line (number) in H5D_read(): can't read data + #001: (file name) line (number) in H5D__read(): can't read data major: Dataset minor: Read failed - #002: (file name) line (number) in H5D_chunk_read(): unable to read raw data chunk + #002: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk major: Low-level I/O minor: Read failed - #003: (file name) line (number) in H5D_chunk_lock(): data pipeline read failed + #003: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed major: Data filters minor: Filter operation failed #004: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered diff --git a/test/tgenprop.c b/test/tgenprop.c index 5f9a69b..3dbaa14 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -1575,6 +1575,46 @@ test_genprop_class_addprop(void) /**************************************************************** ** +** test_genprop_list_add_remove_prop(): Test adding then removing the +** same properties to a standard HDF5 property list. This is testing +** also for a memory leak that could be caused by not freeing the +** removed property resources from the property list. +** +****************************************************************/ +static void +test_genprop_list_add_remove_prop(void) +{ + hid_t pid; /* Property List ID */ + herr_t ret; /* Generic return value */ + + /* Create a dataset creation property list */ + pid = H5Pcreate(H5P_DATASET_CREATE); + CHECK(pid, FAIL, "H5Pcreate"); + + /* Insert temporary property into class (with no callbacks) */ + ret = H5Pinsert2(pid, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL); + CHECK_I(ret, "H5Pinsert2"); + + /* Delete added property */ + ret = H5Premove(pid, PROP1_NAME); + CHECK_I(ret, "H5Premove"); + + /* Insert temporary property into class (with no callbacks) */ + ret = H5Pinsert2(pid, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL); + CHECK_I(ret, "H5Pinsert2"); + + /* Delete added property */ + ret = H5Premove(pid, PROP1_NAME); + CHECK_I(ret, "H5Premove"); + + /* Close property list */ + ret = H5Pclose(pid); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_genprop_list_add_remove_prop() */ + +/**************************************************************** +** ** test_genprop_equal(): Test basic generic property list code. ** More tests for H5Pequal() ** @@ -1990,6 +2030,8 @@ test_genprop(void) test_genprop_list_addprop(); /* Test adding properties to HDF5 property list */ test_genprop_class_addprop(); /* Test adding properties to HDF5 property class */ + test_genprop_list_add_remove_prop(); /* Test adding and removing the same property several times to HDF5 property list */ + test_genprop_equal(); /* Tests for more H5Pequal verification */ test_genprop_path(); /* Tests for class path verification */ test_genprop_refcount(); /* Tests for class reference counting */ diff --git a/test/tmisc.c b/test/tmisc.c index 5539cee..6fcf557 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -3460,14 +3460,14 @@ test_misc20(void) CHECK(did, FAIL, "H5Dopen2"); /* Get the layout version */ - ret = H5D_layout_version_test(did,&version); - CHECK(ret, FAIL, "H5D_layout_version_test"); - VERIFY(version, 3, "H5D_layout_version_test"); + ret = H5D__layout_version_test(did,&version); + CHECK(ret, FAIL, "H5D__layout_version_test"); + VERIFY(version, 3, "H5D__layout_version_test"); /* Get the layout contiguous storage size */ - ret = H5D_layout_contig_size_test(did,&contig_size); - CHECK(ret, FAIL, "H5D_layout_contig_size_test"); - VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D_layout_contig_size_test"); + ret = H5D__layout_contig_size_test(did,&contig_size); + CHECK(ret, FAIL, "H5D__layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D__layout_contig_size_test"); /* Close datasset */ ret = H5Dclose(did); @@ -3478,14 +3478,14 @@ test_misc20(void) CHECK(did, FAIL, "H5Dopen2"); /* Get the layout version */ - ret = H5D_layout_version_test(did,&version); - CHECK(ret, FAIL, "H5D_layout_version_test"); - VERIFY(version, 3, "H5D_layout_version_test"); + ret = H5D__layout_version_test(did,&version); + CHECK(ret, FAIL, "H5D__layout_version_test"); + VERIFY(version, 3, "H5D__layout_version_test"); /* Get the layout contiguous storage size */ - ret = H5D_layout_contig_size_test(did,&contig_size); - CHECK(ret, FAIL, "H5D_layout_contig_size_test"); - VERIFY(contig_size, (MISC20_SPACE2_DIM0 * MISC20_SPACE2_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D_layout_contig_size_test"); + ret = H5D__layout_contig_size_test(did,&contig_size); + CHECK(ret, FAIL, "H5D__layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE2_DIM0 * MISC20_SPACE2_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D__layout_contig_size_test"); /* Close datasset */ ret = H5Dclose(did); @@ -3508,14 +3508,14 @@ test_misc20(void) CHECK(did, FAIL, "H5Dopen2"); /* Get the layout version */ - ret = H5D_layout_version_test(did,&version); - CHECK(ret, FAIL, "H5D_layout_version_test"); - VERIFY(version, 2, "H5D_layout_version_test"); + ret = H5D__layout_version_test(did,&version); + CHECK(ret, FAIL, "H5D__layout_version_test"); + VERIFY(version, 2, "H5D__layout_version_test"); /* Get the layout contiguous storage size */ - ret = H5D_layout_contig_size_test(did,&contig_size); - CHECK(ret, FAIL, "H5D_layout_contig_size_test"); - VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_STD_I32LE)), "H5D_layout_contig_size_test"); + ret = H5D__layout_contig_size_test(did,&contig_size); + CHECK(ret, FAIL, "H5D__layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_STD_I32LE)), "H5D__layout_contig_size_test"); /* Close datasset */ ret = H5Dclose(did); @@ -4963,10 +4963,10 @@ test_misc28(void) CHECK(did, FAIL, "H5Dcreate2"); /* Verify that the chunk cache is empty */ - ret = H5D_current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D_current_cache_size_test"); - VERIFY(nbytes_used, (size_t) 0, "H5D_current_cache_size_test"); - VERIFY(nused, 0, "H5D_current_cache_size_test"); + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t) 0, "H5D__current_cache_size_test"); + VERIFY(nused, 0, "H5D__current_cache_size_test"); /* Initialize write buffer */ for(i=0; i<MISC28_SIZE; i++) @@ -4984,10 +4984,10 @@ test_misc28(void) CHECK(ret, FAIL, "H5Dwrite"); /* Verify that all 10 chunks written have been cached */ - ret = H5D_current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D_current_cache_size_test"); - VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D_current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D_current_cache_size_test"); + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); /* Initialize write buffer */ for(i=0; i<MISC28_SIZE; i++) @@ -5003,10 +5003,10 @@ test_misc28(void) CHECK(ret, FAIL, "H5Dwrite"); /* Verify that the size of the cache remains at 10 */ - ret = H5D_current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D_current_cache_size_test"); - VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D_current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D_current_cache_size_test"); + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); /* Close dataset */ ret = H5Dclose(did); @@ -5018,10 +5018,10 @@ test_misc28(void) CHECK(did, FAIL, "H5Dopen2"); /* Verify that the chunk cache is empty */ - ret = H5D_current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D_current_cache_size_test"); - VERIFY(nbytes_used, (size_t) 0, "H5D_current_cache_size_test"); - VERIFY(nused, 0, "H5D_current_cache_size_test"); + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t) 0, "H5D__current_cache_size_test"); + VERIFY(nused, 0, "H5D__current_cache_size_test"); /* Select hyperslabe for reading */ start[1] = 0; @@ -5037,10 +5037,10 @@ test_misc28(void) VERIFY(buf[i], i, "H5Dread"); /* Verify that all 10 chunks read have been cached */ - ret = H5D_current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D_current_cache_size_test"); - VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D_current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D_current_cache_size_test"); + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); /* Select new hyperslab */ start[1] = 1; @@ -5056,10 +5056,10 @@ test_misc28(void) VERIFY(buf[i], MISC28_SIZE - 1 - i, "H5Dread"); /* Verify that the size of the cache remains at 10 */ - ret = H5D_current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D_current_cache_size_test"); - VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D_current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D_current_cache_size_test"); + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t) MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); /* Close dataset */ ret = H5Dclose(did); @@ -1150,11 +1150,10 @@ test_multi_compat(void) { hid_t file=(-1), fapl, fapl2=(-1), dset=(-1), space=(-1); hid_t access_fapl = -1; - char filename[1024], newname[1024], tmp[1024]; + char newname[1024]; char filename_s[1024], newname_s[1024]; char filename_r[1024], newname_r[1024]; int *fhandle2=NULL, *fhandle=NULL; - hsize_t file_size; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; |