summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/COPYING2
-rw-r--r--test/Makefile.am52
-rw-r--r--test/Makefile.in311
-rw-r--r--test/app_ref.c199
-rw-r--r--test/big.c57
-rw-r--r--test/btree2.c5085
-rw-r--r--test/cache.c9159
-rw-r--r--test/cache_api.c16
-rw-r--r--test/cache_common.c1055
-rw-r--r--test/cache_common.h124
-rw-r--r--test/chunk_info.c36
-rw-r--r--test/cmpd_dset.c496
-rwxr-xr-xtest/corrupt_stab_msg.h5bin0 -> 2928 bytes
-rw-r--r--test/dangle.c30
-rw-r--r--test/dsets.c1548
-rw-r--r--test/dt_arith.c249
-rw-r--r--test/dtransform.c101
-rw-r--r--test/dtypes.c1404
-rw-r--r--test/earray.c2955
-rw-r--r--test/enum.c199
-rw-r--r--test/error_test.c35
-rw-r--r--test/extend.c82
-rw-r--r--test/external.c229
-rw-r--r--test/family_v16_00000.h5bin5120 -> 5120 bytes
-rw-r--r--test/farray.c1659
-rw-r--r--test/fheap.c777
-rw-r--r--test/filespace_1_6.h5bin0 -> 2448 bytes
-rw-r--r--test/filespace_1_8.h5bin0 -> 2448 bytes
-rw-r--r--test/fillval.c181
-rw-r--r--test/flush1.c69
-rw-r--r--test/flush2.c120
-rw-r--r--test/freespace.c2812
-rw-r--r--test/gen_bad_ohdr.c2
-rw-r--r--test/gen_bogus.c2
-rw-r--r--test/gen_filespace.c81
-rw-r--r--test/gen_specmetaread.c96
-rw-r--r--test/gen_udlinks.c4
-rw-r--r--test/getname.c95
-rw-r--r--test/gheap.c131
-rw-r--r--test/h5test.c234
-rw-r--r--test/h5test.h8
-rw-r--r--test/hyperslab.c4
-rw-r--r--test/istore.c240
-rw-r--r--test/links.c3425
-rw-r--r--test/mf.c7314
-rw-r--r--test/mount.c235
-rw-r--r--test/mtime.c2
-rw-r--r--test/ntypes.c1849
-rwxr-xr-xtest/objcopy.c1228
-rw-r--r--test/ohdr.c184
-rw-r--r--test/pool.c214
-rwxr-xr-xtest/reserved.c4
-rw-r--r--test/set_extent.c2928
-rw-r--r--test/specmetaread.h5bin0 -> 1752 bytes
-rw-r--r--test/stab.c255
-rw-r--r--test/tarray.c23
-rw-r--r--test/tattr.c735
-rw-r--r--test/tcheck_version.c121
-rw-r--r--test/tconfig.c41
-rw-r--r--test/tcoords.c42
-rw-r--r--test/testcheck_version.sh.in258
-rw-r--r--test/testfiles/error_test_113
-rw-r--r--test/testhdf5.c1
-rw-r--r--test/testhdf5.h15
-rw-r--r--test/testlibinfo.sh.in128
-rw-r--r--test/tfile.c1408
-rw-r--r--test/tgenprop.c200
-rw-r--r--test/th5o.c6
-rw-r--r--test/th5s.c5
-rw-r--r--test/theap.c2
-rw-r--r--test/tid.c127
-rw-r--r--test/tmisc.c377
-rw-r--r--test/trefer.c9
-rw-r--r--test/trefstr.c1
-rw-r--r--test/tselect.c76
-rw-r--r--test/tskiplist.c248
-rw-r--r--test/tsohm.c296
-rw-r--r--test/ttsafe_error.c6
-rw-r--r--test/ttst.c2
-rw-r--r--test/tunicode.c7
-rw-r--r--test/tvlstr.c18
-rw-r--r--test/tvltypes.c16
-rw-r--r--test/unlink.c492
-rw-r--r--test/vfd.c75
84 files changed, 42998 insertions, 9327 deletions
diff --git a/test/COPYING b/test/COPYING
index ef0cbaf..6903daf 100755
--- a/test/COPYING
+++ b/test/COPYING
@@ -1,5 +1,5 @@
- Copyright by The HDF Group (THG) and
+ Copyright by The HDF Group and
The Board of Trustees of the University of Illinois.
All rights reserved.
diff --git a/test/Makefile.am b/test/Makefile.am
index a3f8660..ec1eed7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -24,7 +24,7 @@ include $(top_srcdir)/config/commence.am
INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
-TEST_SCRIPT = testerror.sh
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh
check_SCRIPTS = $(TEST_SCRIPT)
SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
@@ -39,17 +39,18 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
- fillval mount flush1 flush2 enum \
+ fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe \
getname vfd ntypes dangle dtransform reserved cross_read \
- btree2 fheap
+ freespace mf farray earray btree2 fheap
# 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.
+# tcheck_version is used by testcheck_version.sh.
# 'make check' doesn't run them directly, so they are not included in TEST_PROG.
# Also build testmeta, which is used for timings test. It builds quickly,
# and this lets automake keep all its test programs in one place.
-check_PROGRAMS=$(TEST_PROG) error_test err_compat testmeta
+check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta
# These programs generate test files for the tests. They don't need to be
@@ -61,7 +62,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat testmeta
# so do not appear in this list.
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_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread
if BUILD_ALL_CONDITIONAL
noinst_PROGRAMS=$(BUILD_ALL_PROGS)
@@ -103,24 +104,27 @@ flush2.chkexe_: flush1.chkexe_
# prefix or low-level driver with environment variables will influence
# the temporary file name in ways that the makefile is not aware of.
CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \
- max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
- huge_chunks.h5 extend.h5 istore.h5 \
- tfile[1-4].h5 th5s[1-3].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[1-8].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_read.h5 set_extent_create.h5 \
- getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \
- family_file000[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
+ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
+ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \
+ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
+ sys_file1 tfile[1-4].h5 th5s[1-3].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[1-8].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
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
@@ -129,6 +133,6 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
tvlstr.c tvltypes.c
# Temporary files.
-DISTCLEANFILES=testerror.sh
+DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh
include $(top_srcdir)/config/conclude.am
diff --git a/test/Makefile.in b/test/Makefile.in
index f9e36cc..0f8adca 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -34,8 +35,9 @@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
@@ -51,10 +53,11 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/testerror.sh.in $(top_srcdir)/config/commence.am \
+ $(srcdir)/testcheck_version.sh.in $(srcdir)/testerror.sh.in \
+ $(srcdir)/testlibinfo.sh.in $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am COPYING
check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \
- err_compat$(EXEEXT) testmeta$(EXEEXT)
+ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT)
@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2)
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
subdir = test
@@ -64,7 +67,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/H5config.h
-CONFIG_CLEAN_FILES = testerror.sh
+CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh testlibinfo.sh
+CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libh5test_la_LIBADD =
am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo
@@ -76,19 +80,25 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
dsets$(EXEEXT) cmpd_dset$(EXEEXT) extend$(EXEEXT) \
external$(EXEEXT) objcopy$(EXEEXT) links$(EXEEXT) \
unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) fillval$(EXEEXT) \
- mount$(EXEEXT) flush1$(EXEEXT) flush2$(EXEEXT) enum$(EXEEXT) \
- set_extent$(EXEEXT) ttsafe$(EXEEXT) getname$(EXEEXT) \
- vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
- dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \
- btree2$(EXEEXT) fheap$(EXEEXT)
+ mount$(EXEEXT) flush1$(EXEEXT) flush2$(EXEEXT) \
+ app_ref$(EXEEXT) enum$(EXEEXT) set_extent$(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)
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) \
gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \
gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \
gen_nullspace$(EXEEXT) gen_udlinks$(EXEEXT) \
- space_overflow$(EXEEXT)
+ space_overflow$(EXEEXT) gen_filespace$(EXEEXT) \
+ gen_specmetaread$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
+app_ref_SOURCES = app_ref.c
+app_ref_OBJECTS = app_ref.$(OBJEXT)
+app_ref_LDADD = $(LDADD)
+app_ref_DEPENDENCIES = libh5test.la $(LIBHDF5)
big_SOURCES = big.c
big_OBJECTS = big.$(OBJEXT)
big_LDADD = $(LDADD)
@@ -137,6 +147,10 @@ dtypes_SOURCES = dtypes.c
dtypes_OBJECTS = dtypes.$(OBJEXT)
dtypes_LDADD = $(LDADD)
dtypes_DEPENDENCIES = libh5test.la $(LIBHDF5)
+earray_SOURCES = earray.c
+earray_OBJECTS = earray.$(OBJEXT)
+earray_LDADD = $(LDADD)
+earray_DEPENDENCIES = libh5test.la $(LIBHDF5)
enum_SOURCES = enum.c
enum_OBJECTS = enum.$(OBJEXT)
enum_LDADD = $(LDADD)
@@ -157,6 +171,10 @@ external_SOURCES = external.c
external_OBJECTS = external.$(OBJEXT)
external_LDADD = $(LDADD)
external_DEPENDENCIES = libh5test.la $(LIBHDF5)
+farray_SOURCES = farray.c
+farray_OBJECTS = farray.$(OBJEXT)
+farray_LDADD = $(LDADD)
+farray_DEPENDENCIES = libh5test.la $(LIBHDF5)
fheap_SOURCES = fheap.c
fheap_OBJECTS = fheap.$(OBJEXT)
fheap_LDADD = $(LDADD)
@@ -173,6 +191,10 @@ flush2_SOURCES = flush2.c
flush2_OBJECTS = flush2.$(OBJEXT)
flush2_LDADD = $(LDADD)
flush2_DEPENDENCIES = libh5test.la $(LIBHDF5)
+freespace_SOURCES = freespace.c
+freespace_OBJECTS = freespace.$(OBJEXT)
+freespace_LDADD = $(LDADD)
+freespace_DEPENDENCIES = libh5test.la $(LIBHDF5)
gen_bad_ohdr_SOURCES = gen_bad_ohdr.c
gen_bad_ohdr_OBJECTS = gen_bad_ohdr.$(OBJEXT)
gen_bad_ohdr_LDADD = $(LDADD)
@@ -189,6 +211,10 @@ gen_deflate_SOURCES = gen_deflate.c
gen_deflate_OBJECTS = gen_deflate.$(OBJEXT)
gen_deflate_LDADD = $(LDADD)
gen_deflate_DEPENDENCIES = libh5test.la $(LIBHDF5)
+gen_filespace_SOURCES = gen_filespace.c
+gen_filespace_OBJECTS = gen_filespace.$(OBJEXT)
+gen_filespace_LDADD = $(LDADD)
+gen_filespace_DEPENDENCIES = libh5test.la $(LIBHDF5)
gen_filters_SOURCES = gen_filters.c
gen_filters_OBJECTS = gen_filters.$(OBJEXT)
gen_filters_LDADD = $(LDADD)
@@ -221,6 +247,10 @@ gen_nullspace_SOURCES = gen_nullspace.c
gen_nullspace_OBJECTS = gen_nullspace.$(OBJEXT)
gen_nullspace_LDADD = $(LDADD)
gen_nullspace_DEPENDENCIES = libh5test.la $(LIBHDF5)
+gen_specmetaread_SOURCES = gen_specmetaread.c
+gen_specmetaread_OBJECTS = gen_specmetaread.$(OBJEXT)
+gen_specmetaread_LDADD = $(LDADD)
+gen_specmetaread_DEPENDENCIES = libh5test.la $(LIBHDF5)
gen_udlinks_SOURCES = gen_udlinks.c
gen_udlinks_OBJECTS = gen_udlinks.$(OBJEXT)
gen_udlinks_LDADD = $(LDADD)
@@ -249,6 +279,10 @@ links_SOURCES = links.c
links_OBJECTS = links.$(OBJEXT)
links_LDADD = $(LDADD)
links_DEPENDENCIES = libh5test.la $(LIBHDF5)
+mf_SOURCES = mf.c
+mf_OBJECTS = mf.$(OBJEXT)
+mf_LDADD = $(LDADD)
+mf_DEPENDENCIES = libh5test.la $(LIBHDF5)
mount_SOURCES = mount.c
mount_OBJECTS = mount.$(OBJEXT)
mount_LDADD = $(LDADD)
@@ -289,6 +323,10 @@ stab_SOURCES = stab.c
stab_OBJECTS = stab.$(OBJEXT)
stab_LDADD = $(LDADD)
stab_DEPENDENCIES = libh5test.la $(LIBHDF5)
+tcheck_version_SOURCES = tcheck_version.c
+tcheck_version_OBJECTS = tcheck_version.$(OBJEXT)
+tcheck_version_LDADD = $(LDADD)
+tcheck_version_DEPENDENCIES = libh5test.la $(LIBHDF5)
am_testhdf5_OBJECTS = testhdf5.$(OBJEXT) tarray.$(OBJEXT) \
tattr.$(OBJEXT) tchecksum.$(OBJEXT) tconfig.$(OBJEXT) \
tfile.$(OBJEXT) tgenprop.$(OBJEXT) th5o.$(OBJEXT) \
@@ -322,6 +360,7 @@ vfd_DEPENDENCIES = libh5test.la $(LIBHDF5)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
+am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -331,36 +370,51 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \
- cache_api.c cmpd_dset.c cross_read.c dangle.c dsets.c \
- dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \
- error_test.c extend.c external.c fheap.c fillval.c flush1.c \
- flush2.c gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.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_udlinks.c getname.c gheap.c hyperslab.c \
- istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \
- ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \
- $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
- vfd.c
-DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \
+SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.c \
cache.c cache_api.c cmpd_dset.c cross_read.c dangle.c dsets.c \
- dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \
- error_test.c extend.c external.c fheap.c fillval.c flush1.c \
- flush2.c gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \
+ dt_arith.c dtransform.c dtypes.c earray.c enum.c err_compat.c \
+ error_test.c extend.c external.c farray.c fheap.c fillval.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_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
+ istore.c lheap.c links.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
+DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \
+ btree2.c cache.c cache_api.c cmpd_dset.c cross_read.c dangle.c \
+ dsets.c dt_arith.c dtransform.c dtypes.c earray.c enum.c \
+ err_compat.c error_test.c extend.c external.c farray.c fheap.c \
+ fillval.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_udlinks.c getname.c gheap.c hyperslab.c \
- istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \
- ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \
+ gen_nullspace.c gen_specmetaread.c gen_udlinks.c getname.c \
+ gheap.c hyperslab.c istore.c lheap.c links.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 = \
+red=; grn=; lgn=; blu=; std=
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = /home1/packages/automake/automake-1.9.6/bin/aclocal-1.9 -I /afs/ncsa/projects/hdf/packages/libtool_1.5.14/Linux_2.4/share/aclocal
ADD_PARALLEL_FILES = @ADD_PARALLEL_FILES@
AMTAR = @AMTAR@
+
+# H5_CFLAGS holds flags that should be used when building hdf5,
+# but which should not be exported to h5cc for building other programs.
+# AM_CFLAGS is an automake construct which should be used by Makefiles
+# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
+AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@
+AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
+AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
+AM_LDFLAGS = @AM_LDFLAGS@
AM_MAKEFLAGS = @AM_MAKEFLAGS@
AR = @AR@
@@ -374,21 +428,18 @@ BYTESEX = @BYTESEX@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_VERSION = @CC_VERSION@
-
-# H5_CFLAGS holds flags that should be used as CFLAGS when building hdf5,
-# but which shouldn't be exported to h5cc for building other programs.
-CFLAGS = @CFLAGS@ @H5_CFLAGS@
+CFLAGS = @CFLAGS@
CLEARFILEBUF = @CLEARFILEBUF@
CODESTACK = @CODESTACK@
CONFIG_DATE = @CONFIG_DATE@
CONFIG_MODE = @CONFIG_MODE@
CONFIG_USER = @CONFIG_USER@
CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@ @H5_CPPFLAGS@
+CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@ @H5_CXXFLAGS@
+CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG_PKG = @DEBUG_PKG@
DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
@@ -411,7 +462,7 @@ F9XMODEXT = @F9XMODEXT@
F9XMODFLAG = @F9XMODFLAG@
F9XSUFFIXFLAG = @F9XSUFFIXFLAG@
FC = @FC@
-FCFLAGS = @FCFLAGS@ @H5_FCFLAGS@
+FCFLAGS = @FCFLAGS@
FCFLAGS_f90 = @FCFLAGS_f90@
FCLIBS = @FCLIBS@
FGREP = @FGREP@
@@ -449,6 +500,8 @@ LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LINUX_LFS = @LINUX_LFS@
+LIPO = @LIPO@
+LL_PATH = @LL_PATH@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
@@ -459,13 +512,17 @@ MPE = @MPE@
MPI_GET_SIZE = @MPI_GET_SIZE@
NM = @NM@
NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@
OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PARALLEL = @PARALLEL@
PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -481,12 +538,7 @@ SEARCH = @SEARCH@
SED = @SED@
SETX = @SETX@
SET_MAKE = @SET_MAKE@
-
-# Hardcode SHELL to be /bin/sh. Most machines have this shell, and
-# on at least one machine configure fails to detect its existence (janus).
-# Also, when HDF5 is configured on one machine but run on another,
-# configure's automatic SHELL detection may not work on the build machine.
-SHELL = /bin/sh
+SHELL = @SHELL@
SIZE_T = @SIZE_T@
STATIC_EXEC = @STATIC_EXEC@
STATIC_SHARED = @STATIC_SHARED@
@@ -506,6 +558,7 @@ USE_FILTER_SHUFFLE = @USE_FILTER_SHUFFLE@
USE_FILTER_SZIP = @USE_FILTER_SZIP@
USINGMEMCHECKER = @USINGMEMCHECKER@
VERSION = @VERSION@
+WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@@ -528,6 +581,8 @@ build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
+
+# Install directories that automake doesn't know about
docdir = $(exec_prefix)/doc
dvidir = @dvidir@
enable_shared = @enable_shared@
@@ -539,9 +594,7 @@ host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
-
-# Install directories that automake doesn't know about
-includedir = $(exec_prefix)/include
+includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
@@ -561,6 +614,7 @@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@@ -613,26 +667,29 @@ TRACE = perl $(top_srcdir)/bin/trace
CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \
compact_dataset.h5 dataset.h5 dset_offset.h5 \
max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
- huge_chunks.h5 extend.h5 istore.h5 tfile[1-4].h5 th5s[1-3].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 \
+ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \
+ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
+ sys_file1 tfile[1-4].h5 th5s[1-3].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[1-8].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_read.h5 \
- set_extent_create.h5 getname.h5 getname[1-3].h5 sec2_file.h5 \
- direct_file.h5 family_file000[0-3][0-9].h5 multi_file-[rs].h5 \
- core_file new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.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
+ objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \
+ app_ref.h5 farray.h5 earray.h5
INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
-TEST_SCRIPT = testerror.sh
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh
check_SCRIPTS = $(TEST_SCRIPT)
SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
@@ -646,10 +703,10 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
- fillval mount flush1 flush2 enum \
+ fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe \
getname vfd ntypes dangle dtransform reserved cross_read \
- btree2 fheap
+ freespace mf farray earray btree2 fheap
# These programs generate test files for the tests. They don't need to be
@@ -661,7 +718,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \
# so do not appear in this list.
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_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread
# The libh5test library provides common support code for the tests.
@@ -686,7 +743,7 @@ testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
# Temporary files.
-DISTCLEANFILES = testerror.sh
+DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh
# Automake needs to be taught how to build lib, progs, and tests targets.
# These will be filled in automatically for the most part (e.g.,
@@ -711,14 +768,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
- cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign test/Makefile
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign test/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -736,8 +793,13 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+testcheck_version.sh: $(top_builddir)/config.status $(srcdir)/testcheck_version.sh.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
testerror.sh: $(top_builddir)/config.status $(srcdir)/testerror.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+testlibinfo.sh: $(top_builddir)/config.status $(srcdir)/testlibinfo.sh.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@@ -751,18 +813,25 @@ libh5test.la: $(libh5test_la_OBJECTS) $(libh5test_la_DEPENDENCIES)
$(LINK) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
- @list='$(check_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
clean-noinstPROGRAMS:
- @list='$(noinst_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+app_ref$(EXEEXT): $(app_ref_OBJECTS) $(app_ref_DEPENDENCIES)
+ @rm -f app_ref$(EXEEXT)
+ $(LINK) $(app_ref_OBJECTS) $(app_ref_LDADD) $(LIBS)
big$(EXEEXT): $(big_OBJECTS) $(big_DEPENDENCIES)
@rm -f big$(EXEEXT)
$(LINK) $(big_OBJECTS) $(big_LDADD) $(LIBS)
@@ -799,6 +868,9 @@ dtransform$(EXEEXT): $(dtransform_OBJECTS) $(dtransform_DEPENDENCIES)
dtypes$(EXEEXT): $(dtypes_OBJECTS) $(dtypes_DEPENDENCIES)
@rm -f dtypes$(EXEEXT)
$(LINK) $(dtypes_OBJECTS) $(dtypes_LDADD) $(LIBS)
+earray$(EXEEXT): $(earray_OBJECTS) $(earray_DEPENDENCIES)
+ @rm -f earray$(EXEEXT)
+ $(LINK) $(earray_OBJECTS) $(earray_LDADD) $(LIBS)
enum$(EXEEXT): $(enum_OBJECTS) $(enum_DEPENDENCIES)
@rm -f enum$(EXEEXT)
$(LINK) $(enum_OBJECTS) $(enum_LDADD) $(LIBS)
@@ -814,6 +886,9 @@ extend$(EXEEXT): $(extend_OBJECTS) $(extend_DEPENDENCIES)
external$(EXEEXT): $(external_OBJECTS) $(external_DEPENDENCIES)
@rm -f external$(EXEEXT)
$(LINK) $(external_OBJECTS) $(external_LDADD) $(LIBS)
+farray$(EXEEXT): $(farray_OBJECTS) $(farray_DEPENDENCIES)
+ @rm -f farray$(EXEEXT)
+ $(LINK) $(farray_OBJECTS) $(farray_LDADD) $(LIBS)
fheap$(EXEEXT): $(fheap_OBJECTS) $(fheap_DEPENDENCIES)
@rm -f fheap$(EXEEXT)
$(LINK) $(fheap_OBJECTS) $(fheap_LDADD) $(LIBS)
@@ -826,6 +901,9 @@ flush1$(EXEEXT): $(flush1_OBJECTS) $(flush1_DEPENDENCIES)
flush2$(EXEEXT): $(flush2_OBJECTS) $(flush2_DEPENDENCIES)
@rm -f flush2$(EXEEXT)
$(LINK) $(flush2_OBJECTS) $(flush2_LDADD) $(LIBS)
+freespace$(EXEEXT): $(freespace_OBJECTS) $(freespace_DEPENDENCIES)
+ @rm -f freespace$(EXEEXT)
+ $(LINK) $(freespace_OBJECTS) $(freespace_LDADD) $(LIBS)
gen_bad_ohdr$(EXEEXT): $(gen_bad_ohdr_OBJECTS) $(gen_bad_ohdr_DEPENDENCIES)
@rm -f gen_bad_ohdr$(EXEEXT)
$(LINK) $(gen_bad_ohdr_OBJECTS) $(gen_bad_ohdr_LDADD) $(LIBS)
@@ -838,6 +916,9 @@ gen_cross$(EXEEXT): $(gen_cross_OBJECTS) $(gen_cross_DEPENDENCIES)
gen_deflate$(EXEEXT): $(gen_deflate_OBJECTS) $(gen_deflate_DEPENDENCIES)
@rm -f gen_deflate$(EXEEXT)
$(LINK) $(gen_deflate_OBJECTS) $(gen_deflate_LDADD) $(LIBS)
+gen_filespace$(EXEEXT): $(gen_filespace_OBJECTS) $(gen_filespace_DEPENDENCIES)
+ @rm -f gen_filespace$(EXEEXT)
+ $(LINK) $(gen_filespace_OBJECTS) $(gen_filespace_LDADD) $(LIBS)
gen_filters$(EXEEXT): $(gen_filters_OBJECTS) $(gen_filters_DEPENDENCIES)
@rm -f gen_filters$(EXEEXT)
$(LINK) $(gen_filters_OBJECTS) $(gen_filters_LDADD) $(LIBS)
@@ -862,6 +943,9 @@ gen_noencoder$(EXEEXT): $(gen_noencoder_OBJECTS) $(gen_noencoder_DEPENDENCIES)
gen_nullspace$(EXEEXT): $(gen_nullspace_OBJECTS) $(gen_nullspace_DEPENDENCIES)
@rm -f gen_nullspace$(EXEEXT)
$(LINK) $(gen_nullspace_OBJECTS) $(gen_nullspace_LDADD) $(LIBS)
+gen_specmetaread$(EXEEXT): $(gen_specmetaread_OBJECTS) $(gen_specmetaread_DEPENDENCIES)
+ @rm -f gen_specmetaread$(EXEEXT)
+ $(LINK) $(gen_specmetaread_OBJECTS) $(gen_specmetaread_LDADD) $(LIBS)
gen_udlinks$(EXEEXT): $(gen_udlinks_OBJECTS) $(gen_udlinks_DEPENDENCIES)
@rm -f gen_udlinks$(EXEEXT)
$(LINK) $(gen_udlinks_OBJECTS) $(gen_udlinks_LDADD) $(LIBS)
@@ -883,6 +967,9 @@ lheap$(EXEEXT): $(lheap_OBJECTS) $(lheap_DEPENDENCIES)
links$(EXEEXT): $(links_OBJECTS) $(links_DEPENDENCIES)
@rm -f links$(EXEEXT)
$(LINK) $(links_OBJECTS) $(links_LDADD) $(LIBS)
+mf$(EXEEXT): $(mf_OBJECTS) $(mf_DEPENDENCIES)
+ @rm -f mf$(EXEEXT)
+ $(LINK) $(mf_OBJECTS) $(mf_LDADD) $(LIBS)
mount$(EXEEXT): $(mount_OBJECTS) $(mount_DEPENDENCIES)
@rm -f mount$(EXEEXT)
$(LINK) $(mount_OBJECTS) $(mount_LDADD) $(LIBS)
@@ -913,6 +1000,9 @@ space_overflow$(EXEEXT): $(space_overflow_OBJECTS) $(space_overflow_DEPENDENCIES
stab$(EXEEXT): $(stab_OBJECTS) $(stab_DEPENDENCIES)
@rm -f stab$(EXEEXT)
$(LINK) $(stab_OBJECTS) $(stab_LDADD) $(LIBS)
+tcheck_version$(EXEEXT): $(tcheck_version_OBJECTS) $(tcheck_version_DEPENDENCIES)
+ @rm -f tcheck_version$(EXEEXT)
+ $(LINK) $(tcheck_version_OBJECTS) $(tcheck_version_LDADD) $(LIBS)
testhdf5$(EXEEXT): $(testhdf5_OBJECTS) $(testhdf5_DEPENDENCIES)
@rm -f testhdf5$(EXEEXT)
$(LINK) $(testhdf5_OBJECTS) $(testhdf5_LDADD) $(LIBS)
@@ -935,6 +1025,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/app_ref.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/big.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bittests.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btree2.Po@am__quote@
@@ -948,19 +1039,23 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dt_arith.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtransform.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtypes.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err_compat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extend.Po@am__quote@
@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)/fillval.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freespace.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_bad_ohdr.Po@am__quote@
@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_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@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_fill.Po@am__quote@
@@ -969,6 +1064,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_super.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_noencoder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_nullspace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_specmetaread.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_udlinks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getname.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gheap.Po@am__quote@
@@ -977,6 +1073,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/istore.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/links.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntypes.Po@am__quote@
@@ -989,6 +1086,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tarray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tattr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcheck_version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tchecksum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tconfig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcoords.Po@am__quote@
@@ -1024,21 +1122,21 @@ distclean-compile:
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
@@ -1054,14 +1152,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- tags=; \
+ set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -1069,29 +1167,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
- if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$tags $$unique
+ $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
- && cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -1112,13 +1215,17 @@ distdir: $(DISTFILES)
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@@ -1148,6 +1255,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@@ -1170,6 +1278,8 @@ dvi-am:
html: html-am
+html-am:
+
info: info-am
info-am:
@@ -1178,18 +1288,28 @@ install-data-am:
install-dvi: install-dvi-am
+install-dvi-am:
+
install-exec-am:
install-html: install-html-am
+install-html-am:
+
install-info: install-info-am
+install-info-am:
+
install-man:
install-pdf: install-pdf-am
+install-pdf-am:
+
install-ps: install-ps-am
+install-ps-am:
+
installcheck-am:
maintainer-clean: maintainer-clean-am
@@ -1212,7 +1332,7 @@ ps-am:
uninstall-am:
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \
clean clean-checkPROGRAMS clean-generic clean-libtool \
@@ -1447,6 +1567,7 @@ check-vfd: $(LIB) $(PROGS) $(TESTS)
HDF5_DRIVER=$$vfd $(MAKE) $(AM_MAKEFLAGS) check || exit 1; \
fi; \
done
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/test/app_ref.c b/test/app_ref.c
new file mode 100644
index 0000000..611d255
--- /dev/null
+++ b/test/app_ref.c
@@ -0,0 +1,199 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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: Neil Fortner <nfortne2@hdfgroup.org>
+ * Thursday, August 14, 2008
+ *
+ * Purpose: Tests closing the library after reference counts have been
+ * manipulated.
+ */
+#include "h5test.h"
+
+#define APPREF_DSET "test_dset"
+#define APPREF_ATTR "test_attr"
+#define APPREF_GROUP "test_grp"
+
+#define ERR_WIDTH 40 /* Width of output for the SIGABRT handler */
+#define MAX_NINC 16 /* Maximum increments of a reference count */
+
+/* Macro to increment the reference count on id a random number of times (from
+ * 1 to MAX_NINC). Assumes integers i and ninc are in scope. */
+#define RAND_INC(id) \
+ ninc = (HDrand() % MAX_NINC) + 1; \
+ \
+ for (i=0; i<ninc; i++) \
+ if (H5Iinc_ref(ids[id]) != i + 2) \
+ TEST_ERROR \
+ \
+ rc[id] = ninc + 1;
+
+typedef enum {
+ T_FILE,
+ T_PLIST,
+ T_PCLASS,
+ T_TYPE,
+ T_SPACE,
+ T_DSET,
+ T_ATTR,
+ T_GROUP,
+ T_ECLASS,
+ T_EMSG,
+ T_ESTACK,
+ T_NUMCLASSES
+} id_class_t;
+
+const char *FILENAME[] = {
+ "app_ref",
+ NULL
+};
+
+const char *IDNAME[T_NUMCLASSES] = {
+ "File",
+ "Property List",
+ "Property Class",
+ "Datatype",
+ "Dataspace",
+ "Dataset",
+ "Attribute",
+ "Group",
+ "Error Class",
+ "Error Message",
+ "Error Stack"
+};
+
+int rc[T_NUMCLASSES];
+
+void Abrt_Handler (int sig);
+
+/* Handler for SIGABRT - prints the reference count on each id */
+void
+Abrt_Handler (int UNUSED sig)
+{
+ int i, n;
+
+ for (i=0; i<T_NUMCLASSES; i++) {
+ fprintf(stderr, "%s ID reference count: %n", IDNAME[i], &n);
+ fprintf(stderr, "%*d\n", (n < ERR_WIDTH) ? (ERR_WIDTH - n) : 0, rc[i]);
+ }
+}
+
+/* Main test routine */
+int
+main (void)
+{
+ hid_t ids[T_NUMCLASSES];
+ hid_t fapl; /* File Access Property List */
+ int ninc;
+ int i;
+ char filename[1024];
+
+ h5_reset();
+ h5_fixname (FILENAME[0], H5P_DEFAULT, filename, sizeof filename);
+
+ HDsrand ((unsigned) HDtime (NULL));
+
+ TESTING ("library shutdown with reference count > 1");
+
+ /* Create the file */
+ if ((ids[T_FILE] = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_FILE)
+
+ /* Create the property list */
+ if ((ids[T_PLIST] = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_PLIST)
+
+ /* Create a property class */
+ if ((ids[T_PCLASS] = H5Pcreate_class (H5P_DATASET_CREATE, "foo", NULL, NULL,
+ NULL, NULL, NULL, NULL)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_PCLASS)
+
+ /* Create a datatype */
+ if ((ids[T_TYPE] = H5Tcreate (H5T_OPAQUE, (size_t) 16)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_TYPE)
+
+ /* Create a dataspace */
+ if ((ids[T_SPACE] = H5Screate (H5S_SCALAR)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_SPACE)
+
+ /* Create a dataset */
+ if ((ids[T_DSET] = H5Dcreate2 (ids[T_FILE], APPREF_DSET, H5T_NATIVE_INT,
+ ids[T_SPACE], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_DSET)
+
+ /* Create an attribute */
+ if ((ids[T_ATTR] = H5Acreate2 (ids[T_DSET], APPREF_ATTR, H5T_NATIVE_INT,
+ ids[T_SPACE], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_ATTR)
+
+ /* Create a group */
+ if ((ids[T_GROUP] = H5Gcreate2 (ids[T_FILE], APPREF_GROUP, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_GROUP)
+
+ /* Create an error class */
+ if ((ids[T_ECLASS] = H5Eregister_class("foo","bar","baz")) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_ECLASS)
+
+ /* Create an error message */
+ if ((ids[T_EMSG] = H5Ecreate_msg(ids[T_ECLASS],H5E_MAJOR,"mumble")) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_EMSG)
+
+ /* Create an error stack */
+ if ((ids[T_ESTACK] = H5Eget_current_stack()) < 0)
+ TEST_ERROR
+
+ RAND_INC (T_ESTACK)
+
+ HDsignal (SIGABRT, &Abrt_Handler);
+
+ if (H5close() < 0)
+ TEST_ERROR
+
+ PASSED();
+
+ h5_reset();
+ fapl = H5Pcreate (H5P_FILE_ACCESS);
+ h5_cleanup (FILENAME, fapl);
+
+ return 0;
+
+error:
+
+ puts("***** APPLICATION REFERENCE COUNT TESTS FAILED *****");
+
+ return 1;
+}
diff --git a/test/big.c b/test/big.c
index 9899754..dde9d7a 100644
--- a/test/big.c
+++ b/test/big.c
@@ -38,7 +38,7 @@ const char *FILENAME[] = {
#define MAX_TRIES 100
#if H5_SIZEOF_LONG_LONG >= 8
-# define GB8LL ((unsigned long_long)8*1024*1024*1024)
+# define GB8LL ((unsigned long long)8*1024*1024*1024)
#else
# define GB8LL 0 /*cannot do the test*/
#endif
@@ -53,7 +53,7 @@ static hsize_t values_used[WRT_N];
/*-------------------------------------------------------------------------
* Function: randll
*
- * Purpose: Create a random long_long value.
+ * Purpose: Create a random long long value.
* Ensures that a write at this value doesn't overlap any
* previous write.
*
@@ -80,8 +80,8 @@ randll(hsize_t limit, int current_index)
/* does not overlap with any previous writes */
while(overlap != 0 && tries < MAX_TRIES)
{
- acc = rand ();
- acc *= rand ();
+ acc = HDrandom();
+ acc *= HDrandom();
acc = acc % limit;
overlap = 0;
@@ -294,11 +294,6 @@ writer (char* filename, hid_t fapl, int wrt_n)
* or it will take some time to write a file.
* We should create a dataset allocating space late and never writing fill values.
* EIP 4/8/03
-
- if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ||
- (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- goto error;
- }
*/
dcpl = H5Pcreate(H5P_DATASET_CREATE);
H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE);
@@ -381,14 +376,14 @@ reader(char *filename, hid_t fapl)
script = fopen(DNAME, "r");
/* Open HDF5 file */
- if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) goto error;
+ if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR
/* Open the dataset */
- if((d2 = H5Dopen2(file, "d2", H5P_DEFAULT)) < 0) goto error;
- if((fspace = H5Dget_space(d2)) < 0) goto error;
+ if((d2 = H5Dopen2(file, "d2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((fspace = H5Dget_space(d2)) < 0) FAIL_STACK_ERROR
/* Describe `buf' */
- if((mspace = H5Screate_simple(1, hs_size, hs_size)) < 0) goto error;
+ if((mspace = H5Screate_simple(1, hs_size, hs_size)) < 0) FAIL_STACK_ERROR
/* Read each region */
while(fgets(ln, (int)sizeof(ln), script)) {
@@ -400,9 +395,9 @@ reader(char *filename, hid_t fapl)
fflush(stdout);
if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL,
- hs_size, NULL) < 0) goto error;
+ hs_size, NULL) < 0) FAIL_STACK_ERROR
if(H5Dread(d2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0)
- goto error;
+ FAIL_STACK_ERROR
/* Check */
for(j = zero = wrong = 0; j < WRT_SIZE; j++) {
@@ -423,10 +418,10 @@ reader(char *filename, hid_t fapl)
}
}
- if(H5Dclose(d2) < 0) goto error;
- if(H5Sclose(mspace) < 0) goto error;
- if(H5Sclose(fspace) < 0) goto error;
- if(H5Fclose(file) < 0) goto error;
+ if(H5Dclose(d2) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(mspace) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(fspace) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file) < 0) FAIL_STACK_ERROR
free(buf);
fclose(script);
@@ -510,7 +505,7 @@ main (int ac, char **av)
hid_t fapl=-1;
hsize_t family_size;
hsize_t family_size_def; /* default family file size */
- double family_size_def_dbl; /* default family file size */
+ unsigned long seed = 0; /* Random # seed */
int cflag=1; /* check file system before test */
char filename[1024];
@@ -522,11 +517,8 @@ main (int ac, char **av)
if (strcmp("-fsize", *av)==0){
/* specify a different family file size */
ac--; av++;
- if (ac > 0){
- family_size_def_dbl = atof(*av);
- H5_ASSIGN_OVERFLOW(family_size_def,family_size_def_dbl,double,hsize_t);
- if (family_size_def <= 0)
- family_size_def = (hsize_t)FAMILY_SIZE;
+ if (ac > 0) {
+ family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0);
}
else{
printf("***Missing fsize value***\n");
@@ -547,6 +539,14 @@ main (int ac, char **av)
}
}
+ /* Choose random # seed */
+ seed = (unsigned long)HDtime(NULL);
+#ifdef QAK
+/* seed = (unsigned long)1155438845; */
+HDfprintf(stderr, "Random # seed was: %lu\n", seed);
+#endif /* QAK */
+ HDsrandom(seed);
+
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
@@ -573,8 +573,8 @@ main (int ac, char **av)
* because we would generate multi-gigabyte files.
*/
puts("Checking if file system is adequate for this test...");
- if (sizeof(long_long)<8 || 0==GB8LL) {
- puts("Test skipped because sizeof(long_long) is too small. This");
+ if (sizeof(long long)<8 || 0==GB8LL) {
+ puts("Test skipped because sizeof(long long) is too small. This");
puts("hardware apparently doesn't support 64-bit integer types.");
usage();
goto quit;
@@ -600,7 +600,7 @@ main (int ac, char **av)
puts("Test passed with the Family Driver.");
/*
- * We shouldn't run this test if the file system doesn't support big files
+ * We shouldn't run this test if the file system doesn't support big files
* because we would generate multi-gigabyte files.
*/
puts("\nChecking if file system supports big files...");
@@ -657,3 +657,4 @@ error:
puts("*** TEST FAILED ***");
return 1;
}
+
diff --git a/test/btree2.c b/test/btree2.c
index e01de65..eabd208 100644
--- a/test/btree2.c
+++ b/test/btree2.c
@@ -42,6 +42,246 @@ const char *FILENAME[] = {
#define DELETE_MEDIUM 200
#define DELETE_LARGE 2000
+/* Testing parameters */
+typedef struct bt2_test_param_t {
+ hbool_t reopen_btree; /* Whether to re-open the B-tree during the test */
+} bt2_test_param_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: init_cparam
+ *
+ * Purpose: Initialize v2 B-tree creation parameter structure
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, October 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+init_cparam(H5B2_create_t *cparam)
+{
+ /* Wipe out background */
+ HDmemset(cparam, 0, sizeof(*cparam));
+
+ /* General parameters */
+ cparam->cls = H5B2_TEST;
+ cparam->node_size = (size_t)512;
+ cparam->rrec_size = (size_t)8;
+ cparam->split_percent = 100;
+ cparam->merge_percent = 40;
+
+ return(0);
+} /* init_cparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_file
+ *
+ * Purpose: Perform common "creation" operations on file
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 5, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_file(hid_t *file, H5F_t **f, hid_t fapl)
+{
+ char filename[1024]; /* Filename to use */
+
+ /* 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)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ STACK_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* end create_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_btree
+ *
+ * Purpose: Perform common "create" operations on B-tree for testing
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 5, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_btree(H5F_t *f, hid_t dxpl, const H5B2_create_t *cparam,
+ H5B2_t **bt2, haddr_t *bt2_addr)
+{
+ /* Create the v2 B-tree & get its address */
+ if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam, f)))
+ FAIL_STACK_ERROR
+ if(H5B2_get_addr(*bt2, bt2_addr/*out*/) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(*bt2_addr))
+ FAIL_STACK_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* end create_btree() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: reopen_btree
+ *
+ * Purpose: Perform common "re-open" operations on B-tree for testing
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 5, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+reopen_btree(H5F_t *f, hid_t dxpl, H5B2_t **bt2, haddr_t bt2_addr,
+ const bt2_test_param_t *tparam)
+{
+ /* Check for closing & re-opening the B-tree */
+ if(tparam->reopen_btree) {
+ /* Close (empty) v2 B-tree */
+ if(H5B2_close(*bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open v2 B-tree */
+ if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* end reopen_btree() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_stats
+ *
+ * Purpose: Check statistics about v1 B-tree
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 5, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_stats(H5B2_t *bt2, const H5B2_stat_t *expected)
+{
+ H5B2_stat_t actual; /* Actual stats retrieved about v2 B-tree */
+
+ /* Get current stats */
+ if(H5B2_stat_info(bt2, &actual) < 0)
+ FAIL_STACK_ERROR
+ if(actual.depth != expected->depth)
+ TEST_ERROR
+ if(actual.nrecords != expected->nrecords)
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* end check_stats() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_node_depth
+ *
+ * Purpose: Check the depth of the node containing a record
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 5, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_node_depth(H5B2_t *bt2, hid_t dxpl, hsize_t record, unsigned depth)
+{
+ int rec_depth; /* Depth of record in B-tree */
+
+ if((rec_depth = H5B2_get_node_depth_test(bt2, dxpl, &record)) < 0)
+ FAIL_STACK_ERROR
+ if((unsigned)rec_depth != depth)
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* end check_node_depth() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_node_info
+ *
+ * Purpose: Check the info of the node containing a record
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Friday, November 6, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_node_info(H5B2_t *bt2, hid_t dxpl, hsize_t record,
+ H5B2_node_info_test_t *ninfo)
+{
+ H5B2_node_info_test_t rec_ninfo; /* Node info for record in B-tree */
+
+ if(H5B2_get_node_info_test(bt2, dxpl, &record, &rec_ninfo) < 0)
+ FAIL_STACK_ERROR
+ if(rec_ninfo.depth != ninfo->depth)
+ TEST_ERROR
+ if(rec_ninfo.nrec != ninfo->nrec)
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* end check_node_depth() */
+
/*-------------------------------------------------------------------------
* Function: iter_cb
@@ -76,9 +316,9 @@ iter_cb(const void *_record, void *_op_data)
*
* Purpose: v2 B-tree find callback
*
- * Return: Success: 0
+ * Return: Success: TRUE/FALSE
*
- * Failure: 1
+ * Failure: FAIL
*
* Programmer: Quincey Koziol
* Thursday, February 24, 2005
@@ -92,9 +332,9 @@ find_cb(const void *_record, void *_op_data)
hsize_t *search = (hsize_t *)_op_data;
if(*record != *search)
- return(-1);
+ return(FALSE);
- return(0);
+ return(TRUE);
} /* end find_cb() */
@@ -211,7 +451,6 @@ remove_cb(const void *_record, void *_op_data)
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -219,41 +458,46 @@ remove_cb(const void *_record, void *_op_data)
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_basic(hid_t fapl)
+static unsigned
+test_insert_basic(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
- char filename[1024]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t idx; /* Index within B-tree, for iterator */
- haddr_t bt2_addr; /* Address of B-tree created */
herr_t ret; /* Generic error return value */
- /* Set the filename to use for this test (dependent on fapl) */
- h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+ /*
+ * Test v2 B-tree creation
+ */
+ TESTING("B-tree creation");
- /* Create the file to work on */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
TEST_ERROR
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
+
+ PASSED();
/*
- * Test v2 B-tree creation
+ * Test queries/iterations on empty v2 B-tree
*/
- TESTING("B-tree creation");
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
- if(!H5F_addr_defined(bt2_addr))
- FAIL_STACK_ERROR
- PASSED();
+ TESTING("B-tree iteration: empty B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
/* Attempt to iterate over a B-tree with no records */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index hasn't changed */
if(idx != 0)
@@ -261,60 +505,57 @@ test_insert_basic(hid_t fapl)
/* Attempt to find record in B-tree with no records */
idx = 0;
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, NULL);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, NULL) != FALSE)
TEST_ERROR
/* Attempt to index record in B-tree with no records */
idx = 0;
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)0, find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
+ PASSED();
+
/*
- * Test inserting record into v2 B-tree
+ * Test inserting first record into v2 B-tree
*/
- TESTING("B-tree insert: several records");
+ TESTING("B-tree insert: first record");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = 42;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Attempt to find non-existant record in B-tree with 1 record */
+ /* (Should not be found, but not fail) */
idx = 41;
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Try again with NULL 'op' */
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, NULL, NULL);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ /* (Should not be found, but not fail) */
+ if(H5B2_find(bt2, dxpl, &idx, NULL, NULL) != FALSE)
TEST_ERROR
/* Attempt to find existant record in B-tree with 1 record */
idx = 42;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
TEST_ERROR
/* Try again with NULL 'op' */
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, NULL, NULL)<0)
+ if(H5B2_find(bt2, dxpl, &idx, NULL, NULL) != TRUE)
TEST_ERROR
/* Attempt to index non-existant record in B-tree with 1 record */
idx = 0;
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)1, find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -322,48 +563,56 @@ test_insert_basic(hid_t fapl)
/* Attempt to index existing record in B-tree with 1 record */
idx = 42;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)0, find_cb, &idx)<0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0)
+ TEST_ERROR
+
+ PASSED();
+
+ /*
+ * Test inserting more records into v2 B-tree
+ */
+ TESTING("B-tree insert: several records");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/*
* Test inserting second record into v2 B-tree, before all other records
*/
record = 34;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/*
* Test inserting third record into v2 B-tree, after all other records
*/
record = 56;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/*
* Test inserting fourth record into v2 B-tree, in the middle of other records
*/
record = 38;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Attempt to find non-existant record in level-0 B-tree with several records */
+ /* (Should not be found, but not fail) */
idx = 41;
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Attempt to find existant record in level-0 B-tree with several record */
idx = 56;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
TEST_ERROR
/* Attempt to index non-existant record in B-tree with several records */
idx = 0;
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)4, find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)4, find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -371,29 +620,36 @@ test_insert_basic(hid_t fapl)
/* Attempt to index existing record in B-tree with several records */
idx = 34;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)0, find_cb, &idx)<0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0)
TEST_ERROR
idx = 38;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)1, find_cb, &idx)<0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, find_cb, &idx) < 0)
TEST_ERROR
idx = 42;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)2, find_cb, &idx)<0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)2, find_cb, &idx) < 0)
TEST_ERROR
idx = 56;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)3, find_cb, &idx)<0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)3, find_cb, &idx) < 0)
TEST_ERROR
- PASSED();
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
/* Close the file */
- if(H5Fclose(file)<0)
+ if(H5Fclose(file) < 0)
TEST_ERROR
+ PASSED();
+
/* All tests passed */
return(0);
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -409,7 +665,6 @@ error:
* left and right leaf nodes after the split
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -417,132 +672,121 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_split_root(hid_t fapl)
+static unsigned
+test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t idx; /* Index within B-tree, for iterator */
- haddr_t bt2_addr; /* Address of B-tree created */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
unsigned u; /* Local index variable */
herr_t ret; /* Generic error return value */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting enough records into v2 B-tree to split the root node
*/
TESTING("B-tree insert: split root");
- /*
- * Test v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert records to fill root leaf node */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC - 1); u++) {
record = u + 2;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 0)
+ bt2_stat.depth = 0;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC - 1);
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC - 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)0) < 0)
TEST_ERROR
- record = 33;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert record to split root leaf node */
record = INSERT_SPLIT_ROOT_NREC + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)1) < 0)
TEST_ERROR
- record = 33;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
+
/* Insert a couple more records, on the left side of the B-tree */
- record=0;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ record = 0;
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
- record=1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ record = 1;
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + 2);
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC + 2))
+ if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)1) < 0)
TEST_ERROR
- record = 33;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
+
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
- if(idx != (INSERT_SPLIT_ROOT_NREC+2))
+ if(idx != (INSERT_SPLIT_ROOT_NREC + 2))
TEST_ERROR
/* Attempt to find non-existant record in level-1 B-tree */
+ /* (Should not be found, but not fail) */
idx = INSERT_SPLIT_ROOT_NREC + 10;
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Attempt to find existant record in root of level-1 B-tree */
idx = 33;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) < 0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
FAIL_STACK_ERROR
/* Attempt to find existant record in leaf of level-1 B-tree */
idx = 56;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) < 0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
FAIL_STACK_ERROR
/* Attempt to index non-existant record in level-1 B-tree */
idx = 0;
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC+2), find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC+2), find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -550,28 +794,35 @@ test_insert_split_root(hid_t fapl)
/* Attempt to index existing record in root of level-1 B-tree */
idx = 33;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)33, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)33, find_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Attempt to index existing record in left leaf of level-1 B-tree */
idx = 0;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Attempt to index existing record in right leaf of level-1 B-tree */
idx = 50;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)50, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)50, find_cb, &idx) < 0)
FAIL_STACK_ERROR
- PASSED();
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
if(H5Fclose(file) < 0)
TEST_ERROR
+ PASSED();
+
return 0;
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -588,7 +839,6 @@ error:
* redistribution
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -596,78 +846,71 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level1_2leaf_redistrib(hid_t fapl)
+static unsigned
+test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: redistribute 2 leaves in level 1 B-tree (l->r)");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u + (INSERT_SPLIT_ROOT_NREC/2) + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ if(check_node_depth(bt2, dxpl, (hsize_t)INSERT_SPLIT_ROOT_NREC, (unsigned)1) < 0)
TEST_ERROR
- record = INSERT_SPLIT_ROOT_NREC;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
+
/* Force redistribution from left node into right node */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1);
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1), (unsigned)1) < 0)
TEST_ERROR
- record = (INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
+
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
FAIL_STACK_ERROR
- if(rec_depth != 1)
- TEST_ERROR
+ bt2 = NULL;
PASSED();
@@ -676,51 +919,48 @@ test_insert_level1_2leaf_redistrib(hid_t fapl)
*/
TESTING("B-tree insert: redistribute 2 leaves in level 1 B-tree (r->l)");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ if(check_node_depth(bt2, dxpl, (hsize_t)(INSERT_SPLIT_ROOT_NREC / 2), (unsigned)1) < 0)
TEST_ERROR
- record = (INSERT_SPLIT_ROOT_NREC / 2);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Force redistribution from left node into right node */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) {
record = u + INSERT_SPLIT_ROOT_NREC;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1), (unsigned)1) < 0)
TEST_ERROR
- record = (INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
+
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
FAIL_STACK_ERROR
- if(rec_depth != 1)
- TEST_ERROR
+ bt2 = NULL;
/* Close file */
if(H5Fclose(file) < 0)
@@ -732,6 +972,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -748,7 +990,6 @@ error:
* split, adding another node to the B-tree
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -756,84 +997,76 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level1_side_split(hid_t fapl)
+static unsigned
+test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: split side leaf into 2 leaves in level 1 B-tree (l->r)");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u + INSERT_SPLIT_ROOT_NREC;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
- TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Force left node to split */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
- TEST_ERROR
- if(bt2_stat.nrecords != (2 * INSERT_SPLIT_ROOT_NREC))
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 31;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 63;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
PASSED();
/*
@@ -841,56 +1074,51 @@ test_insert_level1_side_split(hid_t fapl)
*/
TESTING("B-tree insert: split side leaf into 2 leaves in level 1 B-tree (r->l)");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
- TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = (INSERT_SPLIT_ROOT_NREC / 2);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Force right node to split */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u + INSERT_SPLIT_ROOT_NREC;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (2 * INSERT_SPLIT_ROOT_NREC))
+ if(check_node_depth(bt2, dxpl, (hsize_t)62, (unsigned)1) < 0)
TEST_ERROR
- record = 62;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0)
TEST_ERROR
- record = 94;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
+
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
FAIL_STACK_ERROR
- if(rec_depth != 1)
- TEST_ERROR
+ bt2 = NULL;
/* Close file */
if(H5Fclose(file) < 0)
@@ -902,6 +1130,8 @@ test_insert_level1_side_split(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -927,119 +1157,111 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level1_3leaf_redistrib(hid_t fapl)
+static unsigned
+test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: redistribute 3 leaves in level 1 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u + (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
- TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = (2 * INSERT_SPLIT_ROOT_NREC);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Force left node to split */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
- TEST_ERROR
- if(bt2_stat.nrecords != (2 * INSERT_SPLIT_ROOT_NREC))
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = (INSERT_SPLIT_ROOT_NREC / 2);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert records to force middle node to redistribute */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC / 2) + 1); u++) {
record = u + INSERT_SPLIT_ROOT_NREC;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)52, (unsigned)1) < 0)
TEST_ERROR
- record = 52;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)105, (unsigned)1) < 0)
TEST_ERROR
- record = 105;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 2) + (INSERT_SPLIT_ROOT_NREC / 2) + 1))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
@@ -1050,6 +1272,8 @@ test_insert_level1_3leaf_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -1067,7 +1291,6 @@ error:
* add records until a 3 node split occurs
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -1075,99 +1298,90 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level1_middle_split(hid_t fapl)
+static unsigned
+test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: split middle leaf into 2 leaves in level 1 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 2);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
- TEST_ERROR
- if(bt2_stat.nrecords != INSERT_SPLIT_ROOT_NREC)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2);
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Force split from left node into right node */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 1)
+ bt2_stat.depth = 1;
+ bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (3 * INSERT_SPLIT_ROOT_NREC))
+ if(check_node_depth(bt2, dxpl, (hsize_t)62, (unsigned)1) < 0)
TEST_ERROR
- record = 62;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0)
TEST_ERROR
- record = 94;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)126, (unsigned)1) < 0)
TEST_ERROR
- record = 126;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != (INSERT_SPLIT_ROOT_NREC * 3))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -1178,6 +1392,8 @@ test_insert_level1_middle_split(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -1191,7 +1407,6 @@ error:
* records to make a level 2 B-tree
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -1199,86 +1414,82 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_make_level2(hid_t fapl)
+static unsigned
+test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
herr_t ret; /* Generic error return value */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: make level 2 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 internal nodes */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 9); u++) {
record = u + 2;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
for(; u < ((INSERT_SPLIT_ROOT_NREC * 29) + 1); u++) {
record = u + 4;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 29) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)948, (unsigned)2) < 0)
TEST_ERROR
- record = 948;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Add some extra records to left-most leaf */
record = 0;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
record = 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Add some extra records to middle leaf */
record = (INSERT_SPLIT_ROOT_NREC * 9) + 2;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
record = (INSERT_SPLIT_ROOT_NREC * 9) + 3;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
@@ -1286,54 +1497,42 @@ test_insert_make_level2(hid_t fapl)
TEST_ERROR
/* Attempt to find non-existant record in level-2 B-tree */
+ /* (Should not be found, but not fail) */
idx = INSERT_SPLIT_ROOT_NREC * 30;
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Attempt to find existant record in root of level-2 B-tree */
idx = 948;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) < 0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
FAIL_STACK_ERROR
/* Check with B-tree */
- record = 948;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)948, (unsigned)2) < 0)
TEST_ERROR
/* Attempt to find existant record in internal node of level-2 B-tree */
idx = 505;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) < 0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
FAIL_STACK_ERROR
/* Check with B-tree */
- record = 505;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)505, (unsigned)1) < 0)
TEST_ERROR
/* Attempt to find existant record in leaf of level-2 B-tree */
idx = 555;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) < 0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
FAIL_STACK_ERROR
/* Check with B-tree */
- record = 555;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, (hsize_t)555, (unsigned)0) < 0)
TEST_ERROR
/* Attempt to index non-existant record in level-2 B-tree */
idx = 0;
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC * 30), find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC * 30), find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -1341,18 +1540,23 @@ test_insert_make_level2(hid_t fapl)
/* Attempt to index existing record in root of level-2 B-tree */
idx = 948;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)948, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)948, find_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Attempt to index existing record in internal node of level-2 B-tree */
idx = 505;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)505, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)505, find_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Attempt to index existing record in leaf of level-2 B-tree */
idx = 555;
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)555, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, find_cb, &idx) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
FAIL_STACK_ERROR
+ bt2 = NULL;
/* Close file */
if(H5Fclose(file) < 0)
@@ -1364,6 +1568,8 @@ test_insert_make_level2(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -1386,129 +1592,97 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level2_leaf_redistrib(hid_t fapl)
+static unsigned
+test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: redistrib right-most leaf in level 2 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 internal nodes */
/* And fill rightmost leaf */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 8); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC / 2) + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
for(; u < ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)); u++) {
record = u + INSERT_SPLIT_ROOT_NREC + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2);
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)))
+ if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0)
TEST_ERROR
- record = 1008; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)1859, (unsigned)1) < 0)
TEST_ERROR
- record = 1859; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)1921, (unsigned)0) < 0)
TEST_ERROR
- record = 1921; /* Right-most record in right-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert record to force redistribution of rightmost leaf */
record = u + INSERT_SPLIT_ROOT_NREC + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0)
TEST_ERROR
- record = 1008; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)1875, (unsigned)1) < 0)
TEST_ERROR
- record = 1875; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
- TEST_ERROR
- record = 1922; /* Right-most record in right-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, (hsize_t)1922, (unsigned)0) < 0)
TEST_ERROR
PASSED();
TESTING("B-tree insert: redistrib left-most leaf in level 2 B-tree");
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1))
+
+ /* Check up on B-tree */
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- record = 1008; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0)
TEST_ERROR
- record = 94; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0)
TEST_ERROR
- record = 32; /* Left-most record in left-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, (hsize_t)32, (unsigned)0) < 0)
TEST_ERROR
/* Add more records to left-most leaf, to force a 2->1 split and then a
@@ -1516,109 +1690,83 @@ test_insert_level2_leaf_redistrib(hid_t fapl)
*/
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 30) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0)
TEST_ERROR
- record = 1008; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)47, (unsigned)1) < 0)
TEST_ERROR
- record = 47; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
- TEST_ERROR
- record = 0;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, (hsize_t)0, (unsigned)0) < 0)
TEST_ERROR
PASSED();
TESTING("B-tree insert: redistrib middle leaf in level 2 B-tree");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 30) + 1))
+ if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) /* Record in root node */
TEST_ERROR
- record = 1008; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)535, (unsigned)1) < 0) /* Record in middle node before insertion point */
TEST_ERROR
- record = 535; /* Record in middle node before insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)630, (unsigned)1) < 0) /* Record in middle node after insertion point */
TEST_ERROR
- record = 630; /* Record in middle node after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
- TEST_ERROR
- record = 568; /* Record in leaf node just after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, (hsize_t)568, (unsigned)0) < 0) /* Record in leaf node just after insertion point */
TEST_ERROR
/* Add more records to middle leaf, to force a split and a 3 node redistribution on middle leaf */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 8) + (INSERT_SPLIT_ROOT_NREC / 2) + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2))
+ if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) /* Record in root node */
TEST_ERROR
- record = 1008; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, (hsize_t)524, (unsigned)1) < 0) /* Record in middle node before insertion point */
TEST_ERROR
- record = 524; /* Record in middle node before insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)577, (unsigned)1) < 0) /* Record in middle node after insertion point */
TEST_ERROR
- record = 577; /* Record in middle node after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, (hsize_t)568, (unsigned)0) < 0) /* Record in leaf node just after insertion point */
TEST_ERROR
- record = 568; /* Record in leaf node just after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -1629,6 +1777,8 @@ test_insert_level2_leaf_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -1651,249 +1801,205 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level2_leaf_split(hid_t fapl)
+static unsigned
+test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: split right-most leaf in level 2 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 internal nodes */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 8); u++) {
record = u + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
for(; u < ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)); u++) {
record = u + 2;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2);
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 946; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 1797; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 1859; /* Right-most record in right-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert enough records to force right-most leaf to split */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC / 2) + 1); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 2;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC * 30))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 30;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 946; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 1828; /* Next-to-right-most record in right-most internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 1860; /* Right-most record in right-most internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 1891; /* Right-most record in right-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
PASSED();
TESTING("B-tree insert: split left-most leaf in level 2 B-tree");
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC * 30))
+
+ /* Check up on B-tree */
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 30;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 946; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 63; /* Left-most record in left-most internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 1; /* Left-most record in left-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
/* Add another record to left-most leaf, to force a 1->2 node split on left leaf */
record = 0;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 30) + 1))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 946; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
- record = 63; /* Next-to-left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ record = 63; /* Left-most record in left-most internal node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 32; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 0; /* Left-most record in left-most leaf */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
PASSED();
TESTING("B-tree insert: split middle leaf in level 2 B-tree");
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 30) + 1))
+
+ /* Check up on B-tree */
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 946; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 504; /* Record in internal node just before insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 568; /* Record in internal node just after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 506; /* Record in leaf node just after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
/* Add another record to middle leaf, to force a node split on middle leaf */
record = (INSERT_SPLIT_ROOT_NREC * 8) + 1;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 30) + 2))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 2;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 946; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 504; /* Left-most record of split in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 537; /* Middle record of split in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 568; /* Right-most record of split in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 506; /* Record in leaf node just after insertion point */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 30) + 2))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
@@ -1904,6 +2010,8 @@ test_insert_level2_leaf_split(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -1927,166 +2035,143 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level2_2internal_redistrib(hid_t fapl)
+static unsigned
+test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: redist. 2 internal (r->l) in level 2 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 internal nodes */
/* And fill up right internal node, to just before to redistribute it */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 44); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 6) - 4;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC * 44))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 44;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1318; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3114; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3145; /* Right-most record in right leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert record to redistribute right-most internal node */
record = u + (INSERT_SPLIT_ROOT_NREC * 6) - 4;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 44) + 1))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 44 + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1822; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3114; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3146; /* Right-most record in right leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
PASSED();
TESTING("B-tree insert: redist. 2 internal (l->r) in level 2 B-tree");
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 44) + 1))
+
+ /* Check up on B-tree */
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 44 + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1822; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 436; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 374; /* Left-most record in left leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
/* Force left-most internal node to redistribute */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 6) - 4); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 50) - 3))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 50) - 3;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1570; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 61; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 0; /* Left-most record in left leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 50) - 3))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -2097,6 +2182,8 @@ test_insert_level2_2internal_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -2120,175 +2207,149 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level2_2internal_split(hid_t fapl)
+static unsigned
+test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: split side internal node to 2 in level 2 B-tree (r->l)");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 2 internal nodes */
/* (And fill up two child internal nodes) */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 59); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC * 59))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 59;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 2759; /* Record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 4555; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 4586; /* Right-most record in right leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert record to split right-most internal node */
record = u + (INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 59) + 1))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 59) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 2759; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3704; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 4555; /* Right-most record in right internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 4387; /* Right-most record in right leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
PASSED();
TESTING("B-tree insert: split side internal node to 2 in level 2 B-tree (l->2)");
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 59) + 1))
+
+ /* Check up on B-tree */
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 59) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 2759; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 932; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 870; /* Left-most record in left leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
/* Force left-most internal node to split */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 73) - (INSERT_SPLIT_ROOT_NREC / 4) + 4))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 73) - (INSERT_SPLIT_ROOT_NREC / 4) + 4;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 870; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 1814; /* Next-to-left-most record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 61; /* Left-most record in left internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 0; /* Left-most record in left leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 73) - (INSERT_SPLIT_ROOT_NREC / 4) + 4))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -2299,6 +2360,8 @@ test_insert_level2_2internal_split(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -2323,174 +2386,148 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level2_3internal_redistrib(hid_t fapl)
+static unsigned
+test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: redistrib 3 internals in level 2 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 3 internal nodes */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 36); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
for(; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 59) + 1))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 59) + 1;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3703; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 2267; /* Record to left of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3199; /* Record to right of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3137; /* Record just above insertion point in leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert records to fill up middle internal node */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 36);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3703; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3104; /* Record to left of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3137; /* Record to right of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3135; /* Record just above insertion point in leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert another record, forcing the middle internal node to redistribute */
record = u + (INSERT_SPLIT_ROOT_NREC * 36);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 4))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 4;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1574; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3104; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
#ifdef NONE
record = 2862; /* Record to left of insertion point in right internal node (now) */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
#endif /* NONE */
record = 3137; /* Record to right of insertion point in right internal node (now) */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 3135; /* Record just above insertion point in leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 4))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -2501,6 +2538,8 @@ test_insert_level2_3internal_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -2525,180 +2564,152 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_level2_3internal_split(hid_t fapl)
+static unsigned
+test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
- int rec_depth; /* Depth of record in B-tree */
hsize_t idx; /* Index within B-tree, for iterator */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/*
* Test inserting many records into v2 B-tree
*/
TESTING("B-tree insert: split 3 internals to 4 in level 2 B-tree");
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert enough records to force root to split into 3 internal nodes */
/* (and fill right internal node) */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
for(; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) {
record = u + ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(bt2_stat.nrecords != (INSERT_SPLIT_ROOT_NREC * 74))
+
+ /* Check up on B-tree */
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 74;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3703; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 1952; /* Record to left of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 2884; /* Record to right of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 2822; /* Record just after insertion point in leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
/* Insert records to fill up middle internal node */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) {
record = u + (INSERT_SPLIT_ROOT_NREC * 31);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3703; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 2789; /* Record to left of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 2822; /* Record to right of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 2823; /* Record just above insertion point in leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Insert record to split middle internal node */
record = u + (INSERT_SPLIT_ROOT_NREC * 31);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 2)
- TEST_ERROR
- if(bt2_stat.nrecords != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3))
+ bt2_stat.depth = 2;
+ bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 2789; /* Middle record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
record = 3703; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
#ifdef NONE
record = 3049; /* Record to left of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
#endif /* NONE */
record = 2822; /* Record to right of insertion point in middle internal node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
- record = 2823; /* Record just after insertion point in leaf node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ record = 2823; /* Record just above insertion point in leaf node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
if(idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
@@ -2709,6 +2720,8 @@ test_insert_level2_3internal_split(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -2730,14 +2743,17 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_insert_lots(hid_t fapl)
+static unsigned
+test_insert_lots(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
hsize_t idx; /* Index within B-tree, for iterator */
time_t curr_time; /* Current time, for seeding random number generator */
hsize_t *records; /* Record #'s for random insertion */
@@ -2754,7 +2770,7 @@ test_insert_lots(hid_t fapl)
curr_time=1109170019;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/*
* Test inserting many records into v2 B-tree
@@ -2762,52 +2778,54 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
TESTING("B-tree insert: create random level 4 B-tree");
/* Allocate space for the records */
- if((records = HDmalloc(sizeof(hsize_t) * INSERT_MANY)) == NULL)
+ if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY)))
TEST_ERROR
/* Initialize record #'s */
- for(u=0; u<INSERT_MANY; u++)
+ for(u = 0; u < INSERT_MANY; u++)
records[u] = u;
/* Shuffle record #'s */
- for(u=0; u<INSERT_MANY; u++) {
- swap_idx = (unsigned)(HDrandom()%(INSERT_MANY-u))+u;
+ for(u = 0; u < INSERT_MANY; u++) {
+ swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u;
temp_rec = records[u];
records[u] = records[swap_idx];
records[swap_idx] = temp_rec;
} /* end for */
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ /* 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)
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- FAIL_STACK_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ STACK_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert random records */
for(u = 0; u < INSERT_MANY; u++) {
record = records[u];
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 4)
- TEST_ERROR
- if(bt2_stat.nrecords != INSERT_MANY)
+ bt2_stat.depth = 4;
+ bt2_stat.nrecords = INSERT_MANY;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -2817,20 +2835,22 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
- /* Check up on B-tree after re-open */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
FAIL_STACK_ERROR
- if(bt2_stat.depth != 4)
- TEST_ERROR
- if(bt2_stat.nrecords != INSERT_MANY)
+
+ /* Check up on B-tree after re-open */
+ bt2_stat.depth = 4;
+ bt2_stat.nrecords = INSERT_MANY;
+ if(check_stats(bt2, &bt2_stat) < 0)
TEST_ERROR
/* Iterate over B-tree to check records have been inserted correctly */
idx = 0;
- if(H5B2_iterate(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, iter_cb, &idx) < 0)
+ if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Make certain that the index is correct */
@@ -2838,12 +2858,9 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
TEST_ERROR
/* Attempt to find non-existant record in level-4 B-tree */
- idx = INSERT_MANY*2;
- H5E_BEGIN_TRY {
- ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx);
- } H5E_END_TRY;
- /* Should fail */
- if(ret != FAIL)
+ /* (Should not be found, but not fail) */
+ idx = INSERT_MANY * 2;
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Find random records */
@@ -2852,19 +2869,19 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
idx = (hsize_t)(HDrandom()%INSERT_MANY);
/* Attempt to find existant record in root of level-4 B-tree */
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) < 0)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE)
FAIL_STACK_ERROR
} /* end for */
/* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
H5E_BEGIN_TRY {
- ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL);
+ ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -2877,12 +2894,12 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Attempt to find existant record in root of level-4 B-tree */
/* (in increasing order) */
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, idx, find_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, find_cb, &idx) < 0)
FAIL_STACK_ERROR
/* Attempt to find existant record in root of level-4 B-tree */
/* (in decreasing order) */
- if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0)
+ if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0)
FAIL_STACK_ERROR
} /* end for */
@@ -2890,22 +2907,31 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
TESTING("B-tree insert: attempt duplicate record in level 4 B-tree");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = INSERT_MANY / 2;
H5E_BEGIN_TRY {
- ret = H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record);
+ ret = H5B2_insert(bt2, dxpl, &record);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != INSERT_MANY)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -2918,6 +2944,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
HDfree(records);
@@ -2931,7 +2959,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -2939,40 +2966,34 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_basic(hid_t fapl)
+static unsigned
+test_remove_basic(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
herr_t ret; /* Generic error return value */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/* Record removal tests */
TESTING("B-tree remove: record from empty B-tree");
- /*
- * Test v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -2982,7 +3003,7 @@ test_remove_basic(hid_t fapl)
/* Attempt to remove a record from a B-tree with no records */
record = 0;
H5E_BEGIN_TRY {
- ret = H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, NULL, NULL);
+ ret = H5B2_remove(bt2, dxpl, &record, NULL, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -2992,13 +3013,17 @@ test_remove_basic(hid_t fapl)
TESTING("B-tree remove: non-existant record from 1 record B-tree");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Insert one record into B-tree */
record = 42;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3006,7 +3031,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
@@ -3016,7 +3041,7 @@ test_remove_basic(hid_t fapl)
/* Attempt to remove a non-existant record from a B-tree with 1 record */
record = 0;
H5E_BEGIN_TRY {
- ret = H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, NULL, NULL);
+ ret = H5B2_remove(bt2, dxpl, &record, NULL, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -3026,9 +3051,14 @@ test_remove_basic(hid_t fapl)
/* Attempt to remove a record from a B-tree with 1 record */
TESTING("B-tree remove: existant record from 1 record B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = 42;
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3036,7 +3066,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3044,7 +3074,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the root node has been freed */
@@ -3056,22 +3086,26 @@ test_remove_basic(hid_t fapl)
/* Attempt to insert records into B-tree which had records removed */
TESTING("B-tree remove: adding records to B-tree after removal");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Insert several records into B-tree again */
- record=42;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ record = 42;
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
- record=34;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ record = 34;
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
- record=56;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ record = 56;
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
- record=38;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ record = 38;
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3082,9 +3116,14 @@ test_remove_basic(hid_t fapl)
/* Attempt to remove a non-existant record from a level-0 B-tree with mult. record */
TESTING("B-tree remove: non-existant record from level-0 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = 0;
H5E_BEGIN_TRY {
- ret = H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, NULL, NULL);
+ ret = H5B2_remove(bt2, dxpl, &record, NULL, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -3094,9 +3133,14 @@ test_remove_basic(hid_t fapl)
/* Attempt to remove a record from a level-0 B-tree with mult. record */
TESTING("B-tree remove: mult. existant records from level-0 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = 42;
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3104,7 +3148,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3112,7 +3156,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the root node has not been freed */
@@ -3121,7 +3165,7 @@ test_remove_basic(hid_t fapl)
record = 34;
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3129,7 +3173,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3137,7 +3181,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the root node has not been freed */
@@ -3146,7 +3190,7 @@ test_remove_basic(hid_t fapl)
record = 56;
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3154,7 +3198,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3162,7 +3206,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the root node has not been freed */
@@ -3171,7 +3215,7 @@ test_remove_basic(hid_t fapl)
record = 38;
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3179,7 +3223,7 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3187,13 +3231,18 @@ test_remove_basic(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the root node has been freed */
if(H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
@@ -3204,6 +3253,8 @@ test_remove_basic(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -3216,7 +3267,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3224,49 +3274,42 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_noredistrib(hid_t fapl)
+static unsigned
+test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
unsigned u; /* Local index variable */
herr_t ret; /* Generic error return value */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/* B-tree record removal tests */
TESTING("B-tree remove: non-existant record from level-1 B-tree");
- /*
- * Test v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3274,7 +3317,7 @@ test_remove_level1_noredistrib(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
@@ -3284,14 +3327,14 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Attempt to remove a non-existant record from a B-tree with 1 record */
record = (INSERT_SPLIT_ROOT_NREC * 2) + 1;
H5E_BEGIN_TRY {
- ret = H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, NULL, NULL);
+ ret = H5B2_remove(bt2, dxpl, &record, NULL, NULL);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3302,23 +3345,24 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Attempt to remove a record from right leaf of a level-1 B-tree with noredistribution */
TESTING("B-tree remove: record from right leaf of level-1 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Check up on B-tree */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 94; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = (INSERT_SPLIT_ROOT_NREC * 2) - 2;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
+
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3327,18 +3371,14 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Make certain that the leaf nodes didn't redistribute */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 94; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3349,13 +3389,18 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Attempt to remove a record from left leaf of a level-1 B-tree with noredistribution */
TESTING("B-tree remove: record from left leaf of level-1 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Check up on B-tree */
record = 0;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
+
rrecord = 1;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3364,18 +3409,14 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Make certain that the leaf nodes didn't redistribute */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 94; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3386,13 +3427,18 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Attempt to remove a record from middle leaf of a level-1 B-tree with noredistribution */
TESTING("B-tree remove: record from middle leaf of level-1 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Check up on B-tree */
record = INSERT_SPLIT_ROOT_NREC;
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 0)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0)
TEST_ERROR
+
rrecord = 0;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3401,32 +3447,37 @@ test_remove_level1_noredistrib(hid_t fapl)
/* Make certain that the leaf nodes didn't redistribute */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 94; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 3))
TEST_ERROR
- PASSED();
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
- if (H5Fclose(file)<0) TEST_ERROR
+ PASSED();
return 0;
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -3439,7 +3490,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3447,60 +3497,49 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_redistrib(hid_t fapl)
+static unsigned
+test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
/* More complex record removals */
TESTING("B-tree remove: redistribute 2 leaves in level-1 B-tree (r->l)");
- /*
- * Test v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 94; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3508,18 +3547,22 @@ test_remove_level1_redistrib(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove enough records from right leaf of a level-1 B-tree to force redistribution */
for(u = 0; u < 8; u++) {
record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3527,7 +3570,7 @@ test_remove_level1_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3537,24 +3580,25 @@ test_remove_level1_redistrib(hid_t fapl)
/* Check record values in root of B-tree */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 90; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
PASSED();
/* Attempt to remove enough records from left leaf of a level-1 B-tree to force redistribution */
TESTING("B-tree remove: redistribute 2 leaves in level-1 B-tree (l->r)");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
for(u = 0; u < 39; u++) {
record = u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3562,7 +3606,7 @@ test_remove_level1_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3572,24 +3616,25 @@ test_remove_level1_redistrib(hid_t fapl)
/* Check record values in root of B-tree */
record = 64; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 90; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
PASSED();
/* Attempt to remove enough records from middle leaf of a level-1 B-tree to force redistribution */
TESTING("B-tree remove: redistribute 3 leaves in level-1 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
for(u = 0; u < 2; u++) {
record = INSERT_SPLIT_ROOT_NREC + 2 + u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3597,7 +3642,7 @@ test_remove_level1_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3607,16 +3652,17 @@ test_remove_level1_redistrib(hid_t fapl)
/* Check record values in root of B-tree */
record = 64; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 91; /* Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -3627,6 +3673,8 @@ test_remove_level1_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -3639,7 +3687,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3647,62 +3694,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_2leaf_merge(hid_t fapl)
+static unsigned
+test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
H5B2_node_info_test_t ninfo; /* B-tree node info */
- int rec_depth; /* Depth of record in B-tree */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: merge 2 leaves to 1 in level-1 B-tree (r->l)");
- /*
- * Test v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3710,18 +3746,22 @@ test_remove_level1_2leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove enough records from right leaf of a level-1 B-tree to force redistribution */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 4); u++) {
record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3729,7 +3769,7 @@ test_remove_level1_2leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3738,12 +3778,10 @@ test_remove_level1_2leaf_merge(hid_t fapl)
} /* end for */
/* Check record values in root of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 1;
record = 62; /* Left record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
PASSED();
@@ -3751,32 +3789,32 @@ test_remove_level1_2leaf_merge(hid_t fapl)
/* Attempt to remove enough records from left leaf of a level-1 B-tree to force redistribution */
TESTING("B-tree remove: merge 2 leaves to 1 in level-1 B-tree (l->r)");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Fill B-tree back up */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 4); u++) {
record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1);
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Remove records */
for(u = 0; u < ((3 * INSERT_SPLIT_ROOT_NREC) / 4) - 1; u++) {
record = u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3784,7 +3822,7 @@ test_remove_level1_2leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3793,14 +3831,17 @@ test_remove_level1_2leaf_merge(hid_t fapl)
} /* end for */
/* Check record values in root of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 1;
record = 94; /* Left record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -3811,6 +3852,8 @@ test_remove_level1_2leaf_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -3823,7 +3866,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3831,62 +3873,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_3leaf_merge(hid_t fapl)
+static unsigned
+test_remove_level1_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: merge 3 leaves to 2 in level-1 B-tree");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3894,18 +3925,22 @@ test_remove_level1_3leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove enough records from middle leaf of a level-1 B-tree to force merge */
for(u = 0; u < ((5 * INSERT_SPLIT_ROOT_NREC) / 6) - 1; u++) {
record = ((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -3913,7 +3948,7 @@ test_remove_level1_3leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -3921,14 +3956,18 @@ test_remove_level1_3leaf_merge(hid_t fapl)
TEST_ERROR
} /* end for */
+ /* Check record values in root of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 1;
record = 37; /* Only record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -3939,6 +3978,8 @@ test_remove_level1_3leaf_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -3951,7 +3992,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3959,72 +3999,57 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_promote(hid_t fapl)
+static unsigned
+test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from right leaf of level-1 B-tree");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 5 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 4); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 62; /* Left-most record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 125; /* Center-Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 188; /* Center-Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 4;
record = 220; /* Right-most record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 4)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4032,17 +4057,21 @@ test_remove_level1_promote(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove record from root node of a level-1 B-tree to force promotion from right leaf */
record = 220;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4051,30 +4080,22 @@ test_remove_level1_promote(hid_t fapl)
/* Check record values in root of B-tree */
record = 62; /* Left-most record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 125; /* Center-Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 188; /* Center-Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 4;
record = 221; /* Right-most record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 4)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4089,9 +4110,14 @@ test_remove_level1_promote(hid_t fapl)
* to promote a record from the node with more children. - QAK)
*/
TESTING("B-tree remove: promote from left leaf of level-1 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = 62;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4100,30 +4126,22 @@ test_remove_level1_promote(hid_t fapl)
/* Check record values in root of B-tree */
record = 63; /* Left-most record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 125; /* Center-Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 188; /* Center-Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 4;
record = 221; /* Right-most record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 4)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4134,9 +4152,14 @@ test_remove_level1_promote(hid_t fapl)
/* Attempt to remove record from root node of a level-1 B-tree to force promotion from middle leaf */
TESTING("B-tree remove: promote from middle leaf of level-1 B-tree");
+
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
record = 125;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4145,44 +4168,45 @@ test_remove_level1_promote(hid_t fapl)
/* Check record values in root of B-tree */
record = 63; /* Left-most record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 126; /* Center-Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
record = 188; /* Center-Right record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 4;
record = 221; /* Right-most record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 4)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 3)
TEST_ERROR
- PASSED();
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
- if (H5Fclose(file)<0) TEST_ERROR
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR
+
+ PASSED();
return 0;
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -4195,7 +4219,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4203,62 +4226,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
+static unsigned
+test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from leaf of level-1 B-tree w/2 node redistrib");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
- record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ record = 62; /* Left-most record in root node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4266,20 +4278,24 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove record from root node of a level-1 B-tree to force promotion from right leaf */
/* Remove records from right leaf until its ready to redistribute */
for(u = 0; u < 7; u++) {
record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4287,7 +4303,7 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4297,7 +4313,7 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
record = 94;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4305,27 +4321,28 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
TEST_ERROR
/* Check record values in root of B-tree */
- record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ record = 62; /* Left-most record in root node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 90; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 8)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -4336,6 +4353,8 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -4348,7 +4367,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4356,62 +4374,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
+static unsigned
+test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from leaf of level-1 B-tree w/3 node redistrib");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
- record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ record = 62; /* Left-most record in root node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4419,20 +4426,24 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove record from root node of a level-1 B-tree to force promotion from middle leaf */
/* Remove records from right leaf until its ready to redistribute */
for(u = 0; u < 7; u++) {
record = 63 + u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4440,7 +4451,7 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4450,7 +4461,7 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
record = 62;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4459,26 +4470,27 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
/* Check record values in root of B-tree */
record = 39; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 86; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 8)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -4489,6 +4501,8 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -4501,7 +4515,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4509,62 +4522,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_promote_2leaf_merge(hid_t fapl)
+static unsigned
+test_remove_level1_promote_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from leaf of level-1 B-tree w/2->1 merge");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
- record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ record = 62; /* Left-most record in root node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4572,20 +4574,24 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove record from root node of a level-1 B-tree to force promotion from right leaf */
/* Remove records from right leaf until its ready to merge */
for(u = 0; u < 14; u++) {
record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4593,7 +4599,7 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4603,7 +4609,7 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl)
record = 87;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4611,22 +4617,25 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl)
TEST_ERROR
/* Check record values in root of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 1;
record = 62; /* Middle record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 15)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -4637,6 +4646,8 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -4649,7 +4660,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4657,62 +4667,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_promote_3leaf_merge(hid_t fapl)
+static unsigned
+test_remove_level1_promote_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from leaf of level-1 B-tree w/3->2 merge");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 leaves */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
- record = 62; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 1)
+ record = 62; /* Left-most record in root node */
+ if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0)
TEST_ERROR
+ ninfo.depth = 1;
+ ninfo.nrec = 2;
record = 94; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4720,20 +4719,24 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove record from root node of a level-1 B-tree to force promotion from middle leaf */
/* Remove records from middle leaf until it's ready to merge */
for(u = 0; u < 50; u++) {
record = ((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4741,7 +4744,7 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4751,7 +4754,7 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl)
record = 25;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4759,22 +4762,25 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl)
TEST_ERROR
/* Check record values in root of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 1;
record = 37; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 51)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -4785,6 +4791,8 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -4797,7 +4805,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4805,56 +4812,48 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level1_collapse(hid_t fapl)
+static unsigned
+test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: collapse level-1 B-tree back to level-0");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-1 B-tree with 2 leaves */
for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 1;
record = 31; /* Middle record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4862,18 +4861,22 @@ test_remove_level1_collapse(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove records from B-tree to force a single leaf for the B-tree */
for(u = 0; u < 14; u++) {
record = INSERT_SPLIT_ROOT_NREC - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -4881,7 +4884,7 @@ test_remove_level1_collapse(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4890,16 +4893,14 @@ test_remove_level1_collapse(hid_t fapl)
} /* end for */
/* Check record values in root of B-tree */
+ ninfo.depth = 0;
+ ninfo.nrec = INSERT_SPLIT_ROOT_NREC - u;
record = 31; /* Middle record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 0)
- TEST_ERROR
- if(ninfo.nrec != (INSERT_SPLIT_ROOT_NREC - u))
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -4907,13 +4908,18 @@ test_remove_level1_collapse(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -4924,6 +4930,8 @@ test_remove_level1_collapse(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -4936,7 +4944,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4944,62 +4951,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_promote(hid_t fapl)
+static unsigned
+test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from right internal of level-2 B-tree");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5007,26 +5003,28 @@ test_remove_level2_promote(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in right internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 2960; /* Record in right internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to remove record from right internal node of a level-2 B-tree to force promotion */
record = 2960;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5034,16 +5032,14 @@ test_remove_level2_promote(hid_t fapl)
TEST_ERROR
/* Check information about record promoted into right internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 2961; /* Record in right internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5055,18 +5051,20 @@ test_remove_level2_promote(hid_t fapl)
/* Attempt to remove record from left internal node of a level-2 B-tree to force promotion */
TESTING("B-tree remove: promote from left internal of level-2 B-tree");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in left internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
record = 1133; /* Record in left internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 29)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
record = 1133;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5074,16 +5072,14 @@ test_remove_level2_promote(hid_t fapl)
TEST_ERROR
/* Check information about record in left internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
record = 1134; /* Record in left internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 29)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5095,18 +5091,20 @@ test_remove_level2_promote(hid_t fapl)
/* Attempt to remove record from middle internal node of a level-2 B-tree to force promotion */
TESTING("B-tree remove: promote from middle internal of level-2 B-tree");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in middle internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 2267; /* Record in middle internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
record = 2267;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5114,16 +5112,14 @@ test_remove_level2_promote(hid_t fapl)
TEST_ERROR
/* Check information about record in middle internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 2268; /* Record in middle internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5135,18 +5131,20 @@ test_remove_level2_promote(hid_t fapl)
/* Attempt to remove record from root node of a level-2 B-tree to force promotion */
TESTING("B-tree remove: promote record from root of level-2 B-tree");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in root node */
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 1889; /* Left record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
record = 1889;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5154,34 +5152,34 @@ test_remove_level2_promote(hid_t fapl)
TEST_ERROR
/* Check information about record in root node */
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 1890; /* Left record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 3)
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in root node */
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
record = 2834;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5189,22 +5187,25 @@ test_remove_level2_promote(hid_t fapl)
TEST_ERROR
/* Check information about record in root node */
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2835; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 4)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -5215,6 +5216,8 @@ test_remove_level2_promote(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -5227,7 +5230,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5235,62 +5237,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_promote_2internal_redistrib(hid_t fapl)
+static unsigned
+test_remove_level2_promote_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from right internal of level-2 B-tree w/redistrib");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5298,26 +5289,29 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
- record = 3685; /* Right-most record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(ninfo.nrec != 14)
+
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
+ record = 3685; /* Right-most record in root node */
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to remove record from right internal node of a level-2 B-tree to force promotion w/redistribution */
for(u = 0; u < 8; u++) {
record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5325,7 +5319,7 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5335,29 +5329,33 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl)
record = 3685;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
if(rrecord != 3685)
TEST_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 3681; /* Right-most record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 8)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -5368,6 +5366,8 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -5380,7 +5380,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5388,62 +5387,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_promote_3internal_redistrib(hid_t fapl)
+static unsigned
+test_remove_level2_promote_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from left internal of level-2 B-tree w/redistrib");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5451,26 +5439,29 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
- record = 62; /* Left-most record in left node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(ninfo.nrec != 29)
+
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
+ record = 62; /* Left-most record in left node */
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to remove record from left internal node of a level-2 B-tree to force promotion w/redistribution */
for(u = 0; u < 38; u++) {
record = 63 + u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5478,7 +5469,7 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5488,29 +5479,33 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl)
record = 62;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
if(rrecord != 62)
TEST_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
record = 49; /* Left-most record in left node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 29)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 38)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -5521,6 +5516,8 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -5533,7 +5530,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5541,62 +5537,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_promote_2internal_merge(hid_t fapl)
+static unsigned
+test_remove_level2_promote_2internal_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from right internal of level-2 B-tree w/merge");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5604,27 +5589,29 @@ test_remove_level2_promote_2internal_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in right internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 3685; /* Right-most record in right internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to remove record from right internal node of a level-2 B-tree to force promotion w/redistribution */
for(u = 0; u < 15; u++) {
record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5632,7 +5619,7 @@ test_remove_level2_promote_2internal_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5643,7 +5630,7 @@ test_remove_level2_promote_2internal_merge(hid_t fapl)
/* Force merge by promoting current right-most record */
record = 3678;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5651,22 +5638,25 @@ test_remove_level2_promote_2internal_merge(hid_t fapl)
TEST_ERROR
/* Check information about record in right internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 13;
record = 3653; /* Right-most record in right internal node (now) */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 13)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 15)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -5677,6 +5667,8 @@ test_remove_level2_promote_2internal_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -5689,7 +5681,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5697,62 +5688,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_promote_3internal_merge(hid_t fapl)
+static unsigned
+test_remove_level2_promote_3internal_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: promote from middle internal of level-2 B-tree w/merge");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5760,27 +5740,29 @@ test_remove_level2_promote_3internal_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Check information about record in left internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
record = 62; /* Left-most record in left internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 29)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to remove record from left internal node of a level-2 B-tree to force promotion w/redistribution */
for(u = 0; u < 112; u++) {
record = 48 + u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5788,7 +5770,7 @@ test_remove_level2_promote_3internal_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5799,7 +5781,7 @@ test_remove_level2_promote_3internal_merge(hid_t fapl)
/* Force merge of left-most internal nodes by promotion */
record = 25;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5807,22 +5789,25 @@ test_remove_level2_promote_3internal_merge(hid_t fapl)
TEST_ERROR
/* Check information about record in left internal node */
+ ninfo.depth = 1;
+ ninfo.nrec = 28;
record = 37; /* Left-most record in left internal node (now) */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 28)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 112)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -5833,6 +5818,8 @@ test_remove_level2_promote_3internal_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -5845,7 +5832,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5853,62 +5839,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_2internal_merge_left(hid_t fapl)
+static unsigned
+test_remove_level2_2internal_merge_left(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: merge 2 internal nodes to 1 in level-2 B-tree (l->r)");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5916,18 +5891,22 @@ test_remove_level2_2internal_merge_left(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove records from a level-2 B-tree to force 2 internal nodes to merge */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 21) + 15); u++) {
record = u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -5935,7 +5914,7 @@ test_remove_level2_2internal_merge_left(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -5943,14 +5922,18 @@ test_remove_level2_2internal_merge_left(hid_t fapl)
TEST_ERROR
} /* end for */
+ /* Check status of B-tree */
+ ninfo.depth = 2;
+ ninfo.nrec = 1;
record = 2834; /* Middle record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -5961,6 +5944,8 @@ test_remove_level2_2internal_merge_left(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -5973,7 +5958,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5981,62 +5965,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_2internal_merge_right(hid_t fapl)
+static unsigned
+test_remove_level2_2internal_merge_right(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: merge 2 internal nodes to 1 in level-2 B-tree (r->l)");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6044,18 +6017,22 @@ test_remove_level2_2internal_merge_right(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove records from a level-2 B-tree to force 2 internal nodes to merge */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 5) + 17); u++) {
record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6063,7 +6040,7 @@ test_remove_level2_2internal_merge_right(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6071,14 +6048,18 @@ test_remove_level2_2internal_merge_right(hid_t fapl)
TEST_ERROR
} /* end for */
+ /* Check status of B-tree */
+ ninfo.depth = 2;
+ ninfo.nrec = 1;
record = 1889; /* Middle record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -6089,6 +6070,8 @@ test_remove_level2_2internal_merge_right(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -6101,7 +6084,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -6109,62 +6091,51 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_3internal_merge(hid_t fapl)
+static unsigned
+test_remove_level2_3internal_merge(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: merge 3 internal nodes to 2 in level-2 B-tree");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6172,18 +6143,22 @@ test_remove_level2_3internal_merge(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove record from middle internal node of a level-2 B-tree to force promotion w/redistribution */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 23) + 15); u++) {
record = (INSERT_SPLIT_ROOT_NREC * 20) + u;
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6191,7 +6166,7 @@ test_remove_level2_3internal_merge(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6199,14 +6174,18 @@ test_remove_level2_3internal_merge(hid_t fapl)
TEST_ERROR
} /* end for */
+ /* Check status of B-tree */
+ ninfo.depth = 2;
+ ninfo.nrec = 1;
record = 1196; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -6217,6 +6196,8 @@ test_remove_level2_3internal_merge(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -6229,7 +6210,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -6237,63 +6217,52 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_level2_collapse_right(hid_t fapl)
+static unsigned
+test_remove_level2_collapse_right(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
hsize_t nrec; /* Number of records in B-tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
- int rec_depth; /* Depth of record in B-tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
H5B2_node_info_test_t ninfo; /* B-tree node info */
unsigned u; /* Local index variable */
- 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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
TESTING("B-tree remove: collapse level-2 B-tree back to level-1 (r->l)");
- /*
- * v2 B-tree creation
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check record values in root of B-tree */
record = 1889; /* Left record in root node */
- if((rec_depth = H5B2_get_node_depth_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record)) < 0)
- FAIL_STACK_ERROR
- if(rec_depth != 2)
+ if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0)
TEST_ERROR
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 2834; /* Right record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6301,18 +6270,22 @@ test_remove_level2_collapse_right(hid_t fapl)
TEST_ERROR
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(!H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to remove records from a level-2 B-tree to force back to level-1 */
for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 34) + 17; u++) {
record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1);
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6320,7 +6293,7 @@ test_remove_level2_collapse_right(hid_t fapl)
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6329,11 +6302,16 @@ test_remove_level2_collapse_right(hid_t fapl)
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
+ if(H5B2_stat_info(bt2, &bt2_stat) < 0)
FAIL_STACK_ERROR
if(bt2_stat.depth != 1)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -6344,6 +6322,8 @@ test_remove_level2_collapse_right(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -6351,6 +6331,78 @@ error:
/*-------------------------------------------------------------------------
+ * Function: gen_l4_btree2
+ *
+ * Purpose: Generate a level-4 v2 B-tree for testing.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, October 14, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam,
+ haddr_t *bt2_addr, const hsize_t *records)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ hsize_t record; /* Record to insert into tree */
+ unsigned u; /* Local index variable */
+ H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ STACK_ERROR
+
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, bt2_addr) < 0)
+ TEST_ERROR
+
+ /* Insert random records */
+ for(u = 0; u < INSERT_MANY; u++) {
+ record = records[u];
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
+ FAIL_STACK_ERROR
+ } /* end for */
+
+ /* Check up on B-tree */
+ if(H5B2_stat_info(bt2, &bt2_stat) < 0)
+ FAIL_STACK_ERROR
+ if(bt2_stat.depth != 4)
+ TEST_ERROR
+
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ STACK_ERROR
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* gen_l4_btree2() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_remove_lots
*
* Purpose: Basic tests for the B-tree v2 code. This test inserts many
@@ -6365,25 +6417,27 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_remove_lots(hid_t fapl)
+static unsigned
+test_remove_lots(const char *env_h5_drvr, hid_t fapl, const H5B2_create_t *cparam)
{
- hid_t file = -1;
- char filename[1024];
- H5F_t *f = NULL;
+ hid_t file = -1; /* File ID */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
int fd = -1; /* File descriptor */
h5_stat_t sb; /* Stat buffer for file */
void *file_data = NULL; /* Copy of file data */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
+ haddr_t bt2_addr; /* Address of B-tree created */
hsize_t record; /* Record to insert into tree */
hsize_t rrecord; /* Record to remove from tree */
- haddr_t bt2_addr; /* Address of B-tree created */
haddr_t root_addr; /* Address of root of B-tree created */
time_t curr_time; /* Current time, for seeding random number generator */
hsize_t *records; /* Record #'s for random insertion */
unsigned u; /* Local index variable */
unsigned rem_idx; /* Location to remove */
- H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
hsize_t nrec; /* Number of records in B-tree */
+ hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */
/* Initialize random number seed */
curr_time = HDtime(NULL);
@@ -6391,14 +6445,14 @@ test_remove_lots(hid_t fapl)
curr_time = 1163537969;
HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/*
* Test removing many records into v2 B-tree
*/
/* Allocate space for the records */
- if(NULL == (records = HDmalloc(sizeof(hsize_t) * INSERT_MANY)))
+ if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY)))
TEST_ERROR
/* Initialize record #'s */
@@ -6410,7 +6464,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
hsize_t temp_rec; /* Temporary record */
unsigned swap_idx; /* Location to swap with when shuffling */
- swap_idx = (unsigned)(HDrandom() % (INSERT_MANY - u)) + u;
+ swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u;
temp_rec = records[u];
records[u] = records[swap_idx];
records[swap_idx] = temp_rec;
@@ -6418,62 +6472,36 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
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)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
-
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
-
- /* Insert random records */
- for(u = 0; u < INSERT_MANY; u++) {
- record = records[u];
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
- FAIL_STACK_ERROR
- } /* end for */
-
- /* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
- FAIL_STACK_ERROR
- if(bt2_stat.depth != 4)
+ /* Generate the v2 B-tree to test */
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
TEST_ERROR
- /* Close file */
- if(H5Fclose(file) < 0)
- STACK_ERROR
-
+ /* Check for VFD which stores data in multiple files */
+ single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"));
+ if(single_file_vfd) {
+ /* Make a copy of the file in memory, in order to speed up deletion testing */
- /* Make a copy of the file in memory, in order to speed up deletion testing */
-
- /* Open the file just created */
- if((fd = HDopen(filename, O_RDONLY, 0)) < 0)
- TEST_ERROR
-
- /* Retrieve the file's size */
- if(HDfstat(fd, &sb) < 0)
- TEST_ERROR
-
- /* Allocate space for the file data */
- if(NULL == (file_data = HDmalloc((size_t)sb.st_size)))
- TEST_ERROR
+ /* Open the file just created */
+ if((fd = HDopen(filename, O_RDONLY, 0)) < 0)
+ TEST_ERROR
- /* Read file's data into memory */
- if(HDread(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
- TEST_ERROR
+ /* Retrieve the file's size */
+ if(HDfstat(fd, &sb) < 0)
+ TEST_ERROR
- /* Close the file */
- if(HDclose(fd) < 0)
- TEST_ERROR
- fd = -1;
+ /* Allocate space for the file data */
+ if(NULL == (file_data = HDmalloc((size_t)sb.st_size)))
+ TEST_ERROR
+ /* Read file's data into memory */
+ if(HDread(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
+ TEST_ERROR
+ /* Close the file */
+ if(HDclose(fd) < 0)
+ TEST_ERROR
+ fd = -1;
+ } /* end if */
/* Print banner for this test */
TESTING("B-tree remove: create random level 4 B-tree and delete all records in random order");
@@ -6483,7 +6511,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-shuffle record #'s */
@@ -6491,17 +6519,21 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
hsize_t temp_rec; /* Temporary record */
unsigned swap_idx; /* Location to swap with when shuffling */
- swap_idx = (unsigned)(HDrandom() % (INSERT_MANY - u)) + u;
+ swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u;
temp_rec = records[u];
records[u] = records[swap_idx];
records[swap_idx] = temp_rec;
} /* end for */
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
+ FAIL_STACK_ERROR
+
/* Remove all records */
for(u = 0; u < INSERT_MANY; u++) {
record = records[u];
rrecord = HSIZET_MAX;
- if(H5B2_remove(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, remove_cb, &rrecord) < 0)
+ if(H5B2_remove(bt2, dxpl, &record, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6509,7 +6541,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6518,13 +6550,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end for */
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -6533,21 +6570,28 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
- /* Re-write the file's data with the copy in memory */
-
- /* Open the file just created */
- if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
- TEST_ERROR
+ /* Check for VFD which stores data in multiple files */
+ if(single_file_vfd) {
+ /* Re-write the file's data with the copy in memory */
- /* Write file's data from memory */
- if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
- TEST_ERROR
+ /* Open the file just created */
+ if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
+ TEST_ERROR
- /* Close the file */
- if(HDclose(fd) < 0)
- TEST_ERROR
- fd = -1;
+ /* Write file's data from memory */
+ if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
+ TEST_ERROR
+ /* Close the file */
+ if(HDclose(fd) < 0)
+ TEST_ERROR
+ fd = -1;
+ } /* end if */
+ else {
+ /* Re-generate the v2 B-tree to test */
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
+ TEST_ERROR
+ } /* end else */
/* Print banner for this test */
@@ -6558,17 +6602,21 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
FAIL_STACK_ERROR
/* Remove all records */
for(u = 0; u < INSERT_MANY; u++) {
/* Pick a record index to remove from randomly */
- rem_idx = (unsigned)(HDrandom() % (INSERT_MANY - u));
+ rem_idx = ((unsigned)HDrandom() % (INSERT_MANY - u));
rrecord = HSIZET_MAX;
/* Remove random record */
- if(H5B2_remove_by_idx(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)rem_idx, remove_cb, &rrecord) < 0)
+ if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_INC, (hsize_t)rem_idx, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6576,7 +6624,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6585,13 +6633,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end for */
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -6600,20 +6653,28 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
- /* Re-write the file's data with the copy in memory */
+ /* Check for VFD which stores data in multiple files */
+ if(single_file_vfd) {
+ /* Re-write the file's data with the copy in memory */
- /* Open the file just created */
- if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
- TEST_ERROR
+ /* Open the file just created */
+ if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
+ TEST_ERROR
- /* Write file's data from memory */
- if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
- TEST_ERROR
+ /* Write file's data from memory */
+ if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
+ TEST_ERROR
- /* Close the file */
- if(HDclose(fd) < 0)
- TEST_ERROR
- fd = -1;
+ /* Close the file */
+ if(HDclose(fd) < 0)
+ TEST_ERROR
+ fd = -1;
+ } /* end if */
+ else {
+ /* Re-generate the v2 B-tree to test */
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
+ TEST_ERROR
+ } /* end else */
@@ -6625,14 +6686,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
FAIL_STACK_ERROR
/* Remove all records */
for(u = 0; u < INSERT_MANY; u++) {
/* Remove first record */
rrecord = HSIZET_MAX;
- if(H5B2_remove_by_idx(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_INC, (hsize_t)0, remove_cb, &rrecord) < 0)
+ if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_INC, (hsize_t)0, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6640,7 +6705,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6649,13 +6714,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end for */
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -6664,20 +6734,28 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
- /* Re-write the file's data with the copy in memory */
+ /* Check for VFD which stores data in multiple files */
+ if(single_file_vfd) {
+ /* Re-write the file's data with the copy in memory */
- /* Open the file just created */
- if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
- TEST_ERROR
+ /* Open the file just created */
+ if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
+ TEST_ERROR
- /* Write file's data from memory */
- if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
- TEST_ERROR
+ /* Write file's data from memory */
+ if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size)
+ TEST_ERROR
- /* Close the file */
- if(HDclose(fd) < 0)
- TEST_ERROR
- fd = -1;
+ /* Close the file */
+ if(HDclose(fd) < 0)
+ TEST_ERROR
+ fd = -1;
+ } /* end if */
+ else {
+ /* Re-generate the v2 B-tree to test */
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
+ TEST_ERROR
+ } /* end else */
@@ -6689,14 +6767,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f)))
FAIL_STACK_ERROR
/* Remove all records */
for(u = 0; u < INSERT_MANY; u++) {
/* Remove last record */
rrecord = HSIZET_MAX;
- if(H5B2_remove_by_idx(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5_ITER_DEC, (hsize_t)0, remove_cb, &rrecord) < 0)
+ if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_DEC, (hsize_t)0, remove_cb, &rrecord) < 0)
FAIL_STACK_ERROR
/* Make certain that the record value is correct */
@@ -6704,7 +6786,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
TEST_ERROR
/* Query the number of records in the B-tree */
- if(H5B2_get_nrec(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &nrec) < 0)
+ if(H5B2_get_nrec(bt2, &nrec) < 0)
FAIL_STACK_ERROR
/* Make certain that the # of records is correct */
@@ -6713,33 +6795,44 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end for */
/* Query the address of the root node in the B-tree */
- if(H5B2_get_root_addr_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &root_addr) < 0)
+ if(H5B2_get_root_addr_test(bt2, &root_addr) < 0)
FAIL_STACK_ERROR
/* Make certain that the address of the root node is defined */
if(H5F_addr_defined(root_addr))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
PASSED();
- HDfree(records);
- HDfree(file_data);
+ if(records)
+ HDfree(records);
+ if(file_data)
+ HDfree(file_data);
return 0;
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
if(fd > 0)
HDclose(fd);
- HDfree(records);
- HDfree(file_data);
+ if(records)
+ HDfree(records);
+ if(file_data)
+ HDfree(file_data);
return 1;
} /* test_remove_lots() */
@@ -6752,7 +6845,6 @@ error:
* code to find nearest neighbors to a given value in a B-tree.
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -6760,14 +6852,16 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_find_neighbor(hid_t fapl)
+static unsigned
+test_find_neighbor(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
hsize_t search; /* Search value */
hsize_t *records; /* Record #'s for random insertion */
unsigned u; /* Local index variable */
@@ -6775,106 +6869,96 @@ test_find_neighbor(hid_t fapl)
herr_t ret; /* Generic error return value */
/* Allocate space for the records */
- if((records = HDmalloc(sizeof(hsize_t)*FIND_NEIGHBOR))==NULL)
+ if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * FIND_NEIGHBOR)))
TEST_ERROR
/* Initialize record #'s */
for(u = 0; u < FIND_NEIGHBOR; u++)
records[u] = u * 2;
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
/*
* Test nearest neighbor for '<' cases
*/
TESTING("B-tree find: nearest neighbor less than a value");
- /* Create the file to work on */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert records */
for(u = 0; u < FIND_NEIGHBOR; u++) {
record = records[u];
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Attempt to find record B-tree less than a value */
search = 0;
H5E_BEGIN_TRY {
- ret = H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record);
+ ret = H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
search = 1;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 0)
TEST_ERROR
search = 2;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 0)
TEST_ERROR
search = 3;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 2)
TEST_ERROR
search = 4;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 2)
TEST_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 14;
record = 250; /* Record in left internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 14)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Neighbor is in internal node */
search = 251;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 250)
TEST_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 2;
+ ninfo.nrec = 1;
record = 1888; /* Record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 1)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Neighbor is in root node */
search = 1889;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 1888)
TEST_ERROR
search = (FIND_NEIGHBOR * 2) + 1;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != ((FIND_NEIGHBOR - 1) * 2))
TEST_ERROR
@@ -6886,67 +6970,75 @@ test_find_neighbor(hid_t fapl)
*/
TESTING("B-tree find: nearest neighbor greater than a value");
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
+ TEST_ERROR
+
/* Attempt to find record B-tree less than a value */
search = (FIND_NEIGHBOR * 2) + 1;
H5E_BEGIN_TRY {
- ret = H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record);
+ ret = H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
search = 0;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 2)
TEST_ERROR
search = 1;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 2)
TEST_ERROR
search = 2;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 4)
TEST_ERROR
search = 3;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 4)
TEST_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 16;
record = 2896; /* Record in right internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 16)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Neighbor is in internal node */
search = 2895;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 2896)
TEST_ERROR
/* Neighbor is in root node */
search = 1887;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != 1888)
TEST_ERROR
search = ((FIND_NEIGHBOR - 1) * 2) - 1;
- if(H5B2_neighbor(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
+ if(H5B2_neighbor(bt2, dxpl, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0)
FAIL_STACK_ERROR
if(record != ((FIND_NEIGHBOR - 1) * 2))
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
STACK_ERROR
@@ -6959,6 +7051,8 @@ test_find_neighbor(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
HDfree(records);
@@ -6973,7 +7067,6 @@ error:
* code to delete a B-tree from a file
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -6981,16 +7074,18 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_delete(hid_t fapl)
+static unsigned
+test_delete(hid_t fapl, const H5B2_create_t *cparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
+ hid_t file = -1; /* File ID */
+ char filename[1024]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t empty_size; /* Size of an empty file */
h5_stat_size_t file_size; /* Size of each file created */
- hsize_t record; /* Record to insert into tree */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
unsigned u; /* Local index variable */
@@ -7010,7 +7105,7 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get the size of an empty file */
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Create the file to work on */
@@ -7018,19 +7113,22 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
+
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
FAIL_STACK_ERROR
+ bt2 = NULL;
/*
* Delete v2 B-tree
*/
- if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, NULL, NULL) < 0)
+ if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close the file */
@@ -7038,7 +7136,7 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -7055,32 +7153,35 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert records */
for(u = 0; u < DELETE_SMALL; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
+ if(H5B2_stat_info(bt2, &bt2_stat) < 0)
FAIL_STACK_ERROR
if(bt2_stat.depth != 0)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/*
* Delete v2 B-tree
*/
- if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, NULL, NULL) < 0)
+ if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, f, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close file */
@@ -7088,7 +7189,7 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -7105,32 +7206,35 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert records */
for(u = 0; u < DELETE_MEDIUM; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
+ if(H5B2_stat_info(bt2, &bt2_stat) < 0)
FAIL_STACK_ERROR
if(bt2_stat.depth != 1)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/*
* Delete v2 B-tree
*/
- if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, NULL, NULL) < 0)
+ if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close file */
@@ -7138,7 +7242,7 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -7155,32 +7259,35 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Insert records */
for(u = 0; u < DELETE_LARGE; u++) {
record = u;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
+ if(H5B2_stat_info(bt2, &bt2_stat) < 0)
FAIL_STACK_ERROR
if(bt2_stat.depth != 2)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/*
* Delete v2 B-tree
*/
- if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, NULL, NULL) < 0)
+ if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close file */
@@ -7188,7 +7295,7 @@ test_delete(hid_t fapl)
STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -7201,6 +7308,8 @@ test_delete(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -7214,7 +7323,6 @@ error:
* code to modify an existing record in the B-tree
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -7222,14 +7330,16 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
-test_modify(hid_t fapl)
+static unsigned
+test_modify(hid_t fapl, const H5B2_create_t *cparam,
+ const bt2_test_param_t *tparam)
{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- hsize_t record; /* Record to insert into tree */
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */
+ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */
haddr_t bt2_addr; /* Address of B-tree created */
+ hsize_t record; /* Record to insert into tree */
hsize_t modify; /* Modified value */
hsize_t found; /* Found value */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
@@ -7237,36 +7347,28 @@ test_modify(hid_t fapl)
unsigned u; /* Local index variable */
herr_t ret; /* Generic error return value */
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
/*
* Test modifying records
*/
TESTING("B-tree modify: attempt to modify non-existant record");
- /* Create the file to work on */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
+ /* Create the file for the test */
+ if(create_file(&file, &f, fapl) < 0)
+ TEST_ERROR
- /*
- * Create v2 B-tree
- */
- if(H5B2_create(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, 512, 8, 100, 40, &bt2_addr/*out*/) < 0)
- FAIL_STACK_ERROR
+ /* Create the v2 B-tree & get its address */
+ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0)
+ TEST_ERROR
/* Create level-2 B-tree with 3 internal nodes */
for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) {
record = u * 5;
- if(H5B2_insert(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record) < 0)
+ if(H5B2_insert(bt2, dxpl, &record) < 0)
FAIL_STACK_ERROR
} /* end for */
/* Check up on B-tree */
- if(H5B2_stat_info(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &bt2_stat) < 0)
+ if(H5B2_stat_info(bt2, &bt2_stat) < 0)
FAIL_STACK_ERROR
if(bt2_stat.depth != 2)
TEST_ERROR
@@ -7275,7 +7377,7 @@ test_modify(hid_t fapl)
record = 3;
modify = 4;
H5E_BEGIN_TRY {
- ret = H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify);
+ ret = H5B2_modify(bt2, dxpl, &record, modify_cb, &modify);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -7285,32 +7387,34 @@ test_modify(hid_t fapl)
TESTING("B-tree modify: modify record in leaf node");
- record = 4330; /* Record in leaf node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 0)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(ninfo.nrec != 62)
+
+ /* Check status of B-tree */
+ ninfo.depth = 0;
+ ninfo.nrec = 62;
+ record = 4330; /* Record in leaf node */
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to modify a record in a leaf node */
record = 4330;
modify = 4331;
- if(H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify) < 0)
+ if(H5B2_modify(bt2, dxpl, &record, modify_cb, &modify) < 0)
FAIL_STACK_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 0;
+ ninfo.nrec = 62;
record = 4331; /* Record in leaf node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 0)
- TEST_ERROR
- if(ninfo.nrec != 62)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to find modified record */
record = 4331;
found = 4331;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, find_cb, &found) < 0)
+ if(H5B2_find(bt2, dxpl, &record, find_cb, &found) != TRUE)
FAIL_STACK_ERROR
if(found != 4331)
TEST_ERROR
@@ -7319,7 +7423,7 @@ test_modify(hid_t fapl)
record = 4330;
found = HSIZET_MAX;
H5E_BEGIN_TRY {
- ret = H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify);
+ ret = H5B2_modify(bt2, dxpl, &record, modify_cb, &modify);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -7329,32 +7433,34 @@ test_modify(hid_t fapl)
TESTING("B-tree modify: modify record in internal node");
- record = 5350; /* Record in internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(ninfo.nrec != 29)
+
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
+ record = 5350; /* Record in internal node */
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to modify a record in an internal node */
record = 5350;
modify = 5352;
- if(H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify) < 0)
+ if(H5B2_modify(bt2, dxpl, &record, modify_cb, &modify) < 0)
FAIL_STACK_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 1;
+ ninfo.nrec = 29;
record = 5352; /* Record in internal node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 1)
- TEST_ERROR
- if(ninfo.nrec != 29)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to find modified record */
record = 5352;
found = 5352;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, find_cb, &found) < 0)
+ if(H5B2_find(bt2, dxpl, &record, find_cb, &found) != TRUE)
STACK_ERROR
if(found != 5352)
TEST_ERROR
@@ -7363,7 +7469,7 @@ test_modify(hid_t fapl)
record = 5350;
found = 5350;
H5E_BEGIN_TRY {
- ret = H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify);
+ ret = H5B2_modify(bt2, dxpl, &record, modify_cb, &modify);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
@@ -7373,32 +7479,34 @@ test_modify(hid_t fapl)
TESTING("B-tree modify: modify record in root node");
- record = 9445; /* Record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
+ /* Check for closing & re-opening the B-tree */
+ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0)
TEST_ERROR
- if(ninfo.nrec != 2)
+
+ /* Check status of B-tree */
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
+ record = 9445; /* Record in root node */
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to modify a record in a root node */
record = 9445;
modify = 9448;
- if(H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify) < 0)
+ if(H5B2_modify(bt2, dxpl, &record, modify_cb, &modify) < 0)
FAIL_STACK_ERROR
+ /* Check status of B-tree */
+ ninfo.depth = 2;
+ ninfo.nrec = 2;
record = 9448; /* Record in root node */
- if(H5B2_get_node_info_test(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, &ninfo) < 0)
- FAIL_STACK_ERROR
- if(ninfo.depth != 2)
- TEST_ERROR
- if(ninfo.nrec != 2)
+ if(check_node_info(bt2, dxpl, record, &ninfo) < 0)
TEST_ERROR
/* Attempt to find modified record */
record = 9448;
found = 9448;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, find_cb, &found) < 0)
+ if(H5B2_find(bt2, dxpl, &record, find_cb, &found) != TRUE)
STACK_ERROR
if(found != 9448)
TEST_ERROR
@@ -7407,12 +7515,17 @@ test_modify(hid_t fapl)
record = 9445;
found = 9445;
H5E_BEGIN_TRY {
- ret = H5B2_modify(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &record, modify_cb, &modify);
+ ret = H5B2_modify(bt2, dxpl, &record, modify_cb, &modify);
} H5E_END_TRY;
/* Should fail */
if(ret != FAIL)
TEST_ERROR
+ /* Close the v2 B-tree */
+ if(H5B2_close(bt2, dxpl) < 0)
+ FAIL_STACK_ERROR
+ bt2 = NULL;
+
/* Close file */
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -7423,6 +7536,8 @@ test_modify(hid_t fapl)
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -7446,87 +7561,103 @@ error:
int
main(void)
{
+ H5B2_create_t cparam; /* Creation parameters for v2 B-tree */
+ bt2_test_param_t tparam; /* Test parameters for v2 B-tree */
hid_t fapl = -1; /* File access property list for data files */
unsigned nerrors = 0; /* Cumulative error count */
+ hbool_t reopen; /* Whether to reopen B-tree during tests */
int ExpressMode;
const char *envval = NULL;
-
+
envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
+ if(envval == NULL)
envval = "nomatch";
- if(HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- /* Reset library */
- h5_reset();
- fapl = h5_fileaccess();
- ExpressMode = GetTestExpress();
- if (ExpressMode > 1)
- printf("***Express test mode on. Some tests may be skipped\n");
-
- /* Test B-tree record insertion */
- /* Iteration, find & index routines tested in these routines as well */
- nerrors += test_insert_basic(fapl);
- nerrors += test_insert_split_root(fapl);
- nerrors += test_insert_level1_2leaf_redistrib(fapl);
- nerrors += test_insert_level1_side_split(fapl);
- nerrors += test_insert_level1_3leaf_redistrib(fapl);
- nerrors += test_insert_level1_middle_split(fapl);
- nerrors += test_insert_make_level2(fapl);
- nerrors += test_insert_level2_leaf_redistrib(fapl);
- nerrors += test_insert_level2_leaf_split(fapl);
- nerrors += test_insert_level2_2internal_redistrib(fapl);
- nerrors += test_insert_level2_2internal_split(fapl);
- nerrors += test_insert_level2_3internal_redistrib(fapl);
- nerrors += test_insert_level2_3internal_split(fapl);
- if (ExpressMode > 1)
- printf("***Express test mode on. test_insert_lots skipped\n");
- else
- nerrors += test_insert_lots(fapl);
-
- /* Test B-tree record removal */
- /* Querying the number of records routine also tested in these routines as well */
- nerrors += test_remove_basic(fapl);
- nerrors += test_remove_level1_noredistrib(fapl);
- nerrors += test_remove_level1_redistrib(fapl);
- nerrors += test_remove_level1_2leaf_merge(fapl);
- nerrors += test_remove_level1_3leaf_merge(fapl);
- nerrors += test_remove_level1_promote(fapl);
- nerrors += test_remove_level1_promote_2leaf_redistrib(fapl);
- nerrors += test_remove_level1_promote_3leaf_redistrib(fapl);
- nerrors += test_remove_level1_promote_2leaf_merge(fapl);
- nerrors += test_remove_level1_promote_3leaf_merge(fapl);
- nerrors += test_remove_level1_collapse(fapl);
- nerrors += test_remove_level2_promote(fapl);
- nerrors += test_remove_level2_promote_2internal_redistrib(fapl);
- nerrors += test_remove_level2_promote_3internal_redistrib(fapl);
- nerrors += test_remove_level2_promote_2internal_merge(fapl);
- nerrors += test_remove_level2_promote_3internal_merge(fapl);
- nerrors += test_remove_level2_2internal_merge_left(fapl);
- nerrors += test_remove_level2_2internal_merge_right(fapl);
- nerrors += test_remove_level2_3internal_merge(fapl);
- nerrors += test_remove_level2_collapse_right(fapl);
- if (ExpressMode > 1)
- printf("***Express test mode on. test_remove_lots skipped\n");
- else
- nerrors += test_remove_lots(fapl);
-
- /* Test more complex B-tree queries */
- nerrors += test_find_neighbor(fapl);
-
- /* Test deleting B-trees */
- nerrors += test_delete(fapl);
-
- /* Test modifying B-tree records */
- nerrors += test_modify(fapl);
-
- if(nerrors)
- goto error;
-
- puts("All v2 B-tree tests passed.");
-
- h5_cleanup(FILENAME, fapl);
- } /* end if */
- else
- puts("All v2 B-tree tests skipped - Incompatible with current Virtual File Driver");
+
+ /* Reset library */
+ h5_reset();
+ fapl = h5_fileaccess();
+ ExpressMode = GetTestExpress();
+ if(ExpressMode > 1)
+ printf("***Express test mode on. Some tests may be skipped\n");
+
+ /* Initialize v2 B-tree creation parameters */
+ init_cparam(&cparam);
+
+
+ /* Loop over re-opening B-tree during tests */
+ for(reopen = FALSE; reopen <= TRUE; reopen++) {
+ if(reopen) {
+ fprintf(stdout, "Testing with reopening B-tree:\n");
+ tparam.reopen_btree = TRUE;
+ } /* end if */
+ else {
+ fprintf(stdout, "Testing without reopening B-tree:\n");
+ tparam.reopen_btree = FALSE;
+ } /* end else */
+
+ /* Test B-tree record insertion */
+ /* Iteration, find & index routines tested in these routines as well */
+ nerrors += test_insert_basic(fapl, &cparam, &tparam);
+ nerrors += test_insert_split_root(fapl, &cparam, &tparam);
+ nerrors += test_insert_level1_2leaf_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_insert_level1_side_split(fapl, &cparam, &tparam);
+ nerrors += test_insert_level1_3leaf_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_insert_level1_middle_split(fapl, &cparam, &tparam);
+ nerrors += test_insert_make_level2(fapl, &cparam, &tparam);
+ nerrors += test_insert_level2_leaf_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_insert_level2_leaf_split(fapl, &cparam, &tparam);
+ nerrors += test_insert_level2_2internal_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_insert_level2_2internal_split(fapl, &cparam, &tparam);
+ nerrors += test_insert_level2_3internal_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_insert_level2_3internal_split(fapl, &cparam, &tparam);
+ if(ExpressMode > 1)
+ printf("***Express test mode on. test_insert_lots skipped\n");
+ else
+ nerrors += test_insert_lots(fapl, &cparam, &tparam);
+
+ /* Test B-tree record removal */
+ /* Querying the number of records routine also tested in these routines as well */
+ nerrors += test_remove_basic(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_noredistrib(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_2leaf_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_3leaf_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_promote(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_promote_2leaf_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_promote_3leaf_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_promote_2leaf_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_promote_3leaf_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level1_collapse(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_promote(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_promote_2internal_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_promote_3internal_redistrib(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_promote_2internal_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_promote_3internal_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_2internal_merge_left(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_2internal_merge_right(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_3internal_merge(fapl, &cparam, &tparam);
+ nerrors += test_remove_level2_collapse_right(fapl, &cparam, &tparam);
+ if(ExpressMode > 1)
+ printf("***Express test mode on. test_remove_lots skipped\n");
+ else
+ nerrors += test_remove_lots(envval, fapl, &cparam);
+
+ /* Test more complex B-tree queries */
+ nerrors += test_find_neighbor(fapl, &cparam, &tparam);
+
+ /* Test deleting B-trees */
+ nerrors += test_delete(fapl, &cparam);
+
+ /* Test modifying B-tree records */
+ nerrors += test_modify(fapl, &cparam, &tparam);
+ } /* end for */
+
+ if(nerrors)
+ goto error;
+
+ puts("All v2 B-tree tests passed.");
+
+ h5_cleanup(FILENAME, fapl);
return 0;
diff --git a/test/cache.c b/test/cache.c
index 6ea92ef..b9525ea 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -24,21 +24,22 @@
#include "H5ACprivate.h"
#include "cache_common.h"
+
/* private function declarations: */
-static void smoke_check_1(void);
-static void smoke_check_2(void);
-static void smoke_check_3(void);
-static void smoke_check_4(void);
-static void smoke_check_5(void);
-static void smoke_check_6(void);
-static void smoke_check_7(void);
-static void smoke_check_8(void);
-static void smoke_check_9(void);
-static void smoke_check_10(void);
-static void write_permitted_check(void);
-static void check_insert_entry(void);
-static void check_flush_cache(void);
+static unsigned smoke_check_1(void);
+static unsigned smoke_check_2(void);
+static unsigned smoke_check_3(void);
+static unsigned smoke_check_4(void);
+static unsigned smoke_check_5(void);
+static unsigned smoke_check_6(void);
+static unsigned smoke_check_7(void);
+static unsigned smoke_check_8(void);
+static unsigned smoke_check_9(void);
+static unsigned smoke_check_10(void);
+static unsigned write_permitted_check(void);
+static unsigned check_insert_entry(void);
+static unsigned check_flush_cache(void);
static void check_flush_cache__empty_cache(H5C_t * cache_ptr);
static void check_flush_cache__multi_entry(H5C_t * cache_ptr);
static void check_flush_cache__multi_entry_test(H5C_t * cache_ptr,
@@ -91,36 +92,41 @@ static void check_flush_cache__flush_op_test(H5C_t * cache_ptr,
int check_size,
struct fo_flush_entry_check check[]);
static void check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr);
-static void check_flush_protected_err(void);
-static void check_get_entry_status(void);
-static void check_expunge_entry(void);
-static void check_multiple_read_protect(void);
-static void check_rename_entry(void);
+static unsigned check_flush_protected_err(void);
+static unsigned check_get_entry_status(void);
+static unsigned check_expunge_entry(void);
+static unsigned check_multiple_read_protect(void);
+static unsigned check_rename_entry(void);
static void check_rename_entry__run_test(H5C_t * cache_ptr, int test_num,
struct rename_entry_test_spec * spec_ptr);
-static void check_pin_protected_entry(void);
-static void check_resize_entry(void);
-static void check_evictions_enabled(void);
-static void check_destroy_pinned_err(void);
-static void check_destroy_protected_err(void);
-static void check_duplicate_insert_err(void);
-static void check_rename_err(void);
-static void check_double_pin_err(void);
-static void check_double_unpin_err(void);
-static void check_pin_entry_errs(void);
-static void check_double_protect_err(void);
-static void check_double_unprotect_err(void);
-static void check_mark_entry_dirty_errs(void);
-static void check_expunge_entry_errs(void);
-static void check_resize_entry_errs(void);
-static void check_unprotect_ro_dirty_err(void);
-static void check_protect_ro_rw_err(void);
-static void check_check_evictions_enabled_err(void);
-static void check_auto_cache_resize(void);
-static void check_auto_cache_resize_disable(void);
-static void check_auto_cache_resize_epoch_markers(void);
-static void check_auto_cache_resize_input_errs(void);
-static void check_auto_cache_resize_aux_fcns(void);
+static unsigned check_pin_protected_entry(void);
+static unsigned check_resize_entry(void);
+static unsigned check_evictions_enabled(void);
+static unsigned check_destroy_pinned_err(void);
+static unsigned check_destroy_protected_err(void);
+static unsigned check_duplicate_insert_err(void);
+static unsigned check_rename_err(void);
+static unsigned check_double_pin_err(void);
+static unsigned check_double_unpin_err(void);
+static unsigned check_pin_entry_errs(void);
+static unsigned check_double_protect_err(void);
+static unsigned check_double_unprotect_err(void);
+static unsigned check_mark_entry_dirty_errs(void);
+static unsigned check_expunge_entry_errs(void);
+static unsigned check_resize_entry_errs(void);
+static unsigned check_unprotect_ro_dirty_err(void);
+static unsigned check_protect_ro_rw_err(void);
+static unsigned check_check_evictions_enabled_err(void);
+static unsigned check_auto_cache_resize(void);
+static unsigned check_auto_cache_resize_disable(void);
+static unsigned check_auto_cache_resize_epoch_markers(void);
+static unsigned check_auto_cache_resize_input_errs(void);
+static unsigned check_auto_cache_resize_aux_fcns(void);
+static unsigned check_metadata_blizzard_absence(hbool_t fill_via_insertion);
+static unsigned check_flush_deps(void);
+static unsigned check_flush_deps_err(void);
+static unsigned check_flush_deps_order(void);
+static unsigned check_notify_cb(void);
/**************************************************************************/
@@ -150,7 +156,7 @@ static void check_auto_cache_resize_aux_fcns(void);
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_1(void)
{
const char * fcn_name = "smoke_check_1";
@@ -166,12 +172,9 @@ smoke_check_1(void)
TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
pass = TRUE;
@@ -317,7 +320,7 @@ smoke_check_1(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_1() */
@@ -344,7 +347,7 @@ smoke_check_1(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_2(void)
{
const char * fcn_name = "smoke_check_2";
@@ -360,12 +363,9 @@ smoke_check_2(void)
TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
pass = TRUE;
@@ -511,7 +511,7 @@ smoke_check_2(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_2() */
@@ -537,7 +537,7 @@ smoke_check_2(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_3(void)
{
const char * fcn_name = "smoke_check_3";
@@ -553,12 +553,9 @@ smoke_check_3(void)
TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
pass = TRUE;
@@ -704,7 +701,7 @@ smoke_check_3(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_3() */
@@ -731,7 +728,7 @@ smoke_check_3(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_4(void)
{
const char * fcn_name = "smoke_check_4";
@@ -747,12 +744,9 @@ smoke_check_4(void)
TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
pass = TRUE;
@@ -898,7 +892,7 @@ smoke_check_4(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_4() */
@@ -925,7 +919,7 @@ smoke_check_4(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_5(void)
{
const char * fcn_name = "smoke_check_5";
@@ -965,7 +959,7 @@ smoke_check_5(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -994,7 +988,7 @@ smoke_check_5(void)
HDfprintf(stdout, " Long tests disabled.\n");
- return;
+ return 0; /* <========== note return */
}
if ( run_full_test ) {
@@ -1138,7 +1132,7 @@ smoke_check_5(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_5() */
@@ -1165,7 +1159,7 @@ smoke_check_5(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_6(void)
{
const char * fcn_name = "smoke_check_6";
@@ -1205,7 +1199,7 @@ smoke_check_6(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -1231,12 +1225,9 @@ smoke_check_6(void)
pass = TRUE;
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
if ( run_full_test ) {
@@ -1378,7 +1369,7 @@ smoke_check_6(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_6() */
@@ -1405,7 +1396,7 @@ smoke_check_6(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_7(void)
{
const char * fcn_name = "smoke_check_7";
@@ -1445,7 +1436,7 @@ smoke_check_7(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (8 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -1470,12 +1461,9 @@ smoke_check_7(void)
TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
if ( run_full_test ) {
@@ -1619,7 +1607,7 @@ smoke_check_7(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_7() */
@@ -1646,7 +1634,7 @@ smoke_check_7(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_8(void)
{
const char * fcn_name = "smoke_check_8";
@@ -1686,7 +1674,7 @@ smoke_check_8(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -1711,12 +1699,9 @@ smoke_check_8(void)
TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
if ( run_full_test ) {
@@ -1860,7 +1845,7 @@ smoke_check_8(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_8() */
@@ -1871,9 +1856,9 @@ smoke_check_8(void)
* Purpose: A repeat of smoke check 1, only with the cache corked
* part of the time.
*
- * Recall that smoke check 1 is a basic functional test,
- * with inserts, destroys, and renames in the mix, along
- * with repeated protects and unprotects. All entries are
+ * Recall that smoke check 1 is a basic functional test,
+ * with inserts, destroys, and renames in the mix, along
+ * with repeated protects and unprotects. All entries are
* marked as clean.
*
* Return: void
@@ -1888,7 +1873,7 @@ smoke_check_8(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_9(void)
{
const char * fcn_name = "smoke_check_9";
@@ -1906,12 +1891,9 @@ smoke_check_9(void)
TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
pass = TRUE;
@@ -2167,7 +2149,7 @@ smoke_check_9(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_9() */
@@ -2178,9 +2160,9 @@ smoke_check_9(void)
* Purpose: A repeat of smoke check 2, only with the cache corked
* part of the time.
*
- * Recall that smoke check 2 is a basic functional test,
- * with inserts, destroys, and renames in the mix, along
- * with some repeated protects and unprotects. About half
+ * Recall that smoke check 2 is a basic functional test,
+ * with inserts, destroys, and renames in the mix, along
+ * with some repeated protects and unprotects. About half
* the entries are marked as dirty.
*
* Return: void
@@ -2195,7 +2177,7 @@ smoke_check_9(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
smoke_check_10(void)
{
const char * fcn_name = "smoke_check_10";
@@ -2213,12 +2195,9 @@ smoke_check_10(void)
TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked");
if ( skip_long_tests ) {
-
SKIPPED();
-
HDfprintf(stdout, " Long tests disabled.\n");
-
- return;
+ return 0; /* <========== note return */
}
pass = TRUE;
@@ -2469,7 +2448,7 @@ smoke_check_10(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* smoke_check_10() */
@@ -2493,7 +2472,7 @@ smoke_check_10(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
write_permitted_check(void)
{
@@ -2660,7 +2639,7 @@ write_permitted_check(void)
#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */
- return;
+ return (unsigned)!pass;
} /* write_permitted_check() */
@@ -2686,7 +2665,7 @@ write_permitted_check(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_insert_entry(void)
{
const char * fcn_name = "check_insert_entry";
@@ -2708,12 +2687,12 @@ check_insert_entry(void)
pass = TRUE;
- /* Allocate a cache, and insert entries into it using all
+ /* Allocate a cache, and insert entries into it using all
* combinations of flags. Verify that the entries are inserted,
* and that the flags have the desired effects.
*
* Note that the dirty parameter in insert_entry is no longer
- * used, as we have decided that all inserted entries are
+ * used, as we have decided that all inserted entries are
* dirty by definition. (Which sounds very reasonable, but didn't
* used to be the case.)
*/
@@ -2729,10 +2708,10 @@ check_insert_entry(void)
if ( pass ) {
insert_entry(cache_ptr, entry_type, 0, TRUE, H5C__NO_FLAGS_SET);
- insert_entry(cache_ptr, entry_type, 1, TRUE,
+ insert_entry(cache_ptr, entry_type, 1, TRUE,
H5C__SET_FLUSH_MARKER_FLAG);
insert_entry(cache_ptr, entry_type, 2, TRUE, H5C__PIN_ENTRY_FLAG);
- insert_entry(cache_ptr, entry_type, 3, TRUE,
+ insert_entry(cache_ptr, entry_type, 3, TRUE,
(H5C__SET_FLUSH_MARKER_FLAG | H5C__PIN_ENTRY_FLAG));
}
@@ -2748,8 +2727,8 @@ check_insert_entry(void)
/* Start by checking everything we can via H5C_get_entry_status() */
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -2757,10 +2736,10 @@ check_insert_entry(void)
failure_mssg = "H5AC_get_entry_status() reports failure.";
}
- if ( pass ) {
+ if ( pass ) {
/* check the universals */
- if ( ( ! in_cache ) || ( ! is_dirty ) || ( is_protected ) ||
+ if ( ( ! in_cache ) || ( ! is_dirty ) || ( is_protected ) ||
( entry_size != entry_sizes[entry_type] ) ) {
pass = FALSE;
@@ -2819,7 +2798,7 @@ check_insert_entry(void)
search_ptr = cache_ptr->pel_head_ptr;
while ( ( search_ptr != NULL ) &&
- ( search_ptr !=
+ ( search_ptr !=
(struct H5C_cache_entry_t *)entry_ptr ) )
{
search_ptr = search_ptr->next;
@@ -2841,7 +2820,7 @@ check_insert_entry(void)
search_ptr = cache_ptr->LRU_head_ptr;
while ( ( search_ptr != NULL ) &&
- ( search_ptr !=
+ ( search_ptr !=
(struct H5C_cache_entry_t *)entry_ptr ) )
{
search_ptr = search_ptr->next;
@@ -2864,7 +2843,7 @@ check_insert_entry(void)
search_ptr = cache_ptr->dLRU_head_ptr;
while ( ( search_ptr != NULL ) &&
- ( search_ptr !=
+ ( search_ptr !=
(struct H5C_cache_entry_t *)entry_ptr ) )
{
search_ptr = search_ptr->aux_next;
@@ -2884,8 +2863,8 @@ check_insert_entry(void)
} /* while */
- /* So much for looking at the individual entries. Now verify
- * that the various counts and sized in the cache header are
+ /* So much for looking at the individual entries. Now verify
+ * that the various counts and sized in the cache header are
* as expected.
*/
@@ -2962,7 +2941,7 @@ check_insert_entry(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_insert_entry() */
@@ -2983,10 +2962,11 @@ check_insert_entry(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_flush_cache(void)
{
const char * fcn_name = "check_flush_cache";
+ hbool_t show_progress = FALSE;
H5C_t * cache_ptr = NULL;
TESTING("H5C_flush_cache() functionality");
@@ -3000,6 +2980,11 @@ check_flush_cache(void)
if ( pass ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s: reseting entries.\n", fcn_name);
+ }
+
reset_entries();
cache_ptr = setup_cache((size_t)(2 * 1024 * 1024),
@@ -3012,6 +2997,12 @@ check_flush_cache(void)
if ( pass ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s: calling check_flush_cache__empty_cache().\n",
+ fcn_name);
+ }
+
check_flush_cache__empty_cache(cache_ptr);
}
@@ -3021,21 +3012,45 @@ check_flush_cache(void)
if ( pass ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s: calling check_flush_cache__single_entry().\n",
+ fcn_name);
+ }
+
check_flush_cache__single_entry(cache_ptr);
}
if ( pass ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s: calling check_flush_cache__multi_entry().\n",
+ fcn_name);
+ }
+
check_flush_cache__multi_entry(cache_ptr);
}
if ( pass ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s: calling check_flush_cache__flush_ops().\n",
+ fcn_name);
+ }
+
check_flush_cache__flush_ops(cache_ptr);
}
if ( pass ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s: calling takedown_cache().\n",
+ fcn_name);
+ }
+
takedown_cache(cache_ptr, FALSE, FALSE);
}
@@ -3047,7 +3062,7 @@ check_flush_cache(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_flush_cache() */
@@ -5383,9 +5398,9 @@ check_flush_cache__pe_multi_entry_test(H5C_t * cache_ptr,
/*-------------------------------------------------------------------------
* Function: check_flush_cache__flush_ops()
*
- * Purpose: Run the flush ops cache tests.
+ * Purpose: Run the flush ops cache tests.
*
- * These are tests that test the cache's ability to handle
+ * These are tests that test the cache's ability to handle
* the case in which the flush callback dirties, resizes,
* and/or renames entries.
*
@@ -5421,7 +5436,7 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #1 */
{
/* start with a very simple test, in which there are two entries
- * resident in cache, and the second entry dirties the first in
+ * resident in cache, and the second entry dirties the first in
* the flush callback. No size changes, and no flush flags.
*/
int test_num = 1;
@@ -5431,9 +5446,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE;
int expected_index_len = 2;
size_t expected_index_size = 2 * PICO_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[2] =
+ struct fo_flush_cache_test_spec spec[2] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ 0,
/* entry_index = */ 0,
@@ -5445,23 +5460,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 1,
/* entry_type = */ 0,
/* entry_index = */ 1,
@@ -5473,17 +5488,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -5529,8 +5544,8 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
* Note that we must repeat all tests with the flush invalidate flag
* as this triggers a different set of code to execute the flush.
*
- * Create two entries resident in cache, and have the second entry
- * dirty the first in the flush callback.
+ * Create two entries resident in cache, and have the second entry
+ * dirty the first in the flush callback.
*/
int test_num = 2;
unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG;
@@ -5539,9 +5554,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE;
int expected_index_len = 0;
size_t expected_index_size = 0;
- struct fo_flush_cache_test_spec spec[2] =
+ struct fo_flush_cache_test_spec spec[2] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -5553,23 +5568,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ TRUE
},
- {
+ {
/* entry_num = */ 1,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -5581,17 +5596,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr*/
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -5644,9 +5659,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 4;
int expected_index_len = 1;
size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -5658,17 +5673,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr:*/
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -5723,9 +5738,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 4;
int expected_index_len = 0;
size_t expected_index_size = 0;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -5737,17 +5752,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -5793,8 +5808,8 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
* which the call back function renames the entry for which it has
* been called.
*
- * Run this entry twice, as the first run moves the entry to its
- * alternate address, and the second moves it back.
+ * Run this entry twice, as the first run moves the entry to its
+ * alternate address, and the second moves it back.
*/
int test_num = 5; /* and 6 */
unsigned int flush_flags = H5C__NO_FLAGS_SET;
@@ -5803,9 +5818,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = VARIABLE_ENTRY_SIZE;
int expected_index_len = 1;
size_t expected_index_size = VARIABLE_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -5817,17 +5832,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -5866,15 +5881,15 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
check_size,
checks);
- /* this change forces the rename to move the target entry back to its
+ /* this change forces the rename to move the target entry back to its
* main address. The first test moved it to its alternate address.
*
* Note that these two tests are not the same, as in the first test,
- * the renamed entry is moved forward in the slist. In the second
+ * the renamed entry is moved forward in the slist. In the second
* it is moved backwards.
*
* Since there is only one entry in the cache, this doesn't really
- * matter in this case. But we will do similar tests later with
+ * matter in this case. But we will do similar tests later with
* other entries in the cache.
*/
if ( pass ) {
@@ -5898,15 +5913,15 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #7 & #8 */
{
- /* Run tests 5 & 6 again, using the flush invalidate flag on the
+ /* Run tests 5 & 6 again, using the flush invalidate flag on the
* second test.
*
* Single entry test verifying that the cache can handle the case in
* which the call back function renames the entry for which it has
* been called.
*
- * Run this entry twice, as the first run moves the entry to its
- * alternate address, and the second moves it back.
+ * Run this entry twice, as the first run moves the entry to its
+ * alternate address, and the second moves it back.
*/
int test_num = 7; /* and 8 */
unsigned int flush_flags = H5C__NO_FLAGS_SET;
@@ -5915,9 +5930,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = VARIABLE_ENTRY_SIZE;
int expected_index_len = 1;
size_t expected_index_size = VARIABLE_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -5929,17 +5944,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -5978,15 +5993,15 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
check_size,
checks);
- /* this change forces the rename to move the target entry back to its
+ /* this change forces the rename to move the target entry back to its
* main address. The first test moved it to its alternate address.
*
* Note that these two tests are not the same, as in the first test,
- * the renamed entry is moved forward in the slist. In the second
+ * the renamed entry is moved forward in the slist. In the second
* it is moved backwards.
*
* Since there is only one entry in the cache, this doesn't really
- * matter in this case. But we will do similar tests later with
+ * matter in this case. But we will do similar tests later with
* other entries in the cache.
*/
@@ -6016,11 +6031,11 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #9 & #10 */
{
/* Single entry test verifying that the cache can handle the case in
- * which the call back function both resizes and renames the entry
+ * which the call back function both resizes and renames the entry
* for which it has been called.
*
- * Again, we run this entry twice, as the first run moves the entry to its
- * alternate address, and the second moves it back.
+ * Again, we run this entry twice, as the first run moves the entry to its
+ * alternate address, and the second moves it back.
*/
int test_num = 9; /* and 10 */
unsigned int flush_flags = H5C__NO_FLAGS_SET;
@@ -6029,9 +6044,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 2;
int expected_index_len = 1;
size_t expected_index_size = VARIABLE_ENTRY_SIZE / 4;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -6043,17 +6058,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 2,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6092,15 +6107,15 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
check_size,
checks);
- /* this change forces the rename to move the target entry back to its
+ /* this change forces the rename to move the target entry back to its
* main address. The first test moved it to its alternate address.
*
* Note that these two tests are not the same, as in the first test,
- * the renamed entry is moved forward in the slist. In the second
+ * the renamed entry is moved forward in the slist. In the second
* it is moved backwards.
*
* Since there is only one entry in the cache, this doesn't really
- * matter in this case. But we will do similar tests later with
+ * matter in this case. But we will do similar tests later with
* other entries in the cache.
*/
if ( pass ) {
@@ -6128,11 +6143,11 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
* second test.
*
* Single entry test verifying that the cache can handle the case in
- * which the call back function both resizes and renames the entry
+ * which the call back function both resizes and renames the entry
* for which it has been called.
*
- * Again, we run this entry twice, as the first run moves the entry to its
- * alternate address, and the second moves it back.
+ * Again, we run this entry twice, as the first run moves the entry to its
+ * alternate address, and the second moves it back.
*/
int test_num = 11; /* and 12 */
unsigned int flush_flags = H5C__NO_FLAGS_SET;
@@ -6141,9 +6156,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 2;
int expected_index_len = 1;
size_t expected_index_size = VARIABLE_ENTRY_SIZE / 4;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -6155,17 +6170,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 2,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6204,15 +6219,15 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
check_size,
checks);
- /* this change forces the rename to move the target entry back to its
+ /* this change forces the rename to move the target entry back to its
* main address. The first test moved it to its alternate address.
*
* Note that these two tests are not the same, as in the first test,
- * the renamed entry is moved forward in the slist. In the second
+ * the renamed entry is moved forward in the slist. In the second
* it is moved backwards.
*
* Since there is only one entry in the cache, this doesn't really
- * matter in this case. But we will do similar tests later with
+ * matter in this case. But we will do similar tests later with
* other entries in the cache.
*/
if ( pass ) {
@@ -6241,9 +6256,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #13 */
{
- /* Test the ability of the cache to handle the case in which
- * the flush function of an entry that is resident in cache
- * dirties two entries that are not in cache. No size
+ /* Test the ability of the cache to handle the case in which
+ * the flush function of an entry that is resident in cache
+ * dirties two entries that are not in cache. No size
* changes.
*
* At present, I am assured that this case will never occur, but
@@ -6256,9 +6271,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 1 * PICO_ENTRY_SIZE;
int expected_index_len = 3;
size_t expected_index_size = 3 * PICO_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ 0,
/* entry_index = */ 1,
@@ -6270,17 +6285,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 2,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, 0, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, 0, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6339,9 +6354,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
{
/* Repeat previous test with the flush invalidate flag.
*
- * Test the ability of the cache to handle the case in which
- * the flush function of an entry that is resident in cache
- * dirties two entries that are not in cache. No size
+ * Test the ability of the cache to handle the case in which
+ * the flush function of an entry that is resident in cache
+ * dirties two entries that are not in cache. No size
* changes.
*
* At present, I am assured that this case will never occur, but
@@ -6354,9 +6369,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 1 * PICO_ENTRY_SIZE;
int expected_index_len = 0;
size_t expected_index_size = (size_t)0;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ 0,
/* entry_index = */ 1,
@@ -6368,17 +6383,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 2,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, 0, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, 0, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6435,8 +6450,8 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #15 */
{
- /* Test the ability of the cache to handle the case in which
- * the flush function of an entry that is resident in cache
+ /* Test the ability of the cache to handle the case in which
+ * the flush function of an entry that is resident in cache
* resizes and dirties two entries that are not in cache.
*
* At present, I am assured that this case will never occur, but
@@ -6451,9 +6466,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t expected_index_size = VARIABLE_ENTRY_SIZE +
(VARIABLE_ENTRY_SIZE / 4) +
(VARIABLE_ENTRY_SIZE / 2);
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -6465,17 +6480,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 4,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6534,8 +6549,8 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
{
/* Repeat previous test with the flush invalidate flag.
*
- * Test the ability of the cache to handle the case in which
- * the flush function of an entry that is resident in cache
+ * Test the ability of the cache to handle the case in which
+ * the flush function of an entry that is resident in cache
* resizes and dirties two entries that are not in cache.
*
* At present, I am assured that this case will never occur, but
@@ -6548,9 +6563,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE;
int expected_index_len = 0;
size_t expected_index_size = (size_t)0;
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -6562,17 +6577,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 4,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6629,8 +6644,8 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #17 & #18 */
{
- /* Test the ability of the cache to handle the case in which
- * the flush function of an entry that is resident in cache
+ /* Test the ability of the cache to handle the case in which
+ * the flush function of an entry that is resident in cache
* resizes, dirties, and renames two entries that are not in cache.
*
* At present, I am assured that this case will never occur, but
@@ -6645,9 +6660,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t expected_index_size = VARIABLE_ENTRY_SIZE +
(VARIABLE_ENTRY_SIZE / 4) +
(VARIABLE_ENTRY_SIZE / 2);
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -6659,17 +6674,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6710,7 +6725,7 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* expected_destroyed = */ FALSE
}
};
-
+
check_flush_cache__flush_op_test(cache_ptr,
test_num,
flush_flags,
@@ -6723,12 +6738,12 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
check_size,
checks);
- /* this change forces the renames to move the target entries back to
- * their main address. The first test moved them to their alternate
+ /* this change forces the renames to move the target entries back to
+ * their main address. The first test moved them to their alternate
* address.
*
* Note that these two tests are not the same, as in the first test,
- * the renamed entries are moved forward in the slist. In the second
+ * the renamed entries are moved forward in the slist. In the second
* they are moved backwards.
*/
if ( pass ) {
@@ -6758,8 +6773,8 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* Repeat the above test with the flush invalidate flag on the
* second test.
*
- * Test the ability of the cache to handle the case in which
- * the flush function of an entry that is resident in cache
+ * Test the ability of the cache to handle the case in which
+ * the flush function of an entry that is resident in cache
* resizes, dirties, and renames two entries that are not in cache.
*
* At present, I am assured that this case will never occur, but
@@ -6774,9 +6789,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t expected_index_size = VARIABLE_ENTRY_SIZE +
(VARIABLE_ENTRY_SIZE / 4) +
(VARIABLE_ENTRY_SIZE / 2);
- struct fo_flush_cache_test_spec spec[1] =
+ struct fo_flush_cache_test_spec spec[1] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -6788,17 +6803,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -6852,12 +6867,12 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
check_size,
checks);
- /* this change forces the renames to move the target entries back to
- * their main address. The first test moved them to their alternate
+ /* this change forces the renames to move the target entries back to
+ * their main address. The first test moved them to their alternate
* address.
*
* Note that these two tests are not the same, as in the first test,
- * the renamed entries are moved forward in the slist. In the second
+ * the renamed entries are moved forward in the slist. In the second
* they are moved backwards.
*/
if ( pass ) {
@@ -6894,14 +6909,14 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
{
/* Now mix things up a bit.
*
- * Load several entries, two of which have flush functions that
- * resize, dirty, and rename two entries that are not in the
- * cache. Mark only one of these entries, and then flush the
+ * Load several entries, two of which have flush functions that
+ * resize, dirty, and rename two entries that are not in the
+ * cache. Mark only one of these entries, and then flush the
* cache with the flush marked entries flag.
*
- * This is the only test in which we test the
+ * This is the only test in which we test the
* H5C__FLUSH_MARKED_ENTRIES_FLAG. The hope is that since
- * we test the two features extensively by themselves, so
+ * we test the two features extensively by themselves, so
* it should be sufficient to verify that they play together
* as expected.
*/
@@ -6915,9 +6930,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
(VARIABLE_ENTRY_SIZE / 4) +
(VARIABLE_ENTRY_SIZE / 2) +
(2 * PICO_ENTRY_SIZE);
- struct fo_flush_cache_test_spec spec[4] =
+ struct fo_flush_cache_test_spec spec[4] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -6929,23 +6944,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 1,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 11,
@@ -6957,23 +6972,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 10, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 12, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ FALSE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 2,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -6985,23 +7000,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 3,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -7013,17 +7028,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ FALSE,
@@ -7113,9 +7128,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
{
/* Mix things up some more.
*
- * Load lots of entries, some of which have flush functions that
- * resize, dirty, and rename two entries that are not in the
- * cache.
+ * Load lots of entries, some of which have flush functions that
+ * resize, dirty, and rename two entries that are not in the
+ * cache.
*
* Also load entries that have flush ops on entries that are in
* cache.
@@ -7130,9 +7145,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
(2 * (VARIABLE_ENTRY_SIZE / 4)) +
(2 * (VARIABLE_ENTRY_SIZE / 2)) +
(4 * PICO_ENTRY_SIZE);
- struct fo_flush_cache_test_spec spec[6] =
+ struct fo_flush_cache_test_spec spec[6] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -7144,23 +7159,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 1,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 11,
@@ -7172,23 +7187,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 10, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 12, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 2,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -7200,23 +7215,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 3,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -7228,23 +7243,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ FALSE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 4,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 10,
@@ -7256,23 +7271,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ FALSE
},
- {
+ {
/* entry_num = */ 5,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 20,
@@ -7284,17 +7299,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7386,9 +7401,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
*
* Mix things up some more.
*
- * Load lots of entries, some of which have flush functions that
- * resize, dirty, and rename two entries that are not in the
- * cache.
+ * Load lots of entries, some of which have flush functions that
+ * resize, dirty, and rename two entries that are not in the
+ * cache.
*
* Also load entries that have flush ops on entries that are in
* cache.
@@ -7400,9 +7415,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE);
int expected_index_len = 0;
size_t expected_index_size = 0;
- struct fo_flush_cache_test_spec spec[6] =
+ struct fo_flush_cache_test_spec spec[6] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -7414,23 +7429,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ TRUE
},
- {
+ {
/* entry_num = */ 1,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 11,
@@ -7442,23 +7457,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 6,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 10, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 12, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ TRUE
},
- {
+ {
/* entry_num = */ 2,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 0,
@@ -7470,23 +7485,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ TRUE
},
- {
+ {
/* entry_num = */ 3,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 1,
@@ -7498,23 +7513,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ TRUE
},
- {
+ {
/* entry_num = */ 4,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 10,
@@ -7526,23 +7541,23 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
/* expected_destroyed = */ TRUE
},
- {
+ {
/* entry_num = */ 5,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 20,
@@ -7554,17 +7569,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7666,9 +7681,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 3 * PICO_ENTRY_SIZE;
int expected_index_len = 3;
size_t expected_index_size = 3 * PICO_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[3] =
+ struct fo_flush_cache_test_spec spec[3] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 100,
@@ -7680,17 +7695,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7708,17 +7723,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7736,17 +7751,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__DIRTY, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7800,9 +7815,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 3 * PICO_ENTRY_SIZE;
int expected_index_len = 0;
size_t expected_index_size = (size_t)0;
- struct fo_flush_cache_test_spec spec[3] =
+ struct fo_flush_cache_test_spec spec[3] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ PICO_ENTRY_TYPE,
/* entry_index = */ 100,
@@ -7814,17 +7829,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7842,17 +7857,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7870,17 +7885,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 1,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__DIRTY, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -7922,22 +7937,22 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #26 */
{
- /* This one is complex.
+ /* This one is complex.
*
- * In the following overvies table, VET stands for
+ * In the following overvies table, VET stands for
* VARIABLE_ENTRY_TYPE.
*
* In trying to follow what happens when we flush the
* set of entries constructed below, recall that each
- * flush operation is executed the first time the
+ * flush operation is executed the first time the
* entry is flushed, and then not executed again.
- * This may be a weakness in the tests, but that
+ * This may be a weakness in the tests, but that
* is the way it is for now.
*
- * After thinking about it for a while, I'm not sure that
- * the interaction between pins and flush operations needs
- * all that much testing, as the two are essentially
- * orthoginal. Thus this is a bit of a smoke check to
+ * After thinking about it for a while, I'm not sure that
+ * the interaction between pins and flush operations needs
+ * all that much testing, as the two are essentially
+ * orthoginal. Thus this is a bit of a smoke check to
* verify that we get the expected results.
*
* (VET, 100) initially not resident in cache
@@ -8004,9 +8019,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 10 * VARIABLE_ENTRY_SIZE;
int expected_index_len = 13;
size_t expected_index_size = 9 * VARIABLE_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[10] =
+ struct fo_flush_cache_test_spec spec[10] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 200,
@@ -8018,17 +8033,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8046,17 +8061,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8074,17 +8089,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8102,17 +8117,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 4,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8130,17 +8145,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8158,17 +8173,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8186,17 +8201,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8214,17 +8229,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8242,17 +8257,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8270,17 +8285,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 4,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8357,24 +8372,24 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
{
/* Repeat test #26 with the flush invalidate flag.
*
- * In the following overview table, VET stands for
+ * In the following overview table, VET stands for
* VARIABLE_ENTRY_TYPE.
*
* In trying to follow what happens when we flush the
* set of entries constructed below, recall that each
- * flush operation is executed the first time the
+ * flush operation is executed the first time the
* entry is flushed, and then not executed again.
- * This may be a weakness in the tests, but that
+ * This may be a weakness in the tests, but that
* is the way it is for now.
*
- * After thinking about it for a while, I'm not sure that
- * the interaction between pins and flush operations needs
- * all that much testing, as the two are essentially
+ * After thinking about it for a while, I'm not sure that
+ * the interaction between pins and flush operations needs
+ * all that much testing, as the two are essentially
* orthoginal. The big thing is to verify that flushes of
- * pinned entries with flush ops result in the expected
+ * pinned entries with flush ops result in the expected
* updates of the cache.
*
- * Thus this is a bit of a smoke check to * verify that we
+ * Thus this is a bit of a smoke check to * verify that we
* get the expected results.
*
* (VET, 100) initially not resident in cache
@@ -8441,9 +8456,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 10 * VARIABLE_ENTRY_SIZE;
int expected_index_len = 0;
size_t expected_index_size = (size_t)0;
- struct fo_flush_cache_test_spec spec[10] =
+ struct fo_flush_cache_test_spec spec[10] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 200,
@@ -8455,17 +8470,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8483,17 +8498,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8511,17 +8526,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8539,17 +8554,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 4,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8567,17 +8582,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8595,17 +8610,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8623,17 +8638,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8651,17 +8666,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ FALSE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8679,17 +8694,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8707,17 +8722,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 4,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0 },
- { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0, NULL },
+ { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8793,7 +8808,7 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
if ( pass ) /* test #28 */
{
/* Test the expected fheap case, in which an entry dirties
- * and resizes itself, and dirties an entry which it has
+ * and resizes itself, and dirties an entry which it has
* pinned.
*/
int test_num = 28;
@@ -8803,9 +8818,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE;
int expected_index_len = 5;
size_t expected_index_size = 4 * VARIABLE_ENTRY_SIZE;
- struct fo_flush_cache_test_spec spec[5] =
+ struct fo_flush_cache_test_spec spec[5] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 100,
@@ -8817,17 +8832,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8845,17 +8860,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 200, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 200, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8873,17 +8888,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8901,17 +8916,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8929,17 +8944,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 500, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 500, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -8986,7 +9001,7 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* Repeat test #28 with the flush invalidate flag.
*
* Test the expected fheap case, in which an entry dirties
- * and resizes itself, and dirties an entry which it has
+ * and resizes itself, and dirties an entry which it has
* pinned.
*/
int test_num = 29;
@@ -8996,9 +9011,9 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE;
int expected_index_len = 0;
size_t expected_index_size = 0;
- struct fo_flush_cache_test_spec spec[5] =
+ struct fo_flush_cache_test_spec spec[5] =
{
- {
+ {
/* entry_num = */ 0,
/* entry_type = */ VARIABLE_ENTRY_TYPE,
/* entry_index = */ 100,
@@ -9010,17 +9025,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -9038,17 +9053,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 200, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 200, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -9066,17 +9081,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -9094,17 +9109,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 0,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -9122,17 +9137,17 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0},
/* num_flush_ops = */ 3,
/* flush_ops = */
- /* op_code: type: idx: flag: size: */
- { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0 },
- { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2 },
- { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 500, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 },
- { FLUSH_OP__NO_OP, 0, 0, FALSE, 0 } },
+ /* op_code: type: idx: flag: size: order_ptr: */
+ { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL },
+ { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL },
+ { FLUSH_OP__RENAME, VARIABLE_ENTRY_TYPE, 500, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL },
+ { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } },
/* expected_loaded = */ TRUE,
/* expected_cleared = */ FALSE,
/* expected_flushed = */ TRUE,
@@ -9185,7 +9200,7 @@ check_flush_cache__flush_ops(H5C_t * cache_ptr)
/*-------------------------------------------------------------------------
* Function: check_flush_cache__flush_op_test()
*
- * Purpose: Run a flush op flush cache test. Of the nature of
+ * Purpose: Run a flush op flush cache test. Of the nature of
* flush operations, this is a multi-entry test.
*
* Return: void
@@ -9211,9 +9226,12 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
int check_size,
struct fo_flush_entry_check check[])
{
- /* const char * fcn_name = "check_flush_cache__flush_op_test"; */
+ const char * fcn_name = "check_flush_cache__flush_op_test";
static char msg[128];
+ hbool_t show_progress = FALSE;
+ hbool_t verbose = FALSE;
herr_t result;
+ int target_test = -1;
int i;
int j;
test_entry_t * base_addr;
@@ -9222,7 +9240,18 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
#if 0 /* This is useful debugging code -- lets keep it around. */
HDfprintf(stdout, "check_flush_cache__flush_op_test: test %d\n",
test_num);
-#endif
+#endif
+
+ if ( ( target_test > 0 ) && ( test_num != target_test ) ) {
+
+ show_progress = FALSE;
+ }
+
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: running sanity checks on entry(1).\n",
+ fcn_name, test_num, (int)pass);
+ }
if ( cache_ptr == NULL ) {
@@ -9251,6 +9280,12 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
failure_mssg = msg;
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: running sanity checks on entry(2).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
i = 0;
while ( ( pass ) && ( i < spec_size ) )
{
@@ -9273,6 +9308,12 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
i++;
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: running sanity checks on entry(3).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
i = 0;
while ( ( pass ) && ( i < check_size ) )
{
@@ -9282,23 +9323,23 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
( check[i].entry_index < 0 ) ||
( check[i].entry_index > max_indices[check[i].entry_type] ) ||
( check[i].expected_size <= (size_t)0 ) ||
- ( ( check[i].in_cache != TRUE ) &&
+ ( ( check[i].in_cache != TRUE ) &&
( check[i].in_cache != FALSE ) ) ||
- ( ( check[i].at_main_addr != TRUE ) &&
+ ( ( check[i].at_main_addr != TRUE ) &&
( check[i].at_main_addr != FALSE ) ) ||
- ( ( check[i].is_dirty != TRUE ) &&
+ ( ( check[i].is_dirty != TRUE ) &&
( check[i].is_dirty != FALSE ) ) ||
- ( ( check[i].is_protected != TRUE ) &&
+ ( ( check[i].is_protected != TRUE ) &&
( check[i].is_protected != FALSE ) ) ||
- ( ( check[i].is_pinned != TRUE ) &&
+ ( ( check[i].is_pinned != TRUE ) &&
( check[i].is_pinned != FALSE ) ) ||
- ( ( check[i].expected_loaded != TRUE ) &&
+ ( ( check[i].expected_loaded != TRUE ) &&
( check[i].expected_loaded != FALSE ) ) ||
- ( ( check[i].expected_cleared != TRUE ) &&
+ ( ( check[i].expected_cleared != TRUE ) &&
( check[i].expected_cleared != FALSE ) ) ||
- ( ( check[i].expected_flushed != TRUE ) &&
+ ( ( check[i].expected_flushed != TRUE ) &&
( check[i].expected_flushed != FALSE ) ) ||
- ( ( check[i].expected_destroyed != TRUE ) &&
+ ( ( check[i].expected_destroyed != TRUE ) &&
( check[i].expected_destroyed != FALSE ) ) ) {
pass = FALSE;
@@ -9310,18 +9351,54 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
i++;
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Setting up the test.\n",
+ fcn_name, test_num, (int)pass);
+ }
+
i = 0;
while ( ( pass ) && ( i < spec_size ) )
{
if ( spec[i].insert_flag ) {
+ if ( show_progress ) {
+
+ HDfprintf(stdout,
+ "%s:%d: Inserting entry(%d,%d) with flags 0x%x.\n",
+ fcn_name, test_num,
+ (int)(spec[i].entry_type),
+ (int)(spec[i].entry_index),
+ (unsigned)spec[i].flags);
+ }
+
insert_entry(cache_ptr, spec[i].entry_type, spec[i].entry_index,
TRUE, spec[i].flags);
} else {
+ if ( show_progress ) {
+
+ HDfprintf(stdout,
+ "%s:%d: Protecting entry(%d,%d).\n",
+ fcn_name, test_num,
+ (int)(spec[i].entry_type),
+ (int)(spec[i].entry_index));
+ }
+
protect_entry(cache_ptr, spec[i].entry_type, spec[i].entry_index);
+ if ( show_progress ) {
+
+ HDfprintf(stdout,
+ "%s:%d: Unprotecting entry(%d,%d) with flags 0x%x ns = %d.\n",
+ fcn_name, test_num,
+ (int)(spec[i].entry_type),
+ (int)(spec[i].entry_index),
+ (unsigned)spec[i].flags,
+ (int)(spec[i].new_size));
+ }
+
unprotect_entry_with_size_change(cache_ptr, spec[i].entry_type,
spec[i].entry_index,
spec[i].flags, spec[i].new_size);
@@ -9338,13 +9415,14 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
for ( j = 0; j < spec[i].num_flush_ops; j++ )
{
- add_flush_op(spec[i].entry_type,
+ add_flush_op(spec[i].entry_type,
spec[i].entry_index,
spec[i].flush_ops[j].op_code,
spec[i].flush_ops[j].type,
spec[i].flush_ops[j].idx,
spec[i].flush_ops[j].flag,
- spec[i].flush_ops[j].size);
+ spec[i].flush_ops[j].size,
+ spec[i].flush_ops[j].order_ptr);
}
i++;
@@ -9363,6 +9441,12 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
}
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Running the test.\n",
+ fcn_name, test_num, (int)pass);
+ }
+
if ( pass ) {
result = H5C_flush_cache(NULL, -1, -1, cache_ptr, flush_flags);
@@ -9377,6 +9461,11 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
}
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Checking test results(1).\n",
+ fcn_name, test_num, (int)pass);
+ }
i = 0;
while ( ( pass ) && ( i < spec_size ) )
@@ -9415,12 +9504,18 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
i++;
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Checking test results(2).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
if ( pass ) {
i = 0;
while ( ( pass ) && ( i < check_size ) )
{
- if ( check[i].in_cache != entry_in_cache(cache_ptr,
+ if ( check[i].in_cache != entry_in_cache(cache_ptr,
check[i].entry_type,
check[i].entry_index) ) {
@@ -9460,7 +9555,7 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
if ( ( ! entry_ptr->header.destroy_in_progress ) &&
( check[i].in_cache ) &&
( entry_ptr->header.size != check[i].expected_size ) ) {
- HDfprintf(stdout,
+ HDfprintf(stdout,
"(!destroy in progress and in cache and size (expected) = %d (%d).\n",
(int)(entry_ptr->header.size),
(int)(check[i].expected_size));
@@ -9533,6 +9628,12 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
}
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Checking test results(3).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
if ( pass ) {
if ( ( ( (flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0 )
@@ -9561,6 +9662,13 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
}
/* clean up the cache to prep for the next test */
+
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Cleaning up after test(1).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
if ( pass ) {
result = H5C_flush_cache(NULL, -1, -1, cache_ptr,
@@ -9575,17 +9683,35 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
failure_mssg = msg;
}
else if ( ( cache_ptr->index_len != 0 ) ||
- ( cache_ptr->index_size != 0 ) ) {
+ ( cache_ptr->index_size != 0 ) ||
+ ( cache_ptr->clean_index_size != 0 ) ||
+ ( cache_ptr->dirty_index_size != 0 ) ) {
pass = FALSE;
+
+ if ( verbose ) {
+
+ HDfprintf(stdout, "%s:%d: il/is/cis/dis = %lld/%lld/%lld/%lld.\n",
+ fcn_name, test_num,
+ (long long)(cache_ptr->index_len),
+ (long long)(cache_ptr->index_size),
+ (long long)(cache_ptr->clean_index_size),
+ (long long)(cache_ptr->dirty_index_size));
+ }
HDsnprintf(msg, (size_t)128,
- "Unexpected cache len/size after cleanup in flush op test #%d.",
+ "Unexpected cache len/size/cs/ds after cleanup in flush op test #%d.",
test_num);
failure_mssg = msg;
}
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Cleaning up after test(2).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
i = 0;
while ( ( pass ) && ( i < spec_size ) )
{
@@ -9602,6 +9728,12 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
i++;
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Cleaning up after test(3).\n",
+ fcn_name, test_num, (int)pass);
+ }
+
i = 0;
while ( ( pass ) && ( i < check_size ) )
{
@@ -9618,6 +9750,11 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr,
i++;
}
+ if ( show_progress ) {
+
+ HDfprintf(stdout, "%s:%d:%d: Done.\n", fcn_name, test_num, (int)pass);
+ }
+
return;
} /* check_flush_cache__flush_op_test() */
@@ -9654,100 +9791,104 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
test_entry_t * base_addr;
struct expected_entry_status expected[8 + 31 + 14] =
{
- /* the expected array is used to maintain a table of the expected status of every
+ /* the expected array is used to maintain a table of the expected status of every
* entry used in this test. Note that since the function that processes this
- * array only processes as much of it as it is told to, we don't have to
+ * array only processes as much of it as it is told to, we don't have to
* worry about maintaining the status of entries that we haven't used yet.
*/
- /* entry entry in at main */
- /* type: index: size: cache: addr: dirty: prot: pinned: loaded: clrd: flshd: dest: */
- { VARIABLE_ENTRY_TYPE, 0, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 1, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 2, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 3, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 4, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 6, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { VARIABLE_ENTRY_TYPE, 7, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 1, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 2, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 3, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 4, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 5, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 6, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 7, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 8, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 9, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 10, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 11, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 12, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 13, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 14, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 15, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 16, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 17, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 18, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 19, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 20, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 21, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 22, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 23, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 24, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 25, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 26, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 27, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 28, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 29, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { MONSTER_ENTRY_TYPE, 30, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 0, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 1, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 2, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 3, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 4, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 5, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 6, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 7, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 8, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 9, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 10, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 11, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 12, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE },
- { LARGE_ENTRY_TYPE, 13, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE }
+ /* entry entry in at main flush dep flush dep child flush flush flush */
+ /* type: index: size: cache: addr: dirty: prot: pinned: loaded: clrd: flshd: dest: par type: par idx: dep ref.count: dep height: order: */
+ { VARIABLE_ENTRY_TYPE, 0, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 1, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 2, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 3, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 4, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 6, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { VARIABLE_ENTRY_TYPE, 7, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 1, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 2, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 3, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 4, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 5, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 6, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 7, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 8, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 9, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 10, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 11, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 12, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 13, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 14, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 15, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 16, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 17, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 18, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 19, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 20, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 21, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 22, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 23, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 24, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 25, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 26, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 27, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 28, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 29, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { MONSTER_ENTRY_TYPE, 30, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 0, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 1, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 2, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 3, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 4, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 5, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 6, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 7, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 8, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 9, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 10, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 11, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 12, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { LARGE_ENTRY_TYPE, 13, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 }
};
- if ( cache_ptr == NULL ) {
+ if ( pass ) {
- pass = FALSE;
- failure_mssg = "cache_ptr NULL on entry to flush ops test.";
- }
- else if ( ( cache_ptr->index_len != 0 ) ||
- ( cache_ptr->index_size != 0 ) ) {
+ if ( cache_ptr == NULL ) {
- pass = FALSE;
- failure_mssg = "cache not empty at start of flush ops eviction test.";
- }
- else if ( ( cache_ptr->max_cache_size != (2 * 1024 * 1024 ) ) ||
- ( cache_ptr->min_clean_size != (1 * 1024 * 1024 ) ) ) {
+ pass = FALSE;
+ failure_mssg = "cache_ptr NULL on entry to flush ops test.";
+ }
+ else if ( ( cache_ptr->index_len != 0 ) ||
+ ( cache_ptr->index_size != 0 ) ) {
- pass = FALSE;
- failure_mssg = "unexpected cache config at start of flush op eviction test.";
+ pass = FALSE;
+ failure_mssg = "cache not empty at start of flush ops eviction test.";
+ }
+ else if ( ( cache_ptr->max_cache_size != (2 * 1024 * 1024 ) ) ||
+ ( cache_ptr->min_clean_size != (1 * 1024 * 1024 ) ) ) {
- } else {
+ pass = FALSE;
+ failure_mssg =
+ "unexpected cache config at start of flush op eviction test.";
- /* set min clean size to zero for this test as it simplifies
- * computing the expected cache size after each operation.
- */
+ } else {
- cache_ptr->min_clean_size = 0;
+ /* set min clean size to zero for this test as it simplifies
+ * computing the expected cache size after each operation.
+ */
+
+ cache_ptr->min_clean_size = 0;
+ }
}
if ( pass ) {
/* the basic idea in this test is to insert a bunch of entries
- * with flush operations associated with them, and then load
- * other entries into the cache until the cache is full. At
- * that point, load yet more entries into the cache, and see
+ * with flush operations associated with them, and then load
+ * other entries into the cache until the cache is full. At
+ * that point, load yet more entries into the cache, and see
* if the flush operations are performed as expected.
*
* To make things a bit more interesting, we also include a
@@ -9765,43 +9906,43 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
*/
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 0);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 0,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 0,
H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG,
(VARIABLE_ENTRY_SIZE / 2));
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 1);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 1,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 1,
H5C__NO_FLAGS_SET, (size_t)0);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 2);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 2,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 2,
H5C__NO_FLAGS_SET, (size_t)0);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 3);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 3,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 3,
H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG,
(VARIABLE_ENTRY_SIZE / 2));
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 4);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 4,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 4,
H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG,
(VARIABLE_ENTRY_SIZE / 2));
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 5);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 5,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 5,
H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG,
(VARIABLE_ENTRY_SIZE / 2));
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 6);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 6,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 6,
H5C__NO_FLAGS_SET, (size_t)0);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 7);
- unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 7,
+ unprotect_entry_with_size_change(cache_ptr, VARIABLE_ENTRY_TYPE, 7,
H5C__NO_FLAGS_SET, (size_t)0);
if ( ( cache_ptr->index_len != 8 ) ||
- ( cache_ptr->index_size != (4 * (VARIABLE_ENTRY_SIZE / 2)) +
+ ( cache_ptr->index_size != (4 * (VARIABLE_ENTRY_SIZE / 2)) +
(4 * VARIABLE_ENTRY_SIZE) ) ) {
pass = FALSE;
@@ -9811,7 +9952,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
if ( pass ) {
- /* Now set up the pinning relationships:
+ /* Now set up the pinning relationships:
*
* Briefly, (VET, 0) is pinned by (VET, 1), (VET, 2), and (VET, 3)
* (VET, 7) is pinned by (VET, 3), and (VET, 5)
@@ -9841,39 +9982,39 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
*
* (VET, 7) dirties (VET, 6)
*/
- add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__DIRTY,
- VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0);
- add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__RESIZE,
- VARIABLE_ENTRY_TYPE, 0, FALSE,
- 3 * VARIABLE_ENTRY_SIZE / 4);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__DIRTY,
+ VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__RESIZE,
+ VARIABLE_ENTRY_TYPE, 0, FALSE,
+ 3 * VARIABLE_ENTRY_SIZE / 4, NULL);
- add_flush_op(VARIABLE_ENTRY_TYPE, 2, FLUSH_OP__DIRTY,
- VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0);
- add_flush_op(VARIABLE_ENTRY_TYPE, 2, FLUSH_OP__RESIZE,
- VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE);
- add_flush_op(VARIABLE_ENTRY_TYPE, 2, FLUSH_OP__RENAME,
- VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 2, FLUSH_OP__DIRTY,
+ VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 2, FLUSH_OP__RESIZE,
+ VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE, NULL);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 2, FLUSH_OP__RENAME,
+ VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL);
- add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__DIRTY,
- VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0);
- add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__RESIZE,
- VARIABLE_ENTRY_TYPE, 3, FALSE, VARIABLE_ENTRY_SIZE);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__DIRTY,
+ VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__RESIZE,
+ VARIABLE_ENTRY_TYPE, 3, FALSE, VARIABLE_ENTRY_SIZE, NULL);
- add_flush_op(VARIABLE_ENTRY_TYPE, 7, FLUSH_OP__DIRTY,
- VARIABLE_ENTRY_TYPE, 6, FALSE, (size_t)0);
+ add_flush_op(VARIABLE_ENTRY_TYPE, 7, FLUSH_OP__DIRTY,
+ VARIABLE_ENTRY_TYPE, 6, FALSE, (size_t)0, NULL);
}
if ( pass ) {
- /* to summarize, at present the following variable size entries
+ /* to summarize, at present the following variable size entries
* are in cache with the following characteristics:
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 5 KB Y Y - -
*
- * (VET, 1) Y 10 KB N N 0 dirty (VET, 0),
+ * (VET, 1) Y 10 KB N N 0 dirty (VET, 0),
* resize (VET, 0) to 7.5 KB
*
* (VET, 2) Y 10 KB N N 0 dirty (VET, 0)
@@ -9888,11 +10029,11 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) Y 5 KB Y N 7 -
*
* (VET, 6) Y 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB N Y - dirty (VET, 6)
*
- * Recall that in this test bed, flush operations are excuted the
- * first time the associated entry is flushed, and are then
+ * Recall that in this test bed, flush operations are excuted the
+ * first time the associated entry is flushed, and are then
* deleted.
*/
@@ -9900,14 +10041,14 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 0; i < 31; i++ )
{
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
for ( i = 0; i < 1; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -9926,9 +10067,9 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
/* verify the expected status of all entries we have loaded to date: */
num_large_entries = 1;
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
0,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
}
@@ -9936,8 +10077,8 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
if ( pass ) {
- /* Now load a large entry. This should result in the eviction
- * of (VET,1), and the increase in the size of (VET, 0) from .5
+ /* Now load a large entry. This should result in the eviction
+ * of (VET,1), and the increase in the size of (VET, 0) from .5
* VARIABLE_ENTRY_SIZE to .75 VARIABLE_ENTRY_SIZE.
*
* The following table illustrates the intended state of affairs
@@ -9945,7 +10086,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 7.5 KB Y Y - -
*
* (VET, 1) N 10 KB N N - -
@@ -9962,7 +10103,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) Y 5 KB Y N 7 -
*
* (VET, 6) Y 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB Y Y - dirty (VET, 6)
*
* Start by updating the expected table for the expected changes in entry status:
@@ -9975,7 +10116,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
num_large_entries = 2;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 1,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 1,
H5C__DIRTIED_FLAG, (size_t)0);
if ( ( cache_ptr->index_len != 40 ) ||
@@ -9994,25 +10135,25 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
1,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
- /* Now load another large entry. This should result in the eviction
+ /* Now load another large entry. This should result in the eviction
* of (VET, 2), the increase in the size of (VET, 0) from .75
* VARIABLE_ENTRY_SIZE to 1.0 VARIABLE_ENTRY_SIZE, and the renaming
* of (VET, 0) to its alternate address.
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 10 KB Y Y - -
*
* (VET, 1) N 10 KB N N - -
@@ -10027,7 +10168,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) Y 5 KB Y N 7 -
*
* (VET, 6) Y 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB Y Y - dirty (VET, 6)
*
* Start by updating the expected table for the expected changes in entry status:
@@ -10041,7 +10182,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
num_large_entries = 3;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 2,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 2,
H5C__DIRTIED_FLAG, (size_t)0);
if ( ( cache_ptr->index_len != 40 ) ||
@@ -10051,7 +10192,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
(2 * LARGE_ENTRY_SIZE) ) ||
( cache_ptr->index_size != ((3 * VARIABLE_ENTRY_SIZE / 2) +
(3 * VARIABLE_ENTRY_SIZE) +
- (31 * MONSTER_ENTRY_SIZE) +
+ (31 * MONSTER_ENTRY_SIZE) +
(3 * LARGE_ENTRY_SIZE)) ) ) {
pass = FALSE;
@@ -10059,9 +10200,9 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
2,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
@@ -10071,16 +10212,16 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* flushed, and increasing its size from 1/2 VARIABLE_ENTRY_SIZE to
* VARIABLE_ENTRY_SIZE.
*
- * As a result of this size increase, the cache will have to look
+ * As a result of this size increase, the cache will have to look
* for another entry to evict. After flushing (VET, 4) and (VET, 5),
* it should evict (VET, 6), yielding the needed memory.
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 10 KB Y Y - -
*
* (VET, 1) N 10 KB N N - -
@@ -10094,7 +10235,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) Y 5 KB N N 7 -
*
* (VET, 6) N 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB Y Y - dirty (VET, 6)
*
* Start by updating the expected table for the expected changes in entry status:
@@ -10114,11 +10255,11 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
num_large_entries = 5;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 3,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 3,
H5C__DIRTIED_FLAG, (size_t)0);
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 4);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 4,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, 4,
H5C__DIRTIED_FLAG, (size_t)0);
/* verify cache size */
@@ -10137,16 +10278,16 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
3,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
/* now touch all the non VARIABLE_ENTRY_TYPE entries in the
- * cache to bring all the VARIABLE_ENTRY_TYPE entries to the
+ * cache to bring all the VARIABLE_ENTRY_TYPE entries to the
* end of the LRU list.
*
* Note that we don't have to worry about (VET, 0) and (VET, 7)
@@ -10155,14 +10296,14 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 0; i < 31; i++ )
{
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
for ( i = 0; i < 5; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10177,9 +10318,9 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
4,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
@@ -10188,12 +10329,12 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
/* Now load three more large entries. This should result
* in the eviction of (VET, 3), and the unpinning of (VET, 0)
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 10 KB Y N - -
*
* (VET, 1) N 10 KB N N - -
@@ -10207,7 +10348,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) Y 5 KB N N 7 -
*
* (VET, 6) N 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB Y Y - dirty (VET, 6)
*
* Start by updating the expected table for the expected changes in entry status:
@@ -10222,7 +10363,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 5; i < 8; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10241,9 +10382,9 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
5,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
@@ -10251,12 +10392,12 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
/* load another large entry. (VET, 4) should be evicted.
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 10 KB Y N - -
*
* (VET, 1) N 10 KB N N - -
@@ -10270,7 +10411,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) Y 5 KB N N 7 -
*
* (VET, 6) N 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB Y Y - dirty (VET, 6)
*
* Start by updating the expected table for the expected changes in entry status:
@@ -10284,7 +10425,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 8; i < 9; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10304,24 +10445,24 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
6,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
- /* Load another large entry.
+ /* Load another large entry.
*
- * (VET, 5) should be evicted, and (VET, 7) should be unpinned.
+ * (VET, 5) should be evicted, and (VET, 7) should be unpinned.
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) Y 10 KB Y N - -
*
* (VET, 1) N 10 KB N N - -
@@ -10335,7 +10476,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) N 5 KB N N - -
*
* (VET, 6) N 10 KB N N - -
- *
+ *
* (VET, 7) Y 10 KB Y N - dirty (VET, 6)
*
* Start by updating the expected table for the expected changes in entry status:
@@ -10350,7 +10491,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 9; i < 10; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10368,16 +10509,16 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
7,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
/* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the
- * cache to bring all the VARIABLE_ENTRY_TYPE entries to the
+ * cache to bring all the VARIABLE_ENTRY_TYPE entries to the
* end of the LRU list.
*
* Both (VET, 0) and (VET, 7) have been unpinned, so they are
@@ -10386,14 +10527,14 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 0; i < 31; i++ )
{
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
for ( i = 0; i < 10; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10411,35 +10552,35 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
8,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
- /* load two more large entries.
+ /* load two more large entries.
*
* (VET, 0) should be flushed, but not evicted initially since it is dirty.
*
- * (VET, 7) should be evicted, but (VET, 7) has an eviction operation that
- * dirties (VET, 6). Since (VET, 6) is not in the cache, it will be loaded.
+ * (VET, 7) should be evicted, but (VET, 7) has an eviction operation that
+ * dirties (VET, 6). Since (VET, 6) is not in the cache, it will be loaded.
* Since this results in no net increase in free space, the cache will
* continue to attempt to create free space.
*
* The cache will then flush all the monster and large entries, but since they
- * are all dirty, they will not be evicted.
+ * are all dirty, they will not be evicted.
*
* Finally, it will reach (VET, 0) again, and evict it on the second pass.
* This finally makes the necessary space.
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) N 10 KB N N - -
*
* (VET, 1) N 10 KB N N - -
@@ -10453,12 +10594,12 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) N 5 KB N N - -
*
* (VET, 6) Y 10 KB Y N - -
- *
+ *
* (VET, 7) N 10 KB N N - -
*
* Start by updating the expected table for the expected changes in entry status:
*
- * Note that we reset the loaded, cleared, flushed, and destroyed fields of
+ * Note that we reset the loaded, cleared, flushed, and destroyed fields of
* (VET,6) so we can track what is happening.
*/
base_addr = entries[VARIABLE_ENTRY_TYPE];
@@ -10486,7 +10627,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
/* a newly loaded entry is not inserted in the cache until after space has been
* made for it. Thus (LET, 11) will not be flushed.
*/
- for ( i = num_variable_entries;
+ for ( i = num_variable_entries;
i < num_variable_entries + num_monster_entries + num_large_entries - 1;
i++ )
{
@@ -10497,7 +10638,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 10; i < 12; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10515,34 +10656,34 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
9,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
/* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the
- * cache to bring the last remaining VARIABLE_ENTRY_TYPE entry to the
- * end of the LRU list.
+ * cache to bring the last remaining VARIABLE_ENTRY_TYPE entry to the
+ * end of the LRU list.
*/
for ( i = 0; i < num_monster_entries; i++ )
{
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, MONSTER_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
for ( i = 0; i < num_large_entries; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
/* update the expected array to mark all these entries dirty again. */
- for ( i = num_variable_entries;
+ for ( i = num_variable_entries;
i < num_variable_entries + num_monster_entries + num_large_entries - 1;
i++ )
{
@@ -10563,27 +10704,27 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
10,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
if ( pass ) {
-
- /* Load two more large entries.
+
+ /* Load two more large entries.
*
* Since (VET, 6) is dirty, at first this will just cause (VET, 6) to be flushed.
*
* But all other entries in the cache are dirty, so the cache will flush them all,
* and then evict (VET, 6) on the second pass.
*
- * The following table shows the expected states of the variable
+ * The following table shows the expected states of the variable
* size entries after the test.
*
* in
* entry: cache? size: dirty? pinned? pins: flush operations:
- *
+ *
* (VET, 0) N 10 KB N N - -
*
* (VET, 1) N 10 KB N N - -
@@ -10597,7 +10738,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
* (VET, 5) N 5 KB N N - -
*
* (VET, 6) N 10 KB N N - -
- *
+ *
* (VET, 7) N 10 KB N N - -
*
* Start by updating the expected table for the expected changes in entry status:
@@ -10613,7 +10754,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
/* a newly loaded entry is not inserted in the cache until after space has been
* made for it. Thus (LET, 13) will not be flushed.
*/
- for ( i = num_variable_entries;
+ for ( i = num_variable_entries;
i < num_variable_entries + num_monster_entries + num_large_entries - 1;
i++ )
{
@@ -10624,7 +10765,7 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
for ( i = 12; i < 14; i++ )
{
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, i);
- unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
+ unprotect_entry_with_size_change(cache_ptr, LARGE_ENTRY_TYPE, i,
H5C__DIRTIED_FLAG, (size_t)0);
}
@@ -10641,9 +10782,9 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
/* verify entry status */
- verify_entry_status(cache_ptr,
+ verify_entry_status(cache_ptr,
11,
- (num_variable_entries + num_monster_entries + num_large_entries),
+ (num_variable_entries + num_monster_entries + num_large_entries),
expected);
}
@@ -10671,12 +10812,12 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
}
}
-#if H5C_COLLECT_CACHE_STATS
+#if H5C_COLLECT_CACHE_STATS
/* If we are collecting stats, check to see if we get the expected
* values.
*
* Testing the stats code is fairly new, but given the extent
- * to which I find myself depending on the stats, I've decided
+ * to which I find myself depending on the stats, I've decided
* to start testing the stats whenever it is convenient to do
* so.
*/
@@ -10793,7 +10934,8 @@ check_flush_cache__flush_op_eviction_test(H5C_t * cache_ptr)
static void
check_flush_cache__single_entry(H5C_t * cache_ptr)
{
- /* const char * fcn_name = "check_flush_cache__single_entry"; */
+ const char * fcn_name = "check_flush_cache__single_entry";
+ hbool_t show_progress = FALSE;
if ( cache_ptr == NULL ) {
@@ -10809,6 +10951,10 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 1);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10824,10 +10970,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 2);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10843,10 +10997,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 3);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10862,10 +11024,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 4);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10881,10 +11051,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 5);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10900,10 +11078,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 6);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10919,10 +11105,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 7);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10938,10 +11132,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 8);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10957,10 +11159,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 9);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10977,10 +11187,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 10);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -10997,10 +11215,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 11);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11017,10 +11243,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 12);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11037,10 +11271,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 13);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11057,10 +11299,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 14);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11077,10 +11327,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 15);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11098,10 +11356,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 16);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11119,10 +11385,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 17);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11138,10 +11412,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 18);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11157,10 +11439,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 19);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11176,10 +11466,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 20);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11195,10 +11493,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 21);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11214,10 +11520,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 22);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11233,10 +11547,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 23);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11252,10 +11574,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 24);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11271,10 +11601,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 25);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11291,10 +11629,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 26);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11311,10 +11657,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 27);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11331,10 +11685,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 28);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11351,10 +11713,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 29);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11371,10 +11741,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 30);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11391,10 +11769,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 31);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11412,10 +11798,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 32);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11433,10 +11827,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 33);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11452,10 +11854,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 34);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11471,10 +11881,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 35);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11490,10 +11908,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 36);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11509,10 +11935,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 37);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11528,10 +11962,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 38);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11547,10 +11989,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 39);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11566,10 +12016,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 40);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11585,10 +12043,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 41);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11605,10 +12071,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 42);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11625,10 +12099,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 43);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11645,10 +12127,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 44);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11665,10 +12155,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 45);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11685,10 +12183,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 46);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11705,10 +12211,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 47);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11726,10 +12240,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 48);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11747,10 +12269,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 49);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11766,10 +12296,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 50);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11785,10 +12323,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 51);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11804,10 +12350,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 52);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11823,10 +12377,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 53);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11842,10 +12404,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 54);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11861,10 +12431,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 55);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11880,10 +12458,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 56);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11899,10 +12485,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 57);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11919,10 +12513,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 58);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11939,10 +12541,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 59);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11959,10 +12569,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 60);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11979,10 +12597,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ FALSE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 61);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -11999,10 +12625,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 62);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -12019,10 +12653,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ TRUE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 63);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -12040,10 +12682,18 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
if ( pass ) {
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running test %d.\n", fcn_name, 64);
+ }
+
check_flush_cache__single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -12061,6 +12711,10 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
/* expected_flushed */ FALSE,
/* expected_destroyed */ TRUE
);
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: pass = %d.\n", fcn_name, (int)pass);
+ }
}
@@ -12409,6 +13063,11 @@ check_flush_cache__single_entry(H5C_t * cache_ptr)
i = 0;
while ( ( pass ) && ( i < 256 ) )
{
+
+ if ( show_progress ) {
+ HDfprintf(stdout, "%s: running pinned test %d.\n", fcn_name, i);
+ }
+
check_flush_cache__pinned_single_entry_test
(
/* cache_ptr */ cache_ptr,
@@ -12544,7 +13203,7 @@ check_flush_cache__single_entry_test(H5C_t * cache_ptr,
(int)expected_flushed,
(int)(entry_ptr->destroyed),
(int)expected_destroyed);
-#endif
+#endif
pass = FALSE;
HDsnprintf(msg, (size_t)128,
"Unexpected entry status after flush in single entry test #%d.",
@@ -12846,7 +13505,7 @@ check_flush_cache__pinned_single_entry_test(H5C_t * cache_ptr,
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_get_entry_status(void)
{
const char * fcn_name = "check_get_entry_status";
@@ -12883,7 +13542,7 @@ check_get_entry_status(void)
*/
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -12907,7 +13566,7 @@ check_get_entry_status(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -12929,7 +13588,7 @@ check_get_entry_status(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -12951,7 +13610,7 @@ check_get_entry_status(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -12973,7 +13632,7 @@ check_get_entry_status(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -12995,7 +13654,7 @@ check_get_entry_status(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13025,7 +13684,7 @@ check_get_entry_status(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_get_entry_status() */
@@ -13047,7 +13706,7 @@ check_get_entry_status(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_expunge_entry(void)
{
const char * fcn_name = "check_expunge_entry";
@@ -13084,8 +13743,8 @@ check_expunge_entry(void)
*/
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13123,7 +13782,7 @@ check_expunge_entry(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13151,19 +13810,19 @@ check_expunge_entry(void)
}
/* Expunge the entry and then verify that it is no longer in the cache.
- * Also verify that the entry was loaded, cleared, and destroyed, but
+ * Also verify that the entry was loaded, cleared, and destroyed, but
* not flushed.
*/
expunge_entry(cache_ptr, 0, 0);
if ( pass ) {
- /* entry shouldn't be in cache -- only in_cache should be touched
+ /* entry shouldn't be in cache -- only in_cache should be touched
* by the status call. Thus, only check that boolean.
*/
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected, &is_pinned);
+ &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13193,7 +13852,7 @@ check_expunge_entry(void)
/* now repeat the process with a different entry. On unprotect
* mark the entry as dirty. Verify that it is not flushed.
*/
-
+
base_addr = entries[0];
entry_ptr = &(base_addr[1]);
@@ -13204,8 +13863,8 @@ check_expunge_entry(void)
*/
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13243,8 +13902,8 @@ check_expunge_entry(void)
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13279,13 +13938,13 @@ check_expunge_entry(void)
if ( pass ) {
- /* entry shouldn't be in cache -- only in_cache should be touched
+ /* entry shouldn't be in cache -- only in_cache should be touched
* by the status call. Thus, only check that boolean.
*/
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -13325,7 +13984,7 @@ check_expunge_entry(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_expunge_entry() */
@@ -13333,7 +13992,7 @@ check_expunge_entry(void)
/*-------------------------------------------------------------------------
* Function: check_multiple_read_protect()
*
- * Purpose: Verify that multiple, simultaneous read protects of a
+ * Purpose: Verify that multiple, simultaneous read protects of a
* single entry perform as expectd.
*
* Return: void
@@ -13349,7 +14008,7 @@ check_expunge_entry(void)
*/
-static void
+static unsigned
check_multiple_read_protect(void)
{
const char * fcn_name = "check_multiple_read_protect()";
@@ -13390,7 +14049,7 @@ check_multiple_read_protect(void)
entry_ptr = &((entries[0])[0]);
- if ( ( entry_ptr->header.is_protected ) ||
+ if ( ( entry_ptr->header.is_protected ) ||
( entry_ptr->header.is_read_only ) ||
( entry_ptr->header.ro_ref_count != 0 ) ) {
@@ -13413,7 +14072,7 @@ check_multiple_read_protect(void)
{
protect_entry_ro(cache_ptr, 0, 0);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 1 ) ) {
@@ -13436,7 +14095,7 @@ check_multiple_read_protect(void)
{
protect_entry_ro(cache_ptr, 0, 0);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 2 ) ) {
@@ -13459,7 +14118,7 @@ check_multiple_read_protect(void)
{
unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 1 ) ) {
@@ -13482,7 +14141,7 @@ check_multiple_read_protect(void)
{
protect_entry_ro(cache_ptr, 0, 0);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 2 ) ) {
@@ -13505,7 +14164,7 @@ check_multiple_read_protect(void)
{
protect_entry_ro(cache_ptr, 0, 0);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 3 ) ) {
@@ -13528,7 +14187,7 @@ check_multiple_read_protect(void)
{
unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 2 ) ) {
@@ -13551,7 +14210,7 @@ check_multiple_read_protect(void)
{
unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( ! ( entry_ptr->header.is_read_only ) ) ||
( entry_ptr->header.ro_ref_count != 1 ) ) {
@@ -13574,7 +14233,7 @@ check_multiple_read_protect(void)
{
unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- if ( ( entry_ptr->header.is_protected ) ||
+ if ( ( entry_ptr->header.is_protected ) ||
( entry_ptr->header.is_read_only ) ||
( entry_ptr->header.ro_ref_count != 0 ) ) {
@@ -13594,7 +14253,7 @@ check_multiple_read_protect(void)
#endif /* H5C_COLLECT_CACHE_STATS */
- /* If we get this far, do a write protect and unprotect to verify
+ /* If we get this far, do a write protect and unprotect to verify
* that the stats are getting collected properly here as well.
*/
@@ -13602,7 +14261,7 @@ check_multiple_read_protect(void)
{
protect_entry(cache_ptr, 0, 0);
- if ( ( ! ( entry_ptr->header.is_protected ) ) ||
+ if ( ( ! ( entry_ptr->header.is_protected ) ) ||
( entry_ptr->header.is_read_only ) ||
( entry_ptr->header.ro_ref_count != 0 ) ) {
@@ -13625,7 +14284,7 @@ check_multiple_read_protect(void)
{
unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- if ( ( entry_ptr->header.is_protected ) ||
+ if ( ( entry_ptr->header.is_protected ) ||
( entry_ptr->header.is_read_only ) ||
( entry_ptr->header.ro_ref_count != 0 ) ) {
@@ -13645,7 +14304,7 @@ check_multiple_read_protect(void)
#endif /* H5C_COLLECT_CACHE_STATS */
- /* Finally, mix things up a little, using a mix of reads and
+ /* Finally, mix things up a little, using a mix of reads and
* and writes on different entries. Also include a pin to verify
* that it works as well.
*
@@ -13746,7 +14405,7 @@ check_multiple_read_protect(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_multiple_read_protect() */
@@ -13768,7 +14427,7 @@ check_multiple_read_protect(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_rename_entry(void)
{
const char * fcn_name = "check_rename_entry";
@@ -13859,7 +14518,7 @@ check_rename_entry(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_rename_entry() */
@@ -14029,7 +14688,7 @@ check_rename_entry__run_test(H5C_t * cache_ptr,
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_pin_protected_entry(void)
{
const char * fcn_name = "check_pin_protected_entry";
@@ -14099,7 +14758,7 @@ check_pin_protected_entry(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_pin_protected_entry() */
@@ -14122,7 +14781,7 @@ check_pin_protected_entry(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_resize_entry(void)
{
const char * fcn_name = "check_resize_entry";
@@ -14142,7 +14801,7 @@ check_resize_entry(void)
/* Setup a cache and verify that it is empty.
*
- * Then force the load of an entry by protecting it, and verify that
+ * Then force the load of an entry by protecting it, and verify that
* the entry and cache have the expected sizes.
*
* Then unprotect the entry with the size changed flag and a reduced
@@ -14150,10 +14809,10 @@ check_resize_entry(void)
* sizes.
*
* Use a second protect/unprotect cycle to restore the entry to
- * its original size. Verify that the entry and cache have the
+ * its original size. Verify that the entry and cache have the
* expected sizes.
*
- * Protect and unprotect the entry again to pin it. Use
+ * Protect and unprotect the entry again to pin it. Use
* H5C_resize_entry to reduce its size. Verify that the entry
* and cache have the expected sizes.
*
@@ -14165,7 +14824,7 @@ check_resize_entry(void)
*
*
* Obesrve that all the above tests have been done with only one
- * entry in the cache. Repeat the tests with several entries in
+ * entry in the cache. Repeat the tests with several entries in
* the cache.
*/
@@ -14218,9 +14877,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14249,9 +14908,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_unprotect(NULL, -1, -1, cache_ptr,
+ result = H5C_unprotect(NULL, -1, -1, cache_ptr,
&(types[LARGE_ENTRY_TYPE]), entry_ptr->addr,
- (void *)entry_ptr,
+ (void *)entry_ptr,
H5C__SIZE_CHANGED_FLAG | H5C__DIRTIED_FLAG,
(LARGE_ENTRY_SIZE / 2));
@@ -14288,9 +14947,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14322,9 +14981,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_unprotect(NULL, -1, -1, cache_ptr,
+ result = H5C_unprotect(NULL, -1, -1, cache_ptr,
&(types[LARGE_ENTRY_TYPE]), entry_ptr->addr,
- (void *)entry_ptr,
+ (void *)entry_ptr,
(H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG),
LARGE_ENTRY_SIZE);
@@ -14361,9 +15020,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14397,17 +15056,17 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
+ result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
(LARGE_ENTRY_SIZE / 4));
if ( result < 0 ) {
pass = FALSE;
- HDsnprintf(msg, (size_t)128,
+ HDsnprintf(msg, (size_t)128,
"H5C_resize_pinned_entry() reports failure 1.");
failure_mssg = msg;
- }
+ }
}
if ( pass ) {
@@ -14426,9 +15085,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14458,17 +15117,17 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
+ result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
LARGE_ENTRY_SIZE);
if ( result < 0 ) {
pass = FALSE;
- HDsnprintf(msg, (size_t)128,
+ HDsnprintf(msg, (size_t)128,
"H5C_resize_pinned_entry() reports failure 2.");
failure_mssg = msg;
- }
+ }
}
if ( pass ) {
@@ -14487,9 +15146,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14519,14 +15178,14 @@ check_resize_entry(void)
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE,
H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14630,9 +15289,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14661,9 +15320,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_unprotect(NULL, -1, -1, cache_ptr,
+ result = H5C_unprotect(NULL, -1, -1, cache_ptr,
&(types[LARGE_ENTRY_TYPE]), entry_ptr->addr,
- (void *)entry_ptr,
+ (void *)entry_ptr,
H5C__SIZE_CHANGED_FLAG | H5C__DIRTIED_FLAG,
(LARGE_ENTRY_SIZE / 2));
@@ -14687,10 +15346,10 @@ check_resize_entry(void)
if ( pass ) {
if ( ( cache_ptr->index_len != 4 ) ||
- ( cache_ptr->index_size !=
+ ( cache_ptr->index_size !=
((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 2)) ) ||
( cache_ptr->slist_len != 2 ) ||
- ( cache_ptr->slist_size !=
+ ( cache_ptr->slist_size !=
(LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 2)) ) ) {
pass = FALSE;
@@ -14702,9 +15361,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14736,9 +15395,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_unprotect(NULL, -1, -1, cache_ptr,
+ result = H5C_unprotect(NULL, -1, -1, cache_ptr,
&(types[LARGE_ENTRY_TYPE]), entry_ptr->addr,
- (void *)entry_ptr,
+ (void *)entry_ptr,
(H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG),
LARGE_ENTRY_SIZE);
@@ -14775,9 +15434,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14811,26 +15470,26 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
+ result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
(LARGE_ENTRY_SIZE / 4));
if ( result < 0 ) {
pass = FALSE;
- HDsnprintf(msg, (size_t)128,
+ HDsnprintf(msg, (size_t)128,
"H5C_resize_pinned_entry() reports failure 3.");
failure_mssg = msg;
- }
+ }
}
if ( pass ) {
if ( ( cache_ptr->index_len != 4 ) ||
- ( cache_ptr->index_size !=
+ ( cache_ptr->index_size !=
((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 4)) ) ||
( cache_ptr->slist_len != 2 ) ||
- ( cache_ptr->slist_size !=
+ ( cache_ptr->slist_size !=
(LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 4)) ) ) {
pass = FALSE;
@@ -14842,9 +15501,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14874,17 +15533,17 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
+ result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr,
LARGE_ENTRY_SIZE);
if ( result < 0 ) {
pass = FALSE;
- HDsnprintf(msg, (size_t)128,
+ HDsnprintf(msg, (size_t)128,
"H5C_resize_pinned_entry() reports failure 4.");
failure_mssg = msg;
- }
+ }
}
if ( pass ) {
@@ -14903,9 +15562,9 @@ check_resize_entry(void)
if ( pass ) {
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- &reported_entry_size, &in_cache,
- &is_dirty, &is_protected, &is_pinned);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ &reported_entry_size, &in_cache,
+ &is_dirty, &is_protected, &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -14935,14 +15594,14 @@ check_resize_entry(void)
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE,
H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
if ( pass ) {
result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
@@ -15020,7 +15679,7 @@ check_resize_entry(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_resize_entry() */
@@ -15028,7 +15687,7 @@ check_resize_entry(void)
/*-------------------------------------------------------------------------
* Function: check_evictions_enabled()
*
- * Purpose: Verify that H5C_get_evictions_enabled() and
+ * Purpose: Verify that H5C_get_evictions_enabled() and
* H5C_set_evictions_enabled() functions perform as expected.
*
* Return: void
@@ -15043,7 +15702,7 @@ check_resize_entry(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_evictions_enabled(void)
{
const char * fcn_name = "check_evictions_enabled";
@@ -15054,7 +15713,6 @@ check_evictions_enabled(void)
hbool_t in_cache;
int i;
int mile_stone = 1;
- size_t entry_size;
H5C_t * cache_ptr = NULL;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
@@ -15077,7 +15735,7 @@ check_evictions_enabled(void)
* Load another entry -- verify that this does not cause an entry
* to be evicted.
*
- * Insert an entry -- verify that this does not cause an entry to
+ * Insert an entry -- verify that this does not cause an entry to
* be evicted.
*
* Use H5C_set_evictions_enabled() to re-enable evictions. Verify
@@ -15090,7 +15748,7 @@ check_evictions_enabled(void)
* Protect an entry not in the cache. Verify that this causes
* two evictions.
*
- * Used H5C_set_evictions_enabled() to disable evictions again.
+ * Used H5C_set_evictions_enabled() to disable evictions again.
* Verify with a call to H5C_get_evictions_enabled().
*
* Now flush and discard the cache -- should succeed.
@@ -15111,7 +15769,6 @@ check_evictions_enabled(void)
(size_t)( 512 * 1024));
base_addr = entries[MONSTER_ENTRY_TYPE];
- entry_size = MONSTER_ENTRY_SIZE;
}
if ( show_progress ) /* 2 */
@@ -15159,7 +15816,7 @@ check_evictions_enabled(void)
for ( i = 0; i < 16 ; i++ )
{
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i,
+ unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i,
FALSE, H5C__NO_FLAGS_SET);
}
@@ -15190,7 +15847,7 @@ check_evictions_enabled(void)
/* protect and unprotect another entry */
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 16);
- unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 16,
+ unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 16,
FALSE, H5C__NO_FLAGS_SET);
if ( show_progress ) /* 7 */
@@ -15221,8 +15878,8 @@ check_evictions_enabled(void)
entry_ptr = &(base_addr[0]);
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- NULL, &in_cache, NULL, NULL, NULL);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ NULL, &in_cache, NULL, NULL, NULL, NULL, NULL);
if ( result < 0 ) {
@@ -15284,8 +15941,8 @@ check_evictions_enabled(void)
entry_ptr = &(base_addr[1]);
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- NULL, &in_cache, NULL, NULL, NULL);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ NULL, &in_cache, NULL, NULL, NULL, NULL, NULL);
if ( result < 0 ) {
@@ -15355,7 +16012,7 @@ check_evictions_enabled(void)
/* protect and unprotect another entry */
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 18);
- unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 18,
+ unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 18,
FALSE, H5C__NO_FLAGS_SET);
if ( show_progress ) /* 15 */
@@ -15428,7 +16085,7 @@ check_evictions_enabled(void)
/* protect and unprotect an entry that is in the cache */
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 19);
- unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 19,
+ unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 19,
FALSE, H5C__NO_FLAGS_SET);
if ( show_progress ) /* 20 */
@@ -15457,14 +16114,14 @@ check_evictions_enabled(void)
/* protect and unprotect an entry that isn't in the cache */
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 20);
- unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 20,
+ unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 20,
FALSE, H5C__NO_FLAGS_SET);
if ( show_progress ) /* 22 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* verify that the entries have been evicted to bring the
+ /* verify that the entries have been evicted to bring the
* cache back down to its normal size.
*/
@@ -15491,8 +16148,8 @@ check_evictions_enabled(void)
entry_ptr = &(base_addr[2]);
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- NULL, &in_cache, NULL, NULL, NULL);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ NULL, &in_cache, NULL, NULL, NULL, NULL, NULL);
if ( result < 0 ) {
@@ -15527,8 +16184,8 @@ check_evictions_enabled(void)
entry_ptr = &(base_addr[3]);
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- NULL, &in_cache, NULL, NULL, NULL);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ NULL, &in_cache, NULL, NULL, NULL, NULL, NULL);
if ( result < 0 ) {
@@ -15576,11 +16233,11 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that isn't in the cache, forcing
+ /* protect and unprotect an entry that isn't in the cache, forcing
* the cache to grow.
*/
protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 21);
- unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 21,
+ unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 21,
FALSE, H5C__NO_FLAGS_SET);
@@ -15656,8 +16313,8 @@ check_evictions_enabled(void)
entry_ptr = &(base_addr[4]);
- result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
- NULL, &in_cache, NULL, NULL, NULL);
+ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr,
+ NULL, &in_cache, NULL, NULL, NULL, NULL, NULL);
if ( result < 0 ) {
@@ -15722,7 +16379,7 @@ check_evictions_enabled(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_evictions_enabled() */
@@ -15743,7 +16400,7 @@ check_evictions_enabled(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_flush_protected_err(void)
{
const char * fcn_name = "check_flush_protected_err";
@@ -15798,7 +16455,7 @@ check_flush_protected_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_flush_protected_err() */
@@ -15820,7 +16477,7 @@ check_flush_protected_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_destroy_pinned_err(void)
{
const char * fcn_name = "check_destroy_pinned_err()";
@@ -15871,7 +16528,7 @@ check_destroy_pinned_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_destroy_pinned_err() */
@@ -15892,7 +16549,7 @@ check_destroy_pinned_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_destroy_protected_err(void)
{
const char * fcn_name = "check_destroy_protected_err";
@@ -15942,7 +16599,7 @@ check_destroy_protected_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_destroy_protected_err() */
@@ -15963,11 +16620,11 @@ check_destroy_protected_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_duplicate_insert_err(void)
{
const char * fcn_name = "check_duplicate_insert_err";
- herr_t result;
+ herr_t result = -1;
H5C_t * cache_ptr = NULL;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
@@ -16021,7 +16678,7 @@ check_duplicate_insert_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_duplicate_insert_err() */
@@ -16042,7 +16699,7 @@ check_duplicate_insert_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_rename_err(void)
{
const char * fcn_name = "check_rename_err()";
@@ -16114,7 +16771,7 @@ check_rename_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_rename_err() */
@@ -16137,7 +16794,7 @@ check_rename_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_double_pin_err(void)
{
const char * fcn_name = "check_double_pin_err()";
@@ -16202,7 +16859,7 @@ check_double_pin_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_double_pin_err() */
@@ -16225,7 +16882,7 @@ check_double_pin_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_double_unpin_err(void)
{
const char * fcn_name = "check_double_unpin_err()";
@@ -16301,7 +16958,7 @@ check_double_unpin_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_double_unpin_err() */
@@ -16324,7 +16981,7 @@ check_double_unpin_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_pin_entry_errs(void)
{
const char * fcn_name = "check_pin_entry_errs()";
@@ -16412,7 +17069,7 @@ check_pin_entry_errs(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_pin_entry_errs() */
@@ -16438,7 +17095,7 @@ check_pin_entry_errs(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_double_protect_err(void)
{
const char * fcn_name = "check_double_protect_err()";
@@ -16469,7 +17126,7 @@ check_double_protect_err(void)
if ( pass ) {
- cache_entry_ptr = H5C_protect(NULL, -1, -1, cache_ptr, &(types[0]),
+ cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(NULL, -1, -1, cache_ptr, &(types[0]),
entry_ptr->addr, NULL, NULL,
H5C__NO_FLAGS_SET);
@@ -16498,7 +17155,7 @@ check_double_protect_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_double_protect_err() */
@@ -16527,7 +17184,7 @@ check_double_protect_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_double_unprotect_err(void)
{
const char * fcn_name = "check_double_unprotect_err()";
@@ -16585,7 +17242,7 @@ check_double_unprotect_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_double_unprotect_err() */
@@ -16617,7 +17274,7 @@ check_double_unprotect_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_mark_entry_dirty_errs(void)
{
const char * fcn_name = "check_mark_entry_dirty_errs()";
@@ -16715,7 +17372,7 @@ check_mark_entry_dirty_errs(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_mark_entry_dirty_errs() */
@@ -16738,7 +17395,7 @@ check_mark_entry_dirty_errs(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_expunge_entry_errs(void)
{
const char * fcn_name = "check_expunge_entry_errs()";
@@ -16777,8 +17434,8 @@ check_expunge_entry_errs(void)
if ( pass ) {
- result = H5C_expunge_entry(NULL, -1, -1, cache_ptr,
- &(types[0]), entry_ptr->addr);
+ result = H5C_expunge_entry(NULL, -1, -1, cache_ptr,
+ &(types[0]), entry_ptr->addr, H5AC__NO_FLAGS_SET);
if ( result > 0 ) {
@@ -16795,8 +17452,8 @@ check_expunge_entry_errs(void)
if ( pass ) {
- result = H5C_expunge_entry(NULL, -1, -1, cache_ptr,
- &(types[0]), entry_ptr->addr);
+ result = H5C_expunge_entry(NULL, -1, -1, cache_ptr,
+ &(types[0]), entry_ptr->addr, H5AC__NO_FLAGS_SET);
if ( result > 0 ) {
@@ -16813,8 +17470,8 @@ check_expunge_entry_errs(void)
if ( pass ) {
- result = H5C_expunge_entry(NULL, -1, -1, cache_ptr,
- &(types[0]), entry_ptr->addr);
+ result = H5C_expunge_entry(NULL, -1, -1, cache_ptr,
+ &(types[0]), entry_ptr->addr, H5AC__NO_FLAGS_SET);
if ( result < 0 ) {
@@ -16839,7 +17496,7 @@ check_expunge_entry_errs(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_expunge_entry_errs() */
@@ -16862,7 +17519,7 @@ check_expunge_entry_errs(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_resize_entry_errs(void)
{
const char * fcn_name = "check_resize_entry_errs()";
@@ -16874,11 +17531,11 @@ check_resize_entry_errs(void)
pass = TRUE;
- /* Allocate a cache, protect an entry, and then call
+ /* Allocate a cache, protect an entry, and then call
* H5C_resize_pinned_entry() to resize it -- this should fail.
*
* Unprotect the the entry with the pinned flag, and then call
- * H5C_resize_pinned_entry() again with new size of zero.
+ * H5C_resize_pinned_entry() again with new size of zero.
* This should fail too.
*
* Finally, unpin the entry and destroy the cache.
@@ -16945,7 +17602,7 @@ check_resize_entry_errs(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_resize_entry_errs() */
@@ -16968,7 +17625,7 @@ check_resize_entry_errs(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_unprotect_ro_dirty_err(void)
{
const char * fcn_name = "check_unprotect_ro_dirty_err()";
@@ -16980,7 +17637,7 @@ check_unprotect_ro_dirty_err(void)
pass = TRUE;
- /* allocate a cache, protect an entry read only, and then unprotect it
+ /* allocate a cache, protect an entry read only, and then unprotect it
* with the dirtied flag set. This should fail. Destroy the cache
* -- should succeed.
*/
@@ -17022,8 +17679,8 @@ check_unprotect_ro_dirty_err(void)
takedown_cache(cache_ptr, FALSE, FALSE);
}
- /* allocate a another cache, protect an entry read only twice, and
- * then unprotect it with the dirtied flag set. This should fail.
+ /* allocate a another cache, protect an entry read only twice, and
+ * then unprotect it with the dirtied flag set. This should fail.
* Unprotect it with no flags set twice and then destroy the cache.
* This should succeed.
*/
@@ -17075,7 +17732,7 @@ check_unprotect_ro_dirty_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_unprotect_ro_dirty_err() */
@@ -17098,7 +17755,7 @@ check_unprotect_ro_dirty_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_protect_ro_rw_err(void)
{
const char * fcn_name = "check_protect_ro_rw_err()";
@@ -17110,9 +17767,9 @@ check_protect_ro_rw_err(void)
pass = TRUE;
- /* allocate a cache, protect an entry read only, and then try to protect
+ /* allocate a cache, protect an entry read only, and then try to protect
* it again rw. This should fail.
- *
+ *
* Unprotect the entry and destroy the cache -- should succeed.
*/
@@ -17158,7 +17815,7 @@ check_protect_ro_rw_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_protect_ro_rw_err() */
@@ -17166,7 +17823,7 @@ check_protect_ro_rw_err(void)
/*-------------------------------------------------------------------------
* Function: check_evictions_enabled_err()
*
- * Purpose: Verify that H5C_get_evictions_enabled() and
+ * Purpose: Verify that H5C_get_evictions_enabled() and
* H5C_set_evictions_enabled() generate errors as expected.
*
* Return: void
@@ -17181,7 +17838,7 @@ check_protect_ro_rw_err(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_check_evictions_enabled_err(void)
{
const char * fcn_name = "check_evictions_enabled_err()";
@@ -17200,7 +17857,7 @@ check_check_evictions_enabled_err(void)
*
* Repeat with a NULL evictions_enabled_ptr, should fail as well.
*
- * Configure the cache to use auto cache resize. Call
+ * Configure the cache to use auto cache resize. Call
* H5C_set_evictions_enabled() to disable evictions. Should fail.
*
* Unprotect the entry and destroy the cache -- should succeed.
@@ -17295,7 +17952,7 @@ check_check_evictions_enabled_err(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_evictions_enabled_err() */
@@ -17317,7 +17974,7 @@ check_check_evictions_enabled_err(void)
*
* John Mainzer 1/8/08
* Added a basic set of tests for the flash cache size
- * increment code.
+ * increment code.
*
*-------------------------------------------------------------------------
*/
@@ -17338,7 +17995,7 @@ static void test_rpt_fcn(UNUSED H5C_t * cache_ptr,
rpt_status = status;
}
-static void
+static unsigned
check_auto_cache_resize(void)
{
const char * fcn_name = "check_auto_cache_resize()";
@@ -17372,7 +18029,7 @@ check_auto_cache_resize(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -20523,10 +21180,10 @@ check_auto_cache_resize(void)
}
/* now test the flash cache size increment code. At least at present,
- * there should be no interaction between the regular auto-resize
- * code and the flash cache size increment code other than a reset
+ * there should be no interaction between the regular auto-resize
+ * code and the flash cache size increment code other than a reset
* of the counter and stats collection used by the regular auto-resize
- * code. Thus we do only limited tests of the two pieces of code
+ * code. Thus we do only limited tests of the two pieces of code
* operating together.
*
* Start with simple test to verify that the flash cache increment
@@ -20535,7 +21192,7 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* allocate a cache, enable the flash cache size increase code, and
+ /* allocate a cache, enable the flash cache size increase code, and
* then force the flash size increase code through all its operational
* modes. Verify that all performs as expected.
*/
@@ -20648,7 +21305,7 @@ check_auto_cache_resize(void)
/* Now load a monster entry. Since a monster entry is larger than
* half the size of the cache, and there is not sufficient space
- * for a monster entry in the cache, we will add space to the
+ * for a monster entry in the cache, we will add space to the
* cache to make room for the entry.
*/
if ( pass ) {
@@ -20664,7 +21321,7 @@ check_auto_cache_resize(void)
( ( ( cache_ptr->max_cache_size != (80 * 1024) ) ||
( cache_ptr->min_clean_size != (40 * 1024) ) ||
( cache_ptr->index_len != 2 ) ||
- ( cache_ptr->index_size != (HUGE_ENTRY_SIZE +
+ ( cache_ptr->index_size != (HUGE_ENTRY_SIZE +
MONSTER_ENTRY_SIZE) ) ||
( cache_ptr->cache_accesses != 1 ) ) ) ) {
@@ -20726,9 +21383,9 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* delete existing entries to prepare for next test, and reset
+ /* delete existing entries to prepare for next test, and reset
* the size of the cache.
- */
+ */
if ( pass ) {
expunge_entry(cache_ptr, MONSTER_ENTRY_TYPE, 1);
@@ -20736,12 +21393,12 @@ check_auto_cache_resize(void)
if ( pass ) {
- result = H5C_set_cache_auto_resize_config(cache_ptr,
+ result = H5C_set_cache_auto_resize_config(cache_ptr,
&auto_size_ctl);
if ( result != SUCCEED ) {
- pass = FALSE;
+ pass = FALSE;
failure_mssg = "H5C_set_cache_auto_resize_config failed 13.\n";
}
}
@@ -20758,7 +21415,7 @@ check_auto_cache_resize(void)
}
}
- /* repeat the above basic test, only this time, use inserts to add
+ /* repeat the above basic test, only this time, use inserts to add
* entries to the cache, not protects.
*/
@@ -20793,7 +21450,7 @@ check_auto_cache_resize(void)
/* Now insert a monster entry. Since a monster entry is larger than
* half the size of the cache, and there is not sufficient space
- * for a monster entry in the cache, we will add space to the
+ * for a monster entry in the cache, we will add space to the
* cache to make room for the entry.
*/
if ( pass ) {
@@ -20805,7 +21462,7 @@ check_auto_cache_resize(void)
( ( ( cache_ptr->max_cache_size != (80 * 1024) ) ||
( cache_ptr->min_clean_size != (40 * 1024) ) ||
( cache_ptr->index_len != 2 ) ||
- ( cache_ptr->index_size !=
+ ( cache_ptr->index_size !=
HUGE_ENTRY_SIZE + MONSTER_ENTRY_SIZE ) ||
( cache_ptr->cache_accesses != 0 ) ) ) ) {
@@ -20820,14 +21477,14 @@ check_auto_cache_resize(void)
*/
if ( pass ) {
- insert_entry(cache_ptr, MONSTER_ENTRY_TYPE, 5, TRUE,
+ insert_entry(cache_ptr, MONSTER_ENTRY_TYPE, 5, TRUE,
H5C__NO_FLAGS_SET);
if ( ( pass ) &&
( ( ( cache_ptr->max_cache_size != (144 * 1024) ) ||
( cache_ptr->min_clean_size != ( 72 * 1024) ) ||
( cache_ptr->index_len != 3 ) ||
- ( cache_ptr->index_size !=
+ ( cache_ptr->index_size !=
2 * MONSTER_ENTRY_SIZE + HUGE_ENTRY_SIZE ) ||
( cache_ptr->cache_accesses != 0 ) ) ) ) {
@@ -20862,11 +21519,11 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* delete existing entries to prepare for next test, and reset
+ /* delete existing entries to prepare for next test, and reset
* the size of the cache. We must also change the size of the needed
- * variable entries before we run the test, so will protect and
+ * variable entries before we run the test, so will protect and
* unprotect them now so as to get the correct initial size.
- */
+ */
if ( pass ) {
expunge_entry(cache_ptr, MONSTER_ENTRY_TYPE, 5);
@@ -20894,12 +21551,12 @@ check_auto_cache_resize(void)
if ( pass ) {
auto_size_ctl.initial_size = 6 * 1024;
- result = H5C_set_cache_auto_resize_config(cache_ptr,
+ result = H5C_set_cache_auto_resize_config(cache_ptr,
&auto_size_ctl);
if ( result != SUCCEED ) {
- pass = FALSE;
+ pass = FALSE;
failure_mssg = "H5C_set_cache_auto_resize_config failed 13.\n";
}
}
@@ -20922,11 +21579,11 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
H5C__NO_FLAGS_SET);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
H5C__NO_FLAGS_SET);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12);
@@ -21049,7 +21706,7 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
/* re-size the variable entries back down to their initial size, and
- * restore the cache to its initial size as well, in preparation
+ * restore the cache to its initial size as well, in preparation
* for the next test.
*/
if ( pass ) {
@@ -21067,12 +21724,12 @@ check_auto_cache_resize(void)
if ( pass ) {
auto_size_ctl.initial_size = 6 * 1024;
- result = H5C_set_cache_auto_resize_config(cache_ptr,
+ result = H5C_set_cache_auto_resize_config(cache_ptr,
&auto_size_ctl);
if ( result != SUCCEED ) {
- pass = FALSE;
+ pass = FALSE;
failure_mssg = "H5C_set_cache_auto_resize_config failed 14.\n";
}
}
@@ -21096,7 +21753,7 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
H5C__PIN_ENTRY_FLAG);
resize_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, 2 * 1024, TRUE);
@@ -21135,7 +21792,7 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
H5C__PIN_ENTRY_FLAG);
resize_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, 10 * 1024, TRUE);
@@ -21156,7 +21813,7 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
H5C__PIN_ENTRY_FLAG);
resize_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, 10 * 1024, TRUE);
@@ -21180,15 +21837,15 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
H5C__UNPIN_ENTRY_FLAG);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
H5C__UNPIN_ENTRY_FLAG);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
H5C__UNPIN_ENTRY_FLAG);
if ( ( pass ) &&
@@ -21206,7 +21863,7 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
/* re-size the variable entries back down to their initial size, and
- * restore the cache to its initial size as well, in preparation
+ * restore the cache to its initial size as well, in preparation
* for the next test.
*/
if ( pass ) {
@@ -21224,12 +21881,12 @@ check_auto_cache_resize(void)
if ( pass ) {
auto_size_ctl.initial_size = 6 * 1024;
- result = H5C_set_cache_auto_resize_config(cache_ptr,
+ result = H5C_set_cache_auto_resize_config(cache_ptr,
&auto_size_ctl);
if ( result != SUCCEED ) {
- pass = FALSE;
+ pass = FALSE;
failure_mssg = "H5C_set_cache_auto_resize_config failed 15.\n";
}
}
@@ -21249,7 +21906,7 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
H5C__PIN_ENTRY_FLAG);
resize_pinned_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, 2 * 1024);
@@ -21288,7 +21945,7 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
H5C__PIN_ENTRY_FLAG);
resize_pinned_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, 10 * 1024);
@@ -21309,7 +21966,7 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
H5C__PIN_ENTRY_FLAG);
resize_pinned_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, 10 * 1024);
@@ -21333,15 +21990,15 @@ check_auto_cache_resize(void)
if ( pass ) {
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 10, NO_CHANGE,
H5C__UNPIN_ENTRY_FLAG);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 11, NO_CHANGE,
H5C__UNPIN_ENTRY_FLAG);
protect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12);
- unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
+ unprotect_entry(cache_ptr, VARIABLE_ENTRY_TYPE, 12, NO_CHANGE,
H5C__UNPIN_ENTRY_FLAG);
if ( ( pass ) &&
@@ -21455,14 +22112,14 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
/* protect and unprotect a large entry -- no change in cache size since
- * a large entry will just fill the available space in the cache.
+ * a large entry will just fill the available space in the cache.
*/
if ( pass ) {
rpt_fcn_called = FALSE;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, NO_CHANGE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, NO_CHANGE,
H5C__NO_FLAGS_SET);
if ( ( pass ) &&
@@ -21480,7 +22137,7 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* protect and unprotect another a large entry -- should trigger a
+ /* protect and unprotect another a large entry -- should trigger a
* flash cache size increase to 12 KB (remember that flash_multiple is
* set to 2.0).
*/
@@ -21489,7 +22146,7 @@ check_auto_cache_resize(void)
rpt_fcn_called = FALSE;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, NO_CHANGE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, NO_CHANGE,
H5C__NO_FLAGS_SET);
if ( ( pass ) &&
@@ -21507,7 +22164,7 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* protect and unprotect two more large entries -- shouldnt trigger a
+ /* protect and unprotect two more large entries -- shouldnt trigger a
* flash cache size increase.
*/
if ( pass ) {
@@ -21515,10 +22172,10 @@ check_auto_cache_resize(void)
rpt_fcn_called = FALSE;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, NO_CHANGE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, NO_CHANGE,
H5C__NO_FLAGS_SET);
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, NO_CHANGE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, NO_CHANGE,
H5C__NO_FLAGS_SET);
if ( ( pass ) &&
@@ -21536,7 +22193,7 @@ check_auto_cache_resize(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* do many accesses of a single entry to talk the cache into reducing
+ /* do many accesses of a single entry to talk the cache into reducing
* its size to the minimum.
*/
if ( pass ) {
@@ -21572,17 +22229,17 @@ check_auto_cache_resize(void)
rpt_fcn_called = FALSE;
protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, NO_CHANGE,
+ unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, NO_CHANGE,
H5C__NO_FLAGS_SET);
if ( ( pass ) &&
( ( ( cache_ptr->max_cache_size != (4 * 1024 + 128) ) ||
( cache_ptr->min_clean_size != (2 * 1024 + 64) ) ||
( cache_ptr->index_len != 2 ) ||
- ( cache_ptr->index_size !=
+ ( cache_ptr->index_size !=
LARGE_ENTRY_SIZE + TINY_ENTRY_SIZE ) ||
( cache_ptr->cache_accesses != 1 ) ||
- ( rpt_fcn_called == FALSE ) ||
+ ( rpt_fcn_called == FALSE ) ||
( rpt_status != flash_increase ) ) ) ) {
pass = FALSE;
@@ -21610,7 +22267,7 @@ check_auto_cache_resize(void)
if ( ( cache_ptr->max_cache_size != (20 * 1024) ) ||
( cache_ptr->min_clean_size != (10 * 1024) ) ||
- ( rpt_fcn_called == FALSE ) ||
+ ( rpt_fcn_called == FALSE ) ||
( rpt_status != at_max_size ) ) {
pass = FALSE;
@@ -21636,7 +22293,7 @@ check_auto_cache_resize(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_auto_cache_resize() */
@@ -21654,14 +22311,14 @@ check_auto_cache_resize(void)
*
* Modifications:
*
- * Added code to include the flash cache size increment
+ * Added code to include the flash cache size increment
* code in this test.
* JRM -- 1/10/08
*
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_auto_cache_resize_disable(void)
{
const char * fcn_name = "check_auto_cache_resize_disable()";
@@ -21695,7 +22352,7 @@ check_auto_cache_resize_disable(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 1.0,
/* double flash_threshold = */ 0.25,
@@ -24207,27 +24864,27 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
/* Now test the flash cache size increment code to verify that it
- * is disabled when it should be.
+ * is disabled when it should be.
*
- * Since the flash size increase code doesn't look at hit rate, or
+ * Since the flash size increase code doesn't look at hit rate, or
* use epochs (other than to start a new epoch if a flash cache size
* increase is triggered), we go about these tests somewhat differently
* than the rest of the tests in this function.
*
- * As of this writing, there is only one flash cache size increment
+ * As of this writing, there is only one flash cache size increment
* mode (add space), which is triggered whenever the size of a newly
* loaded or inserted entry, or the delta between old and new entry
* sizes exceeds some fraction of the current maximum cache size, and
* the cache doesn't have enough free space to accomodate the new/
* resize entry without performing evictions. The range of permissible
* values for the flash_threshold (0.1 to 1.0 as of this writing), and
- * for the flash_multiple (0.1 to 10.0) do not permit the facility to
+ * for the flash_multiple (0.1 to 10.0) do not permit the facility to
* be turned off by configuration. Thus, flash cache size increases
- * can be disabled only via the flash_incr_mode, and by setting the
+ * can be disabled only via the flash_incr_mode, and by setting the
* current max_cache_size equal to max_size.
*
* We have already tested the latter in check_auto_cache_resize(), so
- * we need only thest the former here. Do this by disabling flash
+ * we need only thest the former here. Do this by disabling flash
* cache size increments via the flash_incr_mode, and then creating
* situations that would trigger flash cache size increases were that
* code enabled.
@@ -24339,7 +24996,7 @@ check_auto_cache_resize_disable(void)
* size increment code was active, this would trigger an increase.
* Verify that it doesn't.
*
- * This finishes the additional tests needed for the flash cache
+ * This finishes the additional tests needed for the flash cache
* size increase code.
*/
if ( pass ) {
@@ -24390,7 +25047,7 @@ check_auto_cache_resize_disable(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_auto_cache_resize_disable() */
@@ -24411,7 +25068,7 @@ check_auto_cache_resize_disable(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_auto_cache_resize_epoch_markers(void)
{
const char * fcn_name = "check_auto_cache_resize_epoch_markers()";
@@ -24446,7 +25103,7 @@ check_auto_cache_resize_epoch_markers(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -25098,7 +25755,7 @@ check_auto_cache_resize_epoch_markers(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_auto_cache_resize_epoch_markers() */
@@ -25116,7 +25773,7 @@ check_auto_cache_resize_epoch_markers(void)
*
* Modifications:
*
- * Added code to verify that errors in the flash cache size
+ * Added code to verify that errors in the flash cache size
* increment related fields are caught as well.
*
* JRM -- 1/17/08
@@ -25124,38 +25781,66 @@ check_auto_cache_resize_epoch_markers(void)
*-------------------------------------------------------------------------
*/
-#define RESIZE_CONFIGS_ARE_EQUAL(a, b, compare_init) \
-( ( (a).version == (b).version ) && \
- ( (a).rpt_fcn == (b).rpt_fcn ) && \
- ( ( ! compare_init ) || \
- ( (a).set_initial_size == (b).set_initial_size ) ) && \
- ( ( ! compare_init ) || \
- ( (a).initial_size == (b).initial_size ) ) && \
- ( (a).min_clean_fraction == (b).min_clean_fraction ) && \
- ( (a).max_size == (b).max_size ) && \
- ( (a).min_size == (b).min_size ) && \
- ( (a).epoch_length == (b).epoch_length ) && \
- ( (a).incr_mode == (b).incr_mode ) && \
- ( (a).lower_hr_threshold == (b).lower_hr_threshold ) && \
- ( (a).increment == (b).increment ) && \
- ( (a).apply_max_increment == (b).apply_max_increment ) && \
- ( (a).max_increment == (b).max_increment ) && \
- ( (a).flash_incr_mode == (b).flash_incr_mode ) && \
- ( (a).flash_multiple == (b).flash_multiple ) && \
- ( (a).flash_threshold == (b).flash_threshold ) && \
- ( (a).decr_mode == (b).decr_mode ) && \
- ( (a).upper_hr_threshold == (b).upper_hr_threshold ) && \
- ( (a).flash_incr_mode == (b).flash_incr_mode ) && \
- ( (a).flash_multiple == (b).flash_multiple ) && \
- ( (a).flash_threshold == (b).flash_threshold ) && \
- ( (a).decrement == (b).decrement ) && \
- ( (a).apply_max_decrement == (b).apply_max_decrement ) && \
- ( (a).max_decrement == (b).max_decrement ) && \
- ( (a).epochs_before_eviction == (b).epochs_before_eviction ) && \
- ( (a).apply_empty_reserve == (b).apply_empty_reserve ) && \
- ( (a).empty_reserve == (b).empty_reserve ) )
+/* Epsilon for floating-point comparisons */
+#define FP_EPSILON 0.000001
-static void
+static hbool_t
+resize_configs_are_equal(const H5C_auto_size_ctl_t *a,
+ const H5C_auto_size_ctl_t *b,
+ hbool_t compare_init)
+{
+ if(a->version != b->version)
+ return(FALSE);
+ else if(a->rpt_fcn != b->rpt_fcn)
+ return(FALSE);
+ else if(compare_init && (a->set_initial_size != b->set_initial_size))
+ return(FALSE);
+ else if(compare_init && (a->initial_size != b->initial_size))
+ return(FALSE);
+ else if(HDfabs(a->min_clean_fraction - b->min_clean_fraction) > FP_EPSILON)
+ return(FALSE);
+ else if(a->max_size != b->max_size)
+ return(FALSE);
+ else if(a->min_size != b->min_size)
+ return(FALSE);
+ else if(a->epoch_length != b->epoch_length)
+ return(FALSE);
+ else if(a->incr_mode != b->incr_mode)
+ return(FALSE);
+ else if(HDfabs(a->lower_hr_threshold - b->lower_hr_threshold) > FP_EPSILON)
+ return(FALSE);
+ else if(HDfabs(a->increment - b->increment) > FP_EPSILON)
+ return(FALSE);
+ else if(a->apply_max_increment != b->apply_max_increment)
+ return(FALSE);
+ else if(a->max_increment != b->max_increment)
+ return(FALSE);
+ else if(a->flash_incr_mode != b->flash_incr_mode)
+ return(FALSE);
+ else if(HDfabs(a->flash_multiple - b->flash_multiple) > FP_EPSILON)
+ return(FALSE);
+ else if(HDfabs(a->flash_threshold - b->flash_threshold) > FP_EPSILON)
+ return(FALSE);
+ else if(a->decr_mode != b->decr_mode)
+ return(FALSE);
+ else if(HDfabs(a->upper_hr_threshold - b->upper_hr_threshold) > FP_EPSILON)
+ return(FALSE);
+ else if(HDfabs(a->decrement - b->decrement) > FP_EPSILON)
+ return(FALSE);
+ else if(a->apply_max_decrement != b->apply_max_decrement)
+ return(FALSE);
+ else if(a->max_decrement != b->max_decrement)
+ return(FALSE);
+ else if(a->epochs_before_eviction != b->epochs_before_eviction)
+ return(FALSE);
+ else if(a->apply_empty_reserve != b->apply_empty_reserve)
+ return(FALSE);
+ else if(HDfabs(a->empty_reserve - b->empty_reserve) > FP_EPSILON)
+ return(FALSE);
+ return(TRUE);
+}
+
+static unsigned
check_auto_cache_resize_input_errs(void)
{
const char * fcn_name = "check_auto_cache_resize_input_errs()";
@@ -25186,7 +25871,7 @@ check_auto_cache_resize_input_errs(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -25260,8 +25945,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 1.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 1.";
@@ -25333,8 +26018,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 2.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 2.";
@@ -25409,8 +26094,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 3.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 3.";
@@ -25486,8 +26171,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 4.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 4.";
@@ -25560,8 +26245,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 5.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 5.";
@@ -25636,8 +26321,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 6.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 6.";
@@ -25709,8 +26394,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 7.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 7.";
@@ -25786,8 +26471,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 8.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 8.";
@@ -25859,8 +26544,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 9.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 9.";
@@ -25932,8 +26617,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 10.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 10.";
@@ -26008,8 +26693,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 11.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 11.";
@@ -26081,8 +26766,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 12.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 12.";
@@ -26158,8 +26843,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 13.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 13.";
@@ -26232,8 +26917,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 14.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 14.";
@@ -26308,8 +26993,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 15.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 15.";
@@ -26381,8 +27066,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 16.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 16.";
@@ -26454,8 +27139,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 17.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 17.";
@@ -26531,8 +27216,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 18.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 18.";
@@ -26567,7 +27252,7 @@ check_auto_cache_resize_input_errs(void)
invalid_auto_size_ctl.apply_max_increment = TRUE;
invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024);
- invalid_auto_size_ctl.flash_incr_mode =
+ invalid_auto_size_ctl.flash_incr_mode =
(enum H5C_cache_flash_incr_mode) -1; /* INVALID */
invalid_auto_size_ctl.flash_multiple = 2.0;
invalid_auto_size_ctl.flash_threshold = 0.5;
@@ -26608,8 +27293,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 19.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 19.";
@@ -26643,7 +27328,7 @@ check_auto_cache_resize_input_errs(void)
invalid_auto_size_ctl.apply_max_increment = TRUE;
invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024);
- invalid_auto_size_ctl.flash_incr_mode =
+ invalid_auto_size_ctl.flash_incr_mode =
H5C_flash_incr__add_space;
invalid_auto_size_ctl.flash_multiple = 0.09; /* INVALID */
invalid_auto_size_ctl.flash_threshold = 0.5;
@@ -26684,8 +27369,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 20.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 20.";
@@ -26717,7 +27402,7 @@ check_auto_cache_resize_input_errs(void)
invalid_auto_size_ctl.apply_max_increment = TRUE;
invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024);
- invalid_auto_size_ctl.flash_incr_mode =
+ invalid_auto_size_ctl.flash_incr_mode =
H5C_flash_incr__add_space;
invalid_auto_size_ctl.flash_multiple = 10.01; /* INVALID */
invalid_auto_size_ctl.flash_threshold = 0.5;
@@ -26758,8 +27443,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 21.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 21.";
@@ -26793,7 +27478,7 @@ check_auto_cache_resize_input_errs(void)
invalid_auto_size_ctl.apply_max_increment = TRUE;
invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024);
- invalid_auto_size_ctl.flash_incr_mode =
+ invalid_auto_size_ctl.flash_incr_mode =
H5C_flash_incr__add_space;
invalid_auto_size_ctl.flash_multiple = 1.0;
invalid_auto_size_ctl.flash_threshold = 0.09; /* INVALID */
@@ -26834,8 +27519,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 22.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 22.";
@@ -26867,7 +27552,7 @@ check_auto_cache_resize_input_errs(void)
invalid_auto_size_ctl.apply_max_increment = TRUE;
invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024);
- invalid_auto_size_ctl.flash_incr_mode =
+ invalid_auto_size_ctl.flash_incr_mode =
H5C_flash_incr__add_space;
invalid_auto_size_ctl.flash_multiple = 1.0;
invalid_auto_size_ctl.flash_threshold = 1.001; /* INVALID */
@@ -26908,8 +27593,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 23.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 23.";
@@ -26984,8 +27669,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 24.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 24.";
@@ -27058,8 +27743,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 25.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 25.";
@@ -27134,8 +27819,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 26.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 26.";
@@ -27207,8 +27892,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 27.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 27.";
@@ -27282,8 +27967,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 28.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 28.";
@@ -27355,8 +28040,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 29.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 29.";
@@ -27430,8 +28115,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 30.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 30.";
@@ -27503,8 +28188,8 @@ check_auto_cache_resize_input_errs(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_auto_resize_config failed 31.";
- } else if ( ! RESIZE_CONFIGS_ARE_EQUAL(test_auto_size_ctl, \
- ref_auto_size_ctl, FALSE) ) {
+ } else if ( ! resize_configs_are_equal(&test_auto_size_ctl, \
+ &ref_auto_size_ctl, FALSE) ) {
pass = FALSE;
failure_mssg = "Unexpected auto resize config 31.";
@@ -27566,7 +28251,7 @@ check_auto_cache_resize_input_errs(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_auto_cache_resize_input_errs() */
@@ -27592,7 +28277,7 @@ check_auto_cache_resize_input_errs(void)
*-------------------------------------------------------------------------
*/
-static void
+static unsigned
check_auto_cache_resize_aux_fcns(void)
{
const char * fcn_name = "check_auto_cache_resize_aux_fcns()";
@@ -27632,7 +28317,7 @@ check_auto_cache_resize_aux_fcns(void)
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
- /* enum H5C_cache_flash_incr_mode */
+ /* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
@@ -27714,7 +28399,7 @@ check_auto_cache_resize_aux_fcns(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_hit_rate failed.\n";
- } else if ( hit_rate != 0.0 ) {
+ } else if ( hit_rate > FP_EPSILON ) { /* i.e. hit_rate != 0.0 */
pass = FALSE;
failure_mssg =
@@ -27748,7 +28433,7 @@ check_auto_cache_resize_aux_fcns(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_hit_rate failed.\n";
- } else if ( hit_rate != 0.0 ) {
+ } else if ( hit_rate > FP_EPSILON ) { /* i.e. hit_rate != 0.0 */
pass = FALSE;
failure_mssg =
@@ -27794,7 +28479,7 @@ check_auto_cache_resize_aux_fcns(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_hit_rate failed.\n";
- } else if ( hit_rate != 0.5 ) {
+ } else if ( HDfabs(hit_rate - 0.5) > FP_EPSILON ) { /* i.e. hit_rate != 0.5 */
pass = FALSE;
failure_mssg =
@@ -27878,7 +28563,7 @@ check_auto_cache_resize_aux_fcns(void)
pass = FALSE;
failure_mssg = "H5C_get_cache_hit_rate failed.\n";
- } else if ( hit_rate != 0.5 ) {
+ } else if ( HDfabs(hit_rate - 0.5) > FP_EPSILON ) { /* i.e. hit_rate != 0.5 */
pass = FALSE;
failure_mssg =
@@ -28148,12 +28833,5194 @@ check_auto_cache_resize_aux_fcns(void)
fcn_name, failure_mssg);
}
- return;
+ return (unsigned)!pass;
} /* check_auto_cache_resize_aux_fcns() */
/*-------------------------------------------------------------------------
+ * Function: check_metadata_blizzard_absence()
+ *
+ * Purpose: Test to verify that a 'metadata blizzard' can not occur
+ * upon insertion into the cache.
+ *
+ * A 'metadata blizzard' in this context occurs when the cache
+ * gets completely filled with all dirty entries. Upon needing
+ * to make space in the cache, the cache then has no clean
+ * entries ready to evict, and must clean every dirty entry
+ * in the cache first, due to the second chance replacement
+ * policy. (i.e. after cleaning an entry, it is bumped to the
+ * top of the LRU to make a second pass before eviction).
+ * The massive amount of sequential writes to disk while
+ * flushing the entire cache is what constitutes a 'metadata
+ * blizzard'.
+ *
+ * Return: void
+ *
+ * Programmer: Mike McGreevy
+ * <mamcgree@hdfgroup.org>
+ * 12/16/08
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static unsigned
+check_metadata_blizzard_absence(hbool_t fill_via_insertion)
+{
+ const char * fcn_name = "check_metadata_blizzard_absence";
+ int entry_type = HUGE_ENTRY_TYPE;
+ size_t entry_size = HUGE_ENTRY_SIZE; /* 16 KB */
+ H5C_t * cache_ptr = NULL;
+ hbool_t show_progress = FALSE;
+ int32_t checkpoint = 0;
+ int32_t entry_idx = 0;
+ int32_t i;
+
+ /* Expected loaded status of entries depends on how they get into
+ * the cache. Insertions = not loaded, protect/unprotect = loaded.
+ */
+ hbool_t loaded = (hbool_t)!(fill_via_insertion);
+
+ /* Set up the expected array. This is used to maintain a table of the
+ * expected status of every entry used in this test.
+ */
+ struct expected_entry_status expected[150] =
+ {
+ /* entry entry in at main flush dep flush dep child flush flush flush */
+ /* type: index: size: cache: addr: dirty: prot: pinned: loaded: clrd: flshd: dest: par type: par idx: dep ref.count: dep height: order: */
+ { HUGE_ENTRY_TYPE, 0, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 1, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 2, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 3, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 4, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 5, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 6, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 7, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 8, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 9, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 10, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 11, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 12, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 13, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 14, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 15, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 16, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 17, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 18, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 19, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 20, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 21, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 22, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 23, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 24, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 25, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 26, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 27, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 28, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 29, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 30, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 31, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 32, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 33, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 34, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 35, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 36, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 37, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 38, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 39, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 40, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 41, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 42, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 43, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 44, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 45, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 46, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 47, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 48, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 49, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 50, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 51, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 52, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 53, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 54, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 55, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 56, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 57, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 58, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 59, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 60, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 61, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 62, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 63, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 64, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 65, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 66, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 67, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 68, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 69, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 70, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 71, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 72, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 73, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 74, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 75, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 76, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 77, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 78, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 79, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 80, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 81, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 82, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 83, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 84, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 85, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 86, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 87, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 88, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 89, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 90, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 91, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 92, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 93, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 94, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 95, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 96, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 97, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 98, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 99, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 100, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 101, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 102, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 103, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 104, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 105, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 106, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 107, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 108, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 109, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 110, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 111, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 112, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 113, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 114, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 115, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 116, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 117, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 118, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 119, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 120, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 121, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 122, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 123, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 124, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 125, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 126, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 127, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 128, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 129, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 130, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 131, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 132, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 133, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 134, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 135, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 136, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 137, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 138, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 139, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 140, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 141, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 142, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 143, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 144, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 145, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 146, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 147, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 148, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { HUGE_ENTRY_TYPE, 149, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 }
+ };
+
+ pass = TRUE;
+
+ if (fill_via_insertion) {
+
+ TESTING("to ensure metadata blizzard absence when inserting");
+
+ } else {
+
+ TESTING("to ensure metadata blizzard absence on protect/unprotect");
+ }
+
+ if ( show_progress) /* 0 */
+ HDfprintf(stdout, "\n%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* Set up the cache.
+ *
+ * The max_cache_size should have room for 50 entries.
+ * The min_clean_size is half of that, or 25 entries.
+ */
+ cache_ptr = setup_cache((size_t)(50 * entry_size), /* max_cache_size */
+ (size_t)(25 * entry_size)); /* min_clean_size */
+
+ if ( cache_ptr == NULL) {
+
+ pass = FALSE;
+ failure_mssg = "bad return from cache intialization.\n";
+ }
+ }
+
+ if ( show_progress) /* 1 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ /* ========================================================================
+ * ========================================================================
+ * Phase 1:
+ *
+ * Inserting dirty entries into an empty cache, until the cache
+ * violates the min_clean_size requirement. The expected result is
+ * that none of the inserted entries during this phase will get
+ * flushed or evicted.
+ *
+ * This verifies that while maintaining min_clean_size, we don't go
+ * overboard and flush entries that we don't need to flush.
+ *
+ * ========================================================================
+ * ========================================================================
+ */
+
+ if ( pass ) {
+
+ /* Insert 26 entries (indexes 0 through 25) into the cache.
+ *
+ * Note that we are inserting 26 entries, and not 25, because the cache
+ * will only try to adhere to the min_clean_size if it's currently
+ * being violated. Thus, on insertion of the 26th entry, since the
+ * min_clean_size will not be violated, it will accept the insertion
+ * without having to make clean space.
+ */
+
+ for (entry_idx = 0; entry_idx < 26; entry_idx++) {
+
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[entry_idx].in_cache = TRUE;
+ expected[entry_idx].is_dirty = TRUE;
+ expected[entry_idx].loaded = loaded;
+
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ entry_idx, /* int tag */
+ 150, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ }
+ }
+
+ if ( show_progress) /* 2 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ /* ========================================================================
+ * ========================================================================
+ * Phase 2:
+ *
+ * Inserting entries into a cache that violates the min_clean_size,
+ * until the cache is full. The expected result is that each insertion
+ * will result in the flushing of a dirty entry in the cache.
+ *
+ * This verifies that we maintain the min_clean_size. By doing so, we
+ * prevent building the situation in which a 'metadata blizzard' would
+ * occur (i.e., the cache being completely filled with dirty entries).
+ *
+ * ========================================================================
+ * ========================================================================
+ */
+
+ if ( pass ) {
+
+ /* Insert the 27th entry (index = 26) into the cache.
+ *
+ * This should cause the cache to flush its least recently used entry
+ * before the insertion because it doesn't satisfy the min_clean_size
+ * constraint.
+ */
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* Verify the status of the entries.
+ *
+ * Expected status is that there are 27 entries in the cache, and
+ * entry number 0 has been cleaned.
+ *
+ * Changes from last entry verification:
+ * - entry w/ index 0 has now been flushed and is now clean.
+ * - entry w/ index 26 is now in the cache and dirty.
+ */
+
+ /* entry w/ index 0 has now been flushed and is now clean. */
+ expected[0].flushed = TRUE;
+ expected[0].is_dirty = FALSE;
+
+ /* entry w/ index 26 is now in the cache and dirty. */
+ expected[26].in_cache = TRUE;
+ expected[26].is_dirty = TRUE;
+ expected[26].loaded = loaded;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ 26, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+
+ if ( show_progress) /* 3 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* Insert the 28th entry (index = 27) into the cache.
+ *
+ * This should, once again, cause the cache to flush its least
+ * recently used entry before the insertion as it again does not
+ * satisfy the min_clean_size constraint.
+ */
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* Verify the status of the entries.
+ *
+ * Expected status is that there are 28 entries in the cache, and
+ * entry numbers 0 and 1 have been cleaned.
+ *
+ * Changes from last entry verification:
+ * - entry w/ index 1 has now been flushed and is now clean.
+ * - entry w/ index 27 is now in the cache and dirty.
+ */
+
+ /* entry w/ index 1 has now been flushed and is now clean. */
+ expected[1].flushed = TRUE;
+ expected[1].is_dirty = FALSE;
+
+ /* entry w/ index 27 is now in the cache and dirty. */
+ expected[27].in_cache = TRUE;
+ expected[27].is_dirty = TRUE;
+ expected[27].loaded = loaded;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ 27, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+
+ if ( show_progress) /* 4 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* Fill out the rest of the cache with entries */
+ /* Verify expected status of entries after each insertion */
+ for (entry_idx = entry_idx; entry_idx < 50; entry_idx++) {
+
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* Expected staus is that after each insertion, the entry
+ * inserted 26 insertions ago has been flushed, and the
+ * entry currently getting inserted is now in the cache and
+ * dirty.
+ */
+ expected[entry_idx - 26].flushed = TRUE;
+ expected[entry_idx - 26].is_dirty = FALSE;
+
+ expected[entry_idx].in_cache = TRUE;
+ expected[entry_idx].is_dirty = TRUE;
+ expected[entry_idx].loaded = loaded;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ entry_idx, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+
+ /* Verify that the cache is now full */
+ if ( cache_ptr->cache_full != TRUE ) {
+
+ pass = FALSE;
+ failure_mssg = "cache not completely filled.\n";
+ }
+ }
+
+ if ( show_progress) /* 5 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ /* ========================================================================
+ * ========================================================================
+ * Phase 3:
+ *
+ * Inserting entries into a cache that is completely full. Insertions
+ * of new entries will force evictions of old entries, but since the
+ * min_clean_size has been maintained, doing so will not result in
+ * the entire cache getting flushed in order to evict a single entry,
+ * as a clean entry will be available to flush reasonably close to
+ * the bottom of the LRU.
+ *
+ * This verifies that with a maintained min_clean_size, a metadata
+ * blizzard does not occur on insertion.
+ *
+ * ========================================================================
+ * ========================================================================
+ */
+
+ if ( pass ) {
+
+ /* Insert the 51st entry (index = 50) into the cache.
+ *
+ * The cache is full prior to the insertion, so it will
+ * have to evict in order to make room for the new entry.
+ */
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* Verify the status of the entries.
+ *
+ * Changes from last entry verification:
+ * - entry w/ index 0 has been evicted.
+ * - entries w/ indices 24,25 have now been flushed and are clean.
+ * - entry w/ index 50 is now in the cache and dirty.
+ */
+
+ /* entry w/ index 0 has been evicted. */
+ expected[0].in_cache = FALSE;
+ expected[0].destroyed = TRUE;
+
+ /* entries w/ indices 24,25 have now been flushed and are clean. */
+ expected[24].flushed = TRUE;
+ expected[24].is_dirty = FALSE;
+ expected[25].flushed = TRUE;
+ expected[25].is_dirty = FALSE;
+
+ /* entry w/ index 50 is now in the cache and dirty */
+ expected[50].in_cache = TRUE;
+ expected[50].is_dirty = TRUE;
+ expected[50].loaded = loaded;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ 50, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+
+ if ( show_progress) /* 6 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+
+ if ( pass ) {
+
+ /* Insert 49 more entries (indices 51-99) into the cache.
+ *
+ * The cache will be flushing an entry on each insertion, and
+ * evicting an entry on each insertion.
+ *
+ * After each insertion, verify the expected status of the
+ * entries in the cache.
+ */
+ for (entry_idx = entry_idx; entry_idx < 100; entry_idx++) {
+
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* This past inserted entry is now in the cache and dirty */
+ expected[entry_idx].in_cache = TRUE;
+ expected[entry_idx].is_dirty = TRUE;
+ expected[entry_idx].loaded = loaded;
+
+ /* The entry inserted 50 insertions ago has been evicted */
+ expected[entry_idx - 50].in_cache = FALSE;
+ expected[entry_idx - 50].destroyed = TRUE;
+
+ /* If the newly inserted entry is among the first 24
+ * insertions in this loop, then the insertion will
+ * have resulted in a flush of the entry inserted
+ * 25 insertions ago. */
+ if (entry_idx < 75) {
+
+ expected[entry_idx - 25].flushed = TRUE;
+ expected[entry_idx - 25].is_dirty = FALSE;
+ }
+ /* If the newly inserted entry is among the last
+ * 25 insertions in this loop, then the insertion will
+ * have resulted in a flush of the entry inserted 26
+ * insertions ago. This switch is because there was two
+ * consecutive clean entries in the cache (due to 51/49
+ * dirty/clean ratio when full), so instead of
+ * flush-then-evict, it switches to evict-then-flush. */
+ else {
+
+ expected[entry_idx - 26].flushed = TRUE;
+ expected[entry_idx - 26].is_dirty = FALSE;
+ }
+
+ /* Verify this expected status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ entry_idx, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+ }
+
+ if ( show_progress) /* 7 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ /* ========================================================================
+ * ========================================================================
+ * Phase 4:
+ *
+ * Flushing the entire cache, and then inserting entries into a cache
+ * that is completely full, but all clean.
+ *
+ * Phases 1 and 2 are then repeated. Rather than inserting dirty entries
+ * into an empty cache, we're inserting into a full cache that's all
+ * clean, thus an eviction occurs before each insertion.
+ *
+ * When the cache finally hits the point of violating the
+ * min_clean_size, the bottom half of the LRU will be filled with
+ * clean entries and the top half will be filled with recently inserted
+ * dirty entries. We'll then verify that an insertion will only evict
+ * one entry and flush one entry, and no more.
+ *
+ * ========================================================================
+ * ========================================================================
+ */
+
+ if ( pass ) {
+
+ /* Flush the cache.
+ *
+ * We're doing this so we can repeat the above insertions, but
+ * starting from a cache filled with clean entries as opposed
+ * to an empty cache.
+ */
+
+ flush_cache(cache_ptr, /* H5C_t * cache_ptr */
+ FALSE, /* hbool_t destory_entries */
+ FALSE, /* hbool_t dump_stats */
+ FALSE); /* hbool_t dump_detailed_stats */
+
+ /* Verify that the cache is clean */
+ verify_clean();
+
+ /* Verify the status of the entries.
+ *
+ * Changes from last entry verification:
+ * - entries w/ indices 74-99 have been flushed.
+ */
+
+ /* entries w/ indices 74-99 have been flushed. */
+ for (i = 74; i < 100; i++) {
+
+ expected[i].flushed = TRUE;
+ expected[i].is_dirty = FALSE;
+ }
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ 0, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+
+ if ( show_progress) /* 8 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* Insert 26 entries (indexes 100 through 125) into the cache.
+ *
+ * The cache will evict 26 entries since it's currently full with
+ * all clean entries. None of the entries we're inserting now
+ * will get cleaned, however.
+ */
+
+ for (entry_idx = 100; entry_idx < 126; entry_idx++) {
+
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* This past inserted entry is now in the cache and dirty */
+ expected[entry_idx].in_cache = TRUE;
+ expected[entry_idx].is_dirty = TRUE;
+ expected[entry_idx].loaded = loaded;
+
+ /* The entry with ID minus 50 will have been evicted */
+ expected[entry_idx - 50].in_cache = FALSE;
+ expected[entry_idx - 50].destroyed = TRUE;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ entry_idx, /* int tag */
+ 150, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ }
+ }
+
+ if ( show_progress) /* 9 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* Insert the 127th entry (index = 126) into the cache. */
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx++, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* Verify the status of the entries.
+ *
+ * Changes from last entry verification:
+ * - entry w/ index 76 is evicted.
+ * - entry w/ index 100 is cleaned.
+ * - entry w/ index 126 is now in the cache and dirty.
+ */
+
+ /* entry w/ index 76 has been evicted. */
+ expected[76].in_cache = FALSE;
+ expected[76].destroyed = TRUE;
+
+ /* entry w/ index 100 has now been flushed and is now clean. */
+ expected[100].flushed = TRUE;
+ expected[100].is_dirty = FALSE;
+
+ /* entry w/ index 26 is now in the cache and dirty. */
+ expected[126].in_cache = TRUE;
+ expected[126].is_dirty = TRUE;
+ expected[126].loaded = loaded;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ 126, /* int tag */
+ 150, /* int num_entries */
+ expected); /* expected */
+ }
+
+ if ( show_progress) /* 10 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* Insert entries w/ indices 127 through 149 into the cache */
+ for (entry_idx = 127; entry_idx < 150; entry_idx++) {
+
+ if (fill_via_insertion) {
+ insert_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* hbool_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+
+ } else {
+ protect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx); /* int32-t idx */
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ entry_idx, /* int32_t idx */
+ TRUE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ }
+
+ /* This past inserted entry is now in the cache and dirty */
+ expected[entry_idx].in_cache = TRUE;
+ expected[entry_idx].is_dirty = TRUE;
+ expected[entry_idx].loaded = loaded;
+
+ /* The entry with ID minus 50 will have been evicted */
+ expected[entry_idx - 50].in_cache = FALSE;
+ expected[entry_idx - 50].destroyed = TRUE;
+
+ /* The entry with ID minus 26 will now be clean */
+ expected[entry_idx - 26].flushed = TRUE;
+ expected[entry_idx - 26].is_dirty = FALSE;
+
+ /* verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ entry_idx, /* int tag */
+ 150, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ }
+
+ }
+
+ if ( show_progress) /* 11 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) {
+
+ /* We're done with testing. We can take down the cache. */
+ takedown_cache(cache_ptr, FALSE, FALSE);
+ reset_entries();
+ }
+
+ if ( show_progress) /* 12 */
+ HDfprintf(stdout, "%s: check point %d -- pass %d\n",
+ fcn_name, checkpoint++, pass);
+
+ if ( pass ) { PASSED(); } else { H5_FAILED(); }
+
+ return (unsigned)!pass;
+
+} /* check_metadata_blizzard_absence() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_flush_deps()
+ *
+ * Purpose: Exercise the flush dependency routines.
+ *
+ * Return: 0 on success, non-zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * 3/12/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static unsigned
+check_flush_deps(void)
+{
+ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */
+ test_entry_t *base_addr; /* Base address of entries for test */
+ int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */
+ size_t entry_size = PICO_ENTRY_SIZE; /* 1 byte */
+ unsigned u; /* Local index variable */
+ struct expected_entry_status expected[5] =
+ {
+ /* entry entry in at main flush dep flush dep child flush flush flush */
+ /* type: index: size: cache: addr: dirty: prot: pinned: loaded: clrd: flshd: dest: par type: par idx: dep ref.count: dep height: order: */
+ { PICO_ENTRY_TYPE, 0, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 1, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 2, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 3, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 }
+ };
+
+ TESTING("flush dependencies");
+
+ pass = TRUE;
+
+ /* allocate a cache, build up flush dependency hierarchy and tear it down.
+ * Verify that all performs as expected.
+ */
+
+ reset_entries();
+ cache_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024));
+ base_addr = entries[entry_type];
+
+ if ( !pass ) CACHE_ERROR("setup_cache failed")
+
+ /* Insert entries to work with into the cache */
+ for(u = 0; u < 5; u++) {
+ insert_entry(cache_ptr, entry_type, (int32_t)u, TRUE, H5C__NO_FLAGS_SET);
+ if ( !pass ) CACHE_ERROR("insert_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = TRUE;
+ expected[u].is_dirty = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+
+/* Test Case #1 - Single flush dependency relationship */
+
+ /* Create flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ hbool_t in_cache, is_flush_dep_parent, is_flush_dep_child;
+ test_entry_t * entry_ptr;
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ /* Check the parent's entry status */
+ entry_ptr = &(base_addr[1]);
+ if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache,
+ NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0)
+ CACHE_ERROR("H5C_get_entry_status() failed")
+ if(!in_cache || is_flush_dep_parent || is_flush_dep_child)
+ CACHE_ERROR("invalid entry status")
+
+ /* Check the child's entry status */
+ entry_ptr = &(base_addr[0]);
+ if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache,
+ NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0)
+ CACHE_ERROR("H5C_get_entry_status() failed")
+ if(!in_cache || is_flush_dep_parent || is_flush_dep_child)
+ CACHE_ERROR("invalid entry status")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Check the parent's entry status */
+ entry_ptr = &(base_addr[1]);
+ if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache,
+ NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0)
+ CACHE_ERROR("H5C_get_entry_status() failed")
+ if(!in_cache || !is_flush_dep_parent || is_flush_dep_child)
+ CACHE_ERROR("invalid entry status")
+
+ /* Check the child's entry status */
+ entry_ptr = &(base_addr[0]);
+ if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache,
+ NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0)
+ CACHE_ERROR("H5C_get_entry_status() failed")
+ if(!in_cache || is_flush_dep_parent || !is_flush_dep_child)
+ CACHE_ERROR("invalid entry status")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #2 - Multiple children for one parent flush dependency relationship */
+
+ /* Create flush dependency between entries 0, 1 (children) & 2 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 2;
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[0] = 2;
+ expected[2].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries 0, 1 (children) & 2 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #3a1 - Single chain of flush dependencies, 4 entries tall
+ * created from the "bottom up" and destroyed from the "top down"
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 3;
+ expected[3].is_protected = TRUE;
+ expected[3].is_pinned = TRUE;
+ expected[3].child_flush_dep_height_rc[2] = 1;
+ expected[3].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, from the "top down" */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+ expected[3].is_protected = FALSE;
+ expected[3].is_pinned = FALSE;
+ expected[3].child_flush_dep_height_rc[2] = 0;
+ expected[3].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #3a2 - Single chain of flush dependencies, 4 entries tall
+ * created from the "bottom up" and destroyed from the "top down"
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 3;
+ expected[3].is_protected = TRUE;
+ expected[3].is_pinned = TRUE;
+ expected[3].child_flush_dep_height_rc[2] = 1;
+ expected[3].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, from the "bottom up" */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+ expected[2].child_flush_dep_height_rc[0] = 1;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 1;
+ expected[3].child_flush_dep_height_rc[1] = 1;
+ expected[3].child_flush_dep_height_rc[2] = 0;
+ expected[3].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].flush_dep_height = 0;
+ expected[3].child_flush_dep_height_rc[0] = 1;
+ expected[3].child_flush_dep_height_rc[1] = 0;
+ expected[3].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+ expected[3].is_protected = FALSE;
+ expected[3].is_pinned = FALSE;
+ expected[3].child_flush_dep_height_rc[0] = 0;
+ expected[3].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #3b1 - Single chain of flush dependencies, 4 entries tall
+ * created from the "top down" and destroyed from the "top down"
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 3;
+ expected[3].is_protected = TRUE;
+ expected[3].is_pinned = TRUE;
+ expected[3].child_flush_dep_height_rc[0] = 1;
+ expected[3].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[0] = 1;
+ expected[2].flush_dep_height = 1;
+ expected[3].child_flush_dep_height_rc[0] = 0;
+ expected[3].child_flush_dep_height_rc[1] = 1;
+ expected[3].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+ expected[3].child_flush_dep_height_rc[1] = 0;
+ expected[3].child_flush_dep_height_rc[2] = 1;
+ expected[3].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, from the "top down" */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+ expected[3].is_protected = FALSE;
+ expected[3].is_pinned = FALSE;
+ expected[3].child_flush_dep_height_rc[2] = 0;
+ expected[3].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #3b2 - Single chain of flush dependencies, 4 entries tall
+ * created from the "top down" and destroyed from the "bottom up"
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 3;
+ expected[3].is_protected = TRUE;
+ expected[3].is_pinned = TRUE;
+ expected[3].child_flush_dep_height_rc[0] = 1;
+ expected[3].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[0] = 1;
+ expected[2].flush_dep_height = 1;
+ expected[3].child_flush_dep_height_rc[0] = 0;
+ expected[3].child_flush_dep_height_rc[1] = 1;
+ expected[3].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+ expected[3].child_flush_dep_height_rc[1] = 0;
+ expected[3].child_flush_dep_height_rc[2] = 1;
+ expected[3].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, from the "bottom up" */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+ expected[2].child_flush_dep_height_rc[0] = 1;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 1;
+ expected[3].child_flush_dep_height_rc[1] = 1;
+ expected[3].child_flush_dep_height_rc[2] = 0;
+ expected[3].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].flush_dep_height = 0;
+ expected[3].child_flush_dep_height_rc[0] = 1;
+ expected[3].child_flush_dep_height_rc[1] = 0;
+ expected[3].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+ expected[3].is_protected = FALSE;
+ expected[3].is_pinned = FALSE;
+ expected[3].child_flush_dep_height_rc[0] = 0;
+ expected[3].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #4 - Multiple children for a single parent */
+
+ /* Create flush dependency between entries (child) 0,1,2,3->4 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ for(u = 0; u < 4; u++) {
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[u].flush_dep_par_type = entry_type;
+ expected[u].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = u + 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+ }
+
+ /* Destroy flush dependency between entries */
+ {
+ for(u = 0; u < 4; u++) {
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[u].flush_dep_par_type = -1;
+ expected[u].flush_dep_par_idx = -1;
+ expected[4].child_flush_dep_height_rc[0] = 3 - u;
+
+ /* Check for destroying flush dependency on last entry */
+ if(3 == u) {
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].is_protected = FALSE;
+ expected[4].is_pinned = FALSE;
+ expected[4].flush_dep_height = 0;
+ } /* end if */
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+ }
+
+/* Test Case #5a - Join two flush dependency chains together, creating a single
+ * un-forked dependency chain
+ */
+
+ /* Create flush dependency between entries (child) 0->1 and 3->4 (parent)
+ * then add entry 4 as a child of 0
+ */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[4].flush_dep_par_type = entry_type;
+ expected[4].flush_dep_par_idx = 0;
+ expected[0].is_protected = TRUE;
+ expected[0].is_pinned = TRUE;
+ expected[0].child_flush_dep_height_rc[1] = 1;
+ expected[0].flush_dep_height = 2;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].child_flush_dep_height_rc[2] = 1;
+ expected[1].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ }
+
+ /* Destroy flush dependency between entries, detaching 3->4 from 0 first */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].flush_dep_par_type = -1;
+ expected[4].flush_dep_par_idx = -1;
+ expected[0].is_protected = FALSE;
+ expected[0].is_pinned = FALSE;
+ expected[0].child_flush_dep_height_rc[1] = 0;
+ expected[0].flush_dep_height = 0;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].child_flush_dep_height_rc[2] = 0;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+ expected[4].is_protected = FALSE;
+ expected[4].is_pinned = FALSE;
+ expected[4].child_flush_dep_height_rc[0] = 0;
+ expected[4].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #5b - Join two flush dependency chains together, creating a
+ * forked dependency chain
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent)
+ * then add entry 4 as a child of 1
+ */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[4].flush_dep_par_type = entry_type;
+ expected[4].flush_dep_par_idx = 1;
+ expected[1].child_flush_dep_height_rc[1] = 1;
+ expected[1].flush_dep_height = 2;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].child_flush_dep_height_rc[2] = 1;
+ expected[2].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ }
+
+ /* Destroy flush dependency between entries, detaching 3->4 from 1 first */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].flush_dep_par_type = -1;
+ expected[4].flush_dep_par_idx = -1;
+ expected[1].child_flush_dep_height_rc[1] = 0;
+ expected[1].flush_dep_height = 1;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].child_flush_dep_height_rc[2] = 0;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+ expected[4].is_protected = FALSE;
+ expected[4].is_pinned = FALSE;
+ expected[4].child_flush_dep_height_rc[0] = 0;
+ expected[4].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #5c - Join two flush dependency chains together, creating a
+ * forked dependency chain
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent)
+ * then add entry 4 as a child of 2
+ */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[4].flush_dep_par_type = entry_type;
+ expected[4].flush_dep_par_idx = 2;
+ expected[2].child_flush_dep_height_rc[1] = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ }
+
+ /* Destroy flush dependency between entries, detaching 3->4 from 2 first */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].flush_dep_par_type = -1;
+ expected[4].flush_dep_par_idx = -1;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+ expected[4].is_protected = FALSE;
+ expected[4].is_pinned = FALSE;
+ expected[4].child_flush_dep_height_rc[0] = 0;
+ expected[4].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_protected = FALSE;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #6a - Make certain that flush dependency relationship with parent
+ * already pinned works (unpin ater destroying flush dependency)
+ */
+
+ /* Create flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ pin_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("pin_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Unpin entry & destroy flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unpin_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("unpin_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #6b - Make certain that flush dependency relationship with parent
+ * already pinned works (unpin before destroying flush dependency)
+ */
+
+ /* Create flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ pin_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("pin_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Unpin entry & destroy flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ unpin_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("unpin_entry failed")
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_protected = FALSE;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+
+done:
+ if(cache_ptr)
+ takedown_cache(cache_ptr, FALSE, FALSE);
+
+ if ( pass )
+ PASSED()
+ else {
+ H5_FAILED();
+ HDfprintf(stdout, "%s.\n", failure_mssg);
+ } /* end else */
+
+ return (unsigned)!pass;
+} /* check_flush_deps() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_flush_deps_err()
+ *
+ * Purpose: Check the flush dependency routines for error conditions.
+ *
+ * Return: 0 on success, non-zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * 3/16/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static unsigned
+check_flush_deps_err(void)
+{
+ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */
+ int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */
+ unsigned test_count; /* Test iteration variable */
+
+ TESTING("flush dependency errors");
+
+ pass = TRUE;
+
+ /* Loop over test cases, check for various errors in configuring flush
+ * dependencies. Verify that all performs as expected.
+ */
+ for(test_count = 0; test_count < 9; test_count++) {
+ unsigned u; /* Local index variable */
+ herr_t result; /* Generic return value */
+
+ /* Allocate a cache */
+ reset_entries();
+ cache_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024));
+ if ( !pass ) CACHE_ERROR("setup_cache failed")
+
+ /* Insert entries to work with into the cache */
+ for(u = 0; u < 10; u++) {
+ insert_entry(cache_ptr, entry_type, (int32_t)u, TRUE, H5C__NO_FLAGS_SET);
+ if ( !pass ) CACHE_ERROR("insert_entry failed")
+ } /* end for */
+
+ /* Various test cases */
+ switch(test_count) {
+ /* Verify that parent entry in flush dependency must be protected */
+ case 0:
+ result = H5C_create_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[1]));
+ if( result != FAIL ) CACHE_ERROR("Creating flush dependency with unprotected entry succeeded")
+ break;
+
+ /* Verify that entry can't have flush dependency on itself */
+ case 1:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ result = H5C_create_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[0]));
+ if( result != FAIL ) CACHE_ERROR("Creating flush dependency with parent == child")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+ /* Verify that a child entry can only have one flush dependency parent */
+ case 2:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ result = H5C_create_flush_dependency(cache_ptr, &((entries[entry_type])[1]), &((entries[entry_type])[2]));
+ if( result != FAIL ) CACHE_ERROR("Creating second flush dependency for child")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+ /* Verify that a flush dependency chain can't be higher than (H5C__NUM_FLUSH_DEP_HEIGHTS - 1) */
+ case 3:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 5);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 5);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 5, entry_type, 6);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 6);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ result = H5C_create_flush_dependency(cache_ptr, &((entries[entry_type])[6]), &((entries[entry_type])[7]));
+ if( result != FAIL ) CACHE_ERROR("Creating flush dependency that's too tall")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 6, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ protect_entry(cache_ptr, entry_type, 7);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ result = H5C_create_flush_dependency(cache_ptr, &((entries[entry_type])[7]), &((entries[entry_type])[0]));
+ if( result != FAIL ) CACHE_ERROR("Creating flush dependency that's too tall")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 7, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 5);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 5, entry_type, 6);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 5, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+ /* Verify that parent entry must be protected */
+ case 4:
+ result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[1]));
+ if( result != FAIL ) CACHE_ERROR("Destroying [non-existant] dependency when parent isn't protected")
+ break;
+
+ /* Verify that parent entry has flush dependency */
+ case 5:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[1]));
+ if( result != FAIL ) CACHE_ERROR("Destroying dependency when parent isn't in relationship")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+ /* Verify that child entry is in flush dependency relationship */
+ case 6:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[2]));
+ if( result != FAIL ) CACHE_ERROR("Destroying dependency when child isn't in relationship")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+ /* Verify that parent has child entries at this height */
+ case 7:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[4]));
+ if( result != FAIL ) CACHE_ERROR("Destroying dependency when parent has no children at child's height")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+
+ /* Verify that child entry is child of parent */
+ case 8:
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[3]));
+ if( result != FAIL ) CACHE_ERROR("Destroying dependency when child isn't in relationship")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+ break;
+
+ default:
+ CACHE_ERROR("Unknown test case!")
+ } /* end switch */
+
+ takedown_cache(cache_ptr, FALSE, FALSE);
+ if ( !pass ) CACHE_ERROR("takedown_cache failed")
+ cache_ptr = NULL;
+ } /* end for */
+
+
+done:
+ if(cache_ptr)
+ takedown_cache(cache_ptr, FALSE, FALSE);
+
+ if ( pass )
+ PASSED()
+ else {
+ H5_FAILED();
+ HDfprintf(stdout, "%s.\n", failure_mssg);
+ } /* end else */
+
+ return (unsigned)!pass;
+} /* check_flush_deps_err() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_flush_deps_order()
+ *
+ * Purpose: Verify that the order that entries with flush dependencies
+ * is correct
+ *
+ * Return: 0 on success, non-zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * 3/17/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static unsigned
+check_flush_deps_order(void)
+{
+ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */
+ int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */
+ size_t entry_size = PICO_ENTRY_SIZE; /* 1 byte */
+ unsigned u; /* Local index variable */
+ struct expected_entry_status expected[5] =
+ {
+ /* entry entry in at main flush dep flush dep child flush flush flush */
+ /* type: index: size: cache: addr: dirty: prot: pinned: loaded: clrd: flshd: dest: par type: par idx: dep ref.count: dep height: order: */
+ { PICO_ENTRY_TYPE, 0, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 1, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 2, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 3, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 }
+ };
+ unsigned flush_order; /* Index for tracking flush order */
+
+ TESTING("flush dependencies flush order");
+
+ pass = TRUE;
+
+ /* allocate a cache, build up flush dependency hierarchy and tear it down.
+ * Verify that all performs as expected.
+ */
+
+ reset_entries();
+ cache_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024));
+
+ if ( !pass ) CACHE_ERROR("setup_cache failed")
+
+ /* Insert entries to work with into the cache */
+ for(u = 0; u < 5; u++) {
+ insert_entry(cache_ptr, entry_type, (int32_t)u, TRUE, H5C__NO_FLAGS_SET);
+ if ( !pass ) CACHE_ERROR("insert_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = TRUE;
+ expected[u].is_dirty = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+
+/* Test Case #1a - Single flush dependency relationship, increasing addr order */
+
+ /* Create flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 0;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 1;
+ expected[1].is_protected = FALSE;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[4].is_dirty = FALSE;
+ expected[4].flushed = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #1b - Single flush dependency relationship, decreasing addr order */
+
+ /* Create flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].is_protected = TRUE;
+ expected[0].is_pinned = TRUE;
+ expected[0].child_flush_dep_height_rc[0] = 1;
+ expected[0].flush_dep_height = 1;
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0 & 1 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, TRUE);
+ dirty_entry(cache_ptr, entry_type, 1, FALSE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 1;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries 0 (child) & 1 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_pinned = FALSE;
+ expected[0].child_flush_dep_height_rc[0] = 0;
+ expected[0].flush_dep_height = 0;
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #2a - Multiple children for one parent flush dependency relationship
+ * increasing addr order
+ */
+
+ /* Create flush dependency between entries 0, 1 (children) & 2 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 2;
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[0] = 2;
+ expected[2].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0, 1 & 2 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, FALSE);
+ dirty_entry(cache_ptr, entry_type, 1, FALSE);
+ dirty_entry(cache_ptr, entry_type, 2, TRUE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 0;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 1;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 2;
+ expected[2].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries 0, 1 (children) & 2 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #2b - Multiple children for one parent flush dependency relationship
+ * decreasing addr order
+ */
+
+ /* Create flush dependency between entries 1, 2 (children) & 0 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].is_protected = TRUE;
+ expected[0].is_pinned = TRUE;
+ expected[0].child_flush_dep_height_rc[0] = 2;
+ expected[0].flush_dep_height = 1;
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 0;
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0, 1 & 2 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, TRUE);
+ dirty_entry(cache_ptr, entry_type, 1, FALSE);
+ dirty_entry(cache_ptr, entry_type, 2, FALSE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 2;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 0;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries 1, 2 (children) & 0 (parent) */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_pinned = FALSE;
+ expected[0].child_flush_dep_height_rc[0] = 0;
+ expected[0].flush_dep_height = 0;
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #3a - Single chain of flush dependencies, 4 entries tall,
+ * increasing addr order
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 3;
+ expected[3].is_protected = TRUE;
+ expected[3].is_pinned = TRUE;
+ expected[3].child_flush_dep_height_rc[2] = 1;
+ expected[3].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 3, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0-3 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, FALSE);
+ dirty_entry(cache_ptr, entry_type, 1, TRUE);
+ dirty_entry(cache_ptr, entry_type, 2, TRUE);
+ dirty_entry(cache_ptr, entry_type, 3, TRUE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 0;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 1;
+ expected[1].is_protected = FALSE;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 2;
+ expected[2].is_protected = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 3;
+ expected[3].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, from the "top down" */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 3, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+ expected[3].is_pinned = FALSE;
+ expected[3].child_flush_dep_height_rc[2] = 0;
+ expected[3].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #3b - Single chain of flush dependencies, 4 entries tall
+ * decreasing addr order
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].is_protected = TRUE;
+ expected[0].is_pinned = TRUE;
+ expected[0].child_flush_dep_height_rc[0] = 1;
+ expected[0].flush_dep_height = 1;
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].child_flush_dep_height_rc[0] = 0;
+ expected[0].child_flush_dep_height_rc[1] = 1;
+ expected[0].flush_dep_height = 2;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+ expected[2].flush_dep_par_type = entry_type;
+ expected[2].flush_dep_par_idx = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].child_flush_dep_height_rc[1] = 0;
+ expected[0].child_flush_dep_height_rc[2] = 1;
+ expected[0].flush_dep_height = 3;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].child_flush_dep_height_rc[1] = 1;
+ expected[1].flush_dep_height = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[0] = 1;
+ expected[2].flush_dep_height = 1;
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0-3 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, TRUE);
+ dirty_entry(cache_ptr, entry_type, 1, TRUE);
+ dirty_entry(cache_ptr, entry_type, 2, TRUE);
+ dirty_entry(cache_ptr, entry_type, 3, FALSE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 3;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 2;
+ expected[1].is_protected = FALSE;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 1;
+ expected[2].is_protected = FALSE;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, from the "bottom up" */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].child_flush_dep_height_rc[2] = 0;
+ expected[0].child_flush_dep_height_rc[1] = 1;
+ expected[0].flush_dep_height = 2;
+ expected[1].child_flush_dep_height_rc[1] = 0;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[0] = 0;
+ expected[2].flush_dep_height = 0;
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].child_flush_dep_height_rc[1] = 0;
+ expected[0].child_flush_dep_height_rc[0] = 1;
+ expected[0].flush_dep_height = 1;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+ expected[2].flush_dep_par_type = -1;
+ expected[2].flush_dep_par_idx = -1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].is_pinned = FALSE;
+ expected[0].child_flush_dep_height_rc[0] = 0;
+ expected[0].flush_dep_height = 0;
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #4a - Multiple children for a single parent, increasing addr order */
+
+ /* Create flush dependency between entries (child) 0,1,2,3->4 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ for(u = 0; u < 4; u++) {
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[u].flush_dep_par_type = entry_type;
+ expected[u].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = u + 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 4, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0-4 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, FALSE);
+ dirty_entry(cache_ptr, entry_type, 1, FALSE);
+ dirty_entry(cache_ptr, entry_type, 2, FALSE);
+ dirty_entry(cache_ptr, entry_type, 3, FALSE);
+ dirty_entry(cache_ptr, entry_type, 4, TRUE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+ expected[4].flushed = FALSE;
+ expected[4].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 0;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 1;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 2;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 3;
+ expected[4].is_dirty = FALSE;
+ expected[4].flushed = TRUE;
+ expected[4].flush_order = 4;
+ expected[4].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries */
+ {
+ for(u = 0; u < 4; u++) {
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[u].flush_dep_par_type = -1;
+ expected[u].flush_dep_par_idx = -1;
+ expected[4].child_flush_dep_height_rc[0] = 3 - u;
+
+ /* Check for destroying flush dependency on last entry */
+ if(3 == u) {
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].is_pinned = FALSE;
+ expected[4].flush_dep_height = 0;
+ } /* end if */
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+ }
+
+/* Test Case #4b - Multiple children for a single parent, decreasing addr order */
+
+ /* Create flush dependency between entries (child) 0,1,2,3->4 (parent) */
+ {
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ for(u = 1; u < 5; u++) {
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[u].flush_dep_par_type = entry_type;
+ expected[u].flush_dep_par_idx = 0;
+ expected[0].is_protected = TRUE;
+ expected[0].is_pinned = TRUE;
+ expected[0].child_flush_dep_height_rc[0] = u;
+ expected[0].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 4, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0-4 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, TRUE);
+ dirty_entry(cache_ptr, entry_type, 1, FALSE);
+ dirty_entry(cache_ptr, entry_type, 2, FALSE);
+ dirty_entry(cache_ptr, entry_type, 3, FALSE);
+ dirty_entry(cache_ptr, entry_type, 4, FALSE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+ expected[4].flushed = FALSE;
+ expected[4].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 4;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 0;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 1;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 2;
+ expected[4].is_dirty = FALSE;
+ expected[4].flushed = TRUE;
+ expected[4].flush_order = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries */
+ {
+ for(u = 1; u < 5; u++) {
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[u].flush_dep_par_type = -1;
+ expected[u].flush_dep_par_idx = -1;
+ expected[0].child_flush_dep_height_rc[0] = 4 - u;
+
+ /* Check for destroying flush dependency on last entry */
+ if(4 == u) {
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].is_pinned = FALSE;
+ expected[0].flush_dep_height = 0;
+ } /* end if */
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ } /* end for */
+ }
+
+/* Test Case #5a - Join two flush dependency chains together, creating a single
+ * un-forked dependency chain
+ */
+
+ /* Create flush dependency between entries (child) 0->1 and 3->4 (parent)
+ * then add entry 4 as a child of 0
+ */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[4].flush_dep_par_type = entry_type;
+ expected[4].flush_dep_par_idx = 0;
+ expected[0].is_protected = TRUE;
+ expected[0].is_pinned = TRUE;
+ expected[0].child_flush_dep_height_rc[1] = 1;
+ expected[0].flush_dep_height = 2;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].child_flush_dep_height_rc[2] = 1;
+ expected[1].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 4, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 0, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0 & 1, 3 & 4 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, TRUE);
+ dirty_entry(cache_ptr, entry_type, 1, TRUE);
+ dirty_entry(cache_ptr, entry_type, 3, FALSE);
+ dirty_entry(cache_ptr, entry_type, 4, TRUE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+ expected[4].flushed = FALSE;
+ expected[4].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 2;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 3;
+ expected[1].is_protected = FALSE;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 0;
+ expected[4].is_dirty = FALSE;
+ expected[4].flushed = TRUE;
+ expected[4].flush_order = 1;
+ expected[4].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, detaching 3->4 from 0 first */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 0, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].flush_dep_par_type = -1;
+ expected[4].flush_dep_par_idx = -1;
+ expected[0].is_pinned = FALSE;
+ expected[0].child_flush_dep_height_rc[1] = 0;
+ expected[0].flush_dep_height = 0;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].child_flush_dep_height_rc[2] = 0;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+ expected[4].is_pinned = FALSE;
+ expected[4].child_flush_dep_height_rc[0] = 0;
+ expected[4].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #5b - Join two flush dependency chains together, creating a
+ * forked dependency chain
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent)
+ * then add entry 4 as a child of 1
+ */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[4].flush_dep_par_type = entry_type;
+ expected[4].flush_dep_par_idx = 1;
+ expected[1].child_flush_dep_height_rc[1] = 1;
+ expected[1].flush_dep_height = 2;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].child_flush_dep_height_rc[2] = 1;
+ expected[2].flush_dep_height = 3;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 4, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0-4 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, FALSE);
+ dirty_entry(cache_ptr, entry_type, 1, TRUE);
+ dirty_entry(cache_ptr, entry_type, 2, TRUE);
+ dirty_entry(cache_ptr, entry_type, 3, FALSE);
+ dirty_entry(cache_ptr, entry_type, 4, TRUE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+ expected[4].flushed = FALSE;
+ expected[4].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 0;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 3;
+ expected[1].is_protected = FALSE;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 4;
+ expected[2].is_protected = FALSE;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 1;
+ expected[4].is_dirty = FALSE;
+ expected[4].flushed = TRUE;
+ expected[4].flush_order = 2;
+ expected[4].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, detaching 3->4 from 1 first */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].flush_dep_par_type = -1;
+ expected[4].flush_dep_par_idx = -1;
+ expected[1].child_flush_dep_height_rc[1] = 0;
+ expected[1].flush_dep_height = 1;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].child_flush_dep_height_rc[2] = 0;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+ expected[4].is_pinned = FALSE;
+ expected[4].child_flush_dep_height_rc[0] = 0;
+ expected[4].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+/* Test Case #5c - Join two flush dependency chains together, creating a
+ * forked dependency chain
+ */
+
+ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent)
+ * then add entry 4 as a child of 2
+ */
+ {
+ protect_entry(cache_ptr, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[0].flush_dep_par_type = entry_type;
+ expected[0].flush_dep_par_idx = 1;
+ expected[1].is_protected = TRUE;
+ expected[1].is_pinned = TRUE;
+ expected[1].child_flush_dep_height_rc[0] = 1;
+ expected[1].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 2);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[1].flush_dep_par_type = entry_type;
+ expected[1].flush_dep_par_idx = 2;
+ expected[2].is_protected = TRUE;
+ expected[2].is_pinned = TRUE;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+ expected[2].flush_dep_height = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ protect_entry(cache_ptr, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[3].flush_dep_par_type = entry_type;
+ expected[3].flush_dep_par_idx = 4;
+ expected[4].is_protected = TRUE;
+ expected[4].is_pinned = TRUE;
+ expected[4].child_flush_dep_height_rc[0] = 1;
+ expected[4].flush_dep_height = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ create_flush_dependency(cache_ptr, entry_type, 2, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("create_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after creating flush dependency
+ */
+ expected[4].flush_dep_par_type = entry_type;
+ expected[4].flush_dep_par_idx = 2;
+ expected[2].child_flush_dep_height_rc[1] = 2;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ }
+
+ /* Flush the cache and verify that the entries were flushed in correct order */
+ {
+ herr_t result; /* Generic return value */
+
+ add_flush_op(entry_type, 0, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 1, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 2, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 3, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+ add_flush_op(entry_type, 4, FLUSH_OP__ORDER,
+ entry_type, 0, FALSE, (size_t)0, &flush_order);
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 1, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 2, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */
+ entry_type, /* int32_t type */
+ 4, /* int32_t idx */
+ FALSE, /* int32_t dirty */
+ H5C__NO_FLAGS_SET); /* unsigned int flags */
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Mark entries 0-4 dirty, so they are flushed */
+ dirty_entry(cache_ptr, entry_type, 0, FALSE);
+ dirty_entry(cache_ptr, entry_type, 1, TRUE);
+ dirty_entry(cache_ptr, entry_type, 2, TRUE);
+ dirty_entry(cache_ptr, entry_type, 3, FALSE);
+ dirty_entry(cache_ptr, entry_type, 4, TRUE);
+ if ( !pass ) CACHE_ERROR("dirty_entry failed")
+
+ /* Reset 'flushed' flag & 'flush_order' value in expected array */
+ expected[0].flushed = FALSE;
+ expected[0].flush_order = -1;
+ expected[1].flushed = FALSE;
+ expected[1].flush_order = -1;
+ expected[2].flushed = FALSE;
+ expected[2].flush_order = -1;
+ expected[3].flushed = FALSE;
+ expected[3].flush_order = -1;
+ expected[4].flushed = FALSE;
+ expected[4].flush_order = -1;
+
+ /* Reset index for tracking flush order */
+ flush_order = 0;
+
+ result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET);
+ if( result < 0 ) CACHE_ERROR("flushing entries with flush dependendices")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroy flush dependency
+ */
+ expected[0].is_dirty = FALSE;
+ expected[0].flushed = TRUE;
+ expected[0].flush_order = 0;
+ expected[0].is_protected = FALSE;
+ expected[1].is_dirty = FALSE;
+ expected[1].flushed = TRUE;
+ expected[1].flush_order = 2;
+ expected[1].is_protected = FALSE;
+ expected[2].is_dirty = FALSE;
+ expected[2].flushed = TRUE;
+ expected[2].flush_order = 4;
+ expected[2].is_protected = FALSE;
+ expected[3].is_dirty = FALSE;
+ expected[3].flushed = TRUE;
+ expected[3].flush_order = 1;
+ expected[4].is_dirty = FALSE;
+ expected[4].flushed = TRUE;
+ expected[4].flush_order = 3;
+ expected[4].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+ /* Destroy flush dependency between entries, detaching 3->4 from 2 first */
+ {
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 4);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[4].flush_dep_par_type = -1;
+ expected[4].flush_dep_par_idx = -1;
+ expected[2].child_flush_dep_height_rc[1] = 1;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 4, entry_type, 3);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[3].flush_dep_par_type = -1;
+ expected[3].flush_dep_par_idx = -1;
+ expected[4].is_pinned = FALSE;
+ expected[4].child_flush_dep_height_rc[0] = 0;
+ expected[4].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 2, entry_type, 1);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[1].flush_dep_par_type = -1;
+ expected[1].flush_dep_par_idx = -1;
+ expected[2].is_pinned = FALSE;
+ expected[2].child_flush_dep_height_rc[1] = 0;
+ expected[2].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0);
+ if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after destroying flush dependency
+ */
+ expected[0].flush_dep_par_type = -1;
+ expected[0].flush_dep_par_idx = -1;
+ expected[1].is_pinned = FALSE;
+ expected[1].child_flush_dep_height_rc[0] = 0;
+ expected[1].flush_dep_height = 0;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)0, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+ }
+
+
+done:
+ if(cache_ptr)
+ takedown_cache(cache_ptr, FALSE, FALSE);
+
+ if ( pass )
+ PASSED()
+ else {
+ H5_FAILED();
+ HDfprintf(stdout, "%s.\n", failure_mssg);
+ } /* end else */
+
+ return (unsigned)!pass;
+} /* check_flush_deps_order() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_notify_cb()
+ *
+ * Purpose: Exercise the client 'notify' callback.
+ *
+ * Return: 0 on success, non-zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * 4/28/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static unsigned
+check_notify_cb(void)
+{
+ H5C_t * cache_ptr = NULL; /* Metadata cache for this test */
+ test_entry_t *base_addr; /* Base address of entries for test */
+ test_entry_t * entry_ptr; /* Cache entry to examine/manipulate */
+ int entry_type = NOTIFY_ENTRY_TYPE; /* Use entry w/notify callback (size of entries doesn't matter) */
+ size_t entry_size = NOTIFY_ENTRY_SIZE; /* 1 byte */
+ unsigned u; /* Local index variable */
+ struct expected_entry_status expected[5] =
+ {
+ /* entry entry in at main flush dep flush dep child flush flush flush */
+ /* type: index: size: cache: addr: dirty: prot: pinned: loaded: clrd: flshd: dest: par type: par idx: dep ref.count: dep height: order: */
+ { NOTIFY_ENTRY_TYPE, 0, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { NOTIFY_ENTRY_TYPE, 1, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { NOTIFY_ENTRY_TYPE, 2, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { NOTIFY_ENTRY_TYPE, 3, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 },
+ { NOTIFY_ENTRY_TYPE, 4, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, -1, {0,0,0,0,0,0}, 0, -1 }
+ };
+
+ TESTING("'notify' callback");
+
+ pass = TRUE;
+
+ /* Allocate a cache, insert & remove entries, triggering 'notify' callback.
+ * Verify that all performs as expected.
+ */
+
+ reset_entries();
+ cache_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024));
+ base_addr = entries[entry_type];
+
+ if ( !pass ) CACHE_ERROR("setup_cache failed")
+
+ /* Insert entries to work with into the cache */
+ for(u = 0; u < 5; u++) {
+ insert_entry(cache_ptr, entry_type, (int32_t)u, TRUE, H5C__NO_FLAGS_SET);
+ if ( !pass ) CACHE_ERROR("insert_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = TRUE;
+ expected[u].is_dirty = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ /* Check the entry's 'after insert' count */
+ entry_ptr = &(base_addr[u]);
+ if(1 != entry_ptr->notify_after_insert_count)
+ CACHE_ERROR("invalid notify after insert count")
+ if(0 != entry_ptr->notify_before_evict_count)
+ CACHE_ERROR("invalid notify before evict count")
+ } /* end for */
+
+ /* Remove entries from the cache */
+ for(u = 0; u < 5; u++) {
+ expunge_entry(cache_ptr, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("expunge_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = FALSE;
+ expected[u].is_dirty = FALSE;
+ expected[u].cleared = TRUE;
+ expected[u].destroyed = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ /* Check the entry's 'before evict' count */
+ entry_ptr = &(base_addr[u]);
+ if(1 != entry_ptr->notify_after_insert_count)
+ CACHE_ERROR("invalid notify after insert count")
+ if(1 != entry_ptr->notify_before_evict_count)
+ CACHE_ERROR("invalid notify before evict count")
+ } /* end for */
+
+ /* Protect entries to bring them into the cache */
+ for(u = 0; u < 5; u++) {
+ protect_entry(cache_ptr, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("protect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = TRUE;
+ expected[u].is_dirty = FALSE;
+ expected[u].is_protected = TRUE;
+ expected[u].loaded = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ /* Check the entry's 'after insert' count */
+ entry_ptr = &(base_addr[u]);
+ if(2 != entry_ptr->notify_after_insert_count)
+ CACHE_ERROR("invalid notify after insert count")
+ if(1 != entry_ptr->notify_before_evict_count)
+ CACHE_ERROR("invalid notify before evict count")
+ } /* end for */
+
+ /* Unprotect entries, evicting them from the cache */
+ for(u = 0; u < 5; u++) {
+ unprotect_entry(cache_ptr, entry_type, (int32_t)u, TRUE, H5C__NO_FLAGS_SET);
+ if ( !pass ) CACHE_ERROR("unprotect_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = TRUE;
+ expected[u].is_dirty = TRUE;
+ expected[u].is_protected = FALSE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ /* Check the entry's 'after insert' count */
+ entry_ptr = &(base_addr[u]);
+ if(2 != entry_ptr->notify_after_insert_count)
+ CACHE_ERROR("invalid notify after insert count")
+ if(1 != entry_ptr->notify_before_evict_count)
+ CACHE_ERROR("invalid notify before evict count")
+ } /* end for */
+
+ /* Remove entries from the cache */
+ for(u = 0; u < 5; u++) {
+ expunge_entry(cache_ptr, entry_type, (int32_t)u);
+ if ( !pass ) CACHE_ERROR("expunge_entry failed")
+
+ /* Change expected values, and verify the status of the entries
+ * after each insertion
+ */
+ expected[u].in_cache = FALSE;
+ expected[u].is_dirty = FALSE;
+ expected[u].cleared = TRUE;
+ expected[u].destroyed = TRUE;
+
+ /* Verify the status */
+ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */
+ (int)u, /* int tag */
+ (int)5, /* int num_entries */
+ expected); /* struct expected_entry_staus[] */
+ if ( !pass ) CACHE_ERROR("verify_entry_status failed")
+
+ /* Check the entry's 'before evict' count */
+ entry_ptr = &(base_addr[u]);
+ if(2 != entry_ptr->notify_after_insert_count)
+ CACHE_ERROR("invalid notify after insert count")
+ if(2 != entry_ptr->notify_before_evict_count)
+ CACHE_ERROR("invalid notify before evict count")
+ } /* end for */
+
+done:
+ if(cache_ptr)
+ takedown_cache(cache_ptr, FALSE, FALSE);
+
+ if ( pass )
+ PASSED()
+ else {
+ H5_FAILED();
+ HDfprintf(stdout, "%s.\n", failure_mssg);
+ } /* end else */
+
+ return (unsigned)!pass;
+} /* check_notify_cb() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Run tests on the cache code contained in H5C.c
@@ -28173,6 +34040,8 @@ check_auto_cache_resize_aux_fcns(void)
int
main(void)
{
+ unsigned nerrs = 0;
+
H5open();
skip_long_tests = FALSE;
@@ -28183,55 +34052,55 @@ main(void)
run_full_test = FALSE;
#endif /* NDEBUG */
-#if 0
- run_full_test = TRUE;
-#endif
-
-#if 1
- smoke_check_1();
- smoke_check_2();
- smoke_check_3();
- smoke_check_4();
- smoke_check_5();
- smoke_check_6();
- smoke_check_7();
- smoke_check_8();
- smoke_check_9();
- smoke_check_10();
-#endif
+ nerrs += smoke_check_1();
+ nerrs += smoke_check_2();
+ nerrs += smoke_check_3();
+ nerrs += smoke_check_4();
+ nerrs += smoke_check_5();
+ nerrs += smoke_check_6();
+ nerrs += smoke_check_7();
+ nerrs += smoke_check_8();
+ nerrs += smoke_check_9();
+ nerrs += smoke_check_10();
+
+ nerrs += write_permitted_check();
+ nerrs += check_insert_entry();
+ nerrs += check_flush_cache();
+ nerrs += check_get_entry_status();
+ nerrs += check_expunge_entry();
+ nerrs += check_multiple_read_protect();
+ nerrs += check_rename_entry();
+ nerrs += check_pin_protected_entry();
+ nerrs += check_resize_entry();
+ nerrs += check_evictions_enabled();
+ nerrs += check_flush_protected_err();
+ nerrs += check_destroy_pinned_err();
+ nerrs += check_destroy_protected_err();
+ nerrs += check_duplicate_insert_err();
+ nerrs += check_rename_err();
+ nerrs += check_double_pin_err();
+ nerrs += check_double_unpin_err();
+ nerrs += check_pin_entry_errs();
+ nerrs += check_double_protect_err();
+ nerrs += check_double_unprotect_err();
+ nerrs += check_mark_entry_dirty_errs();
+ nerrs += check_expunge_entry_errs();
+ nerrs += check_resize_entry_errs();
+ nerrs += check_unprotect_ro_dirty_err();
+ nerrs += check_protect_ro_rw_err();
+ nerrs += check_check_evictions_enabled_err();
+ nerrs += check_auto_cache_resize();
+ nerrs += check_auto_cache_resize_disable();
+ nerrs += check_auto_cache_resize_epoch_markers();
+ nerrs += check_auto_cache_resize_input_errs();
+ nerrs += check_auto_cache_resize_aux_fcns();
+ nerrs += check_metadata_blizzard_absence(TRUE);
+ nerrs += check_metadata_blizzard_absence(FALSE);
+ nerrs += check_flush_deps();
+ nerrs += check_flush_deps_err();
+ nerrs += check_flush_deps_order();
+ nerrs += check_notify_cb();
+
+ return(nerrs > 0);
+}
- write_permitted_check();
- check_insert_entry();
- check_flush_cache();
- check_get_entry_status();
- check_expunge_entry();
- check_multiple_read_protect();
- check_rename_entry();
- check_pin_protected_entry();
- check_resize_entry();
- check_evictions_enabled();
- check_flush_protected_err();
- check_destroy_pinned_err();
- check_destroy_protected_err();
- check_duplicate_insert_err();
- check_rename_err();
- check_double_pin_err();
- check_double_unpin_err();
- check_pin_entry_errs();
- check_double_protect_err();
- check_double_unprotect_err();
- check_mark_entry_dirty_errs();
- check_expunge_entry_errs();
- check_resize_entry_errs();
- check_unprotect_ro_dirty_err();
- check_protect_ro_rw_err();
- check_check_evictions_enabled_err();
- check_auto_cache_resize();
- check_auto_cache_resize_disable();
- check_auto_cache_resize_epoch_markers();
- check_auto_cache_resize_input_errs();
- check_auto_cache_resize_aux_fcns();
-
- return(0);
-
-} /* main() */
diff --git a/test/cache_api.c b/test/cache_api.c
index fcc4664..ad5c823 100644
--- a/test/cache_api.c
+++ b/test/cache_api.c
@@ -2200,11 +2200,11 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* double lower_hr_threshold = */ 0.9,
/* double increment = */ 2.0,
/* hbool_t apply_max_increment = */ TRUE,
+ /* size_t max_increment = */ (4 * 1024 * 1024),
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
- /* size_t max_increment = */ (4 * 1024 * 1024),
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
@@ -2658,7 +2658,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* size_t max_size = */ (16 * 1024 * 1024),
/* size_t min_size = */ ( 1 * 1024 * 1024),
/* long int epoch_length = */ 50000,
- /* enum H5C_cache_incr_mode incr_mode = */ -1,
+ /* enum H5C_cache_incr_mode incr_mode = */ (enum H5C_cache_incr_mode)-1,
/* double lower_hr_threshold = */ 0.9,
/* double increment = */ 2.0,
/* hbool_t apply_max_increment = */ TRUE,
@@ -2829,7 +2829,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* hbool_t apply_max_increment = */ TRUE,
/* size_t max_increment = */ (4 * 1024 * 1024),
/* enum H5C_cache_flash_incr_mode */
- /* flash_incr_mode = */ -1,
+ /* flash_incr_mode = */ (enum H5C_cache_flash_incr_mode)-1,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold,
@@ -2997,7 +2997,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] =
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
- /* enum H5C_cache_decr_mode decr_mode = */ -1,
+ /* enum H5C_cache_decr_mode decr_mode = */ (enum H5C_cache_decr_mode)-1,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
/* hbool_t apply_max_decrement = */ TRUE,
@@ -3854,7 +3854,7 @@ check_file_mdc_api_errs(void)
{
if ( show_progress ) {
- HDfprintf(stdout,
+ HDfprintf(stdout,
"%s: testing H5Fset_mdc_config() with invalid config %d.\n",
fcn_name, i);
}
@@ -3884,7 +3884,7 @@ check_file_mdc_api_errs(void)
if ( show_progress ) {
- HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 1.\n",
+ HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 1.\n",
fcn_name);
}
@@ -3903,7 +3903,7 @@ check_file_mdc_api_errs(void)
if ( show_progress ) {
- HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 2.\n",
+ HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 2.\n",
fcn_name);
}
@@ -3924,7 +3924,7 @@ check_file_mdc_api_errs(void)
if ( show_progress ) {
- HDfprintf(stdout, "%s: testing H5Freset_mdc_hit_rate_stats().\n",
+ HDfprintf(stdout, "%s: testing H5Freset_mdc_hit_rate_stats().\n",
fcn_name);
}
diff --git a/test/cache_common.c b/test/cache_common.c
index 25eb988..4768f53 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -33,16 +33,19 @@ hbool_t skip_long_tests = TRUE;
hbool_t run_full_test = TRUE;
const char *failure_mssg = NULL;
-test_entry_t pico_entries[NUM_PICO_ENTRIES];
-test_entry_t nano_entries[NUM_NANO_ENTRIES];
-test_entry_t micro_entries[NUM_MICRO_ENTRIES];
-test_entry_t tiny_entries[NUM_TINY_ENTRIES];
-test_entry_t small_entries[NUM_SMALL_ENTRIES];
-test_entry_t medium_entries[NUM_MEDIUM_ENTRIES];
-test_entry_t large_entries[NUM_LARGE_ENTRIES];
-test_entry_t huge_entries[NUM_HUGE_ENTRIES];
-test_entry_t monster_entries[NUM_MONSTER_ENTRIES];
-test_entry_t variable_entries[NUM_VARIABLE_ENTRIES];
+test_entry_t pico_entries[NUM_PICO_ENTRIES], orig_pico_entries[NUM_PICO_ENTRIES];
+test_entry_t nano_entries[NUM_NANO_ENTRIES], orig_nano_entries[NUM_NANO_ENTRIES];
+test_entry_t micro_entries[NUM_MICRO_ENTRIES], orig_micro_entries[NUM_MICRO_ENTRIES];
+test_entry_t tiny_entries[NUM_TINY_ENTRIES], orig_tiny_entries[NUM_TINY_ENTRIES];
+test_entry_t small_entries[NUM_SMALL_ENTRIES], orig_small_entries[NUM_SMALL_ENTRIES];
+test_entry_t medium_entries[NUM_MEDIUM_ENTRIES], orig_medium_entries[NUM_MEDIUM_ENTRIES];
+test_entry_t large_entries[NUM_LARGE_ENTRIES], orig_large_entries[NUM_LARGE_ENTRIES];
+test_entry_t huge_entries[NUM_HUGE_ENTRIES], orig_huge_entries[NUM_HUGE_ENTRIES];
+test_entry_t monster_entries[NUM_MONSTER_ENTRIES], orig_monster_entries[NUM_MONSTER_ENTRIES];
+test_entry_t variable_entries[NUM_VARIABLE_ENTRIES], orig_variable_entries[NUM_VARIABLE_ENTRIES];
+test_entry_t notify_entries[NUM_NOTIFY_ENTRIES], orig_notify_entries[NUM_NOTIFY_ENTRIES];
+
+hbool_t orig_entry_arrays_init = FALSE;
test_entry_t * entries[NUMBER_OF_ENTRY_TYPES] =
{
@@ -55,7 +58,23 @@ test_entry_t * entries[NUMBER_OF_ENTRY_TYPES] =
large_entries,
huge_entries,
monster_entries,
- variable_entries
+ variable_entries,
+ notify_entries
+};
+
+test_entry_t * orig_entries[NUMBER_OF_ENTRY_TYPES] =
+{
+ orig_pico_entries,
+ orig_nano_entries,
+ orig_micro_entries,
+ orig_tiny_entries,
+ orig_small_entries,
+ orig_medium_entries,
+ orig_large_entries,
+ orig_huge_entries,
+ orig_monster_entries,
+ orig_variable_entries,
+ orig_notify_entries
};
const int32_t max_indices[NUMBER_OF_ENTRY_TYPES] =
@@ -69,7 +88,8 @@ const int32_t max_indices[NUMBER_OF_ENTRY_TYPES] =
NUM_LARGE_ENTRIES - 1,
NUM_HUGE_ENTRIES - 1,
NUM_MONSTER_ENTRIES - 1,
- NUM_VARIABLE_ENTRIES - 1
+ NUM_VARIABLE_ENTRIES - 1,
+ NUM_NOTIFY_ENTRIES - 1
};
const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES] =
@@ -83,7 +103,8 @@ const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES] =
LARGE_ENTRY_SIZE,
HUGE_ENTRY_SIZE,
MONSTER_ENTRY_SIZE,
- VARIABLE_ENTRY_SIZE
+ VARIABLE_ENTRY_SIZE,
+ NOTIFY_ENTRY_SIZE
};
const haddr_t base_addrs[NUMBER_OF_ENTRY_TYPES] =
@@ -97,7 +118,8 @@ const haddr_t base_addrs[NUMBER_OF_ENTRY_TYPES] =
LARGE_BASE_ADDR,
HUGE_BASE_ADDR,
MONSTER_BASE_ADDR,
- VARIABLE_BASE_ADDR
+ VARIABLE_BASE_ADDR,
+ NOTIFY_BASE_ADDR
};
const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES] =
@@ -111,7 +133,8 @@ const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES] =
LARGE_ALT_BASE_ADDR,
HUGE_ALT_BASE_ADDR,
MONSTER_ALT_BASE_ADDR,
- VARIABLE_ALT_BASE_ADDR
+ VARIABLE_ALT_BASE_ADDR,
+ NOTIFY_ALT_BASE_ADDR
};
const char * entry_type_names[NUMBER_OF_ENTRY_TYPES] =
@@ -125,7 +148,8 @@ const char * entry_type_names[NUMBER_OF_ENTRY_TYPES] =
"large entries -- 4 KB",
"huge entries -- 16 KB",
"monster entries -- 64 KB",
- "variable entries -- 1B - 10KB"
+ "variable entries -- 1B - 10KB",
+ "notify entries -- 1B"
};
@@ -139,6 +163,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)pico_flush,
(H5C_dest_func_t)pico_dest,
(H5C_clear_func_t)pico_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)pico_size
},
{
@@ -147,6 +172,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)nano_flush,
(H5C_dest_func_t)nano_dest,
(H5C_clear_func_t)nano_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)nano_size
},
{
@@ -155,6 +181,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)micro_flush,
(H5C_dest_func_t)micro_dest,
(H5C_clear_func_t)micro_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)micro_size
},
{
@@ -163,6 +190,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)tiny_flush,
(H5C_dest_func_t)tiny_dest,
(H5C_clear_func_t)tiny_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)tiny_size
},
{
@@ -171,6 +199,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)small_flush,
(H5C_dest_func_t)small_dest,
(H5C_clear_func_t)small_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)small_size
},
{
@@ -179,6 +208,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)medium_flush,
(H5C_dest_func_t)medium_dest,
(H5C_clear_func_t)medium_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)medium_size
},
{
@@ -187,6 +217,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)large_flush,
(H5C_dest_func_t)large_dest,
(H5C_clear_func_t)large_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)large_size
},
{
@@ -195,6 +226,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)huge_flush,
(H5C_dest_func_t)huge_dest,
(H5C_clear_func_t)huge_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)huge_size
},
{
@@ -203,6 +235,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)monster_flush,
(H5C_dest_func_t)monster_dest,
(H5C_clear_func_t)monster_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)monster_size
},
{
@@ -211,7 +244,17 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] =
(H5C_flush_func_t)variable_flush,
(H5C_dest_func_t)variable_dest,
(H5C_clear_func_t)variable_clear,
+ (H5C_notify_func_t)NULL,
(H5C_size_func_t)variable_size
+ },
+ {
+ NOTIFY_ENTRY_TYPE,
+ (H5C_load_func_t)notify_load,
+ (H5C_flush_func_t)notify_flush,
+ (H5C_dest_func_t)notify_dest,
+ (H5C_clear_func_t)notify_clear,
+ (H5C_notify_func_t)notify_notify,
+ (H5C_size_func_t)notify_size
}
};
@@ -222,6 +265,7 @@ static herr_t flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
static void * load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
const void *udata1, void *udata2);
static herr_t size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t notify(H5C_notify_action_t action, void *thing);
@@ -516,6 +560,13 @@ variable_clear(H5F_t * f, void * thing, hbool_t dest)
return(clear(f, thing, dest));
}
+herr_t
+notify_clear(H5F_t * f, void * thing, hbool_t dest)
+{
+ HDassert ( ((test_entry_t *)thing)->type == NOTIFY_ENTRY_TYPE );
+ return(clear(f, thing, dest));
+}
+
/*-------------------------------------------------------------------------
@@ -684,6 +735,13 @@ variable_dest(H5F_t * f, void * thing)
return(destroy(f, thing));
}
+herr_t
+notify_dest(H5F_t * f, void * thing)
+{
+ HDassert ( ((test_entry_t *)thing)->type == NOTIFY_ENTRY_TYPE );
+ return(destroy(f, thing));
+}
+
/*-------------------------------------------------------------------------
* Function: flush & friends
@@ -736,7 +794,7 @@ flush(H5F_t *f,
HDassert( entry_ptr->header.addr == entry_ptr->addr );
HDassert( entry_ptr->addr == addr );
HDassert( entry_ptr->header.size == entry_ptr->size );
- HDassert( ( entry_ptr->type == VARIABLE_ENTRY_TYPE ) ||
+ HDassert( ( entry_ptr->type == VARIABLE_ENTRY_TYPE ) ||
( entry_ptr->size == entry_sizes[entry_ptr->type] ) );
HDassert( entry_ptr->header.is_dirty == entry_ptr->is_dirty );
HDassert( entry_ptr->cache_ptr != NULL );
@@ -748,7 +806,7 @@ flush(H5F_t *f,
for ( i = 0; i < entry_ptr->num_flush_ops; i++ )
{
- execute_flush_op(entry_ptr->cache_ptr,
+ execute_flush_op(entry_ptr->cache_ptr,
entry_ptr,
&((entry_ptr->flush_ops)[i]),
flags_ptr);
@@ -782,8 +840,8 @@ flush(H5F_t *f,
} /* flush() */
-herr_t
-pico_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+herr_t
+pico_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == PICO_ENTRY_TYPE );
@@ -791,7 +849,7 @@ pico_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-nano_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+nano_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == NANO_ENTRY_TYPE );
@@ -799,7 +857,7 @@ nano_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-micro_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+micro_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == MICRO_ENTRY_TYPE );
@@ -807,7 +865,7 @@ micro_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-tiny_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+tiny_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == TINY_ENTRY_TYPE );
@@ -815,7 +873,7 @@ tiny_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-small_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+small_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == SMALL_ENTRY_TYPE );
@@ -823,7 +881,7 @@ small_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-medium_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+medium_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == MEDIUM_ENTRY_TYPE );
@@ -831,7 +889,7 @@ medium_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-large_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+large_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == LARGE_ENTRY_TYPE );
@@ -839,7 +897,7 @@ large_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-huge_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+huge_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == HUGE_ENTRY_TYPE );
@@ -847,7 +905,7 @@ huge_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-monster_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+monster_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == MONSTER_ENTRY_TYPE );
@@ -855,13 +913,21 @@ monster_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
}
herr_t
-variable_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+variable_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
void *thing, unsigned * flags_ptr)
{
HDassert ( ((test_entry_t *)thing)->type == VARIABLE_ENTRY_TYPE );
return(flush(f, dxpl_id, dest, addr, thing, flags_ptr));
}
+herr_t
+notify_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
+ void *thing, unsigned * flags_ptr)
+{
+ HDassert ( ((test_entry_t *)thing)->type == NOTIFY_ENTRY_TYPE );
+ return(flush(f, dxpl_id, dest, addr, thing, flags_ptr));
+}
+
/*-------------------------------------------------------------------------
@@ -1003,6 +1069,13 @@ variable_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
return(load(f, dxpl_id, addr, udata1, udata2));
}
+void *
+notify_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
+ const void *udata1, void *udata2)
+{
+ return(load(f, dxpl_id, addr, udata1, udata2));
+}
+
/*-------------------------------------------------------------------------
* Function: size & friends
@@ -1122,6 +1195,73 @@ variable_size(H5F_t * f, void * thing, size_t * size_ptr)
return(size(f, thing, size_ptr));
}
+herr_t
+notify_size(H5F_t * f, void * thing, size_t * size_ptr)
+{
+ HDassert ( ((test_entry_t *)thing)->type == NOTIFY_ENTRY_TYPE );
+ return(size(f, thing, size_ptr));
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: notify & friends
+ *
+ * Purpose: Record notifications of cache events for the entry.
+ * The helper functions verify that the correct version of notify
+ * is being called, and then call notify proper.
+ *
+ * Return: SUCCEED
+ *
+ * Programmer: Quincey Koziol
+ * 4/28/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static herr_t
+notify(H5C_notify_action_t action, void *thing)
+{
+ test_entry_t * entry_ptr;
+ test_entry_t * base_addr;
+
+ HDassert( thing );
+
+ entry_ptr = (test_entry_t *)thing;
+ base_addr = entries[entry_ptr->type];
+
+ HDassert( entry_ptr->index >= 0 );
+ HDassert( entry_ptr->index <= max_indices[entry_ptr->type] );
+ HDassert( entry_ptr == &(base_addr[entry_ptr->index]) );
+ HDassert( entry_ptr == entry_ptr->self );
+ HDassert( entry_ptr->header.addr == entry_ptr->addr );
+ HDassert( ( entry_ptr->type == VARIABLE_ENTRY_TYPE ) || \
+ ( entry_ptr->size == entry_sizes[entry_ptr->type] ) );
+
+ /* Increment count for appropriate action */
+ switch(action) {
+ case H5C_NOTIFY_ACTION_AFTER_INSERT: /* Entry has been added to the cache */
+ entry_ptr->notify_after_insert_count++;
+ break;
+
+ case H5C_NOTIFY_ACTION_BEFORE_EVICT: /* Entry is about to be evicted from cache */
+ entry_ptr->notify_before_evict_count++;
+ break;
+
+ default:
+ HDassert(0 && "Unknown notify action!?!");
+ } /* end switch */
+
+ return(SUCCEED);
+} /* notify() */
+
+herr_t
+notify_notify(H5C_notify_action_t action, void *thing)
+{
+ HDassert ( ((test_entry_t *)thing)->type == NOTIFY_ENTRY_TYPE );
+ return(notify(action, thing));
+}
+
+
/**************************************************************************/
@@ -1133,9 +1273,9 @@ variable_size(H5F_t * f, void * thing, size_t * size_ptr)
/*-------------------------------------------------------------------------
* Function: add_flush_op
*
- * Purpose: Do noting if pass is FALSE on entry.
+ * Purpose: Do nothing if pass is FALSE on entry.
*
- * Otherwise, add the specified flush operation to the
+ * Otherwise, add the specified flush operation to the
* target instance of test_entry_t.
*
* Return: void
@@ -1155,17 +1295,18 @@ add_flush_op(int target_type,
int type,
int idx,
hbool_t flag,
- size_t new_size)
+ size_t new_size,
+ unsigned * order_ptr)
{
int i;
test_entry_t * target_base_addr;
test_entry_t * target_entry_ptr;
HDassert( ( 0 <= target_type ) && ( target_type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= target_idx ) &&
+ HDassert( ( 0 <= target_idx ) &&
( target_idx <= max_indices[target_type] ) );
HDassert( ( 0 <= op_code ) && ( op_code <= FLUSH_OP__MAX_OP ) );
- HDassert( ( op_code != FLUSH_OP__RESIZE ) ||
+ HDassert( ( op_code != FLUSH_OP__RESIZE ) ||
( type == VARIABLE_ENTRY_TYPE ) );
HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
@@ -1188,9 +1329,10 @@ add_flush_op(int target_type,
(target_entry_ptr->flush_ops)[i].idx = idx;
(target_entry_ptr->flush_ops)[i].flag = flag;
(target_entry_ptr->flush_ops)[i].size = new_size;
+ (target_entry_ptr->flush_ops)[i].order_ptr = order_ptr;
}
-
+
return;
} /* add_flush_op() */
@@ -1199,7 +1341,7 @@ add_flush_op(int target_type,
/*-------------------------------------------------------------------------
* Function: create_pinned_entry_dependency
*
- * Purpose: Do noting if pass is FALSE on entry.
+ * Purpose: Do nothing if pass is FALSE on entry.
*
* Otherwise, set up a pinned entry dependency so we can
* test the pinned entry modifications to the flush routine.
@@ -1282,11 +1424,11 @@ create_pinned_entry_dependency(H5C_t * cache_ptr,
* Function: dirty_entry
*
* Purpose: Given a pointer to a cache, an entry type, and an index,
- * dirty the target entry.
+ * dirty the target entry.
*
* If the dirty_pin parameter is true, verify that the
- * target entry is in the cache and is pinned. If it
- * isn't, scream and die. If it is, use the
+ * target entry is in the cache and is pinned. If it
+ * isn't, scream and die. If it is, use the
* H5C_mark_pinned_entry_dirty() call to dirty it.
*
* Do nothing if pass is false on entry.
@@ -1338,7 +1480,7 @@ dirty_entry(H5C_t * cache_ptr,
pass = FALSE;
failure_mssg = "entry to be dirty pinned is not pinned.";
-
+
} else {
mark_pinned_entry_dirty(cache_ptr, type, idx, FALSE, (size_t)0);
@@ -1346,7 +1488,7 @@ dirty_entry(H5C_t * cache_ptr,
}
}
} else {
-
+
protect_entry(cache_ptr, type, idx);
unprotect_entry(cache_ptr, type, idx, TRUE, H5C__NO_FLAGS_SET);
}
@@ -1391,13 +1533,13 @@ execute_flush_op(H5C_t * cache_ptr,
HDassert( ( entry_ptr->flush_op_self_resize_in_progress ) ||
( entry_ptr->header.size == entry_ptr->size ) );
HDassert( op_ptr != NULL );
- HDassert( ( 0 <= entry_ptr->type ) &&
+ HDassert( ( 0 <= entry_ptr->type ) &&
( entry_ptr->type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= entry_ptr->index ) &&
+ HDassert( ( 0 <= entry_ptr->index ) &&
( entry_ptr->index <= max_indices[entry_ptr->type] ) );
- HDassert( ( 0 <= op_ptr->type ) &&
+ HDassert( ( 0 <= op_ptr->type ) &&
( op_ptr->type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= op_ptr->idx ) &&
+ HDassert( ( 0 <= op_ptr->idx ) &&
( op_ptr->idx <= max_indices[op_ptr->type] ) );
HDassert( ( op_ptr->flag == FALSE ) || ( op_ptr->flag == TRUE ) );
HDassert( flags_ptr != NULL );
@@ -1410,17 +1552,17 @@ execute_flush_op(H5C_t * cache_ptr,
break;
case FLUSH_OP__DIRTY:
- HDassert( ( entry_ptr->type != op_ptr->type ) ||
+ HDassert( ( entry_ptr->type != op_ptr->type ) ||
( entry_ptr->index != op_ptr->idx ) );
dirty_entry(cache_ptr, op_ptr->type, op_ptr->idx, op_ptr->flag);
break;
case FLUSH_OP__RESIZE:
- if ( ( entry_ptr->type == op_ptr->type ) &&
+ if ( ( entry_ptr->type == op_ptr->type ) &&
( entry_ptr->index == op_ptr->idx ) ) {
- /* the flush operation is acting on the entry to
+ /* the flush operation is acting on the entry to
* which it is attached. Handle this here:
*/
HDassert( entry_ptr->type == VARIABLE_ENTRY_TYPE );
@@ -1439,21 +1581,27 @@ execute_flush_op(H5C_t * cache_ptr,
entry_ptr->header.size = entry_ptr->size;
}
-
+
} else {
/* change the size of some other entry */
- resize_entry(cache_ptr, op_ptr->type, op_ptr->idx,
+ resize_entry(cache_ptr, op_ptr->type, op_ptr->idx,
op_ptr->size, op_ptr->flag);
}
break;
case FLUSH_OP__RENAME:
- rename_entry(cache_ptr, op_ptr->type, op_ptr->idx,
+ rename_entry(cache_ptr, op_ptr->type, op_ptr->idx,
op_ptr->flag);
break;
+ case FLUSH_OP__ORDER:
+ HDassert( op_ptr->order_ptr );
+ entry_ptr->flush_order = *op_ptr->order_ptr;
+ (*op_ptr->order_ptr)++;
+ break;
+
default:
pass = FALSE;
failure_mssg = "Undefined flush op code.";
@@ -1524,7 +1672,7 @@ entry_in_cache(H5C_t * cache_ptr,
/*-------------------------------------------------------------------------
* Function: reset_entries
*
- * Purpose: reset the contents of the entries arrays to know values.
+ * Purpose: reset the contents of the entries arrays to known values.
*
* Return: void
*
@@ -1538,7 +1686,7 @@ entry_in_cache(H5C_t * cache_ptr,
* fields.
*
* JRM -- 4/1/07
- * Added initialization for the new is_read_only, and
+ * Added initialization for the new is_read_only, and
* ro_ref_count fields.
*
*-------------------------------------------------------------------------
@@ -1549,87 +1697,126 @@ reset_entries(void)
{
int i;
- int j;
- int k;
- int32_t max_index;
- haddr_t addr = 0;
- haddr_t alt_addr = PICO_ALT_BASE_ADDR;
- size_t entry_size;
- test_entry_t * base_addr;
- for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ )
+ if( !orig_entry_arrays_init)
{
- entry_size = entry_sizes[i];
- max_index = max_indices[i];
- base_addr = entries[i];
-
- HDassert( base_addr );
+ haddr_t addr = 0;
+ haddr_t alt_addr = PICO_ALT_BASE_ADDR;
- for ( j = 0; j <= max_index; j++ )
+ for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ )
{
- /* one can argue that we should fill the header with garbage.
- * If this is desired, we can simply comment out the header
- * initialization - the headers will be full of garbage soon
- * enough.
- */
+ int32_t max_index;
+ size_t entry_size;
+ test_entry_t * base_addr;
+ test_entry_t * orig_base_addr;
+ int j;
- base_addr[j].header.addr = (haddr_t)0;
- base_addr[j].header.size = (size_t)0;
- base_addr[j].header.type = NULL;
- base_addr[j].header.is_dirty = FALSE;
- base_addr[j].header.is_protected = FALSE;
- base_addr[j].header.is_read_only = FALSE;
- base_addr[j].header.ro_ref_count = FALSE;
- base_addr[j].header.next = NULL;
- base_addr[j].header.prev = NULL;
- base_addr[j].header.aux_next = NULL;
- base_addr[j].header.aux_prev = NULL;
-
- base_addr[j].self = &(base_addr[j]);
- base_addr[j].cache_ptr = NULL;
- base_addr[j].addr = addr;
- base_addr[j].at_main_addr = TRUE;
- base_addr[j].main_addr = addr;
- base_addr[j].alt_addr = alt_addr;
- base_addr[j].size = entry_size;
- base_addr[j].type = i;
- base_addr[j].index = j;
- base_addr[j].reads = 0;
- base_addr[j].writes = 0;
- base_addr[j].is_dirty = FALSE;
- base_addr[j].is_protected = FALSE;
- base_addr[j].is_read_only = FALSE;
- base_addr[j].ro_ref_count = FALSE;
-
- base_addr[j].is_pinned = FALSE;
- base_addr[j].pinning_ref_count = 0;
- base_addr[j].num_pins = 0;
- for ( k = 0; k < MAX_PINS; k++ )
- {
- base_addr[j].pin_type[k] = -1;
- base_addr[j].pin_idx[k] = -1;
- }
+ entry_size = entry_sizes[i];
+ max_index = max_indices[i];
+ base_addr = entries[i];
+ orig_base_addr = orig_entries[i];
- base_addr[j].num_flush_ops = 0;
- for ( k = 0; k < MAX_FLUSH_OPS; k++ )
- {
- base_addr[j].flush_ops[k].op_code = FLUSH_OP__NO_OP;
- base_addr[j].flush_ops[k].type = -1;
- base_addr[j].flush_ops[k].idx = -1;
- base_addr[j].flush_ops[k].flag = FALSE;
- base_addr[j].flush_ops[k].size = 0;
- }
- base_addr[j].flush_op_self_resize_in_progress = FALSE;
+ HDassert( base_addr );
+ HDassert( orig_base_addr );
- base_addr[j].loaded = FALSE;
- base_addr[j].cleared = FALSE;
- base_addr[j].flushed = FALSE;
- base_addr[j].destroyed = FALSE;
+ for ( j = 0; j <= max_index; j++ )
+ {
+ int k;
+
+ /* one can argue that we should fill the header with garbage.
+ * If this is desired, we can simply comment out the header
+ * initialization - the headers will be full of garbage soon
+ * enough.
+ */
+
+ base_addr[j].header.addr = (haddr_t)0;
+ base_addr[j].header.size = (size_t)0;
+ base_addr[j].header.type = NULL;
+ base_addr[j].header.is_dirty = FALSE;
+ base_addr[j].header.is_protected = FALSE;
+ base_addr[j].header.is_read_only = FALSE;
+ base_addr[j].header.ro_ref_count = FALSE;
+ base_addr[j].header.next = NULL;
+ base_addr[j].header.prev = NULL;
+ base_addr[j].header.aux_next = NULL;
+ base_addr[j].header.aux_prev = NULL;
+
+ base_addr[j].self = &(base_addr[j]);
+ base_addr[j].cache_ptr = NULL;
+ base_addr[j].addr = addr;
+ base_addr[j].at_main_addr = TRUE;
+ base_addr[j].main_addr = addr;
+ base_addr[j].alt_addr = alt_addr;
+ base_addr[j].size = entry_size;
+ base_addr[j].type = i;
+ base_addr[j].index = j;
+ base_addr[j].reads = 0;
+ base_addr[j].writes = 0;
+ base_addr[j].is_dirty = FALSE;
+ base_addr[j].is_protected = FALSE;
+ base_addr[j].is_read_only = FALSE;
+ base_addr[j].ro_ref_count = FALSE;
+
+ base_addr[j].is_pinned = FALSE;
+ base_addr[j].pinning_ref_count = 0;
+ base_addr[j].num_pins = 0;
+ for ( k = 0; k < MAX_PINS; k++ )
+ {
+ base_addr[j].pin_type[k] = -1;
+ base_addr[j].pin_idx[k] = -1;
+ }
- addr += (haddr_t)entry_size;
- alt_addr += (haddr_t)entry_size;
- }
- }
+ base_addr[j].num_flush_ops = 0;
+ for ( k = 0; k < MAX_FLUSH_OPS; k++ )
+ {
+ base_addr[j].flush_ops[k].op_code = FLUSH_OP__NO_OP;
+ base_addr[j].flush_ops[k].type = -1;
+ base_addr[j].flush_ops[k].idx = -1;
+ base_addr[j].flush_ops[k].flag = FALSE;
+ base_addr[j].flush_ops[k].size = 0;
+ }
+ base_addr[j].flush_op_self_resize_in_progress = FALSE;
+
+ base_addr[j].loaded = FALSE;
+ base_addr[j].cleared = FALSE;
+ base_addr[j].flushed = FALSE;
+ base_addr[j].destroyed = FALSE;
+
+ base_addr[j].flush_dep_par_type = -1;
+ base_addr[j].flush_dep_par_idx = -1;
+ for ( k = 0; k < H5C__NUM_FLUSH_DEP_HEIGHTS; k++ )
+ base_addr[j].child_flush_dep_height_rc[k] = 0;
+ base_addr[j].flush_dep_height = 0;
+ base_addr[j].pinned_from_client = FALSE;
+ base_addr[j].pinned_from_cache = FALSE;
+
+ base_addr[j].flush_order = 0;
+
+ base_addr[j].notify_after_insert_count = 0;
+ base_addr[j].notify_before_evict_count = 0;
+
+ addr += (haddr_t)entry_size;
+ alt_addr += (haddr_t)entry_size;
+ } /* end for */
+
+ /* Make copy of entries in base_addr for later */
+ HDmemcpy(orig_base_addr, base_addr, (size_t)(max_index + 1) * sizeof( *base_addr ));
+ } /* end for */
+
+ /* Indicate that we've made a copy for later */
+ orig_entry_arrays_init = TRUE;
+ } /* end if */
+ else {
+ for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ )
+ {
+ int32_t max_index = max_indices[i];
+ test_entry_t * base_addr = entries[i];
+ test_entry_t * orig_base_addr = orig_entries[i];
+
+ /* Make copy of entries in base_addr for later */
+ HDmemcpy(base_addr, orig_base_addr, (size_t)(max_index + 1) * sizeof( *base_addr ));
+ } /* end for */
+ } /* end else */
return;
@@ -1641,12 +1828,12 @@ reset_entries(void)
*
* Purpose: Given a pointer to a cache, an entry type, an index, and
* a size, set the size of the target entry to the size. Note
- * that at present, the type of the entry must be
+ * that at present, the type of the entry must be
* VARIABLE_ENTRY_TYPE.
*
* If the resize_pin parameter is true, verify that the
- * target entry is in the cache and is pinned. If it
- * isn't, scream and die. If it is, use the
+ * target entry is in the cache and is pinned. If it
+ * isn't, scream and die. If it is, use the
* H5C_mark_pinned_entry_dirty() call to resize it.
*
* Do nothing if pass is false on entry.
@@ -1701,15 +1888,15 @@ resize_entry(H5C_t * cache_ptr,
pass = FALSE;
failure_mssg = "entry to be resized pinned is not pinned.";
-
+
} else {
- mark_pinned_entry_dirty(cache_ptr, type, idx,
+ mark_pinned_entry_dirty(cache_ptr, type, idx,
TRUE, new_size);
}
}
} else {
-
+
protect_entry(cache_ptr, type, idx);
unprotect_entry_with_size_change(cache_ptr, type, idx,
H5C__SIZE_CHANGED_FLAG, new_size);
@@ -1755,7 +1942,7 @@ resize_pinned_entry(H5C_t * cache_ptr,
HDassert( cache_ptr );
HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
- HDassert( type = VARIABLE_ENTRY_TYPE ) ;
+ HDassert( type == VARIABLE_ENTRY_TYPE ) ;
HDassert( ( 0 < new_size ) && ( new_size <= entry_sizes[type] ) );
if ( pass ) {
@@ -1778,13 +1965,13 @@ resize_pinned_entry(H5C_t * cache_ptr,
pass = FALSE;
failure_mssg = "entry to be resized is not pinned.";
-
+
} else {
entry_ptr->size = new_size;
- result = H5C_resize_pinned_entry(cache_ptr,
- (void *)entry_ptr,
+ result = H5C_resize_pinned_entry(cache_ptr,
+ (void *)entry_ptr,
new_size);
if ( result != SUCCEED ) {
@@ -1845,7 +2032,7 @@ verify_clean(void)
for ( j = 0; j <= max_index; j++ )
{
- if ( ( base_addr[j].header.is_dirty ) ||
+ if ( ( base_addr[j].header.is_dirty ) ||
( base_addr[j].is_dirty ) ) {
dirty_count++;
@@ -1891,16 +2078,15 @@ verify_entry_status(H5C_t * cache_ptr,
struct expected_entry_status expected[])
{
static char msg[128];
- hbool_t in_cache = FALSE; /* will set to TRUE if necessary */
int i;
- test_entry_t * entry_ptr;
- test_entry_t * base_addr;
i = 0;
while ( ( pass ) && ( i < num_entries ) )
{
- base_addr = entries[expected[i].entry_type];
- entry_ptr = &(base_addr[expected[i].entry_index]);
+ test_entry_t * base_addr = entries[expected[i].entry_type];
+ test_entry_t * entry_ptr = &(base_addr[expected[i].entry_index]);
+ hbool_t in_cache = FALSE; /* will set to TRUE if necessary */
+ unsigned u; /* Local index variable */
if ( ( ! expected[i].in_cache ) &&
( ( expected[i].is_dirty ) ||
@@ -1914,7 +2100,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( pass ) {
- in_cache = entry_in_cache(cache_ptr, expected[i].entry_type,
+ in_cache = entry_in_cache(cache_ptr, expected[i].entry_type,
expected[i].entry_index);
if ( in_cache != expected[i].in_cache ) {
@@ -1936,8 +2122,8 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->size != expected[i].size ) {
pass = FALSE;
- sprintf(msg,
- "%d entry (%d, %d) size actualexpected = %ld/%ld.\n",
+ sprintf(msg,
+ "%d entry (%d, %d) size actual/expected = %ld/%ld.\n",
tag,
(int)expected[i].entry_type,
(int)expected[i].entry_index,
@@ -1952,7 +2138,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->header.size != expected[i].size ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) header size actual/expected = %ld/%ld.\n",
tag,
(int)expected[i].entry_type,
@@ -1968,7 +2154,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->at_main_addr != expected[i].at_main_addr ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) at main addr actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -1984,7 +2170,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->is_dirty != expected[i].is_dirty ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) is_dirty actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -2000,7 +2186,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->header.is_dirty != expected[i].is_dirty ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) header is_dirty actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -2016,7 +2202,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->is_protected != expected[i].is_protected ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) is_protected actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -2032,7 +2218,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->header.is_protected != expected[i].is_protected ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) header is_protected actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -2048,7 +2234,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->is_pinned != expected[i].is_pinned ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) is_pinned actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -2064,7 +2250,7 @@ verify_entry_status(H5C_t * cache_ptr,
if ( entry_ptr->header.is_pinned != expected[i].is_pinned ) {
pass = FALSE;
- sprintf(msg,
+ sprintf(msg,
"%d entry (%d, %d) header is_pinned actual/expected = %d/%d.\n",
tag,
(int)expected[i].entry_type,
@@ -2099,6 +2285,127 @@ verify_entry_status(H5C_t * cache_ptr,
failure_mssg = msg;
}
}
+
+ /* Check flush dependency fields */
+
+ /* Flush dependency parent type & index */
+ if ( pass ) {
+ if ( entry_ptr->flush_dep_par_type != expected[i].flush_dep_par_type ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) flush_dep_par_type actual/expected = %d/%d.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ entry_ptr->flush_dep_par_type,
+ expected[i].flush_dep_par_type);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+ if ( pass ) {
+ if ( entry_ptr->flush_dep_par_idx != expected[i].flush_dep_par_idx ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) flush_dep_par_idx actual/expected = %d/%d.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ entry_ptr->flush_dep_par_idx,
+ expected[i].flush_dep_par_idx);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+ if ( ( pass ) && ( in_cache ) && expected[i].flush_dep_par_idx >= 0 ) {
+ test_entry_t * par_base_addr = entries[expected[i].flush_dep_par_type];
+
+ if ( entry_ptr->header.flush_dep_parent != (H5C_cache_entry_t *)&(par_base_addr[expected[i].flush_dep_par_idx]) ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) header flush_dep_parent actual/expected = %p/%p.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ (void *)entry_ptr->header.flush_dep_parent,
+ (void *)&(par_base_addr[expected[i].flush_dep_par_idx]));
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+
+ /* Flush dependency child ref. counts */
+ for(u = 0; u < H5C__NUM_FLUSH_DEP_HEIGHTS; u++) {
+ if ( pass ) {
+ if ( entry_ptr->child_flush_dep_height_rc[u] != expected[i].child_flush_dep_height_rc[u] ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) child_flush_dep_height_rc[%u] actual/expected = %llu/%llu.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ u,
+ (unsigned long long)(entry_ptr->child_flush_dep_height_rc[u]),
+ (unsigned long long)expected[i].child_flush_dep_height_rc[u]);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+ if ( ( pass ) && ( in_cache ) ) {
+ if ( entry_ptr->header.child_flush_dep_height_rc[u] != expected[i].child_flush_dep_height_rc[u] ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) header child_flush_dep_height_rc[%u] actual/expected = %llu/%llu.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ u,
+ (unsigned long long)entry_ptr->header.child_flush_dep_height_rc[u],
+ (unsigned long long)expected[i].child_flush_dep_height_rc[u]);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+ } /* end for */
+
+ /* Flush dependency height */
+ if ( pass ) {
+ if ( entry_ptr->flush_dep_height != expected[i].flush_dep_height ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) flush_dep_height actual/expected = %u/%u.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ entry_ptr->flush_dep_height,
+ expected[i].flush_dep_height);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+ if ( ( pass ) && ( in_cache ) ) {
+ if ( entry_ptr->header.flush_dep_height != expected[i].flush_dep_height ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) header flush_dep_height actual/expected = %u/%u.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ entry_ptr->header.flush_dep_height,
+ expected[i].flush_dep_height);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+
+ /* Flush dependency flush order */
+ if ( pass ) {
+ if ( expected[i].flush_order >= 0 && entry_ptr->flush_order != (unsigned)expected[i].flush_order ) {
+ pass = FALSE;
+ sprintf(msg,
+ "%d entry (%d, %d) flush_order actual/expected = %u/%d.\n",
+ tag,
+ expected[i].entry_type,
+ expected[i].entry_index,
+ entry_ptr->flush_order,
+ expected[i].flush_order);
+ failure_mssg = msg;
+ } /* end if */
+ } /* end if */
+
i++;
} /* while */
@@ -2302,7 +2609,7 @@ expunge_entry(H5C_t * cache_ptr,
HDassert( ! ( entry_ptr->is_pinned ) );
result = H5C_expunge_entry(NULL, -1, -1, cache_ptr, &(types[type]),
- entry_ptr->addr);
+ entry_ptr->addr, H5AC__NO_FLAGS_SET);
if ( result < 0 ) {
@@ -2339,7 +2646,9 @@ flush_cache(H5C_t * cache_ptr,
hbool_t dump_stats,
hbool_t dump_detailed_stats)
{
+ const char * fcn_name = "flush_cache()";
herr_t result = 0;
+ hbool_t verbose = FALSE;
HDassert(cache_ptr);
@@ -2369,6 +2678,26 @@ flush_cache(H5C_t * cache_ptr,
pass = FALSE;
failure_mssg = "error in H5C_flush_cache().";
}
+ else if ( ( destroy_entries ) &&
+ ( ( cache_ptr->index_len != 0 ) ||
+ ( cache_ptr->index_size != 0 ) ||
+ ( cache_ptr->clean_index_size != 0 ) ||
+ ( cache_ptr->dirty_index_size != 0 ) ) ) {
+
+ if ( verbose ) {
+ HDfprintf(stdout,
+ "%s: unexpected il/is/cis/dis = %lld/%lld/%lld/%lld.\n",
+ fcn_name,
+ (long long)(cache_ptr->index_len),
+ (long long)(cache_ptr->index_size),
+ (long long)(cache_ptr->clean_index_size),
+ (long long)(cache_ptr->dirty_index_size));
+ }
+ pass = FALSE;
+ failure_mssg =
+ "non zero index len/sizes after H5C_flush_cache() with invalidate.";
+ }
+
return;
@@ -2439,7 +2768,7 @@ insert_entry(H5C_t * cache_ptr,
HDassert( entry_ptr == entry_ptr->self );
HDassert( !(entry_ptr->is_protected) );
- insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0 );
+ insert_pinned = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0 );
entry_ptr->is_dirty = TRUE;
@@ -2478,14 +2807,15 @@ insert_entry(H5C_t * cache_ptr,
if ( insert_pinned ) {
HDassert( entry_ptr->header.is_pinned );
- entry_ptr->is_pinned = TRUE;
} else {
HDassert( ! ( entry_ptr->header.is_pinned ) );
- entry_ptr->is_pinned = FALSE;
}
+ entry_ptr->is_pinned = insert_pinned;
+ entry_ptr->pinned_from_client = insert_pinned;
+
HDassert( entry_ptr->header.is_dirty );
HDassert( ((entry_ptr->header).type)->id == type );
}
@@ -2546,7 +2876,7 @@ mark_pinned_entry_dirty(H5C_t * cache_ptr,
entry_ptr->is_dirty = TRUE;
if ( size_changed ) {
-
+
/* update entry size now to keep the sanity checks happy */
entry_ptr->size = new_size;
}
@@ -2569,16 +2899,16 @@ mark_pinned_entry_dirty(H5C_t * cache_ptr,
(int)(entry_ptr->header.is_dirty));
HDfprintf(stdout, "entry_ptr->header.is_pinned = %d.\n",
(int)(entry_ptr->header.is_pinned));
- HDfprintf(stdout,
+ HDfprintf(stdout,
"(entry_ptr->header.type != &(types[type])) = %d.\n",
(int)(entry_ptr->header.type != &(types[type])));
- HDfprintf(stdout,
+ HDfprintf(stdout,
"entry_ptr->size = %ld, entry_ptr->header.size = %ld.\n",
(long)(entry_ptr->size), (long)(entry_ptr->header.size));
- HDfprintf(stdout,
+ HDfprintf(stdout,
"entry_ptr->addr = %ld, entry_ptr->header.addr = %ld.\n",
(long)(entry_ptr->addr), (long)(entry_ptr->header.addr));
-#endif
+#endif
pass = FALSE;
failure_mssg = "error in H5C_mark_pinned_entry_dirty().";
@@ -2761,7 +3091,7 @@ rename_entry(H5C_t * cache_ptr,
if ( ! done ) {
- if ( ( result < 0 ) ||
+ if ( ( result < 0 ) ||
( ( ! ( entry_ptr->header.destroy_in_progress ) ) &&
( entry_ptr->header.addr != new_addr ) ) ) {
@@ -2798,8 +3128,8 @@ rename_entry(H5C_t * cache_ptr,
* 6/11/04
*
* Modifications:
- *
- * - Modified call to H5C_protect to pass H5C__NO_FLAGS_SET in the
+ *
+ * - Modified call to H5C_protect to pass H5C__NO_FLAGS_SET in the
* new flags parameter.
* JRM -- 3/28/07
*
@@ -2830,7 +3160,7 @@ protect_entry(H5C_t * cache_ptr,
HDassert( entry_ptr == entry_ptr->self );
HDassert( !(entry_ptr->is_protected) );
- cache_entry_ptr = H5C_protect(NULL, -1, -1, cache_ptr, &(types[type]),
+ cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(NULL, -1, -1, cache_ptr, &(types[type]),
entry_ptr->addr, NULL, NULL,
H5C__NO_FLAGS_SET);
@@ -2886,7 +3216,7 @@ protect_entry(H5C_t * cache_ptr,
/*-------------------------------------------------------------------------
* Function: protect_entry_ro()
*
- * Purpose: Do a read only protect the entry indicated by the type
+ * Purpose: Do a read only protect the entry indicated by the type
* and index.
*
* Do nothing if pass is FALSE on entry.
@@ -2897,7 +3227,7 @@ protect_entry(H5C_t * cache_ptr,
* 4/1/07
*
* Modifications:
- *
+ *
* - None.
*
*-------------------------------------------------------------------------
@@ -2925,11 +3255,11 @@ protect_entry_ro(H5C_t * cache_ptr,
HDassert( entry_ptr->index == idx );
HDassert( entry_ptr->type == type );
HDassert( entry_ptr == entry_ptr->self );
- HDassert( ( ! ( entry_ptr->is_protected ) ) ||
- ( ( entry_ptr->is_read_only ) &&
+ HDassert( ( ! ( entry_ptr->is_protected ) ) ||
+ ( ( entry_ptr->is_read_only ) &&
( entry_ptr->ro_ref_count > 0 ) ) );
- cache_entry_ptr = H5C_protect(NULL, -1, -1, cache_ptr, &(types[type]),
+ cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(NULL, -1, -1, cache_ptr, &(types[type]),
entry_ptr->addr, NULL, NULL,
H5C__READ_ONLY_FLAG);
@@ -2964,6 +3294,69 @@ protect_entry_ro(H5C_t * cache_ptr,
/*-------------------------------------------------------------------------
+ * Function: pin_entry()
+ *
+ * Purpose: Pin the entry indicated by the type and index.
+ *
+ * Do nothing if pass is FALSE on entry.
+ *
+ * Return: void
+ *
+ * Programmer: Quincey Koziol
+ * 3/17/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+pin_entry(H5C_t * cache_ptr,
+ int32_t type,
+ int32_t idx)
+{
+ HDassert( cache_ptr );
+ HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
+ HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
+
+ if ( pass ) {
+ test_entry_t * base_addr;
+ test_entry_t * entry_ptr;
+ herr_t result;
+
+ base_addr = entries[type];
+ entry_ptr = &(base_addr[idx]);
+
+ HDassert( entry_ptr->index == idx );
+ HDassert( entry_ptr->type == type );
+ HDassert( entry_ptr == entry_ptr->self );
+ HDassert( entry_ptr->is_protected );
+ HDassert( !(entry_ptr->pinned_from_client) );
+
+ result = H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr);
+
+ if ( result < 0 ) {
+
+ pass = FALSE;
+ failure_mssg = "H5C_pin_protected_entry() reports failure.";
+
+ } else if ( ! ( entry_ptr->header.is_pinned ) ) {
+
+ pass = FALSE;
+ failure_mssg = "entry not pinned when it should be.";
+
+ } else {
+
+ entry_ptr->pinned_from_client = TRUE;
+ entry_ptr->is_pinned = TRUE;
+
+ }
+ } /* end if */
+
+ return;
+
+} /* pin_entry() */
+
+
+/*-------------------------------------------------------------------------
* Function: unpin_entry()
*
* Purpose: Unpin the entry indicated by the type and index.
@@ -3005,14 +3398,16 @@ unpin_entry(H5C_t * cache_ptr,
HDassert( entry_ptr->type == type );
HDassert( entry_ptr == entry_ptr->self );
HDassert( entry_ptr->cache_ptr == cache_ptr );
- HDassert( ! (entry_ptr->header.is_protected) );
HDassert( entry_ptr->header.is_pinned );
+ HDassert( entry_ptr->header.pinned_from_client );
HDassert( entry_ptr->is_pinned );
+ HDassert( entry_ptr->pinned_from_client );
result = H5C_unpin_entry(cache_ptr, (void *)entry_ptr);
if ( ( result < 0 ) ||
- ( entry_ptr->header.is_pinned ) ||
+ ( entry_ptr->header.pinned_from_client ) ||
+ ( entry_ptr->header.is_pinned && !entry_ptr->header.pinned_from_cache ) ||
( entry_ptr->header.type != &(types[type]) ) ||
( entry_ptr->size != entry_ptr->header.size ) ||
( entry_ptr->addr != entry_ptr->header.addr ) ) {
@@ -3022,7 +3417,9 @@ unpin_entry(H5C_t * cache_ptr,
}
- entry_ptr->is_pinned = FALSE;
+ entry_ptr->pinned_from_client = FALSE;
+
+ entry_ptr->is_pinned = entry_ptr->pinned_from_cache;
HDassert( ((entry_ptr->header).type)->id == type );
@@ -3062,7 +3459,7 @@ unpin_entry(H5C_t * cache_ptr,
* JRM -- 3/31/06
* Update for pinned entries.
*
- * JRM -- 4/1/07
+ * JRM -- 4/1/07
* Updated for new multiple read protects.
*
*-------------------------------------------------------------------------
@@ -3098,8 +3495,8 @@ unprotect_entry(H5C_t * cache_ptr,
HDassert( entry_ptr->header.is_protected );
HDassert( entry_ptr->is_protected );
- pin_flag_set = ((flags & H5C__PIN_ENTRY_FLAG) != 0 );
- unpin_flag_set = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0 );
+ pin_flag_set = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0 );
+ unpin_flag_set = (hbool_t)((flags & H5C__UNPIN_ENTRY_FLAG) != 0 );
HDassert ( ! ( pin_flag_set && unpin_flag_set ) );
HDassert ( ( ! pin_flag_set ) || ( ! (entry_ptr->is_pinned) ) );
@@ -3108,7 +3505,7 @@ unprotect_entry(H5C_t * cache_ptr,
if ( ( dirty == TRUE ) || ( dirty == FALSE ) ) {
flags |= (dirty ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET);
- entry_ptr->is_dirty = (entry_ptr->is_dirty || dirty);
+ entry_ptr->is_dirty = (hbool_t)(entry_ptr->is_dirty || dirty);
}
result = H5C_unprotect(NULL, -1, -1, cache_ptr, &(types[type]),
@@ -3160,7 +3557,7 @@ unprotect_entry(H5C_t * cache_ptr,
entry_ptr->ro_ref_count = 0;
} else {
-
+
entry_ptr->is_protected = FALSE;
}
@@ -3168,12 +3565,14 @@ unprotect_entry(H5C_t * cache_ptr,
if ( pin_flag_set ) {
HDassert ( entry_ptr->header.is_pinned );
+ entry_ptr->pinned_from_client = TRUE;
entry_ptr->is_pinned = TRUE;
} else if ( unpin_flag_set ) {
- HDassert ( ! ( entry_ptr->header.is_pinned ) );
- entry_ptr->is_pinned = FALSE;
+ HDassert ( entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache );
+ entry_ptr->pinned_from_client = FALSE;
+ entry_ptr->is_pinned = entry_ptr->pinned_from_cache;
}
}
@@ -3229,12 +3628,13 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr,
unsigned int flags,
size_t new_size)
{
- /* const char * fcn_name = "unprotect_entry_with_size_change()"; */
+ const char * fcn_name = "unprotect_entry_with_size_change()";
herr_t result;
hbool_t dirty_flag_set;
hbool_t pin_flag_set;
hbool_t unpin_flag_set;
hbool_t size_changed_flag_set;
+ hbool_t verbose = FALSE;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
@@ -3255,23 +3655,23 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr,
HDassert( entry_ptr->header.is_protected );
HDassert( entry_ptr->is_protected );
- dirty_flag_set = ((flags & H5C__DIRTIED_FLAG) != 0 );
- pin_flag_set = ((flags & H5C__PIN_ENTRY_FLAG) != 0 );
- unpin_flag_set = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0 );
- size_changed_flag_set = ((flags & H5C__SIZE_CHANGED_FLAG) != 0 );
+ dirty_flag_set = (hbool_t)((flags & H5C__DIRTIED_FLAG) != 0 );
+ pin_flag_set = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0 );
+ unpin_flag_set = (hbool_t)((flags & H5C__UNPIN_ENTRY_FLAG) != 0 );
+ size_changed_flag_set = (hbool_t)((flags & H5C__SIZE_CHANGED_FLAG) != 0 );
HDassert ( ! ( pin_flag_set && unpin_flag_set ) );
HDassert ( ( ! pin_flag_set ) || ( ! (entry_ptr->is_pinned) ) );
HDassert ( ( ! unpin_flag_set ) || ( entry_ptr->is_pinned ) );
HDassert ( ( ! size_changed_flag_set ) || ( new_size > 0 ) );
- HDassert ( ( ! size_changed_flag_set ) ||
+ HDassert ( ( ! size_changed_flag_set ) ||
( type == VARIABLE_ENTRY_TYPE ) );
- entry_ptr->is_dirty = (entry_ptr->is_dirty || dirty_flag_set);
+ entry_ptr->is_dirty = (hbool_t)(entry_ptr->is_dirty || dirty_flag_set);
if ( size_changed_flag_set ) {
- entry_ptr->is_dirty = TRUE;
+ entry_ptr->is_dirty = TRUE;
entry_ptr->size = new_size;
}
@@ -3285,6 +3685,39 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr,
( entry_ptr->size != entry_ptr->header.size ) ||
( entry_ptr->addr != entry_ptr->header.addr ) ) {
+ if ( verbose ) {
+
+ if ( result < 0 ) {
+ HDfprintf(stdout, "%s: H5C_unprotect() failed.\n", fcn_name);
+ }
+
+ if ( entry_ptr->header.is_protected ) {
+ HDfprintf(stdout, "%s: entry still protected?!?.\n",
+ fcn_name);
+ }
+
+ if ( entry_ptr->header.type != &(types[type]) ) {
+ HDfprintf(stdout,
+ "%s: entry has bad type after unprotect.\n",
+ fcn_name);
+ }
+
+ if ( entry_ptr->size != entry_ptr->header.size ) {
+ HDfprintf(stdout,
+ "%s: bad entry size after unprotect. e/a = %d/%d\n",
+ fcn_name,
+ (int)(entry_ptr->size),
+ (int)(entry_ptr->header.size));
+ }
+
+ if ( entry_ptr->addr != entry_ptr->header.addr ) {
+ HDfprintf(stdout,
+ "%s: bad entry addr after unprotect. e/a = 0x%llx/0x%llx\n",
+ fcn_name,
+ (long long)(entry_ptr->addr),
+ (long long)(entry_ptr->header.addr));
+ }
+ }
pass = FALSE;
failure_mssg = "error in H5C_unprotect().";
@@ -3296,12 +3729,14 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr,
if ( pin_flag_set ) {
HDassert ( entry_ptr->header.is_pinned );
+ entry_ptr->pinned_from_client = TRUE;
entry_ptr->is_pinned = TRUE;
} else if ( unpin_flag_set ) {
- HDassert ( ! ( entry_ptr->header.is_pinned ) );
- entry_ptr->is_pinned = FALSE;
+ HDassert ( entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache );
+ entry_ptr->pinned_from_client = FALSE;
+ entry_ptr->is_pinned = entry_ptr->pinned_from_cache;
}
}
@@ -3457,7 +3892,7 @@ row_major_scan_forward(H5C_t * cache_ptr,
( (idx + lag - 5) % 9 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(p-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(p-ro, %d, %d) ", type,
(idx + lag - 5));
protect_entry_ro(cache_ptr, type, (idx + lag - 5));
@@ -3468,7 +3903,7 @@ row_major_scan_forward(H5C_t * cache_ptr,
( (idx + lag - 6) % 11 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(p-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(p-ro, %d, %d) ", type,
(idx + lag - 6));
protect_entry_ro(cache_ptr, type, (idx + lag - 6));
@@ -3479,7 +3914,7 @@ row_major_scan_forward(H5C_t * cache_ptr,
( (idx + lag - 7) % 13 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(p-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(p-ro, %d, %d) ", type,
(idx + lag - 7));
protect_entry_ro(cache_ptr, type, (idx + lag - 7));
@@ -3490,7 +3925,7 @@ row_major_scan_forward(H5C_t * cache_ptr,
( (idx + lag - 7) % 9 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(u-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx + lag - 7));
unprotect_entry(cache_ptr, type, (idx + lag - 7),
@@ -3502,7 +3937,7 @@ row_major_scan_forward(H5C_t * cache_ptr,
( (idx + lag - 8) % 11 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(u-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx + lag - 8));
unprotect_entry(cache_ptr, type, (idx + lag - 8),
@@ -3514,7 +3949,7 @@ row_major_scan_forward(H5C_t * cache_ptr,
( (idx + lag - 9) % 13 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(u-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx + lag - 9));
unprotect_entry(cache_ptr, type, (idx + lag - 9),
@@ -3874,7 +4309,7 @@ row_major_scan_backward(H5C_t * cache_ptr,
( (idx - lag + 5) % 9 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(p-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(p-ro, %d, %d) ", type,
(idx - lag + 5));
protect_entry_ro(cache_ptr, type, (idx - lag + 5));
@@ -3885,7 +4320,7 @@ row_major_scan_backward(H5C_t * cache_ptr,
( (idx - lag + 6) % 11 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(p-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(p-ro, %d, %d) ", type,
(idx - lag + 6));
protect_entry_ro(cache_ptr, type, (idx - lag + 6));
@@ -3896,7 +4331,7 @@ row_major_scan_backward(H5C_t * cache_ptr,
( (idx - lag + 7) % 13 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(p-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(p-ro, %d, %d) ", type,
(idx - lag + 7));
protect_entry_ro(cache_ptr, type, (idx - lag + 7));
@@ -3907,7 +4342,7 @@ row_major_scan_backward(H5C_t * cache_ptr,
( (idx - lag + 7) % 9 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(u-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx - lag + 7));
unprotect_entry(cache_ptr, type, (idx - lag + 7),
@@ -3919,7 +4354,7 @@ row_major_scan_backward(H5C_t * cache_ptr,
( (idx - lag + 8) % 11 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(u-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx - lag + 8));
unprotect_entry(cache_ptr, type, (idx - lag + 8),
@@ -3931,7 +4366,7 @@ row_major_scan_backward(H5C_t * cache_ptr,
( (idx - lag + 9) % 13 == 0 ) ) {
if ( verbose )
- HDfprintf(stdout, "(u-ro, %d, %d) ", type,
+ HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx - lag + 9));
unprotect_entry(cache_ptr, type, (idx - lag + 9),
@@ -4611,3 +5046,217 @@ hl_col_major_scan_backward(H5C_t * cache_ptr,
} /* hl_col_major_scan_backward() */
+
+/*-------------------------------------------------------------------------
+ * Function: create_flush_dependency()
+ *
+ * Purpose: Create a 'flush dependency' between two entries.
+ *
+ * Do nothing if pass is false.
+ *
+ * Return: void
+ *
+ * Programmer: Quincey Koziol
+ * 3/16/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+create_flush_dependency(H5C_t * cache_ptr,
+ int32_t par_type,
+ int32_t par_idx,
+ int32_t chd_type,
+ int32_t chd_idx)
+{
+ HDassert( cache_ptr );
+ HDassert( ( 0 <= par_type ) && ( par_type < NUMBER_OF_ENTRY_TYPES ) );
+ HDassert( ( 0 <= par_idx ) && ( par_idx <= max_indices[par_type] ) );
+ HDassert( ( 0 <= chd_type ) && ( chd_type < NUMBER_OF_ENTRY_TYPES ) );
+ HDassert( ( 0 <= chd_idx ) && ( chd_idx <= max_indices[chd_type] ) );
+
+ if ( pass ) {
+ test_entry_t * par_base_addr; /* Base entry of parent's entry array */
+ test_entry_t * par_entry_ptr; /* Parent entry */
+ test_entry_t * chd_base_addr; /* Base entry of child's entry array */
+ test_entry_t * chd_entry_ptr; /* Child entry */
+ hbool_t par_is_pinned; /* Whether parent is already pinned */
+ herr_t result; /* API routine status */
+
+ /* Get parent entry */
+ par_base_addr = entries[par_type];
+ par_entry_ptr = &(par_base_addr[par_idx]);
+ par_is_pinned = par_entry_ptr->header.is_pinned;
+
+ /* Sanity check parent entry */
+ HDassert( par_entry_ptr->index == par_idx );
+ HDassert( par_entry_ptr->type == par_type );
+ HDassert( par_entry_ptr->header.is_protected );
+ HDassert( par_entry_ptr == par_entry_ptr->self );
+
+ /* Get parent entry */
+ chd_base_addr = entries[chd_type];
+ chd_entry_ptr = &(chd_base_addr[chd_idx]);
+
+ /* Sanity check child entry */
+ HDassert( chd_entry_ptr->index == chd_idx );
+ HDassert( chd_entry_ptr->type == chd_type );
+ HDassert( chd_entry_ptr == chd_entry_ptr->self );
+
+ result = H5C_create_flush_dependency(cache_ptr, par_entry_ptr,
+ chd_entry_ptr);
+
+ if ( ( result < 0 ) ||
+ ( !par_entry_ptr->header.is_pinned ) ||
+ ( !(par_entry_ptr->header.flush_dep_height > 0) ) ) {
+
+ pass = FALSE;
+ failure_mssg = "error in H5C_create_flush_dependency().";
+ } /* end if */
+
+ /* Update information about entries */
+ chd_entry_ptr->flush_dep_par_type = par_type;
+ chd_entry_ptr->flush_dep_par_idx = par_idx;
+ par_entry_ptr->child_flush_dep_height_rc[chd_entry_ptr->flush_dep_height]++;
+ par_entry_ptr->pinned_from_cache = TRUE;
+ if( !par_is_pinned )
+ par_entry_ptr->is_pinned = TRUE;
+
+ /* Check flush dependency heights */
+ while(chd_entry_ptr->flush_dep_height >= par_entry_ptr->flush_dep_height) {
+ unsigned prev_par_flush_dep_height = par_entry_ptr->flush_dep_height; /* Save the previous height */
+
+ par_entry_ptr->flush_dep_height = chd_entry_ptr->flush_dep_height + 1;
+
+ /* Check for parent entry being in flush dependency relationship */
+ if(par_entry_ptr->flush_dep_par_idx >= 0) {
+ /* Move parent & child entries up the flushd dependency 'chain' */
+ chd_entry_ptr = par_entry_ptr;
+ par_base_addr = entries[chd_entry_ptr->flush_dep_par_type];
+ par_entry_ptr = &(par_base_addr[chd_entry_ptr->flush_dep_par_idx]);
+
+ /* Adjust the ref. counts in new parent */
+ HDassert(par_entry_ptr->child_flush_dep_height_rc[prev_par_flush_dep_height] > 0);
+ par_entry_ptr->child_flush_dep_height_rc[prev_par_flush_dep_height]--;
+ par_entry_ptr->child_flush_dep_height_rc[chd_entry_ptr->flush_dep_height]++;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
+ return;
+
+} /* create_flush_dependency() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: destroy_flush_dependency()
+ *
+ * Purpose: Destroy a 'flush dependency' between two entries.
+ *
+ * Do nothing if pass is false.
+ *
+ * Return: void
+ *
+ * Programmer: Quincey Koziol
+ * 3/16/09
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+destroy_flush_dependency(H5C_t * cache_ptr,
+ int32_t par_type,
+ int32_t par_idx,
+ int32_t chd_type,
+ int32_t chd_idx)
+{
+ HDassert( cache_ptr );
+ HDassert( ( 0 <= par_type ) && ( par_type < NUMBER_OF_ENTRY_TYPES ) );
+ HDassert( ( 0 <= par_idx ) && ( par_idx <= max_indices[par_type] ) );
+ HDassert( ( 0 <= chd_type ) && ( chd_type < NUMBER_OF_ENTRY_TYPES ) );
+ HDassert( ( 0 <= chd_idx ) && ( chd_idx <= max_indices[chd_type] ) );
+
+ if ( pass ) {
+ test_entry_t * par_base_addr; /* Base entry of parent's entry array */
+ test_entry_t * par_entry_ptr; /* Parent entry */
+ test_entry_t * chd_base_addr; /* Base entry of child's entry array */
+ test_entry_t * chd_entry_ptr; /* Child entry */
+ unsigned chd_flush_dep_height; /* Child flush dep. height */
+
+ /* Get parent entry */
+ par_base_addr = entries[par_type];
+ par_entry_ptr = &(par_base_addr[par_idx]);
+
+ /* Sanity check parent entry */
+ HDassert( par_entry_ptr->index == par_idx );
+ HDassert( par_entry_ptr->type == par_type );
+ HDassert( par_entry_ptr->is_pinned );
+ HDassert( par_entry_ptr->pinned_from_cache );
+ HDassert( par_entry_ptr->flush_dep_height > 0 );
+ HDassert( par_entry_ptr == par_entry_ptr->self );
+
+ /* Get parent entry */
+ chd_base_addr = entries[chd_type];
+ chd_entry_ptr = &(chd_base_addr[chd_idx]);
+
+ /* Sanity check child entry */
+ HDassert( chd_entry_ptr->index == chd_idx );
+ HDassert( chd_entry_ptr->type == chd_type );
+ HDassert( chd_entry_ptr->flush_dep_height < par_entry_ptr->flush_dep_height );
+ HDassert( chd_entry_ptr == chd_entry_ptr->self );
+
+ if ( H5C_destroy_flush_dependency(cache_ptr, par_entry_ptr, chd_entry_ptr) < 0 ) {
+ pass = FALSE;
+ failure_mssg = "error in H5C_destroy_flush_dependency().";
+ } /* end if */
+
+ /* Update information about entries */
+ chd_entry_ptr->flush_dep_par_type = -1;
+ chd_entry_ptr->flush_dep_par_idx = -1;
+ par_entry_ptr->child_flush_dep_height_rc[chd_entry_ptr->flush_dep_height]--;
+
+ /* Check flush dependency heights */
+ chd_flush_dep_height = chd_entry_ptr->flush_dep_height;
+ while( 0 == par_entry_ptr->child_flush_dep_height_rc[chd_flush_dep_height] ) {
+ unsigned prev_par_flush_dep_height = par_entry_ptr->flush_dep_height; /* Save the previous height */
+ int i; /* Local index variable */
+
+ /* Check for new flush dependency height of parent */
+ for(i = (H5C__NUM_FLUSH_DEP_HEIGHTS - 1); i >= 0; i--)
+ if(par_entry_ptr->child_flush_dep_height_rc[i] > 0)
+ break;
+
+ HDassert((i + 1) <= (int)prev_par_flush_dep_height);
+
+ if((unsigned)(i + 1) < prev_par_flush_dep_height) {
+ par_entry_ptr->flush_dep_height = (unsigned)(i + 1);
+ if(i < 0) {
+ par_entry_ptr->pinned_from_cache = FALSE;
+ par_entry_ptr->is_pinned = par_entry_ptr->pinned_from_client;
+ } /* end if */
+
+ /* Check for parent entry being in flush dependency relationship */
+ if(par_entry_ptr->flush_dep_par_idx >= 0) {
+ /* Move parent & child entries up the flushd dependency 'chain' */
+ chd_entry_ptr = par_entry_ptr;
+ par_base_addr = entries[chd_entry_ptr->flush_dep_par_type];
+ par_entry_ptr = &(par_base_addr[chd_entry_ptr->flush_dep_par_idx]);
+
+ /* Adjust the ref. counts in new parent */
+ HDassert(par_entry_ptr->child_flush_dep_height_rc[prev_par_flush_dep_height] > 0);
+ par_entry_ptr->child_flush_dep_height_rc[prev_par_flush_dep_height]--;
+ par_entry_ptr->child_flush_dep_height_rc[chd_entry_ptr->flush_dep_height]++;
+ chd_flush_dep_height = prev_par_flush_dep_height;
+ } /* end if */
+ else
+ break;
+ } /* end if */
+ else
+ break;
+ } /* end while */
+ } /* end if */
+
+ return;
+
+} /* destroy_flush_dependency() */
+
diff --git a/test/cache_common.h b/test/cache_common.h
index e1d33f2..d150f2a 100644
--- a/test/cache_common.h
+++ b/test/cache_common.h
@@ -19,17 +19,23 @@
* This file contains common #defines, type definitions, and
* externs for tests of the cache implemented in H5C.c
*/
-#include "h5test.h"
-#include "H5Iprivate.h"
-#include "H5ACprivate.h"
+#ifndef _CACHE_COMMON_H
+#define _CACHE_COMMON_H
#define H5C_PACKAGE /*suppress error about including H5Cpkg */
+#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+/* Include library header files */
+#include "H5ACprivate.h"
#include "H5Cpkg.h"
+#include "H5Fpkg.h"
+#include "H5Iprivate.h"
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+/* Include test header files */
+#include "h5test.h"
-#include "H5Fpkg.h"
+/* Macro to make error reporting easier */
+#define CACHE_ERROR(s) {failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s ; pass = FALSE; goto done;}
#define NO_CHANGE -1
@@ -45,8 +51,9 @@
#define HUGE_ENTRY_TYPE 7
#define MONSTER_ENTRY_TYPE 8
#define VARIABLE_ENTRY_TYPE 9
+#define NOTIFY_ENTRY_TYPE 10
-#define NUMBER_OF_ENTRY_TYPES 10
+#define NUMBER_OF_ENTRY_TYPES 11
#define PICO_ENTRY_SIZE (size_t)1
#define NANO_ENTRY_SIZE (size_t)4
@@ -58,6 +65,7 @@
#define HUGE_ENTRY_SIZE (size_t)(16 * 1024)
#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024)
#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024)
+#define NOTIFY_ENTRY_SIZE (size_t)1
#define NUM_PICO_ENTRIES (10 * 1024)
#define NUM_NANO_ENTRIES (10 * 1024)
@@ -69,6 +77,7 @@
#define NUM_HUGE_ENTRIES (10 * 1024)
#define NUM_MONSTER_ENTRIES (10 * 1024)
#define NUM_VARIABLE_ENTRIES (10 * 1024)
+#define NUM_NOTIFY_ENTRIES (10 * 1024)
#define MAX_ENTRIES (10 * 1024)
@@ -91,9 +100,11 @@
(HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES))
#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + \
(MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES))
+#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \
+ (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES))
-#define PICO_ALT_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \
- (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES))
+#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + \
+ (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES))
#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + \
(PICO_ENTRY_SIZE * NUM_PICO_ENTRIES))
#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + \
@@ -112,6 +123,8 @@
(HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES))
#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + \
(MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES))
+#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + \
+ (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES))
#define MAX_PINS 8 /* Maximum number of entries that can be
* directly pinned by a single entry.
@@ -121,10 +134,11 @@
#define FLUSH_OP__DIRTY 1
#define FLUSH_OP__RESIZE 2
#define FLUSH_OP__RENAME 3
-#define FLUSH_OP__MAX_OP 3
+#define FLUSH_OP__ORDER 4
+#define FLUSH_OP__MAX_OP 4
#define MAX_FLUSH_OPS 10 /* Maximum number of flush operations
- * that can be associated with a
+ * that can be associated with a
* cache entry.
*/
@@ -138,6 +152,7 @@ typedef struct flush_op
* FLUSH_OP__DIRTY
* FLUSH_OP__RESIZE
* FLUSH_OP__RENAME
+ * FLUSH_OP__ORDER
*/
int type; /* type code of the cache entry that
* is the target of the operation.
@@ -151,32 +166,36 @@ typedef struct flush_op
* function implementing the flush
* operation.
*/
- hbool_t flag; /* boolean flag passed into the
+ hbool_t flag; /* boolean flag passed into the
* function implementing the flush
* operation. The meaning of the
* flag is dependant upon the flush
* operation:
*
- * FLUSH_OP__DIRTY: TRUE iff the
- * target is pinned, and is to
- * be dirtied via the
+ * FLUSH_OP__DIRTY: TRUE iff the
+ * target is pinned, and is to
+ * be dirtied via the
* H5C_mark_pinned_entry_dirty()
* call.
*
* FLUSH_OP__RESIZE: TRUE iff the
- * target is pinned, and is to
- * be resized via the
+ * target is pinned, and is to
+ * be resized via the
* H5C_mark_pinned_entry_dirty()
* call.
*
* FLUSH_OP__RENAME: TRUE iff the
- * target is to be renamed to
+ * target is to be renamed to
* its main address.
*/
- size_t size; /* New target size in the
+ size_t size; /* New target size in the
* FLUSH_OP__RENAME operation.
* Unused elsewhere.
*/
+ unsigned * order_ptr; /* Pointer to outside counter for
+ * recording the order of entries
+ * flushed.
+ */
} flush_op;
typedef struct test_entry_t
@@ -224,7 +243,7 @@ typedef struct test_entry_t
hbool_t is_protected; /* entry should currently be on
* the cache's protected list.
*/
- hbool_t is_read_only; /* TRUE iff the entry should be
+ hbool_t is_read_only; /* TRUE iff the entry should be
* protected read only.
*/
int ro_ref_count; /* Number of outstanding read only
@@ -250,14 +269,14 @@ typedef struct test_entry_t
* entries pinned by this entry.
*/
int num_flush_ops; /* integer field containing the
- * number of flush operations to
- * be executed when the entry is
+ * number of flush operations to
+ * be executed when the entry is
* flushed. This value must lie in
- * the closed interval
+ * the closed interval
* [0, MAX_FLUSH_OPS].
*/
struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances
- * of struct flush_op detailing the
+ * of struct flush_op detailing the
* flush operations (if any) that
* are to be executed when the entry
* is flushed from the cache.
@@ -265,14 +284,14 @@ typedef struct test_entry_t
* num_flush_ops contains the number
* of valid entries in this array.
*/
- hbool_t flush_op_self_resize_in_progress; /* Boolean flag
- * that is set to TRUE iff this
+ hbool_t flush_op_self_resize_in_progress; /* Boolean flag
+ * that is set to TRUE iff this
* entry is being flushed, it has
* been resized by a resize flush
* op, and the flush function has
* not yet returned, This field is
- * used to turn off overactive santity
- * checking code that would otherwise
+ * used to turn off overactive santity
+ * checking code that would otherwise
* cause a false test failure.
*/
hbool_t loaded; /* entry has been loaded since the
@@ -287,6 +306,19 @@ typedef struct test_entry_t
hbool_t destroyed; /* entry has been destroyed since the
* last time it was reset.
*/
+ int flush_dep_par_type; /* Entry type of flush dependency parent */
+ int flush_dep_par_idx; /* Index of flush dependency parent */
+ uint64_t child_flush_dep_height_rc[H5C__NUM_FLUSH_DEP_HEIGHTS];
+ /* flush dependency heights of flush
+ * dependency children
+ */
+ unsigned flush_dep_height; /* flush dependency height of entry */
+ hbool_t pinned_from_client; /* entry was pinned by client call */
+ hbool_t pinned_from_cache; /* entry was pinned by cache internally */
+ unsigned flush_order; /* Order that entry was flushed in */
+
+ unsigned notify_after_insert_count; /* Count of times that entry was inserted in cache */
+ unsigned notify_before_evict_count; /* Count of times that entry was removed in cache */
} test_entry_t;
/* The following is a cut down copy of the hash table manipulation
@@ -451,6 +483,14 @@ struct expected_entry_status
hbool_t cleared;
hbool_t flushed;
hbool_t destroyed;
+ int flush_dep_par_type; /* Entry type of flush dependency parent */
+ int flush_dep_par_idx; /* Index of flush dependency parent */
+ uint64_t child_flush_dep_height_rc[H5C__NUM_FLUSH_DEP_HEIGHTS];
+ /* flush dependency heights of flush
+ * dependency children
+ */
+ unsigned flush_dep_height; /* flush dependency height of entry */
+ int flush_order; /* flush order of entry */
};
@@ -500,6 +540,7 @@ herr_t large_clear(H5F_t * f, void * thing, hbool_t dest);
herr_t huge_clear(H5F_t * f, void * thing, hbool_t dest);
herr_t monster_clear(H5F_t * f, void * thing, hbool_t dest);
herr_t variable_clear(H5F_t * f, void * thing, hbool_t dest);
+herr_t notify_clear(H5F_t * f, void * thing, hbool_t dest);
herr_t pico_dest(H5F_t * f, void * thing);
@@ -512,6 +553,7 @@ herr_t large_dest(H5F_t * f, void * thing);
herr_t huge_dest(H5F_t * f, void * thing);
herr_t monster_dest(H5F_t * f, void * thing);
herr_t variable_dest(H5F_t * f, void * thing);
+herr_t notify_dest(H5F_t * f, void * thing);
herr_t pico_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
@@ -534,6 +576,8 @@ herr_t monster_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
haddr_t addr, void *thing, unsigned * flags_ptr);
herr_t variable_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
haddr_t addr, void *thing, unsigned * flags_ptr);
+herr_t notify_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
void * pico_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
@@ -556,6 +600,8 @@ void * monster_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
const void *udata1, void *udata2);
void * variable_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
const void *udata1, void *udata2);
+void * notify_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
+ const void *udata1, void *udata2);
herr_t pico_size(H5F_t * f, void * thing, size_t * size_ptr);
@@ -568,6 +614,9 @@ herr_t large_size(H5F_t * f, void * thing, size_t * size_ptr);
herr_t huge_size(H5F_t * f, void * thing, size_t * size_ptr);
herr_t monster_size(H5F_t * f, void * thing, size_t * size_ptr);
herr_t variable_size(H5F_t * f, void * thing, size_t * size_ptr);
+herr_t notify_size(H5F_t * f, void * thing, size_t * size_ptr);
+
+herr_t notify_notify(H5C_notify_action_t action, void *thing);
/* callback table extern */
@@ -582,7 +631,8 @@ void add_flush_op(int target_type,
int type,
int idx,
hbool_t flag,
- size_t size);
+ size_t size,
+ unsigned * order);
void addr_to_type_and_index(haddr_t addr,
@@ -632,6 +682,10 @@ void protect_entry_ro(H5C_t * cache_ptr,
int32_t type,
int32_t idx);
+void pin_entry(H5C_t * cache_ptr,
+ int32_t type,
+ int32_t idx);
+
hbool_t entry_in_cache(H5C_t * cache_ptr,
int32_t type,
int32_t idx);
@@ -784,3 +838,17 @@ void verify_entry_status(H5C_t * cache_ptr,
void verify_unprotected(void);
+void create_flush_dependency(H5C_t * cache_ptr,
+ int32_t parent_type,
+ int32_t parent_idx,
+ int32_t child_type,
+ int32_t child_idx);
+
+void destroy_flush_dependency(H5C_t * cache_ptr,
+ int32_t parent_type,
+ int32_t parent_idx,
+ int32_t child_type,
+ int32_t child_idx);
+
+#endif /* _CACHE_COMMON_H */
+
diff --git a/test/chunk_info.c b/test/chunk_info.c
index 48db292..68bf774 100644
--- a/test/chunk_info.c
+++ b/test/chunk_info.c
@@ -34,17 +34,17 @@
int main( void )
{
-
+
hid_t fid; /* file ID */
hid_t did; /* dataset ID */
hid_t f_sid; /* file space ID */
hid_t m_sid; /* memory space ID */
hid_t pid; /* property list ID */
hsize_t start[2]; /* chunk location to start writing */
- hsize_t dims[2] = { 4, 4};
+ hsize_t dims[2] = { 4, 4};
hsize_t chunk_dims[2] = { 2, 2 };
- int chunk_data[2][2] = { {1, 1}, {1, 1} };
- int buf[4][4];
+ int chunk_data[2][2] = { {1, 1}, {1, 1} };
+ int buf[4][4];
int fillvalue = 0;
int i, j, ii, jj;
@@ -82,22 +82,22 @@ int main( void )
/* iterate in dim 0 */
for (j = 0; j < chunk_dims[0]; j++)
{
-
+
/* reset start in dim 1 */
start[1] = 0;
-
+
/* iterate in dim 1 */
for (i = 0; i < chunk_dims[1]; i++)
{
-
+
/* select file hyperslab to save a 2x2 chunk */
if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, chunk_dims, NULL) < 0) TEST_ERROR;
-
+
/* write the data to the hyperslab. */
- if (H5Dwrite(did, H5T_NATIVE_INT, m_sid, f_sid, H5P_DEFAULT, chunk_data) < 0) TEST_ERROR;
-
- /* read back and display complete dataset 4x4 */
- if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+ if (H5Dwrite(did, H5T_NATIVE_INT, m_sid, f_sid, H5P_DEFAULT, chunk_data) < 0) TEST_ERROR;
+
+ /* read back and display complete dataset 4x4 */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
#if defined (PRINT_DATA)
@@ -108,14 +108,14 @@ int main( void )
printf("\n");
}
#endif
-
-
+
+
/* increment start in dim 1 */
start[1] += 2;
-
-
+
+
}
-
+
/* increment start in dim 0 */
start[0] += 2;
}
@@ -134,7 +134,7 @@ int main( void )
if (H5Fclose(fid) < 0) TEST_ERROR
PASSED();
-
+
puts("All chunk info tests passed.");
return 0;
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index a03d37e..d565e82 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -23,6 +23,7 @@
#define H5T_PACKAGE
#include "H5Tpkg.h" /*to turn off hardware conversions*/
+#include "H5Iprivate.h"
#include "h5test.h"
@@ -115,11 +116,12 @@ typedef struct {
float f, g, h[16], i, j;
double k, l, m, n;
long o, p, q;
- long_long r, s, t;
+ long long r, s, t;
} stype4;
#define NX 100u
#define NY 2000u
+#define PACK_NMEMBS 100
/*-------------------------------------------------------------------------
@@ -197,6 +199,7 @@ test_compound (char *filename, hid_t fapl)
hsize_t f_offset[2]; /*offset of hyperslab in file */
hsize_t h_size[2]; /*size of hyperslab */
hsize_t memb_size[1] = {4};
+ int ret_code;
/* Create the file */
if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
@@ -207,8 +210,19 @@ test_compound (char *filename, hid_t fapl)
if ((space = H5Screate_simple (2, dim, NULL)) < 0) goto error;
/* Create xfer properties to preserve initialized data */
- if ((PRESERVE = H5Pcreate (H5P_DATASET_XFER)) < 0) goto error;
- if (H5Pset_preserve (PRESERVE, 1) < 0) goto error;
+ /* Also verify H5Pset_preserve is initially 0 and then is set to 1. */
+ if ((PRESERVE = H5Pcreate (H5P_DATASET_XFER))<0) goto error;
+ if ((ret_code=H5Pget_preserve (PRESERVE)) != 0){
+ printf("Preserve status of dataset transfer property list should be"
+ " 0 (FALSE), got %d\n", ret_code);
+ goto error;
+ }
+ if (H5Pset_preserve (PRESERVE, 1)<0) goto error;
+ if ((ret_code=H5Pget_preserve (PRESERVE)) != 1){
+ printf("Preserve status of dataset transfer property list should be"
+ " 1 (TRUE), got %d\n", ret_code);
+ goto error;
+ }
/*
*######################################################################
@@ -600,7 +614,7 @@ test_compound (char *filename, hid_t fapl)
if ((s8_m_sid = H5Screate_simple (2, h_size, NULL)) < 0) goto error;
/* Read the dataset */
- s8 = calloc ((size_t)(h_size[0]*h_size[1]), sizeof(s1_t));
+ s8 = (s1_t *) calloc ((size_t)(h_size[0]*h_size[1]), sizeof(s1_t));
assert (s8);
if (H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5P_DEFAULT, s8) < 0) {
goto error;
@@ -767,7 +781,7 @@ test_compound (char *filename, hid_t fapl)
f_offset[1] = NY/3;
h_size[0] = 2*NX/3 - f_offset[0];
h_size[1] = 2*NY/3 - f_offset[1];
- s11 = malloc ((size_t)h_size[0]*(size_t)h_size[1]*sizeof(s4_t));
+ s11 = (s4_t *) malloc ((size_t)h_size[0]*(size_t)h_size[1]*sizeof(s4_t));
assert (s11);
/* Initialize */
@@ -935,7 +949,7 @@ initialize_stype2(unsigned char *buf, const size_t num)
*
* Purpose: Initialize data buffer.
*
- * Return: Success:
+ * Return: Success:
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1019,7 +1033,7 @@ initialize_stype4(unsigned char *buf, const size_t num)
*
* Return: Success: datatype ID
*
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1053,7 +1067,7 @@ create_stype1(void)
H5Tinsert(tid, "k", HOFFSET(stype1, k), H5T_NATIVE_DOUBLE) < 0 ||
H5Tinsert(tid, "l", HOFFSET(stype1, l), H5T_NATIVE_DOUBLE) < 0 ||
H5Tinsert(tid, "m", HOFFSET(stype1, m), H5T_NATIVE_DOUBLE) < 0 ||
- H5Tinsert(tid, "n", HOFFSET(stype1, n), H5T_NATIVE_DOUBLE) < 0)
+ H5Tinsert(tid, "n", HOFFSET(stype1, n), H5T_NATIVE_DOUBLE) < 0)
goto error;
if(H5Tclose(array_dt1) < 0)
@@ -1075,7 +1089,7 @@ error:
*
* Return: Success: datatype ID
*
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1134,7 +1148,7 @@ error:
*
* Return: Success: datatype ID
*
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1177,7 +1191,7 @@ error:
*
* Return: Success: datatype ID
*
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1239,7 +1253,7 @@ error:
*
* Return: Success: 0
*
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1286,14 +1300,14 @@ compare_data(void *src_data, void *dst_data, hbool_t src_subset)
printf(" i=%d\n", i);
printf(" src={a=%d, b=%d, c=[%d,%d,%d,%d,%d,%d,%d,%d], d=%d, e=%d, f=%f, g=%f, h=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f], i=%f, j=%f, k=%f, l=%f, m=%f, n=%f}\n",
s_ptr->a, s_ptr->b, s_ptr->c[0], s_ptr->c[1], s_ptr->c[2],
- s_ptr->c[3], s_ptr->c[4], s_ptr->c[5], s_ptr->c[6], s_ptr->c[7],
+ s_ptr->c[3], s_ptr->c[4], s_ptr->c[5], s_ptr->c[6], s_ptr->c[7],
s_ptr->d, s_ptr->e, s_ptr->f, s_ptr->g,s_ptr->h[0],s_ptr->h[1],s_ptr->h[2],
s_ptr->h[3],s_ptr->h[4],s_ptr->h[5],s_ptr->h[6],s_ptr->h[7],s_ptr->h[8],
s_ptr->h[9],s_ptr->h[10],s_ptr->h[11],s_ptr->h[12],s_ptr->h[13],s_ptr->h[14],
s_ptr->h[15], s_ptr->i,s_ptr->j,s_ptr->k,s_ptr->l,s_ptr->m,s_ptr->n);
printf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d,%d,%d,%d,%d], d=%d, e=%d, f=%f, g=%f, h=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f], i=%f, j=%f, k=%f, l=%f, m=%f, n=%f}\n",
d_ptr->a, d_ptr->b, d_ptr->c[0], d_ptr->c[1], d_ptr->c[2],
- d_ptr->c[3], d_ptr->c[4], d_ptr->c[5], d_ptr->c[6], d_ptr->c[7],
+ d_ptr->c[3], d_ptr->c[4], d_ptr->c[5], d_ptr->c[6], d_ptr->c[7],
d_ptr->d, d_ptr->e, d_ptr->f, d_ptr->g,d_ptr->h[0],d_ptr->h[1],d_ptr->h[2],
d_ptr->h[3],d_ptr->h[4],d_ptr->h[5],d_ptr->h[6],d_ptr->h[7],d_ptr->h[8],
d_ptr->h[9],d_ptr->h[10],d_ptr->h[11],d_ptr->h[12],d_ptr->h[13],
@@ -1330,7 +1344,7 @@ error:
* Failure: 1
*
* Programmer: Raymond Lu
- * Friday, 15 June 2007
+ * Friday, 15 June 2007
*
* Modifications:
*-------------------------------------------------------------------------
@@ -1338,7 +1352,7 @@ error:
static int
test_hdf5_src_subset(char *filename, hid_t fapl)
{
- hid_t file;
+ hid_t file;
hid_t rew_tid, src_tid, dst_tid;
hid_t dataset;
hid_t space;
@@ -1415,7 +1429,7 @@ test_hdf5_src_subset(char *filename, hid_t fapl)
/*
*######################################################################
- * STEP 2. Rewrite the data with a subset of original data type.
+ * STEP 2. Rewrite the data with a subset of original data type.
*/
TESTING("rewriting data with a subset of original data type");
@@ -1463,7 +1477,7 @@ test_hdf5_src_subset(char *filename, hid_t fapl)
if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0)
FAIL_STACK_ERROR
- if(compare_data(orig, rbuf, TRUE) < 0)
+ if(compare_data(orig, rbuf, TRUE) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
@@ -1476,7 +1490,7 @@ test_hdf5_src_subset(char *filename, hid_t fapl)
if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0)
FAIL_STACK_ERROR
- if(compare_data(orig, rbuf, TRUE) < 0)
+ if(compare_data(orig, rbuf, TRUE) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
@@ -1527,15 +1541,15 @@ error:
* TYPE4 D; }
* TYPE5 E;
* };
- * This optimization is for the Chicago company. This test
- * is in opposite of test_hdf5_src_subset.
+ * This optimization is for the Chicago company. This test
+ * is in opposite of test_hdf5_src_subset.
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Raymond Lu
- * Friday, 15 June 2007
+ * Friday, 15 June 2007
*
* Modifications:
*-------------------------------------------------------------------------
@@ -1543,7 +1557,7 @@ error:
static int
test_hdf5_dst_subset(char *filename, hid_t fapl)
{
- hid_t file;
+ hid_t file;
hid_t rew_tid, src_tid, dst_tid;
hid_t dataset;
hid_t space;
@@ -1619,7 +1633,7 @@ test_hdf5_dst_subset(char *filename, hid_t fapl)
/*
*######################################################################
- * STEP 2. Rewrite the data with a subset of original data type.
+ * STEP 2. Rewrite the data with a subset of original data type.
*/
TESTING("rewriting data with a subset of original data type");
@@ -1667,7 +1681,7 @@ test_hdf5_dst_subset(char *filename, hid_t fapl)
if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0)
goto error;
- if(compare_data(orig, rbuf, FALSE) < 0)
+ if(compare_data(orig, rbuf, FALSE) < 0)
goto error;
if(H5Dclose(dataset) < 0)
@@ -1680,7 +1694,7 @@ test_hdf5_dst_subset(char *filename, hid_t fapl)
if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0)
goto error;
- if(compare_data(orig, rbuf, FALSE) < 0)
+ if(compare_data(orig, rbuf, FALSE) < 0)
goto error;
if(H5Dclose(dataset) < 0)
@@ -1717,16 +1731,436 @@ error:
return 1;
}
+/* Error macro that outputs the state of the randomly generated variables so the
+ * failure can be reproduced */
+#define PACK_OOO_ERROR \
+{ \
+ int _i; \
+ H5_FAILED(); AT(); \
+ printf(" Insertion order ="); \
+ for(_i=0; _i<PACK_NMEMBS; _i++) \
+ printf(" %d", order[_i]); \
+ printf("\n Inner compound order = %d, location = %d\n", sub_cmpd_order, order[sub_cmpd_order]); \
+ fflush(stdout); \
+ goto error; \
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_pack_ooo
+ *
+ * Purpose: Test inserting fields into a compound out of offset order.
+ * Verifies that the compound is correctly marked as packed
+ * or non-packed.
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Neil Fortner
+ * Thursday, 22 January 2009
+ *
+ * Modifications:
+ *-------------------------------------------------------------------------
+ */
+static int
+test_pack_ooo(void)
+{
+ hid_t cmpd, sub_cmpd; /* Datatype IDs */
+ H5T_t *dt; /* Datatype pointer */
+ unsigned order[PACK_NMEMBS]; /* Order of insertion */
+ unsigned free_order[PACK_NMEMBS]; /* Index of remaining free slots in order */
+ unsigned num_free; /* Number of free slots in order */
+ unsigned sub_cmpd_order; /* Order to insert the inner compound */
+ char name[6]; /* Member name */
+ unsigned extra_space; /* Whether to add extra space to the end of
+ * the compound */
+ unsigned i, j; /* Indices */
+
+ HDsrand((unsigned) time(NULL));
+
+ /* Initialize "free_order" array to indicate that all slots in order are
+ * free */
+ for(i=0; i<PACK_NMEMBS; i++)
+ free_order[i] = i;
+
+ /* Create "order" array */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ /* Generate index into free_order array */
+ num_free = PACK_NMEMBS - i;
+ j = HDrand() % num_free;
+
+ /* Update order array at the randomly generated (but guaranteed to be
+ * free) location */
+ order[free_order[j]] = i;
+
+ /* Reshape free_order to remove j (which is no longer free) */
+ if(j < (num_free - 1))
+ HDmemmove(&free_order[j], &free_order[j+1], (num_free - j - 1) * sizeof(free_order[0]));
+ } /* end for */
+
+ /* Generate order to insert inner compound type */
+ sub_cmpd_order = HDrand() % PACK_NMEMBS;
+
+ for(extra_space=0; extra_space<2; extra_space ++) {
+ if(extra_space)
+ puts("With extra space at the end of compound...");
+ else
+ puts("Without extra space at the end of compound...");
+
+ TESTING("random member insertion with empty compound subtype");
+
+ /* Create inner compound type. It will be empty for the first run */
+ if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR
+
+ /* Create main compound type, with extra space at the end */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
+
+ /* Insert the compound members in the random order previously generated */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ sprintf(name, "%05d", i);
+ if(i == sub_cmpd_order) {
+ if(H5Tinsert(cmpd, name, 4 * order[i], sub_cmpd) < 0) PACK_OOO_ERROR
+ } else
+ if(H5Tinsert(cmpd, name, 4 * order[i], H5T_STD_I32BE) < 0) PACK_OOO_ERROR
+ } /* end for */
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
+ if(dt->shared->u.compnd.packed) PACK_OOO_ERROR
+
+ /* Close the main compound */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+
+ PASSED();
+
+ TESTING("random member insertion with full compound subtype");
+
+ /* Complete the inner compound type */
+ if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR
+
+ /* Recreate main compound type */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
+
+ /* Insert the compound members in the random order previously generated */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ sprintf(name, "%05d", i);
+ if(i == sub_cmpd_order) {
+ if(H5Tinsert(cmpd, name, 4 * order[i], sub_cmpd) < 0) PACK_OOO_ERROR
+ } else
+ if(H5Tinsert(cmpd, name, 4 * order[i], H5T_STD_I32BE) < 0) PACK_OOO_ERROR
+ } /* end for */
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
+ if(dt->shared->u.compnd.packed != !extra_space) PACK_OOO_ERROR
+
+ /* Close */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
+
+ PASSED();
+
+ TESTING("reverse member insertion with empty compound subtype");
+
+ /* Create inner compound type. It will be empty for the first run */
+ if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR
+
+ /* Create main compound type, with extra space at the end */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
+
+ /* Insert the compound members in reverse order, with compound last */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ sprintf(name, "%05d", i);
+ if(i == PACK_NMEMBS - 1) {
+ if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), sub_cmpd) < 0) PACK_OOO_ERROR
+ } else
+ if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), H5T_STD_I32BE) < 0) PACK_OOO_ERROR
+ } /* end for */
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
+ if(dt->shared->u.compnd.packed) PACK_OOO_ERROR
+
+ /* Close the main compound */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+
+ PASSED();
+
+ TESTING("reverse member insertion with full compound subtype");
+
+ /* Complete the inner compound type */
+ if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR
+
+ /* Recreate main compound type */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
+
+ /* Insert the compound members in reverse order, with compound last */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ sprintf(name, "%05d", i);
+ if(i == PACK_NMEMBS - 1) {
+ if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), sub_cmpd) < 0) PACK_OOO_ERROR
+ } else
+ if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), H5T_STD_I32BE) < 0) PACK_OOO_ERROR
+ } /* end for */
+
+ /* Verify that the compound is packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
+ if(dt->shared->u.compnd.packed != !extra_space) PACK_OOO_ERROR
+
+ /* Close */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
+
+ PASSED();
+
+ TESTING("forward member insertion with empty compound subtype");
+
+ /* Create inner compound type. It will be empty for the first run */
+ if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR
+
+ /* Create main compound type, with extra space at the end */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
+
+ /* Insert the compound members in forward order, with compound first */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ sprintf(name, "%05d", i);
+ if(i == 0) {
+ if(H5Tinsert(cmpd, name, 4 * i, sub_cmpd) < 0) PACK_OOO_ERROR
+ } else
+ if(H5Tinsert(cmpd, name, 4 * i, H5T_STD_I32BE) < 0) PACK_OOO_ERROR
+ } /* end for */
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
+ if(dt->shared->u.compnd.packed) PACK_OOO_ERROR
+
+ /* Close the main compound */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+
+ PASSED();
+
+ TESTING("forward member insertion with full compound subtype");
+
+ /* Complete the inner compound type */
+ if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR
+
+ /* Recreate main compound type */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
+
+ /* Insert the compound members in forward order */
+ for(i=0; i<PACK_NMEMBS; i++) {
+ sprintf(name, "%05d", i);
+ if(i == 0) {
+ if(H5Tinsert(cmpd, name, 4 * i, sub_cmpd) < 0) PACK_OOO_ERROR
+ } else
+ if(H5Tinsert(cmpd, name, 4 * i, H5T_STD_I32BE) < 0) PACK_OOO_ERROR
+ } /* end for */
+
+ /* Verify that the compound is packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
+ if(dt->shared->u.compnd.packed != !extra_space) PACK_OOO_ERROR
+
+ /* Close */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
+
+ PASSED();
+ } /* end for */
+
+ return 0;
+
+error:
+ puts("*** DATASET TESTS FAILED ***");
+ return 1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_ooo_order
+ *
+ * Purpose: Test inserting fields into a compound out of offset order.
+ * Verifies that the order of compound members is the same as
+ * the order in which they were inserted. While this is
+ * explicitly not guaranteed by the documentation, the H5TB
+ * API currently makes this assumption.
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Neil Fortner
+ * Monday, 19 October 2009
+ *
+ * Modifications:
+ *-------------------------------------------------------------------------
+ */
+static int
+test_ooo_order(char *filename)
+{
+ hid_t file = -1; /* File ID */
+ hid_t dtype = -1; /* Datatype IDs */
+ hid_t dtype_tmp = -1; /* Temp Datatype ID */
+ H5T_t *dt = NULL; /* Datatype pointer */
+
+ TESTING("that compound member insertion order is preserved")
+
+ /* Create the file */
+ if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create the compound */
+ if((dtype = H5Tcreate(H5T_COMPOUND, 20)) < 0) TEST_ERROR
+ if(H5Tinsert(dtype, "A", 8, H5T_STD_I32LE) < 0) TEST_ERROR
+ if(H5Tinsert(dtype, "B", 12, H5T_STD_I32LE) < 0) TEST_ERROR
+ if(H5Tinsert(dtype, "C", 0, H5T_STD_I32LE) < 0) TEST_ERROR
+ if(H5Tinsert(dtype, "D", 16, H5T_STD_I32LE) < 0) TEST_ERROR
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(dt->shared->u.compnd.packed) TEST_ERROR
+
+ /* Verify that the order is the same as the insertion order */
+ if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR
+
+ /* Commit the datatype */
+ if(H5Tcommit2(file, "dtype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close and reopen the file */
+ if(H5Tclose(dtype)) TEST_ERROR
+ if(H5Fclose(file)) TEST_ERROR
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Open the type */
+ if((dtype_tmp = H5Topen2(file, "dtype", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype_tmp, H5I_DATATYPE)))
+ TEST_ERROR
+ if(dt->shared->u.compnd.packed) TEST_ERROR
+
+ /* Verify that the order is the same as the insertion order */
+ if(H5Tget_member_offset(dtype_tmp, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 3) != 16) TEST_ERROR
+
+ /* Copy the datatype */
+ if((dtype = H5Tcopy(dtype_tmp)) < 0) TEST_ERROR
+
+ /* Verify that the compound is not packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(dt->shared->u.compnd.packed) TEST_ERROR
+
+ /* Verify that the order is the same as the insertion order */
+ if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR
+
+ /* Insert the last member */
+ if(H5Tinsert(dtype, "E", 4, H5T_STD_I32LE) < 0) TEST_ERROR
+
+ /* Verify that the compound is packed */
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(!dt->shared->u.compnd.packed) TEST_ERROR
+
+ /* Verify that the order is the same as the insertion order */
+ if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR
+
+ /* Commit the modified datatype */
+ if(H5Tcommit2(file, "dtype2", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close and reopen the file */
+ if(H5Tclose(dtype_tmp)) TEST_ERROR
+ if(H5Tclose(dtype)) TEST_ERROR
+ if(H5Fclose(file)) TEST_ERROR
+ if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Open the type, and verify status */
+ if((dtype_tmp = H5Topen2(file, "dtype2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype_tmp, H5I_DATATYPE)))
+ TEST_ERROR
+ if(!dt->shared->u.compnd.packed) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 3) != 16) TEST_ERROR
+ if(H5Tget_member_offset(dtype_tmp, 4) != 4) TEST_ERROR
+
+ /* Copy the datatype, and verify status */
+ if((dtype = H5Tcopy(dtype_tmp)) < 0) TEST_ERROR
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(!dt->shared->u.compnd.packed) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR
+
+ /* Expand the type, and verify that it became unpacked */
+ if(H5Tset_size(dtype, 21) < 0) TEST_ERROR
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(dt->shared->u.compnd.packed) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR
+
+ /* Shrink the type, and verify that it became packed */
+ if(H5Tset_size(dtype, 20) < 0) TEST_ERROR
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(!dt->shared->u.compnd.packed) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR
+ if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR
+
+ /* Close */
+ if(H5Tclose(dtype_tmp)) TEST_ERROR
+ if(H5Tclose(dtype)) TEST_ERROR
+ if(H5Fclose(file)) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(dtype_tmp);
+ H5Tclose(dtype);
+ H5Fclose(file);
+ } H5E_END_TRY
+ puts("*** DATASET TESTS FAILED ***");
+ return 1;
+} /* test_ooo_order */
+
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: Test different cases of I/O for compound data and the
+ * Purpose: Test different cases of I/O for compound data and the
* compound optimization for the Chicago company.
*
* Return: Success: 0
*
- * Failure: 1
+ * Failure: 1
*
* Programmer: Raymond Lu
* Friday, 15 June 2007
@@ -1768,6 +2202,12 @@ main (int argc, char *argv[])
h5_fixname(FILENAME[2], fapl_id, fname, sizeof(fname));
nerrors += test_hdf5_dst_subset(fname, fapl_id);
+ puts("Testing that compound types can be packed out of order:");
+ nerrors += test_pack_ooo();
+
+ puts("Testing compound member ordering:");
+ nerrors += test_ooo_order(fname);
+
if (nerrors) {
printf("***** %u FAILURE%s! *****\n",
nerrors, 1==nerrors?"":"S");
diff --git a/test/corrupt_stab_msg.h5 b/test/corrupt_stab_msg.h5
new file mode 100755
index 0000000..4fa287c
--- /dev/null
+++ b/test/corrupt_stab_msg.h5
Binary files differ
diff --git a/test/dangle.c b/test/dangle.c
index b08a5e6..2f8a67e 100644
--- a/test/dangle.c
+++ b/test/dangle.c
@@ -111,13 +111,13 @@ test_dangle_dataset(H5F_close_degree_t degree)
if(H5Fclose(fid) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
+ if(h5_get_file_size(filename, fapl) < 0)
TEST_ERROR;
- if(H5close() < 0)
+ if(H5Pclose(fapl) < 0)
TEST_ERROR;
- if(h5_get_file_size(filename) < 0)
+ if(H5close() < 0)
TEST_ERROR;
/* Clean up temporary file */
@@ -202,13 +202,13 @@ test_dangle_group(H5F_close_degree_t degree)
if(H5Fclose(fid) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
+ if(h5_get_file_size(filename, fapl) < 0)
TEST_ERROR;
- if(H5close() < 0)
+ if(H5Pclose(fapl) < 0)
TEST_ERROR;
- if(h5_get_file_size(filename) < 0)
+ if(H5close() < 0)
TEST_ERROR;
/* Clean up temporary file */
@@ -298,13 +298,13 @@ test_dangle_datatype1(H5F_close_degree_t degree)
if(H5Fclose(fid) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
+ if(h5_get_file_size(filename, fapl) < 0)
TEST_ERROR;
- if(H5close() < 0)
+ if(H5Pclose(fapl) < 0)
TEST_ERROR;
- if(h5_get_file_size(filename) < 0)
+ if(H5close() < 0)
TEST_ERROR;
/* Clean up temporary file */
@@ -385,13 +385,13 @@ test_dangle_datatype2(H5F_close_degree_t degree)
if(H5Fclose(fid) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
+ if(h5_get_file_size(filename, fapl) < 0)
TEST_ERROR;
- if(H5close() < 0)
+ if(H5Pclose(fapl) < 0)
TEST_ERROR;
- if(h5_get_file_size(filename) < 0)
+ if(H5close() < 0)
TEST_ERROR;
/* Clean up temporary file */
@@ -492,13 +492,13 @@ test_dangle_attribute(H5F_close_degree_t degree)
if(H5Fclose(fid) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
+ if(h5_get_file_size(filename, fapl) < 0)
TEST_ERROR;
- if(H5close() < 0)
+ if(H5Pclose(fapl) < 0)
TEST_ERROR;
- if(h5_get_file_size(filename) < 0)
+ if(H5close() < 0)
TEST_ERROR;
/* Clean up temporary file */
diff --git a/test/dsets.c b/test/dsets.c
index d0b2098..b4c6a84 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -34,6 +34,7 @@
#define H5Z_PACKAGE
#include "H5Zpkg.h"
+
const char *FILENAME[] = {
"dataset",
"compact_dataset",
@@ -43,6 +44,9 @@ const char *FILENAME[] = {
"set_local",
"random_chunks",
"huge_chunks",
+ "chunk_cache",
+ "big_chunk",
+ "chunk_expand",
NULL
};
#define FILENAME_BUF_SIZE 1024
@@ -96,6 +100,7 @@ const char *FILENAME[] = {
#define DSET_DEPREC_NAME "deprecated"
#define DSET_DEPREC_NAME_CHUNKED "deprecated_chunked"
#define DSET_DEPREC_NAME_COMPACT "deprecated_compact"
+#define DSET_DEPREC_NAME_FILTER "deprecated_filter"
#define USER_BLOCK 1024
#define SIXTY_FOUR_KB 65536
@@ -103,7 +108,10 @@ const char *FILENAME[] = {
/* Temporary filter IDs used for testing */
#define H5Z_FILTER_BOGUS 305
#define H5Z_FILTER_CORRUPT 306
-#define H5Z_FILTER_BOGUS2 307
+#define H5Z_FILTER_CAN_APPLY_TEST 307
+#define H5Z_FILTER_SET_LOCAL_TEST 308
+#define H5Z_FILTER_DEPREC 309
+#define H5Z_FILTER_EXPAND 310
/* Flags for testing filters */
#define DISABLE_FLETCHER32 0
@@ -131,10 +139,13 @@ const char *FILENAME[] = {
#define FILTER_HS_SIZE2 50
/* Names for noencoder test */
+#ifdef H5_HAVE_FILTER_SZIP
#define NOENCODER_FILENAME "noencoder.h5"
+#define NOENCODER_COPY_FILENAME "noencoder.h5.copy"
#define NOENCODER_TEST_DATASET "noencoder_tdset.h5"
#define NOENCODER_SZIP_DATASET "noencoder_szip_dset.h5"
#define NOENCODER_SZIP_SHUFF_FLETCH_DATASET "noencoder_szip_shuffle_fletcher_dset.h5"
+#endif /* H5_HAVE_FILTER_SZIP */
/* Names for zero-dim test */
#define ZERODIM_DATASET "zerodim"
@@ -162,6 +173,13 @@ const char *FILENAME[] = {
#define TOO_HUGE_CHUNK_DIM2_1 ((hsize_t)1024)
#define TOO_HUGE_CHUNK_DIM2_2 ((hsize_t)1024)
+/* Parameters for testing bypassing chunk cache */
+#define BYPASS_DATASET1 "Dset1"
+#define BYPASS_DATASET2 "Dset2"
+#define BYPASS_DIM 1000
+#define BYPASS_CHUNK_DIM 500
+#define BYPASS_FILL_VALUE 7
+
/* Shared global arrays */
#define DSET_DIM1 100
#define DSET_DIM2 200
@@ -177,6 +195,8 @@ static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
static size_t filter_corrupt(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+static size_t filter_expand(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
/*-------------------------------------------------------------------------
@@ -355,7 +375,7 @@ test_create(hid_t file)
*-------------------------------------------------------------------------
*/
static herr_t
-test_simple_io(hid_t fapl)
+test_simple_io(const char *env_h5_drvr, hid_t fapl)
{
char filename[FILENAME_BUF_SIZE];
hid_t file, dataset, space, xfer;
@@ -368,83 +388,91 @@ test_simple_io(hid_t fapl)
TESTING("simple I/O");
- h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
- /* Initialize the dataset */
- for(i = n = 0; i < DSET_DIM1; i++)
- for(j = 0; j < DSET_DIM2; j++)
- points[i][j] = n++;
+ /* Initialize the dataset */
+ for(i = n = 0; i < DSET_DIM1; i++)
+ for(j = 0; j < DSET_DIM2; j++)
+ points[i][j] = n++;
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- goto error;
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
- /* Create the data space */
- dims[0] = DSET_DIM1;
- dims[1] = DSET_DIM2;
- if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error;
+ /* Create the data space */
+ dims[0] = DSET_DIM1;
+ dims[1] = DSET_DIM2;
+ if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error;
- /* Create a small conversion buffer to test strip mining */
- tconv_buf = HDmalloc((size_t)1000);
- xfer = H5Pcreate(H5P_DATASET_XFER);
- assert(xfer>=0);
- if(H5Pset_buffer (xfer, (size_t)1000, tconv_buf, NULL) < 0) goto error;
+ /* Create a small conversion buffer to test strip mining */
+ tconv_buf = HDmalloc((size_t)1000);
+ xfer = H5Pcreate(H5P_DATASET_XFER);
+ assert(xfer>=0);
+ if(H5Pset_buffer (xfer, (size_t)1000, tconv_buf, NULL) < 0) goto error;
- /* Create the dataset */
- if((dataset = H5Dcreate2(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
+ /* Create the dataset */
+ if((dataset = H5Dcreate2(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
- /* Test dataset address. Should be undefined. */
- if(H5Dget_offset(dataset) != HADDR_UNDEF) goto error;
+ /* Test dataset address. Should be undefined. */
+ if(H5Dget_offset(dataset) != HADDR_UNDEF) goto error;
- /* Write the data to the dataset */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points) < 0)
- goto error;
+ /* Write the data to the dataset */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points) < 0)
+ goto error;
- /* Test dataset address in file. Open the same file as a C file, seek
- * the data position as H5Dget_offset points to, read the dataset, and
- * compare it with the data written in.*/
- if((offset=H5Dget_offset(dataset))==HADDR_UNDEF) goto error;
+ /* Test dataset address in file. Open the same file as a C file, seek
+ * the data position as H5Dget_offset points to, read the dataset, and
+ * compare it with the data written in.*/
+ if((offset=H5Dget_offset(dataset))==HADDR_UNDEF) goto error;
- /* Read the dataset back */
- if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check) < 0)
- goto error;
+ /* Read the dataset back */
+ if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check) < 0)
+ goto error;
- /* Check that the values read are the same as the values written */
- for(i = 0; i < DSET_DIM1; i++) {
- for(j = 0; j < DSET_DIM2; j++) {
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < DSET_DIM1; i++) {
+ for(j = 0; j < DSET_DIM2; j++) {
+ if(points[i][j] != check[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ }
+ }
+ }
- if(H5Pclose (xfer) < 0) goto error;
- if(H5Dclose(dataset) < 0) goto error;
- if(H5Fclose(file) < 0) goto error;
+ if(H5Pclose (xfer) < 0) goto error;
+ if(H5Dclose(dataset) < 0) goto error;
+ if(H5Fclose(file) < 0) goto error;
- f = HDopen(filename, O_RDONLY, 0);
- HDlseek(f, (off_t)offset, SEEK_SET);
- HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2);
+ f = HDopen(filename, O_RDONLY, 0);
+ HDlseek(f, (off_t)offset, SEEK_SET);
+ HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2);
- /* Check that the values read are the same as the values written */
- for(i = 0; i < DSET_DIM1; i++) {
- for(j = 0; j < DSET_DIM2; j++) {
- if(points[i][j] != rdata[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < DSET_DIM1; i++) {
+ for(j = 0; j < DSET_DIM2; j++) {
+ if(points[i][j] != rdata[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ }
+ }
+ }
- HDclose(f);
+ HDclose(f);
+
+ free (tconv_buf);
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support continuous address space");
+ } /* end else */
- free (tconv_buf);
- PASSED();
return 0;
error:
@@ -469,7 +497,7 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_userblock_offset(hid_t fapl)
+test_userblock_offset(const char *env_h5_drvr, hid_t fapl)
{
char filename[FILENAME_BUF_SIZE];
hid_t file, fcpl, dataset, space;
@@ -481,54 +509,62 @@ test_userblock_offset(hid_t fapl)
TESTING("dataset offset with user block");
- h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
- if((fcpl=H5Pcreate(H5P_FILE_CREATE)) < 0) goto error;
- if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) goto error;
+ if((fcpl=H5Pcreate(H5P_FILE_CREATE)) < 0) goto error;
+ if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) goto error;
- if((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
- goto error;
+ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ goto error;
- /* Create the data space */
- dims[0] = DSET_DIM1;
- dims[1] = DSET_DIM2;
- if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error;
+ /* Create the data space */
+ dims[0] = DSET_DIM1;
+ dims[1] = DSET_DIM2;
+ if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error;
- /* Create the dataset */
- if((dataset = H5Dcreate2(file, DSET_USERBLOCK_IO_NAME, H5T_NATIVE_INT, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
+ /* Create the dataset */
+ if((dataset = H5Dcreate2(file, DSET_USERBLOCK_IO_NAME, H5T_NATIVE_INT, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
- /* Write the data to the dataset */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- goto error;
+ /* Write the data to the dataset */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ goto error;
- /* Test dataset address in file. Open the same file as a C file, seek
- * the data position as H5Dget_offset points to, read the dataset, and
- * compare it with the data written in.*/
- if((offset = H5Dget_offset(dataset)) == HADDR_UNDEF) goto error;
+ /* Test dataset address in file. Open the same file as a C file, seek
+ * the data position as H5Dget_offset points to, read the dataset, and
+ * compare it with the data written in.*/
+ if((offset = H5Dget_offset(dataset)) == HADDR_UNDEF) goto error;
- if(H5Dclose(dataset) < 0) goto error;
- if(H5Fclose(file) < 0) goto error;
+ if(H5Dclose(dataset) < 0) goto error;
+ if(H5Fclose(file) < 0) goto error;
- f = HDopen(filename, O_RDONLY, 0);
- HDlseek(f, (off_t)offset, SEEK_SET);
- HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2);
+ f = HDopen(filename, O_RDONLY, 0);
+ HDlseek(f, (off_t)offset, SEEK_SET);
+ HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2);
- /* Check that the values read are the same as the values written */
- for(i = 0; i < DSET_DIM1; i++) {
- for(j = 0; j < DSET_DIM2; j++) {
- if(points[i][j] != rdata[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < DSET_DIM1; i++) {
+ for(j = 0; j < DSET_DIM2; j++) {
+ if(points[i][j] != rdata[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ }
+ }
+ }
- HDclose(f);
+ HDclose(f);
+
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support continuous address space");
+ } /* end else */
- PASSED();
return 0;
error:
@@ -674,7 +710,9 @@ test_max_compact(hid_t fapl)
compact_size = (SIXTY_FOUR_KB-64)/sizeof(int);
wbuf = (int*)HDmalloc(sizeof(int)*(size_t)compact_size);
+ assert(wbuf);
rbuf = (int*)HDmalloc(sizeof(int)*(size_t)compact_size);
+ assert(rbuf);
n=0;
for(i=0; i<(int)compact_size; i++)
@@ -731,8 +769,9 @@ test_max_compact(hid_t fapl)
if(H5Dclose(dataset) < 0) goto error;
if(H5Fclose(file) < 0) goto error;
HDfree(wbuf);
+ wbuf = NULL;
HDfree(rbuf);
-
+ rbuf = NULL;
/* Test compact dataset of size 64KB */
@@ -766,6 +805,19 @@ test_max_compact(hid_t fapl)
return 0;
error:
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+
+ H5E_BEGIN_TRY {
+ /* Close file */
+ H5Sclose(space);
+ H5Pclose(plist);
+ H5Fclose(file);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
}
@@ -937,25 +989,25 @@ error:
static herr_t
test_tconv(hid_t file)
{
- char *out=NULL, *in=NULL;
- int i;
+ char *out = NULL, *in = NULL;
hsize_t dims[1];
- hid_t space, dataset;
+ hid_t space = -1, dataset = -1;
+ int i;
- out = HDmalloc((size_t)(4 * 1000 * 1000));
+ out = (char *)HDmalloc((size_t)(4 * 1000 * 1000));
HDassert(out);
- in = HDmalloc((size_t)(4 * 1000 * 1000));
+ in = (char *)HDmalloc((size_t)(4 * 1000 * 1000));
HDassert(in);
TESTING("data type conversion");
/* Initialize the dataset */
for(i = 0; i < 1000000; i++) {
- out[i*4+0] = 0x11;
- out[i*4+1] = 0x22;
- out[i*4+2] = 0x33;
- out[i*4+3] = 0x44;
- }
+ out[i * 4 + 0] = 0x11;
+ out[i * 4 + 1] = 0x22;
+ out[i * 4 + 2] = 0x33;
+ out[i * 4 + 3] = 0x44;
+ } /* end for */
/* Create the data space */
dims[0] = 1000000;
@@ -972,32 +1024,44 @@ test_tconv(hid_t file)
/* Read data with byte order conversion */
if(H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in) < 0)
- goto error;
+ goto error;
/* Check */
for(i = 0; i < 1000000; i++) {
- if(in[4*i+0]!=out[4*i+3] ||
- in[4*i+1]!=out[4*i+2] ||
- in[4*i+2]!=out[4*i+1] ||
- in[4*i+3]!=out[4*i+0]) {
- H5_FAILED();
- puts(" Read with byte order conversion failed.");
- goto error;
- }
+ if(in[4 * i + 0] != out[4 * i + 3] ||
+ in[4 * i + 1] != out[4 * i + 2] ||
+ in[4 * i + 2] != out[4 * i + 1] ||
+ in[4 * i + 3] != out[4 * i + 0]) {
+ H5_FAILED();
+ puts(" Read with byte order conversion failed.");
+ goto error;
+ }
}
if(H5Dclose(dataset) < 0) goto error;
- free (out);
- free (in);
+ if(H5Sclose(space) < 0) goto error;
+ HDfree(out);
+ HDfree(in);
+
puts(" PASSED");
return 0;
- error:
+error:
+ if(out)
+ HDfree(out);
+ if(in)
+ HDfree(in);
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Sclose(space);
+ } H5E_END_TRY;
+
return -1;
}
/* This message derives from H5Z */
-const H5Z_class_t H5Z_BOGUS[1] = {{
+const H5Z_class2_t H5Z_BOGUS[1] = {{
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_BOGUS, /* Filter id number */
1, 1, /* Encoding and decoding enabled */
@@ -1089,7 +1153,7 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
add_on=(unsigned)H5Tget_size(type_id);
/* Get the filter's current parameters */
- if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_BOGUS2, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0)
+ if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0)
return(FAIL);
/* Check that the parameter values were passed along correctly */
@@ -1099,11 +1163,11 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
return(FAIL);
/* Set "local" parameters for this dataset */
- cd_values[2]=(add_on>0); /* Flag to indicate data is modified */
+ cd_values[2]=(unsigned)(add_on>0); /* Flag to indicate data is modified */
cd_values[3]=add_on; /* Amount the data was modified by */
/* Modify the filter's parameters for this dataset */
- if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_BOGUS2, flags, (size_t)BOGUS2_ALL_NPARMS,
+ if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, flags, (size_t)BOGUS2_ALL_NPARMS,
cd_values) < 0)
return(FAIL);
@@ -1153,12 +1217,12 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts,
/* "Compressing" */
else {
unsigned add_on=cd_values[3]; /* Get "add on" value */
- int *int_ptr=*buf; /* Pointer to the data values */
+ int *int_ptr=(int *)*buf; /* Pointer to the data values */
size_t buf_left=*buf_size; /* Amount of data buffer left to process */
/* Add the "add on" value to all the data values */
while(buf_left>0) {
- *int_ptr++ += add_on;
+ *int_ptr++ += (int)add_on;
buf_left -= sizeof(int);
} /* end while */
} /* end else */
@@ -1171,7 +1235,7 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts,
}
/* This message derives from H5Z */
-const H5Z_class_t H5Z_CORRUPT[1] = {{
+const H5Z_class2_t H5Z_CORRUPT[1] = {{
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_CORRUPT, /* Filter id number */
1, 1, /* Encoding and decoding enabled */
@@ -1205,19 +1269,19 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes,
size_t *buf_size, void **buf)
{
- size_t ret_value = 0;
+ void *data;
unsigned char *dst = (unsigned char*)(*buf);
unsigned int offset;
unsigned int length;
unsigned int value;
- void *data;
+ size_t ret_value = 0;
- if(cd_nelmts!=3 || !cd_values)
+ if(cd_nelmts != 3 || !cd_values)
return 0;
offset = cd_values[0];
length = cd_values[1];
value = cd_values[2];
- if(offset>nbytes || (offset+length)>nbytes || length<sizeof(unsigned int))
+ if(offset > nbytes || (offset + length) > nbytes || length < sizeof(unsigned int))
return 0;
data = HDmalloc((size_t)length);
@@ -1225,15 +1289,19 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts,
if(flags & H5Z_FLAG_REVERSE) { /* Varify data is actually corrupted during read */
dst += offset;
- if(HDmemcmp(data, dst, (size_t)length)!=0) return 0;
- *buf_size = nbytes;
- ret_value = nbytes;
- } else { /* Write corrupted data */
+ if(HDmemcmp(data, dst, (size_t)length) != 0)
+ ret_value = 0;
+ else {
+ *buf_size = nbytes;
+ ret_value = nbytes;
+ } /* end else */
+ } /* end if */
+ else { /* Write corrupted data */
dst += offset;
HDmemcpy(dst, data, (size_t)length);
*buf_size = nbytes;
- ret_value = *buf_size;
- }
+ ret_value = *buf_size;
+ } /* end else */
if(data)
HDfree(data);
@@ -1367,8 +1435,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
*/
TESTING(" filters (uninitialized read)");
- if(H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
- goto error;
+ if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
+ TEST_ERROR;
for(i=0; i<(size_t)size[0]; i++) {
for(j=0; j<(size_t)size[1]; j++) {
@@ -1657,12 +1725,14 @@ error:
* Monday, June 7, 2004
*
* Modifications:
+ * Make copy of data file since the test writes to the file.
+ * Larry Knox, October 14, 2009
*
*-------------------------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_SZIP
static herr_t
-test_filter_noencoder(const char *dset_name, hid_t fapl)
+test_filter_noencoder(const char *dset_name)
{
hid_t file_id = -1;
hid_t dset_id = -1;
@@ -1674,20 +1744,14 @@ test_filter_noencoder(const char *dset_name, hid_t fapl)
int test_ints[10] = { 12 };
int read_buf[10];
int i;
- char * srcdir = HDgetenv("srcdir"); /* The source directory */
- char testfile[512]=""; /* Buffer to hold name of test file */
-
- /*
- * Create the name of the file to open (in case we are using the --srcdir
- * option and the file is in a different directory from this test).
- */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(NOENCODER_FILENAME) + 1) < sizeof(testfile))) {
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, NOENCODER_FILENAME);
-
- file_id = H5Fopen(testfile, H5F_ACC_RDWR, fapl);
+
+ /* Make a local copy of the file since this test writes to the data file
+ from svn. */
+ if (h5_make_local_copy(NOENCODER_FILENAME, NOENCODER_COPY_FILENAME) < 0)
+ goto error;
+
+ /* Open file */
+ file_id = H5Fopen(NOENCODER_COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
if(file_id < 0) goto error;
dset_id = H5Dopen2(file_id, dset_name, H5P_DEFAULT);
@@ -1769,6 +1833,7 @@ error:
H5Pclose(dcpl_id);
if(file_id != -1)
H5Fclose(file_id);
+
return -1;
}
#endif /* H5_HAVE_FILTER_SZIP */
@@ -1874,7 +1939,7 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_filters(hid_t file, hid_t
+test_filters(hid_t file, hid_t
#ifndef H5_HAVE_FILTER_SZIP
UNUSED
#endif /* H5_HAVE_FILTER_SZIP */
@@ -2017,7 +2082,7 @@ UNUSED
if( h5_szip_can_encode() != 1) {
puts("");
- if(test_filter_noencoder(NOENCODER_SZIP_DATASET, fapl) < 0) goto error;
+ if(test_filter_noencoder(NOENCODER_SZIP_DATASET) < 0) goto error;
} else {
SKIPPED();
}
@@ -2112,7 +2177,7 @@ UNUSED
if( h5_szip_can_encode() != 1) {
puts("");
- if(test_filter_noencoder(NOENCODER_SZIP_SHUFF_FLETCH_DATASET,fapl) < 0) goto error;
+ if(test_filter_noencoder(NOENCODER_SZIP_SHUFF_FLETCH_DATASET) < 0) goto error;
} else {
SKIPPED();
}
@@ -2580,11 +2645,11 @@ test_nbit_int(hid_t file)
if((dataset = H5Dcreate2(file, DSET_NBIT_INT_NAME, datatype,
space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
- /* Initialize data, assuming size of long_long >= size of int */
+ /* Initialize data, assuming size of long long >= size of int */
for(i= 0;i< (size_t)size[0]; i++)
for(j = 0; j < (size_t)size[1]; j++) {
- orig_data[i][j] = (int)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision - 1))) << offset);
+ orig_data[i][j] = (int)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision - 1))) << offset);
/* even-numbered values are negtive */
if((i*size[1]+j+1)%2 == 0)
@@ -2629,7 +2694,7 @@ test_nbit_int(hid_t file)
/* Check that the values read are the same as the values written
* Use mask for checking the significant bits, ignoring the padding bits
*/
- mask = ~(~0 << (precision + offset)) & (~0 << offset);
+ mask = ~((unsigned)~0 << (precision + offset)) & ((unsigned)~0 << offset);
for(i=0; i<(size_t)size[0]; i++) {
for(j=0; j<(size_t)size[1]; j++) {
if((new_data[i][j] & mask) != (orig_data[i][j] & mask)) {
@@ -2890,7 +2955,7 @@ test_nbit_double(hid_t file)
goto error;
/* Check that the values read are the same as the values written
- * Assume size of long_long = size of double
+ * Assume size of long long = size of double
*/
for(i=0; i<(size_t)size[0]; i++) {
for(j=0; j<(size_t)size[1]; j++) {
@@ -2992,13 +3057,13 @@ test_nbit_array(hid_t file)
if((dataset = H5Dcreate2(file, DSET_NBIT_ARRAY_NAME, array_datatype,
space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
- /* Initialize data, assuming size of long_long >= size of unsigned int */
+ /* Initialize data, assuming size of long long >= size of unsigned int */
for(i= 0;i< (size_t)size[0]; i++)
for(j = 0; j < (size_t)size[1]; j++)
for(m = 0; m < (size_t)adims[0]; m++)
for(n = 0; n < (size_t)adims[1]; n++)
- orig_data[i][j][m][n] = (unsigned int)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)precision)) << offset);
+ orig_data[i][j][m][n] = (unsigned int)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)precision)) << offset);
PASSED();
#else
SKIPPED();
@@ -3174,21 +3239,21 @@ test_nbit_compound(hid_t file)
if((dataset = H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME, cmpd_tid,
space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
- /* Initialize data, assuming size of long_long >= size of member datatypes */
+ /* Initialize data, assuming size of long long >= size of member datatypes */
for(i= 0;i< (size_t)size[0]; i++)
for(j = 0; j < (size_t)size[1]; j++) {
- orig_data[i][j].i = (int)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[0]-1))) << offset[0]);
- orig_data[i][j].c = (char)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[1]-1))) << offset[1]);
- orig_data[i][j].s = (short)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[2]-1))) << offset[2]);
+ orig_data[i][j].i = (int)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[0]-1))) << offset[0]);
+ orig_data[i][j].c = (char)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[1]-1))) << offset[1]);
+ orig_data[i][j].s = (short)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[2]-1))) << offset[2]);
orig_data[i][j].f = float_val[i][j];
/* some even-numbered integer values are negtive */
if((i*size[1]+j+1)%2 == 0) {
orig_data[i][j].i = -orig_data[i][j].i;
- orig_data[i][j].s = -orig_data[i][j].s;
+ orig_data[i][j].s = (short)-orig_data[i][j].s;
}
}
@@ -3230,9 +3295,9 @@ test_nbit_compound(hid_t file)
/* Check that the values read are the same as the values written
* Use mask for checking the significant bits, ignoring the padding bits
*/
- i_mask = ~(~0 << (precision[0] + offset[0])) & (~0 << offset[0]);
- c_mask = ~(~0 << (precision[1] + offset[1])) & (~0 << offset[1]);
- s_mask = ~(~0 << (precision[2] + offset[2])) & (~0 << offset[2]);
+ i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]);
+ c_mask = ~((unsigned)~0 << (precision[1] + offset[1])) & ((unsigned)~0 << offset[1]);
+ s_mask = ~((unsigned)~0 << (precision[2] + offset[2])) & ((unsigned)~0 << offset[2]);
for(i=0; i<size[0]; i++) {
for(j=0; j<size[1]; j++) {
if((new_data[i][j].i & i_mask) != (orig_data[i][j].i & i_mask) ||
@@ -3421,33 +3486,33 @@ test_nbit_compound_2(hid_t file)
if((dataset = H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME_2, cmpd_tid2,
space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
- /* Initialize data, assuming size of long_long >= size of member datatypes */
+ /* Initialize data, assuming size of long long >= size of member datatypes */
for(i= 0;i< (size_t)size[0]; i++)
for(j = 0; j < (size_t)size[1]; j++) {
- orig_data[i][j].a.i = (int)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[0]-1))) << offset[0]);
- orig_data[i][j].a.c = (char)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[1]-1))) << offset[1]);
- orig_data[i][j].a.s = (short)(-((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[2]-1))) << offset[2]);
+ orig_data[i][j].a.i = (int)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[0]-1))) << offset[0]);
+ orig_data[i][j].a.c = (char)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[1]-1))) << offset[1]);
+ orig_data[i][j].a.s = (short)(-((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[2]-1))) << offset[2]);
orig_data[i][j].a.f = float_val[i][j];
- orig_data[i][j].v = (unsigned int)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)precision[3])) << offset[3]);
+ orig_data[i][j].v = (unsigned int)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)precision[3])) << offset[3]);
for(m = 0; m < (size_t)array_dims[0]; m++)
for(n = 0; n < (size_t)array_dims[1]; n++)
- orig_data[i][j].b[m][n] = (char)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[4]-1))) << offset[4]);
+ orig_data[i][j].b[m][n] = (char)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[4]-1))) << offset[4]);
for(m = 0; m < (size_t)array_dims[0]; m++)
for(n = 0; n < (size_t)array_dims[1]; n++) {
- orig_data[i][j].d[m][n].i = (int)(-((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[0]-1))) << offset[0]);
- orig_data[i][j].d[m][n].c = (char)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[1]-1))) << offset[1]);
- orig_data[i][j].d[m][n].s = (short)(((long_long)HDrandom() %
- (long_long)HDpow(2.0, (double)(precision[2]-1))) << offset[2]);
+ orig_data[i][j].d[m][n].i = (int)(-((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[0]-1))) << offset[0]);
+ orig_data[i][j].d[m][n].c = (char)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[1]-1))) << offset[1]);
+ orig_data[i][j].d[m][n].s = (short)(((long long)HDrandom() %
+ (long long)HDpow(2.0, (double)(precision[2]-1))) << offset[2]);
orig_data[i][j].d[m][n].f = float_val[i][j];
}
}
@@ -3490,10 +3555,10 @@ test_nbit_compound_2(hid_t file)
/* Check that the values read are the same as the values written
* Use mask for checking the significant bits, ignoring the padding bits
*/
- i_mask = ~(~0 << (precision[0] + offset[0])) & (~0 << offset[0]);
- c_mask = ~(~0 << (precision[1] + offset[1])) & (~0 << offset[1]);
- s_mask = ~(~0 << (precision[2] + offset[2])) & (~0 << offset[2]);
- b_mask = ~(~0 << (precision[4] + offset[4])) & (~0 << offset[4]);
+ i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]);
+ c_mask = ~((unsigned)~0 << (precision[1] + offset[1])) & ((unsigned)~0 << offset[1]);
+ s_mask = ~((unsigned)~0 << (precision[2] + offset[2])) & ((unsigned)~0 << offset[2]);
+ b_mask = ~((unsigned)~0 << (precision[4] + offset[4])) & ((unsigned)~0 << offset[4]);
for(i=0; i<(size_t)size[0]; i++) {
for(j=0; j<(size_t)size[1]; j++) {
b_failed = 0;
@@ -4768,11 +4833,11 @@ test_types(hid_t file)
}
/* This message derives from H5Z */
-const H5Z_class_t H5Z_CAN_APPLY_TEST[1] = {{
- H5Z_CLASS_T_VERS,
- H5Z_FILTER_BOGUS, /* Filter id number */
- 1, 1,
- "bogus", /* Filter name for debugging */
+const H5Z_class2_t H5Z_CAN_APPLY_TEST[1] = {{
+ H5Z_CLASS_T_VERS,
+ H5Z_FILTER_CAN_APPLY_TEST, /* Filter id number */
+ 1, 1,
+ "can_apply_test", /* Filter name for debugging */
can_apply_bogus, /* The "can apply" callback */
NULL, /* The "set local" callback */
filter_bogus, /* The actual filter function */
@@ -4822,7 +4887,7 @@ test_can_apply(hid_t file)
printf(" Line %d: Can't register 'can apply' filter\n",__LINE__);
goto error;
}
- if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) {
+ if(H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST, 0, (size_t)0, NULL) < 0) {
H5_FAILED();
printf(" Line %d: Can't set bogus filter\n",__LINE__);
goto error;
@@ -5128,11 +5193,11 @@ error:
/* This message derives from H5Z */
-const H5Z_class_t H5Z_SET_LOCAL_TEST[1] = {{
- H5Z_CLASS_T_VERS,
- H5Z_FILTER_BOGUS2, /* Filter id number */
- 1, 1,
- "bogus2", /* Filter name for debugging */
+const H5Z_class2_t H5Z_SET_LOCAL_TEST[1] = {{
+ H5Z_CLASS_T_VERS,
+ H5Z_FILTER_SET_LOCAL_TEST, /* Filter id number */
+ 1, 1,
+ "set_local_test", /* Filter name for debugging */
NULL, /* The "can apply" callback */
set_local_bogus2, /* The "set local" callback */
filter_bogus2, /* The actual filter function */
@@ -5202,7 +5267,7 @@ test_set_local(hid_t fapl)
printf(" Line %d: Can't register 'set local' filter\n",__LINE__);
goto error;
}
- if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS2, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) {
+ if(H5Pset_filter(dcpl, H5Z_FILTER_SET_LOCAL_TEST, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) {
H5_FAILED();
printf(" Line %d: Can't set bogus2 filter\n",__LINE__);
goto error;
@@ -5368,7 +5433,7 @@ test_set_local(hid_t fapl)
/* Check that the values read are the modified version of what was written */
for(i=0; i<dims[0]; i++) {
for(j=0; j<dims[1]; j++) {
- /* If the difference between two values is greater than 0.001%, they're
+ /* If the difference between two values is greater than 0.001%, they're
* considered not equal. */
if(!DBL_REL_EQUAL(points_dbl[i][j],check_dbl[i][j],0.00001)) {
H5_FAILED();
@@ -5515,6 +5580,7 @@ test_filter_delete(hid_t file)
hsize_t dims[2]={20,20}; /* dataspace dimensions */
hsize_t chunk_dims[2]={10,10}; /* chunk dimensions */
int nfilters; /* number of filters in DCPL */
+ unsigned flags; /* flags for filter */
herr_t ret; /* generic return value */
int i;
@@ -5555,6 +5621,16 @@ test_filter_delete(hid_t file)
goto error;
}
+ /* try to get the info for the deflate filter */
+ H5E_BEGIN_TRY {
+ ret=H5Pget_filter_by_id2(dcpl1,H5Z_FILTER_DEFLATE,&flags,NULL,NULL,0,NULL,NULL);
+ } H5E_END_TRY;
+ if(ret >=0) {
+ H5_FAILED();
+ printf(" Line %d: Shouldn't have deleted filter!\n",__LINE__);
+ goto error;
+ } /* end if */
+
/* try to delete the deflate filter again */
H5E_BEGIN_TRY {
ret=H5Premove_filter(dcpl1,H5Z_FILTER_DEFLATE);
@@ -5707,98 +5783,61 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_filters_endianess(hid_t fapl)
+test_filters_endianess(void)
{
hid_t fid=-1; /* file ID */
hid_t dsid=-1; /* dataset ID */
hid_t sid=-1; /* dataspace ID */
hid_t dcpl=-1; /* dataset creation property list ID */
- hsize_t dims[1]={2}; /* dataspace dimensions */
- hsize_t chunk_dims[1]={2}; /* chunk dimensions */
- int buf[2];
- int rank=1;
- int i;
char *srcdir = getenv("srcdir"); /* the source directory */
char data_file[512]=""; /* buffer to hold name of existing file */
- for(i=0; i<2; i++){
- buf[i]=1;
- }
-
TESTING("filters with big-endian/little-endian data");
#if defined H5_HAVE_FILTER_FLETCHER32
/*-------------------------------------------------------------------------
- * step1: create a file
- *-------------------------------------------------------------------------
- */
- /* create a file using default properties */
- if((fid = H5Fcreate("test_filters.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error;
-
- /* create a data space */
- if((sid = H5Screate_simple(rank,dims,NULL)) < 0) goto error;
-
- /* create dcpl */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk(dcpl,rank,chunk_dims) < 0) goto error;
-
- if(H5Pset_fletcher32 (dcpl) < 0) goto error;
-
- /* create a dataset */
- if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
-
- if(H5Dwrite(dsid,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
- goto error;
-
- /* close */
- if(H5Pclose (dcpl) < 0) goto error;
- if(H5Dclose (dsid) < 0) goto error;
- if(H5Sclose (sid) < 0) goto error;
- if(H5Fclose (fid) < 0) goto error;
-
- /*-------------------------------------------------------------------------
- * step 2: open a file written on a little-endian machine in step 1
+ * step 1: open a file written on a little-endian machine
*-------------------------------------------------------------------------
*/
/* compose the name of the file to open, using the srcdir, if appropriate */
HDstrcpy(data_file, "");
- if( srcdir ) {
+ if(srcdir) {
HDstrcpy(data_file, srcdir);
HDstrcat(data_file, "/");
}
- strcat( data_file, "test_filters_le.hdf5");
+ HDstrcat(data_file, "test_filters_le.hdf5");
/* open */
- if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error;
+ if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* read */
- if(auxread_fdata(fid,"dset") < 0) goto error;
+ if(auxread_fdata(fid,"dset") < 0) TEST_ERROR
/* close */
- if(H5Fclose(fid) < 0) goto error;
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/*-------------------------------------------------------------------------
- * step 3: open a file written on a big-endian machine in step 1
+ * step 2: open a file written on a big-endian machine
*-------------------------------------------------------------------------
*/
/* compose the name of the file to open, using the srcdir, if appropriate */
HDstrcpy(data_file, "");
- if( srcdir ) {
+ if(srcdir) {
HDstrcpy(data_file, srcdir);
HDstrcat(data_file, "/");
}
- HDstrcat( data_file, "test_filters_be.hdf5");
+ HDstrcat(data_file, "test_filters_be.hdf5");
/* open */
- if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error;
+ if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* read */
- if(auxread_fdata(fid,"dset") < 0) goto error;
+ if(auxread_fdata(fid,"dset") < 0) TEST_ERROR
/* close */
- if(H5Fclose(fid) < 0) goto error;
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
PASSED();
#else
@@ -5898,7 +5937,7 @@ test_missing_chunk(hid_t file)
/* Initialize data */
for(u=0; u<MISSING_CHUNK_DIM; u++) {
- wdata[u]=u;
+ wdata[u]=(int)u;
rdata[u]=911;
} /* end for */
@@ -6031,20 +6070,20 @@ test_random_chunks(hid_t fapl)
/* Generate random point coordinates. Only one point is selected per chunk */
for(i=0; i<NPOINTS; i++){
do {
- chunk_row = (int)HDrandom () % (dsize[0]/csize[0]);
- chunk_col = (int)HDrandom () % (dsize[1]/csize[1]);
+ chunk_row = (int)HDrandom () % (int)(dsize[0]/csize[0]);
+ chunk_col = (int)HDrandom () % (int)(dsize[1]/csize[1]);
} while (check2[chunk_row][chunk_col]);
wbuf[i] = check2[chunk_row][chunk_col] = chunk_row+chunk_col+1;
- coord[i][0] = chunk_row * csize[0];
- coord[i][1] = chunk_col * csize[1];
+ coord[i][0] = (hsize_t)chunk_row * csize[0];
+ coord[i][1] = (hsize_t)chunk_col * csize[1];
}
/* Create dataspace for write buffer */
if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR;
/* Select the random points for writing */
- if(H5Sselect_elements(s, H5S_SELECT_SET, NPOINTS, coord) < 0) TEST_ERROR;
+ if(H5Sselect_elements(s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR;
/* Write into dataset */
if(H5Dwrite(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, wbuf) < 0) TEST_ERROR;
@@ -6069,7 +6108,7 @@ test_random_chunks(hid_t fapl)
if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR;
/* Select the random points for reading */
- if(H5Sselect_elements (s, H5S_SELECT_SET, NPOINTS, coord) < 0) TEST_ERROR;
+ if(H5Sselect_elements (s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR;
/* Read from dataset */
if(H5Dread(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, rbuf) < 0) TEST_ERROR;
@@ -6121,20 +6160,20 @@ test_random_chunks(hid_t fapl)
/* Generate random point coordinates. Only one point is selected per chunk */
for(i = 0; i < NPOINTS; i++){
do {
- chunk_row = (int)HDrandom() % (nsize[0] / csize[0]);
- chunk_col = (int)HDrandom() % (nsize[1] / csize[1]);
+ chunk_row = (int)HDrandom() % (int)(nsize[0] / csize[0]);
+ chunk_col = (int)HDrandom() % (int)(nsize[1] / csize[1]);
} while (check2[chunk_row][chunk_col]);
wbuf[i] = check2[chunk_row][chunk_col] = chunk_row + chunk_col + 1;
- coord[i][0] = chunk_row * csize[0];
- coord[i][1] = chunk_col * csize[1];
+ coord[i][0] = (hsize_t)chunk_row * csize[0];
+ coord[i][1] = (hsize_t)chunk_col * csize[1];
}
/* Create dataspace for write buffer */
if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR;
/* Select the random points for writing */
- if(H5Sselect_elements(s, H5S_SELECT_SET, NPOINTS, coord) < 0) TEST_ERROR;
+ if(H5Sselect_elements(s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR;
/* Write into dataset */
if(H5Dwrite(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, wbuf) < 0) TEST_ERROR;
@@ -6159,7 +6198,7 @@ test_random_chunks(hid_t fapl)
if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR;
/* Select the random points for reading */
- if(H5Sselect_elements (s, H5S_SELECT_SET, NPOINTS, coord) < 0) TEST_ERROR;
+ if(H5Sselect_elements (s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR;
/* Read from dataset */
if(H5Dread(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, rbuf) < 0) TEST_ERROR;
@@ -6192,6 +6231,28 @@ error:
} /* end test_random_chunks() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
+/* Empty can_apply and set_local callbacks */
+static herr_t
+can_apply_deprec(hid_t UNUSED dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id)
+{
+ return 1;
+}
+
+static herr_t
+set_local_deprec(hid_t UNUSED dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id)
+{
+ return(SUCCEED);
+}
+
+/* Old style H5Z_class_t, essentially a copy of the "bogus" filter */
+const H5Z_class1_t H5Z_DEPREC[1] = {{
+ H5Z_FILTER_DEPREC, /* Filter id number */
+ "deprec", /* Filter name for debugging */
+ can_apply_deprec, /* The "can apply" callback */
+ set_local_deprec, /* The "set local" callback */
+ filter_bogus, /* The actual filter function */
+}};
+
/*-------------------------------------------------------------------------
* Function: test_deprec
@@ -6209,8 +6270,9 @@ error:
static herr_t
test_deprec(hid_t file)
{
- hid_t dataset, space, small_space, create_parms;
+ hid_t dataset, space, small_space, create_parms, dcpl;
hsize_t dims[2], small_dims[2];
+ hsize_t deprec_size;
herr_t status;
hsize_t csize[2];
@@ -6364,7 +6426,17 @@ test_deprec(hid_t file)
if((dataset = H5Dopen1(file, DSET_DEPREC_NAME_COMPACT)) < 0) goto error;
if(H5Dclose(dataset) < 0) goto error;
- PASSED();
+ /* Test H5Zregister with deprecated H5Z_class1_t */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if(H5Pset_chunk(dcpl, 2, csize) < 0) goto error;
+ if(H5Zregister(H5Z_DEPREC) < 0) goto error;
+ if(H5Pset_filter(dcpl, H5Z_FILTER_DEPREC, 0, (size_t)0, NULL) < 0) goto error;
+
+ puts("");
+ if(test_filter_internal(file,DSET_DEPREC_NAME_FILTER,dcpl,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&deprec_size) < 0) goto error;
+
+ if(H5Pclose(dcpl) < 0) goto error;
+
return 0;
error:
@@ -6486,6 +6558,723 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_chunk_cache
+ *
+ * Purpose: Tests API for setting rdcc info on a DAPL, and interaction
+ * with the corresponding properties in the file structure.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Wednesday, October 29, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_chunk_cache(hid_t fapl)
+{
+ char filename[FILENAME_BUF_SIZE];
+ hid_t fid = -1; /* File ID */
+ hid_t fapl_local = -1; /* Local fapl */
+ hid_t fapl_def = -1; /* Default fapl */
+ hid_t dcpl = -1; /* Dataset creation property list ID */
+ hid_t dapl1 = -1; /* Dataset access property list ID */
+ hid_t dapl2 = -1; /* Dataset access property list ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dsid = -1; /* Dataset ID */
+ hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */
+ size_t nslots_1, nslots_2, nslots_3, nslots_4; /* rdcc number of elements */
+ size_t nbytes_1, nbytes_2, nbytes_3, nbytes_4; /* rdcc number of bytes */
+ size_t nlinks; /* Number of link traversals */
+ double w0_1, w0_2, w0_3, w0_4; /* rdcc preemption policy */
+
+ TESTING("dataset chunk cache configuration");
+
+ /* Create a default fapl and dapl */
+ if ((fapl_def = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR
+ if ((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that H5Pget_chunk_cache(dapl) returns the same values as are in
+ * the default fapl.
+ */
+ if (H5Pget_cache(fapl_def, NULL, &nslots_1, &nbytes_1, &w0_1) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl1, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_1 != nslots_4) || (nbytes_1 != nbytes_4) || !DBL_ABS_EQUAL(w0_1, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from default dapl do not match those from fapl.")
+
+ /* Set a lapl property on dapl1 (to verify inheritance) */
+ if (H5Pset_nlinks(dapl1, 134) < 0) FAIL_STACK_ERROR
+ if (H5Pget_nlinks(dapl1, &nlinks) < 0) FAIL_STACK_ERROR
+ if (nlinks != 134)
+ FAIL_PUTS_ERROR(" nlinks parameter not set properly on dapl.")
+
+ /* Copy fapl passed to this function (as we will be modifying it) */
+ if ((fapl_local = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Set new rdcc settings on fapl */
+ nslots_2 = nslots_1 * 2;
+ nbytes_2 = nbytes_1 * 2;
+ w0_2 = w0_1 / 2.;
+ if (H5Pset_cache(fapl_local, 0, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR
+
+ h5_fixname(FILENAME[8], fapl, filename, sizeof filename);
+
+ /* Create file */
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) FAIL_STACK_ERROR
+
+ /* Create dataset creation property list */
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
+
+ /* Set chunking */
+ chunk_dim = 10;
+ if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
+
+ /* Create 1-D dataspace */
+ dim = 100;
+ if ((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR
+
+ /* Create dataset with default dapl */
+ if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve dapl from dataset, verfiy cache values are the same as on fapl_local */
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.")
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR
+
+ /* Set new values on dapl1. nbytes will be set to default, so the file
+ * property will override this setting */
+ nslots_3 = nslots_2 * 2;
+ nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT;
+ w0_3 = w0_2 / 2;
+ if (H5Pset_chunk_cache(dapl1, nslots_3, nbytes_3, w0_3) < 0) FAIL_STACK_ERROR
+
+ /* Close dataset, reopen with dapl1. Note the use of a dapl with H5Oopen */
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if ((dsid = H5Oopen(fid, "dset", dapl1)) < 0) FAIL_STACK_ERROR
+
+ /* Retrieve dapl from dataset, verfiy cache values are the same as on dapl1 */
+ /* Note we rely on the knowledge that H5Pget_chunk_cache retrieves these
+ * values directly from the dataset structure, and not from a copy of the
+ * dapl used to open the dataset (which is not preserved).
+ */
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_3 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl1.")
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR
+
+ /* Close dataset, reopen with H5P_DEFAULT as dapl */
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Retrieve dapl from dataset, verfiy cache values are the same on fapl_local */
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.")
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR
+
+ /* Similary, test use of H5Dcreate2 with H5P_DEFAULT */
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if ((dsid = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.")
+ /* Don't close dapl2, we will use it in the next section */
+
+ /* Modify cache values on fapl_local */
+ nbytes_3 = nbytes_2 * 2;
+ if (H5Pset_cache(fapl_local, 0, nslots_3, nbytes_3, w0_3) < 0) FAIL_STACK_ERROR
+
+ /* Close and reopen file with new fapl_local */
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_local)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that dapl2 retrieved earlier (using values from the old fapl)
+ * sets its values in the new file (test use of H5Dopen2 with a dapl)
+ */
+ if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl2.")
+
+ /* Test H5D_CHUNK_CACHE_NSLOTS_DEFAULT and H5D_CHUNK_CACHE_W0_DEFAULT */
+ nslots_2 = H5D_CHUNK_CACHE_NSLOTS_DEFAULT;
+ w0_2 = H5D_CHUNK_CACHE_W0_DEFAULT;
+ if (H5Pset_chunk_cache(dapl2, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR
+
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_3 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those expected.")
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the file has indeed started using the new cache values (test
+ * use of H5Oopen with H5P_DEFAULT) */
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if ((dsid = H5Oopen(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_3 != nslots_4) || (nbytes_3 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.")
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR
+
+ /* Verify functionality of H5Pcopy with a dapl */
+ if ((dapl2 = H5Pcopy(dapl1)) < 0) FAIL_STACK_ERROR
+ if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR
+ if ((nslots_3 != nslots_4) || (nbytes_1 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4))
+ FAIL_PUTS_ERROR(" Cache values from dapl2 do not match those from dapl1.")
+
+ /* Close */
+ if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if (H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(fapl_def) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(dapl1) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl_local);
+ H5Pclose(fapl_def);
+ H5Pclose(dapl1);
+ H5Pclose(dapl2);
+ H5Pclose(dcpl);
+ H5Dclose(dsid);
+ H5Sclose(sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_chunk_cache() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_big_chunks_bypass_cache
+ *
+ * Purpose: When the chunk size is bigger than the cache size and the
+ * chunk isn't on disk, this test verifies that the library
+ * bypasses the cache.
+ *
+ * Note: This test is not very conclusive - it doesn't actually check
+ * if the chunks bypass the cache... :-( -QAK
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Raymond Lu
+ * 11 Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_big_chunks_bypass_cache(hid_t fapl)
+{
+ char filename[FILENAME_BUF_SIZE];
+ hid_t fid = -1; /* File ID */
+ hid_t fapl_local = -1; /* File access property list ID */
+ hid_t dcpl = -1; /* Dataset creation property list ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dsid = -1; /* Dataset ID */
+ hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */
+ size_t rdcc_nelmts, rdcc_nbytes;
+ int fvalue = BYPASS_FILL_VALUE;
+ hsize_t count, stride, offset, block;
+ static int wdata[BYPASS_CHUNK_DIM/2], rdata1[BYPASS_DIM],
+ rdata2[BYPASS_CHUNK_DIM/2];
+ int i, j;
+
+ TESTING("big chunks bypassing the cache");
+
+ h5_fixname(FILENAME[9], fapl, filename, sizeof filename);
+
+ /* Copy fapl passed to this function (as we will be modifying it) */
+ if((fapl_local = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Define cache size to be smaller than chunk size */
+ rdcc_nelmts = BYPASS_CHUNK_DIM/5;
+ rdcc_nbytes = sizeof(int)*BYPASS_CHUNK_DIM/5;
+ if(H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, (double)0.0) < 0) FAIL_STACK_ERROR
+
+ /* Create file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) FAIL_STACK_ERROR
+
+ /* Create 1-D dataspace */
+ dim = BYPASS_DIM;
+ if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR
+
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
+
+ /* Define chunk size. There will be only 2 chunks in the dataset. */
+ chunk_dim = BYPASS_CHUNK_DIM;
+ if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
+
+ /* Define fill value, fill time, and chunk allocation time */
+ if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fvalue) < 0) FAIL_STACK_ERROR
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) FAIL_STACK_ERROR
+ if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) FAIL_STACK_ERROR
+
+ /* Create a first dataset */
+ if((dsid = H5Dcreate2(fid, BYPASS_DATASET1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Select first chunk to write the data */
+ offset = 0;
+ count = 1;
+ stride = 1;
+ block = BYPASS_CHUNK_DIM / 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &offset, &stride, &count, &block) < 0)
+ FAIL_STACK_ERROR
+
+ /* Initialize data to write */
+ for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++)
+ wdata[i] = i;
+
+ /* This write should go through the cache because fill value is used. */
+ if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, wdata) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+
+ /* Reopen the dataset */
+ if((dsid = H5Dopen2(fid, BYPASS_DATASET1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Reads both 2 chunks. Reading the second chunk should bypass the cache because the
+ * chunk is bigger than the cache size and it isn't allocated on disk. */
+ if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata1) < 0)
+ FAIL_STACK_ERROR
+
+ for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++)
+ if(rdata1[i] != i) {
+ printf(" Read different values than written in the 1st chunk.\n");
+ printf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], i);
+ TEST_ERROR
+ } /* end if */
+
+ for(j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++)
+ if(rdata1[j] != fvalue) {
+ printf(" Read different values than written in the 2nd chunk.\n");
+ printf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], fvalue);
+ TEST_ERROR
+ } /* end if */
+
+ /* Close the first dataset */
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+
+ /* Create a second dataset without fill value. This time, both write
+ * and read should bypass the cache because the chunk is bigger than the
+ * cache size and it's not allocated on disk. */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) FAIL_STACK_ERROR
+
+ if((dsid = H5Dcreate2(fid, BYPASS_DATASET2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, wdata) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+
+ /* Reopen the dataset */
+ if((dsid = H5Dopen2(fid, BYPASS_DATASET2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Read back only the part that was written to the file. Reading the
+ * half chunk should bypass the cache because the chunk is bigger than
+ * the cache size. */
+ if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0)
+
+ for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++)
+ if(rdata2[i] != i) {
+ printf(" Read different values than written in the chunk.\n");
+ printf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i);
+ TEST_ERROR
+ } /* end if */
+
+ /* Close IDs */
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Pclose(fapl_local);
+ H5Dclose(dsid);
+ H5Sclose(sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_big_chunks_bypass_cache() */
+
+/* This message derives from H5Z */
+const H5Z_class2_t H5Z_EXPAND[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_EXPAND, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "expand", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ filter_expand, /* The actual filter function */
+}};
+
+/* Global "expansion factor" for filter_expand() routine */
+static size_t filter_expand_factor_g = 0;
+
+
+/*-------------------------------------------------------------------------
+ * Function: filter_expand
+ *
+ * Purpose: For testing library's behavior when a filter expands a chunk
+ * too much.
+ *
+ * Note: This filter doesn't actually re-allocate the buffer to be
+ * larger, it just changes the buffer size to a value that's too
+ * large. The library should throw an error before using the
+ * incorrect buffer information.
+ *
+ * Return: Success: Data chunk size
+ * Failure: 0
+ *
+ * Programmer: Quincey Koziol
+ * Mar 31, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+filter_expand(unsigned int flags, size_t UNUSED cd_nelmts,
+ const unsigned int UNUSED *cd_values, size_t nbytes,
+ size_t *buf_size, void UNUSED **buf)
+{
+ size_t ret_value = 0;
+
+ if(flags & H5Z_FLAG_REVERSE) {
+ /* Don't do anything when filter is applied in reverse */
+ *buf_size = nbytes;
+ ret_value = nbytes;
+ } /* end if */
+ else {
+ /* Check for expanding the chunk */
+ if(filter_expand_factor_g > 0) {
+ /* Expand the buffer size beyond what can be encoded */
+ *buf_size = nbytes * 256 * 256 * 256 * filter_expand_factor_g;
+ ret_value = *buf_size;
+ } /* end if */
+ else {
+ /* Don't expand the chunk's size */
+ *buf_size = nbytes;
+ ret_value = nbytes;
+ } /* end else */
+ } /* end else */
+
+ return ret_value;
+} /* end filter_expand() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_chunk_expand
+ *
+ * Purpose: Tests support for proper error handling when a chunk expands
+ * too much after a filter is applied
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, March 31, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_chunk_expand(hid_t fapl)
+{
+ char filename[FILENAME_BUF_SIZE];
+ hid_t fid = -1; /* File ID */
+ hid_t dcpl = -1; /* Dataset creation property list ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t scalar_sid = -1;/* Scalar dataspace ID */
+ hid_t dsid = -1; /* Dataset ID */
+ hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */
+ hsize_t hs_offset; /* Hyperslab offset */
+ hsize_t hs_size; /* Hyperslab size */
+ H5D_alloc_time_t alloc_time; /* Storage allocation time */
+ unsigned write_elem, read_elem; /* Element written/read */
+ unsigned u; /* Local index variable */
+ herr_t status; /* Generic return value */
+
+ TESTING("filter expanding chunks too much");
+
+ h5_fixname(FILENAME[10], fapl, filename, sizeof filename);
+
+ if(sizeof(size_t) <= 4) {
+ SKIPPED();
+ puts(" Current machine can't test for error");
+ } /* end if */
+ else {
+ /* Register "expansion" filter */
+ if(H5Zregister(H5Z_EXPAND) < 0) FAIL_STACK_ERROR
+
+ /* Check that the filter was registered */
+ if(TRUE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) FAIL_STACK_ERROR
+
+ /* Loop over storage allocation time */
+ for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) {
+ /* Create file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
+
+ /* Set chunking */
+ chunk_dim = 10;
+ if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
+
+ /* Set fill time */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR
+
+ /* Set allocation time */
+ if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR
+
+ /* Set "expand" filter */
+ if(H5Pset_filter(dcpl, H5Z_FILTER_EXPAND, 0, (size_t)0, NULL) < 0) FAIL_STACK_ERROR
+
+ /* Create scalar dataspace */
+ if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR
+
+ /* Create 1-D dataspace */
+ dim = 100;
+ max_dim = H5S_UNLIMITED;
+ if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) FAIL_STACK_ERROR
+
+ /* Create chunked dataset */
+ if(H5D_ALLOC_TIME_EARLY == alloc_time) {
+ /* Make the expansion factor large enough to cause failure right away */
+ filter_expand_factor_g = 8;
+
+ H5E_BEGIN_TRY {
+ dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if(dsid >= 0) FAIL_PUTS_ERROR("should fail to create dataset when allocation time is early");
+ } /* end if */
+ else {
+ if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Fill elements */
+ hs_size = 1;
+ for(u = 0; u < 100; u++) {
+ /* Select a single element in the dataset */
+ hs_offset = u;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR
+
+ /* Read (unwritten) element from dataset */
+ read_elem = 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+
+ /* Verify unwritten element is fill value (0) */
+ if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read");
+
+ /* Don't expand chunks yet */
+ filter_expand_factor_g = 0;
+
+ /* Write element to dataset */
+ write_elem = u;
+ if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
+
+ /* Read element from dataset */
+ read_elem = write_elem + 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+
+ /* Verify written element is read in */
+ if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
+
+ /* Expand chunks now */
+ filter_expand_factor_g = 8;
+
+ /* Write element to dataset */
+ write_elem = u;
+ H5E_BEGIN_TRY {
+ status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem);
+ } H5E_END_TRY;
+ if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early");
+ } /* end for */
+
+ /* Incrementally extend dataset and verify write/reads */
+ while(dim < 1000) {
+ /* Extend dataset */
+ dim += 100;
+ if(H5Dset_extent(dsid, &dim) < 0) FAIL_STACK_ERROR
+
+ /* Close old dataspace */
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+
+ /* Get dataspace for dataset now */
+ if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR
+
+ /* Fill new elements */
+ hs_size = 1;
+ for(u = 0; u < 100; u++) {
+ /* Select a single element in the dataset */
+ hs_offset = (dim + u) - 100;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR
+
+ /* Read (unwritten) element from dataset */
+ read_elem = 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+
+ /* Verify unwritten element is fill value (0) */
+ if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read");
+
+ /* Don't expand chunks yet */
+ filter_expand_factor_g = 0;
+
+ /* Write element to dataset */
+ write_elem = u;
+ if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
+
+ /* Read element from dataset */
+ read_elem = write_elem + 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+
+ /* Verify written element is read in */
+ if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
+
+ /* Expand chunks now */
+ filter_expand_factor_g = 8;
+
+ /* Write element to dataset */
+ write_elem = u;
+ H5E_BEGIN_TRY {
+ status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem);
+ } H5E_END_TRY;
+ if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early");
+ } /* end for */
+ } /* end while */
+
+ /* Close dataset */
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ } /* end else */
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /* If the dataset was created, do some extra testing */
+ if(H5D_ALLOC_TIME_EARLY != alloc_time) {
+ /* Re-open file & dataset */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Open dataset */
+ if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Create scalar dataspace */
+ if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR
+
+ /* Get dataspace for dataset now */
+ if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR
+
+ /* Read elements */
+ hs_size = 1;
+ for(u = 0; u < 1000; u++) {
+ /* Select a single element in the dataset */
+ hs_offset = u;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR
+
+ /* Read element from dataset */
+ read_elem = u + 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+
+ /* Verify unwritten element is proper value */
+ if(read_elem != (u % 100)) FAIL_PUTS_ERROR("invalid element read");
+
+ /* Don't expand chunks yet */
+ filter_expand_factor_g = 0;
+
+ /* Write element to dataset */
+ write_elem = u % 100;
+ if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
+
+ /* Read element from dataset */
+ read_elem = write_elem + 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+
+ /* Verify written element is read in */
+ if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
+
+ /* Expand chunks now */
+ filter_expand_factor_g = 8;
+
+ /* Write element to dataset */
+ write_elem = u % 100;
+ H5E_BEGIN_TRY {
+ status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem);
+ } H5E_END_TRY;
+ if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early");
+ } /* end for */
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /* Re-open file */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Delete dataset */
+ if(H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ /* Close everything */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ } /* end if */
+ } /* end for */
+
+ /* Unregister "expansion" filter */
+ if(H5Zunregister(H5Z_FILTER_EXPAND) < 0) FAIL_STACK_ERROR
+
+ /* Check that the filter was unregistered */
+ if(FALSE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) FAIL_STACK_ERROR
+
+ PASSED();
+ } /* end else */
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Dclose(dsid);
+ H5Sclose(sid);
+ H5Sclose(scalar_sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_chunk_expand() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests the dataset interface (H5D)
@@ -6504,6 +7293,13 @@ error:
int
main(void)
{
+ char filename[FILENAME_BUF_SIZE];
+ hid_t file, grp, fapl, fapl2;
+ hbool_t new_format;
+ int mdc_nelmts;
+ size_t rdcc_nelmts;
+ size_t rdcc_nbytes;
+ double rdcc_w0;
int nerrors = 0;
const char *envval;
@@ -6511,116 +7307,112 @@ main(void)
envval = HDgetenv("HDF5_DRIVER");
if(envval == NULL)
envval = "nomatch";
- if(HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- char filename[FILENAME_BUF_SIZE];
- hid_t file, grp, fapl, fapl2;
- hbool_t new_format;
- int mdc_nelmts;
- size_t rdcc_nelmts;
- size_t rdcc_nbytes;
- double rdcc_w0;
-
- /* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
-
- /* Testing setup */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Turn off the chunk cache, so all the chunks are immediately written to disk */
- if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
- goto error;
- rdcc_nbytes = 0;
- if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
- goto error;
- /* Copy the file access property list */
- if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+ /* Set the random # seed */
+ HDsrandom((unsigned)HDtime(NULL));
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+ /* Testing setup */
+ h5_reset();
+ fapl = h5_fileaccess();
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ /* Turn off the chunk cache, so all the chunks are immediately written to disk */
+ if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
+ goto error;
+ rdcc_nbytes = 0;
+ if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
+ goto error;
- /* Test with old & new format groups */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
- /* Set the FAPL for the type of format */
- if(new_format) {
- puts("\nTesting with new file format:");
- my_fapl = fapl2;
- } /* end if */
- else {
- puts("Testing with old file format:");
- my_fapl = fapl;
- } /* end else */
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
- /* Create the file for this test */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0)
- goto error;
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- /* Cause the library to emit initial messages */
- if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
- if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0)
- goto error;
- if(H5Gclose(grp) < 0)
- goto error;
+ /* Test with old & new format groups */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
+
+ /* Set the FAPL for the type of format */
+ if(new_format) {
+ puts("\nTesting with new file format:");
+ my_fapl = fapl2;
+ } /* end if */
+ else {
+ puts("Testing with old file format:");
+ my_fapl = fapl;
+ } /* end else */
+
+ /* Create the file for this test */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0)
+ goto error;
+
+ /* Cause the library to emit initial messages */
+ if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+ if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0)
+ goto error;
+ if(H5Gclose(grp) < 0)
+ goto error;
- nerrors += (test_create(file) < 0 ? 1 : 0);
- nerrors += (test_simple_io(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_conv_buffer(file) < 0 ? 1 : 0);
- nerrors += (test_tconv(file) < 0 ? 1 : 0);
- nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0);
- nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_int(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_float(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_double(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_array(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_compound(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0);
- nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0);
- nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0);
- nerrors += (test_multiopen (file) < 0 ? 1 : 0);
- nerrors += (test_types(file) < 0 ? 1 : 0);
- nerrors += (test_userblock_offset(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_missing_filter(file) < 0 ? 1 : 0);
- nerrors += (test_can_apply(file) < 0 ? 1 : 0);
- nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0);
- nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0);
- nerrors += (test_filter_delete(file) < 0 ? 1 : 0);
- nerrors += (test_filters_endianess(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_zero_dims(file) < 0 ? 1 : 0);
- nerrors += (test_missing_chunk(file) < 0 ? 1 : 0);
- nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_create(file) < 0 ? 1 : 0);
+ nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_conv_buffer(file) < 0 ? 1 : 0);
+ nerrors += (test_tconv(file) < 0 ? 1 : 0);
+ nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_int(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_float(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_double(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_array(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_compound(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0);
+ nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0);
+ nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0);
+ nerrors += (test_multiopen (file) < 0 ? 1 : 0);
+ nerrors += (test_types(file) < 0 ? 1 : 0);
+ nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_missing_filter(file) < 0 ? 1 : 0);
+ nerrors += (test_can_apply(file) < 0 ? 1 : 0);
+ nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0);
+ nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0);
+ nerrors += (test_filter_delete(file) < 0 ? 1 : 0);
+ nerrors += (test_filters_endianess() < 0 ? 1 : 0);
+ nerrors += (test_zero_dims(file) < 0 ? 1 : 0);
+ nerrors += (test_missing_chunk(file) < 0 ? 1 : 0);
+ nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- nerrors += (test_deprec(file) < 0 ? 1 : 0);
+ nerrors += (test_deprec(file) < 0 ? 1 : 0);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0);
-
- if(H5Fclose(file) < 0)
- goto error;
- } /* end for */
+ nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0);
- /* Close 2nd FAPL */
- H5Pclose(fapl2);
-
- if(nerrors)
+ if(H5Fclose(file) < 0)
goto error;
- printf("All dataset tests passed.\n");
- h5_cleanup(FILENAME, fapl);
- } /* end if */
- else
- puts("All dataset tests skipped - Incompatible with current Virtual File Driver");
+ } /* end for */
+
+ /* Close 2nd FAPL */
+ if(H5Pclose(fapl2) < 0) TEST_ERROR
+
+ if(nerrors)
+ goto error;
+ printf("All dataset tests passed.\n");
+#ifdef H5_HAVE_FILTER_SZIP
+ if (GetTestCleanup())
+ HDremove(NOENCODER_COPY_FILENAME);
+#endif /* H5_HAVE_FILTER_SZIP */
+ h5_cleanup(FILENAME, fapl);
return 0;
diff --git a/test/dt_arith.c b/test/dt_arith.c
index 67885a3..420570a 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -617,12 +617,10 @@ generates_sigfpe(void)
static int
test_hard_query(void)
{
- htri_t ret;
-
TESTING("query functions of compiler conversion");
/* Verify the conversion from int to float is a hard conversion. */
- if((ret = H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT))!=TRUE) {
+ if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != TRUE) {
H5_FAILED();
printf("Can't query conversion function\n");
goto error;
@@ -631,7 +629,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);
- if((ret = H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT))!=FALSE) {
+ if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != FALSE) {
H5_FAILED();
printf("Can't query conversion function\n");
goto error;
@@ -640,7 +638,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);
- if((ret = H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT))!=TRUE) {
+ if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != TRUE) {
H5_FAILED();
printf("Can't query conversion function\n");
goto error;
@@ -676,19 +674,18 @@ static H5T_conv_ret_t
expt_handle(H5T_conv_except_t except_type, hid_t UNUSED src_id, hid_t UNUSED dst_id, void UNUSED *src_buf,
void *dst_buf, void *user_data)
{
- H5T_conv_ret_t ret = H5T_CONV_HANDLED;
signed char fill_value1 = 7;
int fill_value2 = 13;
if(except_type == H5T_CONV_EXCEPT_RANGE_HI || except_type == H5T_CONV_EXCEPT_RANGE_LOW ||
- except_type == H5T_CONV_EXCEPT_TRUNCATE) {
+ except_type == H5T_CONV_EXCEPT_TRUNCATE) {
if(*(hbool_t*)user_data)
*(signed char*)dst_buf = fill_value1;
else
*(int*)dst_buf = fill_value2;
- }
+ } /* end if */
- return ret;
+ return H5T_CONV_HANDLED;
}
@@ -1668,8 +1665,8 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
unsigned hw_uint;
long hw_long;
unsigned long hw_ulong;
- long_long hw_llong;
- unsigned long_long hw_ullong;
+ long long hw_llong;
+ unsigned long long hw_ullong;
/* What are the names of the source and destination types */
if (H5Tequal(src, H5T_NATIVE_SCHAR)) {
@@ -1766,7 +1763,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */
src_sign = H5Tget_sign(src);
dst_sign = H5Tget_sign(dst);
- aligned = HDcalloc(1, sizeof(long_long));
+ aligned = HDcalloc(1, sizeof(long long));
/* Allocate and initialize the source buffer through macro INIT_INTEGER. The BUF
* will be used for the conversion while the SAVED buffer will be
@@ -1789,9 +1786,9 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
} else if(src_type == INT_ULONG) {
INIT_INTEGER(unsigned long, ULONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts);
} else if(src_type == INT_LLONG) {
- INIT_INTEGER(long_long, LLONG_MAX, LLONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts);
+ INIT_INTEGER(long long, LLONG_MAX, LLONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts);
} else if(src_type == INT_ULLONG) {
- INIT_INTEGER(unsigned long_long, ULLONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts);
+ INIT_INTEGER(unsigned long long, ULLONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts);
} else
goto error;
@@ -1837,12 +1834,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_char = (signed char)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_char = (signed char)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_char = (signed char)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_char = (signed char)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_char = (signed char)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -1883,12 +1880,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_uchar = (unsigned char)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_uchar = (unsigned char)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_uchar = (unsigned char)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_uchar = (unsigned char)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_uchar = (unsigned char)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -1929,12 +1926,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_short = (short)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_short = (short)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_short = (short)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_short = (short)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_short = (short)(*((unsigned long long*)aligned));
break;
default:
@@ -1976,12 +1973,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_ushort = (unsigned short)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_ushort = (unsigned short)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_ushort = (unsigned short)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_ushort = (unsigned short)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_ushort = (unsigned short)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2022,12 +2019,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_int = (int)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_int = (int)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_int = (int)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_int = (int)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_int = (int)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2068,12 +2065,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_uint = (unsigned int)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_uint = (unsigned int)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_uint = (unsigned int)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_uint = (unsigned int)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_uint = (unsigned int)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2114,12 +2111,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_long = (long int)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_long = (long int)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_long = (long int)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_long = (long int)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_long = (long int)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2160,12 +2157,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
hw_ulong = (unsigned long)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_ulong = (unsigned long)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_ulong = (unsigned long)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_ulong = (unsigned long)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_ulong = (unsigned long)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2175,43 +2172,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
switch (src_type) {
case INT_SCHAR:
HDmemcpy(aligned, saved+j*sizeof(char), sizeof(char));
- hw_llong = (long_long)(*((char*)aligned));
+ hw_llong = (long long)(*((char*)aligned));
break;
case INT_UCHAR:
HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
- hw_llong = (long_long)(*((unsigned char*)aligned));
+ hw_llong = (long long)(*((unsigned char*)aligned));
break;
case INT_SHORT:
HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
- hw_llong = (long_long)(*((short*)aligned));
+ hw_llong = (long long)(*((short*)aligned));
break;
case INT_USHORT:
HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
- hw_llong = (long_long)(*((unsigned short*)aligned));
+ hw_llong = (long long)(*((unsigned short*)aligned));
break;
case INT_INT:
HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
- hw_llong = (long_long)(*((int*)aligned));
+ hw_llong = (long long)(*((int*)aligned));
break;
case INT_UINT:
HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
- hw_llong = (long_long)(*((unsigned*)aligned));
+ hw_llong = (long long)(*((unsigned*)aligned));
break;
case INT_LONG:
HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
- hw_llong = (long_long)(*((long*)aligned));
+ hw_llong = (long long)(*((long*)aligned));
break;
case INT_ULONG:
HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
- hw_llong = (long_long)(*((unsigned long*)aligned));
+ hw_llong = (long long)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_llong = (long_long)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_llong = (long long)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_llong = (long_long)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_llong = (long long)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2221,43 +2218,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
switch (src_type) {
case INT_SCHAR:
HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
- hw_ullong = (unsigned long_long)(*((signed char*)aligned));
+ hw_ullong = (unsigned long long)(*((signed char*)aligned));
break;
case INT_UCHAR:
HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
- hw_ullong = (unsigned long_long)(*((unsigned char*)aligned));
+ hw_ullong = (unsigned long long)(*((unsigned char*)aligned));
break;
case INT_SHORT:
HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
- hw_ullong = (unsigned long_long)(*((short*)aligned));
+ hw_ullong = (unsigned long long)(*((short*)aligned));
break;
case INT_USHORT:
HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
- hw_ullong = (unsigned long_long)(*((unsigned short*)aligned));
+ hw_ullong = (unsigned long long)(*((unsigned short*)aligned));
break;
case INT_INT:
HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
- hw_ullong = (unsigned long_long)(*((int*)aligned));
+ hw_ullong = (unsigned long long)(*((int*)aligned));
break;
case INT_UINT:
HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
- hw_ullong = (unsigned long_long)(*((unsigned*)aligned));
+ hw_ullong = (unsigned long long)(*((unsigned*)aligned));
break;
case INT_LONG:
HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
- hw_ullong = (unsigned long_long)(*((long*)aligned));
+ hw_ullong = (unsigned long long)(*((long*)aligned));
break;
case INT_ULONG:
HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
- hw_ullong = (unsigned long_long)(*((unsigned long*)aligned));
+ hw_ullong = (unsigned long long)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_ullong = (unsigned long_long)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_ullong = (unsigned long long)(*((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_ullong = (unsigned long_long)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_ullong = (unsigned long long)(*((unsigned long long*)aligned));
break;
default:
break;
@@ -2426,12 +2423,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
printf(" %29lu\n", *((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)aligned));
break;
default:
break;
@@ -2475,12 +2472,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
printf(" %29lu\n", *((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
+ HDmemcpy(aligned, buf+j*sizeof(long long), sizeof(long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(unsigned long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
+ HDmemcpy(aligned, buf+j*sizeof(long long), sizeof(unsigned long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)aligned));
break;
default:
break;
@@ -2516,10 +2513,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
printf(" %29lu\n", *((unsigned long*)hw));
break;
case INT_LLONG:
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)hw));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long long*)hw));
break;
case INT_ULLONG:
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)hw));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)hw));
break;
default:
break;
@@ -2527,6 +2524,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
if (++fails_all_tests>=max_fails) {
HDputs(" maximum failures reached, aborting test...");
+ HDputs(" (dst is library's conversion output. ans is compiler's conversion output.)");
goto done;
}
}
@@ -2710,7 +2708,6 @@ my_isinf(int endian, unsigned char *val, size_t size,
unsigned char *bits;
int retval = 0;
size_t i;
- ssize_t ret1=0, ret2=0;
bits = (unsigned char*)calloc(1, size);
@@ -2732,8 +2729,8 @@ my_isinf(int endian, unsigned char *val, size_t size,
bits[size-(i+1)] = *(val + ENDIAN(size, i, endian));
#endif /*H5_VMS*/
- if((ret1=H5T_bit_find(bits, mpos, msize, H5T_BIT_LSB, 1))<0 &&
- (ret2=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);
@@ -3363,6 +3360,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst)
HDputs(" maximum failures reached, aborting test...");
else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL)
HDputs(" maximum warnings reached, aborting test...");
+ HDputs(" (dst is library's conversion output. ans is compiler's conversion output.)");
goto done;
}
@@ -3478,8 +3476,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
unsigned hw_uint=0;
long hw_long=0;
unsigned long hw_ulong=0;
- long_long hw_llong=0;
- unsigned long_long hw_ullong=0;
+ long long hw_llong=0;
+ unsigned long long hw_ullong=0;
/* What is the name of the source type */
if (H5Tequal(src, H5T_NATIVE_SCHAR)) {
@@ -3650,7 +3648,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
dst_size = H5Tget_size(dst);
src_nbits = H5Tget_precision(src); /* not 8*src_size, esp on J90 - QAK */
dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */
- aligned = HDcalloc(1, MAX(sizeof(long double), sizeof(long_long)));
+ aligned = HDcalloc(1, MAX(sizeof(long double), sizeof(long long)));
#ifdef SHOW_OVERFLOWS
noverflows_g = 0;
#endif
@@ -3707,9 +3705,9 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
} else if(src_type == INT_ULONG) {
INIT_INTEGER(unsigned long, ULONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts);
} else if(src_type == INT_LLONG) {
- INIT_INTEGER(long_long, LLONG_MAX, LLONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts);
+ INIT_INTEGER(long long, LLONG_MAX, LLONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts);
} else if(src_type == INT_ULLONG) {
- INIT_INTEGER(unsigned long_long, ULLONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts);
+ INIT_INTEGER(unsigned long long, ULLONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts);
} else if(src_type == FLT_FLOAT) {
if(run_test==TEST_NORMAL) {
INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP,
@@ -3795,13 +3793,13 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
hw_float = (float)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_float = (float)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_float = (float)(*((long long*)aligned));
break;
#ifdef H5_ULLONG_TO_FP_CAST_WORKS
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_float = (float)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_float = (float)(*((unsigned long long*)aligned));
break;
#endif /* H5_ULLONG_TO_FP_CAST_WORKS */
default:
@@ -3843,13 +3841,13 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
hw_double = (double)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_double = (double)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_double = (double)(*((long long*)aligned));
break;
#ifdef H5_ULLONG_TO_FP_CAST_WORKS
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_double = (double)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_double = (double)(*((unsigned long long*)aligned));
break;
#endif /* H5_ULLONG_TO_FP_CAST_WORKS */
default:
@@ -3892,13 +3890,13 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
hw_ldouble = (long double)(*((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- hw_ldouble = (long double)(*((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ hw_ldouble = (long double)(*((long long*)aligned));
break;
#ifdef H5_ULLONG_TO_FP_CAST_WORKS
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- hw_ldouble = (long double)(*((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ hw_ldouble = (long double)(*((unsigned long long*)aligned));
break;
#endif /* H5_ULLONG_TO_FP_CAST_WORKS */
default:
@@ -4070,16 +4068,16 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
switch (src_type) {
case FLT_FLOAT:
HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
- hw_llong = (long_long)(*((float*)aligned));
+ hw_llong = (long long)(*((float*)aligned));
break;
case FLT_DOUBLE:
HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
- hw_llong = (long_long)(*((double*)aligned));
+ hw_llong = (long long)(*((double*)aligned));
break;
#if H5_SIZEOF_LONG_DOUBLE !=0
case FLT_LDOUBLE:
HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
- hw_llong = (long_long)(*((long double*)aligned));
+ hw_llong = (long long)(*((long double*)aligned));
break;
#endif
default:
@@ -4090,16 +4088,16 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
switch (src_type) {
case FLT_FLOAT:
HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
- hw_ullong = (unsigned long_long)(*((float*)aligned));
+ hw_ullong = (unsigned long long)(*((float*)aligned));
break;
case FLT_DOUBLE:
HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
- hw_ullong = (unsigned long_long)(*((double*)aligned));
+ hw_ullong = (unsigned long long)(*((double*)aligned));
break;
#if H5_SIZEOF_LONG_DOUBLE !=0
case FLT_LDOUBLE:
HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
- hw_ullong = (unsigned long_long)(*((long double*)aligned));
+ hw_ullong = (unsigned long long)(*((long double*)aligned));
break;
#endif
default:
@@ -4258,10 +4256,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
if((tmp_s+1)==tmp_h || (tmp_s-1)==tmp_h)
continue; /*no error*/
} /* end if */
- else if (dst_size==sizeof(unsigned long_long)) {
- unsigned long_long tmp_s, tmp_h;
- HDmemcpy(&tmp_s,&buf[j*dst_size],sizeof(unsigned long_long));
- HDmemcpy(&tmp_h,&hw[0],sizeof(unsigned long_long));
+ else if (dst_size==sizeof(unsigned long long)) {
+ unsigned long long tmp_s, tmp_h;
+ HDmemcpy(&tmp_s,&buf[j*dst_size],sizeof(unsigned long long));
+ HDmemcpy(&tmp_h,&hw[0],sizeof(unsigned long long));
if((tmp_s+1)==tmp_h || (tmp_s-1)==tmp_h)
continue; /*no error*/
} /* end if */
@@ -4273,9 +4271,9 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
*/
#ifndef H5_FP_TO_ULLONG_BOTTOM_BIT_WORKS
if((src_type==FLT_FLOAT || src_type==FLT_DOUBLE) && dst_type==INT_ULLONG) {
- unsigned long_long tmp_s, tmp_h;
- HDmemcpy(&tmp_s,&buf[j*dst_size],sizeof(unsigned long_long));
- HDmemcpy(&tmp_h,&hw[0],sizeof(unsigned long_long));
+ unsigned long long tmp_s, tmp_h;
+ HDmemcpy(&tmp_s,&buf[j*dst_size],sizeof(unsigned long long));
+ HDmemcpy(&tmp_h,&hw[0],sizeof(unsigned long long));
if((tmp_s+1)==tmp_h)
continue; /*no error*/
}
@@ -4347,12 +4345,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
printf(" %29lu\n", *((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
+ HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)aligned));
break;
case FLT_FLOAT:
HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
@@ -4410,12 +4408,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
printf(" %29lu\n", *((unsigned long*)aligned));
break;
case INT_LLONG:
- HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
+ HDmemcpy(aligned, buf+j*sizeof(long long), sizeof(long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long long*)aligned));
break;
case INT_ULLONG:
- HDmemcpy(aligned, buf+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
- HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
+ HDmemcpy(aligned, buf+j*sizeof(unsigned long long), sizeof(unsigned long long));
+ HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)aligned));
break;
case FLT_FLOAT:
HDmemcpy(aligned, buf+j*sizeof(float), sizeof(float));
@@ -4465,10 +4463,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
printf(" %29lu\n", *((unsigned long*)hw));
break;
case INT_LLONG:
- printf(" %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)hw));
+ printf(" %29"H5_PRINTF_LL_WIDTH"d\n", *((long long*)hw));
break;
case INT_ULLONG:
- printf(" %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)hw));
+ printf(" %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)hw));
break;
case FLT_FLOAT:
printf(" %29f\n", *((float*)hw));
@@ -4492,6 +4490,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst)
HDputs(" maximum failures reached, aborting test...");
else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL)
HDputs(" maximum warnings reached, aborting test...");
+ HDputs(" (dst is library's conversion output. ans is compiler's conversion output.)");
goto done;
}
@@ -4891,7 +4890,9 @@ run_int_fp_conv(const char *name)
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_FLOAT);
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_DOUBLE);
+#if H5_ULONG_TO_FLOAT_ACCURATE
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_FLOAT);
+#endif
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_DOUBLE);
#endif
@@ -5217,7 +5218,7 @@ main(void)
unsigned long nerrors = 0;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
diff --git a/test/dtransform.c b/test/dtransform.c
index b1bca24..cb58a6c 100644
--- a/test/dtransform.c
+++ b/test/dtransform.c
@@ -19,12 +19,12 @@
#define COLS 18
#define FLOAT_TOL 0.0001
-int init_test(hid_t file_id);
-int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy);
-int test_trivial(const hid_t dxpl_id_simple);
-int test_poly(const hid_t dxpl_id_polynomial);
-int test_set(void);
-int test_getset(const hid_t dxpl_id_simple);
+static int init_test(hid_t file_id);
+static int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy);
+static int test_trivial(const hid_t dxpl_id_simple);
+static int test_poly(const hid_t dxpl_id_polynomial);
+static int test_set(void);
+static int test_getset(const hid_t dxpl_id_simple);
/* These are needed for multiple tests, so are declared here globally and are init'ed in init_test */
hid_t dset_id_int;
@@ -50,17 +50,17 @@ const float windchillFfloat[ROWS][COLS] =
const int transformData[ROWS][COLS] =
{ {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 },
- {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 72 } ,
- {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 77 },
- {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 74, 81 },
- {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 78, 84 },
- {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 73, 80, 87 },
- {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 76, 82, 89 },
- {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 84, 91 },
- {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93 },
- {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 74, 81, 88, 95},
- {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 75, 82, 89, 97},
- {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 76, 84, 91, 98}
+ {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 0 } ,
+ {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 },
+ {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 },
+ {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 },
+ {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 },
+ {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 },
+ {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 },
+ {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 0, 7, 14, 21 },
+ {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23},
+ {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25},
+ {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26}
};
#define UCOMPARE(TYPE,VAR1,VAR2,TOL) \
@@ -104,17 +104,25 @@ const int transformData[ROWS][COLS] =
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ \
const char* utrans = "((x+100)/4)*3"; \
\
- hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset; \
+ hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \
+ H5T_order_t order; \
hsize_t dim[2] = {ROWS, COLS}; \
\
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \
- if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \
+ if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \
+ \
+ if((dt_nn = H5Tcopy(HDF_TYPE)) < 0) TEST_ERROR \
+ if((order = H5Tget_order(dt_nn)) == H5T_ORDER_ERROR) TEST_ERROR \
+ if(H5Tset_order(dt_nn, order == H5T_ORDER_LE ? H5T_ORDER_BE : H5T_ORDER_LE) < 0) TEST_ERROR \
+ if((dset_nn = H5Dcreate2(file_id, "/nonnative_transformtest_"TEST_STR, dt_nn, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR \
+ if(H5Tclose(dt_nn) < 0) TEST_ERROR \
\
if(SIGNED) \
{ \
if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \
if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
+ if(H5Dwrite(dset_nn, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
} \
else \
@@ -122,6 +130,7 @@ const int transformData[ROWS][COLS] =
if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \
if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
+ if(H5Dwrite(dset_nn, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
} \
\
@@ -133,16 +142,21 @@ const int transformData[ROWS][COLS] =
COMPARE(TYPE, array, COMPARE_DATA, 2) \
else \
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
+ \
+ TESTING("contiguous, byte order conversion ("TEST_STR"->"TEST_STR")") \
+ \
+ if(H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \
+ if(SIGNED) \
+ COMPARE(TYPE, array, COMPARE_DATA, 2) \
+ else \
+ UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
\
if(SIGNED) \
{ \
TESTING("contiguous, with type conversion (float->"TEST_STR")") \
\
if(H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \
- if(SIGNED) \
- COMPARE(TYPE, array, COMPARE_DATA, 2) \
- else \
- UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
+ COMPARE(TYPE, array, COMPARE_DATA, 2) \
} \
\
if(H5Dclose(dset) < 0) TEST_ERROR; \
@@ -200,10 +214,7 @@ const int transformData[ROWS][COLS] =
TESTING("chunked, with type conversion (float->"TEST_STR")") \
\
if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \
- if(SIGNED) \
- COMPARE(TYPE, array, COMPARE_DATA, 2) \
- else \
- UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
+ COMPARE(TYPE, array, COMPARE_DATA, 2) \
} \
\
\
@@ -236,7 +247,7 @@ int main(void)
const char* polynomial = "(2+x)* ((x-8)/2)";
/* inverses the utrans transform in init_test to get back original array */
const char* utrans_inv = "(x/3)*4 - 100";
-
+
if((file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
if((dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
@@ -265,14 +276,14 @@ int main(void)
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long, H5T_NATIVE_ULONG, "ulong", transformData, 0);
#ifdef H5_LLONG_TO_FP_CAST_WORKS
- TEST_TYPE_CONTIG(dxpl_id_c_to_f, long_long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
+ TEST_TYPE_CONTIG(dxpl_id_c_to_f, long long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
#else
TESTING("contiguous, with type conversion (float->llong)")
SKIPPED()
#endif
#ifdef H5_ULLONG_TO_FP_CAST_WORKS
- TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long_long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
+ TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
#else
TESTING("contiguous, with type conversion (float->ullong)")
SKIPPED()
@@ -293,14 +304,14 @@ int main(void)
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long, H5T_NATIVE_LONG, "long", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long, H5T_NATIVE_ULONG, "ulong", transformData, 0);
#ifdef H5_LLONG_TO_FP_CAST_WORKS
- TEST_TYPE_CHUNK(dxpl_id_c_to_f, long_long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
+ TEST_TYPE_CHUNK(dxpl_id_c_to_f, long long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
#else
TESTING("chunked, with type conversion (float->llong)")
SKIPPED()
#endif
#ifdef H5_ULLONG_TO_FP_CAST_WORKS
- TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long_long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
+ TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
#else
TESTING("chunked, with type conversion (float->ullong)")
SKIPPED()
@@ -311,7 +322,7 @@ int main(void)
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
#endif
- if(test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) TEST_ERROR;
+ if(test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) TEST_ERROR;
if(test_trivial(dxpl_id_simple) < 0) TEST_ERROR;
if(test_poly(dxpl_id_polynomial) < 0) TEST_ERROR;
if(test_getset(dxpl_id_c_to_f) < 0) TEST_ERROR;
@@ -336,7 +347,8 @@ error:
return -1;
}
-int init_test(hid_t file_id)
+static int
+init_test(hid_t file_id)
{
const char* f_to_c = "(5/9.0)*(x-32)";
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */
@@ -389,7 +401,8 @@ error:
return -1;
}
-int test_poly(const hid_t dxpl_id_polynomial)
+static int
+test_poly(const hid_t dxpl_id_polynomial)
{
float polyflres[ROWS][COLS];
int polyintread[ROWS][COLS];
@@ -430,7 +443,8 @@ error:
return -1;
}
-int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
+static int
+test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
{
int windchillC;
float polyflres[ROWS][COLS];
@@ -462,7 +476,8 @@ error:
return -1;
}
-int test_trivial(const hid_t dxpl_id_simple)
+static int
+test_trivial(const hid_t dxpl_id_simple)
{
float windchillFfloatread[ROWS][COLS];
int windchillFintread[ROWS][COLS];
@@ -505,13 +520,14 @@ error:
return -1;
}
-int test_getset(const hid_t dxpl_id_c_to_f)
+static int
+test_getset(const hid_t dxpl_id_c_to_f)
{
int row, col;
float windchillFfloatread[ROWS][COLS];
const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
const char* c_to_f = "(9/5.0)*x + 32";
- char* ptrgetTest = HDmalloc(HDstrlen(simple)+1);
+ char* ptrgetTest = (char *) HDmalloc(HDstrlen(simple)+1);
TESTING("H5Pget_data_transform")
H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f)+1);
@@ -544,7 +560,7 @@ int test_getset(const hid_t dxpl_id_c_to_f)
PASSED();
- ptrgetTest = malloc(strlen(simple)+1);
+ ptrgetTest = (char *) malloc(strlen(simple)+1);
HDmemset(ptrgetTest, 0, strlen(simple)+1);
TESTING("H5Pget_data_transform, after resetting transform property")
@@ -566,12 +582,13 @@ error:
return -1;
}
-int test_set(void)
+static int
+test_set(void)
{
hid_t dxpl_id;
H5E_auto2_t func;
const char* str = "(9/5.0)*x + 32";
- char* ptrgetTest = malloc(strlen(str)+1);
+ char* ptrgetTest = (char *) malloc(strlen(str)+1);
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
diff --git a/test/dtypes.c b/test/dtypes.c
index f7802ed..04f526a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -23,6 +23,7 @@
#include <math.h>
#include <time.h>
#include "h5test.h"
+#include "H5Iprivate.h" /* For checking that datatype id's don't leak */
/* Number of times to run each test */
#define NTESTS 1
@@ -57,6 +58,23 @@
#define SET_ALIGNMENT(TYPE,VAL) \
H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL)
+/*
+ * Macro for checking that the correct number of datatype ids are present. Be
+ * careful as the call to H5Tunregister removes *ALL* compound conversions from
+ * the soft conversion list. One must call reset_hdf5() after this.
+ */
+#define CHECK_NMEMBS(NMEMBS,SRC_ID,DST_ID) \
+ if(H5Tunregister(H5T_PERS_SOFT, NULL, SRC_ID, DST_ID, NULL) < 0) \
+ FAIL_STACK_ERROR \
+ if(H5Tclose(SRC_ID) < 0 || ((SRC_ID) != (DST_ID) && H5Tclose(DST_ID) < 0)) \
+ FAIL_STACK_ERROR \
+ if((NMEMBS) != H5I_nmembers(H5I_DATATYPE)) { \
+ H5_FAILED(); \
+ printf(" #dtype ids expected: %d; found: %d\n", NMEMBS, \
+ H5I_nmembers(H5I_DATATYPE)); \
+ goto error; \
+ }
+
const char *FILENAME[] = {
"dtypes1",
"dtypes2",
@@ -307,7 +325,10 @@ test_copy(void)
* Saturday, August 30, 2003
*
* Modifications:
- *
+ * Raymond Lu
+ * 8 December 2009
+ * I added a field of VL string in the compound type to test
+ * H5Tdetect_class correctly detect it as string type.
*-------------------------------------------------------------------------
*/
static int
@@ -324,6 +345,7 @@ test_detect(void)
hobj_ref_t arr_r[3][3];
int i;
hvl_t vl_f;
+ hvl_t vl_s;
char c;
short s;
};
@@ -423,6 +445,7 @@ test_detect(void)
if (H5Tinsert(cplx_cmpd_id, "arr_r", HOFFSET(struct complex, arr_r), atom_arr_id) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "i", HOFFSET(struct complex, i), H5T_NATIVE_INT) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "vl_f", HOFFSET(struct complex, vl_f), atom_vlf_id) < 0) TEST_ERROR
+ if (H5Tinsert(cplx_cmpd_id, "vl_s", HOFFSET(struct complex, vl_s), atom_vls_id) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "c", HOFFSET(struct complex, c), H5T_NATIVE_CHAR) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "s", HOFFSET(struct complex, s), H5T_NATIVE_SHORT) < 0) TEST_ERROR
@@ -432,12 +455,12 @@ test_detect(void)
if(H5Tdetect_class(cplx_cmpd_id,H5T_REFERENCE)!=TRUE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_INTEGER)!=TRUE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_FLOAT)!=TRUE) TEST_ERROR
+ if(H5Tdetect_class(cplx_cmpd_id,H5T_STRING)!=TRUE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_VLEN)!=TRUE) TEST_ERROR
/* Make certain that an incorrect class is not detected */
if(H5Tdetect_class(cplx_cmpd_id,H5T_TIME)!=FALSE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_ENUM)!=FALSE) TEST_ERROR
- if(H5Tdetect_class(cplx_cmpd_id,H5T_STRING)!=FALSE) TEST_ERROR
/* Close complex compound datatype */
if(H5Tclose(cplx_cmpd_id) < 0) TEST_ERROR
@@ -628,6 +651,7 @@ test_compound_1(void)
} /* end if */
if (H5Tclose (complex_id) < 0) goto error;
+
PASSED();
return 0;
@@ -669,10 +693,13 @@ test_compound_2(void)
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
hid_t array_dt;
- int i;
+ int i, nmembs;
TESTING("compound element reordering");
+ if ((nmembs = H5I_nmembers(H5I_DATATYPE)) < 0)
+ FAIL_STACK_ERROR
+
/* Sizes should be the same, but be careful just in case */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
@@ -742,13 +769,14 @@ test_compound_2(void)
free(buf);
free(bkg);
free(orig);
- if (H5Tclose(st) < 0 || H5Tclose(dt) < 0) goto error;
+ CHECK_NMEMBS(nmembs , st, dt)
PASSED();
reset_hdf5();
return 0;
error:
+ reset_hdf5();
return 1;
}
@@ -786,10 +814,13 @@ test_compound_3(void)
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
hid_t array_dt;
- int i;
+ int i, nmembs;
TESTING("compound subset conversions");
+ if ((nmembs = H5I_nmembers(H5I_DATATYPE)) < 0)
+ FAIL_STACK_ERROR
+
/* Initialize */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
@@ -856,13 +887,14 @@ test_compound_3(void)
free(buf);
free(bkg);
free(orig);
- if (H5Tclose(st) < 0 || H5Tclose(dt) < 0) goto error;
+ CHECK_NMEMBS(nmembs, st, dt)
PASSED();
reset_hdf5();
return 0;
error:
+ reset_hdf5();
return 1;
}
@@ -904,10 +936,13 @@ test_compound_4(void)
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
hid_t array_dt;
- int i;
+ int i, nmembs;
TESTING("compound element shrinking & reordering");
+ if ((nmembs = H5I_nmembers(H5I_DATATYPE)) < 0)
+ FAIL_STACK_ERROR
+
/* Sizes should be the same, but be careful just in case */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
@@ -978,13 +1013,14 @@ test_compound_4(void)
free(buf);
free(bkg);
free(orig);
- if (H5Tclose(st) < 0 || H5Tclose(dt) < 0) goto error;
+ CHECK_NMEMBS(nmembs, st, dt)
PASSED();
reset_hdf5();
return 0;
error:
+ reset_hdf5();
return 1;
}
@@ -1133,10 +1169,13 @@ test_compound_6(void)
const size_t nelmts = NTESTELEM;
unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
hid_t st=-1, dt=-1;
- int i;
+ int i, nmembs;
TESTING("compound element growing");
+ if ((nmembs = H5I_nmembers(H5I_DATATYPE)) < 0)
+ FAIL_STACK_ERROR
+
/* Sizes should be the same, but be careful just in case */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
@@ -1189,16 +1228,14 @@ test_compound_6(void)
free(buf);
free(bkg);
free(orig);
- if (H5Tclose(st) < 0 || H5Tclose(dt) < 0) {
- H5_FAILED();
- goto error;
- }
+ CHECK_NMEMBS(nmembs, st, dt)
PASSED();
reset_hdf5();
return 0;
error:
+ reset_hdf5();
return 1;
}
@@ -1337,6 +1374,7 @@ test_compound_7(void)
return 0;
error:
+ reset_hdf5();
return 1;
}
@@ -1955,10 +1993,10 @@ test_compound_10(void)
if(H5Dclose(dset_id) < 0)
goto error;
- if(H5Tclose(cmpd_tid) < 0)
- goto error;
if(H5Tclose(arr_tid) < 0)
goto error;
+ if(H5Tclose(cmpd_tid) < 0)
+ goto error;
if(H5Tclose(cstr_id) < 0)
goto error;
if(H5Tclose(vlstr_id) < 0)
@@ -2277,7 +2315,7 @@ test_compound_12(void)
/*-------------------------------------------------------------------------
- * Function: test_compound_12
+ * Function: test_compound_13
*
* Purpose: Tests compound datatypes whose size is at the boundary for
* needing 2 bytes for the datatype size and "use the latest
@@ -2308,7 +2346,7 @@ test_compound_13(void)
TESTING("compound datatypes of boundary size with latest format");
- /* Create some phony data. */
+ /* Create some phony data. */
for(u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++)
data_out.x[u] = u;
data_out.y = 99.99;
@@ -2338,7 +2376,7 @@ test_compound_13(void)
/* Write some data. */
if(H5Awrite(attid, typeid, &data_out) < 0) FAIL_STACK_ERROR
-
+
/* Release all resources. */
if(H5Aclose(attid) < 0) FAIL_STACK_ERROR
if(H5Tclose(array1_tid) < 0) FAIL_STACK_ERROR
@@ -2378,6 +2416,742 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_compound_14
+ *
+ * Purpose: Tests compound type conversions where a vlen string will
+ be misaligned in the conversion buffer and the file. The
+ two compound types are meant to trigger two different
+ conversion routines.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Monday, August 25, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_14(void)
+{
+ typedef struct cmpd_struct_1 {
+ char c1;
+ char c2;
+ char* str;
+ } cmpd_struct_1;
+
+ typedef struct cmpd_struct_2 {
+ char c1;
+ char c2;
+ char* str;
+ long l1;
+ long l2;
+ long l3;
+ long l4;
+ } cmpd_struct_2;
+
+ cmpd_struct_1 wdata1 = {'A', 'B', "variable-length string"};
+
+ cmpd_struct_1 rdata1;
+ cmpd_struct_2 wdata2 = {'C', 'D', "another vlen!", 1, 2, -1, 9001};
+ cmpd_struct_2 rdata2;
+ hid_t file;
+ hid_t cmpd_m1_tid, cmpd_f1_tid, cmpd_m2_tid, cmpd_f2_tid, str_id;
+ hid_t space_id;
+ hid_t dset1_id, dset2_id;
+ hsize_t dim1[1];
+ char filename[1024];
+
+ TESTING("unaligned VL strings in compound");
+
+ /* Create File */
+ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename);
+ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create file!\n");
+ goto error;
+ } /* end if */
+
+ /* Create memory compound datatype 1 */
+ if((cmpd_m1_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct_1))) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create datatype!\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m1_tid,"c1",HOFFSET(struct cmpd_struct_1,c1),H5T_NATIVE_CHAR) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m1_tid,"c2",HOFFSET(struct cmpd_struct_1,c2),H5T_NATIVE_CHAR) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c2'\n");
+ goto error;
+ } /* end if */
+
+ str_id = H5Tcopy(H5T_C_S1);
+ if(H5Tset_size(str_id,H5T_VARIABLE) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't set size for VL string\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m1_tid, "vl_string", HOFFSET(cmpd_struct_1, str), str_id) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'vl_string'\n");
+ goto error;
+ } /* end if */
+
+ /* Create file compound datatype 1 */
+ if((cmpd_f1_tid = H5Tcreate( H5T_COMPOUND, 8 + 1 + sizeof(hvl_t))) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create datatype!\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f1_tid,"c1",0,H5T_STD_I64BE) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f1_tid,"c2",8,H5T_NATIVE_CHAR) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c2'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f1_tid, "vl_string",8 + 1, str_id) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'vl_string'\n");
+ goto error;
+ } /* end if */
+
+ /* Create memory compound datatype 2 */
+ if((cmpd_m2_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct_2))) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create datatype!\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid,"c1",HOFFSET(struct cmpd_struct_2,c1),H5T_NATIVE_CHAR) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid,"c2",HOFFSET(struct cmpd_struct_2,c2),H5T_NATIVE_CHAR) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c2'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid, "vl_string", HOFFSET(cmpd_struct_2, str), str_id) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'vl_string'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid,"l1",HOFFSET(struct cmpd_struct_2,l1),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid,"l2",HOFFSET(struct cmpd_struct_2,l2),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l2'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid,"l3",HOFFSET(struct cmpd_struct_2,l3),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l3'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m2_tid,"l4",HOFFSET(struct cmpd_struct_2,l4),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l4'\n");
+ goto error;
+ } /* end if */
+
+ /* Create file compound datatype 2 */
+ if((cmpd_f2_tid = H5Tcreate( H5T_COMPOUND, 8 + 1 + sizeof(hvl_t) + 4*sizeof(long))) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create datatype!\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid,"c1",0,H5T_STD_I64BE) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid,"c2",8,H5T_NATIVE_CHAR) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'c2'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid, "vl_string", 8 + 1, str_id) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'vl_string'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid,"l1",8 + 1 + sizeof(hvl_t),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid,"l2",8 + 1 + sizeof(hvl_t) + sizeof(long),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l2'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid,"l3",8 + 1 + sizeof(hvl_t) + 2*sizeof(long),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l3'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f2_tid,"l4",8 + 1 + sizeof(hvl_t) + 3*sizeof(long),H5T_NATIVE_LONG) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'l4'\n");
+ goto error;
+ } /* end if */
+
+ dim1[0] = 1;
+ if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create space\n");
+ goto error;
+ } /* end if */
+
+ if((dset1_id = H5Dcreate2(file, "Dataset1", cmpd_f1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create dataset\n");
+ goto error;
+ } /* end if */
+
+ if((dset2_id = H5Dcreate2(file, "Dataset2", cmpd_f2_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create dataset\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dwrite(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't write data\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dwrite(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata2) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't write data\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dread(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata1) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't read data\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dread(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata2) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't read data\n");
+ goto error;
+ } /* end if */
+
+ if(rdata1.c1 != wdata1.c1 || rdata1.c2 != wdata1.c2 || HDstrcmp(rdata1.str, wdata1.str)) {
+ H5_FAILED(); AT();
+ printf("incorrect read data\n");
+ goto error;
+ } /* end if */
+
+ if(rdata2.c1 != wdata2.c1 || rdata2.c2 != wdata2.c2 || HDstrcmp(rdata2.str, wdata2.str) ||
+ rdata2.l1 != wdata2.l1 || rdata2.l2 != wdata2.l2 || rdata2.l3 != wdata2.l3 || rdata2.l4 != wdata2.l4) {
+ H5_FAILED(); AT();
+ printf("incorrect read data\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dclose(dset1_id) < 0)
+ goto error;
+ if(H5Dclose(dset2_id) < 0)
+ goto error;
+ if(H5Tclose(cmpd_f1_tid) < 0)
+ goto error;
+ if(H5Tclose(cmpd_f2_tid) < 0)
+ goto error;
+ if(H5Tclose(str_id) < 0)
+ goto error;
+ if(H5Sclose(space_id) < 0)
+ goto error;
+ if(H5Fclose(file) < 0)
+ goto error;
+
+
+ if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("cannot open file\n");
+ goto error;
+ } /* end if */
+
+ if((dset1_id = H5Dopen2(file, "Dataset1", H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("cannot open dataset\n");
+ goto error;
+ } /* end if */
+
+ if((dset2_id = H5Dopen2(file, "Dataset2", H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("cannot open dataset\n");
+ goto error;
+ } /* end if */
+
+ rdata1.c1 = rdata1.c2 = 0;
+ if(rdata1.str) HDfree(rdata1.str);
+
+ rdata2.c1 = rdata2.c2 = 0;
+ rdata2.l1 = rdata2.l2 = rdata2.l3 = rdata2.l4 = 0;
+ if(rdata2.str) {
+ HDfree(rdata2.str);
+ rdata2.str = NULL;
+ } /* end if */
+
+ if(H5Dread(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata1) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't read data\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dread(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata2) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't read data\n");
+ goto error;
+ } /* end if */
+
+ if(rdata1.c1!=wdata1.c1 || rdata1.c2!=wdata1.c2 || strcmp(rdata1.str, wdata1.str)) {
+ H5_FAILED(); AT();
+ printf("incorrect read data\n");
+ goto error;
+ } /* end if */
+
+ if(rdata2.c1 != wdata2.c1 || rdata2.c2 != wdata2.c2 || HDstrcmp(rdata2.str, wdata2.str) ||
+ rdata2.l1 != wdata2.l1 || rdata2.l2 != wdata2.l2 || rdata2.l3 != wdata2.l3 || rdata2.l4 != wdata2.l4) {
+ H5_FAILED(); AT();
+ printf("incorrect read data\n");
+ goto error;
+ } /* end if */
+
+ if(rdata1.str) HDfree(rdata1.str);
+ if(rdata2.str) HDfree(rdata2.str);
+
+ if(H5Dclose(dset1_id) < 0)
+ goto error;
+ if(H5Dclose(dset2_id) < 0)
+ goto error;
+ if(H5Tclose(cmpd_m1_tid) < 0)
+ goto error;
+ if(H5Tclose(cmpd_m2_tid) < 0)
+ goto error;
+ if(H5Fclose(file) < 0)
+ goto error;
+
+ PASSED();
+ return 0;
+
+ error:
+ return 1;
+} /* end test_compound_14() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_compound_15
+ *
+ * Purpose: Tests that conversion occurs correctly when the source is
+ * subset of the destination, but there is extra space at the
+ * end of the source type.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Friday, September 19, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_15(void)
+{
+ typedef struct cmpd_struct {
+ int i1;
+ int i2;
+ } cmpd_struct;
+
+ cmpd_struct wdata1 = {1254, 5471};
+ cmpd_struct rdata;
+ int wdata2[2] = {1, 2};
+ hid_t file;
+ hid_t cmpd_m_tid, cmpd_f_tid;
+ hid_t space_id;
+ hid_t dset_id;
+ hsize_t dim1[1];
+ char filename[1024];
+
+ TESTING("compound subset conversion with extra space in source");
+
+ /* Create File */
+ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename);
+ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create file!\n");
+ goto error;
+ } /* end if */
+
+ /* Create file compound datatype */
+ if((cmpd_f_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create datatype!\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f_tid,"i1",HOFFSET(struct cmpd_struct,i1),H5T_NATIVE_INT) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'i1'\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_f_tid,"i2",HOFFSET(struct cmpd_struct,i2),H5T_NATIVE_INT) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'i2'\n");
+ goto error;
+ } /* end if */
+
+ /* Create memory compound datatype */
+ if((cmpd_m_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create datatype!\n");
+ goto error;
+ } /* end if */
+
+ if(H5Tinsert(cmpd_m_tid,"i1",0,H5T_NATIVE_INT) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't insert field 'i1'\n");
+ goto error;
+ } /* end if */
+
+ /* Create space, dataset, write wdata1 */
+ dim1[0] = 1;
+ if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create space\n");
+ goto error;
+ } /* end if */
+
+ if((dset_id = H5Dcreate2(file, "Dataset", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't create dataset\n");
+ goto error;
+ } /* end if */
+
+ if(H5Dwrite(dset_id, cmpd_f_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't write data\n");
+ goto error;
+ } /* end if */
+
+ /* Write wdata2. The use of cmpd_m_tid here should cause only the first
+ * element of wdata2 to be written. */
+ if(H5Dwrite(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata2) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't write data\n");
+ goto error;
+ } /* end if */
+
+ /* Read data */
+ if(H5Dread(dset_id, cmpd_f_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't read data\n");
+ goto error;
+ } /* end if */
+
+ /* Check for correctness of read data */
+ if(rdata.i1 != wdata2[0] || rdata.i2 != wdata1.i2) {
+ H5_FAILED(); AT();
+ printf("incorrect read data\n");
+ goto error;
+ } /* end if */
+
+ /* Now try reading only the i1 field, verify it does not overwrite i2 in the
+ * read buffer */
+ rdata.i1 = wdata1.i1;
+ rdata.i2 = wdata2[1];
+
+ /* Read data */
+ if(H5Dread(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) {
+ H5_FAILED(); AT();
+ printf("Can't read data\n");
+ goto error;
+ } /* end if */
+
+ /* Check for correctness of read data */
+ if(rdata.i1 != wdata2[0] || rdata.i2 != wdata2[1]) {
+ H5_FAILED(); AT();
+ printf("incorrect read data\n");
+ goto error;
+ } /* end if */
+
+ /* Close */
+ if(H5Dclose(dset_id) < 0)
+ goto error;
+ if(H5Tclose(cmpd_f_tid) < 0)
+ goto error;
+ if(H5Tclose(cmpd_m_tid) < 0)
+ goto error;
+ if(H5Sclose(space_id) < 0)
+ goto error;
+ if(H5Fclose(file) < 0)
+ goto error;
+
+ PASSED();
+ return 0;
+
+ error:
+ return 1;
+} /* end test_compound_15() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_compound_16
+ *
+ * Purpose: Tests that committed types that can be registered during
+ * compound conversion are not visible to the application
+ * with H5Fget_obj_count or H5Fget_obj_ids.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Friday, October 3, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_16(void)
+{
+ typedef struct cmpd_struct {
+ int i1;
+ int i2;
+ } cmpd_struct;
+
+ cmpd_struct wdata1 = {1254, 5471};
+ int obj_count;
+ hid_t file;
+ hid_t cmpd_m_tid, cmpd_f_tid, int_id;
+ hid_t space_id;
+ hid_t dset_id;
+ hid_t open_dtypes[2] = {0, 0};
+ hsize_t dim1[1] = {1};
+ char filename[1024];
+
+ TESTING("visibility of internally registered type ids");
+
+ /* Create File */
+ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename);
+ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Copy and commit integer datatype */
+ if((int_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if(H5Tcommit2(file, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Create file compound datatype */
+ if((cmpd_f_tid = H5Tcreate(H5T_COMPOUND, 2 * sizeof(int) + 2)) < 0) TEST_ERROR
+ if(H5Tinsert(cmpd_f_tid, "i1", 0, int_id) < 0) TEST_ERROR
+ if(H5Tinsert(cmpd_f_tid, "i2", sizeof(int) + 1, int_id) < 0) TEST_ERROR
+
+ /* Create memory compound datatype */
+ if((cmpd_m_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) TEST_ERROR
+ if(H5Tinsert(cmpd_m_tid, "i1", HOFFSET(struct cmpd_struct, i1), int_id) < 0) TEST_ERROR
+ if(H5Tinsert(cmpd_m_tid, "i2", HOFFSET(struct cmpd_struct, i2), int_id) < 0) TEST_ERROR
+
+ /* Create space, dataset, write wdata1 */
+ if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file, "Dataset", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Dwrite(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) TEST_ERROR
+
+ /* Check behavior of H5Fget_obj_count */
+ if((obj_count = H5Fget_obj_count(file, H5F_OBJ_DATATYPE)) != 1) {
+ H5_FAILED(); AT();
+ printf(" H5Fget_obj_count returned: %d; expected: 1\n", obj_count);
+ goto error;
+ }
+
+ /* Check behavior of H5Fget_obj_ids */
+ if(H5Fget_obj_ids(file, H5F_OBJ_DATATYPE, 2, open_dtypes) < 0) TEST_ERROR
+ if(open_dtypes[1]) {
+ H5_FAILED(); AT();
+ printf(" H5Fget_obj_ids returned as second id: %d; expected: 0\n", open_dtypes[1]);
+ goto error;
+ }
+
+ /* Close */
+ if(H5Dclose(dset_id) < 0) TEST_ERROR
+ if(H5Sclose(space_id) < 0) TEST_ERROR
+ if(H5Tclose(cmpd_f_tid) < 0) TEST_ERROR
+ if(H5Tclose(cmpd_m_tid) < 0) TEST_ERROR
+ if(H5Tclose(int_id) < 0) TEST_ERROR
+ if(H5Fclose(file) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ return 1;
+} /* end test_compound_16() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_compound_17
+ *
+ * Purpose: Tests that compound types are packed correctly when they
+ * only have extra space at the end. The compounds are
+ * "hidden" inside arrays to make sure that they are still
+ * detected correctly.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Tuesday, January 13, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_17(void)
+{
+ hid_t file;
+ hid_t cmpd_int, arr_int, cmpd_ext, arr_ext, tmp_dt;
+ hsize_t dims[1] = {2};
+ char filename[1024];
+
+ TESTING("that H5Tpack removes trailing bytes");
+
+ /* Create inner compound datatype. This type will be "packed" according
+ * to the internal field, but will have trailing space at the end. */
+ if((cmpd_int = H5Tcreate(H5T_COMPOUND, 4)) < 0) TEST_ERROR
+ if(H5Tinsert(cmpd_int, "c", 0, H5T_NATIVE_CHAR) < 0) TEST_ERROR
+
+ /* Create inner array datatype */
+ if((arr_int = H5Tarray_create2(cmpd_int, 1, dims)) < 0) TEST_ERROR
+
+ /* Create outer compound datatype. This type will be truly packed, with no
+ * trailing space. However, the internal compound contained within is not
+ * packed. */
+ if((cmpd_ext = H5Tcreate(H5T_COMPOUND, 8)) < 0) TEST_ERROR
+ if(H5Tinsert(cmpd_ext, "arr", 0, arr_int) < 0) TEST_ERROR
+
+ /* Create outer array datatype */
+ if((arr_ext = H5Tarray_create2(cmpd_ext, 1, dims)) < 0) TEST_ERROR
+
+ /* Try packing the internal array. Size should be 2 after packing. */
+ if((tmp_dt = H5Tcopy(arr_int)) < 0) TEST_ERROR
+ if(H5Tpack(tmp_dt) < 0) TEST_ERROR
+ if(2 != H5Tget_size(tmp_dt)) {
+ H5_FAILED(); AT();
+ printf(" Size after packing: %d; expected: 2\n", H5Tget_size(tmp_dt));
+ goto error;
+ }
+ if(H5Tclose(tmp_dt) < 0) TEST_ERROR
+
+ /* Try packing the external array. Size should be 4 after packing. */
+ if((tmp_dt = H5Tcopy(arr_ext)) < 0) TEST_ERROR
+ if(H5Tpack(tmp_dt) < 0) TEST_ERROR
+ if(4 != H5Tget_size(tmp_dt)) {
+ H5_FAILED(); AT();
+ printf(" Size after packing: %d; expected: 4\n", H5Tget_size(tmp_dt));
+ goto error;
+ }
+ if(H5Tclose(tmp_dt) < 0) TEST_ERROR
+
+ /* Now we will commit arr_int and arr_ext to a file, and verify that they
+ * are still packed correctly after opening them from the file */
+ /* Create File */
+ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename);
+ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Commit the datatypes. Note that they are still unpacked. */
+ if(H5Tcommit2(file, "arr_int", arr_int, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Tcommit2(file, "arr_ext", arr_ext, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close IDs */
+ if(H5Tclose(cmpd_int) < 0) TEST_ERROR
+ if(H5Tclose(arr_int) < 0) TEST_ERROR
+ if(H5Tclose(cmpd_ext) < 0) TEST_ERROR
+ if(H5Tclose(arr_ext) < 0) TEST_ERROR
+ if(H5Fclose(file) < 0) TEST_ERROR
+
+ /* Reopen file */
+ if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Open committed array datatypes */
+ if((arr_int = H5Topen2(file, "arr_int", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((arr_ext = H5Topen2(file, "arr_ext", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Try packing the internal array. Size should be 2 after packing. */
+ if((tmp_dt = H5Tcopy(arr_int)) < 0) TEST_ERROR
+ if(H5Tpack(tmp_dt) < 0) TEST_ERROR
+ if(2 != H5Tget_size(tmp_dt)) {
+ H5_FAILED(); AT();
+ printf(" Size after packing: %d; expected: 2\n", H5Tget_size(tmp_dt));
+ goto error;
+ }
+ if(H5Tclose(tmp_dt) < 0) TEST_ERROR
+
+ /* Try packing the external array. Size should be 4 after packing. */
+ if((tmp_dt = H5Tcopy(arr_ext)) < 0) TEST_ERROR
+ if(H5Tpack(tmp_dt) < 0) TEST_ERROR
+ if(4 != H5Tget_size(tmp_dt)) {
+ H5_FAILED(); AT();
+ printf(" Size after packing: %d; expected: 4\n", H5Tget_size(tmp_dt));
+ goto error;
+ }
+ if(H5Tclose(tmp_dt) < 0) TEST_ERROR
+
+ /* Close IDs */
+ if(H5Tclose(arr_int) < 0) TEST_ERROR
+ if(H5Tclose(arr_ext) < 0) TEST_ERROR
+ if(H5Fclose(file) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ return 1;
+} /* end test_compound_17() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_query
*
* Purpose: Tests query functions of compound and enumeration types.
@@ -2938,10 +3712,41 @@ test_named (hid_t fapl)
if(H5Tclose(t3) < 0) goto error;
if(H5Dclose(dset) < 0) goto error;
- /* Clean up */
+ /* Close */
if(H5Tclose(type) < 0) goto error;
if(H5Sclose(space) < 0) goto error;
if(H5Fclose(file) < 0) goto error;
+
+ /* Reopen file with read only access */
+ if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ goto error;
+
+ /* Verify that H5Tcommit2 returns an error */
+ if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error;
+ H5E_BEGIN_TRY {
+ status = H5Tcommit2(file, "test_named_3 (should not exist)", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if(status >= 0) {
+ H5_FAILED();
+ HDputs (" Types should not be committable to a read-only file!");
+ goto error;
+ }
+
+ /* Verify that H5Tcommit_anon returns an error */
+ if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error;
+ H5E_BEGIN_TRY {
+ status = H5Tcommit_anon(file, type, H5P_DEFAULT, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if(status >= 0) {
+ H5_FAILED();
+ HDputs (" Types should not be committable to a read-only file!");
+ goto error;
+ }
+
+ /* Close */
+ if(H5Tclose(type) < 0) goto error;
+ if(H5Fclose(file) < 0) goto error;
+
PASSED();
return 0;
@@ -3327,7 +4132,6 @@ test_conv_str_3(void)
int ret_value = 1;
int size;
H5T_pad_t inpad;
- H5T_cset_t cset;
H5T_sign_t sign;
char* tag;
herr_t ret;
@@ -3347,13 +4151,13 @@ test_conv_str_3(void)
buf[i*8+j++] = '\0';
}
- if ((size=H5Tget_precision(type))==0) goto error;
- if ((size=H5Tget_size(type))==0) goto error;
- if (H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE) < 0) goto error;
- if ((cset=H5Tget_cset(type)) < 0) goto error;
- if (H5Tget_strpad(type) < 0) goto error;
- if (H5Tset_offset(type, 0) < 0) goto error;
- if (H5Tget_order(type) < 0) goto error;
+ if(H5Tget_precision(type) == 0) FAIL_STACK_ERROR
+ if(H5Tget_size(type) == 0) FAIL_STACK_ERROR
+ if(H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE) < 0) FAIL_STACK_ERROR
+ if(H5Tget_cset(type) < 0) FAIL_STACK_ERROR
+ if(H5Tget_strpad(type) < 0) FAIL_STACK_ERROR
+ if(H5Tset_offset(type, 0) < 0) FAIL_STACK_ERROR
+ if(H5Tget_order(type) < 0) FAIL_STACK_ERROR
H5E_BEGIN_TRY {
ret=H5Tset_precision(type, nelmts);
@@ -3365,7 +4169,7 @@ test_conv_str_3(void)
} /* end if */
H5E_BEGIN_TRY {
- size=H5Tget_ebias(type);
+ size = H5Tget_ebias(type);
} H5E_END_TRY;
if (size>0) {
H5_FAILED();
@@ -4139,8 +4943,9 @@ opaque_funcs(void)
* Programmer: Raymond Lu
* July 14, 2004
*
- * Modifications:
- *
+ * Modifications: Raymond Lu
+ * July 13, 2009
+ * Added the test for VL string types.
*-------------------------------------------------------------------------
*/
static int
@@ -4152,14 +4957,16 @@ test_encode(void)
long c;
double d;
};
- hid_t file=-1, tid1=-1, tid2=-1;
- hid_t decoded_tid1=-1, decoded_tid2=-1;
+ hid_t file=-1, tid1=-1, tid2=-1, tid3=-1;
+ hid_t decoded_tid1=-1, decoded_tid2=-1, decoded_tid3=-1;
char filename[1024];
char compnd_type[]="Compound_type", enum_type[]="Enum_type";
+ char vlstr_type[]="VLstring_type";
short enum_val;
size_t cmpd_buf_size = 0;
size_t enum_buf_size = 0;
- unsigned char *cmpd_buf=NULL, *enum_buf=NULL;
+ size_t vlstr_buf_size = 0;
+ unsigned char *cmpd_buf=NULL, *enum_buf=NULL, *vlstr_buf=NULL;
herr_t ret;
TESTING("functions of encoding and decoding datatypes");
@@ -4170,7 +4977,7 @@ test_encode(void)
goto error;
/*-----------------------------------------------------------------------
- * Create compound and enumerate datatypes
+ * Create compound, enumerate, and VL string datatypes
*-----------------------------------------------------------------------
*/
/* Create a compound datatype */
@@ -4232,8 +5039,20 @@ test_encode(void)
goto error;
} /* end if */
+ /* Create a variable-length string type */
+ if((tid3 = H5Tcopy(H5T_C_S1)) < 0) {
+ H5_FAILED();
+ printf("Can't copy a string type\n");
+ goto error;
+ } /* end if */
+ if(H5Tset_size(tid3, H5T_VARIABLE) < 0) {
+ H5_FAILED();
+ printf("Can't the string type to be variable-length\n");
+ goto error;
+ } /* end if */
+
/*-----------------------------------------------------------------------
- * Test encoding and decoding compound and enumerate datatypes
+ * Test encoding and decoding compound, enumerate, and VL string datatypes
*-----------------------------------------------------------------------
*/
/* Encode compound type in a buffer */
@@ -4328,8 +5147,44 @@ test_encode(void)
goto error;
} /* end if */
+
+ /* Encode VL string type in a buffer */
+ if(H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ if(vlstr_buf_size>0)
+ vlstr_buf = (unsigned char*)calloc(1, vlstr_buf_size);
+
+ if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Decode from the VL string buffer and return an object handle */
+ if((decoded_tid3=H5Tdecode(vlstr_buf)) < 0) {
+ H5_FAILED();
+ printf("Can't decode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid3, tid3)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+ if(!H5Tis_variable_str(decoded_tid3)) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/*-----------------------------------------------------------------------
- * Commit and reopen the compound and enumerate datatypes
+ * Commit and reopen the compound, enumerate, VL string datatypes
*-----------------------------------------------------------------------
*/
/* Commit compound datatype and close it */
@@ -4370,13 +5225,37 @@ test_encode(void)
free(enum_buf);
enum_buf_size = 0;
+ /* Commit enumeration datatype and close it */
+ if(H5Tcommit2(file, vlstr_type, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) {
+ H5_FAILED();
+ printf("Can't commit vl string datatype\n");
+ goto error;
+ } /* end if */
+ if(H5Tclose(tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
+ if(H5Tclose(decoded_tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
+ free(vlstr_buf);
+ vlstr_buf_size = 0;
+
/* Open the dataytpe for query */
if((tid1 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if((tid2 = H5Topen2(file, enum_type, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
+ if((tid3 = H5Topen2(file, vlstr_type, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
-
+ /*-----------------------------------------------------------------------
+ * Test encoding and decoding compound, enumerate, and vl string datatypes
+ *-----------------------------------------------------------------------
+ */
/* Encode compound type in a buffer */
if(H5Tencode(tid1, NULL, &cmpd_buf_size) < 0) {
H5_FAILED();
@@ -4416,10 +5295,6 @@ test_encode(void)
goto error;
} /* end if */
- /*-----------------------------------------------------------------------
- * Test encoding and decoding compound and enumerate datatypes
- *-----------------------------------------------------------------------
- */
/* Encode enumerate type in a buffer */
if(H5Tencode(tid2, NULL, &enum_buf_size) < 0) {
H5_FAILED();
@@ -4462,6 +5337,41 @@ test_encode(void)
goto error;
} /* end if */
+ /* Encode VL string type in a buffer */
+ if(H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ if(vlstr_buf_size>0)
+ vlstr_buf = (unsigned char*)calloc(1, vlstr_buf_size);
+
+ if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) {
+ H5_FAILED();
+ printf("Can't encode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Decode from the VL string buffer and return an object handle */
+ if((decoded_tid3=H5Tdecode(vlstr_buf)) < 0) {
+ H5_FAILED();
+ printf("Can't decode VL string type\n");
+ goto error;
+ } /* end if */
+
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid3, tid3)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+ if(!H5Tis_variable_str(decoded_tid3)) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/*-----------------------------------------------------------------------
* Close and release
*-----------------------------------------------------------------------
@@ -4477,6 +5387,11 @@ test_encode(void)
printf("Can't close datatype\n");
goto error;
} /* end if */
+ if(H5Tclose(tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
if(H5Tclose(decoded_tid1) < 0) {
H5_FAILED();
@@ -4488,6 +5403,11 @@ test_encode(void)
printf("Can't close datatype\n");
goto error;
} /* end if */
+ if(H5Tclose(decoded_tid3) < 0) {
+ H5_FAILED();
+ printf("Can't close datatype\n");
+ goto error;
+ } /* end if */
if(H5Fclose(file) < 0) {
H5_FAILED();
@@ -4505,8 +5425,10 @@ test_encode(void)
H5E_BEGIN_TRY {
H5Tclose (tid1);
H5Tclose (tid2);
+ H5Tclose (tid3);
H5Tclose (decoded_tid1);
H5Tclose (decoded_tid2);
+ H5Tclose (decoded_tid3);
H5Fclose (file);
} H5E_END_TRY;
return 1;
@@ -4637,7 +5559,7 @@ test_latest(void)
if(H5Oget_info_by_name(file, compnd_type, &oi, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR
new_dtype_oh_size = oi.hdr.space.total;
-
+
/* Check that the new format is smaller than the old format */
if(old_dtype_oh_size <= new_dtype_oh_size)
TEST_ERROR
@@ -4875,6 +5797,375 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_set_order
+ *
+ * Purpose: Tests H5Tset_order/H5Tget_order. Verifies that
+ * H5T_ORDER_NONE cannot be set.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * January 23, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_set_order(void)
+{
+ hid_t dtype; /* Datatype ID */
+ H5T_order_t order; /* Byte order */
+ hsize_t dims[2] = {3, 4}; /* Array dimenstions */
+ herr_t ret; /* Generic return value */
+
+ TESTING("H5Tset/get_order");
+
+ /* Integer */
+ if ((dtype = H5Tcopy(H5T_STD_I32BE)) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Float */
+ if ((dtype = H5Tcopy(H5T_IEEE_F64LE)) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Time */
+ if ((dtype = H5Tcopy(H5T_UNIX_D64BE)) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Fixed length string */
+ if ((dtype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
+ if (H5Tset_size(dtype, 5) < 0) TEST_ERROR
+ if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR;
+ if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR;
+
+ /* Variable length string */
+ if (H5Tset_size(dtype, H5T_VARIABLE) < 0) TEST_ERROR
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Bitfield */
+ if ((dtype = H5Tcopy(H5T_STD_B16LE)) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Opaque - functions should fail */
+ if ((dtype = H5Tcreate(H5T_OPAQUE, 96)) < 0) TEST_ERROR
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_LE);
+ order = H5Tget_order(dtype);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (order >= 0) TEST_ERROR
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Compound - functions should fail */
+ if ((dtype = H5Tcreate(H5T_COMPOUND, 48)) < 0) TEST_ERROR
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_LE);
+ order = H5Tget_order(dtype);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (order >= 0) TEST_ERROR
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Object reference */
+ if ((dtype = H5Tcopy(H5T_STD_REF_OBJ)) < 0) TEST_ERROR
+ if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR;
+ if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Region reference */
+ if ((dtype = H5Tcopy(H5T_STD_REF_DSETREG)) < 0) TEST_ERROR
+ if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR;
+ if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Enum */
+ if ((dtype = H5Tenum_create(H5T_STD_I16BE)) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Vlen */
+ if ((dtype = H5Tvlen_create(H5T_STD_U64LE)) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ /* Array */
+ if ((dtype = H5Tarray_create2(H5T_IEEE_F64BE, 2, dims)) < 0) TEST_ERROR
+ if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR;
+ H5E_BEGIN_TRY
+ ret = H5Tset_order(dtype, H5T_ORDER_NONE);
+ H5E_END_TRY
+ if (ret >= 0) TEST_ERROR
+ if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR
+ if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR;
+ if (H5Tclose(dtype) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ H5Tclose (dtype);
+ H5E_END_TRY;
+ return 1;
+} /* end test_set_order() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_named_indirect_reopen
+ *
+ * Purpose: Tests that open named datatypes can be reopened indirectly
+ * through H5Dget_type without causing problems.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Thursday, June 4, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_named_indirect_reopen(hid_t fapl)
+{
+ hid_t file=-1, type=-1, reopened_type=-1, strtype=-1, dset=-1, space=-1;
+ static hsize_t dims[1] = {3};
+ size_t dt_size;
+ int enum_value;
+ const char *tag = "opaque_tag";
+ char *tag_ret = NULL;
+ char filename[1024];
+
+ TESTING("indirectly reopening committed datatypes");
+
+ /* Create file, dataspace */
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if ((space = H5Screate_simple (1, dims, dims)) < 0) TEST_ERROR
+
+ /*
+ * Compound
+ */
+
+ /* Create compound type */
+ if((strtype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
+ if(H5Tset_size(strtype, H5T_VARIABLE) < 0) TEST_ERROR
+ if((type = H5Tcreate(H5T_COMPOUND, sizeof(char *))) < 0) TEST_ERROR
+ if(H5Tinsert(type, "vlstr", 0, strtype) < 0) TEST_ERROR
+ if(H5Tclose(strtype) < 0) TEST_ERROR
+
+ /* Get size of compound type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit compound type and verify the size doesn't change */
+ if(H5Tcommit2(file, "cmpd_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with compound type */
+ if((dset = H5Dcreate2(file, "cmpd_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Enum
+ */
+
+ /* Create enum type */
+ if((type = H5Tenum_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ enum_value = 0;
+ if(H5Tenum_insert(type, "val1", &enum_value) < 0) TEST_ERROR
+ enum_value = 1;
+ if(H5Tenum_insert(type, "val2", &enum_value) < 0) TEST_ERROR
+
+ /* Get size of enum type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit enum type and verify the size doesn't change */
+ if(H5Tcommit2(file, "enum_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with enum type */
+ if((dset = H5Dcreate2(file, "enum_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Vlen
+ */
+
+ /* Create vlen type */
+ if((type = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+
+ /* Get size of vlen type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit vlen type and verify the size doesn't change */
+ if(H5Tcommit2(file, "vlen_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with vlen type */
+ if((dset = H5Dcreate2(file, "vlen_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Opaque
+ */
+
+ /* Create opaque type */
+ if((type = H5Tcreate(H5T_OPAQUE, 13)) < 0) TEST_ERROR
+ if(H5Tset_tag(type, tag) < 0) TEST_ERROR
+
+ /* Get size of opaque type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit opaque type and verify the size and tag don't change */
+ if(H5Tcommit2(file, "opaque_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+ if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR
+ if(HDstrcmp(tag, tag_ret)) TEST_ERROR
+ HDfree(tag_ret);
+ tag_ret = NULL;
+
+ /* Create dataset with opaque type */
+ if((dset = H5Dcreate2(file, "opaque_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size and tag don't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+ if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR
+ if(HDstrcmp(tag, tag_ret)) TEST_ERROR
+ HDfree(tag_ret);
+ tag_ret = NULL;
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /*
+ * Array
+ */
+
+ /* Create array type */
+ if((type = H5Tarray_create2(H5T_NATIVE_INT, 1, dims)) < 0) TEST_ERROR
+
+ /* Get size of array type */
+ if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR
+
+ /* Commit array type and verify the size doesn't change */
+ if(H5Tcommit2(file, "array_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(type)) TEST_ERROR
+
+ /* Create dataset with array type */
+ if((dset = H5Dcreate2(file, "array_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Indirectly reopen type and verify that the size doesn't change */
+ if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR
+ if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
+
+ /* Close types and dataset */
+ if(H5Tclose(type) < 0) TEST_ERROR
+ if(H5Tclose(reopened_type) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /* Close file and dataspace */
+ if(H5Sclose(space) < 0) TEST_ERROR
+ if(H5Fclose(file) < 0) TEST_ERROR
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(type);
+ H5Tclose(strtype);
+ H5Tclose(reopened_type);
+ H5Sclose(space);
+ H5Dclose(dset);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ if(tag_ret)
+ HDfree(tag_ret);
+ return 1;
+} /* end test_named_indirect_reopen() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_deprec
*
* Purpose: Tests deprecated API routines for datatypes.
@@ -4987,10 +6278,29 @@ test_deprec(hid_t fapl)
if(!status)
FAIL_PUTS_ERROR(" Opened named types should be named types!")
- /* Clean up */
+ /* Close */
if(H5Tclose(type) < 0) FAIL_STACK_ERROR
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
+ /* Reopen file with read only access */
+ if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ goto error;
+
+ /* Verify that H5Tcommit2 returns an error */
+ if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error;
+ H5E_BEGIN_TRY {
+ status = H5Tcommit1(file, "test_named_3 (should not exist)", type);
+ } H5E_END_TRY;
+ if(status >= 0) {
+ H5_FAILED();
+ HDputs (" Types should not be committable to a read-only file!");
+ goto error;
+ }
+
+ /* Close */
+ if(H5Tclose(type) < 0) goto error;
+ if(H5Fclose(file) < 0) goto error;
+
PASSED();
return 0;
@@ -5027,7 +6337,7 @@ main(void)
hid_t fapl = -1;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
fapl = h5_fileaccess();
@@ -5047,6 +6357,7 @@ main(void)
nerrors += test_encode();
nerrors += test_latest();
nerrors += test_int_float_except();
+ nerrors += test_named_indirect_reopen(fapl);
#ifndef H5_NO_DEPRECATED_SYMBOLS
nerrors += test_deprec(fapl);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
@@ -5068,11 +6379,16 @@ main(void)
nerrors += test_compound_11();
nerrors += test_compound_12();
nerrors += test_compound_13();
+ nerrors += test_compound_14();
+ nerrors += test_compound_15();
+ nerrors += test_compound_16();
+ nerrors += test_compound_17();
nerrors += test_conv_enum_1();
nerrors += test_conv_enum_2();
nerrors += test_conv_bitfield();
nerrors += test_bitfield_funcs();
nerrors += test_opaque();
+ nerrors += test_set_order();
if(nerrors) {
printf("***** %lu FAILURE%s! *****\n",
diff --git a/test/earray.c b/test/earray.c
new file mode 100644
index 0000000..c1584f9
--- /dev/null
+++ b/test/earray.c
@@ -0,0 +1,2955 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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@hdfgroup.org>
+ * Tuesday, June 17, 2008
+ */
+#include "h5test.h"
+
+/*
+ * This file needs to access private datatypes from the H5EA package.
+ * This file also needs to access the extensible array testing code.
+ */
+#define H5EA_PACKAGE
+#define H5EA_TESTING
+#include "H5EApkg.h" /* Extensible Arrays */
+
+/* Other private headers that this test requires */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Vprivate.h" /* Vectors and arrays */
+
+
+/* Local macros */
+
+/* Max. testfile name length */
+#define EARRAY_FILENAME_LEN 1024
+
+/* Extensible array creation values */
+#define ELMT_SIZE sizeof(uint64_t)
+#define MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */
+#define IDX_BLK_ELMTS 4
+#define SUP_BLK_MIN_DATA_PTRS 4
+#define DATA_BLK_MIN_ELMTS 16
+#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */
+
+/* Convenience macros for computing earray state */
+#define EA_HDR_SIZE 72 /* (hard-coded, current size) */
+#define EA_IBLOCK_SIZE 298 /* (hard-coded, current size) */
+#define EA_NELMTS(cparam, tparam, idx, sblk_idx) \
+ (hsize_t)(cparam->idx_blk_elmts + \
+ tparam->sblk_info[sblk_idx].start_idx + \
+ ((1 + ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts)) \
+ * tparam->sblk_info[sblk_idx].dblk_nelmts))
+#define EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx) \
+ (1 + tparam->sblk_info[sblk_idx].start_dblk + \
+ ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts))
+
+/* Iterator parameter values */
+#define EA_RND2_SCALE 100
+#define EA_CYC_COUNT 4
+
+/* Local typedefs */
+
+/* Types of tests to perform */
+typedef enum {
+ EARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */
+ EARRAY_TEST_REOPEN, /* Set the reopen_array flag */
+ EARRAY_TEST_NTESTS /* The number of test types, must be last */
+} earray_test_type_t;
+
+/* Types of iteration to perform */
+typedef enum {
+ EARRAY_ITER_FW, /* "Forward" iteration */
+ EARRAY_ITER_RV, /* "Reverse" iteration */
+ EARRAY_ITER_RND, /* "Random" iteration */
+ EARRAY_ITER_CYC, /* "Cyclic" iteration */
+ EARRAY_ITER_RND2, /* "Random #2" iteration */
+ EARRAY_ITER_NITERS /* The number of iteration types, must be last */
+} earray_iter_type_t;
+
+/* Orders to operate on entries */
+typedef enum {
+ EARRAY_DIR_FORWARD, /* Insert objects from 0 -> nobjs */
+ EARRAY_DIR_RANDOM, /* Insert objects randomly from 0 - nobjs */
+ EARRAY_DIR_CYCLIC, /* Insert every n'th object cyclicly: 0, n, 2n, 3n, ..., nobjs/n, 1+nobjs/n, 1+n+nobjs/n, 1+2n+nobjs/n, ..., nobjs */
+ EARRAY_DIR_REVERSE, /* Insert objects from nobjs -> 0 */
+ EARRAY_DIR_INWARD, /* Insert objects from outside to in: 0, nobjs, 1, nobjs-1, 2, nobjs-2, ..., nobjs/2 */
+ EARRAY_DIR_OUTWARD, /* Insert objects from inside to out: nobjs/2, (nobjs/2)-1, (nobjs/2)+1, ..., 0, nobjs */
+ EARRAY_DIR_NDIRS /* The number of different insertion orders, must be last */
+} earray_test_dir_t;
+
+/* Whether to compress data blocks */
+typedef enum {
+ EARRAY_TEST_NO_COMPRESS, /* Don't compress data blocks */
+ EARRAY_TEST_COMPRESS, /* Compress data blocks */
+ EARRAY_TEST_COMP_N /* The number of different ways to test compressing array blocks, must be last */
+} earray_test_comp_t;
+
+/* Extensible array state information */
+typedef struct earray_state_t {
+ hsize_t hdr_size; /* Size of header */
+ hsize_t nindex_blks; /* # of index blocks */
+ hsize_t index_blk_size; /* Size of index blocks */
+ hsize_t nsuper_blks; /* # of super blocks */
+ hsize_t super_blk_size; /* Size of super blocks */
+ hsize_t ndata_blks; /* # of data blocks */
+ hsize_t data_blk_size; /* Size of data blocks */
+ hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
+ hsize_t nelmts; /* # of elements "realized" */
+} earray_state_t;
+
+/* Forward decl. */
+typedef struct earray_test_param_t earray_test_param_t;
+
+/* Extensible array iterator class */
+typedef struct earray_iter_t {
+ void *(*init)(const H5EA_create_t *cparam, const earray_test_param_t *tparam,
+ hsize_t cnt); /* Initialize/allocate iterator private info */
+ hssize_t (*next)(void *info); /* Get the next element to test */
+ hssize_t (*max_elem)(const void *info); /* Get the max. element set */
+ int (*state)(void *_eiter, const H5EA_create_t *cparam,
+ const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx); /* Get the state of the extensible array */
+ herr_t (*term)(void *info); /* Shutdown/free iterator private info */
+} earray_iter_t;
+
+/* Testing parameters */
+struct earray_test_param_t {
+ earray_test_type_t reopen_array; /* Whether to re-open the array during the test */
+ earray_test_comp_t comp; /* Whether to compress the blocks or not */
+ const earray_iter_t *eiter; /* Iterator to use for this test */
+
+ /* Super block information */
+ size_t nsblks; /* Number of superblocks needed for array */
+ H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */
+};
+
+/* Flush depend test context */
+typedef struct earray_flush_depend_ctx_t {
+ hbool_t base_obj; /* Flag to indicate that base object has been flushed */
+ hbool_t idx0_obj; /* Flag to indicate that index 0's object has been flushed */
+ hbool_t idx0_elem; /* Flag to indicate that index 0's element has been flushed */
+ hbool_t idx1_obj; /* Flag to indicate that index 1's object has been flushed */
+ hbool_t idx1_elem; /* Flag to indicate that index 1's element has been flushed */
+ hbool_t idx10000_obj; /* Flag to indicate that index 10000's object has been flushed */
+ hbool_t idx10000_elem; /* Flag to indicate that index 10000's element has been flushed */
+} earray_flush_depend_ctx_t;
+
+/* Extensible array test cache object */
+typedef struct earray_test_t {
+ /* Information for H5AC cache functions, _must_ be first field in structure */
+ H5AC_info_t cache_info;
+
+ /* Entry information */
+ uint64_t idx; /* Index that entry corresponds to */
+ earray_flush_depend_ctx_t *fd_info; /* Context information for flush depend test */
+} earray_test_t;
+
+
+/* Local prototypes */
+
+/* Metadata cache (H5AC) callbacks */
+static earray_test_t *earray_cache_test_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
+static herr_t earray_cache_test_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, earray_test_t *test, unsigned * flags_ptr);
+static herr_t earray_cache_test_clear(H5F_t *f, earray_test_t *test, hbool_t destroy);
+static herr_t earray_cache_test_size(const H5F_t *f, const earray_test_t *test, size_t *size_ptr);
+static herr_t earray_cache_test_dest(H5F_t *f, earray_test_t *test);
+
+
+/* Local variables */
+const char *FILENAME[] = {
+ "earray",
+ NULL
+};
+
+/* Filename to use for all tests */
+char filename_g[EARRAY_FILENAME_LEN];
+
+/* Empty file size */
+h5_stat_size_t empty_size_g;
+
+/* H5EA test object inherits cache-like properties from H5AC */
+const H5AC_class_t H5AC_EARRAY_TEST[1] = {{
+ H5AC_TEST_ID,
+ (H5AC_load_func_t)earray_cache_test_load,
+ (H5AC_flush_func_t)earray_cache_test_flush,
+ (H5AC_dest_func_t)earray_cache_test_dest,
+ (H5AC_clear_func_t)earray_cache_test_clear,
+ (H5AC_notify_func_t)NULL,
+ (H5AC_size_func_t)earray_cache_test_size,
+}};
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: init_cparam
+ *
+ * Purpose: Initialize array creation parameter structure
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 21, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+init_cparam(H5EA_create_t *cparam)
+{
+ /* Wipe out background */
+ HDmemset(cparam, 0, sizeof(*cparam));
+
+ /* General parameters */
+ cparam->cls = H5EA_CLS_TEST;
+ cparam->raw_elmt_size = ELMT_SIZE;
+ cparam->max_nelmts_bits = MAX_NELMTS_BITS;
+ cparam->idx_blk_elmts = IDX_BLK_ELMTS;
+ cparam->sup_blk_min_data_ptrs = SUP_BLK_MIN_DATA_PTRS;
+ cparam->data_blk_min_elmts = DATA_BLK_MIN_ELMTS;
+ cparam->max_dblk_page_nelmts_bits = MAX_DBLOCK_PAGE_NELMTS_BITS;
+
+ return(0);
+} /* init_cparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: init_tparam
+ *
+ * Purpose: Initialize array testing parameter structure
+ *
+ * Note: This initialization is the same as that in H5EA_hdr_init()
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 25, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+init_tparam(earray_test_param_t *tparam, const H5EA_create_t *cparam)
+{
+ hsize_t start_idx; /* First element index for each super block */
+ hsize_t start_dblk; /* First data block index for each super block */
+ size_t u; /* Local index variable */
+
+ /* Wipe out background */
+ HDmemset(tparam, 0, sizeof(*tparam));
+
+ /* Compute general information */
+ tparam->nsblks = 1 + (cparam->max_nelmts_bits - H5V_log2_of2(cparam->data_blk_min_elmts));
+
+ /* Allocate information for each super block */
+ tparam->sblk_info = (H5EA_sblk_info_t *)HDmalloc(sizeof(H5EA_sblk_info_t) * tparam->nsblks);
+ HDassert(tparam->sblk_info);
+
+ /* Compute information about each super block */
+ start_idx = 0;
+ start_dblk = 0;
+ for(u = 0; u < tparam->nsblks; u++) {
+ tparam->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2);
+ tparam->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * cparam->data_blk_min_elmts;
+ tparam->sblk_info[u].start_idx = start_idx;
+ tparam->sblk_info[u].start_dblk = start_dblk;
+
+ /* Advance starting indices for next super block */
+ start_idx += (hsize_t)tparam->sblk_info[u].ndblks * (hsize_t)tparam->sblk_info[u].dblk_nelmts;
+ start_dblk += (hsize_t)tparam->sblk_info[u].ndblks;
+ } /* end for */
+
+ return(0);
+} /* init_tparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: finish_tparam
+ *
+ * Purpose: Close down array testing parameter structure
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 25, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+finish_tparam(earray_test_param_t *tparam)
+{
+ /* Release super block information */
+ HDfree(tparam->sblk_info);
+ tparam->sblk_info = NULL;
+
+ return(0);
+} /* finish_tparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_file
+ *
+ * Purpose: Create file and retrieve pointer to internal file object
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_file(hid_t fapl, hid_t *file, H5F_t **f)
+{
+ /* Create the file to work on */
+ if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ FAIL_STACK_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* create_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_stats
+ *
+ * Purpose: Verify stats for an extensible array
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 21, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_stats(const H5EA_t *ea, const earray_state_t *state)
+{
+ H5EA_stat_t earray_stats; /* Statistics about the array */
+
+ /* Get statistics for extensible array and verify they are correct */
+ if(H5EA_get_stats(ea, &earray_stats) < 0)
+ FAIL_STACK_ERROR
+
+ /* Compare information */
+ if(earray_stats.stored.max_idx_set != state->max_idx_set) {
+ HDfprintf(stdout, "earray_stats.stored.max_idx_set = %Hu, state->max_idx_set = %Hu\n", earray_stats.stored.max_idx_set, state->max_idx_set);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.stored.nelmts != state->nelmts) {
+ HDfprintf(stdout, "earray_stats.stored.nelmts = %Hu, state->nelmts = %Hu\n", earray_stats.stored.nelmts, state->nelmts);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.computed.hdr_size != state->hdr_size) {
+ HDfprintf(stdout, "earray_stats.computed.hdr_size = %Hu, state->hdr_size = %Hu\n", earray_stats.computed.hdr_size, state->hdr_size);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.computed.nindex_blks != state->nindex_blks) {
+ HDfprintf(stdout, "earray_stats.computed.nindex_blks = %Hu, state->nindex_blks = %Hu\n", earray_stats.computed.nindex_blks, state->nindex_blks);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.computed.index_blk_size != state->index_blk_size) {
+ HDfprintf(stdout, "earray_stats.computed.index_blk_size = %Hu, state->index_blk_size = %Hu\n", earray_stats.computed.index_blk_size, state->index_blk_size);
+ TEST_ERROR
+ } /* end if */
+ if(earray_stats.stored.ndata_blks != state->ndata_blks) {
+ HDfprintf(stdout, "earray_stats.stored.ndata_blks = %Hu, state->ndata_blks = %Hu\n", earray_stats.stored.ndata_blks, state->ndata_blks);
+ TEST_ERROR
+ } /* end if */
+/* Don't compare this currently, it's very hard to compute */
+#ifdef NOT_YET
+ if(earray_stats.stored.data_blk_size != state->data_blk_size) {
+ HDfprintf(stdout, "earray_stats.stored.data_blk_size = %Hu, state->data_blk_size = %Hu\n", earray_stats.stored.data_blk_size, state->data_blk_size);
+ TEST_ERROR
+ } /* end if */
+#endif /* NOT_YET */
+ if(earray_stats.stored.nsuper_blks != state->nsuper_blks) {
+ HDfprintf(stdout, "earray_stats.stored.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", earray_stats.stored.nsuper_blks, state->nsuper_blks);
+ TEST_ERROR
+ } /* end if */
+/* Don't compare this currently, it's very hard to compute */
+#ifdef NOT_YET
+ if(earray_stats.stored.super_blk_size != state->super_blk_size) {
+ HDfprintf(stdout, "earray_stats.stored.super_blk_size = %Hu, state->super_blk_size = %Hu\n", earray_stats.stored.super_blk_size, state->super_blk_size);
+ TEST_ERROR
+ } /* end if */
+#endif /* NOT_YET */
+#ifdef QAK
+HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.stored.nelmts,
+ (earray_stats.computed.hdr_size + earray_stats.computed.index_blk_size + earray_stats.stored.super_blk_size + earray_stats.stored.data_blk_size));
+#endif /* QAK */
+
+ /* All tests passed */
+ return(0);
+
+error:
+ return(-1);
+} /* check_stats() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: reopen_file
+ *
+ * Purpose: Perform common "re-open" operations on file & array for testing
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
+ H5EA_t **ea, haddr_t ea_addr, const earray_test_param_t *tparam)
+{
+ /* Check for closing & re-opening the array */
+ /* (actually will close & re-open the file as well) */
+ if(tparam->reopen_array) {
+ /* Close array, if given */
+ if(ea) {
+ if(H5EA_close(*ea, dxpl) < 0)
+ FAIL_STACK_ERROR
+ *ea = NULL;
+ } /* end if */
+
+ /* Close file */
+ if(H5Fclose(*file) < 0)
+ FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
+
+ /* Re-open the file */
+ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open array, if given */
+ if(ea) {
+ if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+ } /* end if */
+ } /* end if */
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* reopen_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_array
+ *
+ * Purpose: Create an extensible array and perform initial checks
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_array(H5F_t *f, hid_t dxpl, const H5EA_create_t *cparam,
+ H5EA_t **ea, haddr_t *ea_addr, H5EA__ctx_cb_t *cb)
+{
+ hsize_t nelmts; /* Number of elements in array */
+ earray_state_t state; /* State of extensible array */
+
+ /* Create array */
+ if(NULL == (*ea = H5EA_create(f, dxpl, cparam, cb)))
+ FAIL_STACK_ERROR
+
+ /* Check status of array */
+ nelmts = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(*ea, &nelmts) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts > 0)
+ TEST_ERROR
+ if(H5EA_get_addr(*ea, ea_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(*ea_addr))
+ TEST_ERROR
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
+ if(check_stats(*ea, &state))
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* create_array() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_cparam
+ *
+ * Purpose: Verify creation parameters are correct
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_cparam(const H5EA_t *ea, const H5EA_create_t *cparam)
+{
+ H5EA_create_t test_cparam; /* Creation parameters for array */
+
+ /* Retrieve creation parameters */
+ HDmemset(&test_cparam, 0, sizeof(H5EA_create_t));
+ if(H5EA_get_cparam_test(ea, &test_cparam) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify creation parameters */
+ if(H5EA_cmp_cparam_test(cparam, &test_cparam))
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* verify_cparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: finish
+ *
+ * Purpose: Close array, delete array, close file and verify that file
+ * is empty size
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+finish(hid_t file, hid_t fapl, H5F_t *f, H5EA_t *ea, haddr_t ea_addr)
+{
+ h5_stat_size_t file_size; /* File size, after deleting array */
+
+ /* Close the extensible array */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+#ifdef QAK
+HDfprintf(stderr, "ea_addr = %a\n", ea_addr);
+H5Fflush(file, H5F_SCOPE_GLOBAL);
+HDsystem("cp earray.h5 earray.h5.save");
+#endif /* QAK */
+
+ /* Delete array */
+ if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename_g, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size_g)
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* finish() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: earray_cache_test_load
+ *
+ * Purpose: Loads an extensible array test object from the disk.
+ *
+ * Return: Success: Pointer to a new extensible array test object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 26 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static earray_test_t *
+earray_cache_test_load(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr, const void UNUSED *udata1, void UNUSED *udata2)
+{
+ /* Check arguments */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Should never be called */
+ HDassert(0 && "Can't be called!");
+
+ return(NULL);
+} /* end earray_cache_test_load() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: earray_cache_test_flush
+ *
+ * Purpose: Flushes a dirty extensible array test object to disk.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 26 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+earray_cache_test_flush(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, hbool_t destroy, haddr_t UNUSED addr, earray_test_t *test, unsigned UNUSED * flags_ptr)
+{
+ /* check arguments */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(test);
+
+ if(test->cache_info.is_dirty) {
+ /* Check for out of order flush */
+ if(test->fd_info->base_obj)
+ TEST_ERROR
+
+ /* Check which index this entry corresponds to */
+ if((uint64_t)0 == test->idx) {
+ /* Check for out of order flush */
+ if(test->fd_info->idx0_obj || test->fd_info->idx0_elem)
+ TEST_ERROR
+
+ /* Set flag for object flush */
+ test->fd_info->idx0_obj = TRUE;
+ } /* end if */
+ else if((uint64_t)1 == test->idx) {
+ /* Check for out of order flush */
+ if(test->fd_info->idx1_obj || test->fd_info->idx1_elem)
+ TEST_ERROR
+
+ /* Set flag for object flush */
+ test->fd_info->idx1_obj = TRUE;
+ } /* end if */
+ else if((uint64_t)10000 == test->idx) {
+ /* Check for out of order flush */
+ if(test->fd_info->idx10000_obj || test->fd_info->idx10000_elem)
+ TEST_ERROR
+
+ /* Set flag for object flush */
+ test->fd_info->idx10000_obj = TRUE;
+ } /* end if */
+ else if((uint64_t)-1 == test->idx) {
+ /* Set flag for object flush */
+ test->fd_info->base_obj = TRUE;
+ } /* end if */
+
+ /* Mark the entry as clean */
+ test->cache_info.is_dirty = FALSE;
+ } /* end if */
+
+ if(destroy)
+ if(earray_cache_test_dest(f, test) < 0)
+ TEST_ERROR
+
+ return(SUCCEED);
+
+error:
+ return(FAIL);
+} /* earray_cache_test_flush() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: earray_cache_test_dest
+ *
+ * Purpose: Destroys an extensible array test object in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 26 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+earray_cache_test_dest(H5F_t UNUSED *f, earray_test_t *test)
+{
+ /*
+ * Check arguments.
+ */
+ HDassert(test);
+
+ /* Free the shared info itself */
+ HDfree(test);
+
+ return(SUCCEED);
+} /* end earray_cache_test_dest() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: earray_cache_test_clear
+ *
+ * Purpose: Mark an extensible array test object in memory as non-dirty.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 26 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+earray_cache_test_clear(H5F_t *f, earray_test_t *test, hbool_t destroy)
+{
+ /*
+ * Check arguments.
+ */
+ HDassert(test);
+
+ /* Reset the dirty flag. */
+ test->cache_info.is_dirty = FALSE;
+
+ if(destroy)
+ if(earray_cache_test_dest(f, test) < 0)
+ TEST_ERROR
+
+ return(SUCCEED);
+
+error:
+ return(FAIL);
+} /* end earray_cache_test_clear() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: earray_cache_test_size
+ *
+ * Purpose: Compute the size in bytes of an extensible array test object
+ * on disk, and return it in *size_ptr. On failure,
+ * the value of *size_ptr is undefined.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 26 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+earray_cache_test_size(const H5F_t UNUSED *f, const earray_test_t UNUSED *test, size_t *size_ptr)
+{
+ /* check arguments */
+ HDassert(f);
+ HDassert(test);
+ HDassert(size_ptr);
+
+ /* Set size value */
+ /* (hard-code to 1) */
+ *size_ptr = 1;
+
+ return(SUCCEED);
+} /* earray_cache_test_size() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_create
+ *
+ * Purpose: Test creating extensible array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 7, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("invalid extensible array creation parameters");
+
+#ifndef NDEBUG
+{
+ H5EA_create_t test_cparam; /* Creation parameters for array */
+
+ /* Set invalid element size */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.raw_elmt_size = 0;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid max. # of elements bits */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_nelmts_bits = 0;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_nelmts_bits = 65;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid min. # of data block pointers in super blocks */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.sup_blk_min_data_ptrs = 0;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.sup_blk_min_data_ptrs = 1;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.sup_blk_min_data_ptrs = 6;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid min. # of elements per data block */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.data_blk_min_elmts = 0;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid max. # of elements per data block page bits */
+ if(test_cparam.idx_blk_elmts > 0) {
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_dblk_page_nelmts_bits = H5V_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+ } /* end if */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_dblk_page_nelmts_bits = 4; /* corresponds to 16 elements in data block page, which is less than the 64 elements for the default settings */
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1;
+ H5E_BEGIN_TRY {
+ ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened extensible array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ ea = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ PASSED()
+}
+#else /* NDEBUG */
+ SKIPPED();
+ puts(" Not tested when assertions are disabled");
+#endif /* NDEBUG */
+
+ /*
+ * Display testing message
+ */
+ TESTING("extensible array creation");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ PASSED()
+
+ /* Verify the creation parameters */
+ TESTING("verify array creation parameters");
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, ea, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end test_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_reopen
+ *
+ * Purpose: Create & reopen an extensible array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("create, close & reopen extensible array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ /* Close the extensible array */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the array */
+ if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, ea, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_reopen() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_open_twice
+ *
+ * Purpose: Open an extensible array twice
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t file2 = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5F_t *f2 = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ H5EA_t *ea2 = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("open extensible array twice");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ /* Open the array again, through the first file handle */
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(ea2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second extensible array wrapper */
+ if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea2 = NULL;
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file2 = H5Freopen(file)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
+ /* Open the extensible array through the second file handle */
+ if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the first extensible array wrapper */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea = NULL;
+
+ /* Close the first file */
+ /* (close before second file, to detect error on internal array header's
+ * shared file information)
+ */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file2, fapl, f2, ea2, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ if(ea2)
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ H5Fclose(file2);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_open_twice() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_delete_open
+ *
+ * Purpose: Delete opened extensible array (& open deleted array)
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 28, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ H5EA_t *ea2 = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+ h5_stat_size_t file_size; /* File size, after deleting array */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("deleting open extensible array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ /* Open the array again */
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Request that the array be deleted */
+ if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(ea2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second extensible array wrapper */
+ if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea2 = NULL;
+
+ /* Try re-opening the array again (should fail, as array will be deleted) */
+ H5E_BEGIN_TRY {
+ ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL);
+ } H5E_END_TRY;
+ if(ea2) {
+ /* Close opened array */
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Close the first extensible array wrapper */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea = NULL;
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ TEST_ERROR
+
+ /* Try re-opening the array again (should fail, as array is now deleted) */
+ H5E_BEGIN_TRY {
+ ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL);
+ } H5E_END_TRY;
+ if(ea) {
+ /* Close opened array */
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename_g, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size_g)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ if(ea2)
+ H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_delete_open() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_flush_depend_cb
+ *
+ * Purpose: Callback for flush dependency 'depend'/'undepend' and
+ * 'support'/'unsupport' routines
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, May 26, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_flush_depend_cb(const void *_elmt, size_t nelmts, void *udata)
+{
+ earray_flush_depend_ctx_t *ctx = (earray_flush_depend_ctx_t *)udata;
+ const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */
+
+ /* Check for out of order flush */
+ if(ctx->base_obj)
+ return(FAIL);
+
+ /* Look for magic values */
+ while(nelmts > 0) {
+ /* Check for elements of interest */
+ if((uint64_t)0 == *elmt) {
+ /* Check for out-of-order flush */
+ if(!ctx->idx0_obj)
+ return(FAIL);
+
+ /* Indicate that the element was flushed */
+ ctx->idx0_elem = TRUE;
+ } /* end if */
+ else if((uint64_t)1 == *elmt) {
+ /* Check for out-of-order flush */
+ if(!ctx->idx1_obj)
+ return(FAIL);
+
+ /* Indicate that the element was flushed */
+ ctx->idx1_elem = TRUE;
+ } /* end if */
+ else if((uint64_t)10000 == *elmt) {
+ /* Check for out-of-order flush */
+ if(!ctx->idx10000_obj)
+ return(FAIL);
+
+ /* Indicate that the element was flushed */
+ ctx->idx10000_elem = TRUE;
+ } /* end if */
+
+ /* Decrement elements left to inspect */
+ nelmts--;
+ elmt++;
+ } /* end while */
+
+ return(SUCCEED);
+} /* end test_flush_depend_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_flush_depend
+ *
+ * Purpose: Exercise flush dependency 'depend'/'undepend' routines
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, May 21, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+ H5EA__ctx_cb_t cb; /* Extensible array context action info */
+ earray_flush_depend_ctx_t fd_info; /* Context information for flush depend test */
+ haddr_t base_addr; /* Base test entry address */
+ earray_test_t *base_entry; /* Pointer to base test entry */
+ haddr_t addr1; /* Test entry #1 address */
+ earray_test_t *entry1; /* Pointer to test entry #1 */
+ haddr_t addr2; /* Test entry #2 address */
+ earray_test_t *entry2; /* Pointer to test entry #2 */
+ haddr_t addr3; /* Test entry #3 address */
+ earray_test_t *entry3; /* Pointer to test entry #3 */
+ uint64_t welmt; /* Element to write */
+ hsize_t idx; /* Index value of element */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("flush dependencies on array metadata");
+
+ /* Create array */
+ cb.encode = test_flush_depend_cb;
+ HDmemset(&fd_info, 0, sizeof(earray_flush_depend_ctx_t));
+ cb.udata = &fd_info;
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, &cb) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Create base entry to insert */
+ if(NULL == (base_entry = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(base_entry, 0, sizeof(earray_test_t));
+ base_entry->idx = (uint64_t)-1;
+ base_entry->fd_info = &fd_info;
+
+ /* Insert test entry into cache */
+ base_addr = HADDR_MAX;
+ if(H5AC_set(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
+
+ /* Set the base entry as a flush dependency for the array */
+ if(H5EA_depend((H5AC_info_t *)base_entry, ea) < 0)
+ TEST_ERROR
+
+ /* Create entry #1 to insert */
+ if(NULL == (entry1 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(entry1, 0, sizeof(earray_test_t));
+ entry1->fd_info = &fd_info;
+
+ /* Insert test entry into cache */
+ addr1 = HADDR_MAX - 1;
+ if(H5AC_set(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, entry1, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
+
+ /* Set the test entry as a flush dependency for 0th index in the array */
+ if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)0;
+ idx = 0;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create entry #2 to insert */
+ if(NULL == (entry2 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(entry2, 0, sizeof(earray_test_t));
+ entry2->idx = (uint64_t)1;
+ entry2->fd_info = &fd_info;
+
+ /* Insert test entry into cache */
+ addr2 = HADDR_MAX - 2;
+ if(H5AC_set(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, entry2, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
+
+ /* Set the test entry as a flush dependency for 1st index in the array */
+ if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)1;
+ idx = 1;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create entry #3 to insert */
+ if(NULL == (entry3 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(entry3, 0, sizeof(earray_test_t));
+ entry3->idx = (uint64_t)10000;
+ entry3->fd_info = &fd_info;
+
+ /* Insert test entry into cache */
+ addr3 = HADDR_MAX - 3;
+ if(H5AC_set(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, entry3, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
+
+ /* Set the test entry as a flush dependency for 10,000th index in the array */
+ if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)10000;
+ idx = 10000;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+
+ /* Flush the cache */
+ if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0)
+ TEST_ERROR
+
+ /* Check that all callback flags have been set */
+ if(!fd_info.base_obj)
+ TEST_ERROR
+ if(!fd_info.idx0_obj)
+ TEST_ERROR
+ if(!fd_info.idx0_elem)
+ TEST_ERROR
+ if(!fd_info.idx1_obj)
+ TEST_ERROR
+ if(!fd_info.idx1_elem)
+ TEST_ERROR
+ if(!fd_info.idx10000_obj)
+ TEST_ERROR
+ if(!fd_info.idx10000_elem)
+ TEST_ERROR
+
+
+ /* Remove the base entry as a flush dependency for the array */
+ if(H5EA_undepend((H5AC_info_t *)base_entry, ea) < 0)
+ TEST_ERROR
+
+ /* Protect the base entry */
+ if(NULL == (base_entry = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, NULL, NULL, H5AC_WRITE)))
+ TEST_ERROR
+
+ /* Unprotect & unpin the base entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
+
+ /* Remove the test entry as a flush dependency for 0th index in the array */
+ if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
+ TEST_ERROR
+
+ /* Protect the test entry */
+ if(NULL == (entry1 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, NULL, NULL, H5AC_WRITE)))
+ TEST_ERROR
+
+ /* Unprotect & unpin the test entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, entry1, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
+
+ /* Remove the test entry as a flush dependency for 1st index in the array */
+ if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
+ TEST_ERROR
+
+ /* Protect the test entry */
+ if(NULL == (entry2 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, NULL, NULL, H5AC_WRITE)))
+ TEST_ERROR
+
+ /* Unprotect & unpin the test entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, entry2, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
+
+ /* Remove the test entry as a flush dependency for 10,000th index in the array */
+ if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
+ TEST_ERROR
+
+ /* Protect the test entry */
+ if(NULL == (entry3 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, NULL, NULL, H5AC_WRITE)))
+ TEST_ERROR
+
+ /* Unprotect & unpin the test entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, entry3, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
+
+ /* Close the extensible array */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_flush_depend() */
+
+/* Extensible array iterator info for forward iteration */
+typedef struct eiter_fw_t {
+ hsize_t idx; /* Index of next array location */
+ unsigned base_sblk_idx; /* Starting index for actual superblocks */
+} eiter_fw_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_fw_init
+ *
+ * Purpose: Initialize element interator (forward iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, October 2, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+eiter_fw_init(const H5EA_create_t UNUSED *cparam, const earray_test_param_t UNUSED *tparam,
+ hsize_t UNUSED cnt)
+{
+ eiter_fw_t *eiter; /* Forward element iteration object */
+
+ /* Allocate space for the element iteration object */
+ eiter = (eiter_fw_t *)HDmalloc(sizeof(eiter_fw_t));
+ HDassert(eiter);
+
+ /* Initialize the element iteration object */
+ eiter->idx = 0;
+ eiter->base_sblk_idx = UINT_MAX;
+
+ /* Return iteration object */
+ return(eiter);
+} /* end eiter_fw_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_fw_next
+ *
+ * Purpose: Get next element index (forward iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_fw_next(void *_eiter)
+{
+ eiter_fw_t *eiter = (eiter_fw_t *)_eiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)eiter->idx++;
+
+ return(ret_val);
+} /* end eiter_fw_next() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_fw_max
+ *
+ * Purpose: Get max. element index (forward iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_fw_max(const void *_eiter)
+{
+ const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Return the max. array index used */
+ return((hssize_t)(eiter->idx - 1));
+} /* end eiter_fw_max() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_fw_state
+ *
+ * Purpose: Get extensible array state (forward iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+eiter_fw_state(void *_eiter, const H5EA_create_t *cparam,
+ const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx)
+{
+ eiter_fw_t *eiter = (eiter_fw_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+ HDassert(cparam);
+ HDassert(tparam);
+ HDassert(state);
+
+ /* Compute the state of the extensible array */
+ state->hdr_size = EA_HDR_SIZE;
+ state->nindex_blks = 1;
+ state->index_blk_size = EA_IBLOCK_SIZE;
+ state->max_idx_set = idx + 1;
+ if(idx < cparam->idx_blk_elmts) {
+ state->nelmts = (hsize_t)cparam->idx_blk_elmts;
+ state->nsuper_blks = state->ndata_blks = (hsize_t)0;
+ state->super_blk_size = state->data_blk_size = (hsize_t)0;
+ } /* end if */
+ else {
+ unsigned sblk_idx; /* Which superblock does this index fall in? */
+
+ /* Compute super block index for element index */
+ /* (same eqn. as in H5EA__dblock_sblk_idx()) */
+ sblk_idx = H5V_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
+#ifdef QAK
+HDfprintf(stderr, "idx = %Hu, tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx, sblk_idx, tparam->sblk_info[sblk_idx].ndblks, tparam->sblk_info[sblk_idx].dblk_nelmts, tparam->sblk_info[sblk_idx].start_idx, tparam->sblk_info[sblk_idx].start_dblk);
+#endif /* QAK */
+
+ state->nelmts = EA_NELMTS(cparam, tparam, idx, sblk_idx);
+#ifdef QAK
+HDfprintf(stderr, "state->nelmts = %Hu\n", state->nelmts);
+#endif /* QAK */
+
+ state->ndata_blks = EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx);
+#ifdef QAK
+HDfprintf(stderr, "state->ndata_blks = %Hu\n", state->ndata_blks);
+#endif /* QAK */
+
+ /* Check if we have any super blocks yet */
+ if(tparam->sblk_info[sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) {
+ /* Check if this is the first superblock */
+ if(sblk_idx < eiter->base_sblk_idx)
+ eiter->base_sblk_idx = sblk_idx;
+
+ state->nsuper_blks = (sblk_idx - eiter->base_sblk_idx) + 1;
+#ifdef QAK
+HDfprintf(stderr, "state->nsuper_blks = %Hu\n", state->nsuper_blks);
+#endif /* QAK */
+ } /* end if */
+ else
+ state->nsuper_blks = 0;
+ } /* end else */
+
+ return(0);
+} /* end eiter_fw_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_fw_term
+ *
+ * Purpose: Shut down element interator (forward iteration)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, October 2, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+eiter_fw_term(void *eiter)
+{
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Free iteration object */
+ HDfree(eiter);
+
+ return(0);
+} /* end eiter_fw_term() */
+
+/* Extensible array iterator class for forward iteration */
+static const earray_iter_t ea_iter_fw = {
+ eiter_fw_init, /* Iterator init */
+ eiter_fw_next, /* Next array index */
+ eiter_fw_max, /* Max. array index */
+ eiter_fw_state, /* State of the extensible array */
+ eiter_fw_term /* Iterator term */
+};
+
+/* Extensible array iterator info for reverse iteration */
+typedef struct eiter_rv_t {
+ hsize_t idx; /* Index of next array location */
+ hsize_t max; /* Index of max. array location */
+ hsize_t max_sblk_idx; /* Which superblock does the max. array location fall in? */
+ hsize_t max_nelmts; /* Max. # of elements for array */
+ hsize_t max_ndata_blks; /* Max. # of data blocks for array */
+ hsize_t idx_blk_nsblks; /* Number of superblocks directly pointed to in the index block */
+} eiter_rv_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rv_init
+ *
+ * Purpose: Initialize element interator (reverse iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+eiter_rv_init(const H5EA_create_t *cparam, const earray_test_param_t *tparam,
+ hsize_t cnt)
+{
+ eiter_rv_t *eiter; /* Reverse element iteration object */
+
+ /* Allocate space for the element iteration object */
+ eiter = (eiter_rv_t *)HDmalloc(sizeof(eiter_rv_t));
+ HDassert(eiter);
+
+ /* Initialize reverse iteration info */
+ eiter->idx = cnt - 1;
+ eiter->max = cnt - 1;
+ if(cnt > cparam->idx_blk_elmts) {
+ eiter->max_sblk_idx = H5V_log2_gen((uint64_t)(((eiter->max - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
+ eiter->max_nelmts = EA_NELMTS(cparam, tparam, eiter->max, eiter->max_sblk_idx);
+ eiter->max_ndata_blks = EA_NDATA_BLKS(cparam, tparam, eiter->max, eiter->max_sblk_idx);
+ eiter->idx_blk_nsblks = 2 * H5V_log2_of2((uint32_t)cparam->sup_blk_min_data_ptrs);
+ } /* end if */
+ else {
+ eiter->max_sblk_idx = (hsize_t)0;
+ eiter->max_nelmts = (hsize_t)0;
+ eiter->max_ndata_blks = (hsize_t)0;
+ eiter->idx_blk_nsblks = (hsize_t)0;
+ } /* end else */
+
+ /* Return iteration object */
+ return(eiter);
+} /* end eiter_rv_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rv_next
+ *
+ * Purpose: Get next element index (reverse iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_rv_next(void *_eiter)
+{
+ eiter_rv_t *eiter = (eiter_rv_t *)_eiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)eiter->idx--;
+
+ return(ret_val);
+} /* end eiter_rv_next() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rv_max
+ *
+ * Purpose: Get max. element index (reverse iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_rv_max(const void *_eiter)
+{
+ const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Return the max. array index used */
+ return((hssize_t)eiter->max);
+} /* end eiter_rv_max() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rv_state
+ *
+ * Purpose: Get extensible array state (reverse iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+eiter_rv_state(void *_eiter, const H5EA_create_t *cparam,
+ const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx)
+{
+ eiter_rv_t *eiter = (eiter_rv_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+ HDassert(cparam);
+ HDassert(tparam);
+ HDassert(state);
+
+ /* Compute the state of the extensible array */
+ state->hdr_size = EA_HDR_SIZE;
+ state->nindex_blks = 1;
+ state->index_blk_size = EA_IBLOCK_SIZE;
+ state->max_idx_set = eiter->max + 1;
+ if(eiter->max < cparam->idx_blk_elmts) {
+ state->nelmts = (hsize_t)cparam->idx_blk_elmts;
+ state->nsuper_blks = state->ndata_blks = (hsize_t)0;
+ } /* end if */
+ else {
+ hsize_t idx_nelmts; /* # of elements for array index */
+ hsize_t idx_ndata_blks; /* # of data blocks for array index */
+ hsize_t loc_idx = 0; /* Local index, for computing an offset in next lower data block */
+ unsigned idx_sblk_idx; /* Which superblock does this index fall in? */
+ unsigned loc_sblk_idx = 0; /* Which superblock does the local index fall in? */
+
+ /* Compute super block index for element index */
+ /* (same eqn. as in H5EA__dblock_sblk_idx()) */
+ if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts)
+ idx_sblk_idx = 0;
+ else {
+ hsize_t tmp_idx; /* Temporary index in superblock */
+ hsize_t dblk_idx; /* Index of data block within superblock */
+
+ idx_sblk_idx = H5V_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
+ tmp_idx = idx - (cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx);
+ dblk_idx = tmp_idx / tparam->sblk_info[idx_sblk_idx].dblk_nelmts;
+ if(dblk_idx > 0)
+ loc_idx = idx - tparam->sblk_info[idx_sblk_idx].dblk_nelmts;
+ else
+ loc_idx = cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx - 1;
+ loc_sblk_idx = H5V_log2_gen((uint64_t)(((loc_idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
+ } /* end else */
+#ifdef QAK
+HDfprintf(stderr, "idx = %Hu, loc_idx = %Hu, eiter->max_sblk_idx = %u, idx_sblk_idx = %u, loc_sblk_idx = %u\n", idx, loc_idx, eiter->max_sblk_idx, idx_sblk_idx, loc_sblk_idx);
+HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx_sblk_idx, tparam->sblk_info[idx_sblk_idx].ndblks, tparam->sblk_info[idx_sblk_idx].dblk_nelmts, tparam->sblk_info[idx_sblk_idx].start_idx, tparam->sblk_info[idx_sblk_idx].start_dblk);
+HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", eiter->max_sblk_idx, tparam->sblk_info[eiter->max_sblk_idx].ndblks, tparam->sblk_info[eiter->max_sblk_idx].dblk_nelmts, tparam->sblk_info[eiter->max_sblk_idx].start_idx, tparam->sblk_info[eiter->max_sblk_idx].start_dblk);
+#endif /* QAK */
+
+ if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts)
+ idx_nelmts = (hsize_t)cparam->idx_blk_elmts;
+ else
+ idx_nelmts = EA_NELMTS(cparam, tparam, loc_idx, loc_sblk_idx);
+ state->nelmts = (eiter->max_nelmts - idx_nelmts) + cparam->idx_blk_elmts;
+#ifdef QAK
+HDfprintf(stderr, "eiter->max_nelmts = %Hu, idx_nelmts = %Hu, state->nelmts = %Hu\n", eiter->max_nelmts, idx_nelmts, state->nelmts);
+#endif /* QAK */
+
+ if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts)
+ idx_ndata_blks = 0;
+ else
+ idx_ndata_blks = EA_NDATA_BLKS(cparam, tparam, loc_idx, loc_sblk_idx);
+ state->ndata_blks = eiter->max_ndata_blks - idx_ndata_blks;
+#ifdef QAK
+HDfprintf(stderr, "eiter->max_ndata_blks = %Hu, idx_ndata_blks = %Hu, state->ndata_blks = %Hu\n", eiter->max_ndata_blks, idx_ndata_blks, state->ndata_blks);
+#endif /* QAK */
+
+ /* Check if we have any super blocks yet */
+ if(tparam->sblk_info[eiter->max_sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) {
+ if(idx_sblk_idx > eiter->idx_blk_nsblks)
+ state->nsuper_blks = (eiter->max_sblk_idx - idx_sblk_idx) + 1;
+ else
+ state->nsuper_blks = (eiter->max_sblk_idx - eiter->idx_blk_nsblks) + 1;
+#ifdef QAK
+HDfprintf(stderr, "eiter->idx_blk_nsblks = %Hu, state->nsuper_blks = %Hu\n", eiter->idx_blk_nsblks, state->nsuper_blks);
+#endif /* QAK */
+ } /* end if */
+ } /* end else */
+
+ return(0);
+} /* end eiter_rv_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rv_term
+ *
+ * Purpose: Shut down element interator (reverse iteration)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 4, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+eiter_rv_term(void *eiter)
+{
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Free iteration object */
+ HDfree(eiter);
+
+ return(0);
+} /* end eiter_rv_term() */
+
+/* Extensible array iterator class for reverse iteration */
+static const earray_iter_t ea_iter_rv = {
+ eiter_rv_init, /* Iterator init */
+ eiter_rv_next, /* Next array index */
+ eiter_rv_max, /* Max. array index written */
+ eiter_rv_state, /* State of the extensible array */
+ eiter_rv_term /* Iterator term */
+};
+
+/* Extensible array iterator info for random iteration */
+typedef struct eiter_rnd_t {
+ hsize_t max; /* Max. array index used */
+ hsize_t pos; /* Position in shuffled array */
+ hsize_t *idx; /* Array of shuffled indices */
+} eiter_rnd_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rnd_init
+ *
+ * Purpose: Initialize element interator (random iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 6, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+eiter_rnd_init(const H5EA_create_t UNUSED *cparam, const earray_test_param_t UNUSED *tparam,
+ hsize_t cnt)
+{
+ eiter_rnd_t *eiter; /* Random element iteration object */
+ size_t u; /* Local index variable */
+
+ /* Allocate space for the element iteration object */
+ eiter = (eiter_rnd_t *)HDmalloc(sizeof(eiter_rnd_t));
+ HDassert(eiter);
+
+ /* Allocate space for the array of shuffled indices */
+ eiter->idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)cnt);
+ HDassert(eiter->idx);
+
+ /* Initialize reverse iteration info */
+ eiter->max = 0;
+ eiter->pos = 0;
+ for(u = 0; u < (size_t)cnt; u++)
+ eiter->idx[u] = (hsize_t)u;
+
+ /* Randomly shuffle array indices */
+ if(cnt > 1) {
+ for(u = 0; u < (size_t)cnt; u++) {
+ size_t swap_idx; /* Location to swap with when shuffling */
+ hsize_t temp_idx; /* Temporary index */
+
+ swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u;
+ temp_idx = eiter->idx[u];
+ eiter->idx[u] = eiter->idx[swap_idx];
+ eiter->idx[swap_idx] = temp_idx;
+ } /* end for */
+ } /* end if */
+
+ /* Return iteration object */
+ return(eiter);
+} /* end eiter_rnd_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rnd_next
+ *
+ * Purpose: Get next element index (random iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 6, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_rnd_next(void *_eiter)
+{
+ eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)eiter->idx[eiter->pos];
+ eiter->pos++;
+
+ /* Check for new max. value */
+ if((hsize_t)ret_val > eiter->max)
+ eiter->max = (hsize_t)ret_val;
+
+ return(ret_val);
+} /* end eiter_rnd_next() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rnd_max
+ *
+ * Purpose: Get max. element index (random iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_rnd_max(const void *_eiter)
+{
+ const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Return the max. array index used */
+ return((hssize_t)eiter->max);
+} /* end eiter_rnd_max() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rnd_term
+ *
+ * Purpose: Shut down element interator (random iteration)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+eiter_rnd_term(void *_eiter)
+{
+ eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+ HDassert(eiter->idx);
+
+ /* Free shuffled index array */
+ HDfree(eiter->idx);
+
+ /* Free iteration object */
+ HDfree(eiter);
+
+ return(0);
+} /* end eiter_rnd_term() */
+
+/* Extensible array iterator class for random iteration */
+static const earray_iter_t ea_iter_rnd = {
+ eiter_rnd_init, /* Iterator init */
+ eiter_rnd_next, /* Next array index */
+ eiter_rnd_max, /* Max. array index written */
+ NULL, /* State of the extensible array */
+ eiter_rnd_term /* Iterator term */
+};
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_rnd2_init
+ *
+ * Purpose: Initialize element interator (random #2 iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 11, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+eiter_rnd2_init(const H5EA_create_t UNUSED *cparam, const earray_test_param_t UNUSED *tparam,
+ hsize_t cnt)
+{
+ eiter_rnd_t *eiter; /* Random element iteration object */
+ size_t u; /* Local index variable */
+
+ /* Allocate space for the element iteration object */
+ eiter = (eiter_rnd_t *)HDmalloc(sizeof(eiter_rnd_t));
+ HDassert(eiter);
+
+ /* Allocate space for the array of shuffled indices */
+ eiter->idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)cnt);
+ HDassert(eiter->idx);
+
+ /* Initialize reverse iteration info */
+ eiter->max = 0;
+ eiter->pos = 0;
+
+ /* Randomly shuffle array indices */
+ if(cnt > 1) {
+ hsize_t *tmp_idx; /* Temporary index array */
+ hsize_t sparse_cnt = (hsize_t)(cnt * EA_RND2_SCALE); /* Sparse range to choose from */
+
+ /* Allocate temporary index array */
+ tmp_idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)sparse_cnt);
+ HDassert(tmp_idx);
+
+ /* Initialize temporary index array, for shuffling */
+ for(u = 0; u < (size_t)sparse_cnt; u++)
+ tmp_idx[u] = (hsize_t)u;
+
+ /* Shuffle index elements & store in final array */
+ for(u = 0; u < (size_t)cnt; u++) {
+ size_t swap_idx; /* Location to swap with when shuffling */
+
+ swap_idx = ((size_t)HDrandom() % ((size_t)sparse_cnt - u)) + u;
+ eiter->idx[u] = tmp_idx[swap_idx];
+ tmp_idx[swap_idx] = tmp_idx[u];
+ } /* end for */
+
+ /* Release temporary array */
+ HDfree(tmp_idx);
+ } /* end if */
+ else {
+ for(u = 0; u < (size_t)cnt; u++)
+ eiter->idx[u] = (hsize_t)u;
+ } /* end else */
+
+ /* Return iteration object */
+ return(eiter);
+} /* end eiter_rnd2_init() */
+
+/* Extensible array iterator class for random iteration */
+static const earray_iter_t ea_iter_rnd2 = {
+ eiter_rnd2_init, /* Iterator init */
+ eiter_rnd_next, /* Next array index */
+ eiter_rnd_max, /* Max. array index written */
+ NULL, /* State of the extensible array */
+ eiter_rnd_term /* Iterator term */
+};
+
+/* Extensible array iterator info for cyclic iteration */
+typedef struct eiter_cyc_t {
+ hsize_t max; /* Max. array index used */
+ hsize_t pos; /* Position in shuffled array */
+ hsize_t cnt; /* # of elements to store */
+ hsize_t cyc; /* Cycle of elements to choose from */
+} eiter_cyc_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_cyc_init
+ *
+ * Purpose: Initialize element interator (cyclic iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 11, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+eiter_cyc_init(const H5EA_create_t UNUSED *cparam, const earray_test_param_t UNUSED *tparam,
+ hsize_t cnt)
+{
+ eiter_cyc_t *eiter; /* Cyclic element iteration object */
+
+ /* Allocate space for the element iteration object */
+ eiter = (eiter_cyc_t *)HDmalloc(sizeof(eiter_cyc_t));
+ HDassert(eiter);
+
+ /* Initialize reverse iteration info */
+ eiter->max = 0;
+ eiter->pos = 0;
+ eiter->cnt = cnt;
+ eiter->cyc = 0;
+
+ /* Return iteration object */
+ return(eiter);
+} /* end eiter_cyc_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_cyc_next
+ *
+ * Purpose: Get next element index (cyclic iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 11, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_cyc_next(void *_eiter)
+{
+ eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)eiter->pos;
+ eiter->pos += EA_CYC_COUNT;
+ if(eiter->pos >= eiter->cnt)
+ eiter->pos = ++eiter->cyc;
+
+ /* Check for new max. value */
+ if((hsize_t)ret_val > eiter->max)
+ eiter->max = (hsize_t)ret_val;
+
+ return(ret_val);
+} /* end eiter_cyc_next() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_cyc_max
+ *
+ * Purpose: Get max. element index (cyclic iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 11, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+eiter_cyc_max(const void *_eiter)
+{
+ const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Return the max. array index used */
+ return((hssize_t)eiter->max);
+} /* end eiter_cyc_max() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: eiter_cyc_term
+ *
+ * Purpose: Shut down element interator (cyclic iteration)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 11, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+eiter_cyc_term(void *_eiter)
+{
+ eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter;
+
+ /* Sanity check */
+ HDassert(eiter);
+
+ /* Free iteration object */
+ HDfree(eiter);
+
+ return(0);
+} /* end eiter_cyc_term() */
+
+/* Extensible array iterator class for cyclic iteration */
+static const earray_iter_t ea_iter_cyc = {
+ eiter_cyc_init, /* Iterator init */
+ eiter_cyc_next, /* Next array index */
+ eiter_cyc_max, /* Max. array index written */
+ NULL, /* State of the extensible array */
+ eiter_cyc_term /* Iterator term */
+};
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_set_elmts
+ *
+ * Purpose: Set all elements from 0 through 'nelmts' in extensible array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, September 22, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
+ hsize_t nelmts, const char *test_str)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ void *eiter_info; /* Extensible array iterator info */
+ earray_state_t state; /* State of extensible array */
+ uint64_t welmt; /* Element to write */
+ uint64_t relmt; /* Element to read */
+ hsize_t nelmts_written; /* Highest element written in array */
+ hsize_t cnt; /* Count of array indices */
+ hssize_t smax; /* Index value of max. element set */
+ hsize_t max; /* Index value of max. element set */
+ hssize_t sidx; /* Index value of first element of first data block */
+ hsize_t idx; /* Index value of first element of first data block */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /*
+ * Display testing message
+ */
+ TESTING(test_str);
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts_written = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts_written != 0)
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Get all elements from empty array */
+
+ /* Initialize iterator */
+ if(NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts)))
+ TEST_ERROR
+
+ /* Get elements of array */
+ for(cnt = 0; cnt < nelmts; cnt++) {
+ /* Get the array index */
+ if((sidx = tparam->eiter->next(eiter_info)) < 0)
+ TEST_ERROR
+ idx = (hsize_t)sidx;
+
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+ } /* end for */
+
+ /* Shutdown iterator */
+ if(tparam->eiter->term(eiter_info) < 0)
+ TEST_ERROR
+
+
+ /* Set (& get) all elements from empty array */
+
+ /* Initialize iterator */
+ if(NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts)))
+ TEST_ERROR
+
+ /* Set elements of array */
+ for(cnt = 0; cnt < nelmts; cnt++) {
+ /* Get the array index */
+ if((sidx = tparam->eiter->next(eiter_info)) < 0)
+ TEST_ERROR
+ idx = (hsize_t)sidx;
+
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)7 + idx;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the max. array index */
+ if((smax = tparam->eiter->max_elem(eiter_info)) < 0)
+ TEST_ERROR
+ max = (hsize_t)smax;
+
+ /* Verify high-water # of elements written */
+ nelmts_written = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts_written != (max + 1))
+ TEST_ERROR
+
+ /* Check if array state is available */
+ if(tparam->eiter->state) {
+ /* Get the extensible array state */
+ if(tparam->eiter->state(eiter_info, cparam, tparam, &state, idx) < 0)
+ TEST_ERROR
+
+ /* Verify array state */
+ if(check_stats(ea, &state))
+ TEST_ERROR
+ } /* end if */
+
+ /* Retrieve element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is value written */
+ if(relmt != welmt)
+ TEST_ERROR
+ } /* end for */
+
+ /* Shutdown iterator */
+ if(tparam->eiter->term(eiter_info) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, ea, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_set_elmts() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_skip_elmts
+ *
+ * Purpose: Skip some elements when writing element
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 11, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
+ hsize_t skip_elmts, const char *test_str)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5EA_t *ea = NULL; /* Extensible array wrapper */
+ earray_state_t state; /* State of extensible array */
+ uint64_t welmt; /* Element to write */
+ uint64_t relmt; /* Element to read */
+ hsize_t nelmts_written; /* Highest element written in array */
+ hsize_t idx; /* Index value of element to get */
+ hsize_t cnt; /* Count of array indices */
+ haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
+
+ /*
+ * Display testing message
+ */
+ TESTING(test_str);
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts_written = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts_written != 0)
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Set (& get) element after skipping elements */
+ idx = skip_elmts;
+
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)7 + idx;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify high-water # of elements written */
+ nelmts_written = (hsize_t)ULLONG_MAX;
+ if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
+ FAIL_STACK_ERROR
+ if(nelmts_written != (idx + 1))
+ TEST_ERROR
+
+ /* Set array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = EA_HDR_SIZE;
+ state.nindex_blks = 1;
+ state.index_blk_size = EA_IBLOCK_SIZE;
+ state.max_idx_set = idx + 1;
+ if(1 == skip_elmts) {
+ state.nelmts = (hsize_t)cparam->idx_blk_elmts;
+ state.nsuper_blks = state.ndata_blks = (hsize_t)0;
+ } /* end if */
+ else if(cparam->idx_blk_elmts == skip_elmts) {
+ state.nelmts = (hsize_t)cparam->idx_blk_elmts + cparam->data_blk_min_elmts;
+ state.ndata_blks = (hsize_t)1;
+ state.nsuper_blks = (hsize_t)0;
+ } /* end if */
+ else {
+ unsigned sblk_idx; /* Which superblock does this index fall in? */
+
+ /* Compute super block index for element index */
+ /* (same eqn. as in H5EA__dblock_sblk_idx()) */
+ sblk_idx = H5V_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
+ state.nelmts = (hsize_t)cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].dblk_nelmts;
+ state.ndata_blks = (hsize_t)1;
+ state.nsuper_blks = (hsize_t)1;
+ } /* end if */
+
+ /* Verify array state */
+ if(check_stats(ea, &state))
+ TEST_ERROR
+
+ /* Retrieve element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is value written */
+ if(relmt != welmt)
+ TEST_ERROR
+
+ /* Get unset elements of array */
+ for(cnt = 0; cnt < skip_elmts; cnt++) {
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5EA_get(ea, H5P_DATASET_XFER_DEFAULT, cnt, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify element is fill value for array */
+ if(relmt != H5EA_TEST_FILL)
+ TEST_ERROR
+ } /* end for */
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, ea, ea_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(ea)
+ H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_skip_elmts() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Test the extensible array code
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 17, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ H5EA_create_t cparam; /* Creation parameters for extensible array */
+ earray_test_param_t tparam; /* Testing parameters */
+ earray_test_type_t curr_test; /* Current test being worked on */
+ earray_iter_type_t curr_iter; /* Current iteration type being worked on */
+ hid_t fapl = -1; /* File access property list for data files */
+ unsigned nerrors = 0; /* Cumulative error count */
+ time_t curr_time; /* Current time, for seeding random number generator */
+ int ExpressMode; /* Test express value */
+
+ /* Reset library */
+ h5_reset();
+ fapl = h5_fileaccess();
+ ExpressMode = GetTestExpress();
+ if(ExpressMode > 1)
+ printf("***Express test mode on. Some tests may be skipped\n");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g));
+
+ /* Seed random #'s */
+ curr_time = HDtime(NULL);
+ HDsrandom((unsigned long)curr_time);
+
+ /* Create an empty file to retrieve size */
+ {
+ hid_t file; /* File ID */
+
+ if((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/no array */
+ if((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0)
+ TEST_ERROR
+ }
+
+
+ /* Initialize extensible array creation parameters */
+ init_cparam(&cparam);
+
+ /* Iterate over the testing parameters */
+ for(curr_test = EARRAY_TEST_NORMAL; curr_test < EARRAY_TEST_NTESTS; curr_test++) {
+
+ /* Initialize the testing parameters */
+ init_tparam(&tparam, &cparam);
+
+ /* Set appropriate testing parameters for each test */
+ switch(curr_test) {
+ /* "Normal" testing parameters */
+ case EARRAY_TEST_NORMAL:
+ puts("Testing with normal parameters");
+ break;
+
+ /* "Re-open array" testing parameters */
+ case EARRAY_TEST_REOPEN:
+ puts("Testing with reopen array flag set");
+ tparam.reopen_array = EARRAY_TEST_REOPEN;
+ break;
+
+ /* An unknown test? */
+ case EARRAY_TEST_NTESTS:
+ default:
+ goto error;
+ } /* end switch */
+
+ /* Basic capability tests */
+ nerrors += test_create(fapl, &cparam, &tparam);
+ nerrors += test_reopen(fapl, &cparam, &tparam);
+ nerrors += test_open_twice(fapl, &cparam, &tparam);
+ nerrors += test_delete_open(fapl, &cparam, &tparam);
+ nerrors += test_flush_depend(fapl, &cparam, &tparam);
+
+ /* Iterate over the type of capacity tests */
+ for(curr_iter = EARRAY_ITER_FW; curr_iter < EARRAY_ITER_NITERS; curr_iter++) {
+ hsize_t sblk; /* Super block index */
+ hsize_t dblk; /* Data block index */
+ hsize_t nelmts; /* # of elements to test */
+ char test_str[128]; /* String for describing test */
+ hsize_t ndblks; /* # of data blocks tested */
+
+ /* Set appropriate parameters for each type of iteration */
+ switch(curr_iter) {
+ /* "Forward" testing parameters */
+ case EARRAY_ITER_FW:
+ puts("Testing with forward iteration");
+ tparam.eiter = &ea_iter_fw;
+ break;
+
+ /* "Reverse" testing parameters */
+ case EARRAY_ITER_RV:
+ puts("Testing with reverse iteration");
+ tparam.eiter = &ea_iter_rv;
+ break;
+
+ /* "Random" testing parameters */
+ case EARRAY_ITER_RND:
+ puts("Testing with random iteration");
+ tparam.eiter = &ea_iter_rnd;
+ break;
+
+ /* "Random #2" testing parameters */
+ case EARRAY_ITER_RND2:
+ puts("Testing with random #2 iteration");
+ tparam.eiter = &ea_iter_rnd2;
+ break;
+
+ /* "Cyclic" testing parameters */
+ case EARRAY_ITER_CYC:
+ puts("Testing with cyclic iteration");
+ tparam.eiter = &ea_iter_cyc;
+ break;
+
+ /* An unknown iteration? */
+ case EARRAY_ITER_NITERS:
+ default:
+ goto error;
+ } /* end switch */
+
+ /* Basic capacity tests */
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)1, "setting first element of array");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "setting index block elements of array");
+
+ /* Super Block capacity tests */
+ ndblks = 0;
+ for(sblk = 0; sblk < 9; sblk++) {
+ for(dblk = 0; dblk < tparam.sblk_info[sblk].ndblks; dblk ++) {
+ /* Test first element in data block */
+ nelmts = (hsize_t)((hsize_t)1 + cparam.idx_blk_elmts +
+ tparam.sblk_info[sblk].start_idx +
+ (tparam.sblk_info[sblk].dblk_nelmts * dblk));
+ sprintf(test_str, "setting first element of array's data block #%llu", (unsigned long long)ndblks);
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str);
+
+ /* Test all elements in data block */
+ nelmts = (hsize_t)(cparam.idx_blk_elmts +
+ tparam.sblk_info[sblk].start_idx +
+ (tparam.sblk_info[sblk].dblk_nelmts * (dblk + 1)));
+ sprintf(test_str, "setting all elements of array's data block #%llu", (unsigned long long)ndblks);
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str);
+
+ /* Increment data block being tested */
+ ndblks++;
+ } /* end for */
+ } /* end for */
+ } /* end for */
+
+ /* Check skipping elements */
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)1, "skipping 1st element");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "skipping index block elements");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (15 * cparam.data_blk_min_elmts) + 1), "skipping index block & data block elements");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (31 * cparam.data_blk_min_elmts) + 1), "skipping 1st super block elements");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (63 * cparam.data_blk_min_elmts) + 1), "skipping 2nd super block elements");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (127 * cparam.data_blk_min_elmts) + 1), "skipping 3rd super block elements");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (255 * cparam.data_blk_min_elmts) + 1), "skipping 4th super block elements");
+
+ /* Close down testing parameters */
+ finish_tparam(&tparam);
+ } /* end for */
+
+ if(nerrors)
+ goto error;
+ puts("All extensible array tests passed.");
+
+ /* Clean up file used */
+ h5_cleanup(FILENAME, fapl);
+
+ return 0;
+
+error:
+ puts("*** TESTS FAILED ***");
+
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end main() */
+
diff --git a/test/enum.c b/test/enum.c
index e40965c..4599a7c 100644
--- a/test/enum.c
+++ b/test/enum.c
@@ -211,58 +211,48 @@ test_tr1(hid_t file)
static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE,
E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED};
c_e1 data2[10];
- const char *envval = NULL;
TESTING("O(1) conversions");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "split")) {
- if((cwg = H5Gcreate2(file, "test_tr1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED )) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE )) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK)) < 0) FAIL_STACK_ERROR
-
-
- if((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "RED", CPTR(ival, 105)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101)) < 0) FAIL_STACK_ERROR
-
- if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
- if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
- if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
-
- for(i = 0; i < (size_t)ds_size[0]; i++)
- if(data1[i] != data2[i]) {
- H5_FAILED();
- printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
- (unsigned long)i, (int)(data1[i]),
- (unsigned long)i, (int)(data2[i]));
- goto error;
- }
-
- if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space) < 0) FAIL_STACK_ERROR
- if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR
- if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR
- if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
-
- PASSED();
- }
- else
- {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- }
+ if((cwg = H5Gcreate2(file, "test_tr1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED )) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE )) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK)) < 0) FAIL_STACK_ERROR
+
+
+ if((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "RED", CPTR(ival, 105)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101)) < 0) FAIL_STACK_ERROR
+
+ if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
+ if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
+ if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
+
+ for(i = 0; i < (size_t)ds_size[0]; i++)
+ if(data1[i] != data2[i]) {
+ H5_FAILED();
+ printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
+ (unsigned long)i, (int)(data1[i]),
+ (unsigned long)i, (int)(data2[i]));
+ goto error;
+ }
+
+ if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(space) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+
return 0;
error:
@@ -304,56 +294,47 @@ test_tr2(hid_t file)
static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE,
E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED};
c_e1 data2[10];
- const char *envval = NULL;
TESTING("O(log N) converions");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "split")) {
- if((cwg = H5Gcreate2(file, "test_tr2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED )) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE )) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK)) < 0) FAIL_STACK_ERROR
-
- if((f_type = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "RED", CPTR(val2, 1050)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020)) < 0) FAIL_STACK_ERROR
- if(H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010)) < 0) FAIL_STACK_ERROR
-
- if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
- if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
- if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
-
- for(i = 0; i < (size_t)ds_size[0]; i++)
- if(data1[i] != data2[i]) {
- H5_FAILED();
- printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
- (unsigned long)i, (int)(data1[i]),
- (unsigned long)i, (int)(data2[i]));
- goto error;
- }
-
- if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space) < 0) FAIL_STACK_ERROR
- if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR
- if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR
- if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
-
- PASSED();
- }
- else {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- }
+ if((cwg = H5Gcreate2(file, "test_tr2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED )) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE )) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK)) < 0) FAIL_STACK_ERROR
+
+ if((f_type = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "RED", CPTR(val2, 1050)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010)) < 0) FAIL_STACK_ERROR
+
+ if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
+ if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
+ if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
+
+ for(i = 0; i < (size_t)ds_size[0]; i++)
+ if(data1[i] != data2[i]) {
+ H5_FAILED();
+ printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
+ (unsigned long)i, (int)(data1[i]),
+ (unsigned long)i, (int)(data2[i]));
+ goto error;
+ }
+
+ if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(space) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+
return 0;
error:
@@ -473,7 +454,7 @@ test_funcs(void)
{
hid_t type=-1;
c_e1 val;
- int size;
+ size_t size;
H5T_pad_t inpad;
H5T_cset_t cset;
herr_t ret;
@@ -481,18 +462,18 @@ test_funcs(void)
TESTING("some functions with enumeration types");
/* A native integer */
- if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error;
- if (H5Tenum_insert(type, "RED", CPTR(val, E1_RED ))<0) goto error;
- if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN))<0) goto error;
- if (H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE ))<0) goto error;
- if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE))<0) goto error;
- if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK))<0) goto error;
-
- if ((size=H5Tget_precision(type))==0) goto error;
- if ((size=H5Tget_size(type))==0) goto error;
- if ((size=H5Tget_offset(type))<0) goto error;
- if (H5Tget_sign(type)<0) goto error;
- if (H5Tget_super(type)<0) goto error;
+ if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR
+ if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR
+
+ if(H5Tget_precision(type) == 0) FAIL_STACK_ERROR
+ if(H5Tget_size(type) == 0) FAIL_STACK_ERROR
+ if(H5Tget_offset(type) < 0) FAIL_STACK_ERROR
+ if(H5Tget_sign(type) < 0) FAIL_STACK_ERROR
+ if(H5Tget_super(type) < 0) FAIL_STACK_ERROR
H5E_BEGIN_TRY {
ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE);
diff --git a/test/error_test.c b/test/error_test.c
index 027f31b..89a81a3 100644
--- a/test/error_test.c
+++ b/test/error_test.c
@@ -40,6 +40,7 @@ const char *FILENAME[] = {
int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1];
hid_t ERR_CLS;
+hid_t ERR_CLS2;
hid_t ERR_STACK;
hid_t ERR_MAJ_TEST;
@@ -56,7 +57,9 @@ hid_t ERR_MIN_GETNUM;
#define FAKE_ID 0
#define ERR_CLS_NAME "Error Test"
+#define ERR_CLS2_NAME "Second Test"
#define PROG_NAME "Error Program"
+#define PROG2_NAME "Second Program"
#define PROG_VERS "1.0"
#define ERR_MAJ_TEST_MSG "Error in test"
@@ -69,15 +72,9 @@ hid_t ERR_MIN_GETNUM;
#define ERR_MIN_GETNUM_MSG "Error in H5Eget_num"
#define MSG_SIZE 64
-#define SPACE1_DIM1 4
-#define SPACE1_RANK 1
-#define SPACE2_RANK 2
-#define SPACE2_DIM1 10
-#define SPACE2_DIM2 10
-
#define LONG_DESC_SIZE 8192
-herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc,
+static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc,
void *client_data);
@@ -106,6 +103,7 @@ test_error(hid_t file)
void *old_data;
TESTING("error API based on data I/O");
+ printf("\n");
/* Create the data space */
dims[0] = DIM0;
@@ -189,10 +187,10 @@ static herr_t
init_error(void)
{
ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME)+1;
- char *cls_name = HDmalloc(HDstrlen(ERR_CLS_NAME)+1);
+ char *cls_name = (char*)HDmalloc(HDstrlen(ERR_CLS_NAME)+1);
ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1;
- char *msg = HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1);
- H5E_type_t *msg_type= HDmalloc(sizeof(H5E_type_t));
+ char *msg = (char*)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1);
+ H5E_type_t *msg_type= (H5E_type_t *)HDmalloc(sizeof(H5E_type_t));
if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0)
TEST_ERROR;
@@ -231,6 +229,10 @@ init_error(void)
HDfree(msg);
HDfree(msg_type);
+ /* Register another class for later testing. */
+ if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0)
+ TEST_ERROR;
+
return 0;
error:
@@ -334,8 +336,8 @@ test_long_desc(void)
const char *test_FUNC = "test_long_desc";
/* Allocate space for the error description info */
- if(NULL == (long_desc = HDmalloc(LONG_DESC_SIZE))) TEST_ERROR;
- if(NULL == (full_desc = HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR;
+ if(NULL == (long_desc = (char*)HDmalloc(LONG_DESC_SIZE))) TEST_ERROR;
+ if(NULL == (full_desc = (char*)HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR;
/* Create the long part of the error description */
for(u = 0; u < LONG_DESC_SIZE; u++)
@@ -420,7 +422,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-herr_t
+static herr_t
custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data)
{
FILE *stream = (FILE *)client_data;
@@ -535,6 +537,9 @@ close_error(void)
if(H5Eunregister_class(ERR_CLS) < 0)
TEST_ERROR;
+ if(H5Eunregister_class(ERR_CLS2) < 0)
+ TEST_ERROR;
+
return 0;
error:
@@ -581,6 +586,10 @@ main(void)
/* Delete an error from the top of error stack */
H5Epop(ERR_STACK, 1);
+ /* Make sure we can use other class's major or minor errors. */
+ H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS2, ERR_MAJ_TEST, ERR_MIN_ERRSTACK,
+ "Error stack test failed");
+
/* Print out the errors on stack */
dump_error(ERR_STACK);
diff --git a/test/extend.c b/test/extend.c
index 2248b5d..3ffcadc 100644
--- a/test/extend.c
+++ b/test/extend.c
@@ -68,8 +68,8 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me
for(j = 0; j < 5; j++) {
/* Extend the dataset */
- offset[0] = i * NX;
- offset[1] = j * NY;
+ offset[0] = (hsize_t)(i * NX);
+ offset[1] = (hsize_t)(j * NY);
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
if(size[0] > max_size[0] || size[1] > max_size[1]) {
@@ -96,8 +96,8 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me
for(j = 0; j < 10; j++) {
/* Select a hyperslab */
- offset[0] = i * (NX / 2);
- offset[1] = j * (NY / 2);
+ offset[0] = (hsize_t)(i * (NX / 2));
+ offset[1] = (hsize_t)(j * (NY / 2));
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR;
/* Read */
@@ -164,8 +164,8 @@ write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, h
for(j = 0; j < 5; j++) {
/* Extend the dataset */
- offset[0] = i * NX;
- offset[1] = j * NY;
+ offset[0] = (hsize_t)(i * NX);
+ offset[1] = (hsize_t)(j * NY);
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
if(H5Dextend(dataset, size) < 0) TEST_ERROR;
@@ -186,8 +186,8 @@ write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, h
for(j = 0; j < 10; j++) {
/* Select a hyperslab */
- offset[0] = i * (NX / 2);
- offset[1] = j * (NY / 2);
+ offset[0] = (hsize_t)(i * (NX / 2));
+ offset[1] = (hsize_t)(j * (NY / 2));
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR;
/* Read */
@@ -251,57 +251,49 @@ main (void)
static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
char filename[1024];
int i, j;
- const char *envval = NULL;
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "split")) {
- h5_reset();
- fapl = h5_fileaccess();
+ h5_reset();
+ fapl = h5_fileaccess();
- /* Initialize buffer and space */
- for(i = 0; i < NX; i++)
- for(j = 0; j < NY; j++)
- buf1[i][j] = i * NY + j;
+ /* Initialize buffer and space */
+ for(i = 0; i < NX; i++)
+ for(j = 0; j < NY; j++)
+ buf1[i][j] = i * NY + j;
- if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR;
+ if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR;
- /* Create the file */
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+ /* Create the file */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
- /* Create the dataset creation property list */
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(cparms, 2, chunk_dims) < 0) TEST_ERROR;
+ /* Create the dataset creation property list */
+ if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if(H5Pset_chunk(cparms, 2, chunk_dims) < 0) TEST_ERROR;
- /* Test with incremental allocation */
- nerrors += write_data("extendible dataset with incr. allocation", file, "dataset1a", cparms, mem_space) < 0 ? 1 : 0;
+ /* Test with incremental allocation */
+ nerrors += write_data("extendible dataset with incr. allocation", file, "dataset1a", cparms, mem_space) < 0 ? 1 : 0;
#ifndef H5_NO_DEPRECATED_SYMBOLS
- nerrors += write_data_deprec("extendible dataset with incr. allocation w/deprec. symbols", file, "dataset1b", cparms, mem_space) < 0 ? 1 : 0;
+ nerrors += write_data_deprec("extendible dataset with incr. allocation w/deprec. symbols", file, "dataset1b", cparms, mem_space) < 0 ? 1 : 0;
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- /* Test with early allocation */
- if(H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR;
- nerrors += write_data("extendible dataset with early allocation", file, "dataset2a", cparms, mem_space) < 0 ? 1 : 0;
+ /* Test with early allocation */
+ if(H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR;
+ nerrors += write_data("extendible dataset with early allocation", file, "dataset2a", cparms, mem_space) < 0 ? 1 : 0;
#ifndef H5_NO_DEPRECATED_SYMBOLS
- nerrors += write_data_deprec("extendible dataset with early allocation w/deprec. symbols", file, "dataset2b", cparms, mem_space) < 0 ? 1 : 0;
+ nerrors += write_data_deprec("extendible dataset with early allocation w/deprec. symbols", file, "dataset2b", cparms, mem_space) < 0 ? 1 : 0;
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- if(H5Pclose(cparms) < 0) TEST_ERROR;
- if(H5Sclose(mem_space) < 0) TEST_ERROR;
- if(H5Fclose(file) < 0) TEST_ERROR;
+ if(H5Pclose(cparms) < 0) TEST_ERROR;
+ if(H5Sclose(mem_space) < 0) TEST_ERROR;
+ if(H5Fclose(file) < 0) TEST_ERROR;
- if(nerrors) {
- printf("***** %d FAILURE%s! *****\n", nerrors, (1 == nerrors) ? "" : "S");
- exit(1);
- } /* end if */
-
- printf("All extend tests passed.\n");
- h5_cleanup(FILENAME, fapl);
+ if(nerrors) {
+ printf("***** %d FAILURE%s! *****\n", nerrors, (1 == nerrors) ? "" : "S");
+ exit(1);
} /* end if */
- else
- puts("All extend tests skipped - Incompatible with current Virtual File Driver");
+
+ printf("All extend tests passed.\n");
+ h5_cleanup(FILENAME, fapl);
return 0;
diff --git a/test/external.c b/test/external.c
index 6820543..b3831ad 100644
--- a/test/external.c
+++ b/test/external.c
@@ -58,21 +58,23 @@ same_contents (const char *name1, const char *name2)
fd1 = HDopen(name1, O_RDONLY, 0666);
fd2 = HDopen(name2, O_RDONLY, 0666);
- assert (fd1>=0 && fd2>=0);
-
- while (1) {
- n1 = HDread(fd1, buf1, sizeof(buf1));
- n2 = HDread(fd2, buf2, sizeof(buf2));
- assert (n1>=0 && (size_t)n1<=sizeof(buf1));
- assert (n2>=0 && (size_t)n2<=sizeof(buf2));
- assert (n1==n2);
-
- if (n1<=0 && n2<=0) break;
- if (memcmp (buf1, buf2, (size_t)n1)) {
- HDclose(fd1);
- HDclose(fd2);
- return 0;
- }
+ assert(fd1 >= 0 && fd2 >= 0);
+
+ while(1) {
+ /* Asserts will catch negative return values */
+ n1 = HDread(fd1, buf1, sizeof(buf1));
+ n2 = HDread(fd2, buf2, sizeof(buf2));
+ assert(n1 >= 0 && (size_t)n1 <= sizeof(buf1));
+ assert(n2 >= 0 && (size_t)n2 <= sizeof(buf2));
+ assert(n1 == n2);
+
+ if(n1 == 0 && n2 == 0)
+ break;
+ if(HDmemcmp(buf1, buf2, (size_t)n1)) {
+ HDclose(fd1);
+ HDclose(fd2);
+ return 0;
+ }
}
HDclose(fd1);
HDclose(fd2);
@@ -612,7 +614,7 @@ test_2 (hid_t fapl)
int temparray[10] = {0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f,0x0f0f0f0f};
TESTING("read external dataset");
-
+
/* Write the data to external files directly */
for (i=0; i<4; i++) {
for (j=0; j<25; j++) {
@@ -784,7 +786,7 @@ test_3 (hid_t fapl)
} /* end if */
} /* end for */
- /* Extend the dataset by another 100 elements */
+ /* Extend the dataset by another 100 elements */
if(H5Dset_extent(dset, &max_size) < 0) goto error;
if(H5Sclose(file_space) < 0) goto error;
if((file_space = H5Dget_space(dset)) < 0) goto error;
@@ -838,69 +840,74 @@ test_3 (hid_t fapl)
static int
test_4 (hid_t fapl)
{
- hid_t fid, gid, xid, xid2;
- char filename[1024]; /*file name */
- char pathname[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
- const char *envval = NULL;
+ hid_t fid = -1;
+ hid_t gid = -1;
+ hid_t xid = -1;
+ hid_t xid2 = -1;
+ char filename[1024]; /*file name */
+ char pathname[1024];
+ char *srcdir = getenv("srcdir"); /*where the src code is located*/
TESTING("opening external link twice");
- /* Don't run this test using the multi file driver */
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
+ /* Make a copy of the FAPL, in order to switch to the sec2 driver */
+ /* (useful when running test with another VFD) */
+ if((fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR;
- if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- goto error;
+ /* Switch local copy of the fapl to the sec2 driver */
+ if(H5Pset_fapl_sec2(fapl) < 0) FAIL_STACK_ERROR;
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
- goto error;
+ h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
- pathname[0] = '\0';
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(LINKED_FILE) + 1) < sizeof(pathname))) {
- HDstrcpy(pathname, srcdir);
- HDstrcat(pathname, "/");
- }
- HDstrcat(pathname, LINKED_FILE);
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
- /* Create an external link to an existing file*/
- if(H5Lcreate_external(pathname, "/group", gid, " link", H5P_DEFAULT, H5P_DEFAULT) < 0)
- goto error;
+ if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
+ goto error;
- if(H5Gclose(gid) < 0)
- goto error;
+ pathname[0] = '\0';
+ /* Generate correct name for test file by prepending the source path */
+ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(LINKED_FILE) + 1) < sizeof(pathname))) {
+ HDstrcpy(pathname, srcdir);
+ HDstrcat(pathname, "/");
+ }
+ HDstrcat(pathname, LINKED_FILE);
- if(H5Fclose(fid) < 0)
- goto error;
+ /* Create an external link to an existing file*/
+ if(H5Lcreate_external(pathname, "/group", gid, " link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto error;
- /* Reopen the file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
- goto error;
+ if(H5Gclose(gid) < 0)
+ goto error;
- /* Open the external link */
- if((xid = H5Gopen2(fid, "/ link", H5P_DEFAULT)) < 0)
- goto error;
+ if(H5Fclose(fid) < 0)
+ goto error;
- /* Open the external link twice */
- if((xid2 = H5Gopen2(xid, ".", H5P_DEFAULT)) < 0)
- goto error;
+ /* Reopen the file */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ goto error;
- if(H5Gclose(xid2) < 0)
- goto error;
+ /* Open the external link */
+ if((xid = H5Gopen2(fid, "/ link", H5P_DEFAULT)) < 0)
+ goto error;
- if(H5Gclose(xid) < 0)
- goto error;
+ /* Open the external link twice */
+ if((xid2 = H5Gopen2(xid, ".", H5P_DEFAULT)) < 0)
+ goto error;
- if(H5Fclose(fid) < 0)
- goto error;
+ if(H5Gclose(xid2) < 0)
+ goto error;
+
+ if(H5Gclose(xid) < 0)
+ goto error;
+
+ if(H5Fclose(fid) < 0)
+ goto error;
- PASSED();
- } else
- SKIPPED();
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR
+
+ PASSED();
return 0;
@@ -909,7 +916,7 @@ test_4 (hid_t fapl)
H5Gclose(gid);
H5Gclose(xid);
H5Gclose(xid2);
- H5Fclose(fid);
+ H5Fclose(fid);
} H5E_END_TRY;
return 1;
}
@@ -939,58 +946,48 @@ main (void)
char filename[1024]; /*file name for test_1* funcs */
hid_t grp=-1; /*group to emit diagnostics */
int nerrors=0; /*number of errors */
- const char *envval = NULL;
-
- /* Don't run this test using the split file driver */
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "split")) {
- h5_reset();
- fapl = h5_fileaccess();
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
- if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Gclose(grp) < 0) goto error;
-
- nerrors += test_1a(file);
- nerrors += test_1b(file);
- nerrors += test_1c(file);
- nerrors += test_1d(file);
- nerrors += test_1e(file);
- nerrors += test_1f(file);
- nerrors += test_1g();
- nerrors += test_1h();
- nerrors += test_2(fapl);
- nerrors += test_3(fapl);
- nerrors += test_4(fapl);
- if (nerrors>0) goto error;
-
- if (H5Fclose(file) < 0) goto error;
- puts("All external storage tests passed.");
- if (h5_cleanup(FILENAME, fapl)) {
- remove("extern_1a.raw");
- remove("extern_1b.raw");
- remove("extern_2a.raw");
- remove("extern_2b.raw");
- remove("extern_3a.raw");
- remove("extern_3b.raw");
- remove("extern_4a.raw");
- remove("extern_4b.raw");
- }
- }
- else
- {
- puts("All external storage tests skipped - Incompatible with current Virtual File Driver");
+
+ h5_reset();
+ fapl = h5_fileaccess();
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
+ if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(grp) < 0) goto error;
+
+ nerrors += test_1a(file);
+ nerrors += test_1b(file);
+ nerrors += test_1c(file);
+ nerrors += test_1d(file);
+ nerrors += test_1e(file);
+ nerrors += test_1f(file);
+ nerrors += test_1g();
+ nerrors += test_1h();
+ nerrors += test_2(fapl);
+ nerrors += test_3(fapl);
+ nerrors += test_4(fapl);
+ if (nerrors>0) goto error;
+
+ if (H5Fclose(file) < 0) goto error;
+ puts("All external storage tests passed.");
+ if (h5_cleanup(FILENAME, fapl)) {
+ remove("extern_1a.raw");
+ remove("extern_1b.raw");
+ remove("extern_2a.raw");
+ remove("extern_2b.raw");
+ remove("extern_3a.raw");
+ remove("extern_3b.raw");
+ remove("extern_4a.raw");
+ remove("extern_4b.raw");
}
+
return 0;
- error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- H5Pclose(fapl);
- } H5E_END_TRY;
- nerrors = MAX(1, nerrors);
- printf ("%d TEST%s FAILED.\n", nerrors, 1==nerrors?"":"s");
- return 1;
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+ nerrors = MAX(1, nerrors);
+ printf ("%d TEST%s FAILED.\n", nerrors, 1==nerrors?"":"s");
+ return 1;
}
diff --git a/test/family_v16_00000.h5 b/test/family_v16_00000.h5
index 5b69c93..ac75ea9 100644
--- a/test/family_v16_00000.h5
+++ b/test/family_v16_00000.h5
Binary files differ
diff --git a/test/farray.c b/test/farray.c
new file mode 100644
index 0000000..b949263
--- /dev/null
+++ b/test/farray.c
@@ -0,0 +1,1659 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This file is modified based on earray.c.
+ */
+#include "h5test.h"
+
+/*
+ * This file needs to access private datatypes from the H5FA package.
+ * This file also needs to access the fixed array testing code.
+ */
+#define H5FA_PACKAGE
+#define H5FA_TESTING
+#include "H5FApkg.h" /* Fixed Arrays */
+
+/* Other private headers that this test requires */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Vprivate.h" /* Vectors and arrays */
+
+
+/* Local macros */
+
+/* Max. testfile name length */
+#define FARRAY_FILENAME_LEN 1024
+
+/* Fixed array creation values */
+#define ELMT_SIZE sizeof(uint64_t)
+#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* 2^10 = 1024 elements per data block page */
+
+/* Testing # of elements in the Fixed Array */
+#define TEST_NELMTS 20000
+
+/* Convenience macros for computing earray state */
+#define FA_HDR_SIZE 28 /* hard-coded */
+#define DBLOCK_PREFIX 18 /* hard-coded */
+
+/* 4 giga-elements: max chunk size */
+#define MAX_NELMTS ((unsigned long long)4*1024*1024*1024) /* 4 giga-elements */
+
+/* Iterator parameter values */
+#define FA_CYC_COUNT 4
+
+
+/* Local typedefs */
+
+/* Types of tests to perform */
+typedef enum {
+ FARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */
+ FARRAY_TEST_REOPEN, /* Set the reopen_array flag */
+ FARRAY_TEST_NTESTS /* The number of test types, must be last */
+} farray_test_type_t;
+
+/* Types of iteration to perform */
+typedef enum {
+ FARRAY_ITER_FW, /* "Forward" iteration */
+ FARRAY_ITER_RV, /* "Reverse" iteration */
+ FARRAY_ITER_RND, /* "Random" iteration */
+ FARRAY_ITER_CYC, /* "Cyclic" iteration */
+ FARRAY_ITER_NITERS /* The number of iteration types, must be last */
+} farray_iter_type_t;
+
+
+/* Fixed array state information */
+typedef struct farray_state_t {
+ hsize_t hdr_size; /* Size of header */
+ hsize_t dblk_size; /* Size of data block */
+ hsize_t nelmts; /* # of elements */
+} farray_state_t;
+
+/* Forward decl. */
+typedef struct farray_test_param_t farray_test_param_t;
+
+/* Fixed array iterator class */
+typedef struct farray_iter_t {
+ void *(*init)(const H5FA_create_t *cparam, const farray_test_param_t *tparam,
+ hsize_t cnt); /* Initialize/allocate iterator private info */
+ hssize_t (*next)(void *info); /* Get the next element to test */
+ herr_t (*term)(void *info); /* Shutdown/free iterator private info */
+} farray_iter_t;
+
+
+/* Testing parameters */
+struct farray_test_param_t {
+ farray_test_type_t reopen_array; /* Whether to re-open the array during the test */
+ hsize_t nelmts; /* # of elements to set for the fixed array */
+ const farray_iter_t *fiter; /* Iterator to use for this test */
+};
+
+/* Local variables */
+const char *FILENAME[] = {
+ "farray",
+ NULL
+};
+
+/* Filename to use for all tests */
+char filename_g[FARRAY_FILENAME_LEN];
+
+/* Empty file size */
+h5_stat_size_t empty_size_g;
+
+
+/*-------------------------------------------------------------------------
+ * Function: init_cparam
+ *
+ * Purpose: Initialize array creation parameter structure
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+init_cparam(H5FA_create_t *cparam, farray_test_param_t *tparam)
+{
+ /* Wipe out background */
+ HDmemset(cparam, 0, sizeof(*cparam));
+
+ cparam->cls = H5FA_CLS_TEST;
+ cparam->raw_elmt_size = ELMT_SIZE;
+ cparam->max_dblk_page_nelmts_bits = MAX_DBLOCK_PAGE_NELMTS_BITS;
+ cparam->nelmts = tparam->nelmts;
+
+ return(0);
+} /* init_cparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_file
+ *
+ * Purpose: Create file and retrieve pointer to internal file object
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_file(hid_t fapl, hid_t *file, H5F_t **f)
+{
+ /* Create the file to work on */
+ if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ FAIL_STACK_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* create_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_stats
+ *
+ * Purpose: Verify stats for a fixed array
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_stats(const H5FA_t *fa, const farray_state_t *state)
+{
+ H5FA_stat_t farray_stats; /* Statistics about the array */
+
+ /* Get statistics for fixed array and verify they are correct */
+ if(H5FA_get_stats(fa, &farray_stats) < 0)
+ FAIL_STACK_ERROR
+
+ /* Compare information */
+ if(farray_stats.hdr_size != state->hdr_size) {
+ HDfprintf(stdout, "farray_stats.hdr_size = %Hu, state->hdr_size = %Hu\n",
+ farray_stats.hdr_size, state->hdr_size);
+ TEST_ERROR
+ } /* end if */
+
+ if(farray_stats.dblk_size != state->dblk_size) {
+ HDfprintf(stdout, "farray_stats.dblk_size = %Hu, state->dblk_size = %Hu\n",
+ farray_stats.dblk_size, state->dblk_size);
+ TEST_ERROR
+ } /* end if */
+
+ if(farray_stats.nelmts != state->nelmts) {
+ HDfprintf(stdout, "farray_stats.nelmts = %Hu, state->nelmts = %Hu\n",
+ farray_stats.nelmts, state->nelmts);
+ TEST_ERROR
+ } /* end if */
+
+ /* All tests passed */
+ return(0);
+
+error:
+ return(-1);
+} /* check_stats() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: set_fa_state
+ *
+ * Purpose: Set the state of the Fixed Array
+ *
+ * Return: does not fail
+ *
+ * Programmer: Vailin Choi; 5th August, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+set_fa_state(const H5FA_create_t *cparam, farray_state_t *state)
+{
+ size_t dblk_page_nelmts; /* # of elements per page */
+
+ /* Sanity check */
+ HDassert(cparam);
+ HDassert(state);
+
+ /* Compute the state of the fixed array */
+ state->hdr_size = FA_HDR_SIZE;
+ state->nelmts = cparam->nelmts;
+
+ dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits;
+ if(state->nelmts > dblk_page_nelmts) {
+ size_t npages = (size_t)(((state->nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts);
+ size_t dblk_page_init_size = (npages + 7) / 8;
+ hsize_t checksum_size = npages * 4;
+
+ state->dblk_size = DBLOCK_PREFIX + dblk_page_init_size + checksum_size +
+ state->nelmts * cparam->raw_elmt_size;
+ } else
+ state->dblk_size = DBLOCK_PREFIX + state->nelmts * cparam->raw_elmt_size;
+
+ return(0);
+} /* end set_fa_state() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: reopen_file
+ *
+ * Purpose: Perform common "re-open" operations on file & array for testing
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
+ H5FA_t **fa, haddr_t fa_addr, const farray_test_param_t *tparam)
+{
+ /* Check for closing & re-opening the array */
+ /* (actually will close & re-open the file as well) */
+ if(tparam->reopen_array) {
+ /* Close array, if given */
+ if(fa) {
+ if(H5FA_close(*fa, dxpl) < 0)
+ FAIL_STACK_ERROR
+ *fa = NULL;
+ } /* end if */
+
+ /* Close file */
+ if(H5Fclose(*file) < 0)
+ FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
+
+ /* Re-open the file */
+ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open array, if given */
+ if(fa) {
+ if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+ } /* end if */
+ } /* end if */
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* reopen_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: create_array
+ *
+ * Purpose: Create a fixed array and perform initial checks
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_array(H5F_t *f, hid_t dxpl, const H5FA_create_t *cparam,
+ H5FA_t **fa, haddr_t *fa_addr)
+{
+ farray_state_t state; /* State of extensible array */
+
+ /* Create array */
+ if(NULL == (*fa = H5FA_create(f, dxpl, cparam, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Check status of array */
+ if(H5FA_get_addr(*fa, fa_addr) < 0)
+ FAIL_STACK_ERROR
+ if(!H5F_addr_defined(*fa_addr))
+ TEST_ERROR
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = FA_HDR_SIZE;
+ state.nelmts = cparam->nelmts;
+ if(check_stats(*fa, &state))
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* create_array() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_cparam
+ *
+ * Purpose: Verify creation parameters are correct
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_cparam(const H5FA_t *fa, const H5FA_create_t *cparam)
+{
+ H5FA_create_t test_cparam; /* Creation parameters for array */
+
+ /* Retrieve creation parameters */
+ HDmemset(&test_cparam, 0, sizeof(H5FA_create_t));
+ if(H5FA_get_cparam_test(fa, &test_cparam) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify creation parameters */
+ if(H5FA_cmp_cparam_test(cparam, &test_cparam))
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* verify_cparam() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: finish
+ *
+ * Purpose: Close array, delete array, close file and verify that file
+ * is empty size
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+finish(hid_t file, hid_t fapl, H5F_t *f, H5FA_t *fa, haddr_t fa_addr)
+{
+ h5_stat_size_t file_size; /* File size, after deleting array */
+
+ /* Close the fixed array */
+ if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Delete array */
+ if(H5FA_delete(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename_g, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size_g)
+ TEST_ERROR
+
+ /* Success */
+ return(0);
+
+error:
+ return(-1);
+} /* finish() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_create
+ *
+ * Purpose: Test creating fixed array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t UNUSED *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Fixed array wrapper */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("invalid fixed array creation parameters");
+
+#ifndef NDEBUG
+{
+ H5FA_create_t test_cparam; /* Creation parameters for array */
+
+ /* Set invalid element size */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.raw_elmt_size = 0;
+ H5E_BEGIN_TRY {
+ fa = H5FA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(fa) {
+ /* Close opened fixed array */
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ fa = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid max. # of elements bits */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.max_dblk_page_nelmts_bits = 0;
+ H5E_BEGIN_TRY {
+ fa = H5FA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(fa) {
+ /* Close opened fixed array */
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ fa = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Set invalid max. # of elements */
+ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
+ test_cparam.nelmts = 0;
+ H5E_BEGIN_TRY {
+ fa = H5FA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL);
+ } H5E_END_TRY;
+ if(fa) {
+ /* Close opened fixed array */
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ fa = NULL;
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ PASSED()
+}
+#else /* NDEBUG */
+ SKIPPED();
+ puts(" Not tested when assertions are disabled");
+#endif /* NDEBUG */
+
+ /*
+ * Display testing message
+ */
+ TESTING("fixed array creation");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ PASSED()
+
+ /* Verify the creation parameters */
+ TESTING("verify array creation parameters");
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, fa, fa_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end test_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_reopen
+ *
+ * Purpose: Create & reopen a fixed array
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Fixed array wrapper */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("create, close & reopen fixed array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ /* Close the fixed array */
+ if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the array */
+ if(NULL == (fa = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, fa, fa_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_reopen() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_open_twice
+ *
+ * Purpose: Open an extensible array twice
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_open_twice(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ hid_t file2 = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5F_t *f2 = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Fixed array wrapper */
+ H5FA_t *fa2 = NULL; /* Fixed array wrapper */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("open fixed array twice");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ /* Open the array again, through the first file handle */
+ if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(fa2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second fixed array wrapper */
+ if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ fa2 = NULL;
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file2 = H5Freopen(file)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
+ /* Open the fixed array through the second file handle */
+ if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the first extensible array wrapper */
+ if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ fa = NULL;
+
+ /* Close the first file */
+ /* (close before second file, to detect error on internal array header's
+ * shared file information)
+ */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file2, fapl, f2, fa2, fa_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ if(fa2)
+ H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ H5Fclose(file2);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_open_twice() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_delete_open
+ *
+ * Purpose: Delete opened fixed array (& open deleted array)
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Fixed array wrapper */
+ H5FA_t *fa2 = NULL; /* Fixed array wrapper */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+ h5_stat_size_t file_size; /* File size, after deleting array */
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /*
+ * Display testing message
+ */
+ TESTING("deleting open fixed array");
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ /* Open the array again */
+ if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
+ FAIL_STACK_ERROR
+
+ /* Request that the array be deleted */
+ if(H5FA_delete(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+ if(verify_cparam(fa2, cparam) < 0)
+ TEST_ERROR
+
+ /* Close the second fixed array wrapper */
+ if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ fa2 = NULL;
+
+ /* Try re-opening the array again (should fail, as array will be deleted) */
+ H5E_BEGIN_TRY {
+ fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL);
+ } H5E_END_TRY;
+ if(fa2) {
+ /* Close opened array */
+ H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Close the first fixed array wrapper */
+ if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ fa = NULL;
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, tparam) < 0)
+ TEST_ERROR
+
+ /* Try re-opening the array again (should fail, as array is now deleted) */
+ H5E_BEGIN_TRY {
+ fa = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL);
+ } H5E_END_TRY;
+ if(fa) {
+ /* Close opened array */
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+
+ /* Indicate error */
+ TEST_ERROR
+ } /* end if */
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename_g, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size_g)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ if(fa2)
+ H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_delete_open() */
+
+/* Fixed array iterator info for forward iteration */
+typedef struct fiter_fw_t {
+ hsize_t idx; /* Index of next array location */
+} fiter_fw_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_fw_init
+ *
+ * Purpose: Initialize element interator (forward iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+fiter_fw_init(const H5FA_create_t UNUSED *cparam, const farray_test_param_t UNUSED *tparam,
+ hsize_t UNUSED cnt)
+{
+ fiter_fw_t *fiter; /* Forward element iteration object */
+
+ /* Allocate space for the element iteration object */
+ fiter = (fiter_fw_t *)HDmalloc(sizeof(fiter_fw_t));
+ HDassert(fiter);
+
+ /* Initialize the element iteration object */
+ fiter->idx = 0;
+
+ /* Return iteration object */
+ return(fiter);
+} /* end fiter_fw_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_fw_next
+ *
+ * Purpose: Get next element index (forward iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+fiter_fw_next(void *_fiter)
+{
+ fiter_fw_t *fiter = (fiter_fw_t *)_fiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(fiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)fiter->idx++;
+
+ return(ret_val);
+} /* end fiter_fw_next() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_term
+ *
+ * Purpose: Shut down element interator (simple iterators)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+fiter_term(void *fiter)
+{
+ /* Sanity check */
+ HDassert(fiter);
+
+ /* Free iteration object */
+ HDfree(fiter);
+
+ return(0);
+} /* end fiter_term() */
+
+/* Fixed array iterator class for forward iteration */
+static const farray_iter_t fa_iter_fw = {
+ fiter_fw_init, /* Iterator init */
+ fiter_fw_next, /* Next array index */
+ fiter_term /* Iterator term */
+};
+
+/* Fixed array iterator info for reverse iteration */
+typedef struct fiter_rv_t {
+ hsize_t idx; /* Index of next array location */
+} fiter_rv_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_rv_init
+ *
+ * Purpose: Initialize element interator (reverse iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+fiter_rv_init(const H5FA_create_t *cparam, const farray_test_param_t UNUSED *tparam,
+ hsize_t UNUSED cnt)
+{
+ fiter_rv_t *fiter; /* Reverse element iteration object */
+
+ /* Allocate space for the element iteration object */
+ fiter = (fiter_rv_t *)HDmalloc(sizeof(fiter_rv_t));
+ HDassert(fiter);
+
+ /* Initialize reverse iteration info */
+ fiter->idx = cparam->nelmts - 1;
+
+ /* Return iteration object */
+ return(fiter);
+} /* end fiter_rv_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_rv_next
+ *
+ * Purpose: Get next element index (reverse iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+fiter_rv_next(void *_fiter)
+{
+ fiter_rv_t *fiter = (fiter_rv_t *)_fiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(fiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)fiter->idx--;
+
+ return(ret_val);
+} /* end fiter_rv_next() */
+
+/* Fixed array iterator class for reverse iteration */
+static const farray_iter_t fa_iter_rv = {
+ fiter_rv_init, /* Iterator init */
+ fiter_rv_next, /* Next array index */
+ fiter_term /* Iterator term */
+};
+
+/* Fixed array iterator info for random iteration */
+typedef struct fiter_rnd_t {
+ hsize_t pos; /* Position in shuffled array */
+ hsize_t *idx; /* Array of shuffled indices */
+} fiter_rnd_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_rnd_init
+ *
+ * Purpose: Initialize element interator (random iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+fiter_rnd_init(const H5FA_create_t UNUSED *cparam, const farray_test_param_t UNUSED *tparam,
+ hsize_t cnt)
+{
+ fiter_rnd_t *fiter; /* Random element iteration object */
+ size_t u; /* Local index variable */
+
+ /* Allocate space for the element iteration object */
+ fiter = (fiter_rnd_t *)HDmalloc(sizeof(fiter_rnd_t));
+ HDassert(fiter);
+
+ /* Allocate space for the array of shuffled indices */
+ fiter->idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)cnt);
+ HDassert(fiter->idx);
+
+ /* Initialize reverse iteration info */
+ fiter->pos = 0;
+ for(u = 0; u < (size_t)cnt; u++)
+ fiter->idx[u] = (hsize_t)u;
+
+ /* Randomly shuffle array indices */
+ if(cnt > 1) {
+ for(u = 0; u < (size_t)cnt; u++) {
+ size_t swap_idx; /* Location to swap with when shuffling */
+ hsize_t temp_idx; /* Temporary index */
+
+ swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u;
+ temp_idx = fiter->idx[u];
+ fiter->idx[u] = fiter->idx[swap_idx];
+ fiter->idx[swap_idx] = temp_idx;
+ } /* end for */
+ } /* end if */
+
+ /* Return iteration object */
+ return(fiter);
+} /* end fiter_rnd_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_rnd_next
+ *
+ * Purpose: Get next element index (random iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+fiter_rnd_next(void *_fiter)
+{
+ fiter_rnd_t *fiter = (fiter_rnd_t *)_fiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(fiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)fiter->idx[fiter->pos];
+ fiter->pos++;
+
+ return(ret_val);
+} /* end fiter_rnd_next() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_rnd_term
+ *
+ * Purpose: Shut down element interator (random iteration)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+fiter_rnd_term(void *_fiter)
+{
+ fiter_rnd_t *fiter = (fiter_rnd_t *)_fiter;
+
+ /* Sanity check */
+ HDassert(fiter);
+ HDassert(fiter->idx);
+
+ /* Free shuffled index array */
+ HDfree(fiter->idx);
+
+ /* Free iteration object */
+ HDfree(fiter);
+
+ return(0);
+} /* end fiter_rnd_term() */
+
+/* Fixed array iterator class for random iteration */
+static const farray_iter_t fa_iter_rnd = {
+ fiter_rnd_init, /* Iterator init */
+ fiter_rnd_next, /* Next array index */
+ fiter_rnd_term /* Iterator term */
+};
+
+/* Fixed array iterator info for cyclic iteration */
+typedef struct fiter_cyc_t {
+ hsize_t pos; /* Position in shuffled array */
+ hsize_t cnt; /* # of elements to store */
+ hsize_t cyc; /* Cycle of elements to choose from */
+} fiter_cyc_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_cyc_init
+ *
+ * Purpose: Initialize element interator (cyclic iteration)
+ *
+ * Return: Success: Pointer to iteration status object
+ * Failure: NULL
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+fiter_cyc_init(const H5FA_create_t UNUSED *cparam, const farray_test_param_t UNUSED *tparam,
+ hsize_t cnt)
+{
+ fiter_cyc_t *fiter; /* Cyclic element iteration object */
+
+ /* Allocate space for the element iteration object */
+ fiter = (fiter_cyc_t *)HDmalloc(sizeof(fiter_cyc_t));
+ HDassert(fiter);
+
+ /* Initialize reverse iteration info */
+ fiter->pos = 0;
+ fiter->cnt = cnt;
+ fiter->cyc = 0;
+
+ /* Return iteration object */
+ return(fiter);
+} /* end fiter_cyc_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: fiter_cyc_next
+ *
+ * Purpose: Get next element index (cyclic iteration)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+static hssize_t
+fiter_cyc_next(void *_fiter)
+{
+ fiter_cyc_t *fiter = (fiter_cyc_t *)_fiter;
+ hssize_t ret_val;
+
+ /* Sanity check */
+ HDassert(fiter);
+
+ /* Get the next array index to test */
+ ret_val = (hssize_t)fiter->pos;
+ fiter->pos += FA_CYC_COUNT;
+ if(fiter->pos >= fiter->cnt)
+ fiter->pos = ++fiter->cyc;
+
+ return(ret_val);
+} /* end fiter_cyc_next() */
+
+
+/* Fixed array iterator class for cyclic iteration */
+static const farray_iter_t fa_iter_cyc = {
+ fiter_cyc_init, /* Iterator init */
+ fiter_cyc_next, /* Next array index */
+ fiter_term /* Iterator term */
+};
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_elmt
+ *
+ * Purpose: Check whether _relmt is the same as in _welmt
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; 6th August, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_elmt(void *_relmt, void *_welmt)
+{
+ uint64_t *relmt = (uint64_t *)_relmt;
+ uint64_t *welmt = (uint64_t *)_welmt;
+
+ if(welmt == NULL) { /* check for fill value */
+ if(*relmt != H5FA_TEST_FILL)
+ TEST_ERROR
+ } /* end if */
+ else {
+ if(*relmt != *welmt)
+ TEST_ERROR
+ } /* end else */
+
+ return(0);
+
+error:
+ return(-1);
+} /* end check_elmt() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_set_elmts
+ *
+ * Purpose: Set all elements from 0 to ('nelmts' - 1) in fixed array
+ * ("nelmts" is the # of elements to be set in the fixed array)
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
+ hsize_t nelmts, const char *test_str)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Fixed array wrapper */
+ void *fiter_info; /* Fixed array iterator info */
+ farray_state_t state; /* State of fixed array */
+ uint64_t welmt; /* Element to write */
+ uint64_t relmt; /* Element to read */
+ hsize_t cnt; /* Count of array indices */
+ hssize_t sidx; /* Index value of next element in the fixed array */
+ hsize_t idx; /* Index value of next element in the fixed array */
+ hsize_t fa_nelmts; /* # of elements in fixed array */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+
+ HDassert(nelmts);
+ /*
+ * Display testing message
+ */
+ TESTING(test_str);
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0)
+ TEST_ERROR
+
+ if(H5FA_get_nelmts(fa, &fa_nelmts) < 0)
+ FAIL_STACK_ERROR
+
+ if(nelmts > fa_nelmts)
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = FA_HDR_SIZE;
+ state.nelmts = cparam->nelmts;
+ state.dblk_size = 0;
+ if(check_stats(fa, &state))
+ TEST_ERROR
+
+ /* Get all elements from empty array */
+
+ /* Initialize iterator */
+ if(NULL == (fiter_info = tparam->fiter->init(cparam, tparam, nelmts)))
+ TEST_ERROR
+
+ /* Get elements of array */
+ for(cnt = 0; cnt < nelmts; cnt++) {
+ /* Get the array index */
+ if((sidx = tparam->fiter->next(fiter_info)) < 0)
+ TEST_ERROR
+ idx = (hsize_t)sidx;
+
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5FA_get(fa, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the retrieved is correct */
+ if(check_elmt(&relmt, NULL))
+ TEST_ERROR
+ } /* end for */
+
+ /* Shutdown iterator */
+ if(tparam->fiter->term(fiter_info) < 0)
+ TEST_ERROR
+
+
+ /* Set (& get) all elements from empty array */
+
+ /* Initialize iterator */
+ if(NULL == (fiter_info = tparam->fiter->init(cparam, tparam, nelmts)))
+ TEST_ERROR
+
+ /* Set elements of array */
+ for(cnt = 0; cnt < nelmts; cnt++) {
+ /* Get the array index */
+ if((sidx = tparam->fiter->next(fiter_info)) < 0)
+ TEST_ERROR
+ idx = (hsize_t)sidx;
+
+ relmt = (uint64_t)0;
+ if(H5FA_get(fa, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the retrieved element is correct */
+ if(check_elmt(&relmt, NULL))
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)7 + idx;
+ if(H5FA_set(fa, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5FA_get(fa, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the retrieved element is correct */
+ if(check_elmt(&relmt, &welmt))
+ TEST_ERROR
+ } /* end for */
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ set_fa_state(cparam, &state);
+ if(check_stats(fa, &state))
+ TEST_ERROR
+
+ /* Shutdown iterator */
+ if(tparam->fiter->term(fiter_info) < 0)
+ TEST_ERROR
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, fa, fa_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_set_elmts() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_skip_elmts
+ *
+ * Purpose: Set the element "skip_elmts" in the fixed array
+ * ("skip_elmts" is the index of the fixed array to be set.)
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
+ hsize_t skip_elmts, hbool_t check_rest, const char *test_str)
+{
+ hid_t file = -1; /* File ID */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FA_t *fa = NULL; /* Extensible array wrapper */
+ farray_state_t state; /* State of extensible array */
+ uint64_t welmt; /* Element to write */
+ uint64_t relmt; /* Element to read */
+ hsize_t idx; /* Index value of element to get */
+ hsize_t cnt; /* Count of array indices */
+ hsize_t fa_nelmts; /* # of elements in fixed array */
+ haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */
+
+ /*
+ * Display testing message
+ */
+ TESTING(test_str);
+
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(fapl, &file, &f) < 0)
+ TEST_ERROR
+
+ /* Create array */
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
+ TEST_ERROR
+
+ /* Verify the creation parameters */
+ if(verify_cparam(fa, cparam) < 0)
+ TEST_ERROR
+
+ /* Check for closing & re-opening the file */
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0)
+ TEST_ERROR
+
+ if(H5FA_get_nelmts(fa, &fa_nelmts) < 0)
+ FAIL_STACK_ERROR
+
+ if(skip_elmts >= fa_nelmts)
+ TEST_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ state.hdr_size = FA_HDR_SIZE;
+ state.nelmts = cparam->nelmts;
+ state.dblk_size = 0;
+ if(check_stats(fa, &state))
+ TEST_ERROR
+
+ /* Set (& get) element after skipping elements */
+ idx = skip_elmts;
+
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5FA_get(fa, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the retrieved is correct */
+ if(check_elmt(&relmt, NULL))
+ TEST_ERROR
+
+ /* Set element of array */
+ welmt = (uint64_t)7 + idx;
+ if(H5FA_set(fa, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify array state */
+ HDmemset(&state, 0, sizeof(state));
+ set_fa_state(cparam, &state);
+ if(check_stats(fa, &state))
+ TEST_ERROR
+
+ /* Retrieve element of array (set now) */
+ relmt = (uint64_t)0;
+ if(H5FA_get(fa, H5P_DATASET_XFER_DEFAULT, idx, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the retrieved is correct */
+ if(check_elmt(&relmt, &welmt))
+ TEST_ERROR
+
+ if(check_rest) {
+ /* Get unset elements of array */
+ for(cnt = 0; cnt < skip_elmts; cnt++) {
+ /* Retrieve element of array (not set yet) */
+ relmt = (uint64_t)0;
+ if(H5FA_get(fa, H5P_DATASET_XFER_DEFAULT, cnt, &relmt) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the retrieved is correct */
+ if(check_elmt(&relmt, NULL))
+ TEST_ERROR
+ } /* end for */
+ } /* end if */
+
+ /* Close array, delete array, close file & verify file is empty */
+ if(finish(file, fapl, f, fa, fa_addr) < 0)
+ TEST_ERROR
+
+ /* All tests passed */
+ PASSED()
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ if(fa)
+ H5FA_close(fa, H5P_DATASET_XFER_DEFAULT);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_skip_elmts() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Test the fixed array code
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ H5FA_create_t cparam; /* Creation parameters for fixed array */
+ farray_test_param_t tparam; /* Testing parameters */
+ farray_test_type_t curr_test; /* Current test being worked on */
+ farray_iter_type_t curr_iter; /* Current iteration type being worked on */
+ hid_t fapl = -1; /* File access property list for data files */
+ unsigned nerrors = 0; /* Cumulative error count */
+ time_t curr_time; /* Current time, for seeding random number generator */
+ int ExpressMode; /* Test express value */
+
+ /* Reset library */
+ h5_reset();
+ fapl = h5_fileaccess();
+ ExpressMode = GetTestExpress();
+ if(ExpressMode > 1)
+ printf("***Express test mode on. Some tests may be skipped\n");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g));
+
+ /* Seed random #'s */
+ curr_time = HDtime(NULL);
+ HDsrandom((unsigned long)curr_time);
+
+ /* Create an empty file to retrieve size */
+ {
+ hid_t file; /* File ID */
+
+ if((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/no array */
+ if((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0)
+ TEST_ERROR
+ }
+
+ /* Iterate over the testing parameters */
+ for(curr_test = FARRAY_TEST_NORMAL; curr_test < FARRAY_TEST_NTESTS; curr_test++) {
+
+ /* Initialize the testing parameters */
+ HDmemset(&tparam, 0, sizeof(tparam));
+ tparam.nelmts = TEST_NELMTS;
+
+ /* Set appropriate testing parameters for each test */
+ switch(curr_test) {
+ /* "Normal" testing parameters */
+ case FARRAY_TEST_NORMAL:
+ puts("Testing with NORMAL PARAMETERS");
+ break;
+
+ /* "Re-open array" testing parameters */
+ case FARRAY_TEST_REOPEN:
+ puts("Testing with reopen array flag set");
+ tparam.reopen_array = FARRAY_TEST_REOPEN;
+ break;
+
+ /* An unknown test? */
+ case FARRAY_TEST_NTESTS:
+ default:
+ goto error;
+ } /* end switch */
+
+ /* Initialize fixed array creation parameters */
+ init_cparam(&cparam, &tparam);
+
+ /* Basic capability tests */
+ nerrors += test_create(fapl, &cparam, &tparam);
+ nerrors += test_reopen(fapl, &cparam, &tparam);
+ nerrors += test_open_twice(fapl, &cparam, &tparam);
+ nerrors += test_delete_open(fapl, &cparam, &tparam);
+
+ /* Iterate over the type of capacity tests */
+ for(curr_iter = FARRAY_ITER_FW; curr_iter < FARRAY_ITER_NITERS; curr_iter++) {
+
+ /* Set appropriate parameters for each type of iteration */
+ switch(curr_iter) {
+ /* "Forward" testing parameters */
+ case FARRAY_ITER_FW:
+ puts("Testing with forward iteration");
+ tparam.fiter = &fa_iter_fw;
+ break;
+
+ /* "Reverse" testing parameters */
+ case FARRAY_ITER_RV:
+ puts("Testing with reverse iteration");
+ tparam.fiter = &fa_iter_rv;
+ break;
+
+ /* "Random" testing parameters */
+ case FARRAY_ITER_RND:
+ puts("Testing with random iteration");
+ tparam.fiter = &fa_iter_rnd;
+ break;
+
+ /* "Cyclic" testing parameters */
+ case FARRAY_ITER_CYC:
+ puts("Testing with cyclic iteration");
+ tparam.fiter = &fa_iter_cyc;
+ break;
+
+ /* An unknown iteration? */
+ case FARRAY_ITER_NITERS:
+ default:
+ goto error;
+ } /* end switch */
+
+ /* Basic capacity tests */
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)1, "setting 1 element of the array");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts/2), "setting half of the array's elements ");
+ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)tparam.nelmts, "setting all the array elements");
+ } /* end for */
+
+ /* Check skipping elements */
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)1, TRUE, "skipping to first element");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, ((hsize_t)1 << cparam.max_dblk_page_nelmts_bits), TRUE, "skipping to first element in data block page");
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts - 1), TRUE, "skipping to last element");
+
+ /* Create Fixed Array of MAX_NELMTS elements */
+ /*
+ * MAX_NELMTS succeeds on jam and smirom.
+ * The value was adjusted for linew due to the following:
+ Linew failed with "H5FD_sec2_truncate(): unable to extend file properly"
+ Linew failed with "H5FD_sec2_truncate(): File too large"
+ */
+ tparam.nelmts = MAX_NELMTS/17;
+ init_cparam(&cparam, &tparam);
+
+ /* Set the last element in the Fixed Array */
+ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts - 1), FALSE, "skipping to last element");
+ } /* end for */
+
+ if(nerrors)
+ goto error;
+ puts("All fixed array tests passed.");
+
+ /* Clean up file used */
+ h5_cleanup(FILENAME, fapl);
+
+ return 0;
+
+error:
+ puts("*** TESTS FAILED ***");
+
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end main() */
+
diff --git a/test/fheap.c b/test/fheap.c
index 263d3a9..26bcaec 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -27,7 +27,7 @@
#include "H5HFpkg.h" /* Fractal heaps */
/* Other private headers that this test requires */
-#include "H5Iprivate.h"
+#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Vprivate.h" /* Vectors and arrays */
@@ -125,7 +125,7 @@ typedef struct fheap_test_param_t {
fheap_test_del_drain_t drain_half; /* Whether to drain half of the objects & refill, when deleting objects */
fheap_test_fill_t fill; /* How to "bulk" fill heap blocks */
size_t actual_id_len; /* The actual length of heap IDs for a test */
- fheap_test_comp_t comp; /* Whether to compressed the blocks or not */
+ fheap_test_comp_t comp; /* Whether to compress the blocks or not */
} fheap_test_param_t;
/* Heap state information */
@@ -416,11 +416,11 @@ add_obj(H5HF_t *fh, hid_t dxpl, size_t obj_off,
/* Check for needing to increase size of heap ID array */
if(keep_ids->num_ids + 1 > keep_ids->alloc_ids) {
keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2));
- if(NULL == (keep_ids->ids = H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids)))
+ if(NULL == (keep_ids->ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids)))
TEST_ERROR
- if(NULL == (keep_ids->lens = H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
+ if(NULL == (keep_ids->lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
TEST_ERROR
- if(NULL == (keep_ids->offs = H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
+ if(NULL == (keep_ids->offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
TEST_ERROR
} /* end if */
@@ -535,7 +535,7 @@ begin_test(fheap_test_param_t *tparam, const char *base_desc,
*/
del_str = get_del_string(tparam);
HDassert(del_str);
- test_desc = H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
+ test_desc = (char *)H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
sprintf(test_desc, base_desc, del_str);
TESTING(test_desc);
H5MM_xfree(del_str);
@@ -576,17 +576,20 @@ reopen_file(hid_t *file, H5F_t **f, const char *filename, hid_t fapl, hid_t dxpl
/* Close heap */
if(H5HF_close(*fh, dxpl) < 0)
FAIL_STACK_ERROR
+ *fh = NULL;
/* Close file */
if(H5Fclose(*file) < 0)
FAIL_STACK_ERROR
+ *file = (-1);
+ *f = NULL;
/* Re-open the file */
if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (*f = H5I_object(*file)))
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
FAIL_STACK_ERROR
/* Re-open heap */
@@ -633,7 +636,7 @@ open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam,
/* Check for deleting the entire heap */
if(tparam->del_dir != FHEAP_DEL_HEAP) {
/* Get a pointer to the internal file object */
- if(NULL == (*f = H5I_object(*file)))
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
FAIL_STACK_ERROR
/* Create absolute heap */
@@ -663,7 +666,7 @@ open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam,
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((*empty_size = h5_get_file_size(filename)) < 0)
+ if((*empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -671,7 +674,7 @@ open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam,
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (*f = H5I_object(*file)))
+ if(NULL == (*f = (H5F_t *)H5I_object(*file)))
FAIL_STACK_ERROR
/* Check for deleting the entire heap */
@@ -748,7 +751,6 @@ error:
* Purpose: Perform common "close" operations on file & heap for testing
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -757,7 +759,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-close_heap(char *filename, hid_t dxpl, fheap_test_param_t *tparam,
+close_heap(char *filename, hid_t fapl, hid_t dxpl, fheap_test_param_t *tparam,
hid_t file, H5F_t *f, H5HF_t **fh, haddr_t fh_addr,
fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids,
h5_stat_size_t empty_size)
@@ -796,7 +798,7 @@ close_heap(char *filename, hid_t dxpl, fheap_test_param_t *tparam,
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -1057,11 +1059,11 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size,
/* Check for needing to increase size of heap ID array */
if(num_ids > shared_alloc_ids_g) {
shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2));
- if(NULL == (shared_ids_g = H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g)))
+ if(NULL == (shared_ids_g = (unsigned char *)H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g)))
TEST_ERROR
- if(NULL == (shared_lens_g = H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g)))
+ if(NULL == (shared_lens_g = (size_t *)H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g)))
TEST_ERROR
- if(NULL == (shared_offs_g = H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g)))
+ if(NULL == (shared_offs_g = (size_t *)H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g)))
TEST_ERROR
curr_id_ptr = &shared_ids_g[(num_ids - 1) * id_len];
curr_len_ptr = &shared_lens_g[(num_ids - 1)];
@@ -1108,11 +1110,11 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size,
/* Check for needing to increase size of heap ID array */
if(num_ids > shared_alloc_ids_g) {
shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2));
- if(NULL == (shared_ids_g = H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g)))
+ if(NULL == (shared_ids_g = (unsigned char *)H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g)))
TEST_ERROR
- if(NULL == (shared_lens_g = H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g)))
+ if(NULL == (shared_lens_g = (size_t *)H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g)))
TEST_ERROR
- if(NULL == (shared_offs_g = H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g)))
+ if(NULL == (shared_offs_g = (size_t *)H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g)))
TEST_ERROR
curr_id_ptr = &shared_ids_g[(num_ids - 1) * id_len];
curr_len_ptr = &shared_lens_g[(num_ids - 1)];
@@ -1164,11 +1166,11 @@ fill_heap(H5HF_t *fh, hid_t dxpl, unsigned block_row, size_t obj_size,
/* Check for needing to increase size of heap ID array */
if(keep_ids->num_ids + num_ids > keep_ids->alloc_ids) {
keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2));
- if(NULL == (keep_ids->ids = H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids)))
+ if(NULL == (keep_ids->ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids)))
TEST_ERROR
- if(NULL == (keep_ids->lens = H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
+ if(NULL == (keep_ids->lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids)))
TEST_ERROR
- if(NULL == (keep_ids->offs = H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
+ if(NULL == (keep_ids->offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids)))
TEST_ERROR
} /* end if */
@@ -1797,7 +1799,6 @@ error:
* Purpose: Create fractal heap
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -1805,7 +1806,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam)
{
hid_t file = -1; /* File ID */
@@ -1831,7 +1832,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -1839,7 +1840,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/*
@@ -1883,7 +1884,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -1911,7 +1912,6 @@ error:
* Purpose: Create & reopen a fractal heap
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -1919,7 +1919,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam)
{
hid_t file = -1; /* File ID */
@@ -1928,6 +1928,8 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
H5HF_create_t test_cparam; /* Creation parameters for heap */
H5HF_t *fh = NULL; /* Fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
+ h5_stat_size_t empty_size; /* File size, w/o heap */
+ h5_stat_size_t file_size; /* File size, after deleting heap */
size_t id_len; /* Size of fractal heap IDs */
fheap_heap_state_t state; /* State of fractal heap */
@@ -1938,12 +1940,24 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/*
- * Test fractal heap creation
+ * Display testing message
*/
TESTING("create, close & reopen fractal heap");
@@ -1967,11 +1981,26 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
if(H5HF_close(fh, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
+ /* Check for closing & re-opening the file */
+ if(tparam->reopen_heap) {
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
/* Re-open the heap */
if(NULL == (fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr)))
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Query the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -1983,10 +2012,22 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam
FAIL_STACK_ERROR
fh = NULL;
+ /* Delete heap */
+ if(H5HF_delete(f, H5P_DATASET_XFER_DEFAULT, fh_addr) < 0)
+ FAIL_STACK_ERROR
+
/* Close the file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
/* All tests passed */
PASSED()
@@ -2015,7 +2056,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam)
{
hid_t file = -1; /* File ID */
@@ -2027,6 +2068,8 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
H5HF_t *fh = NULL; /* Fractal heap wrapper */
H5HF_t *fh2 = NULL; /* 2nd fractal heap wrapper */
haddr_t fh_addr; /* Address of fractal heap */
+ h5_stat_size_t empty_size; /* File size, w/o heap */
+ h5_stat_size_t file_size; /* File size, after deleting heap */
size_t id_len; /* Size of fractal heap IDs */
fheap_heap_state_t state; /* State of fractal heap */
@@ -2037,22 +2080,25 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR
- /* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
- STACK_ERROR
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
/* Re-open the file */
- if((file2 = H5Freopen(file)) < 0)
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f2 = H5I_object(file2)))
- FAIL_STACK_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ STACK_ERROR
/*
- * Test fractal heap creation
+ * Display testing message
*/
-
TESTING("open fractal heap twice");
/* Create heap */
@@ -2070,11 +2116,11 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
if(check_stats(fh, &state))
TEST_ERROR
- /* Open the heap again */
+ /* Open the heap again, through the first file handle */
if(NULL == (fh2 = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr)))
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Verify the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh2, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -2086,11 +2132,23 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
FAIL_STACK_ERROR
fh2 = NULL;
+ /* Check for closing & re-opening the heap & file */
+ if(reopen_file(&file, &f, filename, fapl, H5P_DATASET_XFER_DEFAULT, &fh, fh_addr, tparam) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file2 = H5Freopen(file)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
+ FAIL_STACK_ERROR
+
/* Open the fractal heap through the second file handle */
if(NULL == (fh2 = H5HF_open(f2, H5P_DATASET_XFER_DEFAULT, fh_addr)))
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Verify the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh2, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -2114,10 +2172,22 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp
FAIL_STACK_ERROR
fh2 = NULL;
+ /* Delete heap */
+ if(H5HF_delete(f2, H5P_DATASET_XFER_DEFAULT, fh_addr) < 0)
+ FAIL_STACK_ERROR
+
/* Close the second file */
if(H5Fclose(file2) < 0)
FAIL_STACK_ERROR
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
/* All tests passed */
PASSED()
@@ -2132,6 +2202,7 @@ error:
H5Fclose(file);
H5Fclose(file2);
} H5E_END_TRY;
+
return(1);
} /* test_open_twice() */
@@ -2149,7 +2220,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam)
{
hid_t file = -1; /* File ID */
@@ -2176,7 +2247,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
FAIL_STACK_ERROR
/* Get the size of a file w/no heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -2184,7 +2255,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Display test banner */
@@ -2213,7 +2284,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
if(H5HF_delete(f, H5P_DATASET_XFER_DEFAULT, fh_addr) < 0)
FAIL_STACK_ERROR
- /* Query the type of address mapping */
+ /* Verify the creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5HF_create_t));
if(H5HF_get_cparam_test(fh2, &test_cparam) < 0)
FAIL_STACK_ERROR
@@ -2242,7 +2313,21 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
FAIL_STACK_ERROR
fh = NULL;
-#ifdef QAK
+ /* Check for closing & re-opening the file */
+ if(tparam->reopen_heap) {
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+ } /* end if */
+
/* Try re-opening the heap again (should fail, as heap is now deleted) */
H5E_BEGIN_TRY {
fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr);
@@ -2254,14 +2339,13 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t
/* Indicate error */
TEST_ERROR
} /* end if */
-#endif /* QAK */
/* Close the file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -2298,7 +2382,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_id_limits(hid_t fapl, H5HF_create_t *cparam)
{
hid_t file = -1; /* File ID */
@@ -2321,7 +2405,7 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Display testing message */
@@ -2639,7 +2723,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_filtered_create(hid_t fapl, H5HF_create_t *cparam)
{
hid_t file = -1; /* File ID */
@@ -2660,7 +2744,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Display testing message */
@@ -2685,8 +2769,6 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam)
if(!H5F_addr_defined(fh_addr))
TEST_ERROR
-/* XXX: Check heap's I/O filter settings? */
-
/* Close the fractal heap */
if(H5HF_close(fh, dxpl) < 0)
FAIL_STACK_ERROR
@@ -2701,7 +2783,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -2715,8 +2797,6 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam)
if(H5HF_cmp_cparam_test(&tmp_cparam, &test_cparam))
FAIL_STACK_ERROR
-/* XXX: Check heap's I/O filter settings? */
-
/* Close the fractal heap */
if(H5HF_close(fh, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
@@ -2758,7 +2838,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_size(hid_t fapl, H5HF_create_t *cparam)
{
hid_t file = -1; /* File ID */
@@ -2779,7 +2859,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Display testing message */
@@ -2829,7 +2909,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -2892,7 +2972,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -2914,7 +2994,7 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Create absolute heap */
@@ -3000,7 +3080,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3020,7 +3100,7 @@ test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Create absolute heap */
@@ -3097,7 +3177,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3117,7 +3197,7 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3189,7 +3269,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3210,7 +3290,7 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3284,7 +3364,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3305,7 +3385,7 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3386,7 +3466,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3407,7 +3487,7 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3489,7 +3569,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3510,7 +3590,7 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3596,7 +3676,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3617,7 +3697,7 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3688,7 +3768,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3709,7 +3789,7 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3787,7 +3867,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3808,7 +3888,7 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3884,7 +3964,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -3905,7 +3985,7 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -3990,7 +4070,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4012,7 +4092,7 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4084,7 +4164,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4105,7 +4185,7 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4176,7 +4256,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4197,7 +4277,7 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4274,7 +4354,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4295,7 +4375,7 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4380,7 +4460,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4401,7 +4481,7 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4479,7 +4559,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4500,7 +4580,7 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4586,7 +4666,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4607,7 +4687,7 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4690,7 +4770,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4711,7 +4791,7 @@ test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4788,7 +4868,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4809,7 +4889,7 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4893,7 +4973,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -4914,7 +4994,7 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -4992,7 +5072,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5013,7 +5093,7 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5098,7 +5178,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5119,7 +5199,7 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5205,7 +5285,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5226,7 +5306,7 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5308,7 +5388,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5329,7 +5409,7 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5412,7 +5492,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5433,7 +5513,7 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5523,7 +5603,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5544,7 +5624,7 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5639,7 +5719,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5660,7 +5740,7 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5747,7 +5827,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5768,7 +5848,7 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5858,7 +5938,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -5879,7 +5959,7 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -5983,7 +6063,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -6009,7 +6089,7 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -6050,7 +6130,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed);
/* Set heap ID to random (non-null) value */
heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN;
for(u = 1; u < HEAP_ID_LEN; u++)
- heap_id[u] = HDrandom() + 1;
+ heap_id[u] = (unsigned char)(HDrandom() + 1);
/* Try removing bogus heap ID from empty heap */
H5E_BEGIN_TRY {
@@ -6072,7 +6152,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed);
/* Set heap ID to random (non-null) value */
heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN;
for(u = 1; u < HEAP_ID_LEN; u++)
- heap_id[u] = HDrandom() + 1;
+ heap_id[u] = (unsigned char)(HDrandom() + 1);
/* Get offset of random heap ID */
if(H5HF_get_id_off_test(fh, heap_id, &obj_off) < 0)
@@ -6133,7 +6213,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -6158,7 +6238,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -6187,7 +6267,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -6195,7 +6275,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open heap */
@@ -6209,7 +6289,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
/* Initialize the buffer for objects to insert */
for(u = 0; u < sizeof(obj); u++)
- obj[u] = u;
+ obj[u] = (unsigned char)u;
/* Insert object into heap */
if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &heap_id) < 0)
@@ -6252,7 +6332,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
TEST_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -6288,7 +6368,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -6314,7 +6394,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -6343,7 +6423,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -6351,7 +6431,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open heap */
@@ -6365,7 +6445,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
/* Initialize the buffer for objects to insert */
for(u = 0; u < sizeof(obj); u++)
- obj[u] = u;
+ obj[u] = (unsigned char)u;
/* Insert first object into heap */
if(H5HF_insert(fh, dxpl, sizeof(obj), obj, &heap_id1) < 0)
@@ -6436,7 +6516,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara
TEST_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -6473,7 +6553,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -6499,7 +6579,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -6528,7 +6608,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -6536,7 +6616,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open heap */
@@ -6596,7 +6676,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -6633,7 +6713,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -6660,7 +6740,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -6689,7 +6769,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -6697,7 +6777,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open heap */
@@ -6827,7 +6907,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
TEST_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -6868,7 +6948,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -6896,7 +6976,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
TEST_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
STACK_ERROR
/* Create absolute heap */
@@ -6925,7 +7005,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
FAIL_STACK_ERROR
/* Get the size of a file w/empty heap*/
- if((empty_size = h5_get_file_size(filename)) < 0)
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Re-open the file */
@@ -6933,7 +7013,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open heap */
@@ -7122,7 +7202,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
TEST_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
@@ -7165,7 +7245,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7198,7 +7278,7 @@ test_man_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7239,7 +7319,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7287,7 +7367,7 @@ test_man_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7328,7 +7408,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7358,7 +7438,7 @@ test_man_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7399,7 +7479,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7431,7 +7511,7 @@ test_man_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_par
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7472,7 +7552,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7508,7 +7588,7 @@ test_man_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7549,7 +7629,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7579,7 +7659,7 @@ test_man_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7620,7 +7700,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7654,7 +7734,7 @@ test_man_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7695,7 +7775,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7733,7 +7813,7 @@ test_man_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7779,7 +7859,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7815,7 +7895,7 @@ test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7857,7 +7937,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -7913,7 +7993,7 @@ test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -7956,7 +8036,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8023,7 +8103,7 @@ test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8066,7 +8146,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8117,7 +8197,7 @@ test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8163,7 +8243,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8260,7 +8340,7 @@ test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8308,7 +8388,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8427,7 +8507,7 @@ test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8474,7 +8554,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8557,7 +8637,7 @@ test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8601,7 +8681,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8685,7 +8765,7 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8728,7 +8808,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8808,7 +8888,7 @@ test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8852,7 +8932,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -8936,7 +9016,7 @@ test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_
TEST_ERROR
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -8981,7 +9061,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -9079,7 +9159,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -9127,7 +9207,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -9254,7 +9334,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -9297,7 +9377,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -9406,7 +9486,7 @@ test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -9451,7 +9531,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -9587,7 +9667,7 @@ test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -9631,7 +9711,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -9714,7 +9794,7 @@ test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -9760,7 +9840,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -9853,7 +9933,7 @@ test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -9898,7 +9978,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -10004,7 +10084,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -10050,7 +10130,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -10166,7 +10246,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -10213,7 +10293,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -10328,7 +10408,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -10376,7 +10456,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -10497,7 +10577,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -10543,7 +10623,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -10657,7 +10737,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -10705,7 +10785,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -10835,7 +10915,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -10885,7 +10965,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -11048,7 +11128,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -11100,7 +11180,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -11245,7 +11325,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -11297,7 +11377,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -11478,7 +11558,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -11525,7 +11605,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -11613,7 +11693,7 @@ test_man_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -11657,7 +11737,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -11783,7 +11863,7 @@ test_man_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -11829,7 +11909,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_frag_2nd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -11896,7 +11976,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows);
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -11943,7 +12023,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_man_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -12015,7 +12095,7 @@ test_man_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *
/* Perform common file & heap close operations */
- if(close_heap(filename, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
+ if(close_heap(filename, fapl, dxpl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0)
TEST_ERROR
/* Free resources */
@@ -12058,7 +12138,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_huge_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -12087,7 +12167,7 @@ test_huge_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'huge' object's heap IDs are correct size */
@@ -12161,7 +12241,7 @@ test_huge_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -12211,7 +12291,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_huge_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -12241,9 +12321,9 @@ test_huge_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id2 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'huge' object's heap IDs are correct size */
@@ -12392,7 +12472,7 @@ test_huge_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -12444,7 +12524,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_huge_insert_three(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -12475,11 +12555,11 @@ test_huge_insert_three(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id2 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id3 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'huge' object's heap IDs are correct size */
@@ -12698,7 +12778,7 @@ test_huge_insert_three(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -12752,7 +12832,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_huge_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -12785,15 +12865,15 @@ test_huge_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id2 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id3 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id4 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id4 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id5 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id5 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'huge' object's heap IDs are correct size */
@@ -13122,7 +13202,7 @@ test_huge_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -13178,7 +13258,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -13226,7 +13306,7 @@ test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'huge' object's heap IDs are correct form */
@@ -13279,7 +13359,7 @@ test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -13339,7 +13419,7 @@ test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, (unsigned long)file_size);
@@ -13390,7 +13470,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_tiny_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -13419,7 +13499,7 @@ test_tiny_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'tiny' object's heap IDs are correct size */
@@ -13493,7 +13573,7 @@ test_tiny_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -13543,7 +13623,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_tiny_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -13573,9 +13653,9 @@ test_tiny_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id2 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'tiny' object's heap IDs are correct size */
@@ -13724,7 +13804,7 @@ test_tiny_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -13777,7 +13857,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_tiny_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -13812,19 +13892,19 @@ test_tiny_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
TEST_ERROR
/* Allocate heap ID(s) */
- if(NULL == (heap_id = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id2 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id3 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id4 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id4 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id5 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id5 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id6 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id6 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
- if(NULL == (heap_id7 = H5MM_malloc(tparam->actual_id_len)))
+ if(NULL == (heap_id7 = (unsigned char *)H5MM_malloc(tparam->actual_id_len)))
TEST_ERROR
/* Make certain that 'tiny' object's heap IDs are correct size */
@@ -14325,7 +14405,7 @@ test_tiny_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -14388,7 +14468,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_filtered_man_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -14455,7 +14535,7 @@ test_filtered_man_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -14515,9 +14595,10 @@ test_filtered_man_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
+/* Needs file free space to be persistent */
#ifdef NOT_YET
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, (unsigned long)file_size);
@@ -14559,7 +14640,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -14636,7 +14717,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -14696,7 +14777,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -14728,7 +14809,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -14761,7 +14842,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -14793,7 +14874,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -14823,9 +14904,10 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
+/* Needs file free space to be persistent */
#ifdef NOT_YET
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, (unsigned long)file_size);
@@ -14873,7 +14955,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_random(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -14948,7 +15030,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed);
total_obj_added = 0;
while(total_obj_added < size_limit) {
/* Choose a random size of object (from 1 up to above standalone block size limit) */
- obj_size = (HDrandom() % (tmp_cparam.max_man_size + 255)) + 1;
+ obj_size = (((uint32_t)HDrandom() % (tmp_cparam.max_man_size + 255)) + 1);
obj_loc = (tmp_cparam.max_man_size + 255) - obj_size;
/* Insert object */
@@ -14972,7 +15054,7 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %
/* Choose a position to swap with */
/* (0 is current position) */
- pos = HDrandom() % (keep_ids.num_ids - u);
+ pos = ((size_t)HDrandom() % (keep_ids.num_ids - u));
/* If we chose a different position, swap with it */
if(pos > 0) {
@@ -15021,7 +15103,7 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size);
@@ -15077,7 +15159,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_random_pow2(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -15164,7 +15246,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed);
size_range = tmp_cparam.max_man_size + 255;
/* Choose a random size of object (from 1 up to stand alone block size) */
- obj_size = (HDrandom() % (size_range - 1)) + 1;
+ obj_size = (((unsigned)HDrandom() % (size_range - 1)) + 1);
obj_loc = (tmp_cparam.max_man_size + 255) - obj_size;
/* Insert object */
@@ -15188,7 +15270,7 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %
/* Choose a position to swap with */
/* (0 is current position) */
- pos = HDrandom() % (keep_ids.num_ids - u);
+ pos = ((size_t)HDrandom() % (keep_ids.num_ids - u));
/* If we chose a different position, swap with it */
if(pos > 0) {
@@ -15237,7 +15319,7 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %
FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0)
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
TEST_ERROR
#ifdef QAK
HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size);
@@ -15291,7 +15373,19 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+/* Custom filter used to verify that the filters are actually called and do not
+ * just silently fail */
+static hbool_t test_write_filter_called;
+static size_t test_write_filter(unsigned int UNUSED flags, size_t UNUSED cd_nelmts,
+ const unsigned int UNUSED cd_values[], size_t nbytes, size_t UNUSED *buf_size,
+ void UNUSED **buf)
+{
+ test_write_filter_called = TRUE;
+
+ return nbytes;
+} /* end link_filter_filter */
+
+static unsigned
test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -15327,12 +15421,27 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
/* Check if we are compressing the blocks */
if(tparam->comp == FHEAP_TEST_COMPRESS) {
+ H5Z_class2_t filter_class; /* Custom filter */
unsigned deflate_level; /* Deflation level */
/* Set an I/O filter for heap data */
deflate_level = 6;
if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0)
FAIL_STACK_ERROR
+
+ /* Register and append custom filter */
+ filter_class.version = H5Z_CLASS_T_VERS;
+ filter_class.id = H5Z_FILTER_RESERVED + 43;
+ filter_class.encoder_present = TRUE;
+ filter_class.decoder_present = TRUE;
+ filter_class.name = "custom_fheap_filter";
+ filter_class.can_apply = NULL;
+ 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)
+ FAIL_STACK_ERROR
+ test_write_filter_called = FALSE;
} /* end if */
/* Perform common file & heap open operations */
@@ -15380,10 +15489,39 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
if(ret >= 0)
TEST_ERROR
+ /* Close the fractal heap */
+ if(H5HF_close(fh, dxpl) < 0)
+ FAIL_STACK_ERROR
+ fh = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that the custom filter has been applied for the huge object (if
+ * applicable) */
+ if(tparam->comp == FHEAP_TEST_COMPRESS) {
+ if(!test_write_filter_called) TEST_ERROR
+ test_write_filter_called = FALSE;
+ } /* end if */
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Re-open the heap */
+ if(NULL == (fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr)))
+ FAIL_STACK_ERROR
+
/* Initialize data to overwrite with */
- rewrite_obj = H5MM_malloc(shared_obj_size_g);
+ rewrite_obj = (unsigned char *)H5MM_malloc(shared_obj_size_g);
for(u = 0; u < shared_obj_size_g; u++)
- rewrite_obj[u] = shared_wobj_g[u] * 2;
+ rewrite_obj[u] = (unsigned char)(shared_wobj_g[u] * 2);
/* Insert different sized objects, but stay out of "tiny" and "huge" zones */
obj_size = 20;
@@ -15411,9 +15549,9 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
/* Change size of data to write */
if(u < 20)
- obj_size *= 1.3;
+ obj_size = (size_t)(obj_size * 1.3);
else
- obj_size /= 1.3;
+ obj_size = (size_t)(obj_size / 1.3);
} /* end for */
/* Close the fractal heap */
@@ -15425,13 +15563,18 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
+ /* Verify that the custom filter has been applied to the managed objects (if
+ * applicable) */
+ if(tparam->comp == FHEAP_TEST_COMPRESS)
+ if(!test_write_filter_called) TEST_ERROR
+
/* Re-open the file */
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -15451,9 +15594,9 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
/* Change size of data to write */
if(u < 20)
- obj_size *= 1.3;
+ obj_size = (size_t)(obj_size * 1.3);
else
- obj_size /= 1.3;
+ obj_size = (size_t)(obj_size / 1.3);
} /* end for */
/* Close the fractal heap */
@@ -15508,7 +15651,7 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned
test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
@@ -15589,7 +15732,7 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -15615,7 +15758,7 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
- if(NULL == (f = H5I_object(file)))
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
/* Re-open the heap */
@@ -15686,37 +15829,23 @@ main(void)
fheap_test_type_t curr_test; /* Current test being worked on */
unsigned u; /* Local index variable */
unsigned nerrors = 0; /* Cumulative error count */
- int ExpressMode;
- const char *envval = NULL; /* File Driver value from environment */
+ int ExpressMode; /* Express testing level */
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
ExpressMode = GetTestExpress();
- if (ExpressMode > 1)
+ if(ExpressMode > 1)
printf("***Express test mode on. Some tests may be skipped\n");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
-
- /* This test case with Direct driver has a poor performance on
- * NCSA copper, though it works. Skip it if the express mode is set on
- * and worry about the performance later.
- */
- if((HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") &&
- HDstrcmp(envval, "family") && HDstrcmp(envval, "stdio")) &&
- !(!HDstrcmp(envval, "direct") && (ExpressMode > 1)))
- {
-
/* Initialize heap creation parameters */
init_small_cparam(&small_cparam);
init_large_cparam(&large_cparam);
/* Allocate space for the shared objects */
shared_obj_size_g = large_cparam.max_man_size + 256;
- shared_wobj_g = H5MM_malloc(shared_obj_size_g);
- shared_robj_g = H5MM_malloc(shared_obj_size_g);
+ shared_wobj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g);
+ shared_robj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g);
/* Initialize the shared write buffer for objects */
for(u = 0; u < shared_obj_size_g; u++)
@@ -15744,7 +15873,7 @@ curr_test = FHEAP_TEST_NORMAL;
/* "Re-open heap" testing parameters */
case FHEAP_TEST_REOPEN:
puts("Testing with reopen heap flag set");
- tparam.reopen_heap = TRUE;
+ tparam.reopen_heap = FHEAP_TEST_REOPEN;
break;
/* An unknown test? */
@@ -15839,7 +15968,7 @@ fill = FHEAP_TEST_FILL_LARGE;
* level of complexity gradually. -QAK
*/
#ifndef QAK
- if (ExpressMode > 1)
+ if(ExpressMode > 1)
printf("***Express test mode on. test_man_start_5th_recursive_indirect is skipped\n");
else
nerrors += test_man_start_5th_recursive_indirect(fapl, &small_cparam, &tparam);
@@ -15898,7 +16027,7 @@ tparam.drain_half = FHEAP_DEL_DRAIN_ALL;
nerrors += test_man_remove_first_row(fapl, &small_cparam, &tparam);
nerrors += test_man_remove_first_two_rows(fapl, &small_cparam, &tparam);
nerrors += test_man_remove_first_four_rows(fapl, &small_cparam, &tparam);
- if (ExpressMode > 1)
+ if(ExpressMode > 1)
printf("***Express test mode on. Some tests skipped\n");
else {
nerrors += test_man_remove_all_root_direct(fapl, &small_cparam, &tparam);
@@ -15930,7 +16059,7 @@ tparam.drain_half = FHEAP_DEL_DRAIN_ALL;
nerrors += test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam);
nerrors += test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam);
nerrors += test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam);
- if (ExpressMode > 1)
+ if(ExpressMode > 1)
printf("***Express test mode on. Some tests skipped\n");
else {
nerrors += test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(fapl, &small_cparam, &tparam);
@@ -15984,7 +16113,7 @@ HDfprintf(stderr, "Uncomment tests!\n");
/* Test "normal" & "direct" storage of 'huge' & 'tiny' heap IDs */
for(id_len = 0; id_len < 3; id_len++) {
/* Set the ID length for this test */
- small_cparam.id_len = id_len;
+ small_cparam.id_len = (uint16_t)id_len;
/* Print information about each test */
switch(id_len) {
@@ -16018,11 +16147,15 @@ HDfprintf(stderr, "Uncomment tests!\n");
tparam.del_dir = del_dir;
/* Test 'huge' object insert & delete */
+#ifndef QAK
nerrors += test_huge_insert_one(fapl, &small_cparam, &tparam);
nerrors += test_huge_insert_two(fapl, &small_cparam, &tparam);
nerrors += test_huge_insert_three(fapl, &small_cparam, &tparam);
nerrors += test_huge_insert_mix(fapl, &small_cparam, &tparam);
nerrors += test_filtered_huge(fapl, &small_cparam, &tparam);
+#else /* QAK */
+HDfprintf(stderr, "Uncomment tests!\n");
+#endif /* QAK */
#ifndef QAK
/* Test 'tiny' object insert & delete */
@@ -16076,7 +16209,7 @@ HDfprintf(stderr, "Uncomment tests!\n");
#ifndef QAK
/* Random object insertion & deletion */
- if (ExpressMode > 1)
+ if(ExpressMode > 1)
printf("***Express test mode on. Some tests skipped\n");
else {
#ifndef QAK
@@ -16164,10 +16297,6 @@ HDfprintf(stderr, "Uncomment tests!\n");
#else /* QAK */
HDfprintf(stderr, "Uncomment cleanup!\n");
#endif /* QAK */
- } /* end if(HDstrcmp(envval=="...")) */
- else {
- printf("All fractal heap tests skipped - Incompatible with current Virtual File Driver\n");
- }
return 0;
diff --git a/test/filespace_1_6.h5 b/test/filespace_1_6.h5
new file mode 100644
index 0000000..5afc718
--- /dev/null
+++ b/test/filespace_1_6.h5
Binary files differ
diff --git a/test/filespace_1_8.h5 b/test/filespace_1_8.h5
new file mode 100644
index 0000000..85138b0
--- /dev/null
+++ b/test/filespace_1_8.h5
Binary files differ
diff --git a/test/fillval.c b/test/fillval.c
index e92872a..2f58380 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -1529,7 +1529,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
/* Create dataspace describing memory buffer */
if((mspace = H5Screate_simple(5, hs_size, hs_size)) < 0) TEST_ERROR
- /* Select elements within file dataspace */
+ /* Select elements within file dataspace */
if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL) < 0) TEST_ERROR
/* Write to all even data locations */
@@ -1721,7 +1721,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
/* Verify the element read in is the value written out */
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, buf) < 0) TEST_ERROR
-
+
/* Set the element back to fillval */
if(H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, fillval) < 0) TEST_ERROR
@@ -1966,18 +1966,18 @@ skip:
*-------------------------------------------------------------------------
*/
static int
-test_compatible(hid_t fapl)
+test_compatible(void)
{
- hid_t file=-1, dset1=-1, dset2=-1;
- hid_t dcpl1=-1, dcpl2=-1, fspace=-1, mspace=-1;
- int rd_fill=0, fill_val=4444, val_rd=0;
- hsize_t dims[2], one[2]={1,1};
- hsize_t hs_offset[2]={3,4};
- H5D_fill_value_t status;
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
- char testfile[512]=""; /* test file name */
+ hid_t file=-1, dset1=-1, dset2=-1;
+ hid_t dcpl1=-1, dcpl2=-1, fspace=-1, mspace=-1;
+ int rd_fill=0, fill_val=4444, val_rd=0;
+ hsize_t dims[2], one[2]={1,1};
+ hsize_t hs_offset[2]={3,4};
+ H5D_fill_value_t status;
+ char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ char testfile[512]=""; /* test file name */
- TESTING("contiguous dataset compatibility with v. 1.4");
+ TESTING("contiguous dataset compatibility with v. 1.4");
/* Generate correct name for test file by prepending the source path */
if(srcdir && ((strlen(srcdir) + strlen(FILE_COMPATIBLE) + 1) <
@@ -1987,9 +1987,9 @@ test_compatible(hid_t fapl)
}
HDstrcat(testfile, FILE_COMPATIBLE);
- if((file = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0) {
+ if((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
printf(" Could not open file %s. Try set $srcdir to point at the "
- "source directory of test\n", testfile);
+ "source directory of test\n", testfile);
goto error;
}
@@ -2000,7 +2000,7 @@ test_compatible(hid_t fapl)
H5_FAILED();
printf(" %d: Got a different fill value than what was set.",__LINE__);
printf(" Got status=%ld, suppose to be H5D_FILL_VALUE_UNDEFINED\n",
- (long)status);
+ (long)status);
goto error;
}
if((fspace = H5Dget_space(dset1)) < 0) goto error;
@@ -2072,8 +2072,10 @@ test_compatible(hid_t fapl)
if(H5Dclose(dset2) < 0) goto error;
if(H5Fclose(file) < 0) goto error;
+
PASSED();
- return 0;
+
+ return 0;
error:
H5E_BEGIN_TRY {
@@ -2109,93 +2111,84 @@ error:
int
main(int argc, char *argv[])
{
- const char *envval = NULL;
-
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- int nerrors=0, argno, test_contig=1, test_chunk=1, test_compact=1;
- hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */
- hbool_t new_format; /* Whether to use the new format or not */
-
- if(argc >= 2) {
- test_contig = test_chunk = test_compact = 0;
- for(argno = 1; argno < argc; argno++) {
- if(!strcmp(argv[argno], "contiguous"))
- test_contig = 1;
- else if(!strcmp(argv[argno], "chunked"))
- test_chunk = 1;
- else if(!strcmp(argv[argno], "compact"))
- test_compact =1;
- else {
- fprintf(stderr, "usage: %s [contiguous] [chunked] [compact]\n", argv[0]);
- exit(1);
- }
- } /* end for */
- } /* end if */
+ int nerrors=0, argno, test_contig=1, test_chunk=1, test_compact=1;
+ hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */
+ hbool_t new_format; /* Whether to use the new format or not */
+
+ if(argc >= 2) {
+ test_contig = test_chunk = test_compact = 0;
+ for(argno = 1; argno < argc; argno++) {
+ if(!strcmp(argv[argno], "contiguous"))
+ test_contig = 1;
+ else if(!strcmp(argv[argno], "chunked"))
+ test_chunk = 1;
+ else if(!strcmp(argv[argno], "compact"))
+ test_compact =1;
+ else {
+ fprintf(stderr, "usage: %s [contiguous] [chunked] [compact]\n", argv[0]);
+ exit(1);
+ }
+ } /* end for */
+ } /* end if */
- h5_reset();
- fapl = h5_fileaccess();
+ h5_reset();
+ fapl = h5_fileaccess();
- /* Property list tests */
- nerrors += test_getset();
- nerrors += test_getset_vl(fapl);
+ /* Property list tests */
+ nerrors += test_getset();
+ nerrors += test_getset_vl(fapl);
- /* Copy the file access property list */
- if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
+ /* Loop over using new group format */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
- /* Set the FAPL for the type of format */
- if(new_format) {
- puts("\nTesting with new file format:");
- my_fapl = fapl2;
- } /* end if */
- else {
- puts("Testing with old file format:");
- my_fapl = fapl;
- } /* end else */
-
- /* Chunked storage layout tests */
- if(test_chunk) {
- nerrors += test_create(my_fapl, FILENAME[0], H5D_CHUNKED);
- nerrors += test_rdwr (my_fapl, FILENAME[2], H5D_CHUNKED);
- nerrors += test_extend(my_fapl, FILENAME[4], H5D_CHUNKED);
- } /* end if */
-
- /* Contiguous storage layout tests */
- if(test_contig) {
- nerrors += test_create(my_fapl, FILENAME[1], H5D_CONTIGUOUS);
- nerrors += test_rdwr (my_fapl, FILENAME[3], H5D_CONTIGUOUS);
- nerrors += test_extend(my_fapl, FILENAME[5], H5D_CONTIGUOUS);
- nerrors += test_compatible(my_fapl);
- } /* end if */
-
- /* Compact dataset storage tests */
- if(test_compact) {
- nerrors += test_create(my_fapl, FILENAME[6], H5D_COMPACT);
- nerrors += test_rdwr (my_fapl, FILENAME[7], H5D_COMPACT);
- } /* end if */
- } /* end for */
+ /* Set the FAPL for the type of format */
+ if(new_format) {
+ puts("\nTesting with new file format:");
+ my_fapl = fapl2;
+ } /* end if */
+ else {
+ puts("Testing with old file format:");
+ my_fapl = fapl;
+ } /* end else */
+
+ /* Chunked storage layout tests */
+ if(test_chunk) {
+ nerrors += test_create(my_fapl, FILENAME[0], H5D_CHUNKED);
+ nerrors += test_rdwr (my_fapl, FILENAME[2], H5D_CHUNKED);
+ nerrors += test_extend(my_fapl, FILENAME[4], H5D_CHUNKED);
+ } /* end if */
- /* Close 2nd FAPL */
- H5Pclose(fapl2);
+ /* Contiguous storage layout tests */
+ if(test_contig) {
+ nerrors += test_create(my_fapl, FILENAME[1], H5D_CONTIGUOUS);
+ nerrors += test_rdwr (my_fapl, FILENAME[3], H5D_CONTIGUOUS);
+ nerrors += test_extend(my_fapl, FILENAME[5], H5D_CONTIGUOUS);
+ nerrors += test_compatible();
+ } /* end if */
- if(nerrors)
- goto error;
- puts("All fill value tests passed.");
+ /* Compact dataset storage tests */
+ if(test_compact) {
+ nerrors += test_create(my_fapl, FILENAME[6], H5D_COMPACT);
+ nerrors += test_rdwr (my_fapl, FILENAME[7], H5D_COMPACT);
+ } /* end if */
+ } /* end for */
- if(h5_cleanup(FILENAME, fapl))
- remove(FILE_NAME_RAW);
- } /* end if */
- else
- puts("All fill value tests skipped - Incompatible with current Virtual File Driver");
+ /* Close 2nd FAPL */
+ H5Pclose(fapl2);
+
+ if(nerrors)
+ goto error;
+ puts("All fill value tests passed.");
+
+ if(h5_cleanup(FILENAME, fapl))
+ HDremove(FILE_NAME_RAW);
return 0;
diff --git a/test/flush1.c b/test/flush1.c
index 97ddf76..f15a05a 100644
--- a/test/flush1.c
+++ b/test/flush1.c
@@ -52,7 +52,7 @@ static double the_data[100][100];
*/
static hid_t
create_file(char* name, hid_t fapl)
-{
+{
hid_t file, dcpl, space, dset, groups, grp;
hsize_t ds_size[2] = {100, 100};
hsize_t ch_size[2] = {5, 5};
@@ -110,7 +110,7 @@ error:
*/
static hid_t
extend_file(hid_t file)
-{
+{
hid_t dcpl, space, dset;
hsize_t ds_size[2] = {100, 100};
hsize_t ch_size[2] = {5, 5};
@@ -162,7 +162,7 @@ error:
* Sept. 26, 2006, expand test to check for failure if H5Fflush is not called.
* Oct. 4 2006, expand test to check for partial failure in case file is flushed, but then
* new datasets are created after the flush.
- *
+ *
*
*-------------------------------------------------------------------------
*/
@@ -171,49 +171,38 @@ main(void)
{
hid_t file, fapl;
char name[1024];
- const char *envval = NULL;
h5_reset();
fapl = h5_fileaccess();
TESTING("H5Fflush (part1)");
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "split")) {
- /* Create the file */
- h5_fixname(FILENAME[0], fapl, name, sizeof name);
- file = create_file(name, fapl);
- /* Flush and exit without closing the library */
- if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) goto error;
-
- /* Create the file */
- h5_fixname(FILENAME[2], fapl, name, sizeof name);
- file = create_file(name, fapl);
- /* Flush and exit without closing the library */
- if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) goto error;
- /* Add a bit to the file and don't flush the new part */
- extend_file(file);
-
- /* Create the other file which will not be flushed */
- h5_fixname(FILENAME[1], fapl, name, sizeof name);
- file = create_file(name, fapl);
-
-
- PASSED();
- fflush(stdout);
- fflush(stderr);
- }
- else
- {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- }
- HD_exit(0);
+ /* Create the file */
+ h5_fixname(FILENAME[0], fapl, name, sizeof name);
+ file = create_file(name, fapl);
+ /* Flush and exit without closing the library */
+ if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) goto error;
- error:
- HD_exit(1);
- return 1;
+ /* Create the file */
+ h5_fixname(FILENAME[2], fapl, name, sizeof name);
+ file = create_file(name, fapl);
+ /* Flush and exit without closing the library */
+ if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) goto error;
+ /* Add a bit to the file and don't flush the new part */
+ extend_file(file);
+ /* Create the other file which will not be flushed */
+ h5_fixname(FILENAME[1], fapl, name, sizeof name);
+ file = create_file(name, fapl);
+
+
+ PASSED();
+ fflush(stdout);
+ fflush(stderr);
+
+ HD_exit(0);
+
+error:
+ HD_exit(1);
+ return 1;
}
diff --git a/test/flush2.c b/test/flush2.c
index 5ec5300..5675856 100644
--- a/test/flush2.c
+++ b/test/flush2.c
@@ -50,7 +50,7 @@ static double the_data[100][100];
*/
static int
check_dset(hid_t file, const char* name)
-{
+{
hid_t space, dset;
hsize_t ds_size[2] = {100, 100};
double error;
@@ -122,7 +122,7 @@ check_file(char* filename, hid_t fapl, int flag)
if(H5Gclose(grp) < 0) goto error;
} /* end for */
- /* Check to see if that last added dataset in the third file is accessible
+ /* Check to see if that last added dataset in the third file is accessible
* (it shouldn't be...but it might. Flag an error in case it is for now */
if(flag && check_dset(file, "dset2")) goto error;
@@ -159,90 +159,74 @@ main(void)
{
hid_t fapl;
H5E_auto2_t func;
-
char name[1024];
- const char *envval = NULL;
h5_reset();
fapl = h5_fileaccess();
TESTING("H5Fflush (part2 with flush)");
- /* Don't run this test using the core or split file drivers */
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split")) {
- /* Check the case where the file was flushed */
- h5_fixname(FILENAME[0], fapl, name, sizeof name);
- if(check_file(name, fapl, FALSE)) {
- H5_FAILED()
- goto error;
- }
- else
- PASSED();
-
-
- /* Check the case where the file was not flushed. This should give an error
- * so we turn off the error stack temporarily */
- TESTING("H5Fflush (part2 without flush)");
- H5Eget_auto2(H5E_DEFAULT,&func,NULL);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
- h5_fixname(FILENAME[1], fapl, name, sizeof name);
- if(check_file(name, fapl, FALSE))
- PASSED()
- else
- {
-#if defined _WIN32 && defined _HDF5USEDLL_
- SKIPPED();
- puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
-#elif defined H5_VMS
- SKIPPED();
-#else
+ /* Check the case where the file was flushed */
+ h5_fixname(FILENAME[0], fapl, name, sizeof name);
+ if(check_file(name, fapl, FALSE)) {
H5_FAILED()
goto error;
-#endif
- }
- H5Eset_auto2(H5E_DEFAULT, func, NULL);
-
- /* Check the case where the file was flushed, but more data was added afterward. This should give an error
- * so we turn off the error stack temporarily */
- TESTING("H5Fflush (part2 with flush and later addition)");
- H5Eget_auto2(H5E_DEFAULT,&func,NULL);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
- h5_fixname(FILENAME[2], fapl, name, sizeof name);
- if(check_file(name, fapl, TRUE))
- PASSED()
- else
- {
+ }
+ else
+ PASSED();
+
+
+ /* Check the case where the file was not flushed. This should give an error
+ * so we turn off the error stack temporarily */
+ TESTING("H5Fflush (part2 without flush)");
+ H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ h5_fixname(FILENAME[1], fapl, name, sizeof name);
+ if(check_file(name, fapl, FALSE))
+ PASSED()
+ else
+ {
#if defined _WIN32 && defined _HDF5USEDLL_
- SKIPPED();
- puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
+ SKIPPED();
+ puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
#elif defined H5_VMS
- SKIPPED();
+ SKIPPED();
#else
- H5_FAILED()
- goto error;
+ H5_FAILED()
+ goto error;
#endif
+ }
+ H5Eset_auto2(H5E_DEFAULT, func, NULL);
- }
- H5Eset_auto2(H5E_DEFAULT, func, NULL);
+ /* Check the case where the file was flushed, but more data was added afterward. This should give an error
+ * so we turn off the error stack temporarily */
+ TESTING("H5Fflush (part2 with flush and later addition)");
+ H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
- h5_cleanup(FILENAME, fapl);
- }
+ h5_fixname(FILENAME[2], fapl, name, sizeof name);
+ if(check_file(name, fapl, TRUE))
+ PASSED()
else
{
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- }
- return 0;
+#if defined _WIN32 && defined _HDF5USEDLL_
+ SKIPPED();
+ puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
+#elif defined H5_VMS
+ SKIPPED();
+#else
+ H5_FAILED()
+ goto error;
+#endif
- error:
- return 1;
-}
+ }
+ H5Eset_auto2(H5E_DEFAULT, func, NULL);
+ h5_cleanup(FILENAME, fapl);
+ return 0;
+error:
+ return 1;
+}
diff --git a/test/freespace.c b/test/freespace.c
new file mode 100644
index 0000000..0f6514c
--- /dev/null
+++ b/test/freespace.c
@@ -0,0 +1,2812 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*
+ * Tests for free-space manager
+ */
+#include "h5test.h"
+
+#define H5FS_PACKAGE
+#define H5FS_TESTING
+#include "H5FSpkg.h" /* Free space manager */
+
+
+/* Other private headers that this test requires */
+#define H5F_PACKAGE
+#include "H5Fpkg.h"
+#include "H5Iprivate.h"
+#include "H5Vprivate.h"
+
+#define FILENAME_LEN 1024
+
+#define TEST_FSPACE_SECT_TYPE 0
+#define TEST_FSPACE_SECT_TYPE_NEW 1
+#define TEST_FSPACE_SECT_TYPE_NONE 2
+
+#define TEST_FSPACE_SHRINK 80
+#define TEST_FSPACE_EXPAND 120
+#define TEST_MAX_SECT_SIZE (64 * 1024)
+#define TEST_MAX_INDEX 32
+
+#define TEST_SECT_ADDR60 60
+#define TEST_SECT_ADDR70 70
+#define TEST_SECT_ADDR80 80
+#define TEST_SECT_ADDR100 100
+#define TEST_SECT_ADDR150 150
+#define TEST_SECT_ADDR200 200
+#define TEST_SECT_ADDR300 300
+
+#define TEST_SECT_SIZE5 5
+#define TEST_SECT_SIZE10 10
+#define TEST_SECT_SIZE15 15
+#define TEST_SECT_SIZE20 20
+#define TEST_SECT_SIZE30 30
+#define TEST_SECT_SIZE40 40
+#define TEST_SECT_SIZE50 50
+#define TEST_SECT_SIZE80 80
+
+#define FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */
+#define FSPACE_ALIGN_DEF 1 /* Default: no alignment */
+
+const char *FILENAME[] = {
+ "frspace",
+ NULL
+};
+
+typedef struct frspace_state_t {
+ hsize_t tot_space; /* Total amount of space tracked */
+ hsize_t tot_sect_count; /* Total # of sections tracked */
+ hsize_t serial_sect_count; /* # of serializable sections tracked */
+ hsize_t ghost_sect_count; /* # of un-serializable sections tracked */
+} frspace_state_t;
+
+haddr_t g_eoa=0;
+static haddr_t TEST_get_eoa(void);
+static void TEST_set_eoa(haddr_t);
+
+/*
+ * TEST client
+ */
+typedef struct TEST_free_section_t {
+ H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */
+} TEST_free_section_t;
+
+
+static herr_t TEST_sect_init_cls(H5FS_section_class_t *, void *);
+static herr_t TEST_sect_free(H5FS_section_info_t *_sect);
+static herr_t TEST_sect_can_merge(const H5FS_section_info_t *, const H5FS_section_info_t *, void UNUSED *);
+static herr_t TEST_sect_merging(H5FS_section_info_t *, H5FS_section_info_t *, void UNUSED *);
+static herr_t TEST_sect_can_shrink(const H5FS_section_info_t *, void *);
+static herr_t TEST_sect_shrinking(H5FS_section_info_t **, void *);
+
+static unsigned test_fs_create(hid_t fapl);
+static unsigned test_fs_sect_add(hid_t fapl);
+static unsigned test_fs_sect_merge(hid_t fapl);
+static unsigned test_fs_sect_shrink(hid_t fapl);
+static unsigned test_fs_sect_find(hid_t fapl);
+static unsigned test_fs_sect_change_class(hid_t fapl);
+static unsigned test_fs_sect_extend(hid_t fapl);
+static unsigned test_fs_sect_iterate(hid_t fapl);
+
+
+H5FS_section_class_t TEST_FSPACE_SECT_CLS[1] = {{
+ TEST_FSPACE_SECT_TYPE, /* Section type */
+ 0, /* Extra serialized size */
+ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */
+ NULL, /* Class private info */
+
+ /* Class methods */
+ TEST_sect_init_cls, /* Initialize section class */
+ NULL, /* Terminate section class */
+
+ /* Object methods */
+ NULL, /* Add section */
+ NULL, /* Serialize section */
+ NULL, /* Deserialize section */
+ TEST_sect_can_merge, /* Can sections merge? */
+ TEST_sect_merging, /* Merge sections */
+ TEST_sect_can_shrink, /* Can section shrink container?*/
+ TEST_sect_shrinking, /* Shrink container w/section */
+ TEST_sect_free, /* Free section */
+ NULL, /* Check validity of section */
+ NULL, /* Split section node for alignment */
+ NULL, /* Dump debugging for section */
+}};
+
+H5FS_section_class_t TEST_FSPACE_SECT_CLS_NEW[1] = {{
+ TEST_FSPACE_SECT_TYPE_NEW, /* Section type */
+ 0, /* Extra serialized size */
+ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */
+ NULL, /* Class private info */
+
+ /* Class methods */
+ TEST_sect_init_cls, /* Initialize section class */
+ NULL, /* Terminate section class */
+
+ /* Object methods */
+ NULL, /* Add section */
+ NULL, /* Serialize section */
+ NULL, /* Deserialize section */
+ TEST_sect_can_merge, /* Can sections merge? */
+ TEST_sect_merging, /* Merge sections */
+ NULL, /* Can section shrink container?*/
+ NULL, /* Shrink container w/section */
+ TEST_sect_free, /* Free section */
+ NULL, /* Check validity of section */
+ NULL, /* Split section node for alignment */
+ NULL, /* Dump debugging for section */
+}};
+
+H5FS_section_class_t TEST_FSPACE_SECT_CLS_NOINIT[1] = {{
+ TEST_FSPACE_SECT_TYPE_NONE, /* Section type */
+ 0, /* Extra serialized size */
+ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */
+ NULL, /* Class private info */
+
+ /* Class methods */
+ NULL, /* Initialize section class */
+ NULL, /* Terminate section class */
+
+ /* Object methods */
+ NULL, /* Add section */
+ NULL, /* Serialize section */
+ NULL, /* Deserialize section */
+ TEST_sect_can_merge, /* Can sections merge? */
+ TEST_sect_merging, /* Merge sections */
+ NULL, /* Can section shrink container?*/
+ NULL, /* Shrink container w/section */
+ TEST_sect_free, /* Free section */
+ NULL, /* Check validity of section */
+ NULL, /* Split section node for alignment */
+ NULL, /* Dump debugging for section */
+}};
+
+const H5FS_section_class_t *test_classes[] = {
+ TEST_FSPACE_SECT_CLS,
+ TEST_FSPACE_SECT_CLS_NEW,
+ TEST_FSPACE_SECT_CLS_NOINIT
+};
+
+
+static void init_cparam(H5FS_create_t *);
+static void init_sect_node(TEST_free_section_t *, haddr_t, hsize_t, unsigned, H5FS_section_state_t);
+static int check_stats(const H5F_t *, const H5FS_t *, frspace_state_t *);
+
+#define NUM_SECTIONS 1000
+
+/* User data for free space section iterator callback */
+typedef struct {
+ hsize_t tot_size;
+ hsize_t tot_sect_count;
+} TEST_iter_ud_t;
+
+static herr_t TEST_sects_cb(const H5FS_section_info_t *_sect, void *_udata);
+
+
+/*
+ * Tests
+ */
+
+/*
+ * free-space section routines for client TEST
+ */
+static herr_t
+TEST_sect_init_cls(H5FS_section_class_t *cls, void *_udata)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+ unsigned *init_flags;
+
+ /* Check arguments. */
+ HDassert(cls);
+ HDassert(_udata);
+
+ init_flags = (unsigned *)_udata;
+ cls->flags |= *init_flags;
+
+ return(ret_value);
+} /* TEST_sect_init_cls() */
+
+/*
+ * Check if the two sections can be merged:
+ * true if second section adjoins the first section
+ */
+static herr_t
+TEST_sect_can_merge(const H5FS_section_info_t *_sect1,
+ const H5FS_section_info_t *_sect2, void UNUSED *_udata)
+{
+ const TEST_free_section_t *sect1 = (const TEST_free_section_t *)_sect1;
+ const TEST_free_section_t *sect2 = (const TEST_free_section_t *)_sect2;
+ htri_t ret_value; /* Return value */
+
+ /* Check arguments. */
+ HDassert(sect1);
+ HDassert(sect2);
+ HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */
+ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr));
+
+ /* Check if second section adjoins first section */
+ ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr);
+
+ return(ret_value);
+} /* TEST_sect_can_merge() */
+
+/*
+ * Merge the two sections (second section is merged into the first section)
+ */
+static herr_t
+TEST_sect_merging(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2,
+ void UNUSED *_udata)
+{
+ TEST_free_section_t *sect1 = (TEST_free_section_t *)_sect1;
+ TEST_free_section_t *sect2 = (TEST_free_section_t *)_sect2;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /* Check arguments. */
+ HDassert(sect1);
+ HDassert((sect1->sect_info.type == TEST_FSPACE_SECT_TYPE) ||
+ (sect1->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) ||
+ (sect1->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE));
+ HDassert(sect2);
+ HDassert((sect2->sect_info.type == TEST_FSPACE_SECT_TYPE) ||
+ (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) ||
+ (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE));
+ HDassert(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr));
+
+ /* Add second section's size to first section */
+ sect1->sect_info.size += sect2->sect_info.size;
+
+ /* Get rid of second section */
+ if(TEST_sect_free((H5FS_section_info_t *)sect2) < 0)
+ TEST_ERROR
+error:
+ return(ret_value);
+} /* TEST_sect_merging() */
+
+/*
+ * Free the section
+ */
+static herr_t
+TEST_sect_free(H5FS_section_info_t *sect)
+{
+ /* Release the section */
+ HDfree(sect);
+
+ return(0);
+} /* TEST_sect_free() */
+
+/*
+ * Determine if the section can be shrunk and set _udata accordingly
+ * if _udata passed in is NULL, return FALSE
+ * Otherwise:
+ * if section's address+size is the end of file, return TRUE
+ * otherwise return FALSE
+ */
+static herr_t
+TEST_sect_can_shrink(const H5FS_section_info_t *_sect, void *_udata)
+{
+ unsigned *can_shrink = (unsigned *)_udata;
+ const TEST_free_section_t *sect = (const TEST_free_section_t *)_sect;
+ haddr_t end, eoa;
+
+ if (can_shrink == NULL)
+ return(FALSE);
+
+ end = sect->sect_info.addr + sect->sect_info.size;
+ eoa = TEST_get_eoa();
+
+ if (end == eoa)
+ *can_shrink = TRUE;
+ else
+ *can_shrink = FALSE;
+
+ return((htri_t)*can_shrink);
+} /* TEST_sect_can_shrink() */
+
+/*
+ * Shrink the section
+ */
+static herr_t
+TEST_sect_shrinking(H5FS_section_info_t **_sect, void *_udata)
+{
+ TEST_free_section_t **sect = (TEST_free_section_t **)_sect;
+ unsigned *can_shrink = (unsigned *)_udata;
+
+ /* address of the section is faked, so, doesn't need to do anything */
+ /* just free the section node */
+ if (*can_shrink) {
+ if (TEST_sect_free((H5FS_section_info_t *)*sect) < 0)
+ TEST_ERROR
+ *sect = NULL;
+ return(TRUE);
+ }
+
+error:
+ return(FALSE);
+}
+
+
+/*
+ * iteration callback
+ */
+static herr_t
+TEST_sects_cb(const H5FS_section_info_t *_sect, void *_udata)
+{
+ const TEST_free_section_t *sect = (const TEST_free_section_t *)_sect;
+ TEST_iter_ud_t *udata = (TEST_iter_ud_t *)_udata;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ HDassert(sect);
+ HDassert(udata);
+
+ udata->tot_size += sect->sect_info.size;
+ udata->tot_sect_count += 1;
+
+ return(ret_value);
+}
+
+/* supporting routine for shrinking */
+static haddr_t
+TEST_get_eoa(void)
+{
+ return(g_eoa);
+}
+
+/* supporting routine for shrinking */
+static void
+TEST_set_eoa(haddr_t val)
+{
+ g_eoa = val;
+}
+
+/*
+ * Initialize creation parameter structure for TEST client
+ */
+static void
+init_cparam(H5FS_create_t *cparam)
+{
+ HDmemset(cparam, 0, sizeof(H5FS_create_t));
+
+ /* Set the free space creation parameters */
+ cparam->shrink_percent = TEST_FSPACE_SHRINK;
+ cparam->expand_percent = TEST_FSPACE_EXPAND;
+ cparam->max_sect_size = TEST_MAX_SECT_SIZE;
+ cparam->max_sect_addr = TEST_MAX_INDEX;
+
+} /* init_cparam() */
+
+/*
+ * Initialize free space section node
+ */
+static void
+init_sect_node(TEST_free_section_t *sect_node, haddr_t addr, hsize_t size, unsigned type, H5FS_section_state_t state)
+{
+ sect_node->sect_info.addr = addr;
+ sect_node->sect_info.size = size;
+ sect_node->sect_info.type = type;
+ sect_node->sect_info.state = state;
+} /* init_sect_node() */
+
+/*
+ * Verify statistics for the free-space manager
+ */
+static int
+check_stats(const H5F_t *f, const H5FS_t *frsp, frspace_state_t *state)
+{
+ H5FS_stat_t frspace_stats; /* Statistics about the heap */
+
+ /* Get statistics for heap and verify they are correct */
+ if(H5FS_stat_info(f, frsp, &frspace_stats) < 0)
+ FAIL_STACK_ERROR
+
+ if(frspace_stats.tot_space != state->tot_space) {
+ HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n",
+ frspace_stats.tot_space, state->tot_space);
+ TEST_ERROR
+ } /* end if */
+ if(frspace_stats.tot_sect_count != state->tot_sect_count) {
+ HDfprintf(stdout, "frspace_stats.tot_sect_count = %Hu, state->tot_sect_count = %Hu\n",
+ frspace_stats.tot_sect_count, state->tot_sect_count);
+ TEST_ERROR
+ } /* end if */
+ if(frspace_stats.serial_sect_count != state->serial_sect_count) {
+ HDfprintf(stdout, "frspace_stats.serial_sect_count = %Hu, state->serial_sect_count = %Hu\n",
+ frspace_stats.serial_sect_count, state->serial_sect_count);
+ TEST_ERROR
+ } /* end if */
+ if(frspace_stats.ghost_sect_count != state->ghost_sect_count) {
+ HDfprintf(stdout, "frspace_stats.ghost_sect_count = %Hu, state->ghost_sect_count = %Hu\n",
+ frspace_stats.ghost_sect_count, state->ghost_sect_count);
+ TEST_ERROR
+ } /* end if */
+
+ /* All tests passed */
+ return(0);
+
+error:
+ return(1);
+} /* check_stats() */
+
+/*
+ * TESTS for free-space manager
+ */
+
+/*
+ * To verify the creation, close, reopen and deletion of the free-space manager
+ */
+static unsigned
+test_fs_create(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr; /* address of free space */
+ h5_stat_size_t file_size, empty_size; /* File size */
+ frspace_state_t state; /* State of free space*/
+ H5FS_create_t cparam, test_cparam; /* creation parameters */
+ size_t nclasses;
+ unsigned init_flags=0;
+
+ TESTING("the creation/close/reopen/deletion of the free-space manager");
+
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* initialize creation parameters for free-space manager */
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+ if (frsp->nclasses != nclasses)
+ TEST_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ HDmemset(&test_cparam, 0, sizeof(H5FS_create_t));
+ if(H5FS_get_cparam_test(frsp, &test_cparam) < 0)
+ FAIL_STACK_ERROR
+ if (H5FS_cmp_cparam_test(&cparam, &test_cparam))
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* reopen the free-space manager */
+ if(NULL == (frsp = H5FS_open(f, H5P_DATASET_XFER_DEFAULT, fs_addr,
+ nclasses, test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+ if (frsp->nclasses != nclasses)
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_fs_create() */
+
+
+/*
+ * Test 1:
+ * Create free-space manager
+ * Add section A via H5FS_sect_add() with H5FS_ADD_RETURNED_SPACE
+ * Close the free-space manager
+ * Result: section A is serialized to the file
+ *
+ * Test 2:
+ * Create free-space manager with H5FS_CLS_GHOST_OBJ section class setting
+ * Add section A via H5FS_sect_add() with H5FS_ADD_RETURNED_SPACE
+ * Close the free-space manager
+ * Result: section A is not serialized to the file
+ *
+ * Test 3:
+ * Add section A via H5FS_sect_add() to allow shrinking with H5FS_ADD_RETURNED_SPACE
+ * Set EOF to be the ending address of section A
+ * Result: H5FS_sect_add() will shrink section A
+ *
+ * Test 4:
+ * Add section A via H5FS_sect_add() to allow shrinking with H5FS_ADD_DESERIALIZING
+ * Set EOF to be the ending address of section A
+ * Result: H5FS_sect_add() will not shrink section A
+ *
+ */
+static unsigned
+test_fs_sect_add(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+ frspace_state_t state; /* State of free space*/
+
+ TEST_free_section_t *sect_node;
+ unsigned init_flags=0;
+ h5_stat_size_t file_size=0, tmp_file_size=0, fr_meta_size=0;
+ unsigned can_shrink=FALSE;
+
+ TESTING("adding a section via H5FS_sect_add() to free-space: test 1");
+
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ fr_meta_size = H5FS_HEADER_SIZE(f) + H5FS_SINFO_PREFIX_SIZE(f);
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((tmp_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ if (tmp_file_size <= (file_size+fr_meta_size))
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("adding a section via H5FS_sect_add() to free-space with H5FS_CLS_GHOST_OBJ: test 2");
+
+ /* Get the size of a file w/empty heap*/
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = H5FS_CLS_GHOST_OBJ;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /* Create free list section node */
+ if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node,
+ 0, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node->sect_info.size;
+ state.tot_sect_count += 1;
+ state.ghost_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ fr_meta_size = H5FS_HEADER_SIZE(f);
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((tmp_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ if (tmp_file_size != (file_size+fr_meta_size))
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("adding a section via H5FS_sect_add() to free-space: test 3");
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = 0;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ /*
+ * Add section A
+ */
+ init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ /* nothing in free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ TESTING("adding a section via H5FS_sect_add() to free-space: test 4");
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file w/empty heap*/
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = 0;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ /*
+ * Add section A
+ */
+ init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node,
+ H5FS_ADD_DESERIALIZING, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_fs_sect_add() */
+
+
+/*
+ * To verify the finding of a section with the requested-size from free-space
+ *
+ * Test 1: Free-space is empty and is not able to fulfill the requested-size
+ * Set up: free-space is started up but is empty
+ *
+ * Test 2: Add a section and find the section whose size is equal to the requested-size
+ * Set up: Add section A whose size is less than requested-size
+ * Add section B whose size is the same as requested-size with addr=b
+ * Add section C whose size is the same as requested-size with addr=c > b
+ * Add section D whose size is greater than requested-size
+ *
+ * Test 3: Add a section and find the section whose size is > requested-size
+ * Set up: Add section A whose size is less than requested-size
+ * Add section B whose size is greater than requested-size
+ *
+ * Test 4: Add a section but the section is not able to fulfill the requested-size
+ * Set up: Add section A whose size is less than requested-size
+ *
+ */
+static unsigned
+test_fs_sect_find(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+ frspace_state_t state; /* State of free space*/
+
+ TEST_free_section_t *sect_node1, *sect_node2, *sect_node3, *sect_node4;
+ TEST_free_section_t *node;
+ htri_t node_found = FALSE;
+ unsigned init_flags=0;
+
+ TESTING("H5FS_sect_find(): free-space is empty");
+
+ /* 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)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE30, (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ PASSED()
+
+ TESTING("H5FS_sect_find() a section equal to requested-size from free-space");
+
+ /* reopen the free-space manager */
+ if(NULL == (frsp = H5FS_open(f, H5P_DATASET_XFER_DEFAULT, fs_addr, nclasses,
+ test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+ if (frsp->nclasses != nclasses)
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+
+ /*
+ * Add section C
+ */
+ if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node3, (haddr_t)(TEST_SECT_ADDR200), (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node3,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node3->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node2->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section D
+ */
+ if(NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR300, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node4,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node4->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+
+ if ((node->sect_info.addr != TEST_SECT_ADDR100) || (node->sect_info.size != TEST_SECT_SIZE50))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* remove sections A, C and D */
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0)
+ FAIL_STACK_ERROR
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node3) < 0)
+ FAIL_STACK_ERROR
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node4) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ PASSED()
+
+ TESTING("H5FS_sect_find() a section greater than requested-size from free-space");
+
+ /* reopen the free-space manager */
+ if(NULL == (frsp = H5FS_open(f, H5P_DATASET_XFER_DEFAULT, fs_addr, nclasses,
+ test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+ if (frsp->nclasses != nclasses)
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR200, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node2->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+ if ((node->sect_info.addr != TEST_SECT_ADDR200) || (node->sect_info.size < TEST_SECT_SIZE50))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* remove sections A */
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ PASSED()
+
+ TESTING("H5FS_sect_find(): cannot find a section with requested-size from free-space");
+
+ /* reopen the free-space manager */
+ if(NULL == (frsp = H5FS_open(f, H5P_DATASET_XFER_DEFAULT, fs_addr, nclasses,
+ test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+ if (frsp->nclasses != nclasses)
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ /* remove sections A */
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_fs_sect_find() */
+
+
+/*
+ * To verify that sections are merged when adding sections to free-space
+ *
+ * Test 1:
+ * Set up:
+ * H5FS_CLS_SEPAR_OBJ (cls->flags) is not set
+ * H5FS_ADD_RETURNED_SPACE is passed to H5FS_sect_add()
+ *
+ * Add sections C, B, A & D that can be merged together
+ *
+ * Test 2:
+ * Set up:
+ * H5FS_CLS_SEPAR_OBJ (cls->flags) is set
+ * H5FS_ADD_RETURNED_SPACE is passed to H5FS_sect_add()
+ *
+ * Add sections A & B that can be merged together but cannot do so because H5FS_CLS_SEPAR_OBJ flag is set
+ *
+ * Test 3:
+ * Set up:
+ * H5FS_CLS_SEPAR_OBJ (cls->flags) is not set
+ * H5FS_ADD_RETURNED_SPACE is passed to H5FS_sect_add()
+ *
+ * Add 4 sections that adjoin each other as follows:
+ * section A is of section class type A
+ * section B is of section class type B
+ * section C is of section class type B
+ * section D is of section class type A
+ * Sections B & C are merged together but not section A nor D because:
+ * sections B & C are merged because of the same section class type
+ * section A cannot be merged with the merged section of B & C because of different section class type
+ * section D cannot be merged with the merged section of B & C because of different section class type
+ */
+static unsigned
+test_fs_sect_merge(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+ frspace_state_t state; /* State of free space*/
+
+ TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL, *sect_node3=NULL, *sect_node4=NULL;
+ unsigned init_flags=0;
+ htri_t node_found = FALSE;
+ TEST_free_section_t *node;
+
+ TESTING("the merge of sections when H5FS_sect_add() to free-space: test 1");
+
+ /*
+ * TEST 1
+ */
+ /* 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)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section C
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_SECT_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* section B & C are merged */
+ state.tot_space += TEST_SECT_SIZE30;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE10, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node3,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* section A is merged with the merged section of B & C */
+ state.tot_space += TEST_SECT_SIZE10;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section D
+ */
+ if(NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR150, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node4,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* section D is merged with the merged section of A & B & C */
+ state.tot_space += TEST_SECT_SIZE80;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+
+ /* should be able to find the merged section of A, B, C & D */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE10+TEST_SECT_SIZE30+TEST_SECT_SIZE50+TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+ if ((node->sect_info.addr != TEST_SECT_ADDR60) ||
+ (node->sect_info.size != (TEST_SECT_SIZE10+TEST_SECT_SIZE30+TEST_SECT_SIZE50+TEST_SECT_SIZE80)))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ /*
+ * TEST 2
+ */
+ TESTING("the merge of sections when H5FS_sect_add() to free-space: test 2");
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = H5FS_CLS_SEPAR_OBJ;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_SECT_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* section A & B are not merged because H5FS_CLS_SEPAR_OBJ is set */
+ state.tot_space += TEST_SECT_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* should not be able to find the merged section of A & B */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE30+TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ /* remove section A from free-space */
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0)
+ FAIL_STACK_ERROR
+ /* remove section B from free-space */
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ /*
+ * TEST 3
+ */
+ TESTING("the merge of sections when H5FS_sect_add() to free-space: test 3");
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = 0; /* reset */
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE10, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_SECT_SIZE10;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* sections A & B are not merged because H5FS_CLS_MERGE_SYM is set & section class type is different */
+ state.tot_space += TEST_SECT_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section C
+ */
+ if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node3,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* sections B & C are merged because H5FS_CLS_MERGE_SYM is set & section class type is the same */
+ state.tot_space += TEST_SECT_SIZE50;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section D
+ */
+ if(NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR150, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node4,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * section D is not merged with the merged section of B & C because
+ * H5FS_CLS_MERGE_SYM is set and section class type is different
+ */
+ state.tot_space += TEST_SECT_SIZE80;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* should not be able to find a merged section of A, B, C & D */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE10+TEST_SECT_SIZE30+TEST_SECT_SIZE50+TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ /* should be able to find the merged section of B & C */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE30+TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+
+ if ((node->sect_info.addr != TEST_SECT_ADDR70) ||
+ (node->sect_info.size != (TEST_SECT_SIZE30+TEST_SECT_SIZE50)))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* should be able to find section A */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE10), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+
+ if ((node->sect_info.addr != TEST_SECT_ADDR60) || (node->sect_info.size != TEST_SECT_SIZE10))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* should be able to find section D */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+
+ if ((node->sect_info.addr != TEST_SECT_ADDR150) || (node->sect_info.size != TEST_SECT_SIZE80))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_fs_sect_merge() */
+
+/*
+ * To verify that sections are shrunk when adding sections to free-space
+ *
+ * Test 1:
+ * Set EOF to be the ending address of section A
+ * H5FS_CLS_SEPAR_OBJ (cls->flags) is not set when creating free-space manager
+ * Add section A to allow shrinking but is not shrunk because its section class type
+ * TEST_FSPACE_SECT_TYPE_NEW does not define "can_shrink"
+ * Result:section A is not shrunk and section A is still in free-space
+ *
+ * Re-add section A to allow shrinking and with section class type TEST_FSPACE_SECT_TYPE
+ * that defines "can_shrink"
+ * Result:section A is shrunk and there is nothing in free-space
+ *
+ * Test 2:
+ * Set EOF to be greater than the ending address of section A
+ * Set H5FS_CLS_SEPAR_OBJ (cls->flags) when creating free-space manager
+ *
+ * Add section A to allow shrinking but is not shrunk because it is not at EOF,
+ * and section A is not on the merge list due to H5FS_CLS_SEPAR_OBJ
+ * Add section B to allow shrinking and whose ending address is the same as eof.
+ * Section B is not merged with section A because of H5FS_CLS_SEPAR_OBJ but it is shrunk
+ * Result: section A is still in free-space
+ *
+ * Test 3:
+ * Set EOF to be greater than the ending address of section A
+ * H5FS_CLS_SEPAR_OBJ (cls->flags) is not set when creating free-space manager
+ *
+ * Add section A to allow shrinking but is not shrunk because it is not at EOF,
+ * and section A is on the merge list
+ * Add section B to allow shrinking and whose ending address is the same as eof.
+ * Section B is merged with section A and then shrunk.
+ * Result: free-space should be empty
+ */
+static unsigned
+test_fs_sect_shrink(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+ frspace_state_t state; /* State of free space*/
+
+ TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL;
+ unsigned init_flags=0;
+ unsigned can_shrink=FALSE;
+ htri_t node_found = FALSE;
+ TEST_free_section_t *node;
+
+ TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 1");
+
+ /* 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)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A that allow shrinking but its section class type does not define "can_shrink"
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE);
+
+ can_shrink = FALSE;
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* section A should still be there in free-space */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+
+ if ((node->sect_info.addr != TEST_SECT_ADDR100) || (node->sect_info.size != TEST_SECT_SIZE50))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /*
+ * Re-add section A that allow shrinking and its section class type defines "can_shrink"
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ can_shrink = FALSE;
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ /* should have nothing in free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* section A should not be there in free-space */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+
+ TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 2");
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */
+
+ /* does not allow merging */
+ init_flags = H5FS_CLS_SEPAR_OBJ;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ /* free-space should be the same since section B is shrunk */
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* section B should not be there in free-space */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+
+ /* section A should still be there in free-space */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE20), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (!node_found) TEST_ERROR
+
+ if ((node->sect_info.addr != TEST_SECT_ADDR80) || (node->sect_info.size != TEST_SECT_SIZE20))
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 3");
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */
+
+ init_flags = 0; /* reset */
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0)
+ FAIL_STACK_ERROR
+
+ /* section A & B are merged and then strunk, so there is nothing in free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* section B should not be there in free-space */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ /* section A should not be there in free-space */
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)(TEST_SECT_SIZE30), (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+
+ if (node_found) TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_sect_shrink() */
+
+/*
+ * To verify a section's class is changed via H5FS_sect_change_class()
+ *
+ * Test 1:
+ * Add section A with TEST_FSPACE_SECT_TYPE class type with H5FS_CLS_GHOST_OBJ setting
+ * Add section B with TEST_FSPACE_SECT_TYPE_NONE class type without H5FS_CLS_GHOST_OBJ setting
+ * Change section A's class to the second section's class
+ * Result: serial_sect_count is incremented by 1; ghost_sect_count is decremented by 1
+ *
+ * Test 2:
+ * Add section A with TEST_FSPACE_SECT_TYPE class type with H5FS_CLS_SEPAR_OBJ setting
+ * Add section B with TEST_FSPACE_SECT_TYPE_NONE class type without H5FS_CLS_SEPAR_OBJ setting
+ * Add section C with TEST_FSPACE_SECT_TYPE_NONE class type without H5FS_CLS_SEPAR_OBJ setting
+ * Sections B & C are on the merge list
+ * Change section class of B and C to A's section class
+ * Result: the merge list should be null and the class of sections B & C should be changed
+ */
+static unsigned
+test_fs_sect_change_class(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+ frspace_state_t state; /* State of free space*/
+
+ TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL, *sect_node3=NULL;
+ unsigned init_flags=0;
+ TEST_free_section_t *node;
+
+ TESTING("the change of section class via H5FS_sect_change_class() in free-space: Test 1");
+
+ /* 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)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = H5FS_CLS_GHOST_OBJ;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_SECT_SIZE30;
+ state.tot_sect_count += 1;
+ state.ghost_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += TEST_SECT_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if (H5FS_sect_change_class(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ TEST_FSPACE_SECT_TYPE_NONE) < 0)
+ TEST_ERROR
+
+ state.serial_sect_count += 1;
+ state.ghost_sect_count -=1;
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE30, (H5FS_section_info_t **)&node) < 0)
+ FAIL_STACK_ERROR
+
+ if (node->sect_info.type != TEST_FSPACE_SECT_TYPE_NONE)
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ /*
+ * TEST 2
+ */
+ TESTING("the merge of sections when H5FS_sect_add() to free-space: test 2");
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ init_flags = H5FS_CLS_SEPAR_OBJ;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Add section C
+ */
+ if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR200, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node3,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ /* change the class of B to A's class */
+ if (H5FS_sect_change_class(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ TEST_FSPACE_SECT_TYPE) < 0)
+ TEST_ERROR
+
+ /* change the class of C to A's class */
+ if (H5FS_sect_change_class(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node3,
+ TEST_FSPACE_SECT_TYPE) < 0)
+ TEST_ERROR
+
+ /* the merge_list should be empty */
+ if (frsp->sinfo->merge_list)
+ if (H5SL_count(frsp->sinfo->merge_list))
+ TEST_ERROR
+
+ /* verify that section B has changed class */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node) < 0)
+ FAIL_STACK_ERROR
+
+ if (node->sect_info.type != TEST_FSPACE_SECT_TYPE)
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* verify that section C has changed class */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, frsp,
+ (hsize_t)TEST_SECT_SIZE80, (H5FS_section_info_t **)&node) < 0)
+ FAIL_STACK_ERROR
+
+ if (node->sect_info.type != TEST_FSPACE_SECT_TYPE)
+ TEST_ERROR
+
+ if(TEST_sect_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* remove section A from free-space */
+ if(H5FS_sect_remove(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_sect_change_class() */
+
+
+/*
+ * To verify the extension of a block using space from a section in free-space
+ *
+ * Test 1: Try to extend the block by requested-size, which is equal to section B's size
+ * Add section A (addr=70, size=5)
+ * Add section B (addr=100, size=40)
+ * Try to extend the block (addr=80, size=20) by 40, which is the same as section B's size
+ * Result: succeed in extending the block
+ *
+ * Test 2: Try to extend the block by requested-size, which is greater than section B's size
+ * Add section A (addr=70, size=5)
+ * Add section B (addr=100, size=40)
+ * Try to extend the block (addr=80, size=20) by 50, which is greater than section B's size
+ * Result: fail in extending the block
+ *
+ * Test 3: Try to extend the block by requested-size, which is less than section B's size
+ * Add section A (addr=70, size=5)
+ * Add section B (addr=100, size=40)
+ * Try to extend the block (addr=80, size=20) by 30, which is less than section B's size
+ * Result: succeed in extending the block and a section of size=10 is left in free-space
+ *
+ * Test 4: Try to extend the block which does not adjoin section B
+ * Add section A (addr=70, size=5)
+ * Add section B (addr=100, size=40)
+ * Try to extend the block (addr=80, size=15) by 40
+ * Result: fail in extending the block because:
+ * the block does not adjoin section B (80+15 != addr of section B (80))
+ * even though the requested-size is equal to section B's size
+ *
+ */
+static unsigned
+test_fs_sect_extend(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+ frspace_state_t state; /* State of free space*/
+ TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL;
+ unsigned init_flags=0;
+ htri_t status; /* Status of 'try' calls */
+
+ TESTING("a block's extension by requested-size which is = adjoining free section's size: Test 1");
+
+ 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)))
+ FAIL_STACK_ERROR
+
+ /*
+ * TEST 1
+ */
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node2->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Extend a block by requested-size */
+ if((status = H5FS_sect_try_extend(f, H5P_DATASET_XFER_DEFAULT, frsp, (haddr_t)TEST_SECT_SIZE80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE40)) < 0)
+ FAIL_STACK_ERROR
+ if(FALSE == status)
+ TEST_ERROR
+
+ /* Succeed in extending the block: free space info is decremented accordingly */
+ state.tot_space -= (hsize_t)TEST_SECT_SIZE40;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ PASSED()
+
+ /*
+ * TEST 2
+ */
+ TESTING("a block's extension by requested-size which is > adjoining free section's size: Test 2");
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node2->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Extend the block by requested-size */
+ if((status = H5FS_sect_try_extend(f, H5P_DATASET_XFER_DEFAULT, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE50)) < 0)
+ FAIL_STACK_ERROR
+ if(TRUE == status)
+ TEST_ERROR
+
+ /* Not able to extend the block: free space info remains the same */
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ PASSED()
+
+ /*
+ * Test 3
+ */
+ TESTING("a block's extension by requested-size which is < adjoining free section's size: Test 3");
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node2->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Extend the block by requested-size */
+ if((status = H5FS_sect_try_extend(f, H5P_DATASET_XFER_DEFAULT, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE30)) < 0)
+ TEST_ERROR
+ if(FALSE == status)
+ TEST_ERROR
+
+ /* Succeed in extending the block: total free space is decreased but other info remains the same */
+ state.tot_space -= 30;
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ PASSED()
+
+ /*
+ * TEST 4
+ */
+ TESTING("a block's extension by requested-size which does not adjoin any free section: Test 4");
+
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ /*
+ * Add section A
+ */
+ if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node1,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += sect_node1->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /*
+ * Add section B
+ */
+ if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node2,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += sect_node2->sect_info.size;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Extend the block by requested-size */
+ if((status = H5FS_sect_try_extend(f, H5P_DATASET_XFER_DEFAULT, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE15, (hsize_t)TEST_SECT_SIZE40)) < 0)
+ TEST_ERROR
+ if(TRUE == status)
+ TEST_ERROR
+
+ /* Not able to extend the block: free space manager info remains the same */
+ if(check_stats(f, frsp, &state))
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ PASSED()
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_sect_extend() */
+
+
+/*
+ * To verify the iteration of free-space sections
+ *
+ * Create free-space manager with H5FS_CLS_SEPAR_OBJ
+ * Create a whole bunch of sections
+ * Iterate through all sections and collect size and count for all sections
+ * Check info with H5FS_sect_stat()
+ */
+static unsigned
+test_fs_sect_iterate(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FS_t *frsp = NULL; /* pointer to free space structure */
+ haddr_t fs_addr=HADDR_UNDEF; /* address of free space */
+ size_t nclasses;
+ H5FS_create_t cparam; /* creation parameters */
+
+ TEST_free_section_t *sect_node=NULL;
+ unsigned init_flags=0, sect_size;
+ TEST_iter_ud_t udata;
+ int i;
+ hsize_t tot_space, nsects;
+
+ TESTING("iteration of sections in the free-space manager");
+
+ /* 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)))
+ FAIL_STACK_ERROR
+
+ init_cparam(&cparam);
+ nclasses = NELMTS(test_classes);
+ udata.tot_size = 0;
+ udata.tot_sect_count = 0;
+
+ init_flags = H5FS_CLS_SEPAR_OBJ;
+ if(NULL == (frsp = H5FS_create(f, H5P_DATASET_XFER_DEFAULT, &fs_addr,
+ &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF)))
+ FAIL_STACK_ERROR
+
+ if(!H5F_addr_defined(fs_addr))
+ TEST_ERROR
+
+ for (i = 1; i <= NUM_SECTIONS; i++) {
+ if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t))))
+ FAIL_STACK_ERROR
+
+ sect_size = (unsigned)((i-1) % 9) + 1;
+ init_sect_node(sect_node, (haddr_t)i*10, (hsize_t)sect_size, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE);
+
+ if(H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, frsp, (H5FS_section_info_t *)sect_node,
+ H5FS_ADD_RETURNED_SPACE, NULL) < 0)
+ FAIL_STACK_ERROR
+ }
+
+ if(H5FS_sect_iterate(f, H5P_DATASET_XFER_DEFAULT, frsp, TEST_sects_cb, &udata) < 0)
+ TEST_ERROR
+
+ H5FS_sect_stats(frsp, &tot_space, &nsects);
+
+ if (udata.tot_size != tot_space)
+ TEST_ERROR
+ if (udata.tot_sect_count != nsects)
+ TEST_ERROR
+
+ /* Close the free space manager */
+ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
+ FAIL_STACK_ERROR
+ frsp = NULL;
+
+ /* Delete free space manager */
+ if(H5FS_delete(f, H5P_DATASET_XFER_DEFAULT, fs_addr) < 0)
+ FAIL_STACK_ERROR
+ fs_addr = HADDR_UNDEF;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ if(frsp)
+ H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_fs_sect_iterate() */
+
+
+int
+main(void)
+{
+ hid_t fapl = -1; /* File access property list for data files */
+ unsigned nerrors = 0; /* Cumulative error count */
+ const char *env_h5_drvr = NULL; /* File Driver value from environment */
+
+ /* Get the VFD to use */
+ env_h5_drvr = HDgetenv("HDF5_DRIVER");
+ if(env_h5_drvr == NULL)
+ env_h5_drvr = "nomatch";
+
+ fapl = h5_fileaccess();
+
+ /* make sure alignment is not set for tests to succeed */
+ if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0)
+ TEST_ERROR
+
+ nerrors += test_fs_create(fapl);
+ nerrors += test_fs_sect_add(fapl);
+ nerrors += test_fs_sect_merge(fapl);
+ nerrors += test_fs_sect_shrink(fapl);
+ nerrors += test_fs_sect_find(fapl);
+ nerrors += test_fs_sect_change_class(fapl);
+ nerrors += test_fs_sect_extend(fapl);
+ nerrors += test_fs_sect_iterate(fapl);
+
+ if(nerrors)
+ goto error;
+ puts("All free-space tests passed.");
+
+ h5_cleanup(FILENAME, fapl);
+ return (0);
+
+error:
+ puts("*** TESTS FAILED ***");
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+ return (1);
+} /* main() */
+
diff --git a/test/gen_bad_ohdr.c b/test/gen_bad_ohdr.c
index d04996d..6d50230 100644
--- a/test/gen_bad_ohdr.c
+++ b/test/gen_bad_ohdr.c
@@ -28,10 +28,12 @@
#include "H5private.h"
#include "H5Oprivate.h"
+#ifdef H5O_ENABLE_BAD_MESG_COUNT
#define FILENAME "tbad_msg_count.h5"
#define GROUPNAME "Group"
#define ATTRNAME1 "Attribute #1"
#define ATTRNAME2 "Attribute #2"
+#endif /* H5O_ENABLE_BAD_MESG_COUNT */
#ifndef TRUE
#define TRUE 1
diff --git a/test/gen_bogus.c b/test/gen_bogus.c
index a8b88bf..7456ae6 100644
--- a/test/gen_bogus.c
+++ b/test/gen_bogus.c
@@ -25,7 +25,9 @@
#include "hdf5.h"
#include "H5Oprivate.h"
+#ifdef H5O_ENABLE_BOGUS
#define FILENAME "tbogus.h5"
+#endif /* H5O_ENABLE_BOGUS */
#ifndef TRUE
#define TRUE 1
diff --git a/test/gen_filespace.c b/test/gen_filespace.c
new file mode 100644
index 0000000..e9dee1c
--- /dev/null
+++ b/test/gen_filespace.c
@@ -0,0 +1,81 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "hdf5.h"
+
+#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */
+#define TEST_THRESHOLD2 2 /* Free space section threshold */
+
+const char *FILENAMES[] = {
+ "filespace_persist.h5", /* H5F_FILE_SPACE_ALL_PERSIST */
+ "filespace_default.h5", /* H5F_FILE_SPACE_ALL */
+ "filespace_aggr_vfd.h5", /* H5F_FILE_SPACE_AGGR_VFD */
+ "filespace_vfd.h5", /* H5F_FILE_SPACE_VFD */
+ "filespace_threshold.h5" /* H5F_FILE_SPACE_ALL, non-default threshold */
+};
+
+#define DATASET "dset"
+#define NUM_ELMTS 100
+
+/*
+ * Compile and run this program in file-space branch to generate
+ * HDF5 files with different kinds of file space strategies
+ * Move the HDF5 files to the 1.6 and 1.8 branch for compatibility
+ * testing:test_filespace_compatible() will use the files
+ */
+static void gen_file(void)
+{
+ hid_t fid;
+ hid_t fcpl;
+ hid_t dataset, space;
+ hsize_t dim[1];
+ int data[NUM_ELMTS];
+ unsigned i, j; /* Local index variable */
+ H5F_file_space_type_t fs_type; /* File space handling strategy */
+
+ for(j = 0, fs_type = H5F_FILE_SPACE_ALL_PERSIST; j < NELMTS(FILENAMES); j++, (H5F_file_space_type_t)(fs_type)++) {
+ /* Get a copy of the default file creation property */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+
+ if(fs_type == H5F_FILE_SPACE_NTYPES) /* last file */
+ /* Set default strategy but non-default threshold */
+ H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL, (hsize_t)TEST_THRESHOLD2);
+ else
+ /* Set specified file space strategy and free space section threshold */
+ H5Pset_file_space(fcpl, fs_type, (hsize_t)0);
+
+ /* Create the file with the file space info */
+ fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
+
+ dim[0] = NUM_ELMTS;
+ space = H5Screate_simple(1, dim, NULL);
+ dataset = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ for(i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ H5Dclose(dataset);
+ H5Sclose(space);
+ H5Fclose(fid);
+ }
+}
+
+int main(void)
+{
+ gen_file();
+
+ return 0;
+}
diff --git a/test/gen_specmetaread.c b/test/gen_specmetaread.c
new file mode 100644
index 0000000..f489119
--- /dev/null
+++ b/test/gen_specmetaread.c
@@ -0,0 +1,96 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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@hdfgroup.org>
+ * Thursday, October 8, 2009
+ *
+ * Purpose: Create a file with a dataset who's raw data immediately follows
+ * its object header, so that when the dataset is unlinked from its parent
+ * group, a speculative read of the object header would get the raw data
+ * into the metadata accumulator, "polluting" it.
+ * To build the test file, this program MUST be compiled and linked with
+ * the library on the trunk as of when this file is checked in.
+ */
+
+#include "hdf5.h"
+#include <assert.h>
+
+#define FILENAME "specmetaread.h5"
+#define DIM 10
+
+int
+main(void)
+{
+ hid_t fid;
+ hid_t fapl;
+ hid_t did;
+ hid_t space;
+ hsize_t dim[1] = {DIM};
+ unsigned data[DIM];
+ unsigned u;
+ herr_t ret; /* Generic return value */
+
+ /* Initialize the data */
+ for(u = 0; u < DIM; u++)
+ data[u] = u;
+
+ /* Create a FAPL with the metadata and small data aggregators turned off */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ assert(fapl > 0);
+ ret = H5Pset_meta_block_size(fapl, (hsize_t)0);
+ assert(ret >= 0);
+ ret = H5Pset_small_data_block_size(fapl, (hsize_t)0);
+ assert(ret >= 0);
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ assert(fid > 0);
+
+ /* Close FAPL */
+ ret = H5Pclose(fapl);
+ assert(ret >= 0);
+
+ /* Create dataspace */
+ space = H5Screate_simple(1, dim, NULL);
+ assert(space > 0);
+
+ /* Create dataset #1 */
+ did = H5Dcreate2(fid, "dset1", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ assert(did > 0);
+ ret = H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ assert(ret >= 0);
+ ret = H5Dclose(did);
+ assert(ret >= 0);
+
+ /* Create dataset #2 */
+ did = H5Dcreate2(fid, "dset2", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ assert(did > 0);
+ ret = H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ assert(ret >= 0);
+ ret = H5Dclose(did);
+ assert(ret >= 0);
+
+ /* Close dataspace */
+ ret = H5Sclose(space);
+ assert(ret >= 0);
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ assert(ret >= 0);
+
+ return 0;
+}
+
diff --git a/test/gen_udlinks.c b/test/gen_udlinks.c
index 08a25cc..a1312d2 100644
--- a/test/gen_udlinks.c
+++ b/test/gen_udlinks.c
@@ -22,9 +22,9 @@
* They will be named according to the platform and should
* be placed in the hdf5/test directory so that the links test can use them.
*
- * Note: The be_extlink2.h5 is also used by external.c to test opening
+ * Note: The be_extlink2.h5 is also used by external.c to test opening
* external link twice. -SLU 2007/11/7
- *
+ *
*/
#include "hdf5.h"
diff --git a/test/getname.c b/test/getname.c
index 954790f..0dc623e 100644
--- a/test/getname.c
+++ b/test/getname.c
@@ -2401,7 +2401,7 @@ test_obj_ref(hid_t fapl)
FAIL_STACK_ERROR
if(H5Dclose(dataset) < 0)
FAIL_STACK_ERROR
-
+
/* Create a dataset(inside Group1) */
if((dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
@@ -2421,11 +2421,11 @@ test_obj_ref(hid_t fapl)
/* Create another dataset(inside Group1) */
if((dataset = H5Dcreate2(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
-
+
/* Close Dataset */
if(H5Dclose(dataset) < 0)
FAIL_STACK_ERROR
-
+
/* Create a datatype to refer to */
if((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0)
FAIL_STACK_ERROR
@@ -2448,19 +2448,19 @@ test_obj_ref(hid_t fapl)
/* Create a new group in group1 */
if((group2 = H5Gcreate2(group, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
+
/* Create a hard link to group1 in group2 */
if(H5Lcreate_hard(fid1, "/Group1", H5L_SAME_LOC, "/Group1/Group2/Link", H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR
-
+
/* Create dataset in that group */
if((dataset = H5Dcreate2(group2, "Dataset4", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
-
+
/* Close Dataset */
if(H5Dclose(dataset) < 0)
FAIL_STACK_ERROR
-
+
/* Close group */
if(H5Gclose(group) < 0)
FAIL_STACK_ERROR
@@ -2498,7 +2498,7 @@ test_obj_ref(hid_t fapl)
/* Create reference to named datatype */
if(H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, -1) < 0)
FAIL_STACK_ERROR
-
+
if(H5Rcreate(&wbuf[4], fid1, "/Group1/Group2/Dataset4", H5R_OBJECT, -1) < 0)
FAIL_STACK_ERROR
if(H5Rcreate(&wbuf[5], fid1, "/Group1/Group2", H5R_OBJECT, -1) < 0)
@@ -2514,7 +2514,7 @@ test_obj_ref(hid_t fapl)
if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
FAIL_STACK_ERROR
- TESTING("getting path to normal dataset in root group");
+ TESTING("getting path to normal dataset in root group");
if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[0])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
@@ -2526,7 +2526,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to dataset in /Group1");
+ TESTING("getting path to dataset in /Group1");
if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
@@ -2538,7 +2538,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to /Group1");
+ TESTING("getting path to /Group1");
if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[2])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(group, (char*)buf, sizeof(buf));
@@ -2550,7 +2550,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to datatype in /Group1");
+ TESTING("getting path to datatype in /Group1");
if((tid1 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[3])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(tid1, (char*)buf, sizeof(buf));
@@ -2562,7 +2562,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to dataset in nested group");
+ TESTING("getting path to dataset in nested group");
if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
@@ -2574,7 +2574,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to nested group");
+ TESTING("getting path to nested group");
if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[5])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(group, (char*)buf, sizeof(buf));
@@ -2586,7 +2586,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to dataset created via hard link");
+ TESTING("getting path to dataset created via hard link");
if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[6])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
@@ -2598,7 +2598,7 @@ test_obj_ref(hid_t fapl)
PASSED()
HDmemset(buf, 0, sizeof(buf));
- TESTING("getting path to root group");
+ TESTING("getting path to root group");
if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[7])) < 0) FAIL_STACK_ERROR
*buf = '\0';
i = H5Iget_name(group, (char*)buf, sizeof(buf));
@@ -2629,8 +2629,8 @@ test_obj_ref(hid_t fapl)
FAIL_STACK_ERROR
if(H5Ldelete(fid1, "/Group1/Dataset2", H5P_DEFAULT) < 0)
FAIL_STACK_ERROR
-
- TESTING("getting path to dataset that has been unlinked");
+
+ TESTING("getting path to dataset that has been unlinked");
*buf = '\0';
i = H5Iget_name(dataset2, (char*)buf, sizeof(buf));
if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR
@@ -2639,15 +2639,15 @@ test_obj_ref(hid_t fapl)
i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf));
if(i != 0) TEST_ERROR
PASSED()
-
+
/* Close disk dataspace */
if(H5Sclose(sid1) < 0)
FAIL_STACK_ERROR
-
+
/* Close Dataset */
if(H5Dclose(dataset) < 0)
FAIL_STACK_ERROR
-
+
/* Close file */
if(H5Fclose(fid1) < 0)
FAIL_STACK_ERROR
@@ -2666,13 +2666,12 @@ test_reg_ref(hid_t fapl)
char filename1[1024];
hid_t file_id; /* file identifier */
hid_t dsetv_id; /*dataset identifiers*/
- hid_t dsetr_id;
- hid_t space_id, spacer_id;
+ hid_t dsetr_id;
+ hid_t space_id, spacer_id;
hsize_t dims[2] = {2,9};
hsize_t dimsr[1] = {2};
int rank = 2;
int rankr = 1;
- herr_t status;
hdset_reg_ref_t ref[2];
hdset_reg_ref_t ref_out[2];
int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}};
@@ -2701,9 +2700,9 @@ test_reg_ref(hid_t fapl)
TEST_ERROR
/* Write data to the dataset */
- if((status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data)) < 0)
+ if(H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT, data) < 0)
TEST_ERROR
- if((status = H5Dclose(dsetv_id)) < 0)
+ if(H5Dclose(dsetv_id) < 0)
TEST_ERROR
/* Dataset with references */
@@ -2713,35 +2712,35 @@ test_reg_ref(hid_t fapl)
/*
* Create a reference to the hyperslab.
*/
- start[0] = 0;
- start[1] = 3;
+ start[0] = 0;
+ start[1] = 3;
count[0] = 2;
count[1] = 3;
- if((status = H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL)) < 0)
+ if(H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
- if((status = H5Rcreate(&ref[0], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id)) < 0)
+ if(H5Rcreate(&ref[0], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id) < 0)
TEST_ERROR
/* Create a reference to elements selection */
- if((status = H5Sselect_none(space_id)) < 0)
+ if(H5Sselect_none(space_id) < 0)
TEST_ERROR
- if((status = H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, coord)) < 0)
+ if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0)
TEST_ERROR
- if((status = H5Rcreate(&ref[1], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id)) < 0)
+ if(H5Rcreate(&ref[1], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id) < 0)
TEST_ERROR
/* Write dataset with the references */
- if((status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref)) < 0)
+ if(H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0)
TEST_ERROR
/* Close all objects */
- if((status = H5Sclose(space_id)) < 0)
+ if(H5Sclose(space_id) < 0)
TEST_ERROR
- if((status = H5Sclose(spacer_id)) < 0)
+ if(H5Sclose(spacer_id) < 0)
TEST_ERROR
- if((status = H5Dclose(dsetr_id)) < 0)
+ if(H5Dclose(dsetr_id) < 0)
TEST_ERROR
- if((status = H5Fclose(file_id)) < 0)
+ if(H5Fclose(file_id) < 0)
TEST_ERROR
@@ -2753,14 +2752,14 @@ test_reg_ref(hid_t fapl)
if((dsetr_id = H5Dopen2(file_id, REFREG_DSETNAMER, H5P_DEFAULT)) < 0)
TEST_ERROR
- if((status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out)) < 0)
+ if(H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out) < 0)
TEST_ERROR
/* Get name of the dataset the first region reference points to using H5Rget_name */
TESTING("H5Rget_name to get name from region reference(hyperslab)");
*buf1 = '\0';
name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, NAME_BUF_SIZE);
- if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR
+ if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR
PASSED()
TESTING("H5Iget_name to get name from region reference(hyperslab)");
@@ -2770,17 +2769,17 @@ test_reg_ref(hid_t fapl)
/* Get name of the dataset the first region reference points using H5Iget_name */
*buf2 = '\0';
- name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE);
+ name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE);
if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR
- if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR
+ if(H5Dclose(dsetv_id) < 0) TEST_ERROR
PASSED()
/* Get name of the dataset the second region reference points to using H5Rget_name */
TESTING("H5Rget_name to get name from region reference(pnt selec)");
*buf1 = '\0';
- name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, NAME_BUF_SIZE);
+ name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, NAME_BUF_SIZE);
if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR
PASSED()
@@ -2791,18 +2790,18 @@ test_reg_ref(hid_t fapl)
/* Get name of the dataset the first region reference points using H5Iget_name */
*buf2 = '\0';
- name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE);
+ name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE);
if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR
- if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR
+ if(H5Dclose(dsetv_id) < 0) TEST_ERROR
PASSED()
- if((status = H5Dclose(dsetr_id)) < 0)
+ if(H5Dclose(dsetr_id) < 0)
TEST_ERROR
- if((status = H5Fclose(file_id)) < 0)
+ if(H5Fclose(file_id) < 0)
TEST_ERROR
-
+
return 0;
error:
diff --git a/test/gheap.c b/test/gheap.c
index 6dbd8a3..b2c9090 100644
--- a/test/gheap.c
+++ b/test/gheap.c
@@ -30,11 +30,27 @@
#include "H5Iprivate.h"
#include "H5Pprivate.h"
+/* Macros for printing error messages in loops. These print up to
+ * GHEAP_REPEATED_ERR_LIM errors, and suppress the rest */
+#define GHEAP_REPEATED_ERR_LIM 20
+
+#define GHEAP_REPEATED_ERR(MSG) \
+{ \
+ nerrors++; \
+ if(nerrors <= GHEAP_REPEATED_ERR_LIM) { \
+ H5_FAILED(); \
+ puts(MSG); \
+ if(nerrors == GHEAP_REPEATED_ERR_LIM) \
+ puts(" Suppressing further errors..."); \
+ } /* end if */ \
+} /* end GHEAP_REPEATED_ERR */
+
const char *FILENAME[] = {
"gheap1",
"gheap2",
"gheap3",
"gheap4",
+ "gheapooo",
NULL
};
@@ -385,6 +401,120 @@ test_4 (hid_t fapl)
/*-------------------------------------------------------------------------
+ * Function: test_ooo_indices
+ *
+ * Purpose: Tests that indices can be stored out of order. This can
+ * happen when the indices "wrap around" due to many
+ * insertions and deletions (for example, from rewriting a
+ * VL dataset).
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Monday, October 26, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_ooo_indices(hid_t fapl)
+{
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ unsigned i, j;
+ H5HG_t *obj = NULL;
+ herr_t status;
+ int nerrors=0;
+ char filename[1024];
+
+ TESTING("out of order indices");
+
+ if(NULL == (obj = (H5HG_t *)HDmalloc(2000 * sizeof(*obj))))
+ goto error;
+
+ /* Open a clean file */
+ h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+ if(NULL == (f = (H5F_t *)H5I_object(file))) {
+ H5_FAILED();
+ puts(" Unable to create file");
+ goto error;
+ } /* end if */
+
+ /* Alternately insert 1000 entries and remove the previous group of 1000
+ * entries, until the indices wrap around */
+ for(i=0; i<66; i++) {
+ /* Insert 1000 entries. The index into the obj array will alternate up
+ * and down by 1000 so the previous set of insertions is preserved and
+ * can be deleted. */
+ for(j=1000*((~i&1)); j<1000*((~i&1)+1); j++) {
+ H5Eclear2(H5E_DEFAULT);
+ status = H5HG_insert(f, H5P_DATASET_XFER_DEFAULT, sizeof(j), &j, &obj[j]);
+ if (status<0)
+ GHEAP_REPEATED_ERR(" Unable to insert object into global heap")
+
+ /* Check that the index is as expected */
+ if(obj[j].idx != ((1000 * i) + j - (1000 * ((~i & 1)))) % ((1u << 16) - 1) + 1)
+ GHEAP_REPEATED_ERR(" Unexpected global heap index");
+ } /* end for */
+
+ /* Remove the previous 1000 entries */
+ if(i>0)
+ for(j=1000*(i&1); j<1000*((i&1)+1); j++) {
+ H5Eclear2(H5E_DEFAULT);
+ status = H5HG_remove(f, H5P_DATASET_XFER_DEFAULT, &obj[j]);
+ if (status<0)
+ GHEAP_REPEATED_ERR(" Unable to remove object from global heap");
+ } /* end for */
+ } /* end for */
+
+ /* The indices should have "wrapped around" on the last iteration */
+ HDassert(obj[534].idx == 65535);
+ HDassert(obj[535].idx == 1);
+
+ /* Reopen the file */
+ if (H5Fclose(file)<0) goto error;
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ goto error;
+ if(NULL == (f = (H5F_t *)H5I_object(file))) {
+ H5_FAILED();
+ puts(" Unable to open file");
+ goto error;
+ } /* end if */
+
+ /* Read the objects to make sure the heap is still readable */
+ for(i=0; i<1000; i++) {
+ if(NULL == H5HG_read(f, H5P_DATASET_XFER_DEFAULT, &obj[i], &j, NULL))
+ goto error;
+ if(i != j) {
+ H5_FAILED();
+ puts(" Incorrect read value");
+ goto error;
+ } /* end if */
+ } /* end for */
+
+ if (H5Fclose(file)<0) goto error;
+ if (nerrors) goto error;
+ HDfree(obj);
+ obj = NULL;
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ if(obj)
+ HDfree(obj);
+ return MAX(1, nerrors);
+} /* end test_ooo_indices */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests global heap.
@@ -413,6 +543,7 @@ main (void)
nerrors += test_2(fapl);
nerrors += test_3(fapl);
nerrors += test_4(fapl);
+ nerrors += test_ooo_indices(fapl);
if (nerrors) goto error;
puts("All global heap tests passed.");
diff --git a/test/h5test.c b/test/h5test.c
index 98508ff..a5b50d3 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -64,18 +64,16 @@
* is about the best guess.
*/
#ifndef HDF5_PARAPREFIX
-#ifdef __PUMAGON__
-/* For the PFS of TFLOPS */
-#define HDF5_PARAPREFIX "pfs:/pfs_grande/multi/tmp_1"
-#else
#define HDF5_PARAPREFIX ""
#endif
-#endif
char *paraprefix = NULL; /* for command line option para-prefix */
#ifdef H5_HAVE_PARALLEL
MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */
#endif
+#define FILENAME_BUF_SIZE 1024
+#define READ_BUF_SIZE 4096
+
/*
* These are the letters that are appended to the file name when generating
* names for the split and multi drivers. They are:
@@ -541,7 +539,7 @@ h5_fileaccess(void)
if (H5Pset_fapl_stdio(fapl)<0) return -1;
} else if (!HDstrcmp(name, "core")) {
/* In-core temporary file with 1MB increment */
- if (H5Pset_fapl_core(fapl, (size_t)1024*1024, TRUE)<0) return -1;
+ if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1;
} else if (!HDstrcmp(name, "split")) {
/* Split meta data and raw data each using default driver */
if (H5Pset_fapl_split(fapl,
@@ -562,13 +560,13 @@ h5_fileaccess(void)
HDmemset(memb_name, 0, sizeof memb_name);
HDmemset(memb_addr, 0, sizeof memb_addr);
- assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
- for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
memb_fapl[mt] = H5P_DEFAULT;
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
memb_name[mt] = sv[mt];
- memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
- }
+ memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
+ } /* end for */
if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name,
memb_addr, FALSE)<0) {
@@ -847,20 +845,93 @@ h5_dump_info_object(MPI_Info info)
* Programmer: Quincey Koziol
* Saturday, March 22, 2003
*
- * Modifications:
- * Albert Cheng, Oct 11, 2006
- * Changed Failure return value to -1.
- *
*-------------------------------------------------------------------------
*/
h5_stat_size_t
-h5_get_file_size(const char *filename)
+h5_get_file_size(const char *filename, hid_t fapl)
{
- h5_stat_t sb;
+ char temp[2048]; /* Temporary buffer for file names */
+ h5_stat_t sb; /* Structure for querying file info */
+ int j = 0;
+
+ if(fapl == H5P_DEFAULT) {
+ /* Get the file's statistics */
+ if(0 == HDstat(filename, &sb))
+ return((h5_stat_size_t)sb.st_size);
+ } /* end if */
+ else {
+ hid_t driver; /* VFD used for file */
- /* Get the file's statistics */
- if (HDstat(filename, &sb)==0)
- return((h5_stat_size_t)sb.st_size);
+ /* Get the driver used when creating the file */
+ if((driver = H5Pget_driver(fapl)) < 0)
+ return(-1);
+
+ /* Check for simple cases */
+ if(driver == H5FD_SEC2 || driver == H5FD_STDIO || driver == H5FD_CORE ||
+#ifdef H5_HAVE_PARALLEL
+ driver == H5FD_MPIO || driver == H5FD_MPIPOSIX ||
+#endif /* H5_HAVE_PARALLEL */
+#ifdef H5_HAVE_WINDOWS
+ driver == H5FD_WINDOWS ||
+#endif /* H5_HAVE_WINDOWS */
+#ifdef H5_HAVE_DIRECT
+ driver == H5FD_DIRECT ||
+#endif /* H5_HAVE_DIRECT */
+ driver == H5FD_LOG) {
+ /* Get the file's statistics */
+ if(0 == HDstat(filename, &sb))
+ return((h5_stat_size_t)sb.st_size);
+ } /* end if */
+ else if(driver == H5FD_MULTI) {
+ H5FD_mem_t mt;
+ h5_stat_size_t tot_size = 0;
+
+ HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES);
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
+ /* Create the filename to query */
+ HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]);
+
+ /* Check for existence of file */
+ if(0 == HDaccess(temp, F_OK)) {
+ /* Get the file's statistics */
+ if(0 != HDstat(temp, &sb))
+ return(-1);
+
+ /* Add to total size */
+ tot_size += (h5_stat_size_t)sb.st_size;
+ } /* end if */
+ } /* end for */
+
+ /* Return total size */
+ return(tot_size);
+ } /* end if */
+ else if(driver == H5FD_FAMILY) {
+ h5_stat_size_t tot_size = 0;
+
+ /* Try all filenames possible, until we find one that's missing */
+ for(j = 0; /*void*/; j++) {
+ /* Create the filename to query */
+ HDsnprintf(temp, sizeof temp, filename, j);
+
+ /* Check for existence of file */
+ if(HDaccess(temp, F_OK) < 0)
+ break;
+
+ /* Get the file's statistics */
+ if(0 != HDstat(temp, &sb))
+ return(-1);
+
+ /* Add to total size */
+ tot_size += (h5_stat_size_t)sb.st_size;
+ } /* end for */
+
+ /* Return total size */
+ return(tot_size);
+ } /* end if */
+ else {
+ HDassert(0 && "Unknown VFD!");
+ } /* end else */
+ } /* end else */
return(-1);
} /* end get_file_size() */
@@ -903,30 +974,28 @@ print_func(const char *format, ...)
*/
int h5_szip_can_encode(void )
{
-
- herr_t status;
- unsigned int filter_config_flags;
-
- status =H5Zget_filter_info(H5Z_FILTER_SZIP, &filter_config_flags);
- if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
- /* filter present but neither encode nor decode is supported (???) */
- return -1;
- } else if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
- H5Z_FILTER_CONFIG_DECODE_ENABLED) {
- /* decoder only: read but not write */
- return 0;
- } else if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
- H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
- /* encoder only: write but not read (???) */
- return -1;
- } else if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
- return 1;
- }
+ unsigned int filter_config_flags;
+
+ H5Zget_filter_info(H5Z_FILTER_SZIP, &filter_config_flags);
+ if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
+ /* filter present but neither encode nor decode is supported (???) */
+ return -1;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_DECODE_ENABLED) {
+ /* decoder only: read but not write */
+ return 0;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
+ /* encoder only: write but not read (???) */
+ return -1;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
+ return 1;
+ }
return(-1);
}
#endif /* H5_HAVE_FILTER_SZIP */
@@ -958,49 +1027,45 @@ int h5_szip_can_encode(void )
*
*-------------------------------------------------------------------------
*/
-
-char* getenv_all(MPI_Comm comm, int root, const char* name)
+char *
+getenv_all(MPI_Comm comm, int root, const char* name)
{
int mpi_size, mpi_rank, mpi_initialized;
int len;
static char* env = NULL;
- MPI_Status Status;
assert(name);
MPI_Initialized(&mpi_initialized);
- if (!mpi_initialized){
+ if(!mpi_initialized) {
/* use original getenv */
if(env)
HDfree(env);
env = HDgetenv(name);
- }else{
+ } /* end if */
+ else {
MPI_Comm_rank(comm, &mpi_rank);
MPI_Comm_size(comm, &mpi_size);
assert(root < mpi_size);
/* The root task does the getenv call
* and sends the result to the other tasks */
- if(mpi_rank == root)
- {
+ if(mpi_rank == root) {
env = HDgetenv(name);
- if(env)
- {
+ if(env) {
len = HDstrlen(env);
MPI_Bcast(&len, 1, MPI_INT, root, comm);
MPI_Bcast(env, len, MPI_CHAR, root, comm);
}
- else{
+ else {
/* len -1 indicates that the variable was not in the environment */
len = -1;
MPI_Bcast(&len, 1, MPI_INT, root, comm);
}
}
- else
- {
+ else {
MPI_Bcast(&len, 1, MPI_INT, root, comm);
- if(len >= 0)
- {
+ if(len >= 0) {
if(env == NULL)
env = (char*) HDmalloc(len+1);
else if(strlen(env) < len)
@@ -1009,8 +1074,7 @@ char* getenv_all(MPI_Comm comm, int root, const char* name)
MPI_Bcast(env, len, MPI_CHAR, root, comm);
env[len] = '\0';
}
- else
- {
+ else {
if(env)
HDfree(env);
env = NULL;
@@ -1027,3 +1091,55 @@ char* getenv_all(MPI_Comm comm, int root, const char* name)
#endif
+/*-------------------------------------------------------------------------
+ * Function: h5_make_local_copy
+ *
+ * Purpose: Make copy of file. Some tests write to data files under that
+ * are under version control. Those tests should make a copy of
+ * the versioned file and write to the copy. This function
+ * prepends srcdir to the name of the file to be copied and uses
+ * the name of the copy as is.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Larry Knox
+ * Monday, October 13, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+h5_make_local_copy(char *origfilename, char *local_copy_name)
+{
+ char filename[FILENAME_BUF_SIZE] = "";
+ int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
+ ssize_t nread; /* Number of bytes read in */
+ char buf[READ_BUF_SIZE]; /* Buffer for copying data */
+ char * srcdir = HDgetenv("srcdir"); /* The source directory */
+
+ if(srcdir && ((HDstrlen(srcdir) +
+ HDstrlen(origfilename) + 6) < FILENAME_BUF_SIZE)) {
+ HDstrcpy(filename, srcdir);
+ HDstrcat(filename, "/");
+ }
+ HDstrcat(filename, origfilename);
+
+ /* Copy old file into temporary file */
+ if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) return -1;
+ if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, 0666))
+ < 0) return -1;
+
+ /* Copy data */
+ while((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0)
+ HDwrite(fd_new, buf, (size_t)nread);
+
+ /* Close files */
+ if(HDclose(fd_old) < 0) return -1;
+ if(HDclose(fd_new) < 0) return -1;
+
+ return 0;
+}
+
diff --git a/test/h5test.h b/test/h5test.h
index 4add74c..315b504 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -99,6 +99,7 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */
* the H5_FAILED() macro is invoked automatically when an API function fails.
*/
#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);}
+#define TESTING_2(WHAT) {printf(" Testing %-62s",WHAT); fflush(stdout);}
#define PASSED() {puts(" PASSED");fflush(stdout);}
#define H5_FAILED() {puts("*FAILED*");fflush(stdout);}
#define H5_WARNING() {puts("*WARNING*");fflush(stdout);}
@@ -120,12 +121,12 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */
/*
* The methods to compare the equality of floating-point values:
- * 1. XXX_ABS_EQUAL - check if the difference is smaller than the
+ * 1. XXX_ABS_EQUAL - check if the difference is smaller than the
* Epsilon value. The Epsilon values, FLT_EPSILON, DBL_EPSILON,
* and LDBL_EPSILON, are defined by compiler in float.h.
* 2. XXX_REL_EQUAL - check if the relative difference is smaller than a
* predefined value M. See if two values are relatively equal.
- * It's the test's responsibility not to pass in the value 0, which
+ * It's the test's responsibility not to pass in the value 0, which
* may cause the equation to fail.
*/
#define FLT_ABS_EQUAL(X,Y) ((float)fabs(X-Y)<FLT_EPSILON)
@@ -149,8 +150,9 @@ H5TEST_DLL void h5_no_hwconv(void);
H5TEST_DLL const char *h5_rmprefix(const char *filename);
H5TEST_DLL void h5_reset(void);
H5TEST_DLL void h5_show_hostname(void);
-H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename);
+H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename, hid_t fapl);
H5TEST_DLL int print_func(const char *format, ...);
+H5TEST_DLL int h5_make_local_copy(char *origfilename, char *local_copy_name);
/* Routines for operating on the list of tests (for the "all in one" tests) */
H5TEST_DLL void TestUsage(void);
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 89dbc5c..b756449 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -666,7 +666,7 @@ test_multifill(size_t nx)
sprintf(s, "bad dst[%lu].left", (unsigned long)i);
} else if (!DBL_ABS_EQUAL(dst[i].mid, fill.mid)) {
/* Check if two DOUBLE values are equal. If their difference
- * is smaller than the EPSILON value for double, they are
+ * is smaller than the EPSILON value for double, they are
* considered equal. See the definition in h5test.h.
*/
sprintf(s, "bad dst[%lu].mid", (unsigned long)i);
@@ -1234,7 +1234,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/*
* Open the library explicitly for thread-safe builds, so per-thread
diff --git a/test/istore.c b/test/istore.c
index e0d2e82..fb0f3fc 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -250,9 +250,9 @@ test_extend(hid_t f, const char *prefix,
sprintf(s, "istore extend: %s", dims);
TESTING(s);
- buf = HDmalloc(nx * ny * nz);
- check = HDmalloc(nx * ny * nz);
- whole = HDcalloc((size_t)1, nx * ny * nz);
+ buf = (uint8_t *)HDmalloc(nx * ny * nz);
+ check = (uint8_t *)HDmalloc(nx * ny * nz);
+ whole = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz);
whole_size[0] = nx;
whole_size[1] = ny;
@@ -463,7 +463,7 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks,
sprintf(s, "istore sparse: %s", dims);
TESTING(s);
- buf = HDmalloc(nx * ny * nz);
+ buf = (uint8_t *)HDmalloc(nx * ny * nz);
HDmemset(buf, 128, nx * ny * nz);
/* Set dimensions of dataset */
@@ -565,140 +565,116 @@ main(int argc, char *argv[])
unsigned size_of_test;
unsigned u; /* Local index variable */
char filename[1024];
- const char *envval = NULL;
-
- /* Don't run this test using the split file driver */
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "split")) {
- /* Parse arguments or assume these tests (`small', `medium' ) */
- if (1 == argc) {
- size_of_test = TEST_SMALL;
- } else {
- int i;
- for (i = 1, size_of_test = 0; i < argc; i++) {
- if (!strcmp(argv[i], "small")) {
- size_of_test |= TEST_SMALL;
- } else if (!strcmp(argv[i], "medium")) {
- size_of_test |= TEST_MEDIUM;
- } else if (!strcmp(argv[i], "large")) {
- size_of_test |= TEST_LARGE;
- } else {
- printf("unrecognized argument: %s\n", argv[i]);
+
+ /* Parse arguments or assume these tests (`small', `medium' ) */
+ if (1 == argc) {
+ size_of_test = TEST_SMALL | TEST_MEDIUM | TEST_LARGE;
+ } else {
+ int i;
+ for (i = 1, size_of_test = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "small")) {
+ size_of_test |= TEST_SMALL;
+ } else if (!strcmp(argv[i], "medium")) {
+ size_of_test |= TEST_MEDIUM;
+ } else if (!strcmp(argv[i], "large")) {
+ size_of_test |= TEST_LARGE;
+ } else {
+ printf("unrecognized argument: %s\n", argv[i]);
#if 0
- exit(1);
+ exit(1);
#endif
- }
- }
- }
- printf("Test sizes: ");
- if (size_of_test & TEST_SMALL)
- printf(" SMALL");
- if (size_of_test & TEST_MEDIUM)
- printf(" MEDIUM");
- if (size_of_test & TEST_LARGE)
- printf(" LARGE");
- printf("\n");
-
- /* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
-
- /* Reset library */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Use larger file addresses... */
- fcpl = H5Pcreate(H5P_FILE_CREATE);
- H5Pset_sizes(fcpl, (size_t)8, (size_t)0);
-
- /* Create the test file */
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
- printf("Cannot create file %s; test aborted\n", filename);
- exit(1);
- }
+ }
+ }
+ }
+ printf("Test sizes: ");
+ if (size_of_test & TEST_SMALL)
+ printf(" SMALL");
+ if (size_of_test & TEST_MEDIUM)
+ printf(" MEDIUM");
+ if (size_of_test & TEST_LARGE)
+ printf(" LARGE");
+ printf("\n");
+
+ /* Set the random # seed */
+ HDsrandom((unsigned)HDtime(NULL));
+
+ /* Reset library */
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ /* Use larger file addresses... */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ H5Pset_sizes(fcpl, (size_t)8, (size_t)0);
+
+ /* Create the test file */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
+ printf("Cannot create file %s; test aborted\n", filename);
+ exit(1);
+ }
- /*
- * For testing file families, fool the library into thinking it already
- * allocated a whole bunch of data.
- */
- if (H5FD_FAMILY==H5Pget_driver(fapl)) {
- haddr_t addr;
- H5F_t *f;
-
- addr = 8 * ((uint64_t)1<<30); /*8 GB */
- f=H5I_object(file);
- if (H5FDset_eoa(f->shared->lf, H5FD_MEM_DEFAULT, addr) < 0) {
- printf("Cannot create large file family\n");
- exit(1);
- }
- }
+ /* Initialize chunk dimensions */
+ for(u = 0; u < H5O_LAYOUT_NDIMS; u++)
+ chunk_dims[u] = TEST_CHUNK_SIZE;
+
+ /*
+ * Creation test: Creates empty objects with various raw data sizes
+ * and alignments.
+ */
+ status = test_create(file, "create");
+ nerrors += status < 0 ? 1 : 0;
+
+ if (size_of_test & TEST_SMALL) {
+ status = test_extend(file, "extend", (size_t)10, (size_t)0, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(file, "extend", (size_t)10, (size_t)10, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(file, "extend", (size_t)10, (size_t)10, (size_t)10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_extend(file, "extend", (size_t)10000, (size_t)0, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(file, "extend", (size_t)2500, (size_t)10, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(file, "extend", (size_t)10, (size_t)400, (size_t)10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_SMALL) {
+ status = test_sparse(file, "sparse", (size_t)100, (size_t)5, (size_t)0, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(file, "sparse", (size_t)100, (size_t)3, (size_t)4, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(file, "sparse", (size_t)100, (size_t)2, (size_t)3, (size_t)4);
+ 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);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(file, "sparse", (size_t)2000, (size_t)7, (size_t)3, (size_t)0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(file, "sparse", (size_t)2000, (size_t)4, (size_t)2, (size_t)3);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_LARGE) {
+ status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50);
+ nerrors += status < 0 ? 1 : 0;
+ }
- /* Initialize chunk dimensions */
- for (u = 0; u < H5O_LAYOUT_NDIMS; u++)
- chunk_dims[u]=TEST_CHUNK_SIZE;
-
- /*
- * Creation test: Creates empty objects with various raw data sizes
- * and alignments.
- */
- status = test_create(file, "create");
- nerrors += status < 0 ? 1 : 0;
-
- if (size_of_test & TEST_SMALL) {
- status = test_extend(file, "extend", (size_t)10, (size_t)0, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_extend(file, "extend", (size_t)10, (size_t)10, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_extend(file, "extend", (size_t)10, (size_t)10, (size_t)10);
- nerrors += status < 0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_extend(file, "extend", (size_t)10000, (size_t)0, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_extend(file, "extend", (size_t)2500, (size_t)10, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_extend(file, "extend", (size_t)10, (size_t)400, (size_t)10);
- nerrors += status < 0 ? 1 : 0;
- }
- if (size_of_test & TEST_SMALL) {
- status = test_sparse(file, "sparse", (size_t)100, (size_t)5, (size_t)0, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)100, (size_t)3, (size_t)4, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)100, (size_t)2, (size_t)3, (size_t)4);
- 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);
- nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)2000, (size_t)7, (size_t)3, (size_t)0);
- nerrors += status < 0 ? 1 : 0;
- status = test_sparse(file, "sparse", (size_t)2000, (size_t)4, (size_t)2, (size_t)3);
- nerrors += status < 0 ? 1 : 0;
- }
- if (size_of_test & TEST_LARGE) {
- status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50);
- nerrors += status < 0 ? 1 : 0;
- }
+ /* Close the test file and exit */
+ H5Pclose(fcpl);
+ H5Fclose(file);
- /* Close the test file and exit */
- H5Pclose(fcpl);
- H5Fclose(file);
+ if (nerrors) {
+ printf("***** %d I-STORE TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ exit(1);
+ }
- if (nerrors) {
- printf("***** %d I-STORE TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
- exit(1);
- }
+ printf("All i-store tests passed.\n");
+
+ h5_cleanup(FILENAME, fapl);
- printf("All i-store tests passed.\n");
- h5_cleanup(FILENAME, fapl);
- }
- else
- {
- puts("All i-store tests skipped - Incompatible with current Virtual File Driver");
- }
return 0;
}
+
diff --git a/test/links.c b/test/links.c
index 0d89fd2..deae5ef 100644
--- a/test/links.c
+++ b/test/links.c
@@ -26,14 +26,27 @@
*/
#define H5G_PACKAGE
#define H5G_TESTING
-#include "H5Gpkg.h" /* Groups */
#include "h5test.h"
-#include "H5Lprivate.h"
+#include "H5Gpkg.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
/* File for external link test. Created with gen_udlinks.c */
#define LINKED_FILE "be_extlink2.h5"
+#ifdef H5_VMS
+#define TMPDIR "[.tmp]"
+#define TMPDIR2 "[.tmp2]"
+#else /* H5_VMS */
+#define TMPDIR "tmp/"
+#define TMPDIR2 "tmp2/"
+#endif /* H5_VMS */
+
+/* Symlinks for external link symlink test */
+#define SYMLINK1 TMPDIR "sym1.h5"
+#define SYMLINK2 TMPDIR2 "sym2.h5"
+
const char *FILENAME[] = {
"links0",
"links1",
@@ -47,35 +60,53 @@ const char *FILENAME[] = {
"links6", /* 9 */
"links7", /* 10 */
"links8", /* 11 */
- "extlinks0", /* 12: main files */
- "tmp/extlinks0", /* 13: */
- "extlinks1", /* 14: target files */
- "tmp/extlinks1", /* 15: */
+ "extlinks0", /* 12: main files */
+ TMPDIR "extlinks0", /* 13: */
+ "extlinks1", /* 14: target files */
+ TMPDIR "extlinks1", /* 15: */
"extlinks2", /* 16: */
- "tmp/extlinks2", /* 17: */
+ TMPDIR "extlinks2", /* 17: */
"extlinks3", /* 18: */
- "tmp/extlinks3", /* 19: */
+ TMPDIR "extlinks3", /* 19: */
"extlinks4", /* 20: */
- "tmp/extlinks4", /* 21: */
+ TMPDIR "extlinks4", /* 21: */
"extlinks5", /* 22: */
- "tmp/extlinks6", /* 23: */
+ TMPDIR "extlinks6", /* 23: */
"extlinks7", /* 24: */
- "tmp/extlinks7", /* 25: */
- "tmp/extlinks8", /* 26: */
+ TMPDIR "extlinks7", /* 25: */
+ TMPDIR "extlinks8", /* 26: */
"extlinks9", /* 27: */
- "tmp/extlinks9", /* 28: */
+ TMPDIR "extlinks9", /* 28: */
"extlinks10", /* 29: */ /* TESTS for windows */
- "tmp/extlinks10", /* 30: */
- "tmp/extlinks11", /* 31: */
- "tmp/extlinks12", /* 32: */
+ TMPDIR "extlinks10",/* 30: */
+ TMPDIR "extlinks11",/* 31: */
+ TMPDIR "extlinks12",/* 32: */
"extlinks13", /* 33: */
- "tmp/extlinks13", /* 34: */
- "tmp/extlinks14", /* 35: */
- "tmp/extlinks15", /* 36: */
+ TMPDIR "extlinks13",/* 34: */
+ TMPDIR "extlinks14",/* 35: */
+ TMPDIR "extlinks15",/* 36: */
+ "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */
+ "extlinks16B", /* 38: */
+ "extlinks17", /* 39: */
+ "extlinks18A", /* 40: */
+ "extlinks18B", /* 41: */
+ "extlinks19A", /* 42: */
+ "extlinks19B", /* 43: */
+ "extlinks20", /* 44: */
+ "extlinks21A", /* 45: Files for symlink() tests*/
+ TMPDIR2 "extlinks21B",/* 46: */
+ TMPDIR2 "extlinks21C",/* 47: */
+ "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */
+ TMPDIR "extlinks21D",/* 49: */
+ TMPDIR "extlinks21E",/* 50: */
+ "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */
NULL
};
-#define TMPDIR "tmp"
+#define FAMILY_SIZE 1024
+#define CORE_INCREMENT 1024
+#define NUM40 40
+
/* do not do check_all_closed() for "ext*" files and "tmp/ext*" */
#define EXTSTOP 12
@@ -104,9 +135,13 @@ const char *FILENAME[] = {
#define LE_FILENAME "le_extlink1.h5"
#define BE_FILENAME "be_extlink1.h5"
+#define ELINK_CB_FAM_SIZE (hsize_t) 100
+
#define H5L_DIM1 100
#define H5L_DIM2 100
+#define FILTER_FILESIZE_MAX_FRACTION .9
+
/* Creation order macros */
#define CORDER_GROUP_NAME "corder_group"
#define CORDER_SOFT_GROUP_NAME "corder_soft_group"
@@ -135,64 +170,64 @@ typedef struct {
H5L_type_t type; /* Type of link */
} link_visit_t;
static const link_visit_t lvisit0[] = {
- {"Dataset_zero", 0},
- {"Group1", 0},
- {"Group1/Dataset_one", 0},
- {"Group1/Group2", 0},
- {"Group1/Group2/Dataset_two", 0},
- {"Group1/Group2/Type_two", 0},
- {"Group1/Group2/hard_zero", 0},
- {"Group1/Type_one", 0},
- {"Group1/hard_one", 0},
- {"Type_zero", 0},
- {"ext_dangle", 64},
- {"ext_one", 64},
- {"hard_one", 0},
- {"hard_two", 0},
- {"hard_zero", 0},
- {"soft_dangle", 1},
- {"soft_one", 1},
- {"soft_two", 1}
+ {"Dataset_zero", H5L_TYPE_HARD},
+ {"Group1", H5L_TYPE_HARD},
+ {"Group1/Dataset_one", H5L_TYPE_HARD},
+ {"Group1/Group2", H5L_TYPE_HARD},
+ {"Group1/Group2/Dataset_two", H5L_TYPE_HARD},
+ {"Group1/Group2/Type_two", H5L_TYPE_HARD},
+ {"Group1/Group2/hard_zero", H5L_TYPE_HARD},
+ {"Group1/Type_one", H5L_TYPE_HARD},
+ {"Group1/hard_one", H5L_TYPE_HARD},
+ {"Type_zero", H5L_TYPE_HARD},
+ {"ext_dangle", H5L_TYPE_EXTERNAL},
+ {"ext_one", H5L_TYPE_EXTERNAL},
+ {"hard_one", H5L_TYPE_HARD},
+ {"hard_two", H5L_TYPE_HARD},
+ {"hard_zero", H5L_TYPE_HARD},
+ {"soft_dangle", H5L_TYPE_SOFT},
+ {"soft_one", H5L_TYPE_SOFT},
+ {"soft_two", H5L_TYPE_SOFT}
};
static const link_visit_t lvisit1[] = {
- {"Dataset_one", 0},
- {"Group2", 0},
- {"Group2/Dataset_two", 0},
- {"Group2/Type_two", 0},
- {"Group2/hard_zero", 0},
- {"Group2/hard_zero/Dataset_zero", 0},
- {"Group2/hard_zero/Group1", 0},
- {"Group2/hard_zero/Type_zero", 0},
- {"Group2/hard_zero/ext_dangle", 64},
- {"Group2/hard_zero/ext_one", 64},
- {"Group2/hard_zero/hard_one", 0},
- {"Group2/hard_zero/hard_two", 0},
- {"Group2/hard_zero/hard_zero", 0},
- {"Group2/hard_zero/soft_dangle", 1},
- {"Group2/hard_zero/soft_one", 1},
- {"Group2/hard_zero/soft_two", 1},
- {"Type_one", 0},
- {"hard_one", 0}
+ {"Dataset_one", H5L_TYPE_HARD},
+ {"Group2", H5L_TYPE_HARD},
+ {"Group2/Dataset_two", H5L_TYPE_HARD},
+ {"Group2/Type_two", H5L_TYPE_HARD},
+ {"Group2/hard_zero", H5L_TYPE_HARD},
+ {"Group2/hard_zero/Dataset_zero", H5L_TYPE_HARD},
+ {"Group2/hard_zero/Group1", H5L_TYPE_HARD},
+ {"Group2/hard_zero/Type_zero", H5L_TYPE_HARD},
+ {"Group2/hard_zero/ext_dangle", H5L_TYPE_EXTERNAL},
+ {"Group2/hard_zero/ext_one", H5L_TYPE_EXTERNAL},
+ {"Group2/hard_zero/hard_one", H5L_TYPE_HARD},
+ {"Group2/hard_zero/hard_two", H5L_TYPE_HARD},
+ {"Group2/hard_zero/hard_zero", H5L_TYPE_HARD},
+ {"Group2/hard_zero/soft_dangle", H5L_TYPE_SOFT},
+ {"Group2/hard_zero/soft_one", H5L_TYPE_SOFT},
+ {"Group2/hard_zero/soft_two", H5L_TYPE_SOFT},
+ {"Type_one", H5L_TYPE_HARD},
+ {"hard_one", H5L_TYPE_HARD}
};
static const link_visit_t lvisit2[] = {
- {"Dataset_two", 0},
- {"Type_two", 0},
- {"hard_zero", 0},
- {"hard_zero/Dataset_zero", 0},
- {"hard_zero/Group1", 0},
- {"hard_zero/Group1/Dataset_one", 0},
- {"hard_zero/Group1/Group2", 0},
- {"hard_zero/Group1/Type_one", 0},
- {"hard_zero/Group1/hard_one", 0},
- {"hard_zero/Type_zero", 0},
- {"hard_zero/ext_dangle", 64},
- {"hard_zero/ext_one", 64},
- {"hard_zero/hard_one", 0},
- {"hard_zero/hard_two", 0},
- {"hard_zero/hard_zero", 0},
- {"hard_zero/soft_dangle", 1},
- {"hard_zero/soft_one", 1},
- {"hard_zero/soft_two", 1}
+ {"Dataset_two", H5L_TYPE_HARD},
+ {"Type_two", H5L_TYPE_HARD},
+ {"hard_zero", H5L_TYPE_HARD},
+ {"hard_zero/Dataset_zero", H5L_TYPE_HARD},
+ {"hard_zero/Group1", H5L_TYPE_HARD},
+ {"hard_zero/Group1/Dataset_one", H5L_TYPE_HARD},
+ {"hard_zero/Group1/Group2", H5L_TYPE_HARD},
+ {"hard_zero/Group1/Type_one", H5L_TYPE_HARD},
+ {"hard_zero/Group1/hard_one", H5L_TYPE_HARD},
+ {"hard_zero/Type_zero", H5L_TYPE_HARD},
+ {"hard_zero/ext_dangle", H5L_TYPE_EXTERNAL},
+ {"hard_zero/ext_one", H5L_TYPE_EXTERNAL},
+ {"hard_zero/hard_one", H5L_TYPE_HARD},
+ {"hard_zero/hard_two", H5L_TYPE_HARD},
+ {"hard_zero/hard_zero", H5L_TYPE_HARD},
+ {"hard_zero/soft_dangle", H5L_TYPE_SOFT},
+ {"hard_zero/soft_one", H5L_TYPE_SOFT},
+ {"hard_zero/soft_two", H5L_TYPE_SOFT}
};
typedef struct {
@@ -207,70 +242,70 @@ typedef struct {
H5O_type_t type; /* Type of object */
} obj_visit_t;
static const obj_visit_t ovisit0_old[] = {
- {".", 0},
- {"Dataset_zero", 1},
- {"Group1", 0},
- {"Group1/Dataset_one", 1},
- {"Group1/Group2", 0},
- {"Group1/Group2/Dataset_two", 1},
- {"Group1/Group2/Type_two", 2},
- {"Group1/Type_one", 2},
- {"Type_zero", 2}
+ {".", H5O_TYPE_GROUP},
+ {"Dataset_zero", H5O_TYPE_DATASET},
+ {"Group1", H5O_TYPE_GROUP},
+ {"Group1/Dataset_one", H5O_TYPE_DATASET},
+ {"Group1/Group2", H5O_TYPE_GROUP},
+ {"Group1/Group2/Dataset_two", H5O_TYPE_DATASET},
+ {"Group1/Group2/Type_two", H5O_TYPE_NAMED_DATATYPE},
+ {"Group1/Type_one", H5O_TYPE_NAMED_DATATYPE},
+ {"Type_zero", H5O_TYPE_NAMED_DATATYPE}
};
static const obj_visit_t ovisit0_new[] = {
- {".", 0},
- {"Dataset_zero", 1},
- {"Group1", 0},
- {"Group1/Dataset_one", 1},
- {"Group1/Group2", 0},
- {"Group1/Group2/Dataset_two", 1},
- {"Group1/Group2/Type_two", 2},
- {"Group1/Type_one", 2},
- {"Type_zero", 2}
+ {".", H5O_TYPE_GROUP},
+ {"Dataset_zero", H5O_TYPE_DATASET},
+ {"Group1", H5O_TYPE_GROUP},
+ {"Group1/Dataset_one", H5O_TYPE_DATASET},
+ {"Group1/Group2", H5O_TYPE_GROUP},
+ {"Group1/Group2/Dataset_two", H5O_TYPE_DATASET},
+ {"Group1/Group2/Type_two", H5O_TYPE_NAMED_DATATYPE},
+ {"Group1/Type_one", H5O_TYPE_NAMED_DATATYPE},
+ {"Type_zero", H5O_TYPE_NAMED_DATATYPE}
};
static const obj_visit_t ovisit1_old[] = {
- {".", 0},
- {"Dataset_one", 1},
- {"Group2", 0},
- {"Group2/Dataset_two", 1},
- {"Group2/Type_two", 2},
- {"Group2/hard_zero", 0},
- {"Group2/hard_zero/Dataset_zero", 1},
- {"Group2/hard_zero/Type_zero", 2},
- {"Type_one", 2}
+ {".", H5O_TYPE_GROUP},
+ {"Dataset_one", H5O_TYPE_DATASET},
+ {"Group2", H5O_TYPE_GROUP},
+ {"Group2/Dataset_two", H5O_TYPE_DATASET},
+ {"Group2/Type_two", H5O_TYPE_NAMED_DATATYPE},
+ {"Group2/hard_zero", H5O_TYPE_GROUP},
+ {"Group2/hard_zero/Dataset_zero", H5O_TYPE_DATASET},
+ {"Group2/hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE},
+ {"Type_one", H5O_TYPE_NAMED_DATATYPE}
};
static const obj_visit_t ovisit1_new[] = {
- {".", 0},
- {"Dataset_one", 1},
- {"Group2", 0},
- {"Group2/Dataset_two", 1},
- {"Group2/Type_two", 2},
- {"Group2/hard_zero", 0},
- {"Group2/hard_zero/Dataset_zero", 1},
- {"Group2/hard_zero/Type_zero", 2},
- {"Type_one", 2}
+ {".", H5O_TYPE_GROUP},
+ {"Dataset_one", H5O_TYPE_DATASET},
+ {"Group2", H5O_TYPE_GROUP},
+ {"Group2/Dataset_two", H5O_TYPE_DATASET},
+ {"Group2/Type_two", H5O_TYPE_NAMED_DATATYPE},
+ {"Group2/hard_zero", H5O_TYPE_GROUP},
+ {"Group2/hard_zero/Dataset_zero", H5O_TYPE_DATASET},
+ {"Group2/hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE},
+ {"Type_one", H5O_TYPE_NAMED_DATATYPE}
};
static const obj_visit_t ovisit2_old[] = {
- {".", 0},
- {"Dataset_two", 1},
- {"Type_two", 2},
- {"hard_zero", 0},
- {"hard_zero/Dataset_zero", 1},
- {"hard_zero/Group1", 0},
- {"hard_zero/Group1/Dataset_one", 1},
- {"hard_zero/Group1/Type_one", 2},
- {"hard_zero/Type_zero", 2}
+ {".", H5O_TYPE_GROUP},
+ {"Dataset_two", H5O_TYPE_DATASET},
+ {"Type_two", H5O_TYPE_NAMED_DATATYPE},
+ {"hard_zero", H5O_TYPE_GROUP},
+ {"hard_zero/Dataset_zero", H5O_TYPE_DATASET},
+ {"hard_zero/Group1", H5O_TYPE_GROUP},
+ {"hard_zero/Group1/Dataset_one", H5O_TYPE_DATASET},
+ {"hard_zero/Group1/Type_one", H5O_TYPE_NAMED_DATATYPE},
+ {"hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}
};
static const obj_visit_t ovisit2_new[] = {
- {".", 0},
- {"Dataset_two", 1},
- {"Type_two", 2},
- {"hard_zero", 0},
- {"hard_zero/Dataset_zero", 1},
- {"hard_zero/Group1", 0},
- {"hard_zero/Group1/Dataset_one", 1},
- {"hard_zero/Group1/Type_one", 2},
- {"hard_zero/Type_zero", 2}
+ {".", H5O_TYPE_GROUP},
+ {"Dataset_two", H5O_TYPE_DATASET},
+ {"Type_two", H5O_TYPE_NAMED_DATATYPE},
+ {"hard_zero", H5O_TYPE_GROUP},
+ {"hard_zero/Dataset_zero", H5O_TYPE_DATASET},
+ {"hard_zero/Group1", H5O_TYPE_GROUP},
+ {"hard_zero/Group1/Dataset_one", H5O_TYPE_DATASET},
+ {"hard_zero/Group1/Type_one", H5O_TYPE_NAMED_DATATYPE},
+ {"hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}
};
typedef struct {
@@ -281,6 +316,37 @@ typedef struct {
/*-------------------------------------------------------------------------
+ * Function: fix_ext_filename
+ *
+ * Purpose: Internal function to append path to file name. It handles
+ * path name of Unix, Windows, and OpenVMS.
+ *
+ * Return: void
+ *
+ * Programmer: Raymond Lu
+ * 14 Jan. 2009
+ *-------------------------------------------------------------------------
+ */
+static void
+fix_ext_filename(char *path_name, char *cwd, const char *file_name)
+{
+ HDstrcpy(path_name, cwd);
+
+#ifdef H5_VMS
+ if(file_name[0] == '[') {
+ char *tmp = file_name;
+ path_name[strlen(cwd)-1] = '\0';
+ HDstrcat(path_name, ++tmp);
+ } else
+ HDstrcat(path_name, file_name);
+#else
+ HDstrcat(path_name, "/");
+ HDstrcat(path_name, file_name);
+#endif
+}
+
+
+/*-------------------------------------------------------------------------
* Function: mklinks
*
* Purpose: Build a file with assorted links.
@@ -688,7 +754,7 @@ long_links(hid_t fapl, hbool_t new_format)
if((gid = H5Gcreate2(fid, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Construct very long file name */
- if((objname = HDmalloc((size_t)(MAX_NAME_LEN + 1))) == NULL) TEST_ERROR
+ if((objname = (char *)HDmalloc((size_t)(MAX_NAME_LEN + 1))) == NULL) TEST_ERROR
for(u = 0; u < MAX_NAME_LEN; u++)
objname[u] = 'a';
objname[MAX_NAME_LEN] = '\0';
@@ -747,7 +813,6 @@ toomany(hid_t fapl, hbool_t new_format)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename[NAME_BUF_SIZE];
if(new_format)
@@ -821,7 +886,7 @@ toomany(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "hard21", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/hard21")) TEST_ERROR
/* Create object in hard-linked group */
@@ -847,7 +912,7 @@ toomany(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "soft16", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/soft16")) TEST_ERROR
/* Create object using soft links */
@@ -1675,7 +1740,6 @@ external_link_root(hid_t fapl, hbool_t new_format)
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
H5L_info_t linfo; /* Link information */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE];
char filename2[NAME_BUF_SIZE];
const char *file; /* File from external link */
@@ -1725,16 +1789,40 @@ external_link_root(hid_t fapl, hbool_t new_format)
goto error;
}
+ /* Create external link to object in first file */
+ /* (add a few extra '/'s to make certain library normalizes external link object names) */
+ if(H5Lcreate_external(filename1, "///", fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Check information for external link */
+ if(H5Lget_info(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error;
+ if(H5L_TYPE_EXTERNAL != linfo.type) {
+ H5_FAILED();
+ puts(" Unexpected object type - should have been an external link");
+ goto error;
+ }
+ if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR
+ if(HDstrcmp(file, filename1)) {
+ H5_FAILED();
+ puts(" External link file name incorrect");
+ goto error;
+ }
+ if(HDstrcmp(path, "/")) {
+ H5_FAILED();
+ puts(" External link path incorrect");
+ goto error;
+ }
+
/* Close and re-open file to ensure that data is written to disk */
if(H5Fclose(fid) < 0) TEST_ERROR
- if((fid = H5Fopen(filename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
/* Open object through external link */
if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/")) TEST_ERROR
/* Create object in external file */
@@ -1746,7 +1834,7 @@ external_link_root(hid_t fapl, hbool_t new_format)
/* Close external object (lets first file close) */
if(H5Gclose(gid) < 0) TEST_ERROR
- /* Create a new object using H5Gcreate2 through the external link
+ /* Create a new object using H5Gcreate2 through the external link
* directly
*/
if((gid = H5Gcreate2(fid, "ext_link/newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -1754,18 +1842,22 @@ external_link_root(hid_t fapl, hbool_t new_format)
/* Close file and group */
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) TEST_ERROR
-
+
+ /* Check that all file IDs have been closed */
+ if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR
+ if(H5F_sfile_assert_num(0) != 0) TEST_ERROR
+
/* Open first file again with read-only access and check on objects created */
- if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
/* Open objects created through external link */
if((gid = H5Gopen2(fid, "new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if((gid2 = H5Gopen2(fid, "newer_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check names */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/new_group")) TEST_ERROR
- if((name_len = H5Iget_name( gid2, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/newer_group")) TEST_ERROR
/* Close opened objects */
@@ -1775,10 +1867,14 @@ external_link_root(hid_t fapl, hbool_t new_format)
/* Close first file */
if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Check that all file IDs have been closed */
+ if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR
+ if(H5F_sfile_assert_num(0) != 0) TEST_ERROR
+
/* Verify that new objects can't be created through a read-only external
* link.
*/
- if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
H5E_BEGIN_TRY {
gid = H5Gcreate2(fid, "ext_link/readonly_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -1788,6 +1884,10 @@ external_link_root(hid_t fapl, hbool_t new_format)
/* Close second file again */
if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Check that all file IDs have been closed */
+ if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR
+ if(H5F_sfile_assert_num(0) != 0) TEST_ERROR
+
PASSED();
return 0;
@@ -1824,7 +1924,6 @@ external_link_path(hid_t fapl, hbool_t new_format)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE];
char filename2[NAME_BUF_SIZE];
@@ -1864,7 +1963,7 @@ external_link_path(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR
/* Create object in external file */
@@ -1881,13 +1980,13 @@ external_link_path(hid_t fapl, hbool_t new_format)
/* Open first file again and check on object created */
- if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
/* Open object created through external link */
if((gid = H5Gopen2(fid, "/A/B/C/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/A/B/C/new_group")) TEST_ERROR
/* Close opened object */
@@ -1933,7 +2032,6 @@ external_link_mult(hid_t fapl, hbool_t new_format)
hid_t fid = (-1), fid2 = (-1); /* File IDs */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE],
filename3[NAME_BUF_SIZE],
@@ -2011,7 +2109,7 @@ external_link_mult(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR
/* Create object in external file */
@@ -2028,13 +2126,13 @@ external_link_mult(hid_t fapl, hbool_t new_format)
/* Open first file again and check on object created */
- if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
/* Open object created through external link */
if((gid = H5Gopen2(fid, "/A/B/C/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/A/B/C/new_group")) TEST_ERROR
/* Close opened object */
@@ -2045,17 +2143,17 @@ external_link_mult(hid_t fapl, hbool_t new_format)
/* Open an object through external links */
- if((fid = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename4, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* The intermediate files should not stay open. Replace one of them with a new file. */
if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
if(H5Fclose(fid2) < 0) TEST_ERROR
- /* Open the other with write access and delete the external link in it */
+ /* Open the other with write access and delete the external link in it */
if((fid2 = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
if(H5Ldelete(fid2, "G/H/I", H5P_DEFAULT) < 0) TEST_ERROR
-
+
if(H5Fclose(fid2) < 0) TEST_ERROR
/* Cleanup */
@@ -2092,13 +2190,12 @@ external_link_mult(hid_t fapl, hbool_t new_format)
*-------------------------------------------------------------------------
*/
static int
-external_link_self(hid_t fapl, hbool_t new_format)
+external_link_self(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
{
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
hid_t lcpl_id = (-1); /* Link Creation Property List ID */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE];
char filename2[NAME_BUF_SIZE];
char filename3[NAME_BUF_SIZE];
@@ -2108,117 +2205,127 @@ external_link_self(hid_t fapl, hbool_t new_format)
else
TESTING("external link to self")
- /* Set up filename */
- h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
- h5_fixname(FILENAME[2], fapl, filename2, sizeof filename1);
- h5_fixname(FILENAME[3], fapl, filename3, sizeof filename1);
+ /* Skip test when using core VFD, since it doesn't re-open file when linking
+ * to same file.
+ */
+ if(HDstrcmp(env_h5_drvr, "core")) {
+ /* Set up filename */
+ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[2], fapl, filename2, sizeof filename1);
+ h5_fixname(FILENAME[3], fapl, filename3, sizeof filename1);
- /* Create file */
- if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create file */
+ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create an lcpl with intermediate group creation set */
- if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
- if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR
+ /* Create an lcpl with intermediate group creation set */
+ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR
- /* Create a series of groups within the file: /A/B and /X/Y/Z */
- if((gid = H5Gcreate2(fid, "A/B", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if((gid = H5Gcreate2(fid, "X/Y", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Create a series of groups within the file: /A/B and /X/Y/Z */
+ if((gid = H5Gcreate2(fid, "A/B", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "X/Y", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Pclose (lcpl_id) < 0) TEST_ERROR
+ if(H5Pclose (lcpl_id) < 0) TEST_ERROR
- /* Create external link to own root group*/
- if(H5Lcreate_external(filename1, "/X", fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Create external link to own root group*/
+ if(H5Lcreate_external(filename1, "/X", fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Open object through external link */
- if((gid = H5Gopen2(fid, "A/B/C/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Open object through external link */
+ if((gid = H5Gopen2(fid, "A/B/C/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
- if(HDstrcmp(objname, "/X")) TEST_ERROR
+ /* Check name */
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
+ if(HDstrcmp(objname, "/X")) TEST_ERROR
- /* Create object through external link */
- if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Create object through external link */
+ if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Close created group */
- if(H5Gclose(gid2) < 0) TEST_ERROR
+ /* Close created group */
+ if(H5Gclose(gid2) < 0) TEST_ERROR
- /* Close object opened through external link */
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Close object opened through external link */
+ if(H5Gclose(gid) < 0) TEST_ERROR
- /* Check on object created */
- if((gid = H5Gopen2(fid, "X/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Check on object created */
+ if((gid = H5Gopen2(fid, "X/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
- if(HDstrcmp(objname, "/X/new_group")) TEST_ERROR
+ /* Check name */
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
+ if(HDstrcmp(objname, "/X/new_group")) TEST_ERROR
- /* Close opened object */
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Close opened object */
+ if(H5Gclose(gid) < 0) TEST_ERROR
- /* Close first file */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close first file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Complicate things. Use this file as an intermediate file in a chain
- * of external links that will go: file2 -> file1 -> file1 -> file3
- */
+ /* Complicate things. Use this file as an intermediate file in a chain
+ * of external links that will go: file2 -> file1 -> file1 -> file3
+ */
- /* Create file2 with an external link to file1 */
- if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create file2 with an external link to file1 */
+ if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if(H5Lcreate_external(filename1, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename1, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Close file2 */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close file2 */
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Create file3 as a target */
- if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((gid = H5Gcreate2(fid, "end", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Create file3 as a target */
+ if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "end", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Open file1 and create an extlink pointing to file3 */
- if((fid=H5Fopen(filename1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Open file1 and create an extlink pointing to file3 */
+ if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
- if(H5Lcreate_external(filename3, "/", fid, "/X/Y/Z", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename3, "/", fid, "/X/Y/Z", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Close file1 */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close file1 */
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Re-open file2 and traverse through file1 (with its recursive extlink) to file3 */
- if((fid=H5Fopen(filename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Re-open file2 and traverse through file1 (with its recursive extlink) to file3 */
+ if((fid=H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
- if((gid = H5Gopen2(fid, "ext_link/B/C/Y/Z/end", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Create object through external link */
- if((gid2 = H5Gcreate2(gid, "newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gid = H5Gopen2(fid, "ext_link/B/C/Y/Z/end", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Cleanup */
- if(H5Gclose(gid2) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Create object through external link */
+ if((gid2 = H5Gcreate2(gid, "newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Open up file3 and make sure the object was created successfully */
- if((fid = H5Fopen(filename3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Cleanup */
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
- if((gid = H5Gopen2(fid, "end/newer_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Open up file3 and make sure the object was created successfully */
+ if((fid = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
+
+ if((gid = H5Gopen2(fid, "end/newer_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Cleanup */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD can't reopen same file through external link");
+ } /* end else */
- /* Cleanup */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Fclose(fid) < 0) TEST_ERROR
-
- PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Fclose (gid2);
- H5Fclose (gid);
- H5Pclose (lcpl_id);
- H5Fclose (fid);
+ H5Fclose(gid2);
+ H5Fclose(gid);
+ H5Pclose(lcpl_id);
+ H5Fclose(fid);
} H5E_END_TRY;
return -1;
} /* end external_link_self() */
@@ -2249,12 +2356,11 @@ external_link_self(hid_t fapl, hbool_t new_format)
*-------------------------------------------------------------------------
*/
static int
-external_link_pingpong(hid_t fapl, hbool_t new_format)
+external_link_pingpong(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
{
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */
@@ -2263,85 +2369,94 @@ external_link_pingpong(hid_t fapl, hbool_t new_format)
else
TESTING("external links back and forth")
- /* Set up filenames */
- h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1);
- h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2);
+ /* Skip test when using core VFD, since it doesn't re-open file when linking
+ * to same file.
+ */
+ if(HDstrcmp(env_h5_drvr, "core")) {
+ /* Set up filenames */
+ h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2);
- /* Create first file */
- if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create first file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create external links for chain */
- if(H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lcreate_external(filename2, "/link4", fid, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lcreate_external(filename2, "/link6", fid, "link5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Create external links for chain */
+ if(H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "/link4", fid, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "/link6", fid, "link5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Create final object */
- if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Create final object */
+ if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
- /* Close file */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Create second file */
- if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create second file */
+ if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create external links for chain */
- if(H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lcreate_external(filename1, "/link5", fid, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lcreate_external(filename1, "/final", fid, "link6", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Create external links for chain */
+ if(H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename1, "/link5", fid, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename1, "/final", fid, "link6", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Close file */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Open first file */
- if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ /* Open first file */
+ if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
- /* Open object through external link */
- if((gid = H5Gopen2(fid, "link1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Open object through external link */
+ if((gid = H5Gopen2(fid, "link1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
- if(HDstrcmp(objname, "/final")) TEST_ERROR
+ /* Check name */
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
+ if(HDstrcmp(objname, "/final")) TEST_ERROR
- /* Create object in external file */
- if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Create object in external file */
+ if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Close group in external file */
- if(H5Gclose(gid2) < 0) TEST_ERROR
+ /* Close group in external file */
+ if(H5Gclose(gid2) < 0) TEST_ERROR
- /* Close external object (lets first file close) */
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Close external object (lets first file close) */
+ if(H5Gclose(gid) < 0) TEST_ERROR
- /* Close first file */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close first file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
- /* Open first file again and check on object created */
- if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Open first file again and check on object created */
+ if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
- /* Open object created through external link */
- if((gid = H5Gopen2(fid, "/final/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Open object created through external link */
+ if((gid = H5Gopen2(fid, "/final/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
- if(HDstrcmp(objname, "/final/new_group")) TEST_ERROR
+ /* Check name */
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
+ if(HDstrcmp(objname, "/final/new_group")) TEST_ERROR
- /* Close opened object */
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Close opened object */
+ if(H5Gclose(gid) < 0) TEST_ERROR
- /* Close first file */
- if(H5Fclose(fid) < 0) TEST_ERROR
+ /* Close first file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD can't reopen same file through external link");
+ } /* end else */
- PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Gclose (gid2);
- H5Gclose (gid);
- H5Fclose (fid);
+ H5Gclose(gid2);
+ H5Gclose(gid);
+ H5Fclose(fid);
} H5E_END_TRY;
return -1;
} /* end external_link_pingpong() */
@@ -2390,7 +2505,6 @@ external_link_toomany(hid_t fapl, hbool_t new_format)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */
@@ -2464,7 +2578,7 @@ external_link_toomany(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "link3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/final")) TEST_ERROR
/* Create object in external file */
@@ -2587,15 +2701,15 @@ external_link_dangling(hid_t fapl, hbool_t new_format)
/*-------------------------------------------------------------------------
* Function: external_link_env: test 1
*
- * Purpose:
+ * Purpose:
* 1. target link: "extlinks1"
* 2. main file: "extlinks0"
* 3. target file: "tmp/extlinks1"
* 4. The environment variable "HDF5_EXT_PREFIX" should be set to ".:tmp"
- * Should be able to access the target file in tmp directory through searching
+ * Should be able to access the target file in tmp directory through searching
* the pathnames set in HDF5_EXT_PREFIX.
* This test will be skipped if HDF5_EXT_PREFIX is not set as expected.
- *
+ *
*
* Return: Success: 0
* Failure: -1
@@ -2635,7 +2749,7 @@ external_link_env(hid_t fapl, hbool_t new_format)
/* set up name for external linked target file: "extlinks1" */
h5_fixname(FILENAME[14], fapl, filename2, sizeof filename2);
- if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
+ if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
TEST_ERROR
/* set up name for target file: "tmp/extlinks1" */
@@ -2691,9 +2805,9 @@ external_link_env(hid_t fapl, hbool_t new_format)
* 2. main file: "extlinks0"
* 3. target file: "tmp/extlinks2"
* 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp"
- * Should be able to access the target file in tmp directory via the prefix set
+ * Should be able to access the target file in tmp directory via the prefix set
* by H5Pset_elink_prefix()
- *
+ *
*
* Return: Success: 0
* Failure: -1
@@ -2816,20 +2930,19 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format)
/* set up name for external linked target file: "extlinks3" */
h5_fixname(FILENAME[18], fapl, filename2, sizeof filename2);
/* set up name for target file: "tmp/extlinks3" */
- h5_fixname(FILENAME[19], fapl, filename3, sizeof filename3);
+ h5_fixname(FILENAME[19], fapl, filename3, sizeof filename3);
/* create tmp directory and get current working directory path */
if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
TEST_ERROR
- /*
- * set up name for main file:
+ /*
+ * set up name for main file:
* Linux: "/CWD/tmp/extlinks0"
- * Window: "<cur drive>:/CWD/tmp/extlinks0"
+ * Window: "<cur drive>:/CWD/tmp/extlinks0"
+ * OpenVMS: "<cur disk>$<partition>:[CWD.tmp]extlinks0"
*/
- HDstrcpy(tmpname, cwdpath);
- HDstrcat(tmpname, "/");
- HDstrcat(tmpname, FILENAME[13]);
+ fix_ext_filename(tmpname, cwdpath, FILENAME[13]);
h5_fixname(tmpname, fapl, filename1, sizeof filename1);
/* Create the target file */
@@ -2967,7 +3080,7 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format)
* 2. main file: Linux:"/CWD/tmp/extlinks0"; Window: "<cur drive>:/CWD/tmp/extlinks0"
* 2. target file: "extlinks5"
* Should be able to access the target file in the current working directory
- *
+ *
*
* Return: Success: 0
* Failure: -1
@@ -3001,15 +3114,13 @@ external_link_cwd(hid_t fapl, hbool_t new_format)
if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
TEST_ERROR
-
- /*
- * set up name for main file:
- * Linux: "/CWD/tmp/extlinks0"
+
+ /*
+ * set up name for main file:
+ * Linux: "/CWD/tmp/extlinks0"
* Windows: "<cur drive>:/CWD/tmp/extlinks0"
- */
- HDstrcpy(tmpname, cwdpath);
- HDstrcat(tmpname, "/");
- HDstrcat(tmpname, FILENAME[13]);
+ */
+ fix_ext_filename(tmpname, cwdpath, FILENAME[13]);
h5_fixname(tmpname, fapl, filename1, sizeof filename1);
/* Create the target file */
@@ -3055,6 +3166,7 @@ external_link_cwd(hid_t fapl, hbool_t new_format)
} /* end external_link_cwd() */
+
/*-------------------------------------------------------------------------
* Function: external_link_abstar: test 6
*
@@ -3094,16 +3206,14 @@ external_link_abstar(hid_t fapl, hbool_t new_format)
/* create tmp directory and get current working directory path */
if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
- TEST_ERROR
-
- /*
- * set up name for external linked target file:
- * Linux: "/CWD/tmp/extlinks6"
+ TEST_ERROR
+
+ /*
+ * set up name for external linked target file:
+ * Linux: "/CWD/tmp/extlinks6"
* Windows: "<cur drive>:/CWD/tmp/extlinks6"
*/
- HDstrcpy(tmpname, cwdpath);
- HDstrcat(tmpname, "/");
- HDstrcat(tmpname, FILENAME[23]);
+ fix_ext_filename(tmpname, cwdpath, FILENAME[23]);
h5_fixname(tmpname, fapl, filename2, sizeof filename2);
/* set up name for target file: "tmp/extlinks6" */
@@ -3195,14 +3305,12 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format)
if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
TEST_ERROR
- /*
- * set up name for external linked target file:
- * Linux: "/CWD/tmp/extlinks7"
+ /*
+ * set up name for external linked target file:
+ * Linux: "/CWD/tmp/extlinks7"
* Windows: "<cur drive>:/CWD/tmp/extlinks7"
*/
- HDstrcpy(tmpname, cwdpath);
- HDstrcat(tmpname, "/");
- HDstrcat(tmpname, FILENAME[25]);
+ fix_ext_filename(tmpname, cwdpath, FILENAME[25]);
h5_fixname(tmpname, fapl, filename2, sizeof filename2);
/* Create the target file */
@@ -3291,8 +3399,8 @@ external_link_reltar(hid_t fapl, hbool_t new_format)
h5_fixname(FILENAME[26], fapl, filename2, sizeof filename2);
/* Create the target file */
- if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* closing for target file */
if(H5Gclose(gid) < 0) TEST_ERROR
@@ -3300,25 +3408,17 @@ external_link_reltar(hid_t fapl, hbool_t new_format)
/* Create the main file */
- if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create external link to target file */
- if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "///A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Open object through external link */
- H5E_BEGIN_TRY {
- gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
- } H5E_END_TRY;
-
- /*
- * Should be able to find the target file from:
- * main file's current working directory + pathname of external linked targetfile
- */
- if (gid < 0) {
+ if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) {
H5_FAILED();
puts(" Should have found the file in tmp directory.");
goto error;
- }
+ } /* end if */
/* closing for main file */
if(H5Gclose(gid) < 0) TEST_ERROR
@@ -3334,11 +3434,12 @@ external_link_reltar(hid_t fapl, hbool_t new_format)
} H5E_END_TRY;
return -1;
} /* end external_link_reltar() */
+
/*-------------------------------------------------------------------------
* Function: external_link_chdir: test 9
*
- * Purpose:
+ * Purpose:
* 1. target link: "extlinks9"
* 2. main file: "extlinks0"
* 3. target file" "tmp/extlinks9"
@@ -3405,8 +3506,8 @@ external_link_chdir(hid_t fapl, hbool_t new_format)
} H5E_END_TRY;
if (HDchdir("..") < 0) TEST_ERROR
-
- /*
+
+ /*
* Should be able to find the target file from:
* main file's current working directory + pathname of external linked targetfile
*/
@@ -3432,13 +3533,821 @@ external_link_chdir(hid_t fapl, hbool_t new_format)
} /* end external_link_chdir() */
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_fapl1: test 10
+ *
+ * Purpose: To verify that the external linked target file with physical layout
+ * different from the parent can be successfully opened.
+ *
+ * 1. target link: "extlinks16"
+ * 2. target file: "extlinks16"
+ * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: "<cur drive>:/CWD/tmp/extlinks0"
+ * 4. Create target file A to be a "family" file: extlinks16A
+ * 4. Create target file B to be a "multi" file: extlinks16B
+ * 5. Create external link from main file to target file A: ext_linkA->extlinks16A:/A
+ * 5. Create external link from main file to target file B: ext_linkB->extlinks16B:/B
+ * 6. Should succeed in opening the target object: ext_extA
+ * 6. Should succeed in opening the target object: ext_extB
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Sept. 12, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_fapl1(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid=(-1);
+ hid_t fidA=(-1), fidB=(-1);
+ hid_t gidA=(-1), gidB=(-1);
+ hid_t oidA=(-1), oidB=(-1);
+ char filename1[NAME_BUF_SIZE],
+ filename2A[NAME_BUF_SIZE],
+ filename2B[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+ hid_t fam_fapl=-1, multi_fapl=-1;
+ hid_t lapl_idA=-1, lapl_idB=-1;
+ H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES];
+ hid_t memb_fapl[H5FD_MEM_NTYPES];
+ char sv[H5FD_MEM_NTYPES][500];
+ const char *memb_name[H5FD_MEM_NTYPES];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+
+ if(new_format)
+ TESTING("H5Pset/get_elink_fapl() with different physical layouts (w/new group format)")
+ else
+ TESTING("H5Pset/get_elink_fapl() with different physical layouts")
+
+ if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) ||
+ (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
+ TEST_ERROR
+
+ /*
+ * set up name for main file:
+ * Linux: "/CWD/tmp/extlinks0"
+ * Windows: "<cur drive>:/CWD/tmp/extlinks0"
+ */
+ fix_ext_filename(tmpname, cwdpath, FILENAME[13]);
+ h5_fixname(tmpname, fapl, filename1, sizeof filename1);
+
+ /* create "family" fapl */
+ fam_fapl = h5_fileaccess();
+ if(H5Pset_fapl_family(fam_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* set up name for external linked target file A: "extlinks16A" */
+ /* set up name for target file A: "extlinks16A" */
+ h5_fixname(FILENAME[37], fam_fapl, filename2A, sizeof filename2A);
+
+ /* settings for multi file */
+ HDmemset(memb_map, 0, sizeof memb_map);
+ HDmemset(memb_fapl, 0, sizeof memb_fapl);
+ HDmemset(memb_name, 0, sizeof memb_name);
+ HDmemset(memb_addr, 0, sizeof memb_addr);
+ HDmemset(sv, 0, sizeof sv);
+
+ for (mt = 0; mt < H5FD_MEM_NTYPES; mt++) {
+ memb_map[mt] = H5FD_MEM_SUPER;
+ memb_fapl[mt] = H5P_DEFAULT;
+ }
+ memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW;
+ memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE;
+ memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP;
+ memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP;
+
+ sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's');
+ memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER];
+ memb_addr[H5FD_MEM_SUPER] = 0;
+
+ sprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b');
+ memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE];
+ memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6;
+
+ sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r');
+ memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW];
+ memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3;
+
+ sprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g');
+ memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP];
+ memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2;
+
+ sprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l');
+ memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP];
+ memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX*2/3;
+
+ sprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o');
+ memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR];
+ memb_addr[H5FD_MEM_OHDR] = HADDR_MAX*5/6;
+
+ /* create "multi" fapl */
+ multi_fapl = h5_fileaccess();
+ if(H5Pset_fapl_multi(multi_fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* set up name for external linked target file B: "extlinks16B" */
+ /* set up name for target file B: "extlinks16B" */
+ h5_fixname(FILENAME[38], multi_fapl, filename2B, sizeof filename2B);
+
+ /* Create target file A to be a "family" file */
+ if((fidA=H5Fcreate(filename2A, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR
+ if((gidA=H5Gcreate2(fidA, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create target file B to be a "multi" file */
+ if((fidB=H5Fcreate(filename2B, H5F_ACC_TRUNC, H5P_DEFAULT, multi_fapl)) < 0) TEST_ERROR
+ if((gidB=H5Gcreate2(fidB, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing for target files */
+ if(H5Gclose(gidA) < 0) TEST_ERROR
+ if(H5Gclose(gidB) < 0) TEST_ERROR
+ if(H5Fclose(fidA) < 0) TEST_ERROR
+ if(H5Fclose(fidB) < 0) TEST_ERROR
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file A:/A */
+ if(H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ /* Create external link to target file B:/B */
+ if(H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Set file access property list for link access to use the family driver */
+ if((lapl_idA = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(lapl_idA, fam_fapl) < 0) TEST_ERROR
+
+ /* open target object A */
+ oidA = H5Oopen(fid, "ext_linkA", lapl_idA);
+
+ /* should succeed in opening the target object A in the current working directory */
+ if (oidA < 0) {
+ H5_FAILED();
+ puts(" Should succeed in opening family target file A in current working directory");
+ goto error;
+ }
+
+ /* Set file access property list for link access to use the multi driver */
+ if((lapl_idB = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(lapl_idB, multi_fapl) < 0) TEST_ERROR
+
+ /* open target object B */
+ oidB = H5Oopen(fid, "ext_linkB", lapl_idB);
+
+ /* should succeed in opening the target object B in the current working directory */
+ if (oidB < 0) {
+ H5_FAILED();
+ puts(" Should succeed in opening multi target file B in current working directory");
+ goto error;
+ }
+
+ /* closing */
+ if(H5Pclose(lapl_idA) < 0) TEST_ERROR
+ if(H5Pclose(lapl_idB) < 0) TEST_ERROR
+ if(H5Pclose(fam_fapl) < 0) TEST_ERROR
+ if(H5Pclose(multi_fapl) < 0) TEST_ERROR
+ if(H5Oclose(oidA) < 0) TEST_ERROR
+ if(H5Oclose(oidB) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose (lapl_idA);
+ H5Pclose (lapl_idB);
+ H5Pclose (fam_fapl);
+ H5Pclose (multi_fapl);
+ H5Gclose (gidA);
+ H5Gclose (gidB);
+ H5Oclose (oidA);
+ H5Oclose (oidB);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_fapl1() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_fapl2: test 11
+ *
+ * Purpose: To verify that processing done to the external linked target object is
+ * correctly handled when the parent and target files have the same
+ * physical layout but different access methods.
+ *
+ * 1. target link: "extlinks17"
+ * 2. target file: "extlinks17"
+ * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: "<cur drive>:/CWD/tmp/extlinks0"
+ * 4. Create target file to be a "core" file:/A/Dataset
+ * 5. Create external link from main file to target file:ext_link->target file:/A/Dataset
+ * 6. Set the file access property list of the link access to use "core" file without
+ * backing store
+ * 6. Should succeed in opening the target dataset: ext_link
+ * 7. Write data to the target dataset
+ * 8. On closing, the file size of target should be the same as before since
+ * it is opened without backing store.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Sept. 12, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group IDs */
+ hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1;
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+ hsize_t dims[2];
+ int points[NUM40][NUM40];
+ h5_stat_size_t filesize, new_filesize;
+ int i, j, n;
+
+ if(new_format)
+ TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)")
+ else
+ TESTING("H5Pset/get_elink_fapl() with same physical layout")
+
+ if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) ||
+ (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
+ TEST_ERROR
+
+ /*
+ * set up name for main file:
+ * Linux: "/CWD/tmp/extlinks0"
+ * Windows: "<cur drive>:/CWD/tmp/extlinks0"
+ */
+ fix_ext_filename(tmpname, cwdpath, FILENAME[13]);
+ h5_fixname(tmpname, fapl, filename1, sizeof filename1);
+
+ /* create fapl for the target file to be a "core" file */
+ core_fapl = h5_fileaccess();
+ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
+ TEST_ERROR
+
+ /* set up name for external linked target file: "extlinks17" */
+ /* set up name for target file: "extlinks17" */
+ h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2);
+
+ /* Create the target file to be a "core" file */
+ if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ dims[0] = NUM40;
+ dims[1] = NUM40;
+ if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
+
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR;
+
+ /* create "Dataset" in group "A" of target file */
+ if((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing for target file */
+ if(H5Pclose(dcpl) < 0) TEST_ERROR
+ if(H5Sclose(space) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* get size of target file */
+ filesize = h5_get_file_size(filename2, core_fapl);
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file: ext_link->extlinks17:/A/Dataset */
+ if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* create fapl to be a "core" file without backing store */
+ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0)
+ TEST_ERROR
+
+ /* Set file access property list for link access to use the "core" driver */
+ if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(dapl_id, core_fapl) < 0) TEST_ERROR
+
+ /* try to open the external linked target dataset */
+ did = H5Dopen2(fid, "ext_link", dapl_id);
+ if(did < 0) {
+ H5_FAILED();
+ puts(" Should succeed in opening the target dataset");
+ goto error;
+ }
+
+ /* Initialize the dataset */
+ for(i = n = 0; i < NUM40; i++)
+ for(j = 0; j < NUM40; j++)
+ points[i][j] = n++;
+
+ /* Write the data to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ TEST_ERROR
+
+ if(H5Pclose(dapl_id) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ new_filesize = h5_get_file_size(filename2, core_fapl);
+
+ /* the file size should remain the same since there is no backing store */
+ if(new_filesize != filesize) TEST_ERROR
+
+ if(H5Pclose(core_fapl) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ H5Dclose(dset);
+ H5Pclose(core_fapl);
+ H5Pclose(dapl_id);
+ H5Dclose(did);
+ H5Gclose(gid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_fapl2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_fapl3: test 12
+ *
+ * Purpose: To verify that the file access property list for link access is
+ * set and closed correctly.
+ *
+ * 1. Create fapl for core driver
+ * 2. Create fapl for stdio driver
+ * 3. Set link access's fapl to use stdio driver
+ * 4. Verify that link access's fapl is the stdio driver
+ * 5. Reset the link access' fapl to use core driver
+ * 6. H5Pcopy() the link access
+ * 7. Get the fapl property value of the original link access
+ * 8. Close the original link access
+ * 9. H5Pclose() fapl should fail since closing in step #8 should also close its fapl
+ * 10. Verify that the copied link access's fapl is the core driver
+ * 11. Get the fapl property value of the copied link access
+ * 12. H5Premove() the fapl property from the copied link access
+ * 13. H5Pclose() fapl set in the copied link access should fail since the
+ * removal in #12 should also close its fapl
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Sept. 12, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_fapl3(hbool_t new_format)
+{
+ hid_t core_fapl = -1, stdio_fapl = -1;
+ hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl;
+ int ret;
+
+ if(new_format)
+ TESTING("H5Pset/get_fapl() (w/new group format)")
+ else
+ TESTING("H5Pset/get_fapl()")
+
+ /* create fapl for the target file to be a "core" file */
+ core_fapl = h5_fileaccess();
+ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
+ TEST_ERROR
+
+ stdio_fapl = h5_fileaccess();
+ if(H5Pset_fapl_stdio(stdio_fapl) < 0)
+ TEST_ERROR
+
+ /* Set file access property list for link access to use the "stdio" driver */
+ if((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(lapl_id, stdio_fapl) < 0) TEST_ERROR
+
+ /* Verify that the driver for the link's fapl is the "stdio" driver */
+ if((l_fapl = H5Pget_elink_fapl(lapl_id)) < 0) TEST_ERROR
+ if(H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR
+ if(H5Pclose(l_fapl) < 0) TEST_ERROR
+
+ /* Set file access property list for link access to use the "core" driver */
+ if(H5Pset_elink_fapl(lapl_id, core_fapl) < 0) TEST_ERROR
+
+ /* Make a copy of the link access property */
+ if((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR
+
+ /* get the fapl set in lapl_id */
+ if(H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
+ if(H5Pclose(lapl_id) < 0) TEST_ERROR
+
+ /* Try closing out_fapl should fail since H5Pclose(lapl_id) should also close its fapl */
+ H5E_BEGIN_TRY {
+ ret = H5Pclose(out_fapl);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+
+ /* Verify that the driver for the copied link's fapl is the "core" driver */
+ if((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) TEST_ERROR
+ if(H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR
+
+ /* get the fapl set in new_lapl_id */
+ if(H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
+ if(H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR
+
+ /* Try closing out_fapl should fail since the property is removed from new_lapl_id */
+ H5E_BEGIN_TRY {
+ ret = H5Pclose(out_fapl);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+
+ if(H5Pclose(l_fapl) < 0) TEST_ERROR
+ if(H5Pclose(new_lapl_id) < 0) TEST_ERROR
+ if(H5Pclose(core_fapl) < 0) TEST_ERROR
+ if(H5Pclose(stdio_fapl) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(l_fapl);
+ H5Pclose(lapl_id);
+ H5Pclose(new_lapl_id);
+ H5Pclose(core_fapl);
+ H5Pclose(stdio_fapl);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_fapl3() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_acc_flags
+ *
+ * Purpose: Verify functionality of H5P_set/get_elink_acc_flags
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Jan. 5, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
+{
+ hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1;
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE];
+ unsigned flags;
+
+ if(new_format)
+ TESTING("H5Pset/get_elink_acc_flags() (w/new group format)")
+ else
+ TESTING("H5Pset/get_elink_acc_flags()")
+
+ /* Create parent and target files, and external link */
+ h5_fixname(FILENAME[40], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[41], fapl, filename2, sizeof filename2);
+ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close file2, leave file1 open (should be read-write) */
+ if(H5Fclose(file2) < 0) TEST_ERROR
+
+ /* Create new gapl, and set elink access flags to be H5F_ACC_RDONLY */
+ if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) TEST_ERROR
+
+ /* Verify "get" routine functionality */
+ if(H5Pget_elink_acc_flags(gapl, &flags) < 0) TEST_ERROR
+ if(flags != H5F_ACC_RDONLY) TEST_ERROR
+
+ /* Attempt to create a group through the external link using gapl (should fail) */
+ H5E_BEGIN_TRY {
+ group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl);
+ } H5E_END_TRY;
+ if(group != FAIL) TEST_ERROR
+
+ /* Close file1 and reopen with read only access */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* Set elink access flags on gapl to be H5F_ACC_RDWR */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) TEST_ERROR
+
+ /* Create a group through the external link using gapl (should succeed) */
+ if((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
+
+ /* Unset elink access flags on gapl */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR
+
+ /* Attempt to create a group through the external link using gapl (should fail) */
+ H5E_BEGIN_TRY {
+ subgroup = H5Gcreate2(file1, "/ext_link/group/subgroup", H5P_DEFAULT, H5P_DEFAULT, gapl);
+ } H5E_END_TRY;
+ if(subgroup != FAIL) TEST_ERROR
+
+ /* Close file1 and group */
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(H5Fclose(file1) < 0) TEST_ERROR
+
+ /* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */
+ H5E_BEGIN_TRY {
+ file1 = H5Fcreate(filename1, H5F_ACC_DEFAULT, H5P_DEFAULT, fapl);
+ } H5E_END_TRY;
+ if(file1 != FAIL) TEST_ERROR
+ H5E_BEGIN_TRY {
+ file1 = H5Fcreate(filename1, H5F_ACC_TRUNC | H5F_ACC_DEFAULT, H5P_DEFAULT, fapl);
+ } H5E_END_TRY;
+ if(file1 != FAIL) TEST_ERROR
+ H5E_BEGIN_TRY {
+ file1 = H5Fopen(filename1, H5F_ACC_DEFAULT, fapl);
+ } H5E_END_TRY;
+ if(file1 != FAIL) TEST_ERROR
+ H5E_BEGIN_TRY {
+ file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_DEFAULT, fapl);
+ } H5E_END_TRY;
+ if(file1 != FAIL) TEST_ERROR
+
+ /* Close gapl */
+ if(H5Pclose(gapl) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose(group);
+ H5Gclose(subgroup);
+ H5Fclose(file1);
+ H5Fclose(file2);
+ H5Pclose(gapl);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_acc_flags() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_cb
+ *
+ * Purpose: Verify functionality of H5P_set/get_elink_cb
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Jan. 5, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+ /* User data structure for callback function */
+typedef struct {
+ const char *parent_file; /* Expected parent file name */
+ const char *target_file; /* Expected target file name */
+ hid_t base_fapl; /* Base fapl for family driver */
+ hsize_t fam_size; /* Size of family files */
+ int code; /* Code to control the actions taken by the callback */
+} set_elink_cb_t;
+
+/* Callback function */
+static herr_t
+external_set_elink_cb_cb(const char *parent_file, const char *parent_group,
+ const char *target_file, const char *target_obj, unsigned *flags,
+ hid_t fapl, void *_op_data)
+{
+ set_elink_cb_t *op_data = (set_elink_cb_t *)_op_data;
+
+ /* Verify file and object names are correct */
+ if (HDstrcmp(parent_file, op_data->parent_file)) return FAIL;
+ if (HDstrcmp(parent_group, "/group1")) return FAIL;
+ if (HDstrcmp(target_file, op_data->target_file)) return FAIL;
+ if (HDstrcmp(target_obj, "/")) return FAIL;
+
+ /* Set flags to be read-write */
+ *flags = (*flags & ~H5F_ACC_RDONLY) | H5F_ACC_RDWR;
+
+ /* Set family file driver on fapl */
+ if (H5Pset_fapl_family(fapl, op_data->fam_size, op_data->base_fapl) < 0) return FAIL;
+
+ /* Codes to cause an invalid condition (and verify that an error is issued */
+ if (op_data->code == 1)
+ return FAIL;
+ if (op_data->code == 2)
+ *flags = H5F_ACC_DEFAULT;
+
+ return 0;
+}
+
+/* Main test function */
+static int
+external_set_elink_cb(hid_t fapl, hbool_t new_format)
+{
+ hid_t file1 = -1, file2 = -1, group = -1, gapl = -1, fam_fapl = -1, ret_fapl = -1, base_driver;
+ set_elink_cb_t op_data,
+ *op_data_p;
+ H5L_elink_traverse_t cb;
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE];
+ unsigned flags;
+
+ if(new_format)
+ TESTING("H5Pset/get_elink_cb() (w/new group format)")
+ else
+ TESTING("H5Pset/get_elink_cb()")
+
+ /* Build user data for callback */
+ op_data.parent_file = filename1;
+ op_data.target_file = filename2;
+ /* Core file driver has issues when used as the member file driver for a family file */
+ /* Family file driver cannot be used with family or multi drivers for member files */
+ /* Also disable parellel member drivers, because IS_H5FD_MPI whould report FALSE, causing problems */
+ base_driver = H5Pget_driver(fapl);
+ op_data.base_fapl = (base_driver == H5FD_FAMILY || base_driver == H5FD_MULTI
+ || base_driver == H5FD_MPIO || base_driver == H5FD_MPIPOSIX
+ || base_driver == H5FD_CORE) ? H5P_DEFAULT : fapl;
+ op_data.fam_size = ELINK_CB_FAM_SIZE;
+ op_data.code = 0;
+
+ /* Create family fapl */
+ if ((fam_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
+ if (H5Pset_fapl_family(fam_fapl, op_data.fam_size, op_data.base_fapl) < 0) TEST_ERROR
+
+ /* Create parent and target files, group, and external link */
+ h5_fixname(FILENAME[42], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[43], fam_fapl, filename2, sizeof filename2);
+ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR
+ if((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close files and group */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
+ if(H5Gclose(group) < 0) TEST_ERROR
+
+ /* Create new gapl, and set elink callback */
+ if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) TEST_ERROR
+
+ /* Verify "get" routine functionality */
+ if(H5Pget_elink_cb(gapl, &cb, (void **) &op_data_p) < 0) TEST_ERROR
+ if(cb != external_set_elink_cb_cb) TEST_ERROR
+ if(op_data_p != &op_data) TEST_ERROR
+
+ /* Open file1 with read only access */
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* Create a group through the external link using gapl */
+ if((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
+
+ /* Verify that the correct parameters have been set on file2 (somewhat
+ * redundant as the library would be unable to create the group otherwise)
+ */
+ if((file2 = H5Iget_file_id(group)) < 0) TEST_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) TEST_ERROR
+ if(!(flags & H5F_ACC_RDWR)) TEST_ERROR
+ if((ret_fapl = H5Fget_access_plist(file2)) < 0) TEST_ERROR
+ if(H5FD_FAMILY != H5Pget_driver(ret_fapl)) TEST_ERROR
+
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
+ if(H5Pclose(ret_fapl) < 0) TEST_ERROR
+ if(H5Pclose(fam_fapl) < 0) TEST_ERROR
+
+ /* Modify the user data structure to cause the callback to fail next time */
+ op_data.code = 1;
+
+ /* Attempt to reopen group2 (should fail) */
+ H5E_BEGIN_TRY {
+ group = H5Gopen2(file1, "/group1/ext_link/group2", gapl);
+ } H5E_END_TRY;
+ if(group != FAIL) TEST_ERROR
+
+ /* Modify the user data structure to cause the callback to return invalid flags */
+ op_data.code = 2;
+
+ /* Attempt to reopen group2 (should fail) */
+ H5E_BEGIN_TRY {
+ group = H5Gopen2(file1, "/group1/ext_link/group2", gapl);
+ } H5E_END_TRY;
+ if(group != FAIL) TEST_ERROR
+
+ /* Close */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ if(H5Pclose(gapl) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose(group);
+ H5Fclose(file1);
+ H5Fclose(file2);
+ H5Pclose(gapl);
+ H5Pclose(ret_fapl);
+ H5Pclose(fam_fapl);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_reset_register
+ *
+ * Purpose: Check that external links are registered after the library
+ * is reset.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Apr. 9, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_reset_register(void)
+{
+ hid_t file;
+ char filename[NAME_BUF_SIZE];
+
+ TESTING("external links are registered after reset")
+
+ /* Create and close file */
+ h5_fixname(FILENAME[44], H5P_DEFAULT, filename, sizeof filename);
+ if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fclose(file) < 0) TEST_ERROR
+
+ /* Reset the library */
+ H5close();
+
+ /* Re open file */
+ if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create an external link */
+ if (H5Lcreate_external("some_file", "some_obj", file, "ext_link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close file */
+ if (H5Fclose(file) < 0) TEST_ERROR
+
+ /* Try again to make sure the previous H5Lcreate_external call does not
+ * affect the ability to reset */
+ H5close();
+ if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Lcreate_external("another_file", "another_obj", file, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if (H5Fclose(file) < 0) TEST_ERROR
+
+ if(HDremove(filename) != 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_reset_register() */
+
+
#ifdef H5_HAVE_WINDOW_PATH
/*-------------------------------------------------------------------------
* Function: external_link_win1
*
- * Purpose:
+ * Purpose:
* 1. target link: "/CWD/tmp/extlinks10"
* 2. main file: "extlinks0"
* 3. target file: "extlinks10"
@@ -3474,8 +4383,8 @@ external_link_win1(hid_t fapl, hbool_t new_format)
h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1);
if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)
- TEST_ERROR
-
+ TEST_ERROR
+
/* set up name for target link: "/CWD/tmp/extlinks10" */
HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it rel drive but absolute path */
HDstrcat(tmpname, "/");
@@ -3525,13 +4434,13 @@ external_link_win1(hid_t fapl, hbool_t new_format)
H5Fclose (fid);
} H5E_END_TRY;
return -1;
-} /* end external_link_win2() */
+} /* end external_link_win1() */
/*-------------------------------------------------------------------------
* Function: external_link_win2
*
- * Purpose:
+ * Purpose:
* 1. target link: "/CWD/tmp/extlinks11"
* 2. main file: "extlinks0"
* 3. target file: "tmp/extlinks11"
@@ -3568,8 +4477,8 @@ external_link_win2(hid_t fapl, hbool_t new_format)
/* create tmp directory and get current working directory path */
if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
- TEST_ERROR
-
+ TEST_ERROR
+
/* set up name for target link: "/CWD/tmp/extlinks11" */
HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it relative drive but absolute path */
HDstrcat(tmpname, "/");
@@ -3625,7 +4534,7 @@ external_link_win2(hid_t fapl, hbool_t new_format)
/*-------------------------------------------------------------------------
* Function: external_link_win3
*
- * Purpose:
+ * Purpose:
* 1. target link: "<cur drive>:tmp/extlinks12"
* 2. main file: "extlinks0"
* 3. target file: "tmp/extlinks12"
@@ -3717,7 +4626,7 @@ external_link_win3(hid_t fapl, hbool_t new_format)
/*-------------------------------------------------------------------------
* Function: external_link_win4
*
- * Purpose:
+ * Purpose:
* 1. target link: "<cur drive>:extlinks13"
* 2. main file: "<cur-drive>:tmp/extlinks0"
* 3. target file: tmp/extlinks13
@@ -3807,7 +4716,7 @@ external_link_win4(hid_t fapl, hbool_t new_format)
/*-------------------------------------------------------------------------
* Function: external_link_win5
*
- * Purpose:
+ * Purpose:
* 1. target link: "<cur drive+1>:tmp/extlinks14"
* 2. main file: "/CWD/extlinks0"
* 3. target file: "tmp/extlinks14"
@@ -3841,7 +4750,7 @@ external_link_win5(hid_t fapl, hbool_t new_format)
TESTING("external links via main file's rel drive/abs path (windows)")
if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)
- TEST_ERROR
+ TEST_ERROR
drive = HDgetdrive();
/* set up name for main file: "/CWD/extlinks0" */
@@ -3903,7 +4812,7 @@ external_link_win5(hid_t fapl, hbool_t new_format)
/*-------------------------------------------------------------------------
* Function: external_link_win6
*
- * Purpose:
+ * Purpose:
* 1. target link: "<cur drive+1>:tmp/extlinks15"
* 2. main file: "extlinks0"
* 3. target file: "tmp/extlinks15"
@@ -3992,6 +4901,272 @@ external_link_win6(hid_t fapl, hbool_t new_format)
return -1;
} /* end external_link_win6() */
+
+/*-------------------------------------------------------------------------
+ * Function: external_link_win7
+ *
+ * Purpose:
+ * 1. UNC target link: "\\127.0.01\c$/tmp/extlinks10"
+ * 2. main file: "extlinks0"
+ * 3. target file: "extlinks15"
+ * Should be able to find the target file via main file's local host/main drive/rel path
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *-------------------------------------------------------------------------
+ */
+static int
+external_link_win7(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group IDs */
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ filename3[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+
+ if(new_format)
+ TESTING("external links via main file's UNC local host/main drive/rel path(windows)(w/new group format)")
+ else
+ TESTING("external links via main file's UNC local host/main drive/rel path(windows)")
+
+ /* set up name for main file: "extlinks0" */
+ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1);
+
+ if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)
+ TEST_ERROR
+
+ /* set up name for target link: "\\127.0.0.1\c$/tmp/extlinks10" */
+ HDstrcpy(tmpname, "\\\\127.0.0.1\\c$"); /* absolute path */
+ HDstrcat(tmpname, "/");
+ HDstrcat(tmpname, FILENAME[30]);
+ h5_fixname(tmpname, fapl, filename2, sizeof filename2);
+
+ /* set up name for target file: "extlinks15" */
+ h5_fixname(FILENAME[29], fapl, filename3, sizeof filename3);
+
+ /* Create the target file */
+ if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing for target file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file */
+ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open object through external link */
+ H5E_BEGIN_TRY {
+ gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ /* should be able to find the target file via main file's local host/main drive*/
+ if (gid < 0) {
+ H5_FAILED();
+ puts(" Should have found the file in local host/main drive.");
+ goto error;
+ }
+
+ /* closing for main file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose (gid);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_link_win7() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_link_win8
+ *
+ * Purpose:
+ * 1. Long UNC target link: "\\?\<cur drive>:\CWD\extlinks10"
+ * 2. main file: "extlinks0"
+ * 3. target file: "extlinks10"
+ * Should be able to access the target file directly (abs drive/abs path)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_link_win8(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group IDs */
+ int drive=0;
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ filename3[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+
+ if(new_format)
+ TESTING("external links via target's Long UNC abs drive/abs path directly (windows)(w/new group format)")
+ else
+ TESTING("external links via target's Long UNC abs drive/abs path directly (windows)")
+
+ /* set up name for main file: "extlinks0" */
+ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1);
+
+ if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)
+ TEST_ERROR
+
+ /* create tmp directory */
+ if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
+ TEST_ERROR
+
+ /* set up name for target link: "<drive-letter>:\CWD\extlinks10" */
+ drive = HDgetdrive();
+ sprintf(tmpname, "\\\\?\\%c:%s\\%s", (drive+'A'-1), &cwdpath[2], FILENAME[30]);
+ h5_fixname(tmpname, fapl, filename2, sizeof filename2);
+
+ /* set up name for target file: "extlinks10" */
+ h5_fixname(FILENAME[30], fapl, filename3, sizeof filename3);
+
+ /* Create the target file */
+ if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing for target file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file */
+ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open object through external link */
+ H5E_BEGIN_TRY {
+ gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ /* should be able to find the target file directly */
+ if (gid < 0) {
+ H5_FAILED();
+ puts(" Should have found the file in tmp.");
+ goto error;
+ }
+
+ /* closing for main file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose (gid);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_link_win8() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_link_win9
+ *
+ * Purpose:
+ * 1. Long UNC target link: "\\?\UNC\127.0.01\c$/tmp/extlinks10"
+ * 2. main file: "extlinks0"
+ * 3. target file: "extlinks15"
+ * Should be able to find the target file via main file's local host/main drive/rel path
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *-------------------------------------------------------------------------
+ */
+static int
+external_link_win9(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group IDs */
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ filename3[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+
+ if(new_format)
+ TESTING("external links via main file's Long UNC local host/main drive/rel path(windows)(w/new group format)")
+ else
+ TESTING("external links via main file's Long UNC local host/main drive/rel path(windows)")
+
+ /* set up name for main file: "extlinks0" */
+ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1);
+
+ if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)
+ TEST_ERROR
+
+ /* set up name for target link: "\\?\UNC\127.0.0.1\c$/tmp/extlinks10" */
+ HDstrcpy(tmpname, "\\\\?\\UNC\127.0.0.1\\c$"); /* absolute path */
+ HDstrcat(tmpname, "/");
+ HDstrcat(tmpname, FILENAME[30]);
+ h5_fixname(tmpname, fapl, filename2, sizeof filename2);
+
+ /* set up name for target file: "extlinks15" */
+ h5_fixname(FILENAME[29], fapl, filename3, sizeof filename3);
+
+ /* Create the target file */
+ if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing for target file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file */
+ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open object through external link */
+ H5E_BEGIN_TRY {
+ gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ /* should be able to find the target file via main file's local host/main drive*/
+ if (gid < 0) {
+ H5_FAILED();
+ puts(" Should have found the file in local host/main drive.");
+ goto error;
+ }
+
+ /* closing for main file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose (gid);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_link_win9() */
+
#endif /* H5_HAVE_WINDOW_PATH */
@@ -4106,7 +5281,8 @@ external_link_query(hid_t fapl, hbool_t new_format)
if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create external link */
- if(H5Lcreate_external(filename2, "/dst", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* (add a few extra '/'s to make certain library normalizes external link object names) */
+ if(H5Lcreate_external(filename2, "///dst//", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Get size of buffer for external link */
if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR
@@ -4444,7 +5620,6 @@ external_link_move(hid_t fapl, hbool_t new_format)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */
@@ -4489,7 +5664,7 @@ external_link_move(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "src2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
@@ -4534,7 +5709,7 @@ external_link_move(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
@@ -4570,14 +5745,14 @@ external_link_move(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Move external link back to original location */
if(H5Lmove(fid, "/group2/src3", H5L_SAME_LOC, "/src", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) FAIL_STACK_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
@@ -4638,7 +5813,6 @@ external_link_ride(hid_t fapl, hbool_t new_format)
hid_t gcpl = (-1); /* Group creation property list ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */
unsigned nmsgs; /* Number of messages in group's header */
@@ -4722,7 +5896,7 @@ external_link_ride(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "src", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
@@ -4757,7 +5931,7 @@ external_link_ride(hid_t fapl, hbool_t new_format)
if((gid = H5Gopen2(fid, "src", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/dst")) TEST_ERROR
/* Create object in external file */
@@ -4819,7 +5993,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-external_link_closing(hid_t fapl, hbool_t new_format)
+external_link_closing(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
{
hid_t fid1 = (-1), fid2 = (-1), fid3 = (-1), fid4=(-1);
hid_t gid=(-1), tid=(-1), tid2=(-1), sid=(-1), did=(-1);
@@ -4839,184 +6013,195 @@ external_link_closing(hid_t fapl, hbool_t new_format)
else
TESTING("that external files are closed during traversal")
- /* In this test, external links will go from file1 to file2 and from
- * file2 to file3.
- * Test that all functions that can traverse external files close
- * the files they open.
- * Test that providing unusual paths containing external links can't
- * make HDF5 forget to close a file it opened.
- */
-
- /* Set up filenames */
- h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1);
- h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2);
- h5_fixname(FILENAME[5], fapl, filename3, sizeof filename3);
- h5_fixname(FILENAME[6], fapl, filename4, sizeof filename4);
-
- /* Create four files */
- if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
-
- /* Create a dataspace and a datatype so we can create/commit a dataset/datatype in the files */
- dims[0] = 2;
- dims[1] = 2;
- if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
- if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
- if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
-
- /* Create external links from each file to the next */
- if(H5Lcreate_external(filename2, "/", fid1, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lcreate_external(filename3, "/", fid2, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lcreate_external(filename4, "/", fid3, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Close all files but the first */
- if(H5Fclose(fid4) < 0) TEST_ERROR
- if(H5Fclose(fid3) < 0) TEST_ERROR
- if(H5Fclose(fid2) < 0) TEST_ERROR
-
- /* Test creating each kind of object */
- if((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Close objects */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Tclose(tid) < 0) TEST_ERROR
- if(H5Dclose(did) < 0) TEST_ERROR
-
- /* Test that getting info works */
- if(H5Lget_info(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lget_info(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Oget_info_by_name(fid1, "elink/elink/elink/type1", &oi, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Oget_info_by_name(fid1, "elink/elink/elink", &oi, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Test move */
- if(H5Lmove(fid1, "elink/elink/elink/group1", fid1,
- "elink/elink/elink/group1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Open file 4 so we can do some fancy things */
- if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
- if(H5Lmove(fid1, "elink/elink/elink/type1", fid4,
- "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
- if(H5Lmove(fid4, "dataset1", fid1,
- "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
-
- /* Close file 4 again */
- if(H5Fclose(fid4) < 0) FAIL_STACK_ERROR
-
- /* Test copy (as of this test, it uses the same code as move) */
- if(H5Lcopy(fid1, "elink/elink/elink", fid1,
- "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
- if(H5Lcopy(fid1, "elink/elink/elink", fid1,
- "elink/elink/elink/elink_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
-
- /* Test H5Gset and get comment */
- if(H5Oset_comment_by_name(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
- if(H5Oget_comment_by_name(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) FAIL_STACK_ERROR
- if(HDstrcmp(buf, "comment")) TEST_ERROR
-
- /* Test H5*open */
- if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Close objects */
- if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
- if(H5Tclose(tid) < 0) FAIL_STACK_ERROR
- if(H5Dclose(did) < 0) FAIL_STACK_ERROR
-
- /* Test H5*open2 */
- if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Close objects */
- if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
- if(H5Tclose(tid) < 0) FAIL_STACK_ERROR
- if(H5Dclose(did) < 0) FAIL_STACK_ERROR
-
- /* Test H5Oopen */
- if((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Dclose(did) < 0) TEST_ERROR
-
- /* Test H5Fmount */
- if((gid = H5Gcreate2(fid1, "elink/elink/elink/mnt", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- H5E_BEGIN_TRY {
- if(H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) TEST_ERROR
- if(H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) TEST_ERROR
- } H5E_END_TRY
-
- /* Test H5Rcreate */
- if(H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (-1)) < 0) TEST_ERROR
-
- /* Test unlink */
- if(H5Ldelete(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Ldelete(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Ldelete(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Ldelete(fid1, "elink/elink/elink_copied", H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Ldelete(fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT) < 0) TEST_ERROR
-
- /* We've tested that the various functions above don't leave files open.
- * Now test that we can't confuse HDF5 by giving unusual paths with external links
+ /* Skip test when using core VFD, since it doesn't re-open file when linking
+ * to same file.
*/
- /* Create an external link that points to another external link */
- if((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
- if(H5Lcreate_external(filename3, "/elink", fid2, "elink2",
- H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Fclose(fid2) < 0) TEST_ERROR
-
- /* Do an external link traversal that recursively calls another external link. */
- if((gid = H5Gcreate2(fid1, "elink/elink2/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
-
- /* Create two more groups so that the last three elements in the path are
- * all within the same external file
- */
- if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Oget_info_by_name(fid1, "elink/elink2/group2/group3/group4", &oi, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Add a few regular groups and a soft link in file2 using intermediate group creation */
- if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
- if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR
- if(H5Lcreate_soft("/elink2", fid1, "elink/file2group1/file2group2/slink",
- lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Try to traverse this path. There are three soft traversals in a row;
- * slink points to (file2)/elink2, which points to (file3)/elink, which
- * points to file 4.
- */
- if((gid = H5Gcreate2(fid1, "elink/file2group1/file2group2/slink/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Lget_info(fid1, "elink/file2group1/file2group2/slink/group3", &li, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Some simpler tests */
- if((gid = H5Gcreate2(fid1, "elink/file2group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Lget_info(fid1, "elink/file2group3", &li, H5P_DEFAULT) < 0) TEST_ERROR
- if(H5Lget_info(fid1, "elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR
-
-
- /* Close file1, the only file that should still be open */
- if(H5Fclose(fid1) < 0) TEST_ERROR
+ if(HDstrcmp(env_h5_drvr, "core")) {
+ /* In this test, external links will go from file1 to file2 and from
+ * file2 to file3.
+ * Test that all functions that can traverse external files close
+ * the files they open.
+ * Test that providing unusual paths containing external links can't
+ * make HDF5 forget to close a file it opened.
+ */
- /* Re-create each file. If they are hanging open, these creates will fail */
- if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Set up filenames */
+ h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2);
+ h5_fixname(FILENAME[5], fapl, filename3, sizeof filename3);
+ h5_fixname(FILENAME[6], fapl, filename4, sizeof filename4);
+
+ /* Create four files */
+ if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create a dataspace and a datatype so we can create/commit a dataset/datatype in the files */
+ dims[0] = 2;
+ dims[1] = 2;
+ if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+
+ /* Create external links from each file to the next */
+ if(H5Lcreate_external(filename2, "/", fid1, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename3, "/", fid2, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename4, "/", fid3, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close all files but the first */
+ if(H5Fclose(fid4) < 0) TEST_ERROR
+ if(H5Fclose(fid3) < 0) TEST_ERROR
+ if(H5Fclose(fid2) < 0) TEST_ERROR
+
+ /* Test creating each kind of object */
+ if((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Close objects */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Test that getting info works */
+ if(H5Lget_info(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lget_info(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Oget_info_by_name(fid1, "elink/elink/elink/type1", &oi, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Oget_info_by_name(fid1, "elink/elink/elink", &oi, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Test move */
+ if(H5Lmove(fid1, "elink/elink/elink/group1", fid1,
+ "elink/elink/elink/group1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open file 4 so we can do some fancy things */
+ if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
+ if(H5Lmove(fid1, "elink/elink/elink/type1", fid4,
+ "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(H5Lmove(fid4, "dataset1", fid1,
+ "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ /* Close file 4 again */
+ if(H5Fclose(fid4) < 0) FAIL_STACK_ERROR
+
+ /* Test copy (as of this test, it uses the same code as move) */
+ if(H5Lcopy(fid1, "elink/elink/elink", fid1,
+ "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(H5Lcopy(fid1, "elink/elink/elink", fid1,
+ "elink/elink/elink/elink_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ /* Test H5Gset and get comment */
+ if(H5Oset_comment_by_name(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(H5Oget_comment_by_name(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(HDstrcmp(buf, "comment")) TEST_ERROR
+
+ /* Test H5*open */
+ if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Close objects */
+ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+
+ /* Test H5*open2 */
+ if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Close objects */
+ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+
+ /* Test H5Oopen */
+ if((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Test H5Fmount */
+ if((gid = H5Gcreate2(fid1, "elink/elink/elink/mnt", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ H5E_BEGIN_TRY {
+ if(H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) TEST_ERROR
+ if(H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) TEST_ERROR
+ } H5E_END_TRY
+
+ /* Test H5Rcreate */
+ if(H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (-1)) < 0) TEST_ERROR
+
+ /* Test unlink */
+ if(H5Ldelete(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ldelete(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ldelete(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ldelete(fid1, "elink/elink/elink_copied", H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ldelete(fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* We've tested that the various functions above don't leave files open.
+ * Now test that we can't confuse HDF5 by giving unusual paths with external links
+ */
+ /* Create an external link that points to another external link */
+ if((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename3, "/elink", fid2, "elink2",
+ H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Fclose(fid2) < 0) TEST_ERROR
+
+ /* Do an external link traversal that recursively calls another external link. */
+ if((gid = H5Gcreate2(fid1, "elink/elink2/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+
+ /* Create two more groups so that the last three elements in the path are
+ * all within the same external file
+ */
+ if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Oget_info_by_name(fid1, "elink/elink2/group2/group3/group4", &oi, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Add a few regular groups and a soft link in file2 using intermediate group creation */
+ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR
+ if(H5Lcreate_soft("/elink2", fid1, "elink/file2group1/file2group2/slink",
+ lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Try to traverse this path. There are three soft traversals in a row;
+ * slink points to (file2)/elink2, which points to (file3)/elink, which
+ * points to file 4.
+ */
+ if((gid = H5Gcreate2(fid1, "elink/file2group1/file2group2/slink/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Lget_info(fid1, "elink/file2group1/file2group2/slink/group3", &li, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Some simpler tests */
+ if((gid = H5Gcreate2(fid1, "elink/file2group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Lget_info(fid1, "elink/file2group3", &li, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lget_info(fid1, "elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR
+
+
+ /* Close file1, the only file that should still be open */
+ if(H5Fclose(fid1) < 0) TEST_ERROR
+
+ /* Re-create each file. If they are hanging open, these creates will fail */
+ if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Cleanup */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+ if(H5Fclose(fid4) < 0) TEST_ERROR
+ if(H5Fclose(fid3) < 0) TEST_ERROR
+ if(H5Fclose(fid2) < 0) TEST_ERROR
+ if(H5Fclose(fid1) < 0) TEST_ERROR
- /* Cleanup */
- if(H5Sclose(sid) < 0) TEST_ERROR
- if(H5Tclose(tid2) < 0) TEST_ERROR
- if(H5Fclose(fid4) < 0) TEST_ERROR
- if(H5Fclose(fid3) < 0) TEST_ERROR
- if(H5Fclose(fid2) < 0) TEST_ERROR
- if(H5Fclose(fid1) < 0) TEST_ERROR
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD can't reopen same file through external link");
+ } /* end else */
- PASSED();
return 0;
error:
@@ -5051,7 +6236,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-external_link_endian(hid_t fapl, hbool_t new_format)
+external_link_endian(hbool_t new_format)
{
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
@@ -5086,7 +6271,7 @@ external_link_endian(hid_t fapl, hbool_t new_format)
HDstrcat(namebuf, LE_FILENAME);
/* Test LE file; try to open a group through the external link */
- if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+ if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
if((gid = H5Oopen(fid, "ext_link", lapl_id)) < 0) TEST_ERROR
/* Open a group in the external file using that group ID */
@@ -5102,7 +6287,7 @@ external_link_endian(hid_t fapl, hbool_t new_format)
HDstrcat(namebuf, BE_FILENAME);
/* Test BE file; try to open a group through the external link */
- if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+ if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
if((gid = H5Oopen(fid, "ext_link", lapl_id)) < 0) TEST_ERROR
/* Open a group in the external file using that group ID */
@@ -5114,6 +6299,7 @@ external_link_endian(hid_t fapl, hbool_t new_format)
if(H5Fclose(fid) < 0) TEST_ERROR
PASSED();
+
return 0;
error:
@@ -5147,7 +6333,6 @@ external_link_strong(hid_t fapl, hbool_t new_format)
hid_t fid1 = (-1), fid2 = (-1); /* File ID */
hid_t gid1 = (-1), gid2 = (-1); /* Group IDs */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE];
@@ -5188,7 +6373,7 @@ external_link_strong(hid_t fapl, hbool_t new_format)
/* Access external link from file #1 */
if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
if((gid2 = H5Gopen2(fid2, "/W/X/DLINK", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((name_len = H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR
if(H5Gclose(gid2) < 0) TEST_ERROR
if(H5Fclose(fid2) < 0) TEST_ERROR
@@ -5210,6 +6395,222 @@ error:
/*-------------------------------------------------------------------------
+ * Function: external_symlink
+ *
+ * Purpose: Verify functionality of external links when symlinks are
+ * used for parent/child files
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Nov. 23, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
+{
+#ifdef H5_HAVE_SYMLINK
+ hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1;
+ hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1;
+ char filename1[NAME_BUF_SIZE],
+ filename2a[NAME_BUF_SIZE],
+ filename2b[NAME_BUF_SIZE],
+ filename3a[NAME_BUF_SIZE],
+ filename3b[NAME_BUF_SIZE],
+ filename4a[NAME_BUF_SIZE],
+ filename4b[NAME_BUF_SIZE],
+ filename5a[NAME_BUF_SIZE],
+ filename5b[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+ hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */
+#endif /* H5_HAVE_SYMLINK */
+
+ if(new_format)
+ TESTING("external links w/symlink files (w/new group format)")
+ else
+ TESTING("external links w/symlink files")
+
+#ifdef H5_HAVE_SYMLINK
+ /* Skip test when using VFDs that can't provide a POSIX compatible file
+ * descriptor.
+ */
+ have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2")
+ || !HDstrcmp(env_h5_drvr, "core")
+ || !HDstrcmp(env_h5_drvr, "nomatch"));
+ if(have_posix_compat_vfd) {
+ /* set up name for main file: "extlinks21A" */
+ h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1));
+
+ /* create tmp directory and get current working directory path */
+ if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
+ TEST_ERROR
+ if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST)
+ TEST_ERROR
+ if(NULL == HDgetcwd(cwdpath, NAME_BUF_SIZE))
+ TEST_ERROR
+
+ /* Set up names for files in the subdirectories */
+
+ /* set up names for file #2 in temporary directory #2: "tmp2/extlinks21B" */
+ h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a));
+ fix_ext_filename(tmpname, cwdpath, FILENAME[46]);
+ h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b));
+
+ /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */
+ /* (i.e. tmp/sym1.h5 -> <full path to>/tmp2/extlinks21B.h5) */
+ if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR
+
+ /* set up name for file #3 in temporary directory #2: "tmp2/extlinks21C" */
+ h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a));
+ h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b));
+
+ /* set up name for file #4 in temporary directory #1: "tmp/extlinks21D" */
+ h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a));
+ fix_ext_filename(tmpname, cwdpath, FILENAME[49]);
+ h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b));
+
+ /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */
+ /* (i.e. tmp2/sym2.h5 -> <full path to>/tmp/extlinks21D.h5) */
+ if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR
+
+ /* set up name for file #5 in temporary directory #1: "tmp/extlinks21E" */
+ h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a));
+ h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b));
+
+
+ /* Create file #1 in current directory */
+ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to file & object in temporary directory #2, using symlink #1 name */
+ if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close file #1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+
+
+ /* Create file #2 in tmp directory #2 */
+ if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
+
+ /* Re-open file #2 in tmp directory through symlink */
+ if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+
+ /* Create group in file #2 in temporary directory */
+ if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create external link to file #3 & object in temporary directory #2 */
+ if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close group in file #2 */
+ if(H5Gclose(group2) < 0) TEST_ERROR
+
+ /* Close file #2 */
+ if(H5Fclose(file2) < 0) TEST_ERROR
+
+
+ /* Create file #3 in temp. directory #2 */
+ if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create group in file #3 */
+ if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create external link to file & object in temporary directory #1, using symlink #2 name */
+ if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close group in file #3 */
+ if(H5Gclose(group3) < 0) TEST_ERROR
+
+ /* Close file #3 */
+ if(H5Fclose(file3) < 0) TEST_ERROR
+
+
+ /* Create file #4 in temporary directory #1 */
+ if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create group in file #4 in 'temporary' directory */
+ if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create external link to file #5 & object in temporary directory #1 */
+ if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close group in file #4 */
+ if(H5Gclose(group4) < 0) TEST_ERROR
+
+ /* Close file #4 */
+ if(H5Fclose(file4) < 0) TEST_ERROR
+
+
+ /* Create file #5 in temporary directory #1 */
+ if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create group in file #5 in 'temporary' directory #1 */
+ if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(group5) < 0) TEST_ERROR
+
+ /* Close file #5 */
+ if(H5Fclose(file5) < 0) TEST_ERROR
+
+
+ /* Actual tests... */
+
+ /* Reopen file #1 */
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+
+ /* Open group in file #2, through external link w/symlink */
+ if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group2) < 0) TEST_ERROR
+
+ /* Open group in file #3, through external link w/symlink to external link */
+ if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group3) < 0) TEST_ERROR
+
+ /* Open group in file #4, through external link w/symlink to external link w/symlink */
+ if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group4) < 0) TEST_ERROR
+
+ /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */
+ if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group5) < 0) TEST_ERROR
+
+ /* Close file #1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+
+
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support POSIX I/O calls");
+ } /* end else */
+
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose(group5);
+ H5Gclose(group4);
+ H5Gclose(group3);
+ H5Gclose(group2);
+ H5Fclose(file5);
+ H5Fclose(file4);
+ H5Fclose(file3);
+ H5Fclose(file2);
+ H5Fclose(file1);
+ } H5E_END_TRY;
+ return -1;
+#else /* H5_HAVE_SYMLINK */
+ SKIPPED();
+ puts(" Current file system or operating system doesn't support symbolic links");
+
+ return 0;
+#endif /* H5_HAVE_SYMLINK */
+} /* end external_symlink() */
+
+
+/*-------------------------------------------------------------------------
* Function: ud_hard_links
*
* Purpose: Check that the functionality of hard links can be duplicated
@@ -5349,8 +6750,8 @@ done:
} /* end UD_hard_delete() */
const H5L_class_t UD_hard_class[1] = {{
- H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_HARD_TYPE, /* Link type id number */
+ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
+ (H5L_type_t)UD_HARD_TYPE, /* Link type id number */
"UD_hard_link", /* Link class name for debugging */
UD_hard_create, /* Creation callback */
NULL, /* Move/rename callback */
@@ -5367,7 +6768,6 @@ ud_hard_links(hid_t fapl)
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
H5L_info_t li; /* Link information */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
h5_stat_size_t empty_size; /* Size of an empty file */
char filename[NAME_BUF_SIZE];
@@ -5380,20 +6780,20 @@ ud_hard_links(hid_t fapl)
/* Get the size of the empty file for reference */
if(H5Fclose(fid) < 0) TEST_ERROR
- if((empty_size = h5_get_file_size(filename))<0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl))<0) TEST_ERROR
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Check that external links are registered and UD hard links are not */
if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR
- if(H5Lis_registered(UD_HARD_TYPE) != FALSE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR
/* Register "user-defined hard links" with the library */
if(H5Lregister(UD_hard_class) < 0) TEST_ERROR
/* Check that UD hard links are now registered */
if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR
- if(H5Lis_registered(UD_HARD_TYPE) != TRUE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR
/* Create a group for the UD hard link to point to */
if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -5406,17 +6806,17 @@ ud_hard_links(hid_t fapl)
/* Create a user-defined "hard link" to the group using the address we got
* from H5Lget_info */
- if(H5Lcreate_ud(fid, "ud_link", UD_HARD_TYPE, &(li.u.address), sizeof(haddr_t), H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), sizeof(haddr_t), H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Close and re-open file to ensure that data is written to disk */
if(H5Fclose(fid) < 0) TEST_ERROR
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
/* Open group through UD link */
if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/group")) TEST_ERROR
/* Create object in group */
@@ -5430,7 +6830,7 @@ ud_hard_links(hid_t fapl)
if((gid = H5Gopen2(fid, "group/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/group/new_group")) TEST_ERROR
/* Close opened object */
@@ -5465,9 +6865,9 @@ ud_hard_links(hid_t fapl)
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* The file should be empty again. */
- if(empty_size != h5_get_file_size(filename)) TEST_ERROR
+ if(empty_size != h5_get_file_size(filename, fapl)) TEST_ERROR
- if(H5Lunregister(UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
+ if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
@@ -5517,7 +6917,7 @@ error:
* has a very different traversal function */
const H5L_class_t UD_rereg_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_HARD_TYPE, /* Link type id number */
+ (H5L_type_t)UD_HARD_TYPE, /* Link type id number */
"UD_reregistered_type", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move/rename callback */
@@ -5534,7 +6934,6 @@ ud_link_reregister(hid_t fapl)
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
H5L_info_t li; /* Link information */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename[NAME_BUF_SIZE];
h5_stat_size_t empty_size; /* Size of an empty file */
@@ -5547,25 +6946,25 @@ ud_link_reregister(hid_t fapl)
/* Get the size of the empty file for reference */
if(H5Fclose(fid) < 0) TEST_ERROR
- if((empty_size=h5_get_file_size(filename))<0) TEST_ERROR
+ if((empty_size=h5_get_file_size(filename, fapl))<0) TEST_ERROR
if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Check that UD hard links are not registered */
- if(H5Lis_registered(UD_HARD_TYPE) != FALSE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR
/* Register "user-defined hard links" with the library */
if(H5Lregister(UD_hard_class) < 0) TEST_ERROR
/* Check that UD hard links are registered */
- if(H5Lis_registered(UD_HARD_TYPE) != TRUE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR
/* Point a UD defined hard link to a group in the same way as the previous test */
if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if (H5Lget_info(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Lcreate_ud(fid, "ud_link", UD_HARD_TYPE, &(li.u.address),
+ if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address),
sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR
@@ -5574,10 +6973,10 @@ ud_link_reregister(hid_t fapl)
if(H5Gclose(gid) < 0) TEST_ERROR
/* Now unregister UD hard links */
- if(H5Lunregister(UD_HARD_TYPE) < 0) TEST_ERROR
+ if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) TEST_ERROR
/* Check that UD hard links are no longer registered */
- if(H5Lis_registered(UD_HARD_TYPE) != FALSE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR
/* Verify that we can't traverse the ud link anymore */
H5E_BEGIN_TRY {
@@ -5586,7 +6985,7 @@ ud_link_reregister(hid_t fapl)
/* Verify that we can't create any new links of this type */
H5E_BEGIN_TRY {
- if(H5Lcreate_ud(fid, "ud_link2", UD_HARD_TYPE, &(li.u.address),
+ if(H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address),
sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) >= 0)
TEST_ERROR
} H5E_END_TRY
@@ -5595,7 +6994,7 @@ ud_link_reregister(hid_t fapl)
if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR
/* Check that UD hard links are registered again */
- if(H5Lis_registered(UD_HARD_TYPE) != TRUE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR
/* Open a group through the ud link (now a different class of link).
* It should be a different group
@@ -5603,7 +7002,7 @@ ud_link_reregister(hid_t fapl)
if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/" REREG_TARGET_NAME)) TEST_ERROR
/* Create object in group */
@@ -5617,7 +7016,7 @@ ud_link_reregister(hid_t fapl)
if((gid = H5Gopen2(fid, "rereg_target/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/rereg_target/new_group")) TEST_ERROR
/* Close opened object */
@@ -5631,7 +7030,7 @@ ud_link_reregister(hid_t fapl)
* reference counts. We shouldn't actually need to unregister the
* other link type */
if(H5Lregister(UD_hard_class) < 0) FAIL_STACK_ERROR
- if(H5Lis_registered(UD_HARD_TYPE) != TRUE) FAIL_STACK_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) FAIL_STACK_ERROR
/* Ensure we can open the group through the UD link (now that UD hard
* links have been registered) */
@@ -5650,11 +7049,11 @@ ud_link_reregister(hid_t fapl)
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* The file should be empty again. */
- if(empty_size != h5_get_file_size(filename)) TEST_ERROR
+ if(empty_size != h5_get_file_size(filename, fapl)) TEST_ERROR
+
+ if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) FAIL_STACK_ERROR
- if(H5Lunregister(UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
- if(H5Lis_registered(UD_HARD_TYPE) != FALSE) FAIL_STACK_ERROR
-
PASSED();
return 0;
@@ -5693,8 +7092,8 @@ UD_cb_create(const char * link_name, hid_t loc_group, const void *udata,
if(udata_size > 0 && !udata) TEST_ERROR
if(lcpl_id < 0) TEST_ERROR
- if(strcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR
- if(strcmp(udata, UD_CB_TARGET)) TEST_ERROR
+ if(HDstrcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR
+ if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR
if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR
return 0;
@@ -5714,8 +7113,8 @@ UD_cb_traverse(const char * link_name, hid_t cur_group, const void *udata,
if(cur_group < 0) TEST_ERROR
if(udata_size > 0 && !udata) TEST_ERROR
- if(strcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR
- if(strcmp(udata, UD_CB_TARGET)) TEST_ERROR
+ if(HDstrcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR
+ if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR
if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR
if((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0)
@@ -5737,7 +7136,7 @@ UD_cb_move(const char *new_name, hid_t new_loc, const void *udata,
if(udata_size > 0 && !udata) TEST_ERROR
if(HDstrcmp(new_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR
- if(HDstrcmp(udata, UD_CB_TARGET)) TEST_ERROR
+ if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR
if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR
return 0;
@@ -5756,7 +7155,7 @@ UD_cb_delete(const char *link_name, hid_t file, const void *udata,
if(udata_size > 0 && !udata) TEST_ERROR
if(HDstrcmp(link_name, UD_CB_LINK_NAME) && HDstrcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR
- if(HDstrcmp(udata, UD_CB_TARGET)) TEST_ERROR
+ if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR
if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR
return 0;
@@ -5773,13 +7172,13 @@ UD_cb_query(const char * link_name, const void *udata, size_t udata_size,
if(!link_name) TEST_ERROR
if(udata_size > 0 && !udata) TEST_ERROR
- if(strcmp(link_name, UD_CB_LINK_NAME)) TEST_ERROR
- if(strcmp(udata, UD_CB_TARGET)) TEST_ERROR
+ if(HDstrcmp(link_name, UD_CB_LINK_NAME)) TEST_ERROR
+ if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR
if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR
if(buf) {
if(buf_size < 16) TEST_ERROR
- strcpy(buf, "query succeeded");
+ HDstrcpy((char *)buf, "query succeeded");
} /* end if */
/* There are 15 characters and a NULL in "query succeeded" */
@@ -5791,7 +7190,7 @@ error:
const H5L_class_t UD_cb_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_CB_TYPE, /* Link type id number */
+ (H5L_type_t)UD_CB_TYPE, /* Link type id number */
NULL, /* NULL name (to make sure this doesn't break anything */
UD_cb_create, /* Creation callback */
UD_cb_move, /* Move/rename callback */
@@ -5824,8 +7223,8 @@ ud_callbacks(hid_t fapl, hbool_t new_format)
/* Check that registered link classes are, and unregistered ones aren't */
if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR
- if(H5Lis_registered(UD_HARD_TYPE) != FALSE) TEST_ERROR
- if(H5Lis_registered(UD_CB_TYPE) != FALSE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_CB_TYPE) != FALSE) TEST_ERROR
/* Hit two birds with one stone: register UD hard links from previous
* test to check that having two UD links registered at once presents
@@ -5838,14 +7237,14 @@ ud_callbacks(hid_t fapl, hbool_t new_format)
/* Check that registered link classes are, and unregistered ones aren't */
if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR
- if(H5Lis_registered(UD_HARD_TYPE) != TRUE) TEST_ERROR
- if(H5Lis_registered(UD_CB_TYPE) != TRUE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR
+ if(H5Lis_registered((H5L_type_t)UD_CB_TYPE) != TRUE) TEST_ERROR
/* Create a group for the UD link to point to */
if((gid = H5Gcreate2(fid, UD_CB_TARGET, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create a user-defined link to the group. These UD links behave like soft links. */
- if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Gclose(gid) < 0) TEST_ERROR
/* Try opening group through UD link */
@@ -5882,7 +7281,7 @@ ud_callbacks(hid_t fapl, hbool_t new_format)
* encoding (to test that LAPLs work) */
if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) FAIL_STACK_ERROR
if(H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) FAIL_STACK_ERROR
- if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, lcpl, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, lcpl, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(H5Pclose(lcpl) < 0) FAIL_STACK_ERROR
/* Check its character encoding */
@@ -5890,11 +7289,11 @@ ud_callbacks(hid_t fapl, hbool_t new_format)
if(li.cset != H5T_CSET_UTF8) TEST_ERROR
/* Unregister the link class so the library forgets what its callbacks do */
- if(H5Lunregister(UD_CB_TYPE) < 0) FAIL_STACK_ERROR
+ if(H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) FAIL_STACK_ERROR
/* Now test that each of the callbacks fails */
H5E_BEGIN_TRY {
- if(H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR
+ if(H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR
if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR
if(H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR
if((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR
@@ -5907,7 +7306,7 @@ ud_callbacks(hid_t fapl, hbool_t new_format)
if(li.type != UD_CB_TYPE) TEST_ERROR
/* Unregister the UD hard links */
- if(H5Lunregister(UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
+ if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
@@ -5962,7 +7361,7 @@ error:
const H5L_class_t UD_plist_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_PLIST_TYPE, /* Link type id number */
+ (H5L_type_t)UD_PLIST_TYPE, /* Link type id number */
"UD_plist_link", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move/rename callback */
@@ -6004,7 +7403,7 @@ lapl_udata(hid_t fapl, hbool_t new_format)
/* Unregister the first link type registered to make sure this doesn't
* break anything. */
- if(H5Lunregister(UD_CB_TYPE) < 0) TEST_ERROR
+ if(H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) TEST_ERROR
/* Create two groups for the UD link to point to */
if((gid = H5Gcreate2(fid, "group_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -6013,7 +7412,7 @@ lapl_udata(hid_t fapl, hbool_t new_format)
if(H5Gclose(gid) < 0) TEST_ERROR
/* Create a user-defined link to the group. These UD links have no udata. */
- if(H5Lcreate_ud(fid, "ud_link", UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Create a non-default lapl with a new property pointing to group a*/
if((plist_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
@@ -6179,7 +7578,7 @@ UD_cbsucc_query(const char UNUSED *link_name, const void UNUSED *udata,
*/
if(buf != NULL && buf_size >= 8)
- strcpy(buf, "succeed");
+ HDstrcpy((char *)buf, "succeed");
return 8;
} /* end UD_cbsucc_query() */
@@ -6187,7 +7586,7 @@ UD_cbsucc_query(const char UNUSED *link_name, const void UNUSED *udata,
/* This class is full of failing callbacks */
const H5L_class_t UD_cbfail_class1[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_CBFAIL_TYPE, /* Link type id number */
+ (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */
"UD_cbfail_link1", /* Link class name for debugging */
UD_cbsucc_create, /* Creation callback */
UD_cbfail_move, /* Move/rename callback */
@@ -6200,7 +7599,7 @@ const H5L_class_t UD_cbfail_class1[1] = {{
/* This class is has two failing callbacks, move and query */
const H5L_class_t UD_cbfail_class2[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_CBFAIL_TYPE, /* Link type id number */
+ (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */
"UD_cbfail_link2", /* Link class name for debugging */
UD_cbsucc_create, /* Creation callback */
UD_cbfail_move, /* Move/rename callback */
@@ -6213,7 +7612,7 @@ const H5L_class_t UD_cbfail_class2[1] = {{
/* All of these callbacks will succeed */
const H5L_class_t UD_cbfail_class3[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_CBFAIL_TYPE, /* Link type id number */
+ (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */
"UD_cbfail_link3", /* Link class name for debugging */
UD_cbsucc_create, /* Creation callback */
UD_cbsucc_move, /* Move/rename callback */
@@ -6226,7 +7625,7 @@ const H5L_class_t UD_cbfail_class3[1] = {{
/* Link classes that are invalid for various reasons */
const H5L_class_t UD_error1_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_ERROR_TYPE, /* Link type id number */
+ (H5L_type_t)UD_ERROR_TYPE, /* Link type id number */
"UD_error_link", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move/rename callback */
@@ -6237,7 +7636,7 @@ const H5L_class_t UD_error1_class[1] = {{
}};
const H5L_class_t UD_error2_class[1] = {{
UD_BAD_VERS, /* Invalid H5L_class_t version */
- UD_ERROR_TYPE, /* Link type id number */
+ (H5L_type_t)UD_ERROR_TYPE, /* Link type id number */
"UD_error_link", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move/rename callback */
@@ -6248,7 +7647,7 @@ const H5L_class_t UD_error2_class[1] = {{
}};
const H5L_class_t UD_error3_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_BAD_TYPE1, /* Invalid Link type id number */
+ (H5L_type_t)UD_BAD_TYPE1, /* Invalid Link type id number */
"UD_error_link", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move/rename callback */
@@ -6259,7 +7658,7 @@ const H5L_class_t UD_error3_class[1] = {{
}};
const H5L_class_t UD_error4_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */
- UD_BAD_TYPE2, /* Invalid Link type id number */
+ (H5L_type_t)UD_BAD_TYPE2, /* Invalid Link type id number */
"UD_error_link", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move/rename callback */
@@ -6306,9 +7705,17 @@ ud_link_errors(hid_t fapl, hbool_t new_format)
if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
+ /* Try to create internally defined links with H5Lcreate_ud */
+ H5E_BEGIN_TRY {
+ if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, 0, H5P_DEFAULT, H5P_DEFAULT) >= 0)
+ TEST_ERROR
+ if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", 4, H5P_DEFAULT, H5P_DEFAULT) >= 0)
+ TEST_ERROR
+ } H5E_END_TRY
+
/* Create a user-defined link to the group. */
strcpy(group_name, "/group");
- if(H5Lcreate_ud(fid, "/ud_link", UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Open the group through the ud link */
if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -6317,7 +7724,7 @@ ud_link_errors(hid_t fapl, hbool_t new_format)
/* Now test that each of the callbacks will cause a failure if it returns -1 */
H5E_BEGIN_TRY {
/* The create callback will fail if we pass in no udata */
- if(H5Lcreate_ud(fid, "fail", UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
+ if(H5Lcreate_ud(fid, "fail", (H5L_type_t)UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
/* The move and copy callbacks will fail */
if(H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR
@@ -6408,7 +7815,6 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
hid_t tid = (-1), sid = (-1), did = (-1); /* Other IDs */
hid_t gapl = (-1), dapl = (-1), tapl = (-1); /* Other property lists */
char objname[NAME_BUF_SIZE]; /* Object name */
- ssize_t name_len; /* Length of object name */
char filename[NAME_BUF_SIZE];
size_t nlinks; /* nlinks for H5Pset_nlinks */
hsize_t dims[2];
@@ -6473,7 +7879,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
if((gid = H5Oopen(fid, "soft17", plist)) < 0) TEST_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/soft17")) TEST_ERROR
/* Create group using soft link */
@@ -6506,7 +7912,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
if((gid = H5Oopen(fid, "soft4", plist)) < 0) TEST_ERROR
/* Check name */
- if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
+ if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(HDstrcmp(objname, "/soft4")) TEST_ERROR
@@ -6537,7 +7943,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
/* H5Lcreate_external and H5Lcreate_ud */
if(H5Lcreate_external("filename", "path", fid, "soft17/extlink", H5P_DEFAULT, plist) < 0) TEST_ERROR
if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR
- if(H5Lcreate_ud(fid, "soft17/udlink", UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) TEST_ERROR
+ if(H5Lcreate_ud(fid, "soft17/udlink", (H5L_type_t)UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) TEST_ERROR
/* Close plist */
if(H5Pclose(plist) < 0) TEST_ERROR
@@ -6573,9 +7979,9 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR
nlinks = 20;
- if(H5Pset_nlinks(gapl, nlinks) < 0) TEST_ERROR
- if(H5Pset_nlinks(tapl, nlinks) < 0) TEST_ERROR
- if(H5Pset_nlinks(dapl, nlinks) < 0) TEST_ERROR
+ if(H5Pset_nlinks(gapl, nlinks) < 0) TEST_ERROR
+ if(H5Pset_nlinks(tapl, nlinks) < 0) TEST_ERROR
+ if(H5Pset_nlinks(dapl, nlinks) < 0) TEST_ERROR
/* We should now be able to use these property lists to open each kind
* of object.
@@ -6595,7 +8001,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
if(H5Pclose(dapl) < 0) TEST_ERROR
/* Unregister UD hard link class */
- if(H5Lunregister(UD_HARD_TYPE) < 0) TEST_ERROR
+ if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) TEST_ERROR
/* Close file */
if(H5Fclose(fid) < 0) TEST_ERROR
@@ -6665,7 +8071,7 @@ linkinfo(hid_t fapl, hbool_t new_format)
if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR
if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Lcreate_ud(fid, "ud_link", UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Close all objects */
@@ -6704,7 +8110,7 @@ linkinfo(hid_t fapl, hbool_t new_format)
H5Fclose (fid);
} H5E_END_TRY;
return -1;
-} /* end ud_hard_links() */
+} /* end linkinfo() */
/*-------------------------------------------------------------------------
@@ -6788,7 +8194,7 @@ build_visit_file(hid_t fapl)
char *srcdir = getenv("srcdir"); /* where the src code is located */
h5_fixname(FILENAME[9], fapl, filename, sizeof filename);
-
+
/* Create file for visiting */
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@@ -7229,6 +8635,470 @@ error:
/*-------------------------------------------------------------------------
+ * Function: visit_obj_stop_cb
+ *
+ * Purpose: Callback routine for visiting objects in a file
+ *
+ * Return: 1 (H5_ITER_STOP)
+ *
+ * Programmer: Neil Fortner
+ * Sunday, November 2, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+visit_obj_stop_cb(hid_t UNUSED group_id, const char UNUSED *name, const H5O_info_t UNUSED *oinfo,
+ void *_op_data)
+{
+ unsigned *op_data = (unsigned *)_op_data;
+
+ /* Increment the number of visited objects */
+ (*op_data)++;
+
+ return(H5_ITER_STOP);
+} /* end visit_obj_stop_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: obj_visit_stop
+ *
+ * Purpose: Test that the object visiting routine stops iteration
+ * properly on the starting object.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Sunday, November 2, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+obj_visit_stop(hid_t fapl, hbool_t new_format)
+{
+ unsigned nvisited; /* User-data for visiting */
+ hid_t fid = -1;
+ herr_t ret; /* Return value */
+
+ if(new_format)
+ TESTING("stopping object iteration (w/new group format)")
+ else
+ TESTING("stopping object iteration")
+
+ /* Construct "interesting" file to visit */
+ if((fid = build_visit_file(fapl)) < 0) TEST_ERROR
+
+ /* Start iteration. The callback should only be called once because it
+ * returns H5_ITER_STOP
+ */
+ nvisited = 0;
+ if((ret = H5Ovisit(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, &nvisited)) < 0)
+ FAIL_STACK_ERROR
+ if(ret != H5_ITER_STOP) TEST_ERROR
+ if(nvisited != 1) TEST_ERROR
+
+ /* Same test with H5Ovisit_by_name */
+ nvisited = 0;
+ if((ret = H5Ovisit_by_name(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb,
+ &nvisited, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(ret != H5_ITER_STOP) TEST_ERROR
+ if(nvisited != 1) TEST_ERROR
+
+ /* Close file created */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end obj_visit_stop() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: link_filters
+ *
+ * Purpose: Tests adding filters to group link storage. Also tests
+ * copying these groups.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Tuesday, June 16, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static enum {
+ LFS_INIT,
+ LFS_CAN_APPLY_CALLED,
+ LFS_SET_LOCAL_CALLED,
+ LFS_ENCODED,
+ LFS_DECODED
+} link_filter_state;
+
+static herr_t link_filter_can_apply(hid_t dcpl_id, hid_t type_id, hid_t space_id)
+{
+ if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0)
+ return -1;
+
+ if(link_filter_state >= LFS_ENCODED)
+ return 1;
+
+ if(link_filter_state != LFS_INIT)
+ return -1;
+
+ link_filter_state = LFS_CAN_APPLY_CALLED;
+
+ return 1;
+} /* end link_fitler_can_apply */
+
+static herr_t link_filter_set_local(hid_t dcpl_id, hid_t type_id, hid_t space_id)
+{
+ if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0)
+ return -1;
+
+ if(link_filter_state >= LFS_ENCODED)
+ return 0;
+
+ if(link_filter_state != LFS_CAN_APPLY_CALLED)
+ return -1;
+
+ link_filter_state = LFS_SET_LOCAL_CALLED;
+
+ return 0;
+} /* end link_filter_set_local */
+
+static size_t link_filter_filter(unsigned int flags, size_t cd_nelmts,
+ const unsigned int cd_values[], size_t nbytes, size_t UNUSED *buf_size,
+ void UNUSED **buf)
+{
+ if(flags & H5Z_FLAG_OPTIONAL || cd_nelmts != 1 || cd_values[0] != 2112)
+ return 0;
+
+ if(link_filter_state == LFS_DECODED)
+ return nbytes;
+
+ if(flags & H5Z_FLAG_REVERSE) {
+ if(link_filter_state != LFS_ENCODED)
+ return 0;
+ link_filter_state = LFS_DECODED;
+ } else {
+ if(link_filter_state < LFS_SET_LOCAL_CALLED)
+ return 0;
+ link_filter_state = LFS_ENCODED;
+ } /* end else */
+
+ return nbytes;
+} /* end link_filter_filter */
+
+static int
+link_filters(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = -1, fcpl = -1;
+ hid_t gid1 = -1, gid2 = -1, gcpl1 = -1, gcpl2 = -1;
+ hid_t lcpl = -1;
+ size_t cd_nelmts = 1;
+ unsigned cd_value = 2112;
+ unsigned cd_value_out;
+ unsigned flags_out;
+ unsigned filter_config_out;
+ int nfilters = 0;
+ H5Z_class2_t filter_class;
+ char name_out[24];
+ char filename[NAME_BUF_SIZE];
+ htri_t tri_ret;
+ herr_t status;
+
+ /* This test actually always uses the new group format for the main group.
+ * The new format flag affects the version of object header messages,
+ * etc., which are important for this test. */
+ if(new_format)
+ TESTING("group link filters (w/new group format)")
+ else
+ TESTING("group link filters")
+
+ /* Initialize link filter state global */
+ link_filter_state = LFS_INIT;
+
+ /* Set up filename and create file*/
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+
+ if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create gcpl, force use of dense storage */
+ if((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_link_phase_change(gcpl1, 2, 2) < 0) TEST_ERROR
+
+ /* Add deflate and checksum filters, if available */
+ if((tri_ret = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0) TEST_ERROR
+ if(tri_ret) {
+ if(H5Pset_deflate(gcpl1, 6) < 0) TEST_ERROR
+ nfilters++;
+ } /* end if */
+ if((tri_ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32)) < 0) TEST_ERROR
+ if(tri_ret) {
+ if(H5Pset_fletcher32(gcpl1) < 0) TEST_ERROR
+ nfilters++;
+ } /* end if */
+
+ /* Register and add custom filter */
+ filter_class.version = H5Z_CLASS_T_VERS;
+ filter_class.id = H5Z_FILTER_RESERVED + 42;
+ filter_class.encoder_present = TRUE;
+ filter_class.decoder_present = TRUE;
+ filter_class.name = "custom_link_filter";
+ filter_class.can_apply = link_filter_can_apply;
+ filter_class.set_local = link_filter_set_local;
+ filter_class.filter = link_filter_filter;
+ if(H5Zregister(&filter_class) < 0) TEST_ERROR
+ if(H5Pset_filter(gcpl1, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0)
+ TEST_ERROR
+ nfilters++;
+
+ /* Test various other filter functions for use on gcpl's */
+ if(H5Pget_nfilters(gcpl1) != nfilters) TEST_ERROR
+ if(H5Pall_filters_avail(gcpl1) != TRUE) TEST_ERROR
+
+ /* Create a group using this filter, add some soft links to it */
+ if((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, gcpl1, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", gid1, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close file and group */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* Verify the filter has been applied */
+ if(link_filter_state != LFS_ENCODED) TEST_ERROR
+
+ /* Reopen file and group */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ if((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Retrieve gcpl, verify number of filters */
+ if((gcpl2 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR
+ if(H5Pget_nfilters(gcpl2) != nfilters) TEST_ERROR
+ if(H5Pclose(gcpl2) < 0) TEST_ERROR
+
+ /* Now try copying gcpl1, and verify number of filters */
+ if((gcpl2 = H5Pcopy(gcpl1)) < 0) TEST_ERROR
+ if(H5Pget_nfilters(gcpl2) != nfilters) TEST_ERROR
+ if(H5Pclose(gcpl2) < 0) TEST_ERROR
+
+ /* Add another soft link */
+ if(H5Lcreate_soft("/", gid1, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Copy the group */
+ if(H5Ocopy(fid, "group1", fid, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if((gid2 = H5Gopen2(fid, "group2", H5P_DEFAULT)) <0) TEST_ERROR
+
+ /* Verify that all links have been copied */
+ if(H5Lexists(gid2, "link1", H5P_DEFAULT) != TRUE) TEST_ERROR
+ if(H5Lexists(gid2, "link2", H5P_DEFAULT) != TRUE) TEST_ERROR
+ if(H5Lexists(gid2, "link3", H5P_DEFAULT) != TRUE) TEST_ERROR
+ if(H5Lexists(gid2, "link4", H5P_DEFAULT) != TRUE) TEST_ERROR
+
+ /* Retrieve gcpl, verify number of filters */
+ if((gcpl2 = H5Gget_create_plist(gid2)) < 0) TEST_ERROR
+ if(H5Pget_nfilters(gcpl2) != nfilters) TEST_ERROR
+
+ /* Delete 3 links to force the group back into compact mode */
+ if(H5Ldelete(gid1, "link2", H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ldelete(gid1, "link3", H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ldelete(gid1, "link4", H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Close file and groups */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* Reset link filter state */
+ link_filter_state = LFS_INIT;
+
+ /* Reopen file and group, add 2 links */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ if((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close file and group */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* Verify that the filter was reapplied */
+ if(link_filter_state != LFS_ENCODED) TEST_ERROR
+
+ /* Test H5Pget_filter_by_id2 and H5Pget_filter2 */
+ if(H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out,
+ &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0)
+ TEST_ERROR
+ if(flags_out != 0 || cd_value_out != cd_value
+ || HDstrcmp(filter_class.name, name_out)
+ || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED
+ | H5Z_FILTER_CONFIG_DECODE_ENABLED))
+ TEST_ERROR
+ if(H5Pget_filter2(gcpl2, nfilters - 1, &flags_out, &cd_nelmts,
+ &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0)
+ TEST_ERROR
+ if(flags_out != 0 || cd_value_out != cd_value
+ || HDstrcmp(filter_class.name, name_out)
+ || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED
+ | H5Z_FILTER_CONFIG_DECODE_ENABLED))
+ TEST_ERROR
+
+ /* Test H5Pmodify_filter */
+ cd_value++;
+ if(H5Pmodify_filter(gcpl2, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0)
+ TEST_ERROR
+ if(H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out,
+ &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0)
+ TEST_ERROR
+ if(flags_out != 0 || cd_value_out != cd_value
+ || HDstrcmp(filter_class.name, name_out)
+ || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED
+ | H5Z_FILTER_CONFIG_DECODE_ENABLED))
+ TEST_ERROR
+
+ /* Test H5Premove_filter */
+ if(H5Premove_filter(gcpl2, H5Z_FILTER_RESERVED + 42) < 0) TEST_ERROR
+ H5E_BEGIN_TRY {
+ status = H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42,
+ &flags_out, &cd_nelmts, &cd_value_out, (size_t)24, name_out,
+ &filter_config_out);
+ } H5E_END_TRY
+ if(status >= 0) TEST_ERROR
+
+ /* Close remaining ids */
+ if(H5Pclose(gcpl1) < 0) TEST_ERROR
+ if(H5Pclose(gcpl2) < 0) TEST_ERROR
+
+ /* Now create an object in the compressed group, creating intermediate
+ * groups, to verify that the filter pipeline is inherited for the groups
+ * that are created along the way */
+ /* Reopen file */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+
+ /* Create lcpl, setting the "create intermediate groups" flag */
+ if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_create_intermediate_group(lcpl, (unsigned)TRUE) < 0) TEST_ERROR
+
+ /* Create new group, with missing intermediate groups, in compressed group */
+ if((gid1 = H5Gcreate2(fid, "group1/group2/group3/group4", lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Close LCPL ID */
+ if(H5Pclose(lcpl) < 0) TEST_ERROR
+
+ /* Verify that new group doesn't have filters */
+ if((gcpl1 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR
+ if(H5Pget_nfilters(gcpl1) != 0) TEST_ERROR
+
+ /* Close group & GCPL IDs */
+ if(H5Pclose(gcpl1) < 0) TEST_ERROR
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+
+ /* Open intermediate groups that were created and verify that they have filters */
+ if((gid1 = H5Gopen2(fid, "group1/group2", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gcpl1 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR
+ if(H5Pget_nfilters(gcpl1) != nfilters) TEST_ERROR
+ if(H5Pclose(gcpl1) < 0) TEST_ERROR
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if((gid1 = H5Gopen2(fid, "group1/group2/group3", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((gcpl1 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR
+ if(H5Pget_nfilters(gcpl1) != nfilters) TEST_ERROR
+ if(H5Pclose(gcpl1) < 0) TEST_ERROR
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+
+ /* Now create the same file with and without deflate, and verify that the
+ * file size is smaller with deflate */
+ /* But only if the deflate filter is available */
+ if((tri_ret = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0) TEST_ERROR
+ if(tri_ret) {
+ h5_stat_size_t filesize_filtered;
+ h5_stat_size_t filesize_unfiltered;
+
+ /* Create gcpl, force use of dense storage */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_link_phase_change(fcpl, 2, 2) < 0) TEST_ERROR
+
+ /* Create file */
+ if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create links in file */
+ if(H5Lcreate_soft("/", fid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", fid, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", fid, "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close file, get file size */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+ filesize_unfiltered = h5_get_file_size(filename, fapl);
+
+ /* Set deflate fitler */
+ if(H5Pset_deflate(fcpl, 6) < 0) TEST_ERROR
+
+ /* Recreate the same file with the deflate filter */
+ if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", fid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", fid, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ if(H5Lcreate_soft("/", fid, "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close file, get file size */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+ filesize_filtered = h5_get_file_size(filename, fapl);
+
+ /* Check that the file size is smaller with the filter */
+ if((double)filesize_filtered
+ > (filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION))
+ TEST_ERROR
+
+ /* Close */
+ if(H5Pclose(fcpl) < 0) TEST_ERROR
+ } /* end if */
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid1);
+ H5Gclose(gid2);
+ H5Fclose(fid);
+ H5Pclose(lcpl);
+ H5Pclose(gcpl1);
+ H5Pclose(gcpl2);
+ H5Pclose(fcpl);
+ } H5E_END_TRY;
+ return -1;
+} /* end link_filters() */
+
+
+/*-------------------------------------------------------------------------
* Function: corder_create_empty
*
* Purpose: Create an empty group with creation order indices
@@ -7650,7 +9520,7 @@ corder_transition(hid_t fapl)
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
/* Get the size of the file with an empty group */
- if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Re-open the file */
@@ -7789,7 +9659,7 @@ corder_transition(hid_t fapl)
sprintf(objname, "filler %u", u);
if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR
} /* end for */
- sprintf(objname, "filler %u", 0);
+ sprintf(objname, "filler %u", (unsigned)0);
if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR
/* Close the group */
@@ -7799,7 +9669,7 @@ corder_transition(hid_t fapl)
if(H5Fclose(file_id) < 0) TEST_ERROR
/* Get the size of the file now */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
if(file_size != empty_size) TEST_ERROR
PASSED();
@@ -7860,7 +9730,7 @@ corder_delete(hid_t fapl)
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
/* Get the size of an empty file */
- if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Re-open the file */
if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
@@ -7925,7 +9795,7 @@ corder_delete(hid_t fapl)
} /* end if */
/* Get the size of the file now */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
if(file_size != empty_size) TEST_ERROR
} /* end for */
@@ -9028,7 +10898,7 @@ HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr);
op_data->ncalled++;
/* Get the link information directly to compare */
- if(H5Lget_info(group_id, link_name, &my_info, H5P_DEFAULT) < 0)
+ if(H5Lget_info(group_id, link_name, &my_info, H5P_DEFAULT) < 0)
return(H5_ITER_ERROR);
/* Check more things for link iteration (vs. group iteration) */
@@ -9165,7 +11035,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order,
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Iterate over links in group, with H5Giterate */
- iter_info->nskipped = gskip = 0;
+ iter_info->nskipped = (unsigned)(gskip = 0);
iter_info->order = order;
iter_info->stop = -1;
iter_info->ncalled = 0;
@@ -9326,7 +11196,7 @@ link_iterate(hid_t fapl)
/* Allocate the "visited link" array */
iter_info.max_visit = max_compact * 2;
- if(NULL == (visited = HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR
+ if(NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR
iter_info.visited = visited;
/* Loop over operating on different indices on link fields */
@@ -9513,7 +11383,7 @@ HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr);
op_data->ncalled++;
/* Get the link information directly to compare */
- if(H5Lget_info(group_id, link_name, &my_info, H5P_DEFAULT) < 0)
+ if(H5Lget_info(group_id, link_name, &my_info, H5P_DEFAULT) < 0)
return(H5_ITER_ERROR);
/* Check more things for link iteration (vs. group iteration) */
@@ -9734,6 +11604,20 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order,
} H5E_END_TRY;
if(ret >= 0) TEST_ERROR
+ /* Check for iteration w/bad location ID */
+ skip = 0;
+ H5E_BEGIN_TRY {
+ ret = H5Literate((-1), H5_INDEX_NAME, order, &skip, link_iterate_fail_cb, NULL);
+ } H5E_END_TRY;
+ if(ret >= 0) TEST_ERROR
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ H5E_BEGIN_TRY {
+ ret = H5Giterate((-1), ".", &gskip, group_iterate_old_cb, iter_info);
+ } H5E_END_TRY;
+ if(ret >= 0) TEST_ERROR
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
/* Success */
return(0);
@@ -9771,7 +11655,7 @@ link_iterate_old(hid_t fapl)
/* Allocate the "visited link" array */
iter_info.max_visit = CORDER_NLINKS;
- if(NULL == (visited = HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR
+ if(NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR
iter_info.visited = visited;
/* Loop over operating in different orders */
@@ -9882,7 +11766,7 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id,
haddr_t *objno)
{
char mntname[NAME_BUF_SIZE]; /* Link value */
- hid_t group_id; /* ID of group to test */
+ hid_t group_id = (-1); /* ID of group to test */
H5O_info_t oi; /* Buffer for querying object's info */
haddr_t mnt_root_addr; /* Address of root group in file to mount */
hid_t obj_id; /* ID of object opened */
@@ -10009,7 +11893,7 @@ open_by_idx(hid_t fapl)
if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR
/* Allocate object address array */
- if(NULL == (objno = HDmalloc(sizeof(haddr_t) * (max_compact * 2)))) TEST_ERROR
+ if(NULL == (objno = (haddr_t *)HDmalloc(sizeof(haddr_t) * (max_compact * 2)))) TEST_ERROR
/* Create file to mount */
h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
@@ -10350,7 +12234,7 @@ object_info_check(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type,
H5_iter_order_t order, unsigned max_links, haddr_t *objno)
{
char objname[NAME_BUF_SIZE]; /* Object name */
- hid_t group_id; /* ID of group to test */
+ hid_t group_id = (-1); /* ID of group to test */
H5O_info_t oinfo; /* Buffer for querying object's info */
unsigned u, v; /* Local index variables */
@@ -10451,7 +12335,7 @@ object_info(hid_t fapl)
if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR
/* Allocate object address array */
- if(NULL == (objno = HDmalloc(sizeof(haddr_t) * (max_compact * 2)))) TEST_ERROR
+ if(NULL == (objno = (haddr_t *)HDmalloc(sizeof(haddr_t) * (max_compact * 2)))) TEST_ERROR
/* Create dataspace for attributes */
if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR
@@ -11559,7 +13443,7 @@ timestamps(hid_t fapl)
/* Re-open the file */
- if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
/* Open groups */
if((group_id = H5Gopen2(file_id, TIMESTAMP_GROUP_1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -11637,163 +13521,180 @@ error:
int
main(void)
{
- const char *envval = NULL;
+ hid_t fapl, fapl2; /* File access property lists */
+ int nerrors = 0;
+ hbool_t new_format; /* Whether to use the new format or not */
+ const char *env_h5_drvr; /* File Driver value from environment */
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- hid_t fapl, fapl2; /* File access property lists */
- int nerrors = 0;
- hbool_t new_format; /* Whether to use the new format or not */
-
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Copy the file access property list */
- if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+ env_h5_drvr = HDgetenv("HDF5_DRIVER");
+ if(env_h5_drvr == NULL)
+ env_h5_drvr = "nomatch";
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+ h5_reset();
+ fapl = h5_fileaccess();
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
-
- /* Check for FAPL to use */
- if(new_format)
- my_fapl = fapl2;
- else
- my_fapl = fapl;
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
- /* General tests... (on both old & new format groups */
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+ /* Loop over using new group format */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
- nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Test new H5L link creation routine */
- nerrors += test_lcpl(my_fapl, new_format);
- nerrors += test_move(my_fapl, new_format);
- nerrors += test_copy(my_fapl, new_format);
- nerrors += test_move_preserves(my_fapl, new_format);
+ /* Check for FAPL to use */
+ if(new_format)
+ my_fapl = fapl2;
+ else
+ my_fapl = fapl;
+
+ /* General tests... (on both old & new format groups */
+ nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Test new H5L link creation routine */
+ nerrors += test_lcpl(my_fapl, new_format);
+ nerrors += test_move(my_fapl, new_format);
+ nerrors += test_copy(my_fapl, new_format);
+ nerrors += test_move_preserves(my_fapl, new_format);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- nerrors += test_deprec(my_fapl, new_format);
+ nerrors += test_deprec(my_fapl, new_format);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
#ifndef H5_CANNOT_OPEN_TWICE
- nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0;
#endif /* H5_CANNOT_OPEN_TWICE */
- nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0;
#ifndef H5_CANNOT_OPEN_TWICE
- nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_self(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_pingpong(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0;
#endif /* H5_CANNOT_OPEN_TWICE */
- nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0;
#ifndef H5_CANNOT_OPEN_TWICE
- nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_closing(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
#endif /* H5_CANNOT_OPEN_TWICE */
- nerrors += external_link_endian(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* tests for external link */
- nerrors += external_link_env(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0;
-
+ nerrors += external_link_endian(new_format) < 0 ? 1 : 0;
+ nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* tests for external link */
+ nerrors += external_link_env(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_acc_flags(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0;
#ifdef H5_HAVE_WINDOW_PATH
- nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0;
#endif
+ nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
- /* These tests assume that external links are a form of UD links,
- * so assume that everything that passed for external links
- * above has already been tested for UD links.
- */
- if(new_format == TRUE) {
- nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */
- nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */
- } /* end if */
- nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += lapl_nlinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += linkinfo(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Misc. extra tests, useful for both new & old format files */
- nerrors += link_visit(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Keep this test last, it's testing files that are used above */
- /* do not do this for files used by external link tests */
- nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0;
- } /* end for */
+ /* These tests assume that external links are a form of UD links,
+ * so assume that everything that passed for external links
+ * above has already been tested for UD links.
+ */
+ if(new_format == TRUE) {
+ nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */
+ nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */
+ } /* end if */
+ nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += lapl_nlinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += linkinfo(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Misc. extra tests, useful for both new & old format files */
+ nerrors += link_visit(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit_stop(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += link_filters(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Keep this test last, it's testing files that are used above */
+ /* do not do this for files used by external link tests */
+ nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0;
+ } /* end for */
- /* New group revision feature tests */
- nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0;
+ /* New group revision feature tests */
+ nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0;
/* XXX: when creation order indexing is fully working, go back and add checks
* to these tests to make certain that the creation order values are
* correct.
*/
- nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0;
- nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0;
- nerrors += corder_transition(fapl2) < 0 ? 1 : 0;
- nerrors += corder_delete(fapl2) < 0 ? 1 : 0;
- nerrors += link_info_by_idx(fapl2) < 0 ? 1 : 0;
- nerrors += delete_by_idx(fapl2) < 0 ? 1 : 0;
- nerrors += link_iterate(fapl2) < 0 ? 1 : 0;
- nerrors += open_by_idx(fapl2) < 0 ? 1 : 0;
- nerrors += object_info(fapl2) < 0 ? 1 : 0;
- nerrors += group_info(fapl2) < 0 ? 1 : 0;
- nerrors += timestamps(fapl2) < 0 ? 1 : 0;
-
- /* Test new API calls on old-style groups */
- nerrors += link_info_by_idx_old(fapl) < 0 ? 1 : 0;
- nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0;
- nerrors += link_iterate_old(fapl) < 0 ? 1 : 0;
- nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0;
- nerrors += object_info_old(fapl) < 0 ? 1 : 0;
- nerrors += group_info_old(fapl) < 0 ? 1 : 0;
-
- /* Close 2nd FAPL */
- H5Pclose(fapl2);
-
- /* Results */
- if(nerrors) {
- printf("***** %d LINK TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
- exit(1);
- }
- printf("All link tests passed.\n");
- h5_cleanup(FILENAME, fapl);
- /* clean up tmp directory created by external link tests */
- HDrmdir(TMPDIR);
+ nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0;
+ nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0;
+ nerrors += corder_transition(fapl2) < 0 ? 1 : 0;
+ nerrors += corder_delete(fapl2) < 0 ? 1 : 0;
+ nerrors += link_info_by_idx(fapl2) < 0 ? 1 : 0;
+ nerrors += delete_by_idx(fapl2) < 0 ? 1 : 0;
+ nerrors += link_iterate(fapl2) < 0 ? 1 : 0;
+ nerrors += open_by_idx(fapl2) < 0 ? 1 : 0;
+ nerrors += object_info(fapl2) < 0 ? 1 : 0;
+ nerrors += group_info(fapl2) < 0 ? 1 : 0;
+ nerrors += timestamps(fapl2) < 0 ? 1 : 0;
+
+ /* Test new API calls on old-style groups */
+ nerrors += link_info_by_idx_old(fapl) < 0 ? 1 : 0;
+ nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0;
+ nerrors += link_iterate_old(fapl) < 0 ? 1 : 0;
+ nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0;
+ nerrors += object_info_old(fapl) < 0 ? 1 : 0;
+ nerrors += group_info_old(fapl) < 0 ? 1 : 0;
+
+ /* Close 2nd FAPL */
+ H5Pclose(fapl2);
+
+ h5_cleanup(FILENAME, fapl);
+
+ /* Test that external links can be used after a library reset. MUST be
+ * called last so the reset doesn't interfere with the property lists. This
+ * routine will delete its own file. */
+ nerrors += external_reset_register() < 0 ? 1 : 0;
+
+ /* Results */
+ if(nerrors) {
+ printf("***** %d LINK TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ exit(1);
}
- else
- puts("All link tests skipped - Incompatible with current Virtual File Driver");
+ printf("All link tests passed.\n");
+
+ /* clean up symlink created by external link tests */
+ HDremove(SYMLINK1);
+ HDremove(SYMLINK2);
+
+ /* clean up tmp directory created by external link tests */
+ HDrmdir(TMPDIR);
+ HDrmdir(TMPDIR2);
+
return 0;
error:
diff --git a/test/mf.c b/test/mf.c
new file mode 100644
index 0000000..ca89b79
--- /dev/null
+++ b/test/mf.c
@@ -0,0 +1,7314 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Tests for file memory management consist of 3 parts:
+ * test_mf_eoa_*() tests for file meomory that interact with file allocation
+ * test_mf_fs_*() tests for file memory that interact with the free-space manager
+ * test_mf_aggr_*() tests for file memory that interact with the aggregators
+ * test_mf_align_*() tests for file memory with alignment setting
+ * test_filespace_*() tests for file space management
+ */
+
+#include "h5test.h"
+
+#define H5MF_PACKAGE
+#include "H5MFpkg.h"
+
+#define H5FS_PACKAGE
+#include "H5FSpkg.h"
+
+#define H5F_PACKAGE
+#define H5F_TESTING
+#include "H5Fpkg.h"
+
+#include "H5FLprivate.h"
+#include "H5Iprivate.h"
+#include "H5Vprivate.h"
+
+#define FILENAME_LEN 1024
+
+#define TEST_BLOCK_SIZE1 1
+#define TEST_BLOCK_SIZE2 2
+#define TEST_BLOCK_SIZE3 3
+#define TEST_BLOCK_SIZE4 4
+#define TEST_BLOCK_SIZE5 5
+#define TEST_BLOCK_SIZE6 6
+#define TEST_BLOCK_SIZE7 7
+#define TEST_BLOCK_SIZE8 8
+#define TEST_BLOCK_SIZE20 20
+#define TEST_BLOCK_SIZE30 30
+#define TEST_BLOCK_SIZE40 40
+#define TEST_BLOCK_SIZE50 50
+#define TEST_BLOCK_SIZE80 80
+#define TEST_BLOCK_SIZE200 200
+#define TEST_BLOCK_SIZE600 600
+#define TEST_BLOCK_SIZE700 700
+#define TEST_BLOCK_SIZE1034 1034
+#define TEST_BLOCK_SIZE1970 1970
+#define TEST_BLOCK_SIZE2058 2058
+#define TEST_BLOCK_SIZE8000 8000
+#define TEST_BLOCK_SIZE2048 2048
+
+#define TEST_BLOCK_ADDR70 70
+#define TEST_BLOCK_ADDR100 100
+
+#define TEST_ALIGN1024 1024
+#define TEST_ALIGN4096 4096
+
+#define TEST_THRESHOLD10 10
+#define TEST_THRESHOLD3 3
+
+#define CORE_INCREMENT 1024
+#define FAMILY_SIZE 1024
+
+const char *FILENAME[] = {
+ "mf",
+ NULL
+};
+
+typedef enum {
+ TEST_NORMAL, /* size of aggregator is >= alignment size */
+ TEST_AGGR_SMALL, /* size of aggregator is smaller than alignment size */
+ TEST_NTESTS /* The number of test types, must be last */
+} test_type_t;
+
+typedef struct frspace_state_t {
+ hsize_t tot_space; /* Total amount of space tracked */
+ hsize_t tot_sect_count; /* Total # of sections tracked */
+ hsize_t serial_sect_count; /* # of serializable sections tracked */
+ hsize_t ghost_sect_count; /* # of un-serializable sections tracked */
+} frspace_state_t;
+
+
+static int check_stats(const H5F_t *, const H5FS_t *, frspace_state_t *);
+static unsigned test_mf_eoa(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_tmp(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_fs_start(hid_t fapl);
+static unsigned test_mf_fs_alloc_free(hid_t fapl);
+static unsigned test_mf_fs_extend(hid_t fapl);
+static unsigned test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl);
+static unsigned test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl);
+static unsigned test_mf_fs_persist(hid_t fapl_new, hid_t fcpl);
+static unsigned test_mf_fs_gone(hid_t fapl_new, hid_t fcpl);
+static unsigned test_mf_fs_split(hid_t fapl_new, hid_t fcpl);
+static unsigned test_mf_fs_multi(hid_t fapl, hid_t fcpl);
+static unsigned test_mf_fs_drivers(hid_t fapl);
+
+/*
+ * Verify statistics for the free-space manager
+ */
+static int
+check_stats(const H5F_t *f, const H5FS_t *frsp, frspace_state_t *state)
+{
+ H5FS_stat_t frspace_stats; /* Statistics about the heap */
+
+ /* Get statistics for free-space and verify they are correct */
+ if(H5FS_stat_info(f, frsp, &frspace_stats) < 0)
+ FAIL_STACK_ERROR
+
+ if(frspace_stats.tot_space != state->tot_space) {
+ HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n",
+ frspace_stats.tot_space, state->tot_space);
+ TEST_ERROR
+ } /* end if */
+ if(frspace_stats.tot_sect_count != state->tot_sect_count) {
+ HDfprintf(stdout, "frspace_stats.tot_sect_count = %Hu, state->tot_sect_count = %Hu\n",
+ frspace_stats.tot_sect_count, state->tot_sect_count);
+ TEST_ERROR
+ } /* end if */
+ if(frspace_stats.serial_sect_count != state->serial_sect_count) {
+ HDfprintf(stdout, "frspace_stats.serial_sect_count = %Hu, state->serial_sect_count = %Hu\n",
+ frspace_stats.serial_sect_count, state->serial_sect_count);
+ TEST_ERROR
+ } /* end if */
+ if(frspace_stats.ghost_sect_count != state->ghost_sect_count) {
+ HDfprintf(stdout, "frspace_stats.ghost_sect_count = %Hu, state->ghost_sect_count = %Hu\n",
+ frspace_stats.ghost_sect_count, state->ghost_sect_count);
+ TEST_ERROR
+ } /* end if */
+
+ /* All tests passed */
+ return(0);
+
+error:
+ return(1);
+} /* check_stats() */
+
+/*
+ * To verify that blocks are allocated from file allocation
+ *
+ * Set up:
+ * Turn off using meta/small data aggregator
+ * There is nothing in free-space manager
+ *
+ * Allocate two blocks which should be from file allocation
+ */
+static unsigned
+test_mf_eoa(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl_new; /* copy of fapl */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ haddr_t addr1, addr2;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MM_alloc() of file allocation");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* Set the filename to use for this test */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Turn off using meta/small data aggregator */
+ H5Pset_meta_block_size(fapl_new, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
+ if (new_ma_addr != ma_addr)
+ TEST_ERROR
+
+ if (addr1 < (haddr_t)file_size)
+ TEST_ERROR
+
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
+ if (new_ma_addr != ma_addr)
+ TEST_ERROR
+
+ if (addr2 < (haddr_t)file_size)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50))
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support continuous address space");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_eoa() */
+
+/*
+ * To verify that an allocated block from file allocation is shrunk.
+ *
+ * Set up:
+ * Turn off using meta/small data aggregator
+ * There is nothing in free-space manager
+ *
+ * Test 1: Allocate a block of 30 from file allocation
+ * H5MF_try_shrink() the block by 30 : succeed
+ * Test 2: Allocate a block of 30 from file allocation
+ * H5MF_try_shrink() the block by 20 : fail
+ * Test 3: Allocate a block of 30 from file allocation
+ * H5MF_try_shrink() the block by 40 : fail
+ * Test 4: Allocate a block of 30 from file allocation
+ * H5MF_try_shrink() the block by 20 from the end: succeed
+ *
+ */
+static unsigned
+test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl_new; /* copy of fapl */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ haddr_t addr;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_try_shrink() of file allocation: test 1");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Turn off using meta/small data aggregator */
+ H5Pset_meta_block_size(fapl_new, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ type = H5FD_MEM_SUPER;
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if (addr < (haddr_t)file_size)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+ if (new_ma_size != ma_size) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ /* should succeed */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30) <= 0)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+ if (new_ma_size != ma_size) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_shrink() of file allocation: test 2");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ if(contig_addr_vfd) {
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if (addr < (haddr_t)file_size)
+ TEST_ERROR
+
+ /* should not succeed in shrinking */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30 - 10) > 0)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+ if (new_ma_size != ma_size) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+
+ TESTING("H5MF_try_shrink() of file allocation: test 3");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ if(contig_addr_vfd) {
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ /* should not succeed in shrinking */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30 + 10) > 0)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+ if (new_ma_size != ma_size) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_shrink() of file allocation: test 4");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ if(contig_addr_vfd) {
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ /* should succeed in shrinking */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr+10, (hsize_t)(TEST_BLOCK_SIZE30 - 10)) <= 0)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+ if (new_ma_size != ma_size) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+10))
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_eoa_shrink() */
+
+/*
+ * To verify that an allocated block from file allocation is extended.
+ *
+ * Set up:
+ * Turn off using meta/small data aggregator
+ * There is nothing in free-space manager
+ *
+ * Test 1: Allocate a block of 30
+ * H5MF_try_extend() the block of size 30 by 50: succeed
+ *
+ * Test 2: Allocate a block of 30
+ * H5MF_try_extend() the block of size 20 by 50: fail
+ */
+static unsigned
+test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl_new; /* copy of fapl */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* File size */
+ H5FD_mem_t type;
+ haddr_t addr;
+ htri_t extended;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_try_extend() of file allocation: test 1");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Turn off using meta/small data aggregator */
+ H5Pset_meta_block_size(fapl_new, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ type = H5FD_MEM_SUPER;
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ if (addr < (haddr_t)file_size)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* should succeed */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(extended <= 0)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50))
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_extend() of file allocation: test 2");
+
+ /* Skip test when using VFDs that has different address spaces for each
+ * type of metadata allocation.
+ */
+ if(contig_addr_vfd) {
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ type = H5FD_MEM_SUPER;
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if (addr < (haddr_t)file_size)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr)
+ TEST_ERROR
+
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr, (hsize_t)(TEST_BLOCK_SIZE30-10), (hsize_t)(TEST_BLOCK_SIZE50));
+
+ /* should not succeed */
+ if(extended > 0)
+ TEST_ERROR
+
+ /* nothing should be changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size+TEST_BLOCK_SIZE30)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_eoa_extend() */
+
+/*
+ * To verify that temporary blocks are allocated correctly
+ *
+ * Set up:
+ * There is nothing in free-space manager
+ *
+ * Tests:
+ * Allocate a reasonable-sized temporary block
+ * Check that the temporary address is high enough
+ * Check that file I/O with the temporary address fails
+ * Check that freeing a temporary address fails
+ * Check that closing the file doesn't change the file's size
+ * Check that overlapping normal & temporary address space fails:
+ * - Reopen the file
+ * - Allocate enough temporary space to use ~1/3 of the file
+ * - Allocate enough 'normal' space to use ~1/3 of the file
+ * - Check that allocating another 1/2 of the file as temporary address
+ * space fails
+ * - Check that allocating another 1/2 of the file as normal address
+ * space fails
+ */
+static unsigned
+test_mf_tmp(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+
+ TESTING("'temporary' file space allocation");
+
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ haddr_t maxaddr; /* File's max. address */
+ haddr_t tmp_addr; /* Temporary space file address */
+ haddr_t norm_addr; /* Normal space file address */
+ haddr_t check_addr; /* File address for checking for errors */
+ unsigned char buf = 0; /* Buffer to read/write with */
+ herr_t status; /* Generic status value */
+
+ /* Set the filename to use for this test */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Retrieve the file's maxaddr */
+ if(H5F_get_maxaddr_test(file, &maxaddr) < 0)
+ FAIL_STACK_ERROR
+
+ /* Allocate some temporary address space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TEST_BLOCK_SIZE30)))
+ FAIL_STACK_ERROR
+
+ /* Check if temporary file address is valid */
+ if(!H5F_IS_TMP_ADDR(f, tmp_addr))
+ TEST_ERROR
+ if(tmp_addr < (haddr_t)(maxaddr - TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ /* Reading & writing with a temporary address value should fail */
+ H5E_BEGIN_TRY {
+ status = H5F_block_read(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), H5P_DATASET_XFER_DEFAULT, &buf);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+ H5E_BEGIN_TRY {
+ status = H5F_block_write(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), H5P_DATASET_XFER_DEFAULT, &buf);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+
+ /* Freeing a temporary address value should fail */
+ H5E_BEGIN_TRY {
+ status = H5MF_xfree(f, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, tmp_addr, (hsize_t)TEST_BLOCK_SIZE30);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(new_file_size != file_size)
+ TEST_ERROR
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 1/3 of the file as temporary address space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3))))
+ FAIL_STACK_ERROR
+ if(!H5F_IS_TMP_ADDR(f, tmp_addr))
+ TEST_ERROR
+
+ /* Allocate 1/3 of the file as normal address space */
+ if(HADDR_UNDEF == (norm_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(maxaddr / 3))))
+ FAIL_STACK_ERROR
+ if(H5F_IS_TMP_ADDR(f, norm_addr))
+ TEST_ERROR
+
+ /* Test that pushing temporary space allocation into normal space fails */
+ H5E_BEGIN_TRY {
+ check_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3));
+ } H5E_END_TRY;
+ if(H5F_addr_defined(check_addr))
+ TEST_ERROR
+
+ /* Test that pushing normal space allocation into temporary space fails */
+ H5E_BEGIN_TRY {
+ check_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(maxaddr / 3));
+ } H5E_END_TRY;
+ if(H5F_addr_defined(check_addr))
+ TEST_ERROR
+
+ /* Free the normal block (so the file doesn't blow up to a huge size) */
+ if(H5MF_xfree(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, norm_addr, (hsize_t)(maxaddr / 3)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support continuous address space");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_tmp() */
+
+/*
+ * To verify that the free-space manager is created or opened
+ *
+ * Set up:
+ * Turn off using meta/small data aggregator
+ */
+static unsigned
+test_mf_fs_start(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl_new; /* copy of fapl */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ frspace_state_t state;
+
+
+ TESTING("H5MF_alloc_create()/H5MF_alloc_open() of free-space manager");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Turn off using meta/small data aggregator */
+ H5Pset_meta_block_size(fapl_new, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Start up free-space manager */
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_start() */
+
+
+/*
+ * To verify that a block is allocated/freed from/to the free-space manager
+ *
+ * Set up:
+ * Turn off using meta/small data aggregator
+ *
+ * Test 1:
+ * Add section A to free-space manager (addr=70, size=30)
+ * Allocate a block of size=30
+ * The returned space's address should be same as section A's address
+ * Deallocate the block which will be returned to the free-space manager
+ * Test 2:
+ * Add section A to free-space manager (addr=70, size=30)
+ * Allocate a block of size=20
+ * The returned space's address should be same as section A's address
+ * There should still be space of 10 left in the free-space manager
+ * Deallocate the block which will be returned to free-space manager
+ * Test 3:
+ * Add section A to free-space manager (addr=70, size=30)
+ * Allocate a block of size=40
+ * The free-space manager is unable to fulfill the request
+ * The block is allocated from file allocation
+ * Deallocate the block which will be returned to free-space manager
+ * (the space is shrunk and freed since it is at end of file)
+ */
+static unsigned
+test_mf_fs_alloc_free(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl_new; /* copy of fapl */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ H5MF_free_section_t *sect_node = NULL;
+ haddr_t addr;
+ frspace_state_t state;
+ H5MF_sect_ud_t udata;
+ H5FS_section_info_t *node;
+
+ TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 1");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Turn off using meta/small data aggregator */
+ H5Pset_meta_block_size(fapl_new, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 30 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is section A in free-space */
+ if (addr != TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ state.tot_space -= TEST_BLOCK_SIZE30;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the block to free-space */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30);
+
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove section A from free-space */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0)
+
+ /* Free the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 2");
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 20 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE20));
+
+ /* Verify that the allocated block is section A in free-space manager */
+ if (addr != TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ /* should still have 1 section of size 10 left in free-space manager */
+ state.tot_space -= (TEST_BLOCK_SIZE20);
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the block to free-space manager */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)(TEST_BLOCK_SIZE20));
+
+ /* Still 1 section in free-space because of merging */
+ state.tot_space += TEST_BLOCK_SIZE20;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove section A from free-space manager */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0)
+ FAIL_STACK_ERROR
+
+ /* Free the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 3");
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /*
+ * Allocate a block of 40.
+ * Since free-space manager cannot fulfull the request,
+ * the block is obtained from file allocation
+ */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE40));
+
+ /* Verify that the allocated block is not section A in free-space */
+ if (addr == TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ /* free-space info should be the same */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove section A from free-space */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0)
+ FAIL_STACK_ERROR
+
+ /* Free the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the block of size 40 to free-space */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)(TEST_BLOCK_SIZE40));
+
+ /*
+ * Free-space info is the same.
+ * The block is returned to free-space.
+ * It is shrunk and freed because it is at end of file.
+ */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_alloc_free() */
+
+
+/*
+ * To verify that a block allocated from the free-space manager can be extended
+ *
+ * Set up:
+ * Turn off using meta/small data aggregator
+ *
+ * Test 1:
+ * Add section A to free-space manager: addr=70, size=30
+ * Allocate a block of size 30 from free-space manager
+ * Add section B to free-space manager: addr=100, size=50
+ * Try to extend the allocated block by requested-size=50
+ * Succeed: section A adjoins section B (70+30=100 which is section B's address) and
+ * requested-size (50) is equal to the size of section B
+ * Test 2:
+ * Add section A to free-space manager: addr=70, size=30
+ * Allocate a block of size 30 from free-space manager
+ * Add section B to free-space manager: addr=100, size=50
+ * Try to extend the allocated block by requested-size=60
+ * Fail: section A adjoins section B (70+30=100 which is section B's address) but
+ * requested-size (60) > size of section B (50)
+ *
+ * Test 3:
+ * Add section A to free-space manager: addr=70, size=30
+ * Allocate a block of size 30 from free-space manager
+ * Add section B to free-space manager: addr=100, size=50
+ * Try to extend the allocated block by requested-size=40
+ * Succeed: section A adjoins section B (70+30=100 which is section B's address) and
+ * requested-size (40) < size of section B (50), therefore,
+ * a section of 10 is left in the free-space manager
+ * Test 4:
+ * Add section A to free-space manager: addr=70, size=20
+ * Allocate a block of size 20 from free-space manager
+ * Add section B to free-space manager: addr=100, size=50
+ * Try to extend the allocated block by 50 from the free-space_manager:
+ * Fail: section A does not adjoin section B (70+20 != address of section B) even though
+ * the requested-size (50) equal to size of section B (50)
+ */
+static unsigned
+test_mf_fs_extend(hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl_new; /* copy of fapl */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ H5MF_free_section_t *sect_node1 = NULL, *sect_node2=NULL;
+ haddr_t addr;
+ frspace_state_t state; /* State of free space*/
+ H5MF_sect_ud_t udata;
+ H5FS_section_info_t *node;
+ htri_t extended;
+
+ TESTING("H5MF_try_extend() of free-space manager:test 1");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Turn off using meta/small data aggregator */
+ H5Pset_meta_block_size(fapl_new, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 30 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is section A in free-space manager */
+ if (addr != TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ state.tot_space -= TEST_BLOCK_SIZE30;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Create section B */
+ sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Add section B to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ state.tot_space += TEST_BLOCK_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Try to extend the allocated block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* should succeed */
+ if(extended <= 0)
+ TEST_ERROR
+
+ /* Section B is removed from free-space manager */
+ state.tot_space -= TEST_BLOCK_SIZE50;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the extended block to free-space manager */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50));
+
+ /* Verify that the extended block is back into free-space */
+ state.tot_space += TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50;
+ state.tot_sect_count = 1;
+ state.serial_sect_count = 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove the extended block */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50), (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ /* Remove the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_try_extend() of free-space manager:test 2");
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 30 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is section A in free-space manager */
+ if (addr != TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ state.tot_space -= TEST_BLOCK_SIZE30;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Create section B */
+ sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Add section B to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ state.tot_space += TEST_BLOCK_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Try to extend the allocated block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)(TEST_BLOCK_SIZE50+10));
+
+ /* Should not be able to extend the allocated block */
+ if(extended)
+ TEST_ERROR
+
+ /* free-space info should remain the same */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the allocated block A to free-space */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* the returned section A is merged with section B in free-space */
+ /* rest of the info remains the same */
+ state.tot_space += TEST_BLOCK_SIZE30;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove the merged sections A & B from free-space */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50), (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ /* Remove the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_try_extend() of free-space manager:test 3");
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE30;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 30 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is section A in free-space manager */
+ if (addr != TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ state.tot_space -= TEST_BLOCK_SIZE30;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Create section B */
+ sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Add section B to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ state.tot_space += TEST_BLOCK_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Try to extend the allocated block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE30, (hsize_t)(TEST_BLOCK_SIZE40));
+
+ /* Should succeed in extending the allocated block */
+ if(extended <=0)
+ TEST_ERROR
+
+ /* Should have 1 section of size=10 left in free-space manager */
+ state.tot_space -= (TEST_BLOCK_SIZE40);
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the extended block */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE40));
+
+ /* rest info is same, the extended section returned is merged with the section in free-space */
+ state.tot_space += (TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE40);
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove the merged sections A & B from free-space */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50), (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ /* Remove the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_try_extend() of free-space manager:test 4");
+
+ /* Re-open the file with meta/small data setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Create section A */
+ sect_node1 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)(TEST_BLOCK_SIZE30-10));
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A of size=20 to free-space */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += (TEST_BLOCK_SIZE30-10);
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of size=20 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE30-10));
+
+ /* Verify that the allocated block is section A in free-space manager */
+ if (addr != TEST_BLOCK_ADDR70)
+ TEST_ERROR
+
+ state.tot_space -= (TEST_BLOCK_SIZE30-10);
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Create section B */
+ sect_node2 = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR100, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Add section B to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ state.tot_space += TEST_BLOCK_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Try to extend the allocated block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)TEST_BLOCK_ADDR70, (hsize_t)(TEST_BLOCK_SIZE30-10), (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Should not succeed in extending the allocated block */
+ if(extended)
+ TEST_ERROR
+
+ /* Free-space info should be the same */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the allocated block */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)(TEST_BLOCK_SIZE30-10));
+
+ state.tot_space += (TEST_BLOCK_SIZE30-10);
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Remove section A from free-space manger */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)(TEST_BLOCK_SIZE30-10), (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ /* Remove the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* Remove section B from free-space manager */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE50, (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ /* Remove the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_extend() */
+
+/*
+ * To verify that an aggregator is absorbed into a section.
+ *
+ * Test 1: To aborb the aggregator onto the beginning of the section
+ * Allocate block A from meta_aggr
+ * Create a free-space section node with an address that adjoins
+ * the end of meta_aggr and a size to make the aggregator
+ * get absorbed into the section.
+ * The adding of the section to free-space will call H5MF_aggr_absorb(),
+ * which will absorb meta_aggr to the section:
+ * section size + remaining size of aggregator is > aggr->alloc_size,
+ * section is allowed to absorb an aggregator (allow_sect_absorb is true)
+ *
+ * Test 2: To absorb the aggregator onto the end of the section
+ * Allocate block A from meta_aggr
+ * Allocate block B from sdata_aggr
+ * Create a free-space section node with an address that adjoins
+ * the beginning of meta_aggr and a size to make the
+ * aggregator get absorbed into the section.
+ * The adding of the section to free-space will call H5MF_aggr_absorb(),
+ * which will absorb meta_aggr to the section:
+ * section size + remaining size of aggregator is > aggr->alloc_size,
+ * section is allowed to absorb an aggregator (allow_sect_absorb is true)
+ */
+static unsigned
+test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type, stype;
+ haddr_t addr, saddr;
+ haddr_t ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0;
+ H5MF_free_section_t *sect_node=NULL;
+ H5MF_sect_ud_t udata;
+ H5FS_section_info_t *node;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("A free-space section absorbs an aggregator: test 1");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Allocate a section from meta_aggr */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ /* Add a section to free-space that adjoins end of the aggregator */
+ sect_node = H5MF_sect_simple_new((haddr_t)(ma_addr+ma_size), (hsize_t)TEST_BLOCK_SIZE2048);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* When adding, meta_aggr is absorbed onto the beginning of the section */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ /* Verify that the section did absorb the aggregator */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE2048, (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ if (node->addr != ma_addr) TEST_ERROR
+ if (node->size != (ma_size + TEST_BLOCK_SIZE2048)) TEST_ERROR
+
+ /* Remove the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* Restore info for aggregator */
+ f->shared->meta_aggr.addr = ma_addr;
+ f->shared->meta_aggr.size = ma_size;
+
+ /* Remove section from meta_aggr */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("A free-space section absorbs an aggregator: test 2");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ if(contig_addr_vfd) {
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ /* Allocate a section from meta_aggr */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ /* Allocate a section from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Add a section to free-space that adjoins the beginning of meta_aggr */
+ sect_node = H5MF_sect_simple_new((haddr_t)addr, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* When adding, meta_aggr is absorbed onto the end of the section */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ /* Verify that the section did absorb the aggregator */
+ if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)(ma_size+TEST_BLOCK_SIZE30), (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
+
+ if ((node->addr + TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR
+ if (node->size != (ma_size + TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /* free the free-space section node */
+ if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
+ TEST_ERROR
+
+ /* restore info to meta_aggr */
+ f->shared->meta_aggr.addr = ma_addr;
+ f->shared->meta_aggr.size = ma_size;
+
+ /* Remove section from meta_aggr */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30);
+ /* Remove section from sdata_aggr */
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_absorb() */
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in the aggregator)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * The first block of 30 is allocated from meta_aggr
+ * There is space of 2018 left in meta_aggr
+ *
+ * Allocate second block (50) from meta_aggr:
+ * request-size is <= what is left in meta_aggr
+ * Result:
+ * The second block of 50 is allocated from meta_aggr
+ * There is space of 1968 left in meta_aggr
+ */
+static unsigned
+test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ haddr_t addr1, addr2;
+ haddr_t ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator:test 1");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate second block from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr2+TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50))
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Free the two blocks */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc1() */
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in the aggregator)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * There is space of 2018 left in meta_aggr
+ *
+ * Allocate second block (50) from meta_aggr:
+ * request-size is <= what is left in meta_aggr
+ * Result:
+ * The second block of 50 is allocated from what is left in meta_aggr
+ * There is space of 1968 left in meta_aggr
+ *
+ * Allocate third block (2058) from meta_aggr:
+ * request-size is > what is left in meta_aggr and is >= meta_aggr->alloc_size
+ * meta_aggr is at EOA
+ * Result:
+ * A block of request-size is extended via file allocation and is merged with meta_aggr
+ * The block of 2058 is allocated out of meta_aggr
+ * There is space of 1968 left in meta_aggr
+ */
+static unsigned
+test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type;
+ haddr_t addr1, addr2, addr3;
+ haddr_t ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator:test 2");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of a file */
+ if((file_size= h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr2+TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2058);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr3+TEST_BLOCK_SIZE2058) != ma_addr)
+ TEST_ERROR
+
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ /* Unused space is freed from the end of the file */
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50+TEST_BLOCK_SIZE2058))
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50+TEST_BLOCK_SIZE2058);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc2() */
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr : (nothing in the aggregator)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from there
+ * There is space of 2018 left in meta_aggr
+ *
+ * Allocate second block (50) from meta_aggr:
+ * request-size is <= what is left in meta_aggr
+ * Result:
+ * The second block of 50 is allocated from what is left in meta_aggr
+ * There is space of 1968 left in meta_aggr
+ *
+ * Allocate first block (30) from sdata_aggr: (nothing in sdata_aggr)
+ * request-size is > what is left in other_aggr and is < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from there
+ * There is space of 2018 left in sdata_aggr
+ *
+ * Allocate the third block (2058) from meta_aggr:
+ * request-size is > what is left in meta_aggr and >= meta_aggr->alloc_size
+ * sdata_aggr is at EOA but has not used up more than sdata_aggr->alloc_size
+ * Result: A block of request-size is obtained via file allocation
+ * The new block's address is returned
+ * Nothing is changed in meta_aggr and sdata_aggr
+ *
+ * Allocate fourth block (50) from meta_aggr:
+ * request-size is <= what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * The fourth block of 50 is allocated from what is left in meta_aggr
+ * There is space of 1968 left in meta_aggr
+ */
+static unsigned
+test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, addr3, addr4, saddr1;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0;
+ haddr_t sdata_addr=HADDR_UNDEF;
+ hsize_t sdata_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator: test 3");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate second block from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr2+TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ /* Allocate first block from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr)
+ TEST_ERROR
+ if (sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /* Allocate third block, which is from file allocation not from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE2058));
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+
+ /* info for meta_aggr shouldn't be changed */
+ if (addr3 != (sdata_addr+sdata_size)) TEST_ERROR
+ if ((addr3+TEST_BLOCK_SIZE2058) == new_ma_addr) TEST_ERROR
+ if ((new_ma_addr != ma_addr) || (new_ma_size != ma_size)) TEST_ERROR
+
+ /* Allocate fourth block, which should be from meta_aggr */
+ addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr4+TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ /* Free all the allocated blocks */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE2058);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr4, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc3() */
+
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in the aggregator)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * There is space of 2018 left in meta_aggr
+ * The first block of 30 is allocated from there
+ *
+ * Allocate first block (30) from sdata_aggr: (nothing in sdata_aggr)
+ * request-size is > what is left in sdata_aggr and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from there
+ *
+ * Allocate the second block (2018) from sdata_aggr:
+ * request-size is <= what is left in sdata_aggr and < sdata_aggr->alloc_size
+ * request-size is < sdata_aggr->alloc_size
+ * Result:
+ * The block is allocated from what is left in sdata_aggr (all used up)
+ *
+ * Allocate third block (50) from sdata_aggr :
+ * request-size is > what is left in sdata_aggr and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is extended via file allocation
+ * The third block of 50 is allocated from there
+ * There is space of 1998 left in the sdata_aggr
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * request-size is > what is left in meta_aggr and >= meta_aggr->alloc_size
+ * sdata_aggr is at EOA and has used up more than sdata_aggr->alloc_size
+ * Result:
+ * unused spaced in sdata_aggr is freed to free-space and is shrunk
+ * sdata_aggr is reset to 0
+ * A block of request-size is obtained via file allocation
+ * The new block's address is returned
+ * The block does not adjoin meta_aggr
+ * meta_aggr's info is unchanged
+ */
+static unsigned
+test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* File size */
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, saddr1, saddr2, saddr3;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0, sdata_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator:test 4");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ /* Allocate first block from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr)
+ TEST_ERROR
+
+ /* Allocate second block from sdata_aggr */
+ saddr2 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30));
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (saddr2+(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30) != sdata_addr)
+ TEST_ERROR
+
+ /* Allocate third block from sdata_aggr */
+ saddr3 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+
+ if ((saddr3+TEST_BLOCK_SIZE50) != sdata_addr)
+ TEST_ERROR
+ if(sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE50))
+ TEST_ERROR
+
+ /* Allocate second block of 2058, which is from file allocation, not from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2058);
+
+ if (addr2 != sdata_addr)
+ TEST_ERROR
+
+ /* sdata_aggr is reset 0 */
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((sdata_addr != 0) && (sdata_size != 0))
+ TEST_ERROR
+
+ /* info is unchanged in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if ((new_ma_addr != ma_addr) && (new_ma_size != ma_size))
+ TEST_ERROR
+
+ /* Free all the allocated blocks */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE2058);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr2, (hsize_t)TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr3, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc4() */
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in the aggregator)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocate from there
+ *
+ * Allocate second block (50) from meta_aggr:
+ * request-size is < what is left in meta_aggr
+ * Result:
+ * The second block of 50 is allocated from what is left there
+ * There is space of 1968 left in the meta_aggr
+ *
+ * Allocate third block (1970) from meta_aggr:
+ * request-size is > what is left in meta_aggr and is < meta_aggr->alloc_size
+ * Result: A block of meta_aggr->alloc_size is extended via file allocation and is absorbed into the meta_aggr
+ * The block of 1970 is allocated from there
+ * There is space of 2046 left in meta_aggr
+ *
+ */
+static unsigned
+test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* File size */
+ H5FD_mem_t type;
+ haddr_t addr1, addr2, addr3;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator:test 5");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate second block from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if (addr2+TEST_BLOCK_SIZE50 != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ /* Allocate third block from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1970);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+
+ if (addr3 != ma_addr) TEST_ERROR
+ if ((addr3+TEST_BLOCK_SIZE1970) != new_ma_addr) TEST_ERROR
+ if (new_ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE1970 - ma_size)))
+ TEST_ERROR
+
+ /* Free all the allocated blocks */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE1970);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc5() */
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in the aggregator)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from there
+ *
+ * Allocate second block (50) from meta_aggr:
+ * request-size is <= what is left in meta_aggr
+ * Result:
+ * The second block of 50 is allocated from what is left in meta_aggr
+ * There is space of 1968 left in meta_aggr
+ *
+ * Allocate first block (30) from sdata_aggr: (nothing in sdata_aggr)
+ * request-size is > what is left in sdata_aggr and is < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from there
+ * There is space of 2018 left in sdata_aggr
+ *
+ * Allocate third block (1970) from meta_aggr:
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * sdata_aggr is at EOA but has not used up more than sdata_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation.
+ * The block does not adjoin meta_aggr
+ * sdata_aggr is untouched
+ * meta_aggr's unused space of [880, 1968] is freed to free-space
+ * meta_aggr is updated to point to the new block
+ */
+static unsigned
+test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size; /* file size */
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, addr3, saddr1;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0, sdata_size=0;
+ frspace_state_t state;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator:test 6");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ /* Allocate first block from meta_aggr */
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate second block from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if (addr2+TEST_BLOCK_SIZE50 != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ /* Allocate first block from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) TEST_ERROR
+ if (sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /* Allocate third block from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1970);
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+
+ if ((addr3+TEST_BLOCK_SIZE1970) != new_ma_addr) TEST_ERROR
+ if (addr3 != (sdata_addr+sdata_size)) TEST_ERROR
+
+ if ((ma_addr+TEST_BLOCK_SIZE1970) == new_ma_addr) TEST_ERROR
+ if (new_ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE1970))
+ TEST_ERROR
+
+ /* Verify that meta_aggr's unused space of 1968 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50));
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free all the allocated blocks */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE1970);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc6() */
+
+/*
+ * To verify that blocks are allocated from the aggregator
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in meta_aggr)
+ * request-size is > what is left in meta_aggr and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from there
+ *
+ * Allocate second block (50) from meta_aggr:
+ * request-size is <= what is left in meta_aggr
+ * Result:
+ * The second block of 50 is allocated from what is left in the aggregator
+ * There is space of 1968 left in the meta_aggr
+ *
+ * Allocate first block (30) from sdata_aggr: (nothing in sdata_aggr)
+ * request-size is > what is left in sdata_aggr->size and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocate from there
+ *
+ * Allocate second block (2018) from sdata_aggr:
+ * request-size is <= what is left in sdata_aggr and is < sdata_aggr->alloc_size
+ * Result:
+ * The second block of 2018 is allocated from what is left in sdata_aggr (all used up)
+ *
+ * Allocate third block (50) from sdata_aggr:
+ * request-size is > what is left in sdata_aggr and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is extended via file allocation
+ * The third block of 50 is allocated from there
+ *
+ * Allocate third block (1970) from meta_aggr:
+ * request-size is > what is left in meta_aggr and is < meta_aggr->alloc_size
+ * sdata_aggr is at EOA and has used up more than sdata_aggr->alloc_size
+ * Result:
+ * unused space in sdata_aggr is freed to free-space and is shrunk
+ * sdata_aggr is reset to 0
+ * A block of meta_aggr->alloc_size is obtained via file allocation
+ * The block does not adjoin meta_aggr
+ * meta_aggr's unused space of [880, 1968] is freed to free-space
+ * meta_aggr is updated to point to the new block
+ */
+static unsigned
+test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t empty_size, file_size;
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, addr3, saddr1, saddr2, saddr3;
+ haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, sdata_size=0;
+ frspace_state_t state;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator:test 7");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate the first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate the second block from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if (addr2+TEST_BLOCK_SIZE50 != ma_addr)
+ TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)))
+ TEST_ERROR
+
+ /* Allocate the first block from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr)
+ TEST_ERROR
+
+ /* Allocate the second block from sdata_aggr */
+ saddr2 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30);
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr2+(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) != sdata_addr)
+ TEST_ERROR
+ if (sdata_size != 0) TEST_ERROR
+
+ /* Allocate the third block from sdata_aggr */
+ saddr3 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr3+TEST_BLOCK_SIZE50) != sdata_addr)
+ TEST_ERROR
+ if (sdata_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE50))
+ TEST_ERROR
+
+ /* Allocate the third block from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1970);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if (addr3 != sdata_addr) TEST_ERROR
+ if ((addr3 + TEST_BLOCK_SIZE1970) != ma_addr) TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE1970)) TEST_ERROR
+
+ /* sdata_aggr info is reset to 0 */
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (sdata_addr != 0) TEST_ERROR
+ if (sdata_size != 0) TEST_ERROR
+
+ /* Verify that meta_aggr's unused space of 1968 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += (TEST_BLOCK_SIZE2048 - (TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50));
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free all the allocated blocks */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE1970);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr2, (hsize_t)(TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30));
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr3, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_alloc7() */
+
+/*
+ * 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
+ *
+ * Test 2: Allocate block A from meta_aggr
+ * Allocate block B from sdata_aggr so that meta_aggr is not at end of file
+ * Try to extend a block which adjoins meta_aggr and meta_aggr can fulfill the extended-request
+ * H5MF_try_extend() succeeds: the block is extended into the aggregator
+ *
+ * Test 3: Allocate block A from meta_aggr
+ * Allocate block B from sdata_aggr so that meta_aggr is not at end of file
+ * Try to extend a block which adjoins meta_aggr but meta_aggr cannot fulfill the extended-request
+ * H5MF_try_extend() fails
+ */
+static unsigned
+test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t empty_size, file_size;
+ H5FD_mem_t type, stype;
+ haddr_t new_addr, addr, saddr;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0, sdata_size=0;
+ htri_t extended;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_try_extend() of meta/sdata aggregator: test 1");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate the first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Adjust meta_aggr's info info for testing */
+ f->shared->meta_aggr.addr = addr;
+ f->shared->meta_aggr.size = f->shared->meta_aggr.alloc_size;
+
+ new_addr = addr - 10;
+
+ /* Try to extend the block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50));
+
+ /* 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_SIZE50))
+ TEST_ERROR
+ if (new_ma_size != f->shared->meta_aggr.alloc_size) 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_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, (ma_addr+ma_size), (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_extend() of meta/sdata aggregator: test 2");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ if(contig_addr_vfd) {
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate the first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate the first block from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr+TEST_BLOCK_SIZE50) != sdata_addr)
+ TEST_ERROR
+
+ /* Adjust meta_aggr's info info for testing */
+ f->shared->meta_aggr.addr = addr;
+ f->shared->meta_aggr.size = f->shared->meta_aggr.alloc_size;
+
+ new_addr = addr - 10;
+
+ /* should be able to fulfill request from the aggreqator itself */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50));
+
+ 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_SIZE50))
+ 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;
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_extend() of meta/sdata aggregator: test 3");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ if(contig_addr_vfd) {
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate first block from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate first block from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr+TEST_BLOCK_SIZE50) != sdata_addr)
+ TEST_ERROR
+
+ /* Adjust meta_aggr's info info for testing */
+ f->shared->meta_aggr.addr = addr;
+ f->shared->meta_aggr.size = 0;
+
+ new_addr = addr - 10;
+
+ /* unable to fulfill request from the aggreqator itself */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TEST_BLOCK_SIZE50));
+
+ if(extended)
+ TEST_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+
+ if (new_ma_addr != addr) TEST_ERROR
+ if (new_ma_size != 0) TEST_ERROR
+
+ /* restore info for meta_aggr */
+ f->shared->meta_aggr.addr = ma_addr;
+ f->shared->meta_aggr.size = ma_size;
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_extend() */
+
+/*
+ * To verify that a block is absorbed into an aggregator
+ *
+ * MF_try_shrink() only allows blocks to be absorbed into an aggregator
+ *
+ * Test 1: H5MF_alloc() block A from meta_aggr
+ * H5MF_try_shrink() block A should merge it back into meta_aggr
+ * since block A adjoins the beginning of meta_aggr
+ *
+ * Test 2: H5MF_alloc() block A from meta_aggr
+ * H5MF_alloc() block B from sdata_aggr
+ * H5MF_try_shrink() block B should merge it onto the end of meta_aggr
+ * because H5F_FS_MERGE_METADATA|H5F_FS_MERGE_RAWDATA is on for
+ * sec2 driver's FLMAP_SINGLE
+ *
+ * Test 3: H5MF_alloc() block A from meta_aggr
+ * H5MF_alloc() block B from meta_aggr
+ * H5MF_alloc() block C from meta_aggr
+ * H5MF_try_shrink() block B should fail since it does not adjoin the
+ * beginning nor the end of meta_aggr
+ */
+static unsigned
+test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t empty_size, file_size;
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, addr3, saddr1;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ haddr_t sdata_addr=HADDR_UNDEF, new_sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0;
+ hsize_t sdata_size=0, new_sdata_size=0;
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+
+ TESTING("H5MF_try_shrink() of meta/sdata aggregator: test 1");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(contig_addr_vfd) {
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate block A from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ ma_addr = new_ma_addr - TEST_BLOCK_SIZE30;
+
+ if((addr1 + TEST_BLOCK_SIZE30) != new_ma_addr)
+ TEST_ERROR
+
+ /* should succeed */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30) <= 0)
+ TEST_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+
+ if (new_ma_addr != ma_addr) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_shrink() of meta/sdata aggregator: test 2");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ if(contig_addr_vfd) {
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate block A from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR
+ if (ma_size != (TEST_BLOCK_SIZE2048 - TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /* Allocate block B from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+
+ /* should succeed */
+ if(H5MF_try_shrink(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE50) <= 0)
+ TEST_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &new_sdata_addr, &new_sdata_size);
+ if (new_sdata_addr != sdata_addr) TEST_ERROR
+ if (new_sdata_size != sdata_size) TEST_ERROR
+
+ /* meta_aggr info should be updated because the block is absorbed into the meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+ if (new_ma_size != (ma_size+TEST_BLOCK_SIZE50)) TEST_ERROR
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ TESTING("H5MF_try_shrink() of meta/sdata aggregator: test 3");
+
+ /* Skip test when using VFDs that don't use the metadata aggregator */
+ if(contig_addr_vfd) {
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate block A from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate block B from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr2+TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+
+ /* Allocate block C from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50));
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr3+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+
+ /* should not succeed */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50) > 0)
+ TEST_ERROR
+
+ /* aggregator info should be the same as before */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (new_ma_addr != ma_addr) TEST_ERROR
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)(TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50));
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if (file_size != empty_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support metadata aggregator");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_aggr_absorb() */
+
+/*
+ * To verify that a block allocated from file allocation is aligned, can be shrunk and extended
+ *
+ * Alignment = 1024 or 4096
+ *
+ * Test 1:
+ * Turn off using meta data aggregator
+ * Allocate a block of 30 which should be from file allocation
+ * Result:
+ * The return address should be aligned
+ * A fragment [800, 224] or [800, 3296] is freed to free-space
+ * EOA is 1054 or 4126
+ *
+ * Allocate a block of 50 which should be from file allocation
+ * Result:
+ * The return address should be aligned
+ * A fragment [1054, 994] or [4126, 4066] is freed to free-space
+ * EOA is 2098 or 8242
+ * Test 2:
+ * Turn off using meta data aggregator
+ * Allocate a block which should be from file allocation
+ * The return address should be aligned
+ * H5MF_try_shrink() the block with aligned address should succeed
+ *
+ * Test 3:
+ * Turn off using meta data aggregator
+ * Allocate a block which should be from file allocation
+ * The return address should be aligned
+ * H5MF_try_extend() the block with aligned address should succeed
+ */
+static unsigned
+test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fapl1;
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size, new_file_size;
+ H5FD_mem_t type;
+ haddr_t addr1, addr2;
+ haddr_t ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0;
+ htri_t extended;
+ frspace_state_t state;
+ hsize_t alignment=0, mis_align=0, tmp=0, accum=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+ TESTING("H5MM_alloc() of file allocation with alignment: test 1");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Turn off using meta/small data aggregator */
+ if((fapl1 = H5Pcopy(new_fapl)) < 0) TEST_ERROR
+
+ H5Pset_meta_block_size(fapl1, (hsize_t)0);
+ H5Pset_small_data_block_size(fapl1, (hsize_t)0);
+
+ /* Create the file to work on (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(fapl1, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment and meta/sdata setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ accum = mis_align + TEST_BLOCK_SIZE30;
+
+ /* Allocate a block of 30 from file allocation */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* there should be nothing in the aggregator */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if (ma_addr || ma_size) TEST_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+ }
+
+ /* calculate fragment for alignment of block 50 */
+ mis_align = 0;
+ if ((tmp = ((hsize_t)file_size + accum) % alignment))
+ mis_align = alignment - tmp;
+ accum += (mis_align + TEST_BLOCK_SIZE50);
+
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* there should be nothing in the aggregator */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if (ma_addr || ma_size) TEST_ERROR
+
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+ }
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ if((new_file_size = h5_get_file_size(filename, fapl1)) < 0)
+ TEST_ERROR
+
+ if (new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ TESTING("H5MF_try_shrink() of file allocation with alignment: test 2");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ if(have_alloc_vfd) {
+ /* Re-open the file with alignment and meta/sdata setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* allocate a block of 50 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* address should be aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ if((file_size = h5_get_file_size(filename, fapl1)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* shrink the block */
+ if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE50) <= 0)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ if((new_file_size = h5_get_file_size(filename, fapl1)) < 0)
+ TEST_ERROR
+
+ if (new_file_size != (file_size-TEST_BLOCK_SIZE50)) TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ TESTING("H5MF_try_extend() of file allocation with alignment: test 3");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ if(have_alloc_vfd) {
+ /* Re-open the file with alignment and meta/sdata setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* allocate a block of 50 */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* address should be aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ if((file_size = h5_get_file_size(filename, fapl1)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* try to extend the block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr1, (hsize_t)TEST_BLOCK_SIZE50, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if (extended <=0) TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ if((new_file_size = h5_get_file_size(filename, fapl1)) < 0)
+ TEST_ERROR
+
+ if (new_file_size != (file_size+TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_eoa() */
+
+/*
+ * To verify that a block allocated from the free-space manager is aligned
+ *
+ * Alignment = 1024 or 4096
+ *
+ * Test 1:
+ * Add section A with an aligned address to free-space manager (addr=alignment, size=50)
+ * Allocate a block of size=50
+ * The returned space's address should be same as section A's address
+ *
+ * Test 2:
+ * Add section A to free-space manager (addr=70, size=8000):
+ * section A is mis-aligned but the size is big enough for allocation with alignment
+ * Allocate a block of size=600
+ * The returned space should be allocated from section A with an aligned address:
+ * address=alignment size=600
+ * There will be 2 sections in free-space: (alignment = 1024 or alignment = 4096)
+ * the fragment left from aligning section A: [70, 954] or [70, 4026]
+ * the section left after allocating block A: [1624, 416] or [4696, 3374]
+ * H5MF_try_extend() the block of size 600 by 200 should succeed:
+ * the existing fragment left from aligning section A: [70, 954] or [70, 4026]
+ * the section left after extending block A: [1824, 216] or [4896, 3174]
+ *
+ * Test 3:
+ * Add section A to free-space manager (addr=70, size=700):
+ * section A is mis-aligned but the size is not big enough for allocation with alignment
+ * Allocate a block of size=40
+ * The free-space manager is unable to fulfill the request
+ * The block is allocated from file allocation and should be aligned
+ */
+static unsigned
+test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ h5_stat_size_t file_size;
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type;
+ H5MF_free_section_t *sect_node = NULL;
+ haddr_t addr;
+ frspace_state_t state;
+ H5MF_sect_ud_t udata;
+ htri_t extended;
+ hsize_t alignment=0, tmp=0, mis_align=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+ TESTING("H5MF_alloc() of free-space manager with alignment: test 1");
+
+ /* 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
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ sect_node = H5MF_sect_simple_new((haddr_t)alignment, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 50 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is section A in free-space */
+ if (addr != (haddr_t)alignment) TEST_ERROR
+ if (addr % alignment) TEST_ERROR
+
+ state.tot_space -= TEST_BLOCK_SIZE50;
+ state.tot_sect_count -= 1;
+ state.serial_sect_count -= 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the block to free-space */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)TEST_BLOCK_SIZE50);
+
+ state.tot_space += TEST_BLOCK_SIZE50;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_alloc() of free-space manager with alignment: test 2");
+
+
+ /* Re-open the file with alignment setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE8000);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE8000;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Allocate a block of 600 */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE600);
+
+ /* Verify that the allocated block is aligned */
+ if (addr % alignment) TEST_ERROR
+
+ /* should have 1 more section in free-space */
+ state.tot_space -= TEST_BLOCK_SIZE600;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* try to extend the block */
+ extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr, (hsize_t)TEST_BLOCK_SIZE600, (hsize_t)TEST_BLOCK_SIZE200);
+
+ if (extended <=0) TEST_ERROR
+
+ /* space should be decreased by 200, # of sections remain the same */
+ state.tot_space -= TEST_BLOCK_SIZE200;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* Free the block to free-space manager */
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr, (hsize_t)(TEST_BLOCK_SIZE600+TEST_BLOCK_SIZE200));
+
+ /* only 1 section in free-space because of merging */
+ state.tot_space += (TEST_BLOCK_SIZE600+TEST_BLOCK_SIZE200);
+ state.tot_sect_count = 1;
+ state.serial_sect_count = 1;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ TESTING("H5MF_alloc() of free-space manager with alignment: test 3");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ if((file_size = h5_get_file_size(filename, new_fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ type = H5FD_MEM_SUPER;
+
+ if(H5MF_alloc_start(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ TEST_ERROR
+
+ if (f->shared->fs_state[type] != H5F_FS_STATE_OPEN)
+ TEST_ERROR
+ if (f->shared->fs_man[type]->client != H5FS_CLIENT_FILE_ID)
+ TEST_ERROR
+
+ sect_node = H5MF_sect_simple_new((haddr_t)TEST_BLOCK_ADDR70, (hsize_t)TEST_BLOCK_SIZE700);
+
+ /* Construct user data for callbacks */
+ udata.f = f;
+ udata.dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ udata.alloc_type = type;
+ udata.allow_sect_absorb = TRUE;
+
+ /* Add section A to free-space manager */
+ if (H5FS_sect_add(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type], (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &udata))
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE700;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+ /*
+ * Allocate a block of 40
+ * Since free-space manager cannot fulfull the request because of alignment,
+ * the block is obtained from file allocation
+ */
+ addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)(TEST_BLOCK_SIZE40));
+
+ /* Verify that the allocated block is aligned */
+ if (addr % alignment)
+ TEST_ERROR
+
+ /* verify that the allocated block is from file allocation, not section A in free-space */
+ if (!(addr >= (haddr_t)file_size)) TEST_ERROR
+
+ /* calculate fragment for alignment of block 40 from file allocation */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ /* free-space info should be the same */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_fs() */
+
+/*
+ * To verify that blocks allocated from the aggregator are aligned
+ *
+ * Alignment = 1024 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (nothing in the aggregator)
+ * request-size > aggr->size and < aggr->alloc_size
+ * Result:
+ * An "aggr->alloc_size" block is allocated from file allocation for the aggregator
+ * EOA is 3072
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of file allocation is freed to free-space:[800, 224]
+ * There is space of 2018 left in meta_aggr
+ *
+ * Allocate second block (50) from meta_aggr:
+ * (request-size + fragment size) <= aggr->size
+ * Result:
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[1054, 994]
+ * There is space of 974 left in meta_aggr
+ *
+ * Allocate third block (80) from meta_aggr:
+ * (request-size + fragment size) > aggr->size
+ * request-size < meta_aggr->alloc_size
+ * fragment size < (meta_aggr->alloc_size - request-size)
+ * meta_aggr is at EOA
+ * Result:
+ * A block of "meta_aggr->alloc_size" is extended from file allocation for meta_aggr
+ * EOA is 5120
+ * The third block of 80 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[2098, 974]
+ * There is space of 1968 left in meta_aggr
+ *
+ * Allocate fourth block (1970) from meta_aggr:
+ * (request-size + fragment size) is <= aggr->size
+ * fragment size > (aggr->alloc_size - request-size)
+ * meta_aggr is at EOA
+ * Result:
+ * A block of aggr->alloc_size + fragment size - (aggr->alloc_size - request-size))
+ * is extended from file allocation for meta_aggr
+ * The third block of 1970 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[3152, 944]
+ * There is space of 1968 left in meta_aggr
+ * EOA is at 8034
+ *
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (aggregator is empty)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A meta_aggr->alloc_size block is allocated from file allocation for the aggregator
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of file allocation is freed to free-space:[800, 3296]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 6144
+ *
+ * Allocate second block (50) from meta_aggr:
+ * (request-size + fragment size) is > meta_aggr->size
+ * request-size < meta_aggr->alloc_size
+ * fragment size > (meta_aggr->alloc_size - request-size)
+ * meta_aggr is at EOA
+ * Result:
+ * A block of meta_aggr->alloc_size + (fragment size - (meta_aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4126, 4066]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 10260
+ *
+ * Allocate third block (80) from meta_aggr:
+ * (request-size + fragment size) is > meta_aggr->size
+ * request-size < meta_aggr->alloc_size
+ * fragment size > (meta_aggr->alloc_size - request-size)
+ * meta_aggr is at EOA
+ * Result:
+ * A block of meta_aggr->alloc_size + (fragment size - (meta_aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * The third block of 80 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[8242, 4046]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 14386
+ *
+ * Allocate fourth block (1970) from meta_aggr:
+ * (request-size + fragment size) > meta_aggr->size
+ * request-size < meta_aggr->alloc_size
+ * fragment size > (meta_aggr->alloc_size - request-size)
+ * meta_aggr is at EOA
+ * Result:
+ * A block of meta_aggr->alloc_size + (fragment size - (meta_aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * The fourth block of 1970 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[12368, 4016]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 20372
+ */
+static unsigned
+test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size; /* File size */
+
+ H5FD_mem_t type;
+ haddr_t addr1, addr2, addr3, addr4;
+ frspace_state_t state;
+ haddr_t ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, mis_align=0;
+ hsize_t alignment=0, tmp=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 1");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* 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 (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 50 */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 50 from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 50 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr2 + TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 80 */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE80);
+
+ /* Verify that the allocated block is aligned */
+ if (addr3 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 80 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr3 + TEST_BLOCK_SIZE80) != ma_addr)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 1970 */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 1970 from meta_aggr */
+ addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1970);
+
+ /* Verify that the allocated block is aligned */
+ if (addr4 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 1970 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr4 + TEST_BLOCK_SIZE1970) != ma_addr)
+ TEST_ERROR
+
+ /* Verify total size of free space after all the allocations */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE80);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE1970);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_alloc1() */
+
+/*
+ * To verify that blocks allocated from the aggregator are aligned
+ *
+ * Alignment = 1024 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A meta_aggr->alloc_size block is allocated from file allocation for the aggregator
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of file allocation is freed to free-space:[800, 224]
+ * There is space of 2018 left in meta_aggr
+ * EOA is 3072
+ *
+ * Allocate second block (50) from meta_aggr:
+ * (request-size+fragment size) <= aggr->size
+ * Result:
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[1054, 994]
+ * There is space of 974 left in meta_aggr
+ *
+ * Allocate first block (30) from sdata_aggr: (sdata_aggr is empty)
+ * request-size is > sdata_aggr->size and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * The first block of 30 is allocated from sdata_aggr and should be aligned
+ * EOA is 5120
+ *
+ * Allocate third block (80) from meta_aggr:
+ * request-size+fragment size is > meta_aggr->size
+ * sdata_aggr is at EOA but has not used up more than sdata_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * The unused space in meta_aggr is freed to free-space [2098, 974]
+ * meta_aggr is updated to point to the new block
+ * The third block of 80 is allocated from meta_aggr and should be aligned
+ * EOA is 7168
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > aggr->size and < aggr->alloc_size
+ * Result:
+ * A meta_aggr->alloc_size block is allocated from file allocation for the aggregator
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of file allocation is freed to free-space:[800, 3296]
+ * There is space of 2018 left meta_aggr
+ * EOA is at 6144
+ *
+ * Allocate second block (50) from meta_aggr:
+ * (request-size + fragment size) > aggr->size
+ * request-size < aggr->alloc_size
+ * fragment size > (aggr->alloc_size - request-size)
+ * Result:
+ * A block of aggr->alloc_size + (fragment size - (aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4126, 4066]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 10260
+ *
+ * Allocate first block (30) from sdata_aggr: (sdata_aggr is empty)
+ * request-size is > sdata_aggr->size and < sdata_aggr->alloc_size
+ * meta_aggr is at EOA and has used up more than meta_aggr->alloc_size
+ * Result:
+ * The remaining space in meta_aggr is freed to free-space [8242, 2018] and shrunk since at EOF
+ * meta_aggr is reset to 0
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * Fragment from alignment of file allocation is freed to free-space: [8242, 4046]
+ * The first block of 30 is allocated from sdata_aggr and should be aligned
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 14336
+ *
+ * Allocate third block (80) from meta_aggr:
+ * (request-size + fragment size) is > meta_aggr->size
+ * request-size < meta_aggr->alloc_size
+ * sdata_aggr is at EOA but has not used up more than sdata_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation for the aggregator
+ * Fragment from alignment of file allocation is freed to free-space:[14336, 2048]
+ * Since this fragment adjoins sdata_aggr and fulfills "absorb" condition,
+ * the space left in sdata_aggr is absorbed into the fragment and freed to free-space: [12318, 2018]
+ * other_aggr is reset to 0
+ * The third block of 80 is allocated from the aggregator and should be aligned
+ * There is space of 1968 left in meta_aggr
+ * EOA is at 18432
+ */
+static unsigned
+test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size; /* File size */
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, addr3, saddr1;
+ frspace_state_t state;
+ haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, sdata_size=0, mis_align=0;
+ hsize_t alignment=0, tmp=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 2");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* 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 (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* fragment for alignment of block 50 is freed to free-space */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 50 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr2 + TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+
+ /*
+ * Calculate fragment for alignment of block 30 in sdata_aggr:
+ *
+ * For alignment = 1024, alloc_size = 2048:
+ * block 30 is allocated from (ma_addr + ma_size),
+ * which is already aligned
+ *
+ * For alignment = 4096, alloc_size = 2048:
+ * since remaining space in meta_aggr is freed and shrunk,
+ * block 30 is allocated from ma_addr
+ */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment)))
+ mis_align = alignment - tmp;
+ else if ((alignment == TEST_ALIGN4096) && (tmp = (ma_addr % alignment)))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* fragment for alignment of block 30 for sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ /* Verify that the allocated block is aligned */
+ if (saddr1 % alignment) TEST_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if (sdata_addr != (saddr1 + TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /*
+ * Calculate fragment for the allocation of block 80 from meta_aggr:
+ *
+ * For alignment = 1024, alloc_size = 2048:
+ * fragment for unused space in meta_aggr is freed to free-space
+ * For alignment = 4096, alloc_size = 2048:
+ * fragment from alignment of file allocation absorbs sdata_aggr's remaining space
+ */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment)))
+ mis_align = alignment - tmp;
+ else if ((alignment == TEST_ALIGN4096) && (tmp = (sdata_addr % alignment)))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 80 from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE80);
+
+ /* Verify that the allocated block is aligned */
+ if (addr3 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 80 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr3 + TEST_BLOCK_SIZE80) != ma_addr)
+ TEST_ERROR
+
+ /* Verify total size of free space after all the allocations */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE50);
+ H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE80);
+ H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE30);
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_alloc2() */
+
+/*
+ * To verify that blocks allocated from the aggregator are aligned
+ *
+ * Alignment = 1024 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation for the aggregator
+ * Fragment from alignment of file allocation is freed to free-space:[800, 224]
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in meta_aggr
+ * EOA is 3072
+ *
+ * Allocate second block (50) from meta_aggr:
+ * (request-size+fragment size) is <= aggr->size
+ * Result:
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[1054, 994]
+ * There is space of 974 left in the aggregator
+ *
+ * Allocate first block (30) from other_aggr: (nothing in other_aggr)
+ * request-size is > what is left in other_aggr->size and < other_aggr->alloc_size
+ * Result:
+ * A "other_aggr->alloc_size" block is allocated from file allocation for other_aggr
+ * The first block of 30 is allocated from other_aggr and should be aligned
+ * There is space of 2018 left in other_aggr->size
+ * EOA is 5120
+ *
+ * Allocate second block (50) from sdata_aggr:
+ * (request-size+fragment size) < sdata_aggr->size
+ * Result:
+ * The second block of 50 is allocated from sdata_aggr and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[3102, 994]
+ * There is space of 974 left in sdata_aggr
+ *
+ * Allocate third block (80) from sdata_aggr:
+ * (request-size+fragment size) is >= sdata_aggr->size
+ * request-size < sdata_aggr->alloc_size
+ * sdata_aggr is at EOA
+ * Result:
+ * Another block of sdata_aggr->alloc_size is extended from file allocation for sdata_aggr
+ * The third block of 80 is allocated from sdata_aggr and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4146, 974]
+ * There is space of 1968 left in sdata_aggr
+ * EOA is 7168
+ *
+ * Allocate third block (1034) from meta_aggregator:
+ * (request-size + alignment) > meta_aggr->size but < meta_aggr->alloc_size
+ * sdata_aggr is at EOA and has used up more than sdata_aggr->alloc_size
+ * Result:
+ * The unused space in sdata_aggr is freed to free-space [5200, 1968] then shrunk
+ * sdata_aggr is reset to 0
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space [5200, 944]
+ * The unused space in meta_aggr is freed to free-space [2098, 974]
+ * The meta_aggr is updated to point to the new space
+ * The block of 1034 is allocated from the new block and should be aligned
+ * There is space of 1014 left in meta_aggr
+ * EOA is 8192
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > what is left in aggr->size and < aggr->alloc_size
+ * Result:
+ * A meta_aggr->alloc block is allocated from file allocation for the aggregator
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of file allocation is freed to free-space:[800, 3296]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 6144
+ *
+ * Allocate second block (50) from meta_aggr:
+ * (request-size + fragment size) is > what is left in aggr->size
+ * request-size < aggr->alloc_size
+ * fragment size > (aggr->alloc_size - request-size)
+ * Result:
+ * A block of aggr->alloc_size + (fragment size - (aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4126, 4066]
+ * There is space of 2018 left in meta_aggr
+ * EOA is at 10260
+ *
+ * Allocate first block (30) from sdata_aggr: (sdata_aggr is empty)
+ * request-size > sdata_aggr->size and < sdata_aggr->alloc_size
+ * meta_aggr is at EOA and has used up more than meta_aggr->alloc_size
+ * Result:
+ * The remaining space in meta_aggr is freed to free-space [8242, 2018] and shrunk
+ * since at EOF
+ * meta_aggr is reset to 0
+ * A block of sdata_aggr->alloc_size is obtained via file allocation
+ * Fragment from alignment of file allocation is freed to free-space: [8242, 4046]
+ * The first block of 30 is allocated from sdata_aggr and should be aligned
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 14336
+ *
+ * Allocate second block (50) from sdata_aggr:
+ * request-size is > sdata_aggr->size
+ * request-size < sdata_aggr->alloc_size
+ * fragment size > (sdata_aggr->alloc_size - request-size)
+ * Result:
+ * A block of sdata_aggr->alloc_size + (fragment size - (sdata_aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * Fragment from alignment of aggregator allocation is freed to free-space:[12318, 4066]
+ * The second block of 50 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in the sdata_aggr
+ * EOA is at 18452
+ *
+ * Allocate third block (80) from sdata_aggr:
+ * request-size + fragment size is > sdata_aggr->size
+ * request-size < sdata_aggr->alloc_size
+ * fragment size > (sdata_aggr->alloc_size - request-size)
+ * Result:
+ * A block of sdata_aggr->alloc_size + (fragment size - (sdata_aggr->alloc_size - request-size)
+ * is allocated from file allocation for the aggregator
+ * Fragment from alignment of aggregator allocation is freed to free-space:[16434, 4046]
+ * The third block of 80 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in the sdata_aggr
+ * EOA is at 22578
+ *
+ * Allocate third block (1034) from meta_aggregator:
+ * (request-size + fragment size) is > meta_aggr->size but request-size < meta_aggr->alloc_size
+ * sdata_aggr is at EOA and has used up more than sdata_aggr->alloc_size
+ * Result:
+ * The remaining space in sdata_aggr is freed to free-space [20560, 2018] then shrunk
+ * sdata_aggr is reset to 0
+ * There is nothing in meta_aggr
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space [20560, 4016]
+ * EOA is 26624
+ * The meta_aggr is updated to point to the new space
+ * The block of 1034 is allocated from the new block and should be aligned
+ * There is space of 1014 left in meta_aggr
+ */
+static unsigned
+test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size;
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, addr3;
+ haddr_t saddr1, saddr2, saddr3;
+ frspace_state_t state;
+ haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, sdata_size=0, mis_align=0;
+ hsize_t alignment=0, tmp=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 3");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* 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 (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 50 */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 50 from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 50 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr2 + TEST_BLOCK_SIZE50) != ma_addr)
+ TEST_ERROR
+
+ /*
+ * Calculate fragment for alignment of block 30 in sdata_aggr:
+ *
+ * For alignment = 1024, alloc_size = 2048:
+ * block 30 is allocated from (ma_addr + ma_size),
+ * which is already aligned
+ *
+ * For alignment = 4096, alloc_size = 2048:
+ * since remaining space in meta_aggr is freed and shrunk,
+ * block 30 is allocated from ma_addr
+ */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment)))
+ mis_align = alignment - tmp;
+ else if ((alignment == TEST_ALIGN4096) && (tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 for sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (sdata_addr != (saddr1+TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /* calculate fragment for alignment of block 50 in sdata_aggr */
+ mis_align = 0;
+ if ((tmp = sdata_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 50 from sdata_aggr */
+ saddr2 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 50 for sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (sdata_addr != (saddr2 + TEST_BLOCK_SIZE50)) TEST_ERROR
+
+ /* calculate fragment for alignment of block 80 in sdata_aggr */
+ mis_align = 0;
+ if ((tmp = sdata_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 80 from sdata_aggr */
+ saddr3 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE80);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr3 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 80 for sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr3 + TEST_BLOCK_SIZE80) != sdata_addr)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 1034 */
+ mis_align = 0;
+ if ((tmp = sdata_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 1034 for meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1034);
+
+ /* Verify that the allocated block is aligned */
+ if (addr3 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 1034 for meta_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ /* calculate unused space in meta_aggr that is freed to free-space after block 1034 */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment)))
+ mis_align = alignment - tmp;
+
+ /* fragment for unused space in meta_aggr after block 1034 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr3 + TEST_BLOCK_SIZE1034) != ma_addr)
+ TEST_ERROR
+
+ /* Verify total size of free space after all allocations */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_alloc3() */
+
+
+/*
+ * To verify that blocks allocated from the aggregator are aligned
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[800, 224]
+ * The first block of 30 is allocated from meta_aggr and should be aligned
+ * There is space of 2018 left in meta_aggr
+ * EOA is 3072
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * (request-size+fragment) is > meta_aggr->size and request-size is > meta_aggr->alloc_size
+ * meta_aggr is at EOA
+ * Result:
+ * The second block of 2058 + fragment is extended and merged together with meta_aggr
+ * The block of 2058 is allocated out of the aggregator
+ * Fragment from alignment of aggregator allocation is freed to free-space:[1054, 994]
+ * There is space of 2018 (same as before) left in meta_aggr
+ * EOA is 6124
+ *
+ * Allocate third block (5) from meta_aggr:
+ * request-size+fragment < meta_aggr->size
+ * Result:
+ * A block of 5 is allocated from the aggregator
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4106, 1014]
+ * There is space of 999 left in meta_aggr
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[800, 3296]
+ * The first block of 30 is allocated from meta_aggr and should be aligned
+ * There is space of 2018 left in meta_aggr
+ * EOA is 6144
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * (request-size+fragment) is > meta_aggr->size and request-size is > meta_aggr->alloc_size
+ * meta_aggr is at EOA
+ * Result:
+ * The second block of 2058 + fragment is extended and merged together with meta_aggr
+ * The block of 2058 is allocated out of the aggregator
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4126, 4066]
+ * There is space of 2018 (same as before) left in meta_aggr
+ * EOA is 12268
+ *
+ * Allocate third block (5) from meta_aggr:
+ * request-size+fragment is > meta_aggr->size
+ * request-size < meta_aggr->alloc_size
+ * fragment < (meta_aggr->alloc_size - request-size)
+ * meta_aggr is at EOA
+ * Result:
+ * A block of meta_aggr->alloc_size is extended from file allocation for the aggregator
+ * A block of 5 is allocated from the aggregator
+ * Fragment from alignment of aggregator allocation is freed to free-space:[10250, 2038]
+ * There is space of 2023 left in meta_aggr
+ *
+ */
+static unsigned
+test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size;
+ H5FD_mem_t type;
+ haddr_t addr1, addr2, addr3;
+ frspace_state_t state;
+ haddr_t ma_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, saved_ma_size=0;
+ hsize_t alignment=0, mis_align=0, tmp=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 4");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* 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 (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting and meta/sdata setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ saved_ma_size = ma_size;
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR
+
+ /* calculate fragment for alignment of block 2058 */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 2058 from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2058);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 2058 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr2 + TEST_BLOCK_SIZE2058) != ma_addr) TEST_ERROR
+
+ /* meta_aggr->size remains the same */
+ if (ma_size != saved_ma_size) TEST_ERROR
+
+ /* calculate fragment for alignment of block 5 from meta_aggr */
+ mis_align = 0;
+ if ((tmp = ma_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 5 from meta_aggr */
+ addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5);
+
+ /* fragment for alignment of block 5 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ /* Verify that the allocated block is aligned */
+ if (addr3 % alignment) TEST_ERROR
+
+ /* Verify total size of free space after all allocations */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_alloc4() */
+
+/*
+ * To verify that blocks allocated from the aggregator are aligned
+ *
+ * Alignment = 1024 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[800, 224]
+ * The first block of 30 is allocated from meta_aggr and should be aligned
+ * There is space of 2018 left in meta_aggr
+ * EOA is 3072
+ *
+ * Allocate first block (30) from sdata_aggr: (nothing in the aggregator)
+ * A block of sdata_aggr->alloc_size is allocated from file allocation
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 5120
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * (request-size + fragment size) > meta_aggr->size and > meta_aggr->alloc_size
+ * sdata_aggr is at EOA but has not used up sdata_aggr->alloc_size
+ * Result:
+ * A block of 2058 is allocated from file allocation
+ * EOA is 7178
+ * Nothing is changed in meta_aggr and sdata_aggr
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[800, 3296]
+ * The first block of 30 is allocated from meta_aggr and should be aligned
+ * There is space of 2018 left in meta_aggr
+ * EOA is 6144
+ *
+ * Allocate first block (30) from sdata_aggr: (meta_aggr is empty)
+ * meta_aggr is at EOA but has not used up more than meta_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[6144, 2048]
+ * This fragment adjoins meta_aggr and fulfills "absorb" condition,
+ * the remaining space left in meta_aggr is absorbed into the fragment and
+ * freed to free-space: [4126, 2018]
+ * meta_aggr is reset to 0
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 10240
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * request-size + fragment size is > meta_aggr->size
+ * request_size is > meta_aggr->alloc_size
+ * sdata_aggr is at EOA but has not used up more than sdata_aggr->alloc_size
+ * Result:
+ * A block of 2058 is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[10240, 2048]
+ * This fragment adjoins sdata_aggr and fulfills "absorb" condition,
+ * the remaining space left in sdata_aggr is absorbed into the fragment and
+ * freed to free-space: [8222, 2018]
+ * sdata_aggr is reset to 0
+ * EOA is 14346
+ * meta_aggr and sdata_aggr are all 0
+ */
+static unsigned
+test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size;
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2, saddr1;
+ frspace_state_t state;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF;
+ haddr_t sdata_addr=HADDR_UNDEF, new_sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0, sdata_size=0, new_sdata_size=0;
+ hsize_t alignment=0, mis_align=0, tmp=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 5");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* 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 (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting and meta/sdata setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+
+ if ((addr1 + TEST_BLOCK_SIZE30) != ma_addr) TEST_ERROR
+
+ /* fragment for alignment of block 30 is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ /* calculate fragment for alignment of block 30 from sdata_aggr */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr + ma_size) % alignment))
+ mis_align = alignment - tmp;
+ else if ((alignment == TEST_ALIGN4096) && (tmp = (ma_addr % alignment)))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr1 % alignment) TEST_ERROR
+
+ /* fragment of alignment for block 30 in sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if ((saddr1+TEST_BLOCK_SIZE30) != sdata_addr) TEST_ERROR
+
+ /* calculate fragment for alignment of block 2058 from meta_aggr */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = (sdata_addr + sdata_size) % alignment))
+ mis_align = alignment - tmp;
+ else if ((alignment == TEST_ALIGN4096) && (tmp = (sdata_addr % alignment)))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 2058 from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2058);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 2058 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ /* Verify total size of free space after all allocations */
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* nothing is changed in meta_aggr */
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ if (alignment == TEST_ALIGN1024 && (new_ma_addr != ma_addr || new_ma_size != ma_size))
+ TEST_ERROR
+ else if (alignment == TEST_ALIGN4096 && (new_ma_addr != 0 || new_ma_size != 0))
+ TEST_ERROR
+
+ /* nothing is changed in sdata_aggr */
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &new_sdata_addr, &new_sdata_size);
+ if (alignment == TEST_ALIGN1024 && (new_sdata_addr != sdata_addr || new_sdata_size != sdata_size))
+ TEST_ERROR
+ else if (alignment == TEST_ALIGN4096 && ((new_sdata_addr != 0 || new_sdata_size != 0)))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_alloc5() */
+
+
+/*
+ * To verify that blocks allocated from the aggregator are aligned
+ *
+ * Alignment = 1024 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is empty)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[800, 224]
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in meta_aggr->size
+ * EOA is 3072
+ *
+ * Allocate first block (30) from sdata_aggr: (sdata_aggr is empty)
+ * request_size > sdata_aggr->size and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is allocated from file allocation
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 5120
+ *
+ * Allocate second block (50) from sdata_aggr:
+ * (request-size+fragment size) <= sdata_aggr->size
+ * Result:
+ * The second block of 50 is allocated from sdata_aggr and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[3102, 994]
+ * There is space of 974 left in sdata_aggr
+ *
+ * Allocate third block (80) from sdata_aggr:
+ * (request-size+fragment size) > sdata_aggr->size
+ * request-size < sdata_aggr->alloc_size
+ * fragment size < (sdata_aggr->alloc_size - request-size)
+ * Result:
+ * Another block of sdata_aggr->alloc_size block is extended from file allocation
+ * for sdata_aggr
+ * The third block of 80 is allocated from sdata_aggr and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[4146, 974]
+ * There is space of 1968 left in sdata_aggr
+ * EOA is 7168
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * request-size + fragment size is > meta_aggr->size
+ * request-size is > meta_aggr->alloc_size
+ * sdata_aggr is at EOA and has used up more than sdata_aggr->alloc_size
+ * Result:
+ * The remaining space in sdata_aggr is freed to free-space and shrunk
+ * sdata_aggr is reset to 0
+ * A block of 2058 is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[5200, 944]
+ * EOA is at 8202
+ * meta_aggr is unchanged
+ *
+ * Alignment = 4096 aggr->alloc_size = 2048
+ *
+ * Allocate first block (30) from meta_aggr: (meta_aggr is emtpy)
+ * request-size is > meta_aggr->size and < meta_aggr->alloc_size
+ * Result:
+ * A block of meta_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[800, 3296]
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in meta_aggr
+ * EOA is 6144
+ *
+ * Allocate first block (30) from sdata_aggr: (sdata_aggr is empty)
+ * request_size > sdata_aggr->size and < sdata_aggr->alloc_size
+ * Result:
+ * A block of sdata_aggr->alloc_size is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space: [6144, 2048]
+ * This fragment adjoins meta_aggr and fulfills "absorb" condition,
+ * the remaining space left in meta_aggr is absorbed into the fragment and
+ * freed to free-space:[4126, 2018]
+ * meta_aggr is reset to 0
+ * The first block of 30 is allocated from the aggregator and should be aligned
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 5120
+ *
+ * Allocate second block (50) from sdata_aggr:
+ * (request-size+fragment size) is <= sdata_aggr->size
+ * request-size < sdata_aggr->alloc_size
+ * fragment size > (sdata_aggr->alloc_size - request-size)
+ * Result:
+ * A block of sdata_aggr->alloc_size + (fragment size - (sdata_aggr->alloc_size - request-size))
+ * is extended from file allocation for the aggregator
+ * The second block of 50 is allocated from sdata_aggr and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[8222, 4066]
+ * There is space of 2018 left in sdata_aggr
+ * EOA is at 14356
+ *
+ * Allocate third block (80) from sdata_aggr:
+ * (request-size+fragment size) is > sdata_aggr->size
+ * request-size < sdata_aggr->alloc_size
+ * fragment size > (sdata_aggr->alloc_size - request-size)
+ * Result:
+ * A block of sdata_aggr->alloc_size+(fragment size-(sdata_aggr->alloc_size-request-size))
+ * is extended from file allocation for sdata_aggr
+ * The third block of 80 is allocated from sdata_aggr and should be aligned
+ * Fragment from alignment of aggregator allocation is freed to free-space:[12338, 4046]
+ * There is space of 2018 left in sdata_aggr
+ * EOA is 18482
+ *
+ * Allocate second block (2058) from meta_aggr:
+ * request-size + fragment size is > meta_aggr->size
+ * request-size is > meta_aggr->alloc_size
+ * sdata_aggr is at EOA and has used up more than sdata_aggr->alloc_size
+ * Result:
+ * The remaining space in sdata_aggr is freed to free-space and shrunk: [16464, 2018]
+ * sdata_aggr is reset to 0
+ * A block of 2058 is allocated from file allocation
+ * Fragment from alignment of file allocation is freed to free-space:[16464, 4016]
+ * EOA is at 22538
+ * meta_aggr is unchanged
+ */
+static unsigned
+test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ h5_stat_size_t file_size;
+ H5FD_mem_t type, stype;
+ haddr_t addr1, addr2;
+ haddr_t saddr1, saddr2, saddr3;
+ frspace_state_t state;
+ haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF;
+ hsize_t ma_size=0, new_ma_size=0, sdata_size=0;
+ hsize_t alignment=0, mis_align=0, tmp=0;
+ hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */
+
+ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 6");
+
+ /* Skip test when using VFDs that have their own 'alloc' callback, which
+ * don't push mis-aligned space fragments on the file free space list
+ */
+ have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio")
+ && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi"));
+ if(have_alloc_vfd) {
+ /* 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 (without alignment) */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Re-open the file with alignment setting and meta/sdata setting */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* get alignment setting */
+ if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 30 */
+ if ((tmp = (hsize_t)file_size % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from meta_aggr */
+ type = H5FD_MEM_SUPER;
+ addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (addr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 in meta_aggr is freed to free-space */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if ((addr1+TEST_BLOCK_SIZE30) != ma_addr)
+ TEST_ERROR
+
+ /* calculate fragment for alignment of block 30 in sdata_aggr */
+ mis_align = 0;
+ if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr + ma_size) % alignment))
+ mis_align = alignment - tmp;
+ else if ((alignment == TEST_ALIGN4096) && (tmp = (ma_addr % alignment)))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 30 from sdata_aggr */
+ stype = H5FD_MEM_DRAW;
+ saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr1 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 30 in sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (sdata_addr != (saddr1+TEST_BLOCK_SIZE30)) TEST_ERROR
+
+ /* calculate fragment for alignment of block 50 in sdata_aggr */
+ mis_align = 0;
+ if ((tmp = sdata_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 50 from sdata_aggr */
+ saddr2 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE50);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 50 in sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (sdata_addr != (saddr2+TEST_BLOCK_SIZE50)) TEST_ERROR
+
+ /* calculate fragment for alignment of block 80 in sdata_aggr */
+ mis_align = 0;
+ if ((tmp = sdata_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 80 from sdata_aggr */
+ saddr3 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE80);
+
+ /* Verify that the allocated block is aligned */
+ if (saddr3 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 80 in sdata_aggr is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+ if (sdata_addr != (saddr3+TEST_BLOCK_SIZE80)) TEST_ERROR
+
+ /* calculate fragment for alignment of block 2058 */
+ /* remaining space in sdata_aggr is freed and shrunk */
+ mis_align = 0;
+ if ((tmp = sdata_addr % alignment))
+ mis_align = alignment - tmp;
+
+ /* Allocate a block of 2058 from meta_aggr */
+ addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2058);
+
+ /* Verify that the allocated block is aligned */
+ if (addr2 % alignment) TEST_ERROR
+
+ /* fragment for alignment of block 2058 is freed to free-space */
+ if (mis_align) {
+ state.tot_space += mis_align;
+ state.tot_sect_count += 1;
+ state.serial_sect_count += 1;
+ }
+
+ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
+ H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size);
+
+ if (alignment == TEST_ALIGN1024 && (new_ma_addr != ma_addr || new_ma_size != ma_size))
+ TEST_ERROR
+ else if (alignment == TEST_ALIGN4096 && (new_ma_addr != 0 || new_ma_size != 0))
+ TEST_ERROR
+
+ if (sdata_addr != 0 || sdata_size != 0)
+ TEST_ERROR
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support mis-aligned fragments");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_align_alloc6() */
+
+
+/*
+ * Verify that the file's free-space manager persists where there are free sections in the manager
+ */
+static unsigned
+test_mf_fs_persist(hid_t fapl_new, hid_t fcpl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type; /* File allocation type */
+ H5FS_stat_t fs_stat; /* Information for free-space manager */
+ haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */
+ haddr_t tmp_addr; /* Temporary variable for address */
+
+ TESTING("file's free-space manager is persistent");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 6 blocks */
+ type = H5FD_MEM_SUPER;
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE6)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr5, (hsize_t)TEST_BLOCK_SIZE5) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that H5FD_MEM_SUPER free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get info for free-space manager */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3+TEST_BLOCK_SIZE5))
+ TEST_ERROR
+
+ if(fs_stat.serial_sect_count < 3)
+ TEST_ERROR
+
+ /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr3)
+ TEST_ERROR
+
+ /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr1)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that H5FD_MEM_SUPER free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Retrieve block #5 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr5)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_persist() */
+
+/*
+ * Verify that the free-space manager goes away
+ */
+static unsigned
+test_mf_fs_gone(hid_t fapl_new, hid_t fcpl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type; /* File allocation type */
+ H5FS_stat_t fs_stat; /* Information for free-space manager */
+ haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */
+
+ TESTING("file's free-space manager is going away");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 4 blocks */
+ type = H5FD_MEM_SUPER;
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3 to H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve block #1, #3 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the H5FD_MEM_SUPER free-space manager is not there */
+ if(H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Put block #3 to H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that H5FD_MEM_SUPER free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get info for H5FD_MEM_SUPER free-space manager */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(!H5F_addr_defined(fs_stat.addr) || !H5F_addr_defined(fs_stat.sect_addr))
+ TEST_ERROR
+ if(fs_stat.tot_space < TEST_BLOCK_SIZE3)
+ TEST_ERROR
+
+ /* Put block #4 to H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr4, (hsize_t)TEST_BLOCK_SIZE4) < 0)
+ FAIL_STACK_ERROR
+
+ /* The H5FD_MEM_SUPER free-space manager will go away at H5MF_close() */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the H5FD_MEM_SUPER free-space manager is not there */
+ if(H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_gone() */
+
+
+/*
+ * Verify that the file's free-space manager(s) are persistent for a split-file
+ */
+static unsigned
+test_mf_fs_split(hid_t fapl_new, hid_t fcpl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type, stype, btype; /* File allocation type */
+ H5FS_stat_t fs_stat; /* Information for free-space manager */
+ haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */
+ haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_DRAW */
+ haddr_t baddr5, baddr6, baddr7, baddr8; /* File address for H5FD_MEM_BTREE */
+ haddr_t tmp_addr; /* temporary variable for address */
+
+ TESTING("file's free-space managers are persistent for split-file");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 4 blocks of type H5FD_MEM_SUPER */
+ type = H5FD_MEM_SUPER;
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ /* Allocate 4 blocks of type H5FD_MEM_DRAW */
+ stype = H5FD_MEM_DRAW;
+ if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */
+ if(H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the H5FD_MEM_SUPER free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3))
+ TEST_ERROR
+ if(fs_stat.serial_sect_count < 2)
+ TEST_ERROR
+
+ /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #2 still in free-space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr1)
+ TEST_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_DRAW is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[stype]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_DRAW free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, stype) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3))
+ TEST_ERROR
+ if(fs_stat.serial_sect_count < 2)
+ TEST_ERROR
+
+ /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != saddr1)
+ TEST_ERROR
+
+ /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != saddr3)
+ TEST_ERROR
+ /* H5FD_MEM_DRAW free-space manager is going away at closing */
+ /* works for this one because the freeing of sect_addr is to H5FD_MEM_SUPER fs, not against itself */
+
+ /* Allocate 4 blocks of type H5FD_MEM_BTREE */
+ btype = H5FD_MEM_BTREE;
+ if(HADDR_UNDEF == (baddr5 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (baddr6 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE6)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (baddr7 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE7)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (baddr8 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE8)))
+ FAIL_STACK_ERROR
+
+ /* Put block #5 & #7 into H5FD_MEM_BTREE free-space manager */
+ if(H5MF_xfree(f, btype, H5P_DATASET_XFER_DEFAULT, baddr5, (hsize_t)TEST_BLOCK_SIZE5) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, btype, H5P_DATASET_XFER_DEFAULT, baddr7, (hsize_t)TEST_BLOCK_SIZE7) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */
+ if(H5F_addr_defined(f->shared->fs_addr[stype]))
+ TEST_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_SUPER is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE3+TEST_BLOCK_SIZE5+TEST_BLOCK_SIZE7))
+ TEST_ERROR
+
+ /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr3)
+ TEST_ERROR
+
+ /* Retrieve block #7 from H5FD_MEM_BTREE free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE7)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != baddr7)
+ TEST_ERROR
+
+ /* There should still be block #5 of H5FD_MEM_BTREE in H5FD_MEM_BTREE free-space manager */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the H5FD_MEM_SUPER free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < TEST_BLOCK_SIZE5)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_split() */
+
+/*
+ * Verify that the file's free-space manager(s) are persistent for a multi-file
+ */
+static unsigned
+test_mf_fs_multi(hid_t fapl_new, hid_t fcpl)
+{
+ hid_t file = -1; /* File ID */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type, stype, btype, gtype; /* File allocation type */
+ H5FS_stat_t fs_stat; /* Information for free-space manager */
+ haddr_t addr1, addr2, addr3, addr4; /* File allocation type */
+ haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_SUPER */
+ haddr_t baddr1, baddr2, baddr3, baddr4; /* File address for H5FD_MEM_DRAW */
+ haddr_t gaddr1, gaddr2; /* File address for H5FD_MEM_GHEAP */
+ haddr_t tmp_addr; /* Temporary variable for address */
+ H5FS_section_info_t *node; /* Free space section node */
+ htri_t node_found = FALSE; /* Indicate section is in free-space */
+
+ TESTING("file's free-space managers are persistent for multi-file");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 4 blocks of type H5FD_MEM_SUPER */
+ type = H5FD_MEM_SUPER;
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ /* Allocate 4 blocks of type H5FD_MEM_DRAW */
+ stype = H5FD_MEM_DRAW;
+ if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */
+ if(H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, stype, H5P_DATASET_XFER_DEFAULT, saddr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the H5FD_MEM_SUPER free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3))
+ TEST_ERROR
+ if(fs_stat.serial_sect_count < 2)
+ TEST_ERROR
+
+ /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #2 still in free-space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr1)
+ TEST_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_DRAW is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[stype]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_DRAW free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, stype) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3))
+ TEST_ERROR
+ if(fs_stat.serial_sect_count < 2)
+ TEST_ERROR
+
+ /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != saddr1)
+ TEST_ERROR
+
+ /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != saddr3)
+ TEST_ERROR
+
+ /* Allocate 4 blocks of type H5FD_MEM_BTREE */
+ btype = H5FD_MEM_BTREE;
+ if(HADDR_UNDEF == (baddr1 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (baddr2 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (baddr3 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (baddr4 = H5MF_alloc(f, btype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1 & #3 into H5FD_MEM_BTREE free-space manager */
+ if(H5MF_xfree(f, btype, H5P_DATASET_XFER_DEFAULT, baddr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, btype, H5P_DATASET_XFER_DEFAULT, baddr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_SUPER is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < TEST_BLOCK_SIZE3)
+ TEST_ERROR
+
+ /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(tmp_addr != addr3)
+ TEST_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */
+ if(H5F_addr_defined(f->shared->fs_addr[stype]))
+ TEST_ERROR
+
+ /* Verify that the free-space manager for H5FD_MEM_BTREE is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[btype]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_BTREE free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, btype) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[btype], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < (TEST_BLOCK_SIZE1+TEST_BLOCK_SIZE3))
+ TEST_ERROR
+ if(fs_stat.serial_sect_count < 2)
+ TEST_ERROR
+
+ /* Allocate 2 blocks of type H5FD_MEM_GHEAP */
+ gtype = H5FD_MEM_GHEAP;
+ if(HADDR_UNDEF == (gaddr2 = H5MF_alloc(f, gtype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (gaddr1 = H5MF_alloc(f, gtype, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+
+ /* Put block #2 into H5FD_MEM_GHEAP free-space manager */
+ if(H5MF_xfree(f, gtype, H5P_DATASET_XFER_DEFAULT, gaddr2, (hsize_t)TEST_BLOCK_SIZE2) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* If H5FD_MEM_SUPER is there, should not find block #1 & #3 */
+ if(H5F_addr_defined(f->shared->fs_addr[type])) {
+ /* Start up H5FD_MEM_SUPER free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE1, (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+ if(node_found) TEST_ERROR
+
+ if((node_found = H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
+ (hsize_t)TEST_BLOCK_SIZE3, (H5FS_section_info_t **)&node)) < 0)
+ FAIL_STACK_ERROR
+ if(node_found) TEST_ERROR
+ }
+
+ /* Verify that the H5FD_MEM_GHEAP free-space manager is there */
+ if(!H5F_addr_defined(f->shared->fs_addr[gtype]))
+ TEST_ERROR
+
+ /* Start up H5FD_MEM_GHEAP free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, gtype) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get free-space info */
+ if(H5FS_stat_info(f, f->shared->fs_man[gtype], &fs_stat) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify free-space info */
+ if(fs_stat.tot_space < TEST_BLOCK_SIZE2)
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_fs_multi() */
+
+#define MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) { \
+ H5FD_mem_t mt; \
+ HDmemset(memb_map, 0, sizeof memb_map); \
+ HDmemset(memb_fapl, 0, sizeof memb_fapl); \
+ HDmemset(memb_name, 0, sizeof memb_name); \
+ HDmemset(memb_addr, 0, sizeof memb_addr); \
+ HDmemset(sv, 0, sizeof sv); \
+ for (mt = 0; mt < H5FD_MEM_NTYPES; mt++) { \
+ memb_map[mt] = H5FD_MEM_SUPER; \
+ memb_fapl[mt] = H5P_DEFAULT; \
+ } \
+ memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; \
+ memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \
+ memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \
+ memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \
+ sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \
+ memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \
+ memb_addr[H5FD_MEM_SUPER] = 0; \
+ sprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \
+ memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \
+ memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6; \
+ sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \
+ memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \
+ memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3; \
+ sprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \
+ memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \
+ memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2; \
+ sprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \
+ memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \
+ memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX*2/3; \
+ sprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \
+ memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \
+ memb_addr[H5FD_MEM_OHDR] = HADDR_MAX*5/6; \
+}
+
+/*
+ * Tests to verify that file's free-space managers are persistent or going away
+ * for different drivers.
+ */
+static unsigned
+test_mf_fs_drivers(hid_t fapl)
+{
+ hid_t fcpl; /* file creation property list */
+ hid_t fapl_new; /* copy of file access property list */
+ hid_t fapl2; /* copy of file access property list */
+ hbool_t new_format; /* To use new library format or not */
+ unsigned ret = 0; /* return value */
+
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */
+ hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */
+ char sv[H5FD_MEM_NTYPES][500]; /* Name generators */
+ const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */
+ haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */
+
+ /* Create a non-standard file-creation template */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ if(H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0) < 0)
+ TEST_ERROR
+
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR
+
+ /* Test with old and new format */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+
+ if(new_format)
+ HDputs("Testing the following tests for free-space managers with new library format...");
+ else
+ HDputs("Testing the following tests for free-space managers with old library format...");
+
+ /* SEC2 */
+ HDputs("Testing free-space manager(s) with sec2 driver");
+
+ if((fapl_new = H5Pcopy(new_format ? fapl2 : fapl)) < 0) TEST_ERROR
+
+ if(H5Pset_fapl_sec2(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_mf_fs_gone(fapl_new, fcpl);
+ ret += test_mf_fs_persist(fapl_new, fcpl);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+
+ /* STDIO */
+ HDputs("Testing free-space managers with stdio driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_stdio(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_mf_fs_gone(fapl_new, fcpl);
+ ret += test_mf_fs_persist(fapl_new, fcpl);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* CORE */
+ HDputs("Testing free-space managers with core driver");
+
+ /* create fapl to be a "core" file */
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_core(fapl_new, (size_t)CORE_INCREMENT, TRUE) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_mf_fs_gone(fapl_new, fcpl);
+ ret += test_mf_fs_persist(fapl_new, fcpl);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* FAMILY */
+ HDputs("Testing free-space managers with family driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_family(fapl_new, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_mf_fs_persist(fapl_new, fcpl);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* SPLIT */
+ HDputs("Testing free-space managers with split driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_split(fapl_new, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0)
+ FAIL_STACK_ERROR
+
+ ret += test_mf_fs_persist(fapl_new, fcpl);
+ ret += test_mf_fs_split(fapl_new, fcpl);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* MULTI */
+ HDputs("Testing free-space managers with multi driver");
+
+ MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv)
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0)
+ TEST_ERROR;
+
+ ret += test_mf_fs_multi(fapl_new, fcpl);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ } /* end for new_format */
+
+ if (H5Pclose(fcpl) < 0)
+ FAIL_STACK_ERROR
+ if (H5Pclose(fapl2) < 0)
+ FAIL_STACK_ERROR
+
+ return(ret);
+
+error:
+ return(1);
+} /* test_mf_fs_drivers() */
+
+
+/*
+ * Verify that file space management performs according to the
+ * file space strategy and free space threshold as specified.
+ */
+static unsigned
+test_filespace_strategy_threshold(hid_t fapl_new)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fcpl; /* File creation property list template */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type; /* File allocation type */
+ haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */
+ haddr_t tmp_addr; /* Temporary variable for address */
+ H5F_file_space_type_t fs_type; /* File space handling strategy */
+ hsize_t fs_threshold; /* Free space section threshold */
+ hsize_t tot_space, saved_tot_space; /* Total amount of free space */
+ hsize_t tot_sect_count, saved_tot_sect_count; /* # of free-space sections */
+
+ TESTING("file space strategy and threshold");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename));
+
+ for(fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) {
+
+ for(fs_type = H5F_FILE_SPACE_ALL_PERSIST; fs_type < H5F_FILE_SPACE_NTYPES; H5_INC_ENUM(H5F_file_space_type_t, fs_type)) {
+
+ /* Create file-creation template */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set default file space information */
+ if(H5Pset_file_space(fcpl, fs_type, fs_threshold) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 6 blocks */
+ type = H5FD_MEM_SUPER;
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE6)))
+ FAIL_STACK_ERROR
+
+ /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr5, (hsize_t)TEST_BLOCK_SIZE5) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the total amount of free space and # of free-space sections */
+ if(f->shared->fs_man[type] &&
+ H5FS_sect_stats(f->shared->fs_man[type], &saved_tot_space, &saved_tot_sect_count) < 0)
+ FAIL_STACK_ERROR
+
+ /* H5F_FILE_SPACE_AGGR_VFD and H5F_FILE_SPACE_VFD: should not have free-space manager */
+ if(fs_type > H5F_FILE_SPACE_ALL && f->shared->fs_man[type])
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ switch(fs_type) {
+ case H5F_FILE_SPACE_ALL_PERSIST:
+ if(fs_threshold <= TEST_BLOCK_SIZE5) {
+ if(!H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ /* Open the free-space manager */
+ if(H5MF_alloc_open(f, H5P_DATASET_XFER_DEFAULT, type) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the total amount of free space and # of free-space sections */
+ if(H5FS_sect_stats(f->shared->fs_man[type], &tot_space, &tot_sect_count) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify that tot_space should be >= saved_tot_space */
+ /* Verify that tot_sect_count should be >= saved_tot_sect_count */
+ if(tot_space < saved_tot_space || tot_sect_count < saved_tot_sect_count)
+ TEST_ERROR
+
+ /* Retrieve block #5 from H5FD_MEM_SUPER free-space manager */
+ if(HADDR_UNDEF ==
+ (tmp_addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5)))
+ FAIL_STACK_ERROR
+
+ /* Should be the same as before */
+ if(tmp_addr != addr5)
+ TEST_ERROR
+ } else if(H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+ break;
+
+ case H5F_FILE_SPACE_ALL:
+ case H5F_FILE_SPACE_AGGR_VFD:
+ case H5F_FILE_SPACE_VFD:
+ if(H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+ break;
+
+ default:
+ break;
+ } /* end switch */
+
+ /* Closing */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pclose(fcpl) < 0)
+ FAIL_STACK_ERROR
+
+ } /* end for fs_type */
+ } /* end for fs_threshold */
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_filespace_strategy_threshold() */
+
+/*
+ * Verify section is merged/shrunk away for
+ * H5F_FILE_SPACE_ALL_PERSIST and H5F_FILE_SPACE_ALL strategy.
+ */
+static unsigned
+test_filespace_gone(hid_t fapl_new)
+{
+ hid_t file = -1; /* File ID */
+ hid_t fcpl; /* File creation propertly list template */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_t *f = NULL; /* Internal file object pointer */
+ H5FD_mem_t type; /* File allocation type */
+ haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */
+ H5F_file_space_type_t fs_type; /* File space handling strategy */
+ hsize_t fs_threshold; /* Free space section threshold */
+ frspace_state_t state; /* State of free space manager */
+
+ TESTING("file space merge/shrink for section size < threshold");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_new, filename, sizeof(filename));
+
+ /* Set free-space threshold */
+ fs_threshold = TEST_THRESHOLD3;
+
+ for(fs_type = H5F_FILE_SPACE_ALL_PERSIST; fs_type <= H5F_FILE_SPACE_ALL; H5_INC_ENUM(H5F_file_space_type_t, fs_type)) {
+ /* Create file-creation template */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set default file space information */
+ if(H5Pset_file_space(fcpl, fs_type, fs_threshold) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 6 blocks */
+ type = H5FD_MEM_SUPER;
+ if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE1)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE2)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE3)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE4)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE5)))
+ FAIL_STACK_ERROR
+ if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE6)))
+ FAIL_STACK_ERROR
+
+ /* Put block #3, #5 to H5FD_MEM_SUPER free-space manager */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr3, (hsize_t)TEST_BLOCK_SIZE3) < 0)
+ FAIL_STACK_ERROR
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr5, (hsize_t)TEST_BLOCK_SIZE5) < 0)
+ FAIL_STACK_ERROR
+
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ state.tot_space += TEST_BLOCK_SIZE3 + TEST_BLOCK_SIZE5;
+ state.tot_sect_count += 2;
+ state.serial_sect_count += 2;
+
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* section #2 is less than threshold but is merged into section #3 */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr2, (hsize_t)TEST_BLOCK_SIZE2) < 0)
+ FAIL_STACK_ERROR
+
+ state.tot_space += TEST_BLOCK_SIZE2;
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr4, (hsize_t)TEST_BLOCK_SIZE4) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr6, (hsize_t)TEST_BLOCK_SIZE6) < 0)
+ FAIL_STACK_ERROR
+
+ /* all sections should be shrunk away except section #1 */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ /* section #1 is less than threshold but is shrunk away */
+ if(H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE1) < 0)
+ FAIL_STACK_ERROR
+
+ /* free-space manager should be empty */
+ HDmemset(&state, 0, sizeof(frspace_state_t));
+ if(check_stats(f, f->shared->fs_man[type], &state))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* free-space manager should be empty */
+ if(H5F_addr_defined(f->shared->fs_addr[type]))
+ TEST_ERROR
+
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Pclose(fcpl) < 0)
+ FAIL_STACK_ERROR
+
+ } /* end for fs_type */
+
+ PASSED()
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_filespace_gone() */
+
+/*
+ * Tests to verify file space management for different drivers.
+ */
+static unsigned
+test_filespace_drivers(hid_t fapl)
+{
+ hid_t fapl_new; /* copy of file access property list */
+ hid_t fapl2; /* copy of file access property list */
+ hbool_t new_format; /* Using library new format or not */
+ unsigned ret = 0; /* return value */
+
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */
+ hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */
+ char sv[H5FD_MEM_NTYPES][500]; /* Name generators */
+ const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */
+ haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */
+
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR
+
+ /* Test with old and new format */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+
+ if(new_format)
+ HDputs("Testing the following tests for file space management with new library format...");
+ else
+ HDputs("Testing the following tests for file space management with old library format...");
+
+ /* SEC2 */
+ HDputs("Testing file space management with sec2 driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_sec2(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_filespace_strategy_threshold(fapl_new);
+ ret += test_filespace_gone(fapl_new);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* STDIO */
+ HDputs("Testing file space management with stdio driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_stdio(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_filespace_strategy_threshold(fapl_new);
+ ret += test_filespace_gone(fapl_new);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* CORE */
+ HDputs("Testing file space management with core driver");
+
+ /* create fapl to be a "core" file */
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_core(fapl_new, (size_t)CORE_INCREMENT, TRUE) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_filespace_strategy_threshold(fapl_new);
+ ret += test_filespace_gone(fapl_new);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* FAMILY */
+ HDputs("Testing file space managers with family driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_family(fapl_new, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ ret += test_filespace_strategy_threshold(fapl_new);
+ ret += test_filespace_gone(fapl_new);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+
+ /* SPLIT */
+ HDputs("Testing file space managers with split driver");
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_fapl_split(fapl_new, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0)
+ FAIL_STACK_ERROR
+
+ ret += test_filespace_strategy_threshold(fapl_new);
+ ret += test_filespace_gone(fapl_new);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ /* MULTI */
+ HDputs("Testing file space managers with multi driver");
+
+ MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv)
+
+ if((fapl_new = H5Pcopy(new_format?fapl2:fapl)) < 0)
+ TEST_ERROR
+ if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0)
+ TEST_ERROR;
+
+ ret += test_filespace_strategy_threshold(fapl_new);
+ ret += test_filespace_gone(fapl_new);
+
+ h5_cleanup(FILENAME, fapl_new);
+
+ } /* end for new_format */
+
+ if (H5Pclose(fapl2) < 0)
+ FAIL_STACK_ERROR
+
+ return(ret);
+
+error:
+ return(1);
+} /* test_filespace_drivers() */
+
+int
+main(void)
+{
+ hid_t fapl = -1; /* File access property list for data files */
+ hid_t new_fapl = -1; /* File access property list for alignment & aggr setting */
+ unsigned nerrors = 0; /* Cumulative error count */
+ test_type_t curr_test; /* Current test being worked on */
+ const char *env_h5_drvr; /* File Driver value from environment */
+
+ /* Get the VFD to use */
+ env_h5_drvr = HDgetenv("HDF5_DRIVER");
+ if(env_h5_drvr == NULL)
+ env_h5_drvr = "nomatch";
+
+ fapl = h5_fileaccess();
+
+ /* Make a copy of the FAPL before adjusting the alignment */
+ if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* alignment is not set for the following tests */
+ if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0)
+ TEST_ERROR
+
+ /* meta/small data is set to 2048 for the following tests */
+ if(H5Pset_meta_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
+ TEST_ERROR
+ if(H5Pset_small_data_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
+ TEST_ERROR
+
+ /* interaction with file allocation */
+ nerrors += test_mf_eoa(env_h5_drvr, fapl);
+ nerrors += test_mf_eoa_shrink(env_h5_drvr, fapl);
+ nerrors += test_mf_eoa_extend(env_h5_drvr, fapl);
+
+ /* interaction with temporary file space allocation */
+ nerrors += test_mf_tmp(env_h5_drvr, fapl);
+
+ /* interaction with free-space manager */
+ nerrors += test_mf_fs_start(fapl);
+ nerrors += test_mf_fs_alloc_free(fapl);
+ nerrors += test_mf_fs_extend(fapl);
+ nerrors += test_mf_fs_absorb(env_h5_drvr, fapl);
+
+ /* interaction with meta/sdata aggregator */
+ nerrors += test_mf_aggr_alloc1(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_alloc2(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_alloc3(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_alloc4(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_alloc5(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_alloc6(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_alloc7(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_extend(env_h5_drvr, fapl);
+ nerrors += test_mf_aggr_absorb(env_h5_drvr, fapl);
+
+ /* Tests for alignment */
+ for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) {
+
+ switch(curr_test) {
+
+ case TEST_NORMAL: /* set alignment = 1024 */
+ if(H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN1024) < 0)
+ TEST_ERROR
+ break;
+
+ case TEST_AGGR_SMALL: /* set alignment = 4096 */
+ if(H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN4096) < 0)
+ TEST_ERROR
+ break;
+
+ default:
+ TEST_ERROR;
+ break;
+ } /* end switch */
+
+ nerrors += test_mf_align_eoa(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_fs(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_alloc1(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_alloc2(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_alloc3(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_alloc4(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_alloc5(env_h5_drvr, fapl, new_fapl);
+ nerrors += test_mf_align_alloc6(env_h5_drvr, fapl, new_fapl);
+ } /* end if */
+
+ /* tests to verify that file's free-space managers are persistent */
+ nerrors += test_mf_fs_drivers(fapl);
+
+ /* tests for file space management */
+ nerrors += test_filespace_drivers(fapl);
+
+ if (H5Pclose(new_fapl) < 0)
+ FAIL_STACK_ERROR
+ h5_cleanup(FILENAME, fapl);
+
+ if(nerrors)
+ goto error;
+ puts("All free-space manager tests for file memory passed.");
+
+ return (0);
+
+error:
+ puts("*** TESTS FAILED ***");
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+ return (1);
+} /* main() */
+
diff --git a/test/mount.c b/test/mount.c
index c86c56b..f358634 100644
--- a/test/mount.c
+++ b/test/mount.c
@@ -502,6 +502,7 @@ test_assoc(hid_t fapl)
* of file2.
*/
if(H5Oget_info_by_name(file1, "/mnt1", &oi2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) {
H5_FAILED();
puts(" Association failed.");
@@ -2558,7 +2559,6 @@ test_acc_perm(hid_t fapl)
hid_t gidA = -1, gidB = -1, gidC = -1, gidM = -1, gidAM = -1, gidAMZ = -1; /* Group IDs */
hid_t bad_id = -1; /* Bad ID from object create */
char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */
- ssize_t name_len; /* Filename length */
char filename1[1024],
filename2[1024],
filename3[1024]; /* Name of files to mount */
@@ -2605,7 +2605,7 @@ test_acc_perm(hid_t fapl)
TEST_ERROR
/* Get and verify file name */
- if((name_len = H5Fget_name(gidA, name, NAME_BUF_SIZE)) < 0)
+ if(H5Fget_name(gidA, name, NAME_BUF_SIZE) < 0)
TEST_ERROR
if(HDstrcmp(name, filename1) != 0)
TEST_ERROR
@@ -2614,7 +2614,7 @@ test_acc_perm(hid_t fapl)
TEST_ERROR
/* Get and verify file name */
- if((name_len = H5Fget_name(fid2, name, NAME_BUF_SIZE)) < 0)
+ if(H5Fget_name(fid2, name, NAME_BUF_SIZE) < 0)
TEST_ERROR
if(HDstrcmp(name, filename2) != 0)
TEST_ERROR
@@ -2624,7 +2624,7 @@ test_acc_perm(hid_t fapl)
TEST_ERROR
/* Get and verify file name */
- if((name_len = H5Fget_name(fid2, name, NAME_BUF_SIZE)) < 0)
+ if(H5Fget_name(fid2, name, NAME_BUF_SIZE) < 0)
TEST_ERROR
if(HDstrcmp(name, filename2) != 0)
TEST_ERROR
@@ -2634,7 +2634,7 @@ test_acc_perm(hid_t fapl)
TEST_ERROR
/* Get and verify file name */
- if((name_len = H5Fget_name(gidAM, name, NAME_BUF_SIZE)) < 0)
+ if(H5Fget_name(gidAM, name, NAME_BUF_SIZE) < 0)
TEST_ERROR
if(HDstrcmp(name, filename2) != 0)
TEST_ERROR
@@ -2676,7 +2676,7 @@ test_acc_perm(hid_t fapl)
TEST_ERROR
/* Get and verify file name */
- if((name_len = H5Fget_name(gidAMZ, name, NAME_BUF_SIZE)) < 0)
+ if(H5Fget_name(gidAMZ, name, NAME_BUF_SIZE) < 0)
TEST_ERROR
if(HDstrcmp(name, filename3) != 0)
TEST_ERROR
@@ -3392,7 +3392,7 @@ test_cut_graph(hid_t fapl)
hid_t gidQ = -1; /* Group IDs in file #7 */
char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */
ssize_t name_len; /* Filename length */
- int obj_count; /* Number of objects open */
+ ssize_t obj_count; /* Number of objects open */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE],
filename3[NAME_BUF_SIZE],
@@ -4202,6 +4202,130 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_multisharedclose
+ *
+ * Purpose: Test that multiple files mounted to a shared mount structure
+ * can be properly closed by closing the groups holding them open.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Friday, November 14, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+ static int
+test_multisharedclose(hid_t fapl)
+{
+ hid_t fid1 = -1, fid2 = -1; /* File IDs */
+ hid_t gid1 = -1, gid2 = -1, gid3 = -1;
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ filename3[NAME_BUF_SIZE],
+ filename4[NAME_BUF_SIZE]; /* Name of files to mount */
+
+ TESTING("closing multiple shared mounts");
+
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
+ h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3);
+ h5_fixname(FILENAME[3], fapl, filename4, sizeof filename4);
+
+ /* Create master file with three groups to serve as mount points */
+ if ((fid1 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Gclose(H5Gcreate2(fid1, "mnt1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Gclose(H5Gcreate2(fid1, "mnt2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Gclose(H5Gcreate2(fid1, "mnt3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fclose(fid1) < 0) TEST_ERROR
+
+ /* Create child file with group */
+ if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fclose(fid1) < 0) TEST_ERROR
+
+ /* Create child file with group */
+ if ((fid1 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fclose(fid1) < 0) TEST_ERROR
+
+ /* Create child file with group */
+ if ((fid1 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fclose(fid1) < 0) TEST_ERROR
+
+
+ /* Open master and child 1 and mount child 1 to master */
+ if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if ((fid2 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fmount(fid1, "mnt1", fid2, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open the group in child 1 */
+ if ((gid1 = H5Gopen2(fid1, "mnt1/grp", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Close both files. They will be held open by gid1 */
+ if (H5Idec_ref(fid2) < 0) TEST_ERROR
+ if (H5Idec_ref(fid1) < 0) TEST_ERROR
+
+
+ /* Open master and child 2 and mount child 2 to master */
+ if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fmount(fid1, "mnt2", fid2, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open the group in child 2 */
+ if ((gid2 = H5Gopen2(fid1, "mnt2/grp", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Close both files. They will be held open by gid2 */
+ if (H5Idec_ref(fid2) < 0) TEST_ERROR
+ if (H5Idec_ref(fid1) < 0) TEST_ERROR
+
+
+ /* Open master and child 3 and mount child 3 to master */
+ if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if ((fid2 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if (H5Fmount(fid1, "mnt3", fid2, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open the group in child 3 */
+ if ((gid3 = H5Gopen2(fid1, "mnt3/grp", H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Close both files. They will be held open by gid3 */
+ if (H5Idec_ref(fid2) < 0) TEST_ERROR
+ if (H5Idec_ref(fid1) < 0) TEST_ERROR
+
+
+ /* Close gid1. This will close child 1. */
+ if (H5Idec_ref(gid1) < 0) TEST_ERROR
+
+ /* Close gid2. This will close child 2. */
+ if (H5Idec_ref(gid2) < 0) TEST_ERROR
+
+ /* Close gid3. This will close child 3 and the master file. */
+ if (H5Idec_ref(gid3) < 0) TEST_ERROR
+
+ /* Check that all file IDs have been closed */
+ if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR
+ if(H5F_sfile_assert_num(0) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid1);
+ H5Gclose(gid2);
+ H5Gclose(gid3);
+ H5Fclose(fid2);
+ H5Fclose(fid2);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_multisharedclose() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test file mounting
@@ -4222,59 +4346,52 @@ main(void)
{
int nerrors = 0;
hid_t fapl = -1;
- const char *envval = NULL;
-
- envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, "split") && HDstrcmp(envval, "multi")) {
- h5_reset();
- fapl = h5_fileaccess();
- if (setup(fapl) < 0) goto error;
-
- nerrors += test_basic(fapl);
- nerrors += test_illegal(fapl);
- nerrors += test_samefile(fapl);
- nerrors += test_hide(fapl);
- nerrors += test_assoc(fapl);
- nerrors += test_mntlnk(fapl);
- nerrors += test_unlink(fapl);
- nerrors += test_move(fapl);
- nerrors += test_mvmpt(fapl);
- nerrors += test_preopen(fapl);
- nerrors += test_postopen(fapl);
- nerrors += test_interlink(fapl);
- nerrors += test_uniformity(fapl);
- nerrors += test_close(fapl);
- nerrors += test_mount_after_close(fapl);
- nerrors += test_mount_after_unmount(fapl);
- nerrors += test_missing_unmount(fapl);
- nerrors += test_hold_open_file(fapl);
- nerrors += test_hold_open_group(fapl);
- nerrors += test_fcdegree_same(fapl);
- nerrors += test_fcdegree_semi(fapl);
- nerrors += test_fcdegree_strong(fapl);
- nerrors += test_acc_perm(fapl);
- nerrors += test_mult_mount(fapl);
- nerrors += test_nested_survive(fapl);
- nerrors += test_close_parent(fapl);
- nerrors += test_cut_graph(fapl);
- nerrors += test_symlink(fapl);
- nerrors += test_sharedacc(fapl);
- nerrors += test_sharedclose(fapl);
-
- if (nerrors) goto error;
- puts("All mount tests passed.");
- h5_cleanup(FILENAME, fapl);
- }
- else
- {
- puts("All mount tests skipped - Incompatible with current Virtual File Driver");
- }
+
+ h5_reset();
+ fapl = h5_fileaccess();
+ if (setup(fapl) < 0) goto error;
+
+ nerrors += test_basic(fapl);
+ nerrors += test_illegal(fapl);
+ nerrors += test_samefile(fapl);
+ nerrors += test_hide(fapl);
+ nerrors += test_assoc(fapl);
+ nerrors += test_mntlnk(fapl);
+ nerrors += test_unlink(fapl);
+ nerrors += test_move(fapl);
+ nerrors += test_mvmpt(fapl);
+ nerrors += test_preopen(fapl);
+ nerrors += test_postopen(fapl);
+ nerrors += test_interlink(fapl);
+ nerrors += test_uniformity(fapl);
+ nerrors += test_close(fapl);
+ nerrors += test_mount_after_close(fapl);
+ nerrors += test_mount_after_unmount(fapl);
+ nerrors += test_missing_unmount(fapl);
+ nerrors += test_hold_open_file(fapl);
+ nerrors += test_hold_open_group(fapl);
+ nerrors += test_fcdegree_same(fapl);
+ nerrors += test_fcdegree_semi(fapl);
+ nerrors += test_fcdegree_strong(fapl);
+ nerrors += test_acc_perm(fapl);
+ nerrors += test_mult_mount(fapl);
+ nerrors += test_nested_survive(fapl);
+ nerrors += test_close_parent(fapl);
+ nerrors += test_cut_graph(fapl);
+ nerrors += test_symlink(fapl);
+ nerrors += test_sharedacc(fapl);
+ nerrors += test_sharedclose(fapl);
+ nerrors += test_multisharedclose(fapl);
+
+ if (nerrors) goto error;
+
+ puts("All mount tests passed.");
+ h5_cleanup(FILENAME, fapl);
+
return 0;
- error:
- puts("***** MOUNT ERRORS *****");
- return 1;
+error:
+ puts("***** MOUNT ERRORS *****");
+ return 1;
}
diff --git a/test/mtime.c b/test/mtime.c
index 395b065..741f09a 100644
--- a/test/mtime.c
+++ b/test/mtime.c
@@ -85,7 +85,7 @@ main(void)
if(H5Fclose(file) < 0) TEST_ERROR;
/*
- * Open the file and get the modification time. We'll test the
+ * Open the file and get the modification time. We'll test the
* H5Oget_info() arguments too: being able to stat something without
* knowing its name.
*/
diff --git a/test/ntypes.c b/test/ntypes.c
index 4bbbf01..87484d9 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -23,8 +23,8 @@
#include "h5test.h"
const char *FILENAME[] = {
- "ntypes",
- NULL
+ "ntypes",
+ NULL
};
#define DIM0 100
@@ -60,6 +60,7 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5];
#define SPACE2_DIM1 10
#define SPACE2_DIM2 10
+
/*-------------------------------------------------------------------------
* Function: test_atomic_dtype
@@ -80,189 +81,197 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5];
static herr_t
test_atomic_dtype(hid_t file)
{
- hid_t dataset, space;
- hid_t dtype, native_type;
- int i, j, n;
- hsize_t dims[2];
- void *tmp;
- const char *envval = NULL;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tmp = NULL;
TESTING("atomic datatype");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "split") && HDstrcmp(envval, "multi")) {
- /* Initialize the dataset */
- for(i = n = 0; i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
- ipoints2[i][j] = n++;
-
- /* Create the data space */
- dims[0] = DIM0;
- dims[1] = DIM1;
- if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR;
-
- /*------------------- Test data values ------------------------*/
- /* Create the dataset */
- if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_1, H5T_STD_I32BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- /* Write the data to the dataset */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0)
- TEST_ERROR;
- /* Close dataset */
- if(H5Dclose(dataset) < 0) TEST_ERROR;
+ /* Initialize the dataset */
+ for(i = n = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ ipoints2[i][j] = n++;
- /* Open dataset again to check H5Tget_native_type */
- if((dataset = H5Dopen2(file, DSET_ATOMIC_NAME_1, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
-
- if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- TEST_ERROR;
-
- /* Verify the datatype retrieved and converted */
- if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_INT))
- TEST_ERROR;
- if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I32BE))
- TEST_ERROR;
- if(H5T_INTEGER != H5Tget_class(native_type))
- TEST_ERROR;
-
- /* Read the dataset back. The temporary buffer is for special platforms
- * like Cray. */
- tmp = malloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
+ /* Create the data space */
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR;
- if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ /*------------------- Test data values ------------------------*/
+ /* Create the dataset */
+ if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_1, H5T_STD_I32BE, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
- /* Copy data from temporary buffer to destination buffer */
- memcpy(icheck2, tmp, (size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
- free(tmp);
-
- /* Convert to the integer type */
- if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0*DIM1), icheck2, NULL, H5P_DEFAULT) < 0)
- TEST_ERROR;
-
- /* Check that the values read are the same as the values written */
- for(i = 0; i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
- if(ipoints2[i][j] != icheck2[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- } /* end if */
+ /* Write the data to the dataset */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0)
+ TEST_ERROR;
- if(H5Dclose(dataset) < 0) TEST_ERROR;
- if(H5Tclose(native_type) < 0) TEST_ERROR;
- if(H5Tclose(dtype) < 0) TEST_ERROR;
-
- /*------------------ Test different data types ----------------*/
-
- /* Create the dataset of H5T_STD_I64LE */
- if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_2, H5T_STD_I64LE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
-
- if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- TEST_ERROR;
-
- /* Verify the datatype retrieved and converted */
- if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_LLONG))
- TEST_ERROR;
- if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I64LE))
- TEST_ERROR;
- if(H5T_INTEGER!=H5Tget_class(native_type))
- TEST_ERROR;
-
- if(H5Dclose(dataset) < 0) TEST_ERROR;
- if(H5Tclose(native_type) < 0) TEST_ERROR;
- if(H5Tclose(dtype) < 0) TEST_ERROR;
-
-
- /* Create the dataset of H5T_STD_I8LE */
- if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_3, H5T_STD_I8LE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
-
- if((native_type = H5Tget_native_type(dtype, H5T_DIR_ASCEND)) < 0)
- TEST_ERROR;
-
- /* Verify the datatype retrieved and converted */
- if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_CHAR))
- TEST_ERROR;
- if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I8LE))
- TEST_ERROR;
- if(H5T_INTEGER!=H5Tget_class(native_type))
- TEST_ERROR;
+ /* Close dataset */
+ if(H5Dclose(dataset) < 0) TEST_ERROR;
- if(H5Dclose(dataset) < 0) TEST_ERROR;
- if(H5Tclose(native_type) < 0) TEST_ERROR;
- if(H5Tclose(dtype) < 0) TEST_ERROR;
+ /* Open dataset again to check H5Tget_native_type */
+ if((dataset = H5Dopen2(file, DSET_ATOMIC_NAME_1, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
- /* Create the dataset of H5T_IEEE_F32BE */
- if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_4, H5T_IEEE_F32BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ TEST_ERROR;
- if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
+ /* Verify the datatype retrieved and converted */
+ if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_INT))
+ TEST_ERROR;
+ if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I32BE))
+ TEST_ERROR;
+ if(H5T_INTEGER != H5Tget_class(native_type))
+ TEST_ERROR;
- if((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0)
- TEST_ERROR;
+ /* Read the dataset back. The temporary buffer is for special platforms
+ * like Cray. */
+ if(NULL == (tmp = HDmalloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type)))))
+ TEST_ERROR
- /* Verify the datatype retrieved and converted */
- if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_FLOAT))
- TEST_ERROR;
- if(H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F32BE))
- TEST_ERROR;
- if(H5T_FLOAT!=H5Tget_class(native_type))
- TEST_ERROR;
+ if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
+ TEST_ERROR;
- if(H5Dclose(dataset) < 0) TEST_ERROR;
- if(H5Tclose(native_type) < 0) TEST_ERROR;
- if(H5Tclose(dtype) < 0) TEST_ERROR;
+ /* Copy data from temporary buffer to destination buffer */
+ HDmemcpy(icheck2, tmp, (size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
+ HDfree(tmp);
+ tmp = NULL;
+ /* Convert to the integer type */
+ if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0 * DIM1), icheck2, NULL, H5P_DEFAULT) < 0)
+ TEST_ERROR;
- /* Create the dataset of H5T_IEEE_F64BE */
- if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_5, H5T_IEEE_F64BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ if(ipoints2[i][j] != icheck2[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if(H5Tclose(native_type) < 0) TEST_ERROR;
+ if(H5Tclose(dtype) < 0) TEST_ERROR;
+
+ /*------------------ Test different data types ----------------*/
+
+ /* Create the dataset of H5T_STD_I64LE */
+ if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_2, H5T_STD_I64LE, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
- if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
+ if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
- if((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0)
- TEST_ERROR;
+ if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ TEST_ERROR;
- /* Verify the datatype retrieved and converted */
- if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_DOUBLE))
- TEST_ERROR;
- if(H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F64BE))
- TEST_ERROR;
- if(H5T_FLOAT != H5Tget_class(native_type))
- TEST_ERROR;
+ /* Verify the datatype retrieved and converted */
+ if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_LLONG))
+ TEST_ERROR;
+ if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I64LE))
+ TEST_ERROR;
+ if(H5T_INTEGER!=H5Tget_class(native_type))
+ TEST_ERROR;
+
+ if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if(H5Tclose(native_type) < 0) TEST_ERROR;
+ if(H5Tclose(dtype) < 0) TEST_ERROR;
+
+
+ /* Create the dataset of H5T_STD_I8LE */
+ if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_3, H5T_STD_I8LE, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
+
+ if((native_type = H5Tget_native_type(dtype, H5T_DIR_ASCEND)) < 0)
+ TEST_ERROR;
+
+ /* Verify the datatype retrieved and converted */
+ if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_CHAR))
+ TEST_ERROR;
+ if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I8LE))
+ TEST_ERROR;
+ if(H5T_INTEGER!=H5Tget_class(native_type))
+ TEST_ERROR;
+
+ if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if(H5Tclose(native_type) < 0) TEST_ERROR;
+ if(H5Tclose(dtype) < 0) TEST_ERROR;
+
+
+ /* Create the dataset of H5T_IEEE_F32BE */
+ if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_4, H5T_IEEE_F32BE, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
+
+ if((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0)
+ TEST_ERROR;
+
+ /* Verify the datatype retrieved and converted */
+ if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_FLOAT))
+ TEST_ERROR;
+ if(H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F32BE))
+ TEST_ERROR;
+ if(H5T_FLOAT!=H5Tget_class(native_type))
+ TEST_ERROR;
+
+ if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if(H5Tclose(native_type) < 0) TEST_ERROR;
+ if(H5Tclose(dtype) < 0) TEST_ERROR;
+
+
+ /* Create the dataset of H5T_IEEE_F64BE */
+ if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_5, H5T_IEEE_F64BE, space,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
+
+ if((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0)
+ TEST_ERROR;
+
+ /* Verify the datatype retrieved and converted */
+ if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_DOUBLE))
+ TEST_ERROR;
+ if(H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F64BE))
+ TEST_ERROR;
+ if(H5T_FLOAT != H5Tget_class(native_type))
+ TEST_ERROR;
+
+ if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if(H5Tclose(native_type) < 0) TEST_ERROR;
+ if(H5Tclose(dtype) < 0) TEST_ERROR;
- if(H5Dclose(dataset) < 0) TEST_ERROR;
- if(H5Tclose(native_type) < 0) TEST_ERROR;
- if(H5Tclose(dtype) < 0) TEST_ERROR;
+ /* Close dataspace */
+ if(H5Sclose(space) < 0) TEST_ERROR;
- /* Close dataspace */
- if(H5Sclose(space) < 0) TEST_ERROR;
+ PASSED();
- PASSED();
- }
- else
- {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- }
return 0;
- error:
- return -1;
+error:
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(native_type);
+ H5Tclose(dtype);
+ H5Sclose(space);
+ } H5E_END_TRY;
+
+ return -1;
}
@@ -293,35 +302,35 @@ test_compound_dtype2(hid_t file)
char c;
int i;
s2 st;
- unsigned long_long l;
+ unsigned long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m, tid_m2,
- mem_id, nest_mem_id;
- int i, j, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ tid_m2 = -1, mem_id = -1, nest_mem_id = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("nested compound datatype");
/* Allocate space for the points & check arrays */
- if((points=malloc(sizeof(s1)*DIM0*DIM1))==NULL)
+ if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1)))
TEST_ERROR;
- if((check=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
/* Initialize the dataset */
- for (i = n = 0, temp_point=points; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->i = n++;
- temp_point->st.c2 = i+j;
- temp_point->st.l2 = (i*5+j*50)*n;
- temp_point->l = (i*10+j*100)*n;
- }
- }
+ for(i = n = 0, temp_point = points; i < DIM0; i++) {
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->i = n++;
+ temp_point->st.c2 = (short)(i + j);
+ temp_point->st.l2 = (i * 5 + j * 50) * n;
+ temp_point->l = (unsigned long long)((i * 10 + j * 100) * n);
+ } /* end for */
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -362,7 +371,8 @@ test_compound_dtype2(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for memory */
if((tid_m2 = H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR;
@@ -378,7 +388,7 @@ test_compound_dtype2(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -460,36 +470,39 @@ test_compound_dtype2(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->st.c2 != temp_check->st.c2 ||
- temp_point->st.l2 != temp_check->st.l2 ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) {
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->i != temp_check->i ||
+ temp_point->st.c2 != temp_check->st.c2 ||
+ temp_point->st.l2 != temp_check->st.l2 ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
/* Close temporary datatypes */
if(H5Tclose(tid2) < 0) TEST_ERROR;
@@ -503,17 +516,35 @@ test_compound_dtype2(hid_t file)
H5Tclose(tid_m);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
error:
- if(points!=NULL)
- free(points);
- if(check!=NULL)
- free(check);
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Tclose(nest_mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ } H5E_END_TRY;
+
return -1;
}
@@ -540,32 +571,34 @@ test_compound_dtype(hid_t file)
typedef struct {
char c;
unsigned int i;
- long_long l;
+ long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, mem_id;
- int i, j, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points, *check;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, mem_id = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL;
+ s1 *temp_check = NULL;
+ s1 *points = NULL;
+ s1 *check = NULL;
+ void *tmp = NULL;
+ void *bkg = NULL;
TESTING("compound datatype");
-
/* Allocate space for the points & check arrays */
- if((points=malloc(sizeof(s1)*DIM0*DIM1))==NULL)
+ if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1)))
TEST_ERROR;
- if((check = calloc(sizeof(s1), DIM0 * DIM1)) == NULL)
+ if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->i = n++;
- temp_point->l = (i*10+j*100)*n;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->i = (unsigned int)(n++);
+ temp_point->l = (i * 10 + j * 100) * n;
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -582,7 +615,8 @@ test_compound_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -592,7 +626,7 @@ test_compound_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -642,33 +676,35 @@ test_compound_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- bkg = calloc(sizeof(s1),DIM0*DIM1);
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid2, (DIM0*DIM1), check, bkg, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid2, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++)
+ if(temp_point->c != temp_check->c ||
+ temp_point->i != temp_check->i ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
/* Close datatype */
if(H5Tclose(tid) < 0) TEST_ERROR;
@@ -679,13 +715,33 @@ test_compound_dtype(hid_t file)
H5Tclose(tid2);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid2);
+ } H5E_END_TRY;
+
return -1;
}
@@ -712,34 +768,34 @@ test_compound_dtype3(hid_t file)
typedef struct {
char c;
int a[5];
- long_long l;
+ long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m, tid_m2,
- mem_id, nest_mem_id;
- hsize_t array_dims[1]={5};
- int i, j, k, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ tid_m2 = -1, mem_id = -1, nest_mem_id = -1;
+ hsize_t array_dims[1] = {5};
+ int i, j, k, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("compound datatype with array as field");
/* Allocate space for the points & check arrays */
- if((points=malloc(sizeof(s1)*DIM0*DIM1))==NULL)
+ if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1)))
TEST_ERROR;
- if((check=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->l = (i*10+j*100)*n;
- for(k = 0; k < 5; k++)
- (temp_point->a)[k] = n++;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->l = (i * 10 + j * 100) * n;
+ for(k = 0; k < 5; k++)
+ (temp_point->a)[k] = n++;
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -759,7 +815,8 @@ test_compound_dtype3(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_3, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create array datatype */
if((tid_m2 = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR;
@@ -772,7 +829,7 @@ test_compound_dtype3(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -834,42 +891,44 @@ test_compound_dtype3(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR;
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
-
- for (k = 0; k < 5; k++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ for(k = 0; k < 5; k++) {
if(temp_point->a[k] != temp_check->a[k]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d,%d\n", i, j, k);
- goto error;
- }
- }
- }
- }
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d,%d\n", i, j, k);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -878,13 +937,36 @@ test_compound_dtype3(hid_t file)
H5Tclose(tid_m2);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Tclose(nest_mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ } H5E_END_TRY;
+
return -1;
}
@@ -911,33 +993,33 @@ test_compound_opaque(hid_t file)
typedef struct {
char c;
unsigned char o[5];
- long_long l;
+ long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m,
- mem_id;
- int i, j, k, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ mem_id = -1;
+ int i, j, k, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("compound datatype with opaque field");
/* Allocate space for the points & check arrays */
- if((points=HDmalloc(sizeof(s1)*DIM0*DIM1))==NULL)
+ if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1)))
TEST_ERROR;
- if((check=HDcalloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->l = (i*10+j*100)*n;
- for(k = 0; k < 5; k++)
- (temp_point->o)[k] = n++;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->l = (i * 10 + j * 100) * n;
+ for(k = 0; k < 5; k++)
+ (temp_point->o)[k] = (unsigned char)(n++);
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -958,7 +1040,8 @@ test_compound_opaque(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_4, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -968,7 +1051,7 @@ test_compound_opaque(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1023,42 +1106,44 @@ test_compound_opaque(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=HDcalloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR;
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
-
- for (k = 0; k < 5; k++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ for(k = 0; k < 5; k++) {
if(temp_point->o[k] != temp_check->o[k]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d,%d\n", i, j, k);
- goto error;
- }
- }
- }
- }
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d,%d\n", i, j, k);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -1072,7 +1157,28 @@ test_compound_opaque(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1096,28 +1202,28 @@ test_compound_opaque(hid_t file)
static herr_t
test_enum_dtype(hid_t file)
{
- hid_t dataset, space;
- hid_t tid, tid_m, dtype, native_type;
- int i, j, n;
- hsize_t dims[2];
- void *tmp;
- short colors[8];
- unsigned char sub_colors[16];
- const char *mname[] = { "RED",
- "GREEN",
- "BLUE",
- "YELLOW",
- "PINK",
- "PURPLE",
- "ORANGE",
- "WHITE" };
+ hid_t dataset = -1, space = -1;
+ hid_t tid = -1, tid_m = -1, dtype = -1, native_type = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tmp = NULL;
+ short colors[8];
+ unsigned char sub_colors[16];
+ const char *mname[] = { "RED",
+ "GREEN",
+ "BLUE",
+ "YELLOW",
+ "PINK",
+ "PURPLE",
+ "ORANGE",
+ "WHITE" };
TESTING("enum datatype");
/* Initialize the dataset */
for(i = 0; i < DIM0; i++)
for(j = 0, n = 0; j < DIM1; j++, n++)
- spoints2[i][j] = (i*10+j*100+n)%8;
+ spoints2[i][j] = (short)((i * 10 + j * 100 + n) % 8);
/* Create the data space */
dims[0] = DIM0;
@@ -1128,26 +1234,27 @@ test_enum_dtype(hid_t file)
if((tid = H5Tenum_create(H5T_STD_I16LE)) < 0) TEST_ERROR;
for(i = 0; i < 8; i++) {
- sub_colors[i * 2] = i;
+ sub_colors[i * 2] = (unsigned char)i;
sub_colors[i * 2 + 1] = 0;
if(H5Tenum_insert(tid, mname[i], &(sub_colors[i*2])) < 0) TEST_ERROR;
} /* end for */
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ENUM_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Construct enum type based on native type in memory */
if((tid_m = H5Tenum_create(H5T_NATIVE_SHORT)) < 0) TEST_ERROR;
for(i = 0; i < 8; i++) {
- colors[i] = i;
+ colors[i] = (short)i;
if(H5Tenum_insert(tid_m, mname[i], &(colors[i])) < 0) TEST_ERROR;
} /* end for */
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, spoints2) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1168,30 +1275,30 @@ test_enum_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), scheck2, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), scheck2, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- if(spoints2[i][j] != scheck2[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ if(spoints2[i][j] != scheck2[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
printf(" spoints2[i][j]=%hd, scheck2[i][j]=%hd\n", spoints2[i][j],
scheck2[i][j]);
- goto error;
- }
- }
- }
+ goto error;
+ } /* end if */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -1200,7 +1307,20 @@ test_enum_dtype(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1227,32 +1347,32 @@ test_array_dtype(hid_t file)
typedef struct {
char c;
int i;
- long_long l;
+ long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid3, tid_m;
- int i, j, k, n;
- hsize_t space_dims[2], array_dims[1]={5};
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid3 = -1, tid_m = -1;
+ int i, j, k, n;
+ hsize_t space_dims[2], array_dims[1]={5};
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL;
TESTING("array of compound datatype");
/* Allocate space for the points & check arrays */
- if((points=malloc(sizeof(s1)*DIM0*DIM1*5))==NULL)
+ if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1 * 5)))
TEST_ERROR;
- if((check=calloc(sizeof(s1),DIM0*DIM1*5))==NULL)
+ if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1 * 5)))
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
for(k = 0; k < 5; k++,temp_point++) {
temp_point->c= 't';
temp_point->i= n++;
- temp_point->l= (i*10+j*100)*n;
- }
+ temp_point->l= (i * 10 + j * 100) * n;
+ } /* end for */
/* Create the data space */
space_dims[0] = DIM0;
@@ -1272,7 +1392,8 @@ test_array_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ARRAY_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid3 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -1285,7 +1406,7 @@ test_array_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1307,32 +1428,31 @@ test_array_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- for (k = 0; k < 5; k++, temp_point++,temp_check++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ for(k = 0; k < 5; k++, temp_point++, temp_check++)
if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->l != temp_check->l ) {
+ temp_point->i != temp_check->i ||
+ temp_point->l != temp_check->l ) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
- }
- }
- }
- }
+ } /* end if */
/* Close HDF5 objects */
if(H5Dclose(dataset)) TEST_ERROR;
@@ -1342,17 +1462,32 @@ test_array_dtype(hid_t file)
if(H5Tclose(tid3) < 0) TEST_ERROR;
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
error:
- if(points!=NULL)
- free(points);
- if(check!=NULL)
- free(check);
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid3);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1376,17 +1511,17 @@ error:
static herr_t
test_array_dtype2(hid_t file)
{
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid_m;
- int i, j, k, n;
- hsize_t space_dims[2], array_dims[1]={5};
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid_m = -1;
+ int i, j, k, n;
+ hsize_t space_dims[2], array_dims[1] = {5};
+ void *tmp = NULL;
TESTING("array of atomic datatype");
/* Initialize the dataset */
for(i = n = 0;i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
+ for(j = 0; j < DIM1; j++)
for(k = 0; k < 5; k++)
ipoints3[i][j][k] = n++;
@@ -1400,14 +1535,15 @@ test_array_dtype2(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ARRAY2_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create array datatype for memory */
if((tid_m = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR;
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints3) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1418,7 +1554,6 @@ test_array_dtype2(hid_t file)
/* Close dataspace */
if(H5Sclose(space) < 0) TEST_ERROR;
-
/* Open dataset again to check H5Tget_native_type */
if((dataset = H5Dopen2(file, DSET_ARRAY2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR;
@@ -1429,30 +1564,29 @@ test_array_dtype2(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), icheck3, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), icheck3, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- for (k = 0; k < 5; k++) {
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ for(k = 0; k < 5; k++)
if(icheck3[i][j][k] != ipoints3[i][j][k]) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
- }
- }
- }
- }
+ } /* end if */
/* Close HDF5 objects */
if(H5Dclose(dataset)) TEST_ERROR;
@@ -1464,6 +1598,19 @@ test_array_dtype2(hid_t file)
return 0;
error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1487,37 +1634,36 @@ error:
static herr_t
test_vl_dtype(hid_t file)
{
- hvl_t wdata[SPACE1_DIM1]; /* Information to write */
- hvl_t rdata[SPACE1_DIM1]; /* Information read in */
- hvl_t *t1, *t2; /* Temporary pointer to VL information */
- hsize_t dims1[] = {SPACE1_DIM1};
- hid_t dataset, space;
- hid_t dtype, native_type, nat_super_type, tid, tid2, tid_m, tid_m2;
- size_t i, j, k;
- void* *tmp;
+ hvl_t wdata[SPACE1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1]; /* Information read in */
+ hvl_t *t1, *t2; /* Temporary pointer to VL information */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, nat_super_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1;
+ size_t i, j, k;
+ void **tmp = NULL;
TESTING("variable length datatype");
/* Allocate and initialize VL data to write */
- for(i=0; i<SPACE1_DIM1; i++) {
- wdata[i].p=malloc((i+1)*sizeof(hvl_t));
- if(wdata[i].p==NULL) {
+ for(i = 0; i < SPACE1_DIM1; i++) {
+ wdata[i].p = HDmalloc((i + 1) * sizeof(hvl_t));
+ if(NULL == wdata[i].p) {
H5_FAILED();
printf(" Cannot allocate memory for VL data! i=%u\n",(unsigned)i);
goto error;
} /* end if */
- wdata[i].len=i+1;
- for(t1=wdata[i].p,j=0; j<(i+1); j++, t1++) {
- t1->p=malloc((j+1)*sizeof(unsigned int));
- if(t1->p==NULL) {
+ wdata[i].len = i + 1;
+ for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) {
+ t1->p = HDmalloc((j + 1) * sizeof(unsigned int));
+ if(NULL == t1->p) {
H5_FAILED();
printf(" Cannot allocate memory for VL data! i=%u, j=%u\n",(unsigned)i,(unsigned)j);
goto error;
} /* end if */
- t1->len=j+1;
- for(k=0; k<(j+1); k++) {
- ((unsigned int *)t1->p)[k]=(unsigned int)(i*100+j*10+k);
- }
+ t1->len = j + 1;
+ for(k = 0; k < (j + 1); k++)
+ ((unsigned int *)t1->p)[k] = (unsigned int)(i * 100 + j * 10 + k);
} /* end for */
} /* end for */
@@ -1575,7 +1721,7 @@ test_vl_dtype(hid_t file)
printf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
goto error;
} /* end if */
- for(t1 = wdata[i].p, t2 = rdata[i].p, j = 0; j<rdata[i].len; j++, t1++, t2++) {
+ for(t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j < rdata[i].len; j++, t1++, t2++) {
if(t1->len != t2->len) {
H5_FAILED();
printf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
@@ -1584,36 +1730,38 @@ test_vl_dtype(hid_t file)
/* use temporary buffer to convert datatype. This is for special
* platforms like Cray */
- tmp=malloc(t2->len*sizeof(unsigned int));
- memcpy(tmp, t2->p, t2->len*H5Tget_size(nat_super_type));
+ if(NULL == (tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int))))
+ TEST_ERROR
+ HDmemcpy(tmp, t2->p, t2->len * H5Tget_size(nat_super_type));
- if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT))
+ if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
- for(k=0; k<t2->len; k++) {
- if( ((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k] ) {
+ for(k = 0; k < t2->len; k++) {
+ if(((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k]) {
H5_FAILED();
printf(" VL data don't match!, wdata[%u].p=%d, rdata[%u].p=%u\n",
- (unsigned)i,((unsigned int*)t1->p)[k],(unsigned)i,((unsigned int*)tmp)[k]);
+ (unsigned)i, ((unsigned int*)t1->p)[k], (unsigned)i, ((unsigned int*)tmp)[k]);
goto error;
- }
+ } /* end if */
} /* end for */
- free(tmp);
+ HDfree(tmp);
} /* end for */
} /* end for */
/* Reclaim the read VL data */
- if(H5Dvlen_reclaim(native_type,space,H5P_DEFAULT,rdata) < 0) TEST_ERROR;
+ if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
/* Reclaim the write VL data */
- if(H5Dvlen_reclaim(native_type,space,H5P_DEFAULT,wdata) < 0) TEST_ERROR;
+ if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata) < 0) TEST_ERROR;
/* Close Dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
/* Close datatype */
if(H5Tclose(native_type) < 0) TEST_ERROR;
+ native_type = -1; /* reset so that error handling can check for VL reclaim */
if(H5Tclose(dtype) < 0) TEST_ERROR;
if(H5Tclose(tid_m) < 0) TEST_ERROR;
if(H5Tclose(tid_m2) < 0) TEST_ERROR;
@@ -1625,7 +1773,27 @@ test_vl_dtype(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ if(native_type > 0) {
+ H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata);
+ H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata);
+ } /* end if */
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(nat_super_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ } H5E_END_TRY;
+
return -1;
} /* end test_vl_type() */
@@ -1650,17 +1818,18 @@ static herr_t
test_vlstr_dtype(hid_t file)
{
const char *wdata[SPACE1_DIM1]= {
- "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
- "conceived in liberty and dedicated to the proposition that all men are created equal.",
- "Now we are engaged in a great civil war,",
- "testing whether that nation or any nation so conceived and so dedicated can long endure."
- }; /* Information to write */
- char *rdata[SPACE1_DIM1]; /* Information read in */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1,dtype,native_type; /* Datatype ID */
- hsize_t dims1[] = {SPACE1_DIM1};
- unsigned i; /* counting variable */
+ "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
+ "conceived in liberty and dedicated to the proposition that all men are created equal.",
+ "Now we are engaged in a great civil war,",
+ "testing whether that nation or any nation so conceived and so dedicated can long endure."
+ }; /* Information to write */
+ char *rdata[SPACE1_DIM1]; /* Information read in */
+ hbool_t rdata_alloc = FALSE; /* Whether the read data is allocated */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ unsigned i; /* counting variable */
/* Output message about test being performed */
TESTING("variable length string datatype");
@@ -1700,19 +1869,20 @@ test_vlstr_dtype(hid_t file)
/* Read dataset from disk */
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
+ rdata_alloc = TRUE;
/* Compare data read in */
for(i = 0; i < SPACE1_DIM1; i++) {
if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
H5_FAILED();
printf(" VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i]));
goto error;
} /* end if */
if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
H5_FAILED();
printf(" VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
- (int)i,wdata[i],(int)i,rdata[i]);
+ (int)i, wdata[i], (int)i, rdata[i]);
goto error;
} /* end if */
} /* end for */
@@ -1728,14 +1898,28 @@ test_vlstr_dtype(hid_t file)
if(H5Sclose(sid1) < 0) TEST_ERROR;
/* Free memory for rdata */
- for(i=0; i<SPACE1_DIM1; i++) {
+ for(i = 0; i < SPACE1_DIM1; i++)
HDfree(rdata[i]);
- }
+ rdata_alloc = FALSE;
PASSED();
return 0;
error:
+ if(rdata_alloc) {
+ /* Free memory for rdata */
+ for(i = 0; i < SPACE1_DIM1; i++)
+ HDfree(rdata[i]);
+ } /* end if */
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(sid1);
+ H5Tclose(tid1);
+ } H5E_END_TRY;
+
return -1;
} /* end test_vlstr_dtype() */
@@ -1759,18 +1943,18 @@ error:
static herr_t
test_str_dtype(hid_t file)
{
- const char wdata[SPACE1_DIM1][4]= {
- "one",
- "two",
- "3rd",
- "4th"
- }; /* Information to write */
- char rdata[SPACE1_DIM1][4]; /* Information read in */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1,dtype,native_type; /* Datatype ID */
- hsize_t dims1[] = {SPACE1_DIM1};
- unsigned i; /* counting variable */
+ const char wdata[SPACE1_DIM1][4]= {
+ "one",
+ "two",
+ "3rd",
+ "4th"
+ }; /* Information to write */
+ char rdata[SPACE1_DIM1][4]; /* Information read in */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ unsigned i; /* counting variable */
/* Output message about test being performed */
TESTING("fixed-length string datatype");
@@ -1815,13 +1999,13 @@ test_str_dtype(hid_t file)
if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
H5_FAILED();
printf(" data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i]));
goto error;
} /* end if */
if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
H5_FAILED();
printf(" data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
- (int)i,wdata[i],(int)i,rdata[i]);
+ (int)i, wdata[i], (int)i, rdata[i]);
goto error;
} /* end if */
} /* end for */
@@ -1840,11 +2024,17 @@ test_str_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid1);
+ H5Tclose(sid1);
+ } H5E_END_TRY;
+
return -1;
} /* end test_str_dtype() */
-
-
/*-------------------------------------------------------------------------
* Function: test_refer_dtype
@@ -1865,7 +2055,6 @@ error:
static herr_t
test_refer_dtype(hid_t file)
{
-
/* Compound datatype */
typedef struct s1_t {
unsigned int a;
@@ -1873,140 +2062,147 @@ test_refer_dtype(hid_t file)
float c;
} s1_t;
- hid_t dataset; /* Dataset ID */
- hid_t group; /* Group ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1, dtype, native_type; /* Datatype ID */
- hsize_t dims1[] = {1};
- hobj_ref_t *wbuf, /* buffer to write to disk */
- *rbuf; /* buffer read from disk */
- const char *envval = NULL;
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t group = -1; /* Group ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {1};
+ H5O_type_t obj_type; /* Object type */
+ hobj_ref_t *wbuf = NULL, /* buffer to write to disk */
+ *rbuf = NULL; /* buffer read from disk */
/* Output message about test being performed */
TESTING("reference datatype");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "multi")) {
- H5O_type_t obj_type; /* Object type */
- /* Allocate write & read buffers */
- wbuf=HDmalloc(MAX(sizeof(unsigned),sizeof(hobj_ref_t)));
- rbuf=HDmalloc(MAX(sizeof(unsigned),sizeof(hobj_ref_t)));
+ /* Allocate write & read buffers */
+ if(NULL == (wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)))))
+ TEST_ERROR
+ if(NULL == (rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)))))
+ TEST_ERROR
+
+ /* Create dataspace for datasets */
+ if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
+ TEST_ERROR;
+
+ /* Create a group */
+ if((group = H5Gcreate2(file, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Create a datatype to refer to */
+ if((tid1 = H5Tcreate (H5T_COMPOUND, sizeof(s1_t))) < 0)
+ TEST_ERROR;
+
+ /* Insert fields */
+ if(H5Tinsert (tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT) < 0)
+ TEST_ERROR;
+
+ if(H5Tinsert (tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0)
+ TEST_ERROR;
+
+ if(H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0)
+ TEST_ERROR;
+
+ /* Save datatype for later */
+ if(H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* Close datatype */
+ if(H5Tclose(tid1) < 0)
+ TEST_ERROR;
- /* Create dataspace for datasets */
- if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
- TEST_ERROR;
+ /* Close group */
+ if(H5Gclose(group) < 0)
+ TEST_ERROR;
+
+ /* Create a dataset */
+ if((dataset = H5Dcreate2(file, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create reference to named datatype */
+ if(H5Rcreate(wbuf, file, "/Group1/Datatype1", H5R_OBJECT, -1) < 0)
+ TEST_ERROR;
+ if(H5Rget_obj_type2(dataset, H5R_OBJECT, wbuf, &obj_type) < 0)
+ TEST_ERROR;
+ if(obj_type != H5O_TYPE_NAMED_DATATYPE)
+ TEST_ERROR;
+
+ /* Write selection to disk */
+ if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
+ TEST_ERROR;
+
+ /* Close disk dataspace */
+ if(H5Sclose(sid1) < 0)
+ TEST_ERROR;
+
+ /* Close Dataset */
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR;
+
+ /* Open the dataset */
+ if((dataset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Get datatype for dataset */
+ if((dtype = H5Dget_type(dataset)) < 0)
+ TEST_ERROR;
+
+ /* Construct native type */
+ if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Check if the data type is equal */
+ if(!H5Tequal(native_type, H5T_STD_REF_OBJ))
+ TEST_ERROR;
+
+ /* Read selection from disk */
+ if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ TEST_ERROR;
+
+ /* Open datatype object */
+ if((tid1 = H5Rdereference(dataset, H5R_OBJECT, rbuf)) < 0)
+ TEST_ERROR;
+
+ /* Verify correct datatype */
+ if(H5Tget_class(tid1) != H5T_COMPOUND)
+ TEST_ERROR;
+
+ if(H5Tget_nmembers(tid1)!=3)
+ TEST_ERROR;
+
+ /* Close datatype */
+ if(H5Tclose(tid1) < 0)
+ TEST_ERROR;
+
+ if(H5Tclose(native_type) < 0)
+ TEST_ERROR;
+
+ /* Close Dataset */
+ if(H5Dclose(dataset) < 0)
+ TEST_ERROR;
+
+ /* Free memory buffers */
+ HDfree(wbuf);
+ HDfree(rbuf);
+
+ PASSED();
- /* Create a group */
- if((group = H5Gcreate2(file, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Create a datatype to refer to */
- if((tid1 = H5Tcreate (H5T_COMPOUND, sizeof(s1_t))) < 0)
- TEST_ERROR;
-
- /* Insert fields */
- if(H5Tinsert (tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT) < 0)
- TEST_ERROR;
-
- if(H5Tinsert (tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0)
- TEST_ERROR;
-
- if(H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0)
- TEST_ERROR;
-
- /* Save datatype for later */
- if(H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
- TEST_ERROR;
-
- /* Close datatype */
- if(H5Tclose(tid1) < 0)
- TEST_ERROR;
-
- /* Close group */
- if(H5Gclose(group) < 0)
- TEST_ERROR;
-
- /* Create a dataset */
- if((dataset = H5Dcreate2(file, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
-
- /* Create reference to named datatype */
- if(H5Rcreate(wbuf, file, "/Group1/Datatype1", H5R_OBJECT, -1) < 0)
- TEST_ERROR;
- if(H5Rget_obj_type2(dataset, H5R_OBJECT, wbuf, &obj_type) < 0)
- TEST_ERROR;
- if(obj_type != H5O_TYPE_NAMED_DATATYPE)
- TEST_ERROR;
-
- /* Write selection to disk */
- if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
- TEST_ERROR;
-
- /* Close disk dataspace */
- if(H5Sclose(sid1) < 0)
- TEST_ERROR;
-
- /* Close Dataset */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR;
-
-
- /* Open the dataset */
- if((dataset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
- TEST_ERROR;
-
- /* Get datatype for dataset */
- if((dtype = H5Dget_type(dataset)) < 0)
- TEST_ERROR;
-
- /* Construct native type */
- if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- TEST_ERROR;
-
- /* Check if the data type is equal */
- if(!H5Tequal(native_type, H5T_STD_REF_OBJ))
- TEST_ERROR;
-
- /* Read selection from disk */
- if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
- TEST_ERROR;
-
- /* Open datatype object */
- if((tid1 = H5Rdereference(dataset, H5R_OBJECT, rbuf)) < 0)
- TEST_ERROR;
-
- /* Verify correct datatype */
- if(H5Tget_class(tid1) != H5T_COMPOUND)
- TEST_ERROR;
-
- if(H5Tget_nmembers(tid1)!=3)
- TEST_ERROR;
-
- /* Close datatype */
- if(H5Tclose(tid1) < 0)
- TEST_ERROR;
-
- /* Close Dataset */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR;
-
- /* Free memory buffers */
- free(wbuf);
- free(rbuf);
-
- PASSED();
- }
- else
- {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- }
return 0;
- error:
- return -1;
+error:
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(sid1);
+ H5Gclose(group);
+ H5Tclose(tid1);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+ return -1;
} /* test_refer_dtype() */
@@ -2029,42 +2225,44 @@ test_refer_dtype(hid_t file)
static herr_t
test_refer_dtype2(hid_t file)
{
- hid_t dset1, /* Dataset ID */
- dset2; /* Dereferenced dataset ID */
- hid_t sid1, /* Dataspace ID #1 */
- sid2; /* Dataspace ID #2 */
- hid_t dtype, native_type;
- hsize_t dims1[] = {1},
- dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
- hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
- hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
- hdset_reg_ref_t wbuf, /* buffer to write to disk */
- rbuf; /* buffer read from disk */
- uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
- *drbuf; /* Buffer for reading numeric data from disk */
- uint8_t *tu8; /* Temporary pointer to uint8 data */
- H5O_type_t obj_type; /* Object type */
- int i; /* counting variables */
+ hid_t dset1 = -1, /* Dataset ID */
+ dset2 = -1; /* Dereferenced dataset ID */
+ hid_t sid1 = -1, /* Dataspace ID #1 */
+ sid2 = -1; /* Dataspace ID #2 */
+ hid_t dtype = -1, native_type = -1;
+ hsize_t dims1[] = { 1 }, dims2[] = { SPACE2_DIM1, SPACE2_DIM2 };
+ hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
+ hdset_reg_ref_t wbuf, /* buffer to write to disk */
+ rbuf; /* buffer read from disk */
+ uint8_t *dwbuf = NULL, /* Buffer for writing numeric data to disk */
+ *drbuf = NULL; /* Buffer for reading numeric data from disk */
+ uint8_t *tu8 = NULL; /* Temporary pointer to uint8 data */
+ H5O_type_t obj_type; /* Object type */
+ int i; /* counting variables */
/* Output message about test being performed */
TESTING("dataset region reference");
/* Allocate write & read buffers */
- dwbuf = malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
- drbuf = calloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2);
+ if(NULL == (dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2)))
+ TEST_ERROR
+ if(NULL == (drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2)))
+ TEST_ERROR
/* Create dataspace for datasets */
if((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0)
TEST_ERROR;
/* Create a dataset */
- if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
- *tu8++=i*3;
+ *tu8++ = (uint8_t)(i * 3);
/* Write selection to disk */
if(H5Dwrite(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0)
@@ -2074,21 +2272,25 @@ test_refer_dtype2(hid_t file)
if(H5Dclose(dset2) < 0)
TEST_ERROR;
-
/* Create dataspace for the reference dataset */
if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
TEST_ERROR;
/* Create a reference dataset */
- if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Create references */
/* Select 6x6 hyperslab for first reference */
- start[0] = 2; start[1] = 2;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = 6; block[1] = 6;
+ start[0] = 2;
+ start[1] = 2;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = 6;
+ block[1] = 6;
if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR;
@@ -2120,9 +2322,6 @@ test_refer_dtype2(hid_t file)
if(H5Sclose(sid2) < 0)
TEST_ERROR;
-
-
-
/* Open the dataset */
if((dset1 = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -2195,13 +2394,28 @@ test_refer_dtype2(hid_t file)
TEST_ERROR;
/* Free memory buffers */
- free(dwbuf);
- free(drbuf);
+ HDfree(dwbuf);
+ HDfree(drbuf);
PASSED();
return 0;
-error:
+error:
+ /* Free memory buffers */
+ if(dwbuf)
+ HDfree(dwbuf);
+ if(drbuf)
+ HDfree(drbuf);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(sid2);
+ H5Sclose(sid1);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset2);
+ H5Dclose(dset1);
+ } H5E_END_TRY;
+
return -1;
} /* test_refer_dtype2() */
@@ -2225,21 +2439,21 @@ error:
static herr_t
test_opaque_dtype(hid_t file)
{
- hid_t type=-1, space=-1, dset=-1;
- hid_t dataset, dtype, native_type;
- size_t i;
- unsigned char wbuf[32], rbuf[32];
- hsize_t nelmts;
+ hid_t type = -1, space = -1, dset = -1;
+ hid_t dataset = -1, dtype = -1, native_type = -1;
+ size_t i;
+ unsigned char wbuf[32], rbuf[32];
+ hsize_t nelmts;
TESTING("opaque datatype");
/* opaque_1 */
nelmts = sizeof(wbuf);
- if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0 ||
- H5Tset_tag(type, "testing 1-byte opaque type") < 0 ||
- (space = H5Screate_simple(1, &nelmts, NULL)) < 0 ||
- (dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0) TEST_ERROR;
+ if(H5Tset_tag(type, "testing 1-byte opaque type") < 0) TEST_ERROR;
+ if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR;
+ if((dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
for(i = 0; i < sizeof(wbuf); i++)
wbuf[i] = (unsigned char)0xff ^ (unsigned char)i;
@@ -2263,11 +2477,11 @@ test_opaque_dtype(hid_t file)
TEST_ERROR;
for(i = 0; i < sizeof(rbuf); i++)
- if(rbuf[i] != wbuf[i]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
+ if(rbuf[i] != wbuf[i]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
printf(" At index %u\n", (unsigned)i);
- goto error;
+ goto error;
} /* end if */
if(H5Tclose(type) < 0) TEST_ERROR;
@@ -2279,6 +2493,15 @@ test_opaque_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_opaque_dtype */
@@ -2302,20 +2525,20 @@ error:
static herr_t
test_bitfield_dtype(hid_t file)
{
- hid_t type=-1, space=-1, dset=-1;
- hid_t dataset, dtype, native_type;
- size_t i;
- unsigned char wbuf[32];
- hsize_t nelmts;
+ hid_t type = -1, space = -1, dset = -1;
+ hid_t dataset = -1, dtype = -1, native_type = -1;
+ size_t i;
+ unsigned char wbuf[32];
+ hsize_t nelmts;
TESTING("bitfield datatype");
/* opaque_1 */
nelmts = sizeof(wbuf);
- if((type = H5Tcopy(H5T_STD_B8LE)) < 0 ||
- (space = H5Screate_simple(1, &nelmts, NULL)) < 0 ||
- (dset = H5Dcreate2(file, DSET_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if((type = H5Tcopy(H5T_STD_B8LE)) < 0) TEST_ERROR;
+ if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR;
+ if((dset = H5Dcreate2(file, DSET_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
for(i = 0; i < sizeof(wbuf); i++)
wbuf[i] = (unsigned char)0xff ^ (unsigned char)i;
@@ -2347,6 +2570,15 @@ test_bitfield_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_bitfield_dtype */
@@ -2370,176 +2602,166 @@ error:
static herr_t
test_ninteger(void)
{
- hid_t fid1=(-1); /* file ID */
- hid_t fid2=(-1); /* file ID */
- hid_t did1=(-1); /* dataset ID */
- hid_t did2=(-1); /* dataset ID */
- hid_t sid1=(-1); /* dataspace ID */
- hid_t dcpl1=(-1); /* dataset creation property list ID */
- hid_t dcpl2=(-1); /* dataset creation property list ID */
- hid_t tid1=(-1); /* file datatype */
- hid_t tid2=(-1); /* file datatype */
- hid_t nid1=(-1); /* native datatype */
- hid_t nid2=(-1); /* native datatype */
- hsize_t dims[1]={DIM3}; /* dataspace dimensions */
+ hid_t fid1 = -1; /* file ID */
+ hid_t fid2 = -1; /* file ID */
+ hid_t did1 = -1; /* dataset ID */
+ hid_t did2 = -1; /* dataset ID */
+ hid_t sid1 = -1; /* dataspace ID */
+ hid_t dcpl1 = -1; /* dataset creation property list ID */
+ hid_t dcpl2 = -1; /* dataset creation property list ID */
+ hid_t tid1 = -1; /* file datatype */
+ hid_t tid2 = -1; /* file datatype */
+ hid_t nid1 = -1; /* native datatype */
+ hid_t nid2 = -1; /* native datatype */
+ hsize_t dims[1] = {DIM3}; /* dataspace dimensions */
hsize_t nelmts; /* number of elements in dataset */
- int rank=1; /* rank of dataset */
+ int rank = 1; /* rank of dataset */
int buf[DIM3];
int chk[DIM3];
int i;
- for (i=0; i<DIM3; i++){
- buf[i]=i;
- }
-
TESTING("native integer ");
- /*-------------------------------------------------------------------------
- * step1: create a file
- *-------------------------------------------------------------------------
- */
+ for(i = 0; i < DIM3; i++)
+ buf[i] = i;
+
+ /*-------------------------------------------------------------------------
+ * step1: create a file
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid1=H5Fcreate("tstint1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto error;
+ if((fid1 = H5Fcreate("tstint1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* create a data space */
- if((sid1 = H5Screate_simple(rank,dims,NULL)) < 0) goto error;
+ if((sid1 = H5Screate_simple(rank, dims, NULL)) < 0) FAIL_STACK_ERROR
/* create dcpl */
- if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
/* create a dataset */
- if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) goto error;
+ if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* write */
- if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- goto error;
+ if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR
/* close */
- if(H5Sclose(sid1) < 0) goto error;
- if(H5Pclose(dcpl1) < 0) goto error;
- if(H5Dclose(did1) < 0) goto error;
- if(H5Fclose(fid1) < 0) goto error;
+ if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
- /*-------------------------------------------------------------------------
- * step 2: open and create another file copying the data from file1
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * step 2: open and create another file copying the data from file1
+ *-------------------------------------------------------------------------
+ */
- /* open */
- if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error;
+ /* open */
+ if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* open dataset */
- if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) goto error;
+ if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((sid1 = H5Dget_space(did1)) < 0) goto error;
+ if((sid1 = H5Dget_space(did1)) < 0) FAIL_STACK_ERROR
/* get dcpl */
- if((dcpl1 = H5Dget_create_plist(did1)) < 0) goto error;
+ if((dcpl1 = H5Dget_create_plist(did1)) < 0) FAIL_STACK_ERROR
/* get file datatype */
- if((tid1 = H5Dget_type(did1)) < 0) goto error;
+ if((tid1 = H5Dget_type(did1)) < 0) FAIL_STACK_ERROR
/* get native datatype */
- if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) goto error;
+ if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR
/* get size */
- if(H5Tget_size(nid1) == 0) goto error;
+ if(H5Tget_size(nid1) == 0) FAIL_STACK_ERROR
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) goto error;
+ if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) FAIL_STACK_ERROR
HDmemset(dims, 0, sizeof dims);
/* get dimension */
- if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) goto error;
+ if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) FAIL_STACK_ERROR
nelmts = 1;
for(i = 0; i < rank; i++)
- nelmts *= dims[i];
+ nelmts *= dims[i];
/* read */
- if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0)
- goto error;
+ if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR
/* create a file using default properties */
- if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* create a dataset using the native type */
- if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) goto error;
+ if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* write */
- if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0)
- goto error;
+ if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR
/* get dcpl */
- if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- goto error;
+ if((dcpl2 = H5Dget_create_plist(did2)) < 0) FAIL_STACK_ERROR
/* get file datatype */
- if((tid2 = H5Dget_type(did2)) < 0)
- goto error;
+ if((tid2 = H5Dget_type(did2)) < 0) FAIL_STACK_ERROR
/* get native datatype */
- if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR
/* check */
if(H5Tget_precision(nid1) != H5Tget_precision(nid2)) {
- printf(" Precision differ.\n");
- goto error;
- }
+ printf(" Precision differ.\n");
+ TEST_ERROR
+ } /* end if */
/* compare dataset creation property lists */
if(H5Pequal(dcpl1, dcpl2) <= 0) {
- printf(" Property lists differ.\n");
- goto error;
- }
+ printf(" Property lists differ.\n");
+ TEST_ERROR
+ } /* end if */
/* check */
- for (i = 0; i < DIM3; i++) {
- if(buf[i] != chk[i]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d\n", i);
- goto error;
- }
- }
+ for(i = 0; i < DIM3; i++)
+ if(buf[i] != chk[i]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d\n", i);
+ TEST_ERROR
+ } /* end if */
/* close */
- if(H5Sclose (sid1) < 0) goto error;
- if(H5Pclose (dcpl1) < 0) goto error;
- if(H5Pclose (dcpl2) < 0) goto error;
- if(H5Tclose (tid1) < 0) goto error;
- if(H5Tclose (tid2) < 0) goto error;
- if(H5Tclose (nid1) < 0) goto error;
- if(H5Tclose (nid2) < 0) goto error;
- if(H5Dclose (did1) < 0) goto error;
- if(H5Dclose (did2) < 0) goto error;
- if(H5Fclose (fid1) < 0) goto error;
- if(H5Fclose (fid2) < 0) goto error;
-
+ if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid2) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(nid1) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(nid2) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Pclose(dcpl1);
- H5Pclose(dcpl2);
- H5Tclose(tid1);
- H5Tclose(tid2);
- H5Tclose(nid1);
- H5Tclose(nid2);
- H5Dclose(did1);
- H5Dclose(did2);
- H5Sclose(sid1);
- H5Fclose(fid1);
- H5Fclose(fid2);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
+ H5Tclose(tid1);
+ H5Tclose(tid2);
+ H5Tclose(nid1);
+ H5Tclose(nid2);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Sclose(sid1);
+ H5Fclose(fid1);
+ H5Fclose(fid2);
} H5E_END_TRY;
+
return -1;
} /* end test_ninteger() */
-
/*-------------------------------------------------------------------------
* Function: main
@@ -2556,43 +2778,54 @@ error:
int
main(void)
{
- hid_t file, fapl;
- int nerrors=0;
- char filename[1024];
+ hid_t file, fapl;
+ int nerrors = 0;
+ char filename[1024];
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- goto error;
-
- nerrors += test_atomic_dtype(file) < 0 ?1:0;
- nerrors += test_compound_dtype(file) < 0 ?1:0;
- nerrors += test_compound_dtype2(file) < 0 ?1:0;
- nerrors += test_compound_dtype3(file) < 0 ?1:0;
- nerrors += test_compound_opaque(file) < 0 ?1:0;
- nerrors += test_enum_dtype(file) < 0 ?1:0;
- nerrors += test_array_dtype(file) < 0 ?1:0;
- nerrors += test_array_dtype2(file) < 0 ?1:0;
- nerrors += test_vl_dtype(file) < 0 ?1:0;
- nerrors += test_vlstr_dtype(file) < 0 ?1:0;
- nerrors += test_str_dtype(file) < 0 ?1:0;
- nerrors += test_refer_dtype(file) < 0 ?1:0;
- nerrors += test_refer_dtype2(file) < 0 ?1:0;
- nerrors += test_opaque_dtype(file) < 0 ?1:0;
- nerrors += test_bitfield_dtype(file) < 0 ?1:0;
- nerrors += test_ninteger() < 0 ?1:0;
-
- if(H5Fclose(file) < 0) goto error;
- if(nerrors) goto error;
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ nerrors += test_atomic_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype3(file) < 0 ? 1 : 0;
+ nerrors += test_compound_opaque(file) < 0 ? 1 : 0;
+ nerrors += test_enum_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_array_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_array_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_vl_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_str_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_refer_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_refer_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_opaque_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_ninteger() < 0 ? 1 : 0;
+
+ if(H5Fclose(file) < 0)
+ goto error;
+ if(nerrors)
+ goto error;
+
printf("All native datatype tests passed.\n");
h5_cleanup(FILENAME, fapl);
+
return 0;
- error:
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ h5_cleanup(FILENAME, fapl);
+ } H5E_END_TRY;
+
nerrors = MAX(1, nerrors);
printf("***** %d DATASET TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
+ nerrors, 1 == nerrors ? "" : "S");
+
return 1;
}
+
diff --git a/test/objcopy.c b/test/objcopy.c
index 6459519..00cc5bf 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -55,7 +55,8 @@ const char *FILENAME[] = {
#define CONFIG_SHARE_SRC 1
#define CONFIG_SHARE_DST 2
#define CONFIG_NEW_FORMAT 4
-#define MAX_CONFIGURATION 7
+#define CONFIG_DENSE 8
+#define MAX_CONFIGURATION 15
#define FILE_EXT "objcopy_ext.dat"
/* The fill_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory
@@ -69,8 +70,10 @@ const char *FILENAME[] = {
#define NAME_DATATYPE_VL "vlen of int"
#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_COMPOUND "dataset_compound"
#define NAME_DATASET_CHUNKED "dataset_chunked"
+#define NAME_DATASET_CHUNKED2 "dataset_chunked2"
#define NAME_DATASET_COMPACT "dataset_compact"
#define NAME_DATASET_EXTERNAL "dataset_ext"
#define NAME_DATASET_NAMED_DTYPE "dataset_named_dtype"
@@ -79,6 +82,7 @@ const char *FILENAME[] = {
#define NAME_DATASET_MULTI_OHDR2 "dataset_multi_ohdr2"
#define NAME_DATASET_VL "dataset_vl"
#define NAME_DATASET_VL_VL "dataset_vl_vl"
+#define NAME_DATASET_CMPD_VL "dataset_cmpd_vl"
#define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple"
#define NAME_GROUP_UNCOPIED "/uncopied"
#define NAME_GROUP_EMPTY "/empty"
@@ -104,7 +108,6 @@ const char *FILENAME[] = {
#define NAME_OLD_FORMAT "/dset1"
#define NAME_BUF_SIZE 1024
-#define NUM_ATTRIBUTES 4
#define ATTR_NAME_LEN 80
#define DIM_SIZE_1 12
#define DIM_SIZE_2 6
@@ -116,6 +119,8 @@ const char *FILENAME[] = {
char src_obj_full_name[215]; /* the full path + name of the object to be copied */
+unsigned num_attributes_g; /* Number of attributes created */
+
/* Table containing object id and object name */
/* (Used for detecting duplicate objects when comparing groups */
static struct {
@@ -126,7 +131,7 @@ static struct {
/* Local function prototypes */
static int
-compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
+compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
const void *buf1, const void *buf2, hid_t obj_owner);
static int
compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf);
@@ -159,7 +164,7 @@ addr_insert(H5O_info_t *oi)
/* Extend the table */
if(idtab_g.nobjs >= idtab_g.nalloc) {
idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc);
- idtab_g.obj = HDrealloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0]));
+ idtab_g.obj = (haddr_t *)HDrealloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0]));
} /* end if */
/* Insert the entry */
@@ -220,14 +225,14 @@ addr_reset(void)
/*-------------------------------------------------------------------------
- * Function: attach_ref_attr
+ * Function: attach_ref_attr
*
* Purpose: Create an attribute with object references
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Peter Cao
- * Friday, August 4, 2006
+ * Friday, August 4, 2006
*
* Modifications:
*
@@ -281,7 +286,7 @@ error:
/*-------------------------------------------------------------------------
- * Function: attach_reg_ref_attr
+ * Function: attach_reg_ref_attr
*
* Purpose: Create an attribute with object references
*
@@ -325,7 +330,7 @@ attach_reg_ref_attr(hid_t file_id, hid_t loc_id)
/* create reg_ref of point selection */
if(H5Sselect_none(space_id) < 0) TEST_ERROR
- if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, coord) < 0) TEST_ERROR
+ if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) TEST_ERROR
if(H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR
/* create reg_ref attribute */
@@ -358,14 +363,14 @@ error:
/*-------------------------------------------------------------------------
- * Function: create_reg_ref_dataset
+ * Function: create_reg_ref_dataset
*
* Purpose: Create a dataset with region references
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Peter Cao
- * Friday, August 4, 2006
+ * Friday, August 4, 2006
*
* Modifications:
*
@@ -408,7 +413,7 @@ create_reg_ref_dataset(hid_t file_id, hid_t loc_id)
if(H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL) < 0) TEST_ERROR
if(H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR
if(H5Sselect_none(space_id) < 0) TEST_ERROR
- if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, coord) < 0) TEST_ERROR
+ if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) TEST_ERROR
if(H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR
if(H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref) < 0) TEST_ERROR
if(H5Dclose(dsetr_id) < 0) TEST_ERROR
@@ -485,7 +490,7 @@ test_copy_attach_attribute_vl(hid_t loc_id)
buf[i].len = i*3+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = j+1;
+ ((int *)buf[i].p)[j] = (int)(j + 1);
} /* end for */
if((aid = H5Acreate2(loc_id, "vlen attribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -528,19 +533,20 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id)
{
hid_t aid = -1, sid = -1;
char attr_name[ATTR_NAME_LEN];
- int attr_data[2], i = 0;
+ int attr_data[2];
hsize_t dim1 = 2;
+ unsigned u;
int ret_value = -1;
if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 )
goto done;
- for (i=0; i<NUM_ATTRIBUTES; i++) {
- sprintf(attr_name, "%d attr", i);
+ for(u = 0; u < num_attributes_g; u++) {
+ sprintf(attr_name, "%u attr", u);
/* Set attribute data */
- attr_data[0] = 100 * i;
- attr_data[1] = 200 * i;
+ 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)
goto done;
@@ -583,17 +589,18 @@ 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], i;
+ int attr_data[2];
+ unsigned u;
hsize_t dim1 = 2;
if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) goto done;
- for (i=0; i<NUM_ATTRIBUTES; i++) {
- sprintf(attr_name, "%d attr", i);
+ for(u = 0; u < num_attributes_g; u++) {
+ sprintf(attr_name, "%u attr", u);
/* Set attribute data */
- attr_data[0] = 100 * i;
- attr_data[1] = 200 * i;
+ attr_data[0] = (int)(100 * u);
+ attr_data[1] = (int)(200 * u);
/* Add attribute to first object */
if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto done;
@@ -706,7 +713,9 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
/* Release raw data buffers */
HDfree(rbuf);
+ rbuf = NULL;
HDfree(rbuf2);
+ rbuf2 = NULL;
/* close the source dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
@@ -723,11 +732,11 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
return TRUE;
error:
+ if(rbuf)
+ HDfree(rbuf);
+ if(rbuf2)
+ HDfree(rbuf2);
H5E_BEGIN_TRY {
- if(rbuf)
- HDfree(rbuf);
- if(rbuf2)
- HDfree(rbuf2);
H5Sclose(sid2);
H5Sclose(sid);
H5Tclose(tid2);
@@ -785,7 +794,7 @@ compare_std_attributes(hid_t oid, hid_t oid2, hid_t pid)
unsigned i; /* Local index variable */
/* Compare the number of attributes */
- if(oinfo1.num_attrs != oinfo1.num_attrs) TEST_ERROR
+ if(oinfo1.num_attrs != oinfo2.num_attrs) TEST_ERROR
/* Check the attributes are equal */
for(i = 0; i < (unsigned)oinfo1.num_attrs; i++) {
@@ -828,7 +837,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
+compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
const void *buf1, const void *buf2, hid_t obj_owner)
{
size_t elmt_size; /* Size of an element */
@@ -836,8 +845,82 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
/* Check size of each element */
if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR
- /* Check for vlen datatype */
- if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
+ /* If the type is a compound containing a vlen, loop over all elements for
+ * each compound member. Compounds containing reference are not supported
+ * yet. */
+ if((H5Tget_class(tid) == H5T_COMPOUND)
+ && (H5Tdetect_class(tid, H5T_VLEN) == TRUE)) {
+ hid_t memb_id; /* Member id */
+ const uint8_t *memb1; /* Pointer to current member */
+ const uint8_t *memb2; /* Pointer to current member */
+ int nmembs; /* Number of members */
+ size_t memb_off; /* Member offset */
+ size_t memb_size; /* Member size */
+ unsigned memb_idx; /* Member index */
+ size_t elmt; /* Current element */
+
+ /* Get number of members in compound */
+ if((nmembs = H5Tget_nmembers(tid)) < 0) TEST_ERROR
+
+ /* Loop over members */
+ for(memb_idx=0; memb_idx<(unsigned)nmembs; memb_idx++) {
+ /* Get member offset. Note that we cannot check for an error here.
+ */
+ memb_off = H5Tget_member_offset(tid, memb_idx);
+
+ /* Get member id */
+ if((memb_id = H5Tget_member_type(tid, memb_idx)) < 0) TEST_ERROR
+
+ /* Get member size */
+ if((memb_size = H5Tget_size(memb_id)) == 0) TEST_ERROR
+
+ /* Set up pointers to member in the first element */
+ memb1 = (const uint8_t *)buf1 + memb_off;
+ memb2 = (const uint8_t *)buf2 + memb_off;
+
+ /* Check if this member contains (or is) a vlen */
+ if(H5Tget_class(memb_id) == H5T_VLEN) {
+ hid_t base_id; /* vlen base type id */
+
+ /* Get base type of vlen datatype */
+ if((base_id = H5Tget_super(memb_id)) < 0) TEST_ERROR
+
+ /* Iterate over all elements, recursively calling this function
+ * for each */
+ for(elmt=0; elmt<nelmts; elmt++) {
+ /* Check vlen lengths */
+ if(((const hvl_t *)memb1)->len
+ != ((const hvl_t *)memb2)->len)
+ TEST_ERROR
+
+ /* Check vlen data */
+ if(!compare_data(parent1, parent2, pid, base_id,
+ ((const hvl_t *)memb1)->len,
+ ((const hvl_t *)memb1)->p,
+ ((const hvl_t *)memb2)->p, obj_owner))
+ TEST_ERROR
+
+ /* Update member pointers */
+ memb1 += elmt_size;
+ memb2 += elmt_size;
+ } /* end for */
+ } else {
+ /* vlens cannot currently be nested below the top layer of a
+ * compound */
+ HDassert(H5Tdetect_class(memb_id, H5T_VLEN) == FALSE);
+
+ /* Iterate over all elements, calling memcmp() for each */
+ for(elmt=0; elmt<nelmts; elmt++) {
+ if(HDmemcmp(memb1, memb2, memb_size))
+ TEST_ERROR
+
+ /* Update member pointers */
+ memb1 += elmt_size;
+ memb2 += elmt_size;
+ } /* end for */
+ } /* end else */
+ } /* end for */
+ } else if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
const hvl_t *vl_buf1, *vl_buf2; /* Aliases for buffers to compare */
hid_t base_tid; /* Base type of vlen datatype */
size_t u; /* Local index variable */
@@ -849,8 +932,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
if((base_tid = H5Tget_super(tid)) < 0) TEST_ERROR
/* Loop over elements in buffers */
- vl_buf1 = buf1;
- vl_buf2 = buf2;
+ vl_buf1 = (const hvl_t *)buf1;
+ vl_buf2 = (const hvl_t *)buf2;
for(u = 0; u < nelmts; u++, vl_buf1++, vl_buf2++) {
/* Check vlen lengths */
if(vl_buf1->len != vl_buf2->len) TEST_ERROR
@@ -864,7 +947,7 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
else if(H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) {
size_t u; /* Local index variable */
- /* Check for "simple" vlen datatype */
+ /* Check for "simple" reference datatype */
if(H5Tget_class(tid) != H5T_REFERENCE) TEST_ERROR
/* Check for object or region reference */
@@ -872,8 +955,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
const hobj_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */
/* Loop over elements in buffers */
- ref_buf1 = buf1;
- ref_buf2 = buf2;
+ ref_buf1 = (const hobj_ref_t *)buf1;
+ ref_buf2 = (const hobj_ref_t *)buf2;
for(u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) {
hid_t obj1_id, obj2_id; /* IDs for objects referenced */
H5O_type_t obj1_type, obj2_type; /* Types of objects referenced */
@@ -928,8 +1011,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts,
const hdset_reg_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */
/* Loop over elements in buffers */
- ref_buf1 = buf1;
- ref_buf2 = buf2;
+ ref_buf1 = (const hdset_reg_ref_t *)buf1;
+ ref_buf2 = (const hdset_reg_ref_t *)buf2;
for(u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) {
hid_t obj1_id, obj2_id; /* IDs for objects referenced */
hid_t obj1_sid, obj2_sid; /* Dataspace IDs for objects referenced */
@@ -1340,7 +1423,7 @@ HDassert(0 && "Unknown type of object");
if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR
/* Compare link values */
- if(linfo.type == H5L_TYPE_SOFT ||
+ if(linfo.type == H5L_TYPE_SOFT ||
(linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) {
char linkval[NAME_BUF_SIZE]; /* Link value */
char linkval2[NAME_BUF_SIZE]; /* Link value */
@@ -1361,7 +1444,7 @@ HDassert(0 && "Unknown type of link");
} /* end if */
/* Check if the attributes are equal */
- if(compare_std_attributes(gid, gid2, pid) != TRUE) TEST_ERROR
+ if(compare_std_attributes(gid, gid2, pid) != TRUE) TEST_ERROR
/* Groups should be the same. :-) */
return TRUE;
@@ -1779,6 +1862,112 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_simple_samefile
+ *
+ * Purpose: Create a simple dataset in SRC file and copy it to SRC file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Thursday, January 15, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_simple_samefile(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ hsize_t dim2d[2]; /* Dataset dimensions */
+ int i, j; /* local index variables */
+ char filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): simple dataset within the same file");
+
+ /* 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 the filenames */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 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 at SRC file */
+ if((did = H5Dcreate2(fid, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* attach attributes to the dataset */
+ if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+
+ /* open the source file with read-write */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+
+ /* copy the dataset from SRC to DST */
+ if(H5Ocopy(fid, NAME_DATASET_SIMPLE, fid, NAME_DATASET_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid, 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 destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_simple_samefile */
+
+
+/*-------------------------------------------------------------------------
* Function: test_copy_dataset_simple_empty
*
* Purpose: Create a simple dataset in SRC file and copy it to DST file
@@ -2038,9 +2227,13 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
hid_t sid = -1; /* Dataspace ID */
hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hsize_t max_dim1d[1]; /* Dataset max. dimensions */
hsize_t dim2d[2]; /* Dataset dimensions */
+ hsize_t chunk_dim1d[1] ={CHUNK_SIZE_1}; /* Chunk dimensions */
hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */
- float buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ float buf1d[DIM_SIZE_1]; /* Buffer for writing data */
+ float buf2d[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
int i, j; /* Local index variables */
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
@@ -2048,9 +2241,11 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
TESTING("H5Ocopy(): chunked dataset");
/* set initial data values */
- for (i=0; i<DIM_SIZE_1; i++)
- for (j=0; j<DIM_SIZE_2; j++)
- buf[i][j] = (float)(i+j/100.0);
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf1d[i] = (float)(i / 2.0);
+ for(j = 0; j < DIM_SIZE_2; j++)
+ buf2d[i][j] = (float)(i + (j / 100.0));
+ } /* end for */
/* Initialize the filenames */
h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
@@ -2062,11 +2257,40 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* create source file */
if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR
- /* Set dataspace dimensions */
- dim2d[0]=DIM_SIZE_1;
- dim2d[1]=DIM_SIZE_2;
+ /* Set 1-D dataspace dimensions */
+ dim1d[0] = DIM_SIZE_1;
+ max_dim1d[0] = H5S_UNLIMITED;
- /* create dataspace */
+ /* create 1-D dataspace */
+ if((sid = H5Screate_simple(1, dim1d, max_dim1d)) < 0) TEST_ERROR
+
+ /* create and set chunk plist */
+ if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR
+
+ /* create dataset */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close chunk plist */
+ if(H5Pclose(pid) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1d) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* attach attributes to the dataset */
+ if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Set 2-D dataspace dimensions */
+ dim2d[0] = DIM_SIZE_1;
+ dim2d[1] = DIM_SIZE_2;
+
+ /* create 2-D dataspace */
if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR
/* create and set chunk plist */
@@ -2074,13 +2298,13 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
if(H5Pset_chunk(pid, 2, chunk_dim2d) < 0) TEST_ERROR
/* create dataset */
- if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
/* close chunk plist */
if(H5Pclose(pid) < 0) TEST_ERROR
/* write data into file */
- if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+ if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2d) < 0) TEST_ERROR
/* close dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
@@ -2104,17 +2328,33 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* 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 the dataset from SRC to DST */
+ /* copy the datasets from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
- /* open the destination dataset */
+ /* open the 1-D destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check if the datasets are equal */
- if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
+ if(compare_datasets(did, did2, H5P_DEFAULT, buf1d) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* open the 2-D dataset for copy */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, buf2d) != TRUE) TEST_ERROR
/* close the destination dataset */
if(H5Dclose(did2) < 0) TEST_ERROR
@@ -2165,7 +2405,10 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
hid_t sid = -1; /* Dataspace ID */
hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hsize_t max_dim1d[1]; /* Dataset max. dimensions */
hsize_t dim2d[2]; /* Dataset dimensions */
+ hsize_t chunk_dim1d[1] ={CHUNK_SIZE_1}; /* Chunk dimensions */
hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
@@ -2182,11 +2425,37 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* create source file */
if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR
- /* Set dataspace dimensions */
- dim2d[0]=DIM_SIZE_1;
- dim2d[1]=DIM_SIZE_2;
+ /* Set 1-D dataspace dimensions */
+ dim1d[0] = DIM_SIZE_1;
+ max_dim1d[0] = H5S_UNLIMITED;
- /* create dataspace */
+ /* create 1-D dataspace */
+ if((sid = H5Screate_simple(1, dim1d, max_dim1d)) < 0) TEST_ERROR
+
+ /* create and set chunk plist */
+ if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR
+
+ /* create dataset */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close chunk plist */
+ if(H5Pclose(pid) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* attach attributes to the dataset */
+ if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Set 2-D dataspace dimensions */
+ dim2d[0] = DIM_SIZE_1;
+ dim2d[1] = DIM_SIZE_2;
+
+ /* create 2-D dataspace */
if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR
/* create and set chunk plist */
@@ -2194,7 +2463,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
if(H5Pset_chunk(pid, 2, chunk_dim2d) < 0) TEST_ERROR
/* create dataset */
- if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
/* close chunk plist */
if(H5Pclose(pid) < 0) TEST_ERROR
@@ -2221,8 +2490,9 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* 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 the dataset from SRC to DST */
+ /* copy the datasets from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -2239,6 +2509,21 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* close the source dataset */
if(H5Dclose(did) < 0) TEST_ERROR
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
/* close the SRC file */
if(H5Fclose(fid_src) < 0) TEST_ERROR
@@ -2282,11 +2567,16 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
hid_t sid = -1; /* Dataspace ID */
hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hsize_t new_dim1d[1]; /* Dataset dimensions */
+ hsize_t max_dim1d[1]; /* Dataset max. dimensions */
hsize_t dim2d[2]; /* Dataset dimensions */
hsize_t new_dim2d[2]; /* Dataset dimensions */
hsize_t max_dim2d[2]; /* Dataset max. dimensions */
- hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */
- float buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */
+ hsize_t chunk_dim2d[2] = {CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */
+ float buf1d[DIM_SIZE_1]; /* Buffer for writing data */
+ float buf2d[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
int i, j; /* Local index variables */
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
@@ -2294,9 +2584,11 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
TESTING("H5Ocopy(): sparse dataset");
/* set initial data values */
- for (i=0; i<DIM_SIZE_1; i++)
- for (j=0; j<DIM_SIZE_2; j++)
- buf[i][j] = (float)(i+j/100.0);
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf1d[i] = (float)(i / 10.0);
+ for(j = 0; j < DIM_SIZE_2; j++)
+ buf2d[i][j] = (float)(i + (j / 100.0));
+ } /* end for */
/* Initialize the filenames */
h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
@@ -2308,13 +2600,48 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* create source file */
if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR
- /* Set dataspace dimensions */
+ /* Set 1-D dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+ max_dim1d[0]=H5S_UNLIMITED;
+
+ /* create 1-D dataspace */
+ if((sid = H5Screate_simple(1, dim1d, max_dim1d)) < 0) TEST_ERROR
+
+ /* create and set chunk plist */
+ if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR
+
+ /* create dataset */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close chunk plist */
+ if(H5Pclose(pid) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1d) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* Set extended dataset dimensions */
+ new_dim1d[0] = DIM_SIZE_1 * 2;
+
+ /* Extend dataset's dimensions */
+ if(H5Dset_extent(did, new_dim1d) < 0) TEST_ERROR
+
+ /* attach attributes to the dataset */
+ if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Set 2-D dataspace dimensions */
dim2d[0]=DIM_SIZE_1;
dim2d[1]=DIM_SIZE_2;
max_dim2d[0]=H5S_UNLIMITED;
max_dim2d[1]=H5S_UNLIMITED;
- /* create dataspace */
+ /* create 2-D dataspace */
if((sid = H5Screate_simple(2, dim2d, max_dim2d)) < 0) TEST_ERROR
/* create and set chunk plist */
@@ -2322,13 +2649,16 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
if(H5Pset_chunk(pid, 2, chunk_dim2d) < 0) TEST_ERROR
/* create dataset */
- if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
/* close chunk plist */
if(H5Pclose(pid) < 0) TEST_ERROR
/* write data into file */
- if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+ if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2d) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
/* Set extended dataset dimensions */
new_dim2d[0] = DIM_SIZE_1 * 2;
@@ -2337,9 +2667,6 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* Extend dataset's dimensions */
if(H5Dset_extent(did, new_dim2d) < 0) TEST_ERROR
- /* close dataspace */
- if(H5Sclose(sid) < 0) TEST_ERROR
-
/* attach attributes to the dataset */
if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
@@ -2359,8 +2686,9 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* 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 the dataset from SRC to DST */
+ /* copy the datasets from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -2377,6 +2705,21 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* close the source dataset */
if(H5Dclose(did) < 0) TEST_ERROR
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
/* close the SRC file */
if(H5Fclose(fid_src) < 0) TEST_ERROR
@@ -3495,7 +3838,7 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -3626,7 +3969,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -3763,7 +4106,7 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -4020,7 +4363,7 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
/* set initial data values */
for (i = 0; i < DIM_SIZE_1; i++) {
for (j = 0; j < DIM_SIZE_2; j++) {
- buf[i][j].len = j + 1;
+ buf[i][j].len = (size_t)(j + 1);
buf[i][j].p = (int *)HDmalloc(buf[i][j].len * sizeof(int));
for (k = 0; k < (int)buf[i][j].len; k++)
((int *)buf[i][j].p)[k] = i * 10000 + j * 100 + k;
@@ -4369,7 +4712,7 @@ error:
* Failure: number of errors
*
* Programmer: Peter Cao
- * August 8, 2006
+ * August 8, 2006
*
* Modifications:
*
@@ -4520,7 +4863,7 @@ test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
char objname[NAME_BUF_SIZE]; /* Sub-group & dataset name buffer */
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
-
+
TESTING("H5Ocopy(): deep nested groups");
/* set initial data values */
@@ -5625,7 +5968,7 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl)
addr_reset();
/* open source file (read-only) */
- if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR
@@ -5706,7 +6049,7 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -5853,7 +6196,7 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -5994,7 +6337,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -6143,7 +6486,7 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl
buf[i].len = i+1;
buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
for(j = 0; j < buf[i].len; j++)
- ((int *)buf[i].p)[j] = i*10+j;
+ ((int *)buf[i].p)[j] = (int)(i * 10 + j);
} /* end for */
/* Initialize the filenames */
@@ -6296,7 +6639,7 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
return 1;
} /* end if */
buf[i].len=i+1;
- for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ for(tvl = (hvl_t *)buf[i].p,j=0; j<(i+1); j++, tvl++) {
tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
if(tvl->p==NULL) {
TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
@@ -6451,7 +6794,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
TEST_ERROR
} /* end if */
buf[i].len=i+1;
- for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ for(tvl = (hvl_t *)buf[i].p,j=0; j<(i+1); j++, tvl++) {
tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
if(tvl->p==NULL) {
TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
@@ -6606,7 +6949,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
TEST_ERROR
} /* end if */
buf[i].len=i+1;
- for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ for(tvl = (hvl_t *)buf[i].p,j=0; j<(i+1); j++, tvl++) {
tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
if(tvl->p==NULL) {
TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
@@ -6762,7 +7105,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
TEST_ERROR
} /* end if */
buf[i].len=i+1;
- for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ for(tvl = (hvl_t *)buf[i].p,j=0; j<(i+1); j++, tvl++) {
tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
if(tvl->p==NULL) {
TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
@@ -6878,6 +7221,445 @@ error:
return 1;
} /* end test_copy_dataset_compressed_vl_vl */
+/*
+ * Common data structure for the copy_dataset_*_cmpd_vl tests.
+ */
+typedef struct cmpd_vl_t {
+ int a;
+ hvl_t b;
+ double c;
+} cmpd_vl_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_contig_cmpd_vl
+ *
+ * Purpose: Create a contiguous dataset w/VLEN datatype contained in
+ * a compound in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Tuseday, September 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t tid2 = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t did2 = -1; /* Dataset ID */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): contiguous dataset with compound VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].a = i * (i - 1);
+ buf[i].b.len = i+1;
+ buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int));
+ for(j = 0; j < buf[i].b.len; j++)
+ ((int *)buf[i].b.p)[j] = (int)(i * 10 + j);
+ buf[i].c = 1. / (i + 1.);
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], 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, fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, 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 dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_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 the dataset from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ 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
+
+
+ /* Reclaim vlen buffer */
+ if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close datatype */
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid2);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_contig_cmpd_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_chunked_cmpd_vl
+ *
+ * Purpose: Create a chunked dataset w/VLEN datatype contained in a
+ * compound in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Wednesdat, September 30 , 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid2 = -1; /* Datatype IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */
+ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): chunked dataset with compound VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].a = i * (i - 1);
+ buf[i].b.len = i+1;
+ buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int));
+ for(j = 0; j < buf[i].b.len; j++)
+ ((int *)buf[i].b.p)[j] = (int)(i * 10 + j);
+ buf[i].c = 1. / (i + 1.);
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], 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, fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR
+
+ /* create and set chunk plist */
+ if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* close chunk plist */
+ if(H5Pclose(pid) < 0) TEST_ERROR
+
+ /* write data into file */
+ 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 SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_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 the dataset from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ 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
+
+
+ /* Reclaim vlen buffer */
+ if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close datatype */
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid2);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_chunked_cmpd_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_compact_cmpd_vl
+ *
+ * Purpose: Create a compact dataset w/VLEN datatype contained in a
+ * compound in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Sunday, December 11, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid2 = -1; /* Datatype IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): compact dataset with compound VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].a = i * (i - 1);
+ buf[i].b.len = i+1;
+ buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int));
+ for(j = 0; j < buf[i].b.len; j++)
+ ((int *)buf[i].b.p)[j] = (int)(i * 10 + j);
+ buf[i].c = 1. / (i + 1.);
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], 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, fapl)) < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
+
+ /* create datatype */
+ if((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) TEST_ERROR
+ if(H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR
+
+ /* create and set compact plist */
+ if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR
+
+ /* create dataset at SRC file */
+ if((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* write data into file */
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close compact plist */
+ if(H5Pclose(pid) < 0) TEST_ERROR
+
+ /* close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+
+ /* open the source file with read-only */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_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 the dataset from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ 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
+
+
+ /* Reclaim vlen buffer */
+ if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR
+
+ /* close datatype */
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+ if(H5Tclose(tid) < 0) TEST_ERROR
+
+ /* close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid2);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_compact_cmpd_vl */
+
/*-------------------------------------------------------------------------
* Function: test_copy_option
@@ -6998,9 +7780,7 @@ test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl, unsigned flag, hboo
if(attach_reg_ref_attr(fid_src, gid_ref) < 0) TEST_ERROR
/* create a dataset of region references */
-/*
if(create_reg_ref_dataset(fid_src, gid_ref) < 0) TEST_ERROR
-*/
/* Close group holding reference objects */
if(H5Gclose(gid_ref) < 0) TEST_ERROR
@@ -7150,93 +7930,139 @@ error:
int
main(void)
{
- const char *envval;
-
- /* Don't run this test using the core, split, or multi file drivers */
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
-
- if(HDstrcmp(envval, "stdio") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- int nerrors = 0;
- hid_t fapl, fapl2;
- hid_t fcpl_shared;
- int configuration; /* Configuration of tests. */
- int ExpressMode;
-
- /* Setup */
- h5_reset();
- fapl = h5_fileaccess();
-
- ExpressMode = GetTestExpress();
- if (ExpressMode > 1)
- printf("***Express test mode on. Some tests may be skipped\n");
-
- /* Copy the file access property list */
- if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
-
- /* Create an FCPL with sharing enabled */
- if((fcpl_shared = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR
- if(H5Pset_shared_mesg_nindexes(fcpl_shared, 1) < 0) TEST_ERROR
- if(H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, (size_t) 10) < 0) TEST_ERROR
-
- /* Test in all configurations */
- for(configuration = 0; configuration <= MAX_CONFIGURATION; configuration++) {
- hid_t my_fapl;
- hid_t fcpl_src;
- hid_t fcpl_dst;
-
- /* Test with and without shared messages */
- if(configuration & CONFIG_SHARE_SRC) {
- puts("\nTesting with shared src messages:");
- fcpl_src = fcpl_shared;
- }
- else {
- puts("\nTesting without shared src messages:");
- fcpl_src = H5P_DEFAULT;
- }
- if(configuration & CONFIG_SHARE_DST) {
- puts("Testing with shared dst messages:");
- fcpl_dst = fcpl_shared;
+ int nerrors = 0;
+ hid_t fapl, fapl2;
+ hid_t fcpl_shared, ocpl;
+ unsigned max_compact, min_dense;
+ int configuration; /* Configuration of tests. */
+ int ExpressMode;
+
+ /* Setup */
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ ExpressMode = GetTestExpress();
+ if (ExpressMode > 1)
+ printf("***Express test mode on. Some tests may be skipped\n");
+
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ /* Create an FCPL with sharing enabled */
+ if((fcpl_shared = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_shared_mesg_nindexes(fcpl_shared, 1) < 0) TEST_ERROR
+ if(H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, (size_t) 10) < 0) TEST_ERROR
+
+ /* Obtain the default attribute storage phase change values */
+ if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) TEST_ERROR
+ if(H5Pget_attr_phase_change(ocpl, &max_compact, &min_dense) < 0) TEST_ERROR
+ if(H5Pclose(ocpl) < 0) TEST_ERROR
+
+ /* Test in all configurations */
+ for(configuration = 0; configuration <= MAX_CONFIGURATION; configuration++) {
+ hid_t my_fapl;
+ hid_t fcpl_src;
+ hid_t fcpl_dst;
+
+ /* No need to test dense attributes with old format */
+ if(!(configuration & CONFIG_NEW_FORMAT) && (configuration & CONFIG_DENSE))
+ continue;
+
+ /* Test with and without shared messages */
+ if(configuration & CONFIG_SHARE_SRC) {
+ puts("\nTesting with shared src messages:");
+ fcpl_src = fcpl_shared;
+ }
+ else {
+ puts("\nTesting without shared src messages:");
+ fcpl_src = H5P_DEFAULT;
+ }
+ if(configuration & CONFIG_SHARE_DST) {
+ puts("Testing with shared dst messages:");
+ fcpl_dst = fcpl_shared;
+ }
+ else {
+ puts("Testing without shared dst messages:");
+ fcpl_dst = H5P_DEFAULT;
+ }
+
+ /* Set the FAPL for the type of format */
+ if(configuration & CONFIG_NEW_FORMAT) {
+ puts("Testing with new group format:");
+ my_fapl = fapl2;
+
+ /* Test with and without dense attributes */
+ if(configuration & CONFIG_DENSE) {
+ puts("Testing with dense attributes:");
+ num_attributes_g = max_compact + 1;
}
else {
- puts("Testing without shared dst messages:");
- fcpl_dst = H5P_DEFAULT;
+ puts("Testing without dense attributes:");
+ num_attributes_g = MAX(min_dense, 2) - 1;
}
-
- /* Set the FAPL for the type of format */
- if(configuration & CONFIG_NEW_FORMAT) {
- puts("Testing with new group format:");
- my_fapl = fapl2;
- } /* end if */
- else {
- puts("Testing with old group format:");
- my_fapl = fapl;
- } /* end else */
-
-
- /* The tests... */
+ } /* end if */
+ else {
+ puts("Testing with old group format:");
+ my_fapl = fapl;
+ num_attributes_g = 4;
+ } /* end else */
+
+ /* The tests... */
+ nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_simple_samefile(fcpl_src, my_fapl);
+ nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compound(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked_empty(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked_sparse(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compressed(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_attr_named_dtype(fcpl_src, fcpl_dst, my_fapl);
+
+ nerrors += test_copy_group_empty(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_root_group(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_group(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_group_deep(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_group_loop(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_group_wide_loop(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_group_links(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, my_fapl);
+#ifndef H5_CANNOT_OPEN_TWICE
+ nerrors += test_copy_ext_link(fcpl_src, fcpl_dst, my_fapl);
+#endif /* H5_CANNOT_OPEN_TWICE */
+ nerrors += test_copy_exist(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_path(fcpl_src, fcpl_dst, my_fapl);
+
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG,
+ FALSE, "H5Ocopy(): without attributes");
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, 0, TRUE,
+ "H5Ocopy(): with missing groups");
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_SOFT_LINK_FLAG,
+ FALSE, "H5Ocopy(): expand soft link");
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_SHALLOW_HIERARCHY_FLAG,
+ FALSE, "H5Ocopy(): shallow group copy");
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_REFERENCE_FLAG,
+ FALSE, "H5Ocopy(): expand object reference");
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_PRESERVE_NULL_FLAG,
+ FALSE, "H5Ocopy(): preserve NULL messages");
+ nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG |
+ H5O_COPY_PRESERVE_NULL_FLAG, TRUE, "H5Ocopy(): preserve NULL messages");
+
+ /* Tests that do not use attributes and do not need to be tested
+ * multiple times for different attribute configurations */
+ if(configuration < CONFIG_DENSE) {
nerrors += test_copy_named_datatype(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_named_datatype_vl(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_named_datatype_vl_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compound(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_chunked(fcpl_src, fcpl_dst, my_fapl);
-
- nerrors += test_copy_dataset_chunked_empty(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_chunked_sparse(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compressed(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, my_fapl);
+
nerrors += test_copy_dataset_external(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_named_dtype(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_named_dtype_hier(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_named_dtype_hier_outside(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_attr_named_dtype(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_contig_vl(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_chunked_vl(fcpl_src, fcpl_dst, my_fapl);
@@ -7251,69 +8077,37 @@ main(void)
nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_chunked_vl_vl(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_group_empty(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_root_group(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_group(fcpl_src, fcpl_dst, my_fapl);
- if (ExpressMode > 1 && !HDstrcmp(envval, "direct")) {
- /* This test case with Direct driver has a poor performance on
- * NCSA copper, though it works. Skip it for now and worry
- * about the performance later.
- */
- printf("***Express test mode on. test_copy_group_deep is skipped");
- SKIPPED();
- } else
- nerrors += test_copy_group_deep(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_group_loop(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_group_wide_loop(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_group_links(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, my_fapl);
-#ifndef H5_CANNOT_OPEN_TWICE
- nerrors += test_copy_ext_link(fcpl_src, fcpl_dst, my_fapl);
-#endif /* H5_CANNOT_OPEN_TWICE */
- nerrors += test_copy_exist(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_path(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_contig_cmpd_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked_cmpd_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compact_cmpd_vl(fcpl_src, fcpl_dst, my_fapl);
+
nerrors += test_copy_same_file_named_datatype(fcpl_src, my_fapl);
nerrors += test_copy_old_layout(fcpl_dst, my_fapl);
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG,
- FALSE, "H5Ocopy(): without attributes");
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, 0, TRUE,
- "H5Ocopy(): with missing groups");
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_SOFT_LINK_FLAG,
- FALSE, "H5Ocopy(): expand soft link");
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_SHALLOW_HIERARCHY_FLAG,
- FALSE, "H5Ocopy(): shallow group copy");
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_REFERENCE_FLAG,
- FALSE, "H5Ocopy(): expand object reference");
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_PRESERVE_NULL_FLAG,
- FALSE, "H5Ocopy(): preserve NULL messages");
- nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG |
- H5O_COPY_PRESERVE_NULL_FLAG, TRUE, "H5Ocopy(): preserve NULL messages");
+ }
/* TODO: not implemented
- nerrors += test_copy_option(my_fapl, H5O_COPY_EXPAND_EXT_LINK_FLAG, FALSE, "H5Ocopy: expand external link");
- nerrors += test_copy_mount(my_fapl);
- */
- } /* end for */
+ nerrors += test_copy_option(my_fapl, H5O_COPY_EXPAND_EXT_LINK_FLAG, FALSE, "H5Ocopy: expand external link");
+ nerrors += test_copy_mount(my_fapl);
+*/
+ } /* end for */
- /* Reset file address checking info */
- addr_reset();
+ /* Reset file address checking info */
+ addr_reset();
- /* Results */
- if(nerrors) {
- printf("***** %d OBJECT COPY TEST%s FAILED! *****\n",
- nerrors, (1 == nerrors ? "" : "S"));
- exit(1);
- } /* end if */
+ /* Results */
+ if(nerrors) {
+ printf("***** %d OBJECT COPY TEST%s FAILED! *****\n",
+ nerrors, (1 == nerrors ? "" : "S"));
+ exit(1);
+ } /* end if */
- puts ("All object copying tests passed.");
+ puts ("All object copying tests passed.");
- h5_cleanup(FILENAME, fapl);
- } /* end if */
- else
- puts("All object copying tests skipped - Incompatible with current Virtual File Driver");
+ h5_cleanup(FILENAME, fapl);
return 0;
error:
return 1;
} /* main */
+
diff --git a/test/ohdr.c b/test/ohdr.c
index 5425b2b..f59dace 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -43,6 +43,103 @@ const char *FILENAME[] = {
*/
#define FILE_BOGUS "tbogus.h5"
+/*
+ * Verify that messages are moved forward into a "continuation message":
+ * Create an object header with several continuation chunks
+ * Remove a message in the last chunk
+ * The remaining message(s) in the last chunk should be moved forward into the continuation message
+ * The process will repeat when the continuation message is big enough to hold all the
+ * messages in the last chunk.
+ * Result: the number of chunks should be reduced
+ */
+static herr_t
+test_cont(char *filename, hid_t fapl)
+{
+ hid_t file=-1;
+ H5F_t *f = NULL;
+ H5O_hdr_info_t hdr_info;
+ H5O_loc_t oh_locA, oh_locB;
+ time_t time_new;
+ const char *short_name = "T";
+ const char *long_name = "This is the message";
+ size_t nchunks;
+
+ TESTING("object header continuation block");
+
+ /* Create the file to operate on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR
+
+ HDmemset(&oh_locA, 0, sizeof(oh_locA));
+ HDmemset(&oh_locB, 0, sizeof(oh_locB));
+
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)H5O_MIN_SIZE, H5P_GROUP_CREATE_DEFAULT, &oh_locA/*out*/) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)H5O_MIN_SIZE, H5P_GROUP_CREATE_DEFAULT, &oh_locB/*out*/) < 0)
+ FAIL_STACK_ERROR
+
+ time_new = 11111111;
+
+ if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &long_name, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_msg_create(&oh_locA, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &short_name, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5AC_expunge_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_OHDR, oh_locA.addr, H5AC__NO_FLAGS_SET) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_get_hdr_info(&oh_locA, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
+ FAIL_STACK_ERROR
+ nchunks = hdr_info.nchunks;
+
+ /* remove the 1st H5O_NAME_ID message */
+ if(H5O_msg_remove(&oh_locA, H5O_NAME_ID, 0, FALSE, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5O_get_hdr_info(&oh_locA, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
+ FAIL_STACK_ERROR
+
+ if(hdr_info.nchunks >= nchunks)
+ TEST_ERROR
+
+ if(H5O_close(&oh_locA) < 0)
+ FAIL_STACK_ERROR
+ if(H5O_close(&oh_locB) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED();
+
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5O_close(&oh_locA);
+ H5O_close(&oh_locB);
+ H5Fclose (file);
+ } H5E_END_TRY;
+ return -1;
+} /* test_cont() */
+
/*-------------------------------------------------------------------------
* Function: main
@@ -67,14 +164,13 @@ main(void)
hid_t dset=-1;
H5F_t *f=NULL;
char filename[1024];
- H5O_info_t oinfo; /* Object info */
+ H5O_hdr_info_t hdr_info; /* Object info */
H5O_loc_t oh_loc;
time_t time_new, ro;
int i;
hbool_t b; /* Index for "new format" loop */
- const char *envval = NULL;
herr_t ret; /* Generic return value */
-
+
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
@@ -85,15 +181,19 @@ main(void)
/* Display info about testing */
if(b)
HDputs("Using new file format:");
- else
+ else
HDputs("Using default file format:");
/* Set the format to use for the file */
if (H5Pset_libver_bounds(fapl, (b ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR
+ /* test on object continuation block */
+ if (test_cont(filename, fapl) < 0)
+ FAIL_STACK_ERROR
+
/* Create the file to operate on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if(NULL == (f = H5I_object(file))) FAIL_STACK_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR
/*
@@ -112,7 +212,9 @@ main(void)
time_new = 11111111;
if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
- if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0)
+ if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5AC_expunge_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0)
FAIL_STACK_ERROR
if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT))
FAIL_STACK_ERROR
@@ -128,7 +230,9 @@ main(void)
time_new = 33333333;
if(H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
- if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0)
+ if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5AC_expunge_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0)
FAIL_STACK_ERROR
if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT))
FAIL_STACK_ERROR
@@ -136,9 +240,9 @@ main(void)
TEST_ERROR
/* Make certain that chunk #0 in the object header can be encoded with a 1-byte size */
- if(H5O_get_info(&oh_loc, H5P_DATASET_XFER_DEFAULT, FALSE, &oinfo) < 0)
+ if(H5O_get_hdr_info(&oh_loc, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
FAIL_STACK_ERROR
- if(oinfo.hdr.space.total >=256)
+ if(hdr_info.space.total >=256)
TEST_ERROR
PASSED();
@@ -157,13 +261,15 @@ main(void)
if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
} /* end for */
- if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0)
+ if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5AC_expunge_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0)
FAIL_STACK_ERROR
/* Make certain that chunk #0 in the object header will be encoded with a 2-byte size */
- if(H5O_get_info(&oh_loc, H5P_DATASET_XFER_DEFAULT, FALSE, &oinfo) < 0)
+ if(H5O_get_hdr_info(&oh_loc, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
FAIL_STACK_ERROR
- if(oinfo.hdr.space.total < 256)
+ if(hdr_info.space.total < 256)
TEST_ERROR
PASSED();
@@ -174,27 +280,18 @@ main(void)
* works correctly - QAK)
*/
TESTING("close & re-open object header");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "multi") && HDstrcmp(envval, "split") && HDstrcmp(envval, "family")) {
- if(H5O_close(&oh_loc) < 0)
- FAIL_STACK_ERROR
- if(H5Fclose(file) < 0)
- FAIL_STACK_ERROR
- if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
- FAIL_STACK_ERROR
- if(NULL == (f = H5I_object(file)))
- FAIL_STACK_ERROR
- oh_loc.file = f;
- if(H5O_open(&oh_loc) < 0)
- FAIL_STACK_ERROR
- PASSED();
- } /* end if */
- else {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- } /* end else */
+ if(H5O_close(&oh_loc) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+ oh_loc.file = f;
+ if(H5O_open(&oh_loc) < 0)
+ FAIL_STACK_ERROR
+ PASSED();
/*
* Test creation of a bunch of messages one after another to see
@@ -205,7 +302,9 @@ main(void)
time_new = (i + 1) * 1000 + 10;
if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
- if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0)
+ if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5AC_expunge_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0)
FAIL_STACK_ERROR
} /* end for */
PASSED();
@@ -233,7 +332,9 @@ main(void)
time_new = 22222222;
if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0)
FAIL_STACK_ERROR
- if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0)
+ if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ if(H5AC_expunge_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0)
FAIL_STACK_ERROR
if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT))
FAIL_STACK_ERROR
@@ -259,10 +360,7 @@ main(void)
/* Test reading datasets with undefined object header messages */
HDputs("Accessing objects with unknown header messages:");
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "multi") && HDstrcmp(envval, "split") && HDstrcmp(envval, "family")) {
+ {
hid_t file2; /* File ID for 'bogus' object file */
char testpath[512] = "";
char testfile[512] = "";
@@ -282,7 +380,7 @@ main(void)
TESTING("object with unknown header message and no flags set");
/* Open the file with objects that have unknown header messages (generated with gen_bogus.c) */
- if((file2 = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0)
+ if((file2 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
TEST_ERROR
/* Open the dataset with the unknown header message, but no extra flags */
@@ -374,11 +472,7 @@ main(void)
TEST_ERROR
PASSED();
- } /* end if */
- else {
- SKIPPED();
- puts(" Test not compatible with current Virtual File Driver");
- } /* end else */
+ }
/* Close the file we created */
if(H5Fclose(file) < 0)
diff --git a/test/pool.c b/test/pool.c
index 1e26109..9b2e8b9 100644
--- a/test/pool.c
+++ b/test/pool.c
@@ -46,14 +46,11 @@
* Purpose: Test trivial creating & closing memory pool
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, May 3, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
@@ -74,18 +71,18 @@ test_create(void)
/* Check free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != 0)
TEST_ERROR
/* Check first page */
- if (H5MP_get_pool_first_page(mp, &page) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_first_page(mp, &page) < 0)
+ TEST_ERROR
if(page != NULL)
TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -94,7 +91,10 @@ test_create(void)
error:
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_create() */
@@ -105,21 +105,17 @@ error:
* Purpose: Tests closing pool with one block allocated
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Friday, May 6, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
test_close_one(void)
{
H5MP_pool_t *mp; /* Memory pool */
- void *spc1; /* Pointer to space allocated */
/*
* Test memory pool closing
@@ -131,7 +127,7 @@ test_close_one(void)
TEST_ERROR
/* Allocate space in pool */
- if(NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
+ if(NULL == H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))
TEST_ERROR
/* Close the memory pool */
@@ -144,7 +140,10 @@ test_close_one(void)
error:
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_close_one() */
@@ -155,14 +154,11 @@ error:
* Purpose: Tests allocating first block in pool
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, May 3, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
@@ -188,29 +184,29 @@ test_allocate_first(void)
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Get first page */
- if (H5MP_get_pool_first_page(mp, &page) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_first_page(mp, &page) < 0)
+ TEST_ERROR
if(page == NULL)
TEST_ERROR
/* Check page's free space */
- if (H5MP_get_page_free_size(page, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_page_free_size(page, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Check next page */
- if (H5MP_get_page_next_page(page, &page) < 0)
- TEST_ERROR;
+ if(H5MP_get_page_next_page(page, &page) < 0)
+ TEST_ERROR
if(page != NULL)
TEST_ERROR
@@ -218,17 +214,17 @@ test_allocate_first(void)
H5MP_free(mp, spc);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -245,29 +241,29 @@ test_allocate_first(void)
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != 0)
TEST_ERROR
/* Get first page */
- if (H5MP_get_pool_first_page(mp, &page) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_first_page(mp, &page) < 0)
+ TEST_ERROR
if(page == NULL)
TEST_ERROR
/* Check page's free space */
- if (H5MP_get_page_free_size(page, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_page_free_size(page, &free_size) < 0)
+ TEST_ERROR
if(free_size != 0)
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Check next page */
- if (H5MP_get_page_next_page(page, &page) < 0)
- TEST_ERROR;
+ if(H5MP_get_page_next_page(page, &page) < 0)
+ TEST_ERROR
if(page != NULL)
TEST_ERROR
@@ -275,17 +271,17 @@ test_allocate_first(void)
H5MP_free(mp, spc);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -294,7 +290,10 @@ test_allocate_first(void)
error:
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_allocate_first() */
@@ -306,14 +305,11 @@ error:
* existing block
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, May 3, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
@@ -339,13 +335,13 @@ test_allocate_split(void)
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Allocate more space in pool */
if(NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)))
@@ -353,42 +349,42 @@ test_allocate_split(void)
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * 2) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Free first block in pool */
H5MP_free(mp, spc1);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Free second block in pool (should merge with first block) */
H5MP_free(mp, spc2);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -397,7 +393,10 @@ test_allocate_split(void)
error:
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_allocate_split() */
@@ -408,14 +407,11 @@ error:
* Purpose: Tests allocating many small blocks in a pool
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, May 6, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
@@ -442,13 +438,13 @@ test_allocate_many_small(void)
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (((H5MP_BLOCK_ALIGN(MPOOL_SMALL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * MPOOL_NUM_SMALL_BLOCKS) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Free blocks in pool */
/* (Tests free block merging with block after it */
@@ -456,17 +452,17 @@ test_allocate_many_small(void)
H5MP_free(mp, spc[i]);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -475,7 +471,10 @@ test_allocate_many_small(void)
error:
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_allocate_many_small() */
@@ -487,14 +486,11 @@ error:
* new page
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Friday, May 6, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
@@ -523,13 +519,13 @@ test_allocate_new_page(void)
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ TEST_ERROR
if(free_size != (MPOOL_PAGE_SIZE * 3) - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * MPOOL_NUM_NORMAL_BLOCKS) + (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)) * 3)))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Free blocks in pool */
/* (Free alternating blocks, in two passes, which tests block merging w/both neighbors) */
@@ -539,17 +535,17 @@ test_allocate_new_page(void)
H5MP_free(mp, spc[u]);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) * 3))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -569,32 +565,32 @@ test_allocate_new_page(void)
TEST_ERROR
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Free blocks in pool */
H5MP_free(mp, spc1);
H5MP_free(mp, spc2);
/* Check pool's free space */
- if (H5MP_get_pool_free_size(mp, &free_size) < 0)
- TEST_ERROR;
+ if(H5MP_get_pool_free_size(mp, &free_size) < 0)
+ TEST_ERROR
if(free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) +
MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))))
TEST_ERROR
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
@@ -603,7 +599,10 @@ test_allocate_new_page(void)
error:
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_allocate_new_page() */
@@ -614,14 +613,11 @@ error:
* Purpose: Tests allocating random sized blocks in pool
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
* Friday, May 6, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
@@ -641,12 +637,12 @@ test_allocate_random(void)
TESTING("allocate many random sized blocks");
/* Initialize random number seed */
- curr_time=HDtime(NULL);
+ curr_time = HDtime(NULL);
#ifdef QAK
curr_time=1115412944;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create a memory pool */
if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
@@ -671,7 +667,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Check that free space totals match */
if(H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ TEST_ERROR
/* Shuffle pointers to free */
for(u = 0; u < MPOOL_NUM_RANDOM; u++) {
@@ -686,8 +682,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
H5MP_free(mp, spc[u]);
/* Check that free space totals match */
- if (H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ if(H5MP_pool_is_free_size_correct(mp) <= 0)
+ TEST_ERROR
/* Initialize the block sizes with random values */
for(u = 0; u < MPOOL_NUM_RANDOM; u++)
@@ -701,10 +697,10 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Check that free space totals match */
if(H5MP_pool_is_free_size_correct(mp) <= 0)
- TEST_ERROR;
+ TEST_ERROR
/* Close the memory pool */
- if (H5MP_close(mp) < 0)
+ if(H5MP_close(mp) < 0)
TEST_ERROR
/* Free memory for block sizes & pointers */
@@ -721,7 +717,10 @@ error:
if(spc)
HDfree(spc);
H5E_BEGIN_TRY {
+ if(mp)
+ H5MP_close(mp);
} H5E_END_TRY;
+
return 1;
} /* test_allocate_random() */
@@ -732,20 +731,17 @@ error:
* Purpose: Test the memory pool code
*
* Return: Success:
- *
* Failure:
*
* Programmer: Quincey Koziol
* Tuesday, May 3, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
main(void)
{
- int nerrors=0;
+ int nerrors = 0;
/* Reset library */
h5_reset();
@@ -763,14 +759,14 @@ main(void)
nerrors += test_allocate_new_page();
nerrors += test_allocate_random();
- if (nerrors) goto error;
+ if(nerrors)
+ goto error;
puts("All memory pool tests passed.");
+
return 0;
error:
puts("*** TESTS FAILED ***");
- H5E_BEGIN_TRY {
- } H5E_END_TRY;
return 1;
}
diff --git a/test/reserved.c b/test/reserved.c
index 583fd64..bb6d328 100755
--- a/test/reserved.c
+++ b/test/reserved.c
@@ -423,6 +423,8 @@ main(void)
{
/* This test is currently not working properly; it should be revisted
* when we have time.
+ *
+ * (Also, we should try to make this test work with all the VFDs)
*/
#ifdef BROKEN
int num_errs=0;
@@ -430,7 +432,7 @@ main(void)
const char *envval = NULL;
envval = HDgetenv("HDF5_DRIVER");
- if (envval == NULL)
+ if (envval == NULL)
envval = "nomatch";
/* QAK: should be able to use the core driver? */
if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
diff --git a/test/set_extent.c b/test/set_extent.c
index 24d6851..b4e61b4 100644
--- a/test/set_extent.c
+++ b/test/set_extent.c
@@ -20,516 +20,2644 @@
* Purpose: Tests the H5Dset_extent call
*/
-
#include "hdf5.h"
#include "h5test.h"
-
/*-------------------------------------------------------------------------
*
- * Tests the function H5Dset_extent. In the current version of the library
- * the dataset MUST be chunked.
+ * Tests the function H5Dset_extent.
*
*-------------------------------------------------------------------------
*/
-#define RANK 2
-#define ISTORE_IK 64
+const char *FILENAME[] = {
+ "set_extent1",
+ "set_extent2",
+ "set_extent3",
+ "set_extent4",
+ "set_extent5",
+ NULL
+};
+
+#define NAME_BUF_SIZE 1024
+#define EXT_FILE_NAME1 "ext1.bin"
+#define EXT_FILE_NAME2 "ext2.bin"
+
+#define RANK1 1
+#define RANK2 2
+#define RANK3 3
+#define DIM0 5
+#define DIM1 5
+#define DIM2 5
+#define DIMS0 3
+#define DIMS1 3
+#define DIMS2 3
+#define DIME0 7
+#define DIME1 7
+#define DIME2 7
+#define ISTORE_IK 64
+
+static int do_ranks( hid_t fapl );
+static int do_layouts( hid_t fapl );
+
+static int test_rank1( hbool_t do_compress,
+ hbool_t do_fill_value,
+ hbool_t set_istore_k,
+ H5D_fill_time_t fill_time,
+ hid_t fapl);
+static int test_rank2( hbool_t do_compress,
+ hbool_t do_fill_value,
+ hbool_t set_istore_k,
+ H5D_fill_time_t fill_time,
+ hid_t fapl);
+static int test_rank3( hbool_t do_compress,
+ hbool_t do_fill_value,
+ hbool_t set_istore_k,
+ H5D_fill_time_t fill_time,
+ hid_t fapl);
+
+static int test_external( hid_t fapl );
+static int test_layouts( H5D_layout_t layout, hid_t fapl );
+/*-------------------------------------------------------------------------
+ * main
+ *-------------------------------------------------------------------------
+ */
int main( void )
{
- hid_t file_id;
- hid_t dataset_id=(-1);
- hid_t space_id=(-1);
- hid_t plist_id=(-1);
- hid_t fcpl; /* File creation property list */
- hsize_t dims[RANK] = { 90, 90 };
- hsize_t dims_new[RANK] = { 70, 70 };
- hsize_t dims_chunk[RANK] = { 20, 20 };
- hsize_t dims_out[RANK];
- hsize_t maxdims[RANK] = { H5S_UNLIMITED, H5S_UNLIMITED };
- int data[ 90 ][ 90 ];
- int buf1[ 70 ][ 70 ];
- int buf2[ 90 ][ 90 ];
- int i, j, n = 0;
- int fillvalue = 1; /* Fill value for the dataset */
-#ifdef H5_HAVE_FILTER_DEFLATE
- hbool_t do_compress; /* Iterator for looping over compress/no compress */
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
-
- for( i = 0; i < 90; i++ )
- for( j = 0; j < 90; j++ )
- data[i][j] = n++;
-
- /*-------------------------------------------------------------------------
- * Test H5Dset_extent with chunks on the raw data cache
- *-------------------------------------------------------------------------
- */
-#ifdef H5_HAVE_FILTER_DEFLATE
- for(do_compress = FALSE; do_compress <= TRUE; do_compress++) {
- if(do_compress)
- puts("Testing WITH compression on chunks.");
- else
- puts("Testing with NO compression on chunks.");
-#else /* H5_HAVE_FILTER_DEFLATE */
- puts("** deflate filter nor available - Skipping tests for compression on chunks. **");
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
- TESTING("extend dataset create with fill value");
-
- /* Create a new file using default properties. */
- if((file_id = H5Fcreate("set_extent_create.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- /* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
-
- /* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate (H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR;
-#ifdef H5_HAVE_FILTER_DEFLATE
- if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
-
- /*-------------------------------------------------------------------------
- * Create and write one dataset
- *-------------------------------------------------------------------------
- */
-
- /* Create a new dataset */
- if((dataset_id = H5Dcreate2(file_id , "Dataset1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- /* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
-
- /*-------------------------------------------------------------------------
- * Set new dimensions for the array; shrink it
- *-------------------------------------------------------------------------
- */
-
- /* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR;
-
- /* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
-
- /* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
-
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
- if(dims_out[1] != dims_new[1]) TEST_ERROR;
-
-
- /*-------------------------------------------------------------------------
- * Read
- *-------------------------------------------------------------------------
- */
-
- /* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0) TEST_ERROR;
-
-
- /* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ )
- for( j = 0; j < (int)dims_out[1]; j++ )
- if ( buf1[i][j] != data[i][j] ) {
- printf("buf1[%d][%d] = %d\n", i, j, buf1[i][j]);
- printf("data[%d][%d] = %d\n", i, j, data[i][j]);
- TEST_ERROR;
- } /* end if */
-
-
- /*-------------------------------------------------------------------------
- * Set new dimensions for the array; expand it back to original size
- *-------------------------------------------------------------------------
- */
-
- /* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id, dims) < 0) TEST_ERROR;
-
- /* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
-
- /* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
-
- if(dims_out[0] != dims[0]) TEST_ERROR;
- if(dims_out[1] != dims[1]) TEST_ERROR;
-
-
- /*-------------------------------------------------------------------------
- * Read
- *-------------------------------------------------------------------------
- */
-
- /* Read the new dataset. */
- if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) TEST_ERROR;
+ hid_t fapl; /* file access property list */
+ hid_t fapl2; /* file access property list w/latest format set */
+ hbool_t new_format; /* Whether to use the latest file format */
+ hbool_t chunk_cache; /* Whether to enable chunk caching */
+ int nerrors = 0;
+
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Disable chunk caching on fapl2 */
+ if(H5Pset_cache(fapl2, 521, 0, 0, 0.) < 0) TEST_ERROR
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ /* Test with old & new format groups */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
+
+ /* Test chunked datasets with and without chunk cache */
+ for(chunk_cache = FALSE; chunk_cache <= TRUE; chunk_cache++) {
+ /* Output message about the type of format */
+ if(new_format)
+ printf("Testing with new file format");
+ else
+ printf("Testing with old file format");
+
+ /* Set the FAPL for the chunk cache settings */
+ if(chunk_cache) {
+ puts(" and chunk cache enabled:");
+ my_fapl = fapl;
+ } /* end if */
+ else {
+ puts(" and chunk cache disabled:");
+ my_fapl = fapl2;
+ } /* end else */
+
+ /* Set the FAPL for the type of format */
+ if(new_format) {
+ /* Set the "use the latest version of the format" bounds for
+ * creating objects in the file */
+ if(H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST,
+ H5F_LIBVER_LATEST) < 0) TEST_ERROR
+ } /* end if */
+ else
+ /* Set the "use the earliest version of the format" bounds for
+ * creating objects in the file */
+ if(H5Pset_libver_bounds(my_fapl, H5F_LIBVER_EARLIEST,
+ H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ /* Tests which use chunked datasets */
+ nerrors += do_ranks( my_fapl ) < 0 ? 1 : 0;
+ } /* end for */
+
+ /* Tests which do not use chunked datasets */
+ nerrors += test_external( fapl ) < 0 ? 1 : 0;
+ nerrors += do_layouts( fapl ) < 0 ? 1 : 0;
+ } /* end for */
- /* Compare the read array with the original array */
- for(i = 0; i < (int)dims_out[0]; i++ )
- for(j = 0; j < (int)dims_out[1]; j++ )
- if(i >= 70 || j >= 70) {
- if(buf2[i][j] != fillvalue) {
- printf("buf1[%d][%d] = %d\n", i, j, buf1[i][j]);
- printf("fillvalue = %d\n", fillvalue);
- TEST_ERROR;
- } /* end if */
- } /* end if */
- else {
- if(buf2[i][j] != data[i][j]) TEST_ERROR;
- }
+ /* Close 2nd FAPL */
+ if(H5Pclose(fapl2) < 0) TEST_ERROR
+ h5_cleanup(FILENAME, fapl);
+
+ HDremove(EXT_FILE_NAME1);
+ HDremove(EXT_FILE_NAME2);
- /*-------------------------------------------------------------------------
- * Close/release resources
- *-------------------------------------------------------------------------
- */
+ if(nerrors)
+ goto error;
+ puts("All H5Dset_extent tests passed.");
- if(H5Dclose(dataset_id) < 0) TEST_ERROR
- if(H5Sclose(space_id) < 0) TEST_ERROR
- if(H5Pclose(plist_id) < 0) TEST_ERROR
+ return 0;
- PASSED();
+error:
+ nerrors = MAX(1, nerrors);
+ printf("***** %d H5Dset_extent TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ return 1;
+}
- TESTING("extend dataset create without fill value");
+/*-------------------------------------------------------------------------
+* test with several ranks
+*-------------------------------------------------------------------------
+*/
+static int do_ranks( hid_t fapl )
+{
- /* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
+ hbool_t do_compress = 0;
+ hbool_t do_fillvalue = 0;
+ hbool_t set_istore_k = 0;
+
+
+ TESTING_2("with fill value, no compression");
+
+ do_fillvalue = 1;
+
+ if (test_rank1( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank1( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_IFSET, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_IFSET, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank3( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank3( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_IFSET, fapl ) < 0)
+ {
+ goto error;
+ }
+
+
+
+ PASSED();
+
+
+ TESTING_2("no fill value, no compression");
+
+ do_fillvalue = 0;
+
+ if (test_rank1( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ERROR, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ERROR, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank3( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ERROR, fapl ) < 0)
+ {
+ goto error;
+ }
+
+
+
+ PASSED();
+
+ TESTING_2("with fill value, with compression");
- /* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_time(plist_id, H5D_FILL_TIME_ALLOC) < 0) TEST_ERROR;
#ifdef H5_HAVE_FILTER_DEFLATE
- if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
- /*-------------------------------------------------------------------------
- * Create and write one dataset
- *-------------------------------------------------------------------------
- */
- /* Create a new dataset */
- if((dataset_id = H5Dcreate2(file_id , "Dataset2", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
+ do_compress = 1;
+ do_fillvalue = 1;
+
+ if (test_rank1( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank1( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_IFSET, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_IFSET, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank3( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank3( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_IFSET, fapl ) < 0)
+ {
+ goto error;
+ }
+
+
+ PASSED();
+#else
+ SKIPPED();
+#endif
+
+ TESTING_2("no fill value, with compression");
- /* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+#ifdef H5_HAVE_FILTER_DEFLATE
- /*-------------------------------------------------------------------------
- * Set new dimensions for the array; shrink it
- *-------------------------------------------------------------------------
- */
+ do_fillvalue = 0;
+
+ if (test_rank1( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ERROR, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ERROR, fapl ) < 0)
+ {
+ goto error;
+ }
+ if (test_rank3( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ERROR, fapl ) < 0)
+ {
+ goto error;
+ }
+
+ PASSED();
+#else
+ SKIPPED();
+#endif
+
+ TESTING_2("with non-default indexed storage B-tree");
+
+ do_fillvalue = 1;
+ set_istore_k = 1;
+
+ if (test_rank2( do_compress, do_fillvalue, set_istore_k, H5D_FILL_TIME_ALLOC, fapl ) < 0)
+ {
+ goto error;
+ }
+
+
+ PASSED();
+
+
+ return 0;
+
+
+error:
+ return -1;
+}
- /* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR;
- /* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
+/*-------------------------------------------------------------------------
+* test with different storage layouts
+*-------------------------------------------------------------------------
+*/
+static int do_layouts( hid_t fapl )
+{
+
+ TESTING_2("storage layout use");
+
+ if (test_layouts( H5D_COMPACT, fapl ) < 0)
+ {
+ goto error;
+ }
+
+ if (test_layouts( H5D_CONTIGUOUS, fapl ) < 0)
+ {
+ goto error;
+ }
+
+ PASSED();
+
+ return 0;
+
+error:
+ return -1;
+}
- /* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+/*-------------------------------------------------------------------------
+ * test usage with a 1D rank
+ *-------------------------------------------------------------------------
+ */
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
+static int test_rank1( hbool_t do_compress,
+ hbool_t do_fill_value,
+ hbool_t set_istore_k,
+ H5D_fill_time_t fill_time,
+ hid_t fapl)
+{
+ hid_t fid=-1;
+ hid_t did=-1;
+ hid_t sid=-1;
+ hid_t dcpl=-1;
+ hid_t fcpl;
+ hsize_t dims_o[RANK1] = {DIM0}; /* original dimensions */
+ hsize_t dims_s[RANK1] = {DIMS0}; /* shrinking dimensions */
+ hsize_t dims_e[RANK1] = {DIME0}; /* extended dimensions */
+ hsize_t dims_c[RANK1] = {2}; /* chunk dimensions */
+ hsize_t dims_r[RANK1]; /* read dimensions */
+ hsize_t maxdims[RANK1] = {H5S_UNLIMITED};
+ int buf_o[DIM0];
+ int buf_s[DIMS0];
+ int buf_e[DIME0];
+ int buf_r[DIM0];
+ int i;
+ int fillvalue = 1;
+ int comp_value;
+ char filename[NAME_BUF_SIZE];
+
+ if ( do_fill_value )
+ {
+ comp_value = fillvalue;
+ }
+ else
+ {
+ comp_value = 0;
+ }
+
+
+ for( i = 0; i < DIM0; i++ )
+ {
+
+ buf_o[i] = 2;
+ }
+
+ /* create a file creation property list */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ {
+ goto error;
+ }
+
+ if ( set_istore_k )
+ {
+ /* set non-default indexed storage B-tree internal 'K' value */
+ if (H5Pset_istore_k(fcpl,ISTORE_IK) < 0)
+ {
+ goto error;
+ }
+
+ }
+ /* create a new file */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ {
+ goto error;
+ }
+
+ /* close property list */
+ if(H5Pclose(fcpl) < 0)
+ {
+ goto error;
+ }
+
+ /* create the data space with unlimited dimensions. */
+ if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0)
+ {
+ goto error;
+ }
+
+ /* modify dataset creation properties, i.e. enable chunking. */
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ {
+ goto error;
+ }
+ if (H5Pset_chunk(dcpl, RANK1, dims_c) < 0)
+ {
+ goto error;
+ }
+ if ( do_fill_value )
+ {
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0)
+ {
+ goto error;
+ }
- /*-------------------------------------------------------------------------
- * Read
- *-------------------------------------------------------------------------
- */
+ if(H5Pset_fill_time(dcpl, fill_time) < 0)
+ {
+ goto error;
+ }
+ }
+ else
+ {
+
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0)
+ {
+ goto error;
+ }
+
+ }
+ if (do_compress)
+ {
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ {
+ goto error;
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * create, write dataset
+ *-------------------------------------------------------------------------
+ */
+
+ /* create a dataset */
+ if ((did = H5Dcreate2(fid , "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+
+ /* write */
+ if (H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0)
+ {
+ goto error;
+ }
+
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_o[0]; i++ )
+ {
+
+ printf("%d ", buf_o[i]);
+
+ }
+ printf("\n");
+#endif
+
+
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * set new dimensions for the array; expand it
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_e) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+ /* check dimensions */
+ for( i = 0; i < RANK1; i++ )
+ {
+ if (dims_r[i] != dims_e[i])
+ goto error;
+ }
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0)
+ goto error;
+
+
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+
+ printf("%d ", buf_e[i]);
+
+ }
+ printf("\n");
+#endif
+
+
+
+
+ /* compare the read array with the expanded array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+
+ if ( i >= DIM0 )
+ {
+ if(buf_e[i] != comp_value)
+ {
+ printf("buf_e[%d] = %d\n", i, buf_e[i]);
+ printf("value = %d\n", comp_value);
+ goto error;
+ }
+ }
+ else
+ {
+ if(buf_e[i] != buf_o[i])
+ goto error;
+ }
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * shrink
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK1; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ goto error;
+ }
+
+
+
+ /* for this case we close and reopen file */
+ if ( set_istore_k )
+ {
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+ if (H5Fclose(fid) < 0)
+ {
+ goto error;
+ }
- /* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0) TEST_ERROR;
+ if ((fid = H5Fopen( filename, H5F_ACC_RDWR, fapl ))<0)
+ {
+ goto error;
+ }
+
+ if ((did = H5Dopen2( fid , "dset1", H5P_DEFAULT ))<0)
+ {
+ goto error;
+ }
+
+
+
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ /* read */
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s ) < 0)
+ {
+ goto error;
+ }
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+
+ printf("%d ", buf_s[i]);
+ }
+ printf("\n");
+
+#endif
+
+
+
+
+ /* compare the read array with the shrinked array */
+ for( i = 0; i < (int)dims_r[0]; i++ )
+ {
+
+ if ( buf_s[i] != buf_o[i] )
+ {
+ printf("buf_s[%d] = %d\n", i, buf_s[i]);
+ printf("buf_o[%d] = %d\n", i, buf_o[i]);
+ goto error;
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * expand it back to original size
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array */
+ if (H5Dset_extent(did, dims_o) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions. */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+ /* check dimensions */
+ for( i = 0; i < RANK1; i++ )
+ {
+ if (dims_r[i] != dims_o[i])
+ goto error;
+ }
+
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0)
+ goto error;
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+
+ printf("%d ", buf_r[i]);
+
+ }
+ printf("\n");
+#endif
+
+
+
+ /* compare the read array with the original array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+
+ if (i >= DIMS0 )
+ {
+ if(buf_r[i] != comp_value)
+ {
+ printf("buf_r[%d] = %d\n", i, buf_r[i] );
+ printf("value = %d\n", comp_value);
+ goto error;
+ }
+ }
+ else
+ {
+ if(buf_r[i] != buf_o[i])
+ goto error;
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * shrink to 0
+ *
+ *-------------------------------------------------------------------------
+ */
- /* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ )
- for( j = 0; j < (int)dims_out[1]; j++ )
- if ( buf1[i][j] != data[i][j] ) TEST_ERROR;
+ dims_s[0] = 0;
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK1; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * close dataset
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * test a dataset with non initialized chunks
+ *-------------------------------------------------------------------------
+ */
+
+
+ if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0)
+ {
+ goto error;
+ }
+ if ((did = H5Dcreate2(fid , "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+ /* set new dimensions for the array */
+ dims_o[ 0 ] = 0;
+ if (H5Dset_extent( did , dims_o ) < 0)
+ {
+ goto error;
+ }
+
+
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * close property list
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (H5Pclose(dcpl) < 0)
+ {
+ goto error;
+ }
+ if (H5Fclose( fid ) < 0)
+ {
+ goto error;
+ }
- /*-------------------------------------------------------------------------
- * Set new dimensions for the array; expand it again
- *-------------------------------------------------------------------------
- */
- /* Set new dimensions for the array. */
- if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR;
+ return 0;
+
+
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ H5Dclose( did );
+ H5Sclose( sid );
+ H5Pclose( dcpl );
+ H5Pclose( fcpl );
+ H5Fclose( fid );
+ } H5E_END_TRY;
+ return -1;
+
+}
- /* Get the space. */
- if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR;
+/*-------------------------------------------------------------------------
+ * test usage with a 2D rank
+ *-------------------------------------------------------------------------
+ */
- /* Get dimensions. */
- if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR;
+static int test_rank2( hbool_t do_compress,
+ hbool_t do_fill_value,
+ hbool_t set_istore_k,
+ H5D_fill_time_t fill_time,
+ hid_t fapl)
+{
- if ( dims_out[0] != dims[0] ) TEST_ERROR;
+ hid_t fid=-1;
+ hid_t did=-1;
+ hid_t sid=-1;
+ hid_t dcpl=-1;
+ hid_t fcpl;
+ hsize_t dims_o[RANK2] = {DIM0,DIM1}; /* original dimensions */
+ hsize_t dims_s[RANK2] = {DIMS0,DIMS1}; /* shrinking dimensions */
+ hsize_t dims_e[RANK2] = {DIME0,DIME1}; /* extended dimensions */
+ hsize_t dims_c[RANK2] = {2,2}; /* chunk dimensions */
+ hsize_t dims_r[RANK2]; /* read dimensions */
+ hsize_t maxdims[RANK2] = {H5S_UNLIMITED,H5S_UNLIMITED};
+ int buf_o[DIM0][DIM1];
+ int buf_s[DIMS0][DIMS1];
+ int buf_e[DIME0][DIME1];
+ int buf_r[DIM0][DIM1];
+ int i, j;
+ int fillvalue = 1;
+ int comp_value;
+ char filename[NAME_BUF_SIZE];
+
+ if ( do_fill_value )
+ {
+ comp_value = fillvalue;
+ }
+ else
+ {
+ comp_value = 0;
+ }
+
+
+ for( i = 0; i < DIM0; i++ )
+ {
+ for( j = 0; j < DIM1; j++ )
+ {
+ buf_o[i][j] = 2;
+ }
+ }
+
+ /* create a file creation property list */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ {
+ goto error;
+ }
+
+ if ( set_istore_k )
+ {
+ /* set non-default indexed storage B-tree internal 'K' value */
+ if (H5Pset_istore_k(fcpl,ISTORE_IK) < 0)
+ {
+ goto error;
+ }
+
+ }
+
+ /* create a new file */
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ {
+ goto error;
+ }
+
+
+
+ /* create the data space with unlimited dimensions. */
+ if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0)
+ {
+ goto error;
+ }
+
+ /* modify dataset creation properties, i.e. enable chunking. */
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ {
+ goto error;
+ }
+ if (H5Pset_chunk(dcpl, RANK2, dims_c) < 0)
+ {
+ goto error;
+ }
+ if ( do_fill_value )
+ {
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0)
+ {
+ goto error;
+ }
+ if(H5Pset_fill_time(dcpl, fill_time) < 0)
+ {
+ goto error;
+ }
+ }
+ else
+ {
+
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0)
+ {
+ goto error;
+ }
+
+ }
+ if (do_compress)
+ {
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ {
+ goto error;
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * Procedure 1
+ * a. Write an array AxB. These are the dimensions for creating the dataset
+ * b. Define a greater array CxD where C > A and D > B
+ * c. Read data back
+ * d. Verify if new dimensions are C and D
+ * e. Verify if data from A to C and B to D is what it is to be expected
+ *
+ * original data is
+ *
+ * 2 2 2 2
+ * 2 2 2 2
+ * 2 2 2 2
+ * 2 2 2 2
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* create a dataset */
+ if ((did = H5Dcreate2(fid , "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+
+ /* write */
+ if (H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0)
+ {
+ goto error;
+ }
+
+
+#if defined (H5_SET_EXTENT_DEBUG2)
+ printf("\n");
+ for (i = 0; i < (int)dims_o[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_o[1]; j++ )
+ {
+ printf("%d ", buf_o[i][j]);
+ }
+ printf("\n");
+ }
+#endif
- /*-------------------------------------------------------------------------
- * Read
- *-------------------------------------------------------------------------
- */
- /* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0) TEST_ERROR;
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * set new dimensions for the array; expand it
+ * data is now, extended space was initialized with fill value or default value
+ *
+ * 2 2 2 2 1 1 1
+ * 2 2 2 2 1 1 1
+ * 2 2 2 2 1 1 1
+ * 2 2 2 2 1 1 1
+ * 1 1 1 1 1 1 1
+ * 1 1 1 1 1 1 1
+ * 1 1 1 1 1 1 1
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_e) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_e[i])
+ goto error;
+ }
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0)
+ goto error;
+
+
+
+#if defined (H5_SET_EXTENT_DEBUG2)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_e[i][j]);
+ }
+ printf("\n");
+ }
+#endif
+
+
+
+
+ /* compare the read array with the expanded array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ if ( i >= DIM0 || j >= DIM1 )
+ {
+ if(buf_e[i][j] != comp_value)
+ {
+ printf("buf_e[%d][%d] = %d\n", i, j, buf_e[i][j]);
+ printf("value = %d\n", comp_value);
+ goto error;
+ }
+ }
+ else
+ {
+ if(buf_e[i][j] != buf_o[i][j])
+ goto error;
+ }
+ }
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ *
+ * Procedure 2
+ * a. Define a smaller array ExF where E < A and F < B
+ * b. Read data back
+ * c. Verify if new dimensions are E and F
+ * d. Verify if data up until E and F is what to be expected
+ *
+ * data is now
+ *
+ * 2 2
+ * 2 2
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ goto error;
+ }
+
+
+
+ /* for this case we close and reopen file */
+ if ( set_istore_k )
+ {
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+ if (H5Fclose(fid) < 0)
+ {
+ goto error;
+ }
- /* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ ) {
- for( j = 0; j < (int)dims_out[1]; j++ ) {
- if ( i >= 70 || j >= 70 ) {
- if ( buf2[i][j] != 0 ) TEST_ERROR;
- }
- else {
- if ( buf2[i][j] != data[i][j] ) TEST_ERROR;
- }
+ if ((fid = H5Fopen( filename, H5F_ACC_RDWR, fapl ))<0)
+ {
+ goto error;
+ }
+
+ if ((did = H5Dopen2( fid , "dset1", H5P_DEFAULT ))<0)
+ {
+ goto error;
+ }
+
+
+
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ /* read */
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s ) < 0)
+ {
+ goto error;
+ }
+
+#if defined (H5_SET_EXTENT_DEBUG2)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_s[i][j]);
+ }
+ printf("\n");
+ }
+#endif
+
+
+
+
+ /* compare the read array with the shrinked array */
+ for( i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for( j = 0; j < (int)dims_r[1]; j++ )
+ {
+ if ( buf_s[i][j] != buf_o[i][j] )
+ {
+ printf("buf_s[%d][%d] = %d\n", i, j, buf_s[i][j]);
+ printf("buf_o[%d][%d] = %d\n", i, j, buf_o[i][j]);
+ goto error;
+ }
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * set new dimensions for the array; expand it back to original size
+ * data is now, extended space was initialized with fill value or default value
+ *
+ * 2 2 1 1
+ * 2 2 1 1
+ * 1 1 1 1
+ * 1 1 1 1
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array */
+ if (H5Dset_extent(did, dims_o) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions. */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_o[i])
+ goto error;
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0)
+ goto error;
+
+#if defined (H5_SET_EXTENT_DEBUG2)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_r[i][j]);
+ }
+ printf("\n");
+ }
+#endif
+
+
+
+ /* compare the read array with the original array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ if (i >= DIMS0 || j >= DIMS1)
+ {
+ if(buf_r[i][j] != comp_value)
+ {
+ printf("buf_r[%d][%d] = %d\n", i, j, buf_r[i][j]);
+ printf("value = %d\n", comp_value);
+ goto error;
+ }
+ }
+ else
+ {
+ if(buf_r[i][j] != buf_o[i][j])
+ goto error;
}
}
+ }
+ /*-------------------------------------------------------------------------
+ * shrink to 0
+ *
+ *-------------------------------------------------------------------------
+ */
- /*-------------------------------------------------------------------------
- * Close/release resources
- *-------------------------------------------------------------------------
- */
+ dims_s[0] = 0;
+ dims_s[1] = 0;
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ goto error;
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * close dataset
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * test a dataset with non initialized chunks
+ *-------------------------------------------------------------------------
+ */
+
+
+ if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0)
+ {
+ goto error;
+ }
+ if ((did = H5Dcreate2(fid , "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+ /* set new dimensions for the array */
+ dims_o[ 0 ] = 0;
+ dims_o[ 1 ] = 0;
+ if (H5Dset_extent( did , dims_o ) < 0)
+ {
+ goto error;
+ }
+
+
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * close property list
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (H5Pclose(dcpl) < 0)
+ {
+ goto error;
+ }
- H5Dclose( dataset_id );
- H5Sclose( space_id );
- H5Pclose( plist_id );
+ /* close file creation property list */
+ if(H5Pclose(fcpl) < 0)
+ {
+ goto error;
+ }
- H5Fclose( file_id );
+ if (H5Fclose( fid ) < 0)
+ {
+ goto error;
+ }
- PASSED();
+ return 0;
+
+
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ H5Dclose( did );
+ H5Sclose( sid );
+ H5Pclose( dcpl );
+ H5Pclose( fcpl );
+ H5Fclose( fid );
+ } H5E_END_TRY;
+ return -1;
+
+}
- /*-------------------------------------------------------------------------
- * Test H5Dset_extent with chunks written to file
- *-------------------------------------------------------------------------
- */
- /* Create a file creation property list */
- if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR;
- /* Set non-default indexed storage B-tree internal 'K' value */
- if(H5Pset_istore_k(fcpl,ISTORE_IK) < 0) TEST_ERROR;
+/*-------------------------------------------------------------------------
+ * test usage with a 3D rank
+ *-------------------------------------------------------------------------
+ */
- /* Create a new file using properties. */
- if((file_id = H5Fcreate("set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) TEST_ERROR;
+static int test_rank3( hbool_t do_compress,
+ hbool_t do_fill_value,
+ hbool_t set_istore_k,
+ H5D_fill_time_t fill_time,
+ hid_t fapl)
+{
- /* Close property list */
- if(H5Pclose(fcpl) < 0) TEST_ERROR;
+ hid_t fid=-1;
+ hid_t did=-1;
+ hid_t sid=-1;
+ hid_t dcpl=-1;
+ hid_t fcpl;
+ hsize_t dims_o[RANK3] = {DIM0,DIM1,DIM2}; /* original dimensions */
+ hsize_t dims_s[RANK3] = {DIMS0,DIMS1,DIMS2}; /* shrinking dimensions */
+ hsize_t dims_e[RANK3] = {DIME0,DIME1,DIME2}; /* extended dimensions */
+ hsize_t dims_c[RANK3] = {2,2,2}; /* chunk dimensions */
+ hsize_t dims_r[RANK3]; /* read dimensions */
+ hsize_t maxdims[RANK3] = {H5S_UNLIMITED,H5S_UNLIMITED,H5S_UNLIMITED};
+ int buf_o[DIM0][DIM1][DIM2];
+ int buf_s[DIMS0][DIMS1][DIMS2];
+ int buf_e[DIME0][DIME1][DIME2];
+ int buf_r[DIM0][DIM1][DIM2];
+ int i, j, k;
+ int fillvalue = 1;
+ int comp_value;
+ char filename[NAME_BUF_SIZE];
+
+ if ( do_fill_value )
+ {
+ comp_value = fillvalue;
+ }
+ else
+ {
+ comp_value = 0;
+ }
+
+
+ for( i = 0; i < DIM0; i++ )
+ {
+ for( j = 0; j < DIM1; j++ )
+ {
+ for( k = 0; k < DIM2; k++ )
+ {
+ buf_o[i][j][k] = 2;
+ }
+ }
+ }
+
+ /* create a file creation property list */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ {
+ goto error;
+ }
+
+ if ( set_istore_k )
+ {
+ /* set non-default indexed storage B-tree internal 'K' value */
+ if (H5Pset_istore_k(fcpl,ISTORE_IK) < 0)
+ {
+ goto error;
+ }
+
+ }
+ /* create a new file */
+ h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ {
+ goto error;
+ }
+
+ /* close property list */
+ if(H5Pclose(fcpl) < 0)
+ {
+ goto error;
+ }
+
+ /* create the data space with unlimited dimensions. */
+ if ((sid = H5Screate_simple(RANK3, dims_o, maxdims)) < 0)
+ {
+ goto error;
+ }
+
+ /* modify dataset creation properties, i.e. enable chunking. */
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ {
+ goto error;
+ }
+ if (H5Pset_chunk(dcpl, RANK3, dims_c) < 0)
+ {
+ goto error;
+ }
+ if ( do_fill_value )
+ {
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0)
+ {
+ goto error;
+ }
- TESTING("extend dataset read with fill value");
+ if(H5Pset_fill_time(dcpl, fill_time) < 0)
+ {
+ goto error;
+ }
+ }
+ else
+ {
+
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0)
+ {
+ goto error;
+ }
+
+ }
+ if (do_compress)
+ {
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ {
+ goto error;
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * create, write array
+ *-------------------------------------------------------------------------
+ */
+
+ /* create a dataset */
+ if ((did = H5Dcreate2(fid , "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+
+ /* write */
+ if (H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0)
+ {
+ goto error;
+ }
+
+
+#if defined (H5_SET_EXTENT_DEBUG3)
+ printf("\n");
+ for (i = 0; i < (int)dims_o[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_o[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_o[2]; k++ )
+ {
+ printf("%d ", buf_o[i][j][k]);
+ }
+ printf("[%d] ", j);
+ }
+ printf("\n");
+
+ }
+ printf("\n");
+#endif
+
+
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * set new dimensions for the array; expand it
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_e) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+ /* check dimensions */
+ for( i = 0; i < RANK3; i++ )
+ {
+ if (dims_r[i] != dims_e[i])
+ goto error;
+ }
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0)
+ goto error;
+
+
+
+#if defined (H5_SET_EXTENT_DEBUG3)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_r[2]; k++ )
+ {
+ printf("%d ", buf_e[i][j][k]);
+ }
+ printf("[%d] ", j);
+ }
+ printf("\n");
+
+ }
+ printf("\n");
+#endif
+
+
+
+
+ /* compare the read array with the expanded array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_r[2]; k++ )
+ {
+ if ( i >= DIM0 || j >= DIM1 || k >= DIM2 )
+ {
+ if(buf_e[i][j][k] != comp_value)
+ {
+ printf("buf_e[%d][%d][%d] = %d\n", i, j, k, buf_e[i][j][k] );
+ printf("value = %d\n", comp_value);
+ goto error;
+ }
+ }
+ else
+ {
+ if(buf_e[i][j][k] != buf_o[i][j][k] )
+ goto error;
+ }
+ }
+ }
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * shrink
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK3; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ goto error;
+ }
+
+
+
+ /* for this case we close and reopen file */
+ if ( set_istore_k )
+ {
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+ if (H5Fclose(fid) < 0)
+ {
+ goto error;
+ }
- /* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
+ if ((fid = H5Fopen( filename, H5F_ACC_RDWR, fapl ))<0)
+ {
+ goto error;
+ }
+
+ if ((did = H5Dopen2( fid , "dset1", H5P_DEFAULT ))<0)
+ {
+ goto error;
+ }
+
+
+
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ /* read */
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s ) < 0)
+ {
+ goto error;
+ }
+
+#if defined (H5_SET_EXTENT_DEBUG3)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_r[2]; k++ )
+ {
+ printf("%d ", buf_s[i][j][k]);
+ }
+ printf("[%d] ", j);
+ }
+ printf("\n");
+
+ }
+ printf("\n");
+#endif
+
+
+
+
+ /* compare the read array with the shrinked array */
+ for( i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for( j = 0; j < (int)dims_r[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_r[2]; k++ )
+ {
+ if ( buf_s[i][j][k] != buf_o[i][j][k] )
+ {
+ printf("buf_s[%d][%d][%d] = %d\n", i, j, k, buf_s[i][j][k] );
+ printf("buf_o[%d][%d][%d] = %d\n", i, j, k, buf_o[i][j][k] );
+ goto error;
+ }
+ }
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * set new dimensions for the array; expand it back to original size
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array */
+ if (H5Dset_extent(did, dims_o) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions. */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK3; i++ )
+ {
+ if (dims_r[i] != dims_o[i])
+ goto error;
+ }
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0)
+ goto error;
+
+#if defined (H5_SET_EXTENT_DEBUG3)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_r[2]; k++ )
+ {
+
+ printf("%d ", buf_r[i][j][k]);
+ }
+ printf("[%d] ", j);
+ }
+ printf("\n");
+
+ }
+ printf("\n");
+#endif
+
+
+
+ /* compare the read array with the original array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ for( k = 0; k < (int)dims_r[2]; k++ )
+ {
+ if (i >= DIMS0 || j >= DIMS1 || k >= DIMS2 )
+ {
+ if( buf_r[i][j][k] != comp_value )
+ {
+ printf("buf_r[%d][%d][%d] = %d\n", i, j, k, buf_r[i][j][k] );
+ printf("value = %d\n", comp_value);
+ goto error;
+ }
+ }
+ else
+ {
+ if(buf_r[i][j][k] != buf_o[i][j][k])
+ goto error;
+ }
+ }
+ }
+ }
+
- /* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR;
-#ifdef H5_HAVE_FILTER_DEFLATE
- if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
-#endif /* H5_HAVE_FILTER_DEFLATE */
+ /*-------------------------------------------------------------------------
+ * shrink to 0
+ *
+ *-------------------------------------------------------------------------
+ */
- /* Create a new dataset within the file using cparms creation properties. */
- if((dataset_id = H5Dcreate2(file_id , "Dataset1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
+ dims_s[0] = 0;
+ dims_s[1] = 0;
+ dims_s[2] = 0;
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ {
+ goto error;
+ }
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK3; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ goto error;
+ }
+
+
+
+ /*-------------------------------------------------------------------------
+ * close dataset
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * test a dataset with non initialized chunks
+ *-------------------------------------------------------------------------
+ */
+
+
+ if ((sid = H5Screate_simple(RANK3, dims_o, maxdims)) < 0)
+ {
+ goto error;
+ }
+ if ((did = H5Dcreate2(fid , "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+ /* set new dimensions for the array */
+ dims_o[ 0 ] = 0;
+ dims_o[ 1 ] = 0;
+ dims_o[ 2 ] = 0;
+ if (H5Dset_extent( did , dims_o ) < 0)
+ {
+ goto error;
+ }
+
+
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * close property list
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (H5Pclose(dcpl) < 0)
+ {
+ goto error;
+ }
- /* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+ if (H5Fclose( fid ) < 0)
+ {
+ goto error;
+ }
- /* Close/release resources. */
- if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR
- if(H5Pclose(plist_id) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
+ return 0;
+
+
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ H5Dclose( did );
+ H5Sclose( sid );
+ H5Pclose( dcpl );
+ H5Pclose( fcpl );
+ H5Fclose( fid );
+ } H5E_END_TRY;
+ return -1;
+
+}
- /* Open the file */
- if((file_id = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR;
- /* Open the dataset */
- if((dataset_id = H5Dopen2(file_id , "Dataset1", H5P_DEFAULT)) < 0) TEST_ERROR;
+/*-------------------------------------------------------------------------
+ * test usage with external storage
+ *-------------------------------------------------------------------------
+ */
+static int test_external( hid_t fapl )
+{
- /* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR;
+ hid_t fid=-1;
+ hid_t did=-1;
+ hid_t sid=-1;
+ hid_t dcpl=-1;
+ hsize_t dims_o[RANK2] = {DIM0,DIM1}; /* original dimensions */
+ hsize_t dims_s[RANK2] = {DIMS0,DIMS1}; /* shrinking dimensions */
+ hsize_t dims_e[RANK2] = {DIME0,DIM1}; /* extended dimensions, dimension 1 is the original */
+ hsize_t dims_r[RANK2]; /* read dimensions */
+ hsize_t maxdims[RANK2] = {DIME0,DIM1}; /* only the first dimension can be extendible */
+ int buf_o[DIM0][DIM1]; /* original buffer, for writing */
+ int buf_s[DIMS0][DIMS1]; /* shrinked buffer, for reading */
+ int buf_e[DIME0][DIM1]; /* extended buffer, for writing, dimension 1 is the original */
+ int buf_ro[DIM0][DIM1]; /* original buffer for reading */
+ int i, j;
+ int comp_value = 0;
+ char filename[NAME_BUF_SIZE];
+
+
+ hsize_t size; /* number of bytes reserved in the file for the data */
+ hsize_t max_size[2];
+
+ max_size[0] = dims_e[0];
+ max_size[1] = dims_e[1];
+ size = max_size[0] * max_size[1] * sizeof(int) / 2;
+
+
+ for( i = 0; i < DIM0; i++ )
+ {
+ for( j = 0; j < DIM1; j++ )
+ {
+ buf_o[i][j] = 2;
+ }
+ }
+
+ TESTING_2("external file use");
+
+ /* create a new file */
+ h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* modify dataset creation properties */
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Pset_external(dcpl, EXT_FILE_NAME1, (off_t)0, size) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Pset_external(dcpl, EXT_FILE_NAME2, (off_t)0, size) < 0)
+ FAIL_STACK_ERROR
+
+ {
+
+ char name[256]; /*external file name */
+ off_t file_offset; /*external file offset */
+ hsize_t file_size; /*sizeof external file segment */
+
+ if(H5Pget_external(dcpl, 0, sizeof(name), name, &file_offset,
+ &file_size) < 0)
+ FAIL_STACK_ERROR
+
+ }
- /* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
- /* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
+ /*-------------------------------------------------------------------------
+ * Write an array AxB. These are the dimensions for creating the dataset
+ *
+ * original data is
+ *
+ * 2 2 2 2
+ * 2 2 2 2
+ * 2 2 2 2
+ * 2 2 2 2
+ *
+ *-------------------------------------------------------------------------
+ */
- /* Read the new dataset. */
- if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) TEST_ERROR;
- /* Compare the read array with the original array */
- for(i = 0; i < (int)dims_out[0]; i++)
- for(j = 0; j < (int)dims_out[1]; j++)
- if(buf1[i][j] != data[i][j])
- TEST_ERROR;
+ /* create the data space with unlimited dimensions. */
+ if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0)
+ FAIL_STACK_ERROR
+ if ((did = H5Dcreate2(fid , "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if (H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0)
+ FAIL_STACK_ERROR
+ if (H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR
- /*-------------------------------------------------------------------------
- * Set new dimensions for the array; expand it again
- *-------------------------------------------------------------------------
- */
- /* Set new dimensions for the array. */
- if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR;
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
- /* Get the space. */
- if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR;
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ro) < 0)
+ FAIL_STACK_ERROR
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_o[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_o[1]; j++ )
+ {
+ printf("%d ", buf_ro[i][j]);
+ }
+ printf("\n");
+ }
+#endif
- /* Get dimensions. */
- if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR;
- if ( dims_out[0] != dims[0] ) TEST_ERROR;
+
+ /*-------------------------------------------------------------------------
+ * expand
+ *-------------------------------------------------------------------------
+ */
- /* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0) TEST_ERROR;
+ /*-------------------------------------------------------------------------
+ * set new dimensions for the array; expand it
+ * data is now, extended space was initialized with default value
+ *
+ * 2 2 2 2
+ * 2 2 2 2
+ * 2 2 2 2
+ * 2 2 2 2
+ * 0 0 0 0
+ * 0 0 0 0
+ * 0 0 0 0
+ *
+ *-------------------------------------------------------------------------
+ */
- /* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ ) {
- for( j = 0; j < (int)dims_out[1]; j++ ) {
- if ( i >= 70 || j >= 70 ) {
- if ( buf2[i][j] != fillvalue ) TEST_ERROR;
- }
- else {
- if ( buf2[i][j] != data[i][j] ) TEST_ERROR;
- }
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_e) < 0)
+ FAIL_STACK_ERROR
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ FAIL_STACK_ERROR
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ if (H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR
+
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_e[i])
+ TEST_ERROR
+ }
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0)
+ FAIL_STACK_ERROR
+
+
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_e[i][j]);
+ }
+ printf("\n");
+ }
+#endif
+
+
+
+
+ /* compare the read array with the expanded array */
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ if ( i >= DIM0 || j >= DIM1 )
+ {
+ if(buf_e[i][j] != comp_value)
+ {
+ printf("buf_e[%d][%d] = %d\n", i, j, buf_e[i][j]);
+ printf("value = %d\n", comp_value);
+ TEST_ERROR
+ }
+ }
+ else
+ {
+ if(buf_e[i][j] != buf_o[i][j])
+ TEST_ERROR
}
}
+ }
+
+
+
+ /*-------------------------------------------------------------------------
+ * shrink
+ *
+ * data is now
+ *
+ * 2 2
+ * 2 2
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_s) < 0)
+ FAIL_STACK_ERROR
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ FAIL_STACK_ERROR
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ FAIL_STACK_ERROR
+
+ if (H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_s[i])
+ TEST_ERROR
+ }
+
+
+
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ /* read */
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s ) < 0)
+ FAIL_STACK_ERROR
+
+#if defined (H5_SET_EXTENT_DEBUG)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_s[i][j]);
+ }
+ printf("\n");
+ }
+#endif
+
+
+
+
+ /* compare the read array with the shrinked array */
+ for( i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for( j = 0; j < (int)dims_r[1]; j++ )
+ {
+ if ( buf_s[i][j] != buf_o[i][j] )
+ {
+ printf("buf_s[%d][%d] = %d\n", i, j, buf_s[i][j]);
+ printf("buf_o[%d][%d] = %d\n", i, j, buf_o[i][j]);
+ TEST_ERROR
+ }
+ }
+ }
- /*-------------------------------------------------------------------------
- * Close/release resources
- *-------------------------------------------------------------------------
- */
-
- H5Dclose( dataset_id );
- H5Sclose( space_id );
-
- PASSED();
-
-
- TESTING("extend dataset read without fill value");
-
- /* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
-
- /* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_time(plist_id, H5D_FILL_TIME_ALLOC) < 0) TEST_ERROR;
-#ifdef H5_HAVE_FILTER_DEFLATE
- if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
- /* Create a new dataset within the file using cparms creation properties. */
- if((dataset_id = H5Dcreate2(file_id , "Dataset2", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- /* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+ /*-------------------------------------------------------------------------
+ * negative test
+ * try to extend dimension above maximum
+ *-------------------------------------------------------------------------
+ */
- /* Close/release resources. */
- if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR
- if(H5Pclose(plist_id) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
+ dims_e[1] = DIME1;
- /* Open the file */
- if((file_id = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR;
- /* Open the dataset */
- if((dataset_id = H5Dopen2(file_id , "Dataset2", H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5E_BEGIN_TRY
+ {
+
+
+ /* set new dimensions for the array. */
+ if (H5Dset_extent(did , dims_e) == SUCCEED)
+ {
+ TEST_ERROR
+ }
+
+ } H5E_END_TRY;
- /* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR;
- /* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
- /* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+ /*-------------------------------------------------------------------------
+ * close property list
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (H5Pclose(dcpl) < 0)
+ FAIL_STACK_ERROR
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
+ if (H5Dclose( did ) < 0)
+ FAIL_STACK_ERROR
- /* Read the new dataset. */
- if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) TEST_ERROR;
+ if (H5Fclose( fid ) < 0)
+ FAIL_STACK_ERROR
- /* Compare the read array with the original array */
- for(i = 0; i < (int)dims_out[0]; i++)
- for(j = 0; j < (int)dims_out[1]; j++)
- if(buf1[i][j] != data[i][j])
- TEST_ERROR;
+ PASSED();
- /*-------------------------------------------------------------------------
- * Set new dimensions for the array; expand it again
- *-------------------------------------------------------------------------
- */
+ return 0;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ H5Dclose( did );
+ H5Sclose( sid );
+ H5Pclose( dcpl );
+ H5Fclose( fid );
+ } H5E_END_TRY;
+ return -1;
+}
- /* Set new dimensions for the array. */
- if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR;
- /* Get the space. */
- if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR;
+/*-------------------------------------------------------------------------
+ * test usage with layouts compact and contiguous
+ *-------------------------------------------------------------------------
+ */
+static int test_layouts( H5D_layout_t layout, hid_t fapl )
+{
- /* Get dimensions. */
- if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR;
+ hid_t fid=-1;
+ hid_t did=-1;
+ hid_t sid=-1;
+ hid_t dcpl=-1;
+ hsize_t dims_o[RANK2] = {DIM0,DIM1}; /* original dimensions */
+ hsize_t dims_s[RANK2] = {DIMS0,DIMS1}; /* shrinking dimensions */
+ hsize_t dims_e[RANK2] = {DIME0,DIME1}; /* extended dimensions */
+ hsize_t dims_r[RANK2]; /* read dimensions */
+ int buf_o[DIM0][DIM1];
+ int buf_r[DIM0][DIM1];
+ int i, j;
+ char filename[NAME_BUF_SIZE];
+
+ for( i = 0; i < DIM0; i++ )
+ {
+ for( j = 0; j < DIM1; j++ )
+ {
+ buf_o[i][j] = 2;
+ }
+ }
+
+
+ /* create a new file */
+ h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ {
+ goto error;
+ }
+
+ /* create the data space with unlimited dimensions. */
+ if ((sid = H5Screate_simple(RANK2, dims_o, NULL)) < 0)
+ {
+ goto error;
+ }
+
+ /* modify dataset creation properties */
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Pset_layout (dcpl, layout) < 0)
+ {
+ goto error;
+ }
+
+ /* create a dataset */
+ if ((did = H5Dcreate2(fid , "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ {
+ goto error;
+ }
+
+ /* write */
+ if (H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0)
+ {
+ goto error;
+ }
+
+
+#if defined (H5_SET_EXTENT_DEBUG4)
+ printf("\n");
+ for (i = 0; i < (int)dims_o[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_o[1]; j++ )
+ {
+ printf("%d ", buf_o[i][j]);
+ }
+ printf("\n");
+ }
+#endif
- if ( dims_out[0] != dims[0] ) TEST_ERROR;
- /* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0) TEST_ERROR;
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * negative test
+ * try to extend dimension
+ *-------------------------------------------------------------------------
+ */
- /* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ ) {
- for( j = 0; j < (int)dims_out[1]; j++ ) {
- if ( i >= 70 || j >= 70 ) {
- if ( buf2[i][j] != 0 ) TEST_ERROR;
- }
- else {
- if ( buf2[i][j] != data[i][j] ) TEST_ERROR;
- }
- }
+ H5E_BEGIN_TRY
+ {
+
+ if (H5Dset_extent(did , dims_e) == SUCCEED)
+ {
+ goto error;
}
+
+ } H5E_END_TRY;
+
+
+
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_o[i])
+ goto error;
+ }
+
+ /* read */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0)
+ goto error;
+
+
+
+#if defined (H5_SET_EXTENT_DEBUG4)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_r[i][j]);
+ }
+ printf("\n");
+ }
+#endif
+
+
+ /*-------------------------------------------------------------------------
+ * negative test
+ * try to shrink dimension
+ *-------------------------------------------------------------------------
+ */
- /*-------------------------------------------------------------------------
- * Close/release resources
- *-------------------------------------------------------------------------
- */
-
- H5Dclose( dataset_id );
- H5Sclose( space_id );
+ H5E_BEGIN_TRY
+ {
+
+ if (H5Dset_extent(did , dims_s) == SUCCEED)
+ {
+ goto error;
+ }
+
+ } H5E_END_TRY;
+
+
+ /* get the space */
+ if ((sid = H5Dget_space(did)) < 0)
+ {
+ goto error;
+ }
+
+ /* get dimensions */
+ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Sclose(sid) < 0)
+ {
+ goto error;
+ }
+
+ /* check dimensions */
+ for( i = 0; i < RANK2; i++ )
+ {
+ if (dims_r[i] != dims_o[i])
+ goto error;
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ /* read */
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r ) < 0)
+ {
+ goto error;
+ }
+
+#if defined (H5_SET_EXTENT_DEBUG4)
+ printf("\n");
+ for (i = 0; i < (int)dims_r[0]; i++ )
+ {
+ for (j = 0; j < (int)dims_r[1]; j++ )
+ {
+ printf("%d ", buf_r[i][j]);
+ }
+ printf("\n");
+ }
+#endif
- H5Fclose( file_id );
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Dclose(did) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Pclose(dcpl) < 0)
+ {
+ goto error;
+ }
+
+ if (H5Fclose( fid ) < 0)
+ {
+ goto error;
+ }
- PASSED();
-#ifdef H5_HAVE_FILTER_DEFLATE
- } /* end for */
-#endif /* H5_HAVE_FILTER_DEFLATE */
- puts("All set_extent tests passed.");
return 0;
-
-
+
+
+
error:
- H5Dclose( dataset_id );
- H5Sclose( space_id );
- H5Pclose( plist_id );
- H5Fclose( file_id );
- H5_FAILED();
- return 1;
+
+ H5E_BEGIN_TRY
+ {
+ H5Dclose( did );
+ H5Sclose( sid );
+ H5Pclose( dcpl );
+ H5Fclose( fid );
+ } H5E_END_TRY;
+ return -1;
+
}
diff --git a/test/specmetaread.h5 b/test/specmetaread.h5
new file mode 100644
index 0000000..50b0e69
--- /dev/null
+++ b/test/specmetaread.h5
Binary files differ
diff --git a/test/stab.c b/test/stab.c
index 2b9a84d..cab0b1b 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -59,6 +59,7 @@ const char *FILENAME[] = {
* for version 1.6. To get this data file, simply compile gen_old_group.c with
* the HDF5 library in that branch and run it. */
#define FILE_OLD_GROUPS "group_old.h5"
+#define FILE_OLD_GROUPS_COPY "group_old.h5.copy"
/* Definitions for 'no_compact' test */
#define NO_COMPACT_TOP_GROUP "top"
@@ -75,6 +76,12 @@ const char *FILENAME[] = {
/* Definitions for 'old_api' test */
#define OLD_API_GROUP "/old_api"
+/* Definitions for 'corrupt_stab_msg' test */
+#define CORRUPT_STAB_FILE "corrupt_stab_msg.h5"
+#define CORRUPT_STAB_TMP_FILE "corrupt_stab_msg_tmp.h5"
+#define CORRUPT_STAB_COPY_BUF_SIZE 4096
+#define CORRUPT_STAB_DSET "DS1"
+
/*-------------------------------------------------------------------------
* Function: test_misc
@@ -342,7 +349,7 @@ lifecycle(hid_t fapl2)
if(H5Fclose(fid) < 0) TEST_ERROR
/* Get size of file as empty */
- if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Re-open file */
if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR
@@ -491,7 +498,7 @@ lifecycle(hid_t fapl2)
if(H5Fclose(fid) < 0) TEST_ERROR
/* Get size of file as empty */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Verify that file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -547,7 +554,7 @@ long_compact(hid_t fapl2)
if(H5Fclose(fid) < 0) TEST_ERROR
/* Get size of file as empty */
- if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Construct very long object name template */
if((objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1))) == NULL) TEST_ERROR
@@ -624,7 +631,7 @@ long_compact(hid_t fapl2)
if(H5Fclose(fid) < 0) TEST_ERROR
/* Get size of file as empty */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Verify that file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -657,47 +664,21 @@ error:
*-------------------------------------------------------------------------
*/
static int
-read_old(hid_t fapl2)
+read_old(void)
{
- int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
hid_t fid = (-1); /* File ID */
hid_t gid = (-1); /* Group ID */
hid_t gid2 = (-1); /* Group ID */
- char buf[READ_OLD_BUFSIZE]; /* Buffer for copying data */
- ssize_t nread; /* Number of bytes read in */
char objname[NAME_BUF_SIZE]; /* Object name */
unsigned u; /* Local index variable */
- char *srcdir = HDgetenv("srcdir"); /* where the src code is located */
- char filename[512] = ""; /* old test file name */
- char filename2[NAME_BUF_SIZE]; /* copy of old test file */
TESTING("reading old groups");
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_OLD_GROUPS) + 1) < sizeof(filename))) {
- HDstrcpy(filename, srcdir);
- HDstrcat(filename, "/");
- }
- HDstrcat(filename, FILE_OLD_GROUPS);
-
- /* Create filename */
- h5_fixname(FILENAME[0], fapl2, filename2, sizeof(filename2));
-
- /* Copy old file into temporary file */
- if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) TEST_ERROR
- if((fd_new = HDopen(filename2, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) TEST_ERROR
-
- /* Copy data */
- while((nread = HDread(fd_old, buf, (size_t)READ_OLD_BUFSIZE)) > 0)
- HDwrite(fd_new, buf, (size_t)nread);
-
- /* Close files */
- if(HDclose(fd_old) < 0) TEST_ERROR
- if(HDclose(fd_new) < 0) TEST_ERROR
-
+ /* Make a copy of the data file from svn. */
+ if(h5_make_local_copy(FILE_OLD_GROUPS, FILE_OLD_GROUPS_COPY) < 0) TEST_ERROR
/* Open copied file */
- if((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR
+ if((fid = H5Fopen(FILE_OLD_GROUPS_COPY, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
/* Attempt to open "old" group */
if((gid = H5Gopen2(fid, "old", H5P_DEFAULT)) < 0) TEST_ERROR
@@ -794,7 +775,7 @@ no_compact(hid_t fapl2)
if(H5Fclose(fid) < 0) TEST_ERROR
/* Get size of file as empty */
- if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Re-open file */
if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR
@@ -851,12 +832,11 @@ no_compact(hid_t fapl2)
if(H5Fclose(fid) < 0) TEST_ERROR
/* Get size of file as empty */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Verify that file is correct size */
if(file_size != empty_size) TEST_ERROR
-
PASSED();
return 0;
@@ -1006,7 +986,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-old_api(hid_t fapl, const char *driver)
+old_api(hid_t fapl)
{
#ifndef H5_NO_DEPRECATED_SYMBOLS
hid_t fid = (-1); /* File ID */
@@ -1034,11 +1014,8 @@ old_api(hid_t fapl, const char *driver)
/* Close file */
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- /* Avoid size comparisons if we are using the core VFD */
- if(HDstrcmp(driver, "core")) {
- /* Get the size of the file with a "small" heap for group */
- if((small_file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
- } /* end if */
+ /* Get the size of the file with a "small" heap for group */
+ if((small_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Create file */
@@ -1059,20 +1036,16 @@ old_api(hid_t fapl, const char *driver)
/* Close file */
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- /* Avoid size comparisons if we are using the core VFD */
- if(HDstrcmp(driver, "core")) {
- /* Get the size of the file with a "large" heap for group */
- if((large_file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ /* Get the size of the file with a "large" heap for group */
+ if((large_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
- /* Check that the file with a "large" group heap is actually bigger */
- if(large_file_size <= small_file_size) TEST_ERROR
- } /* end if */
+ /* Check that the file with a "large" group heap is actually bigger */
+ if(large_file_size <= small_file_size) TEST_ERROR
PASSED();
#else /* H5_NO_DEPRECATED_SYMBOLS */
/* Shut compiler up */
fapl = fapl;
- driver = driver;
SKIPPED();
puts(" Deprecated API symbols not enabled");
@@ -1092,6 +1065,85 @@ error:
/*-------------------------------------------------------------------------
+ * Function: corrupt_stab_msg
+ *
+ * Purpose: Test that a corrupt symbol table message can be fixed
+ * using the cached symbol table information.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Wednesday, March 18, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+corrupt_stab_msg(void)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t did = (-1); /* Dataset ID */
+
+ TESTING("corrupt symbol table message");
+
+ /* Make a copy of the data file from svn. */
+ if(h5_make_local_copy(CORRUPT_STAB_FILE, CORRUPT_STAB_TMP_FILE) < 0) TEST_ERROR
+
+#ifndef H5_STRICT_FORMAT_CHECKS
+ /* Open temp file through HDF5 library */
+ if((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Open dataset */
+ if((did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Close dataset and file */
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* Now reopen with read only access. This verifies that the issue has been
+ * corrected, as the symbol table message is not patched in read only mode.
+ */
+
+ /* Open file */
+ if((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Open dataset */
+ if((did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Close dataset and file */
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+#else /* H5_STRICT_FORMAT_CHECKS */
+ /* Open file */
+ if((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Verify that an error is thrown when we try to access the dataset */
+ H5E_BEGIN_TRY {
+ did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT);
+ } H5E_END_TRY
+ if(did >= 0) TEST_ERROR
+
+ /* Close file */
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+#endif /* H5_STRICT_FORMAT_CHECKS */
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end old_api() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test groups
@@ -1110,58 +1162,55 @@ error:
int
main(void)
{
- const char *envval = NULL;
-
- /* Don't run this test using the split file driver */
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- hid_t fapl, fapl2; /* File access property list IDs */
- hbool_t new_format; /* Whether to use the new format or not */
- int nerrors = 0;
-
- /* Reset library */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Copy the file access property list */
- if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
-
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- /* Perform basic tests, with old & new style groups */
- nerrors += test_misc((new_format ? fapl2 : fapl), new_format);
- nerrors += test_long((new_format ? fapl2 : fapl), new_format);
- nerrors += test_large((new_format ? fapl2 : fapl), new_format);
- } /* end for */
-
- /* New format group specific tests (require new format features) */
- nerrors += lifecycle(fapl2);
- nerrors += long_compact(fapl2);
- nerrors += read_old(fapl2);
- nerrors += no_compact(fapl2);
- nerrors += gcpl_on_root(fapl2);
-
- /* Old group API specific tests */
- nerrors += old_api(fapl, envval);
-
- /* Close 2nd FAPL */
- H5Pclose(fapl2);
-
- /* Check for test errors */
- if(nerrors)
- goto error;
-
- /* Cleanup */
- puts("All symbol table tests passed.");
- h5_cleanup(FILENAME, fapl);
- } /* end if */
- else
- puts("All symbol table tests skipped - Incompatible with current Virtual File Driver");
+ hid_t fapl, fapl2; /* File access property list IDs */
+ hbool_t new_format; /* Whether to use the new format or not */
+ int nerrors = 0;
+
+ /* Reset library */
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ /* Loop over using new group format */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ /* Perform basic tests, with old & new style groups */
+ nerrors += test_misc((new_format ? fapl2 : fapl), new_format);
+ nerrors += test_long((new_format ? fapl2 : fapl), new_format);
+ nerrors += test_large((new_format ? fapl2 : fapl), new_format);
+ } /* end for */
+
+ /* New format group specific tests (require new format features) */
+ nerrors += lifecycle(fapl2);
+ nerrors += long_compact(fapl2);
+ nerrors += read_old();
+ nerrors += no_compact(fapl2);
+ nerrors += gcpl_on_root(fapl2);
+
+ /* Old group API specific tests */
+ nerrors += old_api(fapl);
+ nerrors += corrupt_stab_msg();
+
+ /* Close 2nd FAPL */
+ H5Pclose(fapl2);
+
+ /* Check for test errors */
+ if(nerrors)
+ goto error;
+
+ puts("All symbol table tests passed.");
+
+ /* Cleanup */
+ if (GetTestCleanup()) {
+ HDremove(FILE_OLD_GROUPS_COPY);
+ HDremove(CORRUPT_STAB_TMP_FILE);
+ }
+ h5_cleanup(FILENAME, fapl);
+
return 0;
error:
diff --git a/test/tarray.c b/test/tarray.c
index 8d739b9..590d48c 100644
--- a/test/tarray.c
+++ b/test/tarray.c
@@ -44,16 +44,9 @@
#define ARRAY3_DIM2 3
/* 1-D dataset with fixed dimensions */
-#define SPACE1_NAME "Space1"
#define SPACE1_RANK 1
#define SPACE1_DIM1 4
-/* 2-D dataset with fixed dimensions */
-#define SPACE2_NAME "Space2"
-#define SPACE2_RANK 2
-#define SPACE2_DIM1 10
-#define SPACE2_DIM2 10
-
/****************************************************************
**
** test_array_atomic_1d(): Test basic array datatype code.
@@ -1952,9 +1945,9 @@ test_compat(void)
/* Check the 1st field's name */
mname=H5Tget_member_name(tid1,0);
CHECK(mname, NULL, "H5Tget_member_name");
- if(HDstrcmp(mname,"i")!=0)
+ if(mname && HDstrcmp(mname,"i")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ if(mname) free(mname);
/* Check the 1st field's offset */
off=H5Tget_member_offset(tid1,0);
@@ -1971,9 +1964,9 @@ test_compat(void)
/* Check the 2nd field's name */
mname=H5Tget_member_name(tid1,1);
CHECK(mname, NULL, "H5Tget_member_name");
- if(HDstrcmp(mname,"f")!=0)
+ if(mname && HDstrcmp(mname,"f")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ if(mname) free(mname);
/* Check the 2nd field's offset */
off=H5Tget_member_offset(tid1,1);
@@ -2016,9 +2009,9 @@ test_compat(void)
/* Check the 3rd field's name */
mname=H5Tget_member_name(tid1,2);
CHECK(mname, NULL, "H5Tget_member_name");
- if(HDstrcmp(mname,"l")!=0)
+ if(mname && HDstrcmp(mname,"l")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ if(mname) free(mname);
/* Check the 3rd field's offset */
off=H5Tget_member_offset(tid1,2);
@@ -2061,9 +2054,9 @@ test_compat(void)
/* Check the 4th field's name */
mname=H5Tget_member_name(tid1,3);
CHECK(mname, NULL, "H5Tget_member_name");
- if(HDstrcmp(mname,"d")!=0)
+ if(mname && HDstrcmp(mname,"d")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ if(mname) free(mname);
/* Check the 4th field's offset */
off=H5Tget_member_offset(tid1,3);
diff --git a/test/tattr.c b/test/tattr.c
index edaebf0..dcf13bc 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -57,7 +57,6 @@
#define CORDER_ITER_STOP 3
/* 3-D dataset with fixed dimensions */
-#define SPACE1_NAME "Space1"
#define SPACE1_RANK 3
#define SPACE1_DIM1 3
#define SPACE1_DIM2 15
@@ -132,6 +131,13 @@ float attr_data5=(float)-5.123; /* Test data for 5th attribute */
#define NATTR_MANY_OLD 350
#define NATTR_MANY_NEW 35000
+#define BUG2_NATTR 100
+#define BUG2_NATTR2 16
+
+#define BUG3_DSET_NAME "dset"
+#define BUG3_DT_NAME "dt"
+#define BUG3_ATTR_NAME "attr"
+
/* Attribute iteration struct */
typedef struct {
H5_iter_order_t order; /* Direction of iteration */
@@ -998,7 +1004,7 @@ test_attr_scalar_read(hid_t fapl)
if(!FLT_ABS_EQUAL(rdata, attr_data5))
printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n",
"H5Aread", attr_data5, rdata, (int)__LINE__, __FILE__);
-
+
/* Get the attribute's dataspace */
sid = H5Aget_space(attr);
CHECK(sid, FAIL, "H5Aget_space");
@@ -1631,7 +1637,7 @@ test_attr_dtype_shared(hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -1770,7 +1776,7 @@ test_attr_dtype_shared(hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dtype_shared() */
@@ -1781,12 +1787,12 @@ test_attr_dtype_shared(hid_t fapl)
** one ID handles.
**
****************************************************************/
-static int
+static void
test_attr_duplicate_ids(hid_t fapl)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
- hid_t gid1, gid2; /* Group ID */
+ hid_t gid1, gid2; /* Group ID */
hid_t sid1,sid2; /* Dataspace ID */
hid_t attr, attr2; /* Attribute ID */
hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
@@ -1811,7 +1817,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT,
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
@@ -1824,7 +1830,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Open the attribute just created and get a second ID */
- attr2 = H5Aopen(dataset, ATTR1_NAME, H5P_DEFAULT);
+ attr2 = H5Aopen(dataset, ATTR1_NAME, H5P_DEFAULT);
CHECK(attr2, FAIL, "H5Aopen");
/* Close attribute */
@@ -1844,7 +1850,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/*-----------------------------------------------------------------------------------
- * Reopen the file and verify the fill value for attribute. Also write
+ * Reopen the file and verify the fill value for attribute. Also write
* some real data.
*/
@@ -1951,7 +1957,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/*-----------------------------------------------------------------------------------
- * Verify that the attribute being pointed to by different paths shares
+ * Verify that the attribute being pointed to by different paths shares
* the same data.
*/
/* Open file */
@@ -1963,7 +1969,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(gid1, FAIL, "H5Gcreate2");
/* Create hard link to the first group */
- ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT,
+ ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT,
H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_hard");
@@ -2070,7 +2076,7 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, check_name);
VERIFY(name_len, HDstrlen(attrname), "H5Aget_name");
if(HDstrcmp(check_name, attrname))
- TestErrPrintf("attribute name different: attr_name = '%s', should be '%s'\n", check_name, attrname);
+ TestErrPrintf("attribute name different: attrname = '%s', should be '%s'\n", check_name, attrname);
/* Read data from the attribute */
ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
@@ -2125,7 +2131,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -2216,7 +2222,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_create() */
@@ -2256,7 +2262,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -2355,7 +2361,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_open() */
@@ -2396,7 +2402,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -2533,7 +2539,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_delete() */
@@ -2575,7 +2581,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -2692,7 +2698,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_rename() */
@@ -2734,7 +2740,7 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -2822,7 +2828,7 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_unlink() */
@@ -2862,7 +2868,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -2987,7 +2993,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_limits() */
@@ -3003,7 +3009,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
{
hid_t fid; /* HDF5 File ID */
hid_t dataset; /* Dataset ID */
- hid_t gid1, gid2; /* Group ID */
+ hid_t gid1, gid2; /* Group ID */
hid_t sid, sid2; /* Dataspace ID */
hid_t attr, attr2, add_attr; /* Attribute ID */
hid_t dcpl; /* Dataset creation property list ID */
@@ -3096,7 +3102,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
/* Open the attribute just created and get a second ID */
- attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT);
+ attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT);
CHECK(attr2, FAIL, "H5Aopen");
/* Close attribute */
@@ -3105,7 +3111,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
ret = H5Aclose(attr2);
CHECK(ret, FAIL, "H5Aclose");
-
+
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
@@ -3115,7 +3121,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/*-----------------------------------------------------------------------------------
- * Reopen the file and verify the fill value for attribute. Also write
+ * Reopen the file and verify the fill value for attribute. Also write
* some real data.
*/
/* Open file */
@@ -3141,7 +3147,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Verify values read in */
for(i = 0; i < ATTR1_DIM1; i++)
if(0 != read_data1[i])
- TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__,
+ TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__,
i, read_data1[i]);
/* Open attribute for the second time */
@@ -3230,7 +3236,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/*-----------------------------------------------------------------------------------
* Open the attribute by index. Verify the data is shared when the attribute
- * is opened twice.
+ * is opened twice.
*/
/* Open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
@@ -3245,12 +3251,12 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
/* Open first attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4,
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Open attribute for the second time */
- attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4,
+ attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
@@ -3264,7 +3270,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Verify values read in */
if(read_scalar != scalar_data)
- TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
+ TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
__LINE__, read_scalar, scalar_data);
/* Close attribute */
@@ -3283,7 +3289,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/*-----------------------------------------------------------------------------------
- * Open one attribute. As it remains open, delete some attributes. The
+ * Open one attribute. As it remains open, delete some attributes. The
* attribute storage should switch from dense to compact. Then open the
* same attribute for the second time and verify that the attribute data
* is shared.
@@ -3301,13 +3307,13 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
/* Open attribute of the dataset for the first time */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2,
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Delete a few attributes until the storage switches to compact */
for(u = max_compact; u >= min_dense - 1; u--) {
- ret = H5Adelete_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u,
+ ret = H5Adelete_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u,
H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_idx");
}
@@ -3317,7 +3323,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
/* Open attribute for the second time */
- attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2,
+ attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
@@ -3331,7 +3337,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Verify values read in */
if(read_scalar != scalar_data)
- TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
+ TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
__LINE__, read_scalar, scalar_data);
/* Close attribute */
@@ -3350,7 +3356,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/*-----------------------------------------------------------------------------------
- * Open one attribute. As it remains open, create some attributes. The
+ * Open one attribute. As it remains open, create some attributes. The
* attribute storage should switch from compact to dense. Then open the
* same attribute for the second time and verify that the attribute data
* is shared.
@@ -3368,7 +3374,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
/* Open attribute of the dataset for the first time */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3,
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
@@ -3393,7 +3399,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
/* Open attribute for the second time */
- attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3,
+ attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
@@ -3407,7 +3413,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Verify values read in */
if(read_scalar != scalar_data)
- TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
+ TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
__LINE__, read_scalar, scalar_data);
/* Close attribute */
@@ -3426,7 +3432,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/*-----------------------------------------------------------------------------------
- * Verify that the attribute being pointed to by different paths shares
+ * Verify that the attribute being pointed to by different paths shares
* the same data.
*/
/* Open file */
@@ -3438,7 +3444,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(gid1, FAIL, "H5Gcreate2");
/* Create hard link to the first group */
- ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT,
+ ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT,
H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_hard");
@@ -3555,7 +3561,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -3780,7 +3786,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_big() */
@@ -3821,7 +3827,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -3998,7 +4004,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_null_space() */
@@ -5286,13 +5292,13 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
ret = H5Dclose(dset3);
CHECK(ret, FAIL, "H5Dclose");
- /* Close dataspace */
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Sclose");
-
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
} /* test_attr_corder_transition() */
@@ -8077,7 +8083,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -8297,7 +8303,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* end for */
@@ -8403,7 +8409,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -8739,7 +8745,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* end for */
@@ -8844,7 +8850,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -9103,7 +9109,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* end for */
@@ -9208,7 +9214,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
+ empty_filesize = h5_get_file_size(FILENAME, fapl);
if(empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -9285,7 +9291,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
attr = H5Acreate2(dataset, attrname, attr_tid, big_sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
- /* Check that attribute is shared */
+ /* ChecFk that attribute is shared */
is_shared = H5A_is_shared_test(attr);
VERIFY(is_shared, TRUE, "H5A_is_shared_test");
@@ -9453,7 +9459,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check size of file */
- filesize = h5_get_file_size(FILENAME);
+ filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* end for */
@@ -9500,7 +9506,7 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
ret = H5Gclose(gid);
CHECK(ret, FAIL, "H5Gclose");
-
+
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
@@ -9523,7 +9529,7 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
/* Create attribute on first group */
aid = H5Acreate2(gid, ATTR7_NAME, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
-
+
ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
@@ -9556,7 +9562,7 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
/* Create another attribute on first group */
aid = H5Acreate2(gid, ATTR8_NAME, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
-
+
ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
@@ -9582,7 +9588,7 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
/* Re-create first attribute */
aid = H5Acreate2(gid, ATTR7_NAME, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
-
+
ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
@@ -9593,7 +9599,7 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
/* Re-create second attribute */
aid = H5Acreate2(gid, ATTR8_NAME, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
-
+
ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
@@ -9611,6 +9617,593 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
/****************************************************************
**
+** test_attr_bug2(): Test basic H5A (attribute) code.
+** Tests deleting a large number of attributes with the
+** intention of creating a null message with a size that
+** is too large. This routine deletes every other
+** attribute, but the original bug could also be
+** reproduced by deleting every attribute except a few to
+** keep the chunk open.
+**
+****************************************************************/
+static void
+test_attr_bug2(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hid_t gcpl; /* Group creation property list */
+ hsize_t dims[2] = {10, 100}; /* Attribute dimensions */
+ char aname[4]; /* Attribute name */
+ unsigned i; /* index */
+ herr_t ret; /* Generic return status */
+ htri_t tri_ret; /* htri_t return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Allocating and De-allocating Attributes in Unusual Way\n"));
+
+ /* Create group creation property list */
+ gcpl = H5Pcreate(H5P_GROUP_CREATE);
+ CHECK(gcpl, FAIL, "H5Pcreate");
+
+ /* Prevent the library from switching to dense attribute storage */
+ /* Not doing this with the latest format actually triggers a different bug.
+ * This will be tested here as soon as it is fixed. -NAF
+ */
+ ret = H5Pset_attr_phase_change (gcpl, BUG2_NATTR+10, BUG2_NATTR+5);
+ CHECK(ret, FAIL, "H5Pset_attr_phase_change");
+
+ /* Create dataspace ID for attributes */
+ sid = H5Screate_simple(2, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create main group to operate on */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ gid = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, gcpl, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Create attributes on group */
+ for (i=0; i<BUG2_NATTR; i++) {
+ sprintf(aname, "%03u", i);
+ aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ }
+
+ /* Delete every other attribute */
+ for (i=1; i<BUG2_NATTR; i+=2) {
+ sprintf(aname, "%03u", i);
+ ret = H5Adelete(gid, aname);
+ CHECK(ret, FAIL, "H5Adelete");
+ }
+
+ /* Close IDs */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Reopen file and group */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen");
+
+ /* Open an attribute in the middle */
+ i = (BUG2_NATTR / 4) * 2;
+ sprintf(aname, "%03u", i);
+ aid = H5Aopen(gid, aname, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Aopen");
+
+ /* Verify that the attribute has the correct datatype */
+ tid = H5Aget_type(aid);
+ CHECK(tid, FAIL, "H5Aget_type");
+
+ tri_ret = H5Tequal(tid, H5T_STD_I32LE);
+ VERIFY(tri_ret, TRUE, "H5Tequal");
+
+ /* Close IDs */
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Now test a variation on this bug - where either the size of chunk 0 goes
+ * down a "notch" or two, or chunk 1 becomes completely null at the same
+ * time that a null message that is too large is formed */
+ dims[0] = 25;
+ dims[1] = 41; /* 1025*4 byte attribute size */
+
+ /* Create dataspace ID for attributes */
+ sid = H5Screate_simple(2, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create main group to operate on */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ gid = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, gcpl, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Create attributes on group */
+ for (i=0; i<BUG2_NATTR2; i++) {
+ sprintf(aname, "%03u", i);
+ aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ }
+
+ /* Delete every other attribute */
+ for (i=0; i<BUG2_NATTR2; i++) {
+ sprintf(aname, "%03u", i);
+ ret = H5Adelete(gid, aname);
+ CHECK(ret, FAIL, "H5Adelete");
+ }
+
+ /* Close IDs */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Pclose(gcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+} /* test_attr_bug2() */
+
+/****************************************************************
+**
+** test_attr_bug3(): Test basic H5A (attribute) code.
+** Tests creating and deleting attributes which use a
+** datatype and/or dataspace stored in the same object
+** header.
+**
+****************************************************************/
+static void
+test_attr_bug3(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t aid1, aid2; /* Attribute IDs */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t did; /* Dataset ID */
+ hsize_t dims1[2] = {2, 2},
+ dims2[2] = {3, 3}; /* Dimensions */
+ int wdata1[2][2];
+ unsigned wdata2[3][3]; /* Write buffers */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Attributes in the Same Header as their Datatypes\n"));
+
+ /* Create dataspaces */
+ sid1 = H5Screate_simple(2, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+ sid2 = H5Screate_simple(2, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Create file to operate on */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create datatypes and commit tid1 */
+ tid1 = H5Tcopy(H5T_STD_I16BE);
+ CHECK(tid1, FAIL, "H5Tcopy");
+ tid2 = H5Tcopy(H5T_STD_U64LE);
+ CHECK(tid1, FAIL, "H5Tcopy");
+ ret = H5Tcommit2(fid, "dtype", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit2");
+
+ /* Create dataset */
+ did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dcreate2");
+
+ /* Create attribute on datatype, using that datatype as its datatype */
+ aid1 = H5Acreate2(tid1, "attr", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid1, FAIL, "H5Acreate2");
+
+ /* Create attribute on dataset, using its datatype and dataspace */
+ aid2 = H5Acreate2(did, "attr", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid2, FAIL, "H5Acreate2");
+
+ /* Close attributes */
+ ret = H5Aclose(aid1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aid2);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Reopen attributes */
+ aid1 = H5Aopen(tid1, "attr", H5P_DEFAULT);
+ CHECK(aid1, FAIL, "H5Aopen");
+ aid2 = H5Aopen(did, "attr", H5P_DEFAULT);
+ CHECK(aid2, FAIL, "H5Aopen");
+
+ /* Write data to the attributes (the data is uninitialized, we only care
+ * that H5Awrite succeeds for now) */
+ ret = H5Awrite(aid1, H5T_NATIVE_INT, wdata1[0]);
+ CHECK(ret, FAIL, "H5Awrite");
+ ret = H5Awrite(aid2, H5T_NATIVE_UINT, wdata2[0]);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Close attributes */
+ ret = H5Aclose(aid1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aid2);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Delete attributes */
+ ret = H5Adelete(tid1, "attr");
+ CHECK(ret, FAIL, "H5Adelete");
+ ret = H5Adelete(did, "attr");
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Recreate attributes */
+ aid1 = H5Acreate2(tid1, "attr", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid1, FAIL, "H5Acreate2");
+ aid2 = H5Acreate2(did, "attr", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid2, FAIL, "H5Acreate2");
+
+ /* Delete attributes (note they are still open) */
+ ret = H5Adelete(tid1, "attr");
+ CHECK(ret, FAIL, "H5Adelete");
+ ret = H5Adelete(did, "attr");
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Close dataspaces and transient datatype */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close dataset and committed datatype */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Delete dataset and committed datatype */
+ ret = H5Ldelete(fid, "dtype", H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Ldelete(fid, "dset", H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close attributes */
+ ret = H5Aclose(aid1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aid2);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_attr_bug3() */
+
+/****************************************************************
+**
+** test_attr_bug4(): Test basic H5A (attribute) code.
+** Attempts to trigger a bug which would result in being
+** unable to add an attribute to a named datatype. This
+** happened when an object header chunk was too small to
+** hold a continuation message and could not be extended.
+**
+****************************************************************/
+static void
+test_attr_bug4(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid1, aid2, aid3; /* Attribute IDs */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hid_t did; /* Dataset ID */
+ hsize_t dims[1] = {5}; /* Attribute dimensions */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing that attributes can always be added to named datatypes\n"));
+
+ /* Create dataspace */
+ sid = H5Screate_simple(1, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Open root group */
+ gid = H5Gopen2(fid, "/", H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Create committed datatype */
+ tid = H5Tcopy(H5T_STD_I32LE);
+ CHECK(tid, FAIL, "H5Tcopy");
+ ret = H5Tcommit2(fid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit2");
+
+ /* Create dataset */
+ did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dcreate2");
+
+ /* Create attributes on group and dataset */
+ aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid1, FAIL, "H5Acreate2");
+ aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid2, FAIL, "H5Acreate2");
+
+ /* Create attribute on datatype (this is the main test) */
+ aid3 = H5Acreate2(tid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid3, FAIL, "H5Acreate2");
+
+ /* Close IDs */
+ ret = H5Aclose(aid3);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ ret = H5Aclose(aid2);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ ret = H5Aclose(aid1);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* test_attr_bug4() */
+
+/****************************************************************
+**
+** test_attr_bug5(): Test basic H5A (attribute) code.
+** Tests opening an attribute multiple times through
+** objects opened through different file handles.
+**
+****************************************************************/
+static void
+test_attr_bug5(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid1, fid2; /* File IDs */
+ hid_t gid1, gid2; /* Group IDs */
+ hid_t did1, did2; /* Dataset IDs */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t aidg1, aidg2,
+ aidd1, aidd2,
+ aidt1, aidt2; /* Attribute IDs */
+ hid_t sid; /* Dataspace ID */
+ hsize_t dims[1] = {5}; /* Attribute dimensions */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Opening an Attribute Through Multiple Files Concurrently\n"));
+
+ /* Create dataspace ID for attributes and datasets */
+ sid = H5Screate_simple(1, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Open root group */
+ gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT);
+ CHECK(gid1, FAIL, "H5Gopen2");
+
+ /* Create and commit datatype */
+ tid1 = H5Tcopy(H5T_STD_I32LE);
+ CHECK(tid1, FAIL, "H5Tcopy");
+ ret = H5Tcommit2(fid1, BUG3_DT_NAME, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit2");
+
+ /* Create dataset */
+ did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(did1, FAIL, "H5Dcreate2");
+
+ /* Create attribute on root group */
+ aidg1 = H5Acreate2(gid1, BUG3_ATTR_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aidg1, FAIL, "H5Acreate2");
+
+ /* Create attribute on dataset */
+ aidd1 = H5Acreate2(did1, BUG3_ATTR_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aidd1, FAIL, "H5Acreate2");
+
+ /* Create attribute on datatype */
+ aidt1 = H5Acreate2(tid1, BUG3_ATTR_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aidt1, FAIL, "H5Acreate2");
+
+ /* Close all IDs */
+ ret = H5Aclose(aidt1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidd1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidg1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Dclose(did1);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Gclose(gid1);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Open file twice */
+ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid1, FAIL, "H5Fopen");
+ fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid2, FAIL, "H5Fopen");
+
+ /* Open the root group twice */
+ gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT);
+ CHECK(gid1, FAIL, "H5Gopen2");
+ gid2 = H5Gopen2(fid2, "/", H5P_DEFAULT);
+ CHECK(gid2, FAIL, "H5Gopen2");
+
+ /* Open the root group attribute twice */
+ aidg1 = H5Aopen(gid1, BUG3_ATTR_NAME, H5P_DEFAULT);
+ CHECK(aidg1, FAIL, "H5Aopen");
+ aidg2 = H5Aopen(gid2, BUG3_ATTR_NAME, H5P_DEFAULT);
+ CHECK(aidg1, FAIL, "H5Aopen");
+
+ /* Open the dataset twice */
+ did1 = H5Dopen2(fid1, BUG3_DSET_NAME, H5P_DEFAULT);
+ CHECK(did1, FAIL, "H5Dopen2");
+ did2 = H5Dopen2(fid2, BUG3_DSET_NAME, H5P_DEFAULT);
+ CHECK(did2, FAIL, "H5Dopen2");
+
+ /* Open the dataset attribute twice */
+ aidd1 = H5Aopen(did1, BUG3_ATTR_NAME, H5P_DEFAULT);
+ CHECK(aidd1, FAIL, "H5Aopen");
+ aidd2 = H5Aopen(did2, BUG3_ATTR_NAME, H5P_DEFAULT);
+ CHECK(aidd1, FAIL, "H5Aopen");
+
+ /* Open the datatype twice */
+ tid1 = H5Topen2(fid1, BUG3_DT_NAME, H5P_DEFAULT);
+ CHECK(tid1, FAIL, "H5Topen2");
+ tid2 = H5Topen2(fid2, BUG3_DT_NAME, H5P_DEFAULT);
+ CHECK(tid2, FAIL, "H5Topen2");
+
+ /* Open the datatype attribute twice */
+ aidt1 = H5Aopen(tid1, BUG3_ATTR_NAME, H5P_DEFAULT);
+ CHECK(aidt1, FAIL, "H5Aopen");
+ aidt2 = H5Aopen(tid2, BUG3_ATTR_NAME, H5P_DEFAULT);
+ CHECK(aidt2, FAIL, "H5Aopen");
+
+ /* Close all attributes */
+ ret = H5Aclose(aidg1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidg2);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidd1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidd2);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidt1);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Aclose(aidt2);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Close root groups */
+ ret = H5Gclose(gid1);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Close datasets */
+ ret = H5Dclose(did1);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Dclose(did2);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close datatypes */
+ ret = H5Tclose(tid1);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Tclose(tid2);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close files */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Fclose(fid2);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_attr_bug5() */
+
+/****************************************************************
+**
+** test_attr_bug6(): Test basic H5A (attribute) code.
+** Tests if reading an empty attribute is OK.
+**
+****************************************************************/
+static void
+test_attr_bug6(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid1, aid2; /* Attribute IDs */
+ hid_t sid; /* Dataspace ID */
+ hsize_t dims[ATTR1_RANK] = {ATTR1_DIM1}; /* Attribute dimensions */
+ int intar[ATTR1_DIM1]; /* Data reading buffer */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing that empty attribute can be read\n"));
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Open root group */
+ gid = H5Gopen2(fid, "/", H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+
+ /* Create dataspace */
+ sid = H5Screate_simple(1, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create attribute on group */
+ aid1 = H5Acreate2(gid, ATTR1_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid1, FAIL, "H5Acreate2");
+
+ ret = H5Aclose(aid1);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Open the attribute again */
+ aid2 = H5Aopen(gid, ATTR1_NAME, H5P_DEFAULT);
+ CHECK(aid2, FAIL, "H5Aopen");
+
+ ret = H5Aread(aid2, H5T_NATIVE_INT, intar);
+ CHECK(ret, FAIL, "H5Aread");
+
+ /* Close IDs */
+ ret = H5Aclose(aid2);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+}
+
+/****************************************************************
+**
** test_attr(): Main H5A (attribute) testing routine.
**
****************************************************************/
@@ -9750,6 +10343,11 @@ test_attr(void)
/* Tests that address specific bugs */
test_attr_bug1(my_fcpl, my_fapl); /* Test odd allocation operations */
+ test_attr_bug2(my_fcpl, my_fapl); /* Test many deleted attributes */
+ test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */
+ test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */
+ test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
+ test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */
} /* end for */
} /* end if */
else {
@@ -9769,6 +10367,11 @@ test_attr(void)
/* Tests that address specific bugs */
test_attr_bug1(fcpl, my_fapl); /* Test odd allocation operations */
+ test_attr_bug2(fcpl, my_fapl); /* Test many deleted attributes */
+ test_attr_bug3(fcpl, my_fapl); /* Test "self referential" attributes */
+ test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */
+ test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
+ test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */
} /* end else */
} /* end for */
diff --git a/test/tcheck_version.c b/test/tcheck_version.c
new file mode 100644
index 0000000..91d98ef
--- /dev/null
+++ b/test/tcheck_version.c
@@ -0,0 +1,121 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This tests the h5check_version() function.
+ *
+ * The default is to call the h5check_version() with the version information
+ * in the header file and should incur no warnings or abort.
+ * Options provided to call it with incorrect versions to test
+ * if it will indeed issue the warning message and aborts. With environment
+ * variable $HDF5_DISABLE_VERSION_CHECK sets to 1, it should issue warnings
+ * but no abort. If it is 2, no warning or abort.
+ *
+ * Programmer: Albert Cheng
+ * September 20, 2009
+ * Modifications:
+ * Added abort signal intercept. AKC - 2009/10/16 -
+ */
+
+#include "h5test.h"
+
+#define progname "tcheck_version"
+
+/* prototypes */
+void showhelp(void);
+void parse(int ac, char **av);
+void abort_intercept (int UNUSED sig);
+
+/* global variables */
+unsigned major = H5_VERS_MAJOR;
+unsigned minor = H5_VERS_MINOR;
+unsigned release = H5_VERS_RELEASE;
+
+void
+showhelp(void)
+{
+ printf("Usage: " progname " [-h] [-t<vers>]\n");
+ printf("\t-h\tShow this page and version information\n");
+ printf("\t-t<vers>: Test by changing (adding 1 to) the <vers> to trigger\n");
+ printf("\t\t the warning. <vers> can be:\n");
+ printf("\t\t\tM for Major version number (%d)\n", H5_VERS_MAJOR);
+ printf("\t\t\tm for Minor version number (%d)\n", H5_VERS_MINOR);
+ printf("\t\t\tr for Release number (%d)\n", H5_VERS_RELEASE);
+}
+
+
+void
+parse(int ac, char **av)
+{
+ char *pt;
+
+ while (--ac > 0){
+ pt = *(++av);
+ if (*pt != '-') {
+ fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ exit(1);
+ }else{
+ switch(*(++pt)) {
+ case 't': /* option -t */
+ switch(*(++pt)) {
+ case 'M':
+ major++;
+ break;
+ case 'm':
+ minor++;
+ break;
+ case 'r':
+ release++;
+ break;
+ default:
+ fprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av);
+ exit(1);
+ }
+ break;
+ case 'h': /* help page */
+ showhelp();
+ exit(0);
+ default:
+ fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ exit(1);
+ }
+ }
+ }
+}
+
+/* Handler for SIGABRT - catch the abort signal supposedly from check_version()
+ * and exit(6). Would have used 134 is the return code in Unix systems
+ * but some systems (e.g., poe in AIX interprets exit(134) the same as
+ * if the process has really been interrupted by the abort signal and prints
+ * extra messages that confuse test script that is looking for matching output.
+ * This handles the abort signal instead letting it interrupt the OS because
+ * some systems may produce extra messages and/or produce core dump.
+ * This tries to eliminate those side effects.
+ */
+void
+abort_intercept (int UNUSED sig)
+{
+ HDexit(6);
+}
+
+int
+main(int ac, char **av)
+{
+ parse(ac, av);
+ HDsignal(SIGABRT, &abort_intercept);
+ H5check_version(major, minor, release);
+ HDsignal(SIGABRT, SIG_DFL);
+ return 0;
+}
diff --git a/test/tconfig.c b/test/tconfig.c
index d4d7d4b..6b8fd84 100644
--- a/test/tconfig.c
+++ b/test/tconfig.c
@@ -47,6 +47,7 @@
/* local routine prototypes */
void test_config_ctypes(void);
+void test_exit_definitions(void);
/*-------------------------------------------------------------------------
@@ -60,7 +61,12 @@ void test_config_ctypes(void);
* September 25, 2001
*
* Modifications:
- *
+ * Raymond Lu
+ * 16 Dec 2009
+ * On Boeing's OpenVMS, the value of EXIT_FAILURE is 268435458.
+ * (The test is in test_exit_definitions.) Their document says
+ * it's supposed to be 2. I commented it out for OpenVMS for
+ * further consideration.
*-------------------------------------------------------------------------
*/
void
@@ -69,6 +75,9 @@ test_configure(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing configure definitions\n"));
test_config_ctypes();
+#ifndef H5_VMS
+ test_exit_definitions();
+#endif
}
@@ -127,7 +136,7 @@ test_config_ctypes(void)
/* standard C99 basic types */
#if H5_SIZEOF_LONG_LONG > 0
- vrfy_cint_type(long_long, unsigned long_long, H5_SIZEOF_LONG_LONG);
+ vrfy_cint_type(long long, unsigned long long, H5_SIZEOF_LONG_LONG);
#endif
#if H5_SIZEOF_INT8_T > 0
@@ -202,3 +211,31 @@ test_config_ctypes(void)
#endif
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_exit_definitions
+ *
+ * Purpose: test the exit macros values
+ *
+ * Return: none (error is fed back via global variable num_errs)
+ *
+ * Programmer: Albert Cheng
+ * October 12, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+test_exit_definitions(void)
+{
+ /* Verify the EXIT_SUCCESS and EXIT_FAILURE are 0 and 1 respectively. */
+ /* This should be true for POSIX compliant systems. */
+ if (EXIT_SUCCESS != 0) \
+ TestErrPrintf("Error: EXIT_SUCCESS is %d, should be %d\n", \
+ EXIT_SUCCESS, 0);
+ if (EXIT_FAILURE != 1) \
+ TestErrPrintf("Error: EXIT_FAILURE is %d, should be %d\n", \
+ EXIT_FAILURE, 1);
+}
diff --git a/test/tcoords.c b/test/tcoords.c
index 998a598..306c6b2 100644
--- a/test/tcoords.c
+++ b/test/tcoords.c
@@ -18,7 +18,7 @@
* Test program: tcoords
*
* Test the element coordinates for dataspace selection. For
-* chunked dataset, when the hyperslab selection of some
+* chunked dataset, when the hyperslab selection of some
* dimensions is full, the library optimize it by "flattenning"
* the fully selected dimensions. This program tests if the
* coordinates of selected elements are correctly calculated.
@@ -40,9 +40,9 @@ int da_buffer[2][3][6][2];
/***********************************************************
**
-** test_singleEnd_selElements(): Test element selection of only
+** test_singleEnd_selElements(): Test element selection of only
** one block.
-**
+**
*************************************************************/
static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked)
{
@@ -53,7 +53,7 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked)
int i, j, k;
hsize_t da_dims[4] = { 2, 3, 6, 2 };
hsize_t da_chunksize[4] = { 1, 3, 3, 2 };
-
+
/* For testing the full selection in the fastest-growing end */
int mem1_buffer[1][1][6][2];
hsize_t mem1_dims[4] = { 1, 1, 6, 2 };
@@ -139,11 +139,11 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked)
ret = H5Dclose(did);
CHECK(ret, FAIL, "H5Dclose");
-
+
/* ****** Case 1: ******
* Testing the full selection in the fastest-growing end */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
elmts_numb = 12;
@@ -176,7 +176,7 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked)
/* ****** Case 2: ******
* Testing the full selection in the slowest-growing end */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
elmts_numb = 6;
@@ -209,7 +209,7 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked)
/* ****** Case 3: ******
* Testing the full selection in the middle dimensions */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
elmts_numb = 18;
@@ -251,7 +251,7 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked)
**
** test_singleEnd_selHyperslab(): Test full hyperslab selection
** of only one block.
-**
+**
*************************************************************/
static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked)
{
@@ -298,7 +298,7 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked)
/* ****** Case 1: ******
* Testing the full selection in the fastest-growing end */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem1_start, mem1_stride, mem1_count, mem1_block);
@@ -329,7 +329,7 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked)
/* ****** Case 2: ******
* Testing the full selection in the slowest-growing end */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem2_start, mem2_stride, mem2_count, mem2_block);
@@ -360,7 +360,7 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked)
/* ****** Case 3: ******
* Testing the full selection in the middle dimensions */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem3_start, mem3_stride, mem3_count, mem3_block);
@@ -397,9 +397,9 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked)
/***********************************************************
**
-** test_multiple_end(): Test full hyperslab selection of
+** test_multiple_end(): Test full hyperslab selection of
** multiple blocks.
-**
+**
*************************************************************/
static void test_multiple_ends(hid_t file, hbool_t is_chunked)
{
@@ -479,7 +479,7 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked)
for(l=0; l<4; l++)
for(m=0; m<2; m++)
for(n=0; n<3; n++)
- for(p=0; p<6; p++) {
+ for(p=0; p<6; p++) {
data_buf[i][j][k][l][m][n][p][0] = i*1000000 + j*100000 + k*10000 + l*1000 + m*100 + n*10 + p;
data_buf[i][j][k][l][m][n][p][1] = i*1000000 + j*100000 + k*10000 + l*1000 + m*100 + n*10 + p + 1;
}
@@ -493,7 +493,7 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked)
/* ****** Case 1: ******
* Testing the full selections in the fastest-growing end and in the middle dimensions*/
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem1_start, mem1_stride, mem1_count, mem1_block);
@@ -525,7 +525,7 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked)
/* ****** Case 2: ******
* Testing the full selections in the slowest-growing end and in the middle dimensions*/
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem2_start, mem2_stride, mem2_count, mem2_block);
@@ -557,7 +557,7 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked)
/* ****** Case 3: ******
* Testing two unadjacent full selections in the middle dimensions */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem3_start, mem3_stride, mem3_count, mem3_block);
@@ -589,7 +589,7 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked)
/* ****** Case 4: ******
* Testing the full selections in the fastest-growing end and the slowest-growing end */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem4_start, mem4_stride, mem4_count, mem4_block);
@@ -620,10 +620,10 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked)
/* ****** Case 5: ******
- * Testing the full selections in the fastest-growing end and the slowest-growing end,
+ * Testing the full selections in the fastest-growing end and the slowest-growing end,
* and also in the middle dimensions */
did = H5Dopen2(file, dset_name, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dopen");
+ CHECK(did, FAIL, "H5Dopen2");
/* Select the elements in the dataset */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem5_start, mem5_stride, mem5_count, mem5_block);
diff --git a/test/testcheck_version.sh.in b/test/testcheck_version.sh.in
new file mode 100644
index 0000000..6e80654
--- /dev/null
+++ b/test/testcheck_version.sh.in
@@ -0,0 +1,258 @@
+#! /bin/sh
+#
+# 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.
+
+#
+# Tests for the H5check_version function.
+#
+# Programmer: Albert Cheng
+# Sep 28, 2009
+
+# Variables filled in by the configure process.
+# Determine the configure options of the hdf5 library and executables.
+Shared_Lib=@enable_shared@
+Static_Lib=@enable_static@
+Static_exec=@STATIC_EXEC@
+
+CMP='cmp -s'
+DIFF='diff -c'
+RM='rm -f'
+
+# Function definitions
+#
+# Show the purpose of this test script and a note about the abort messages.
+PURPOSE() {
+ echo "Tests for the H5check_version function."
+ echo "Note that abort messages may appear due to the expected termination"
+ echo "of the program when it is tested with mis-matched version numnbers."
+}
+
+# Print a line-line message left justified in a field of 70 characters.
+#
+LINEMSG() {
+ SPACES=" "
+ echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+
+# Print a "SKIP" message
+SKIP() {
+ LINEMSG $*
+ echo " -SKIP-"
+}
+
+
+# Print warning message of version mismatch.
+WarnMesg(){
+ echo "Warning! ***HDF5 library version mismatched error***"
+ echo "The HDF5 header files used to compile this application do not match"
+ echo "the version used by the HDF5 library to which this application is linked."
+ echo "Data corruption or segmentation faults may occur if the application continues."
+ echo "This can happen when an application was compiled by one version of HDF5 but"
+ echo "linked with a different version of static or shared HDF5 library."
+ echo "You should recompile the application or check your shared library related"
+ echo "settings such as 'LD_LIBRARY_PATH'."
+ echo "You can, at your own risk, disable this warning by setting the environment"
+ echo "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'."
+ echo "Setting it to 2 or higher will suppress the warning messages totally."
+ echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease"
+ test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings
+ echo "Bye..."
+}
+
+
+# Print warning message2 of version mismatch.
+WarnMesg2(){
+ echo "Warning! ***HDF5 library version mismatched error***"
+ echo "The HDF5 header files used to compile this application do not match"
+ echo "the version used by the HDF5 library to which this application is linked."
+ echo "Data corruption or segmentation faults may occur if the application continues."
+ echo "This can happen when an application was compiled by one version of HDF5 but"
+ echo "linked with a different version of static or shared HDF5 library."
+ echo "You should recompile the application or check your shared library related"
+ echo "settings such as 'LD_LIBRARY_PATH'."
+ echo "'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will"
+ echo "continue at your own risk."
+ echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease"
+ test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings
+}
+
+
+# Run a test and print PASS or *FAIL*. If a test fails then increment
+# the `nerrors' global variable and (if $verbose is set) display the
+# difference between the actual output and the expected output. The
+# expected output generated according to the parameter values and compared
+# against actual output.
+# The expected and actual output files are removed unless $HDF5_NOCLEANUP
+# has a non-zero value.
+# $1: the set value of $HDF5_DISABLE_VERSION_CHECK. (unset means not to set
+# it at all.
+# $2: Change the version number(s) to cause a mismatch. (none means no
+# mismatch).
+#
+# Expected results:
+# Value of $HDF5_DISABLE_VERSION_CHECK
+# unset "" -1 0 1 2 3
+# Matched OK OK OK OK OK OK OK
+# Mismatched W/A W/A W/A W/A W2/OK OK W2/OK
+# Result codes:
+# OK: No warning, exit 0.
+# W/A: Warning, abort and exit non-0.
+# W2/OK: Different Warning, exit 0.
+#
+# Implemented only exit code matching. Still need to match output.
+TESTING() {
+ DEBUGPRINT command is $0 $*
+ TEST_NAME=tcheck_version # The test name
+ TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary
+
+ expect=${TEST_NAME}_expect.out
+ actual=${TEST_NAME}_actual.out
+ actual_err=${TEST_NAME}_actual.err
+ arguments=
+
+ h5DisableVersion="$1"
+ wrongversionnumbers="$2"
+ xxh5versmajor=$h5versmajor
+ xxh5versminor=$h5versminor
+ xxh5versrelease=$h5versrelease
+
+ if [ "$h5DisableVersion" = unset ]; then
+ envcmd="" # noop
+ else
+ envcmd="env HDF5_DISABLE_VERSION_CHECK=$h5DisableVersion"
+ fi
+
+ if [ "$wrongversionnumbers" = none ]; then
+ # OK: No warning, exit 0
+ cp /dev/null $expect
+ expect_code=0
+ else
+ arguments=-t"$wrongversionnumbers"
+ # calculate mismatched version numbers by listing.
+ case $wrongversionnumbers in
+ "M") xxh5versmajor=`expr $h5versmajor + 1`
+ ;;
+ "m") xxh5versminor=`expr $h5versminor + 1`
+ ;;
+ "r") xxh5versrelease=`expr $h5versrelease + 1`
+ ;;
+ esac
+ case "$h5DisableVersion" in
+ 1)
+ # W2/OK: Different Warning, exit 0.
+ WarnMesg2 > $expect
+ expect_code=0
+ ;;
+ [2-9]|[1-9][0-9]*)
+ # OK: No warning, exit 0
+ cp /dev/null $expect
+ expect_code=0
+ ;;
+ *) # W/A: Warning, abort and exit non-0.
+ WarnMesg > $expect
+ expect_code=6 # Signal Abort exit code (128+6)
+ ;;
+ esac
+ fi
+
+ # Run test.
+ LINEMSG $envcmd $TEST_NAME $arguments
+ (
+ $envcmd $RUNSERIAL $TEST_BIN $arguments
+ ) >$actual 2>$actual_err
+ ret_code=$?
+ cat $actual_err >> $actual
+
+ if [ \( $expect_code -ne $ret_code \) ]; then
+ echo "*FAILED*"
+ echo " Expected exit code ($expect_code) differs from actual code ($ret_code)"
+ nerrors="`expr $nerrors + 1`"
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file.
+ # Also clean the core file generated by H5check_version's abort.
+ if test -z "$HDF5_NOCLEANUP"; then
+ $RM $expect $actual $actual_err
+ $RM core
+ fi
+}
+
+
+# Echo parameters for debugging if verbose mode is on.
+DEBUGPRINT() {
+ if [ -n "$debugmode" ]; then
+ echo $*
+ fi
+}
+
+
+# MAIN Body
+nerrors=0
+verbose=yes # default on
+debugmode= # default off
+H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h`
+h5libsettings=../src/libhdf5.settings
+
+PURPOSE
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+
+# Figure out library version numbers from the header file.
+h5versmajor=`grep '#define H5_VERS_MAJOR' $srcdir/../src/H5public.h | cut -f2`
+h5versminor=`grep '#define H5_VERS_MINOR' $srcdir/../src/H5public.h | cut -f2`
+h5versrelease=`grep '#define H5_VERS_RELEASE' $srcdir/../src/H5public.h | cut -f2`
+DEBUGPRINT $h5versmajor.$h5versminor.$h5versrelease
+case "$h5versmajor$h5versminor$h5versrelease" in
+ [0-9]*) # good. noop.
+ ;;
+ *)
+ echo "Illegal library version numbers($h5versmajor.$h5versminor.$h5versrelease)"
+ echo "Test aborted"
+ exit 1
+ ;;
+esac
+
+# Three Categories of tests:
+# Normal: where the version numbers all matched (wrong_version == none).
+# Mismatched version numbers (could be Major or minor version
+# or release numbers or a combination of all three.)
+# Test all the above with different values of the environment variable,
+# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3
+
+for val_disable_version_check in unset "" -1 0 1 2 3; do
+ for wrong_version in none M m r; do
+ TESTING "$val_disable_version_check" "$wrong_version"
+ done
+done
+
+
+# Check and report results.
+if [ $nerrors -gt 0 ]; then
+ echo "***$nerrors errors encountered***"
+ exit 1
+else
+ echo "No error encountered"
+ exit 0
+fi
diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1
index 20f669d..308ca07 100644
--- a/test/testfiles/error_test_1
+++ b/test/testfiles/error_test_1
@@ -1,11 +1,16 @@
#############################
Expected output for error_test
#############################
-Testing error API based on data I/O All error API tests passed.
+Testing error API based on data I/O
+All error API tests passed.
This program tests the Error API. There're supposed to be some error messages
********* Print error stack in HDF5 default way *********
+Second Test-DIAG: Error detected in Second Program (1.0) thread (IDs):
+ #000: (file name) line (number) in main(): Error stack test failed
+ major: Error in test
+ minor: Error in error stack
Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
- #000: (file name) line (number) in error_stack(): Get number test failed, returned 0
+ #001: (file name) line (number) in error_stack(): Get number test failed, returned 0
major: Error in API
minor: Error in H5Eget_num
@@ -14,6 +19,10 @@ Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
class: Error Test
major: Error in API
minor: Error in H5Eget_num
+ error #001: (file name) in main(): line (number)
+ class: Second Test
+ major: Error in test
+ minor: Error in error stack
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Dwrite(): not a dataset
major: Invalid arguments to routine
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 95ec90c..f14c2c3 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -88,3 +88,4 @@ main(int argc, char *argv[])
return (GetTestNumErrs());
} /* end main() */
+
diff --git a/test/testhdf5.h b/test/testhdf5.h
index ed8b049..f2a820f 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -25,7 +25,6 @@
* so we include the private headers here.
*/
#include "H5private.h"
-#include "H5Eprivate.h"
/* Include generic testing header also */
#include "h5test.h"
@@ -82,6 +81,20 @@
} \
} while(0)
+/* Used to make certain a (non-'long' type's) return value _is_ a value */
+#define VERIFY_TYPE(_x, _val, _type, _format, where) do { \
+ _type __x = (_type)_x, __val = (_type)_val; \
+ if(GetTestVerbosity() >= VERBO_HI) { \
+ print_func(" Call to routine: %15s at line %4d in %s had value " \
+ _format " \n", (where), (int)__LINE__, __FILE__, __x); \
+ } \
+ if((__x) != (__val)) { \
+ TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \
+ "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \
+ H5Eprint2(H5E_DEFAULT, stdout); \
+ } \
+} while(0)
+
/* Used to make certain a string return value _is_ a value */
#define VERIFY_STR(x, val, where) do { \
if (GetTestVerbosity()>=VERBO_HI) { \
diff --git a/test/testlibinfo.sh.in b/test/testlibinfo.sh.in
new file mode 100644
index 0000000..97fb59d
--- /dev/null
+++ b/test/testlibinfo.sh.in
@@ -0,0 +1,128 @@
+#! /bin/sh
+#
+# 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.
+
+
+#
+# Tests for the embedded library information feature.
+# Part 1:
+# Verify the HDF5 library does contains an exact copy of the content of the
+# libhdf5.settings file.
+# Part 2:
+# If executable is linked with the static hdf5 library (how to determine?),
+# verify an executable indeed contains an exact copy of hte content of the
+# libhdf5.settings file.
+#
+# Programmer: Albert Cheng
+# Sep 18, 2009
+
+# Determine the configure options of the hdf5 library and executables.
+
+Shared_Lib=@enable_shared@
+Static_Lib=@enable_static@
+Static_exec=@STATIC_EXEC@
+
+
+# Print a line-line message left justified in a field of 70 characters.
+#
+LINEMSG() {
+ SPACES=" "
+ echo "Check file $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+
+# Print a "SKIP" message
+SKIP() {
+ LINEMSG $*
+ echo " -SKIP-"
+}
+
+# Function definitions
+CHECK_LIBINFO(){
+ LINEMSG $1
+ if strings $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" > /dev/null; then
+ echo " PASSED"
+ else
+ echo " FAILED"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+
+# MAIN Body
+nerrors=0
+H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h`
+
+# Skip the rest if embedded-libinfo is not enabled.
+if [ -z "$H5_HAVE_EMBEDDED_LIBINFO" ]; then
+ echo "embedded-libinfo is not enabled. Test skipped."
+ exit 0
+fi
+
+# The location of HDF library file(s) depends on whether shared lib is
+# built too.
+if [ -n $Shared_Lib ]; then
+ h5libdir=../src/.libs
+else
+ h5libdir=../src
+fi
+
+# Different OS uses different naming for shared libs.
+case `uname -s` in
+ Darwin) # MacOS
+ shlibsuffix=.dylib
+ break
+ ;;
+ *) # default
+ shlibsuffix=.so
+ break
+ ;;
+esac
+
+h5libsettings=../src/libhdf5.settings
+
+# Part 1:
+# Verify the HDF5 library does contains an exact copy of the content of the
+# libhdf5.settings file.
+# Check dynamic library file if built.
+if [ x-$Shared_Lib = x-yes ]; then
+ CHECK_LIBINFO ${h5libdir}/libhdf5${shlibsuffix}
+else
+ SKIP ${h5libdir}/libhdf5${shlibsuffix}
+fi
+
+# Though rare, libhdf5.a may not have been built.
+if [ x-$Static_Lib = x-yes ]; then
+ CHECK_LIBINFO ${h5libdir}/libhdf5.a
+else
+ SKIP ${h5libdir}/libhdf5.a
+fi
+
+# Check if executables has the lib information only if shared lib is not
+# built or static-exec is used. (Don't care static-exec since it affects
+# tools binary only.)
+if [ x-$Shared_Lib != x-yes ]; then
+ CHECK_LIBINFO testhdf5
+else
+ SKIP testhdf5
+fi
+
+
+if [ $nerrors -gt 0 ]; then
+ echo "***$nerrors errors encountered***"
+ exit 1
+else
+ echo "No error encountered"
+ exit 0
+fi
diff --git a/test/tfile.c b/test/tfile.c
index e839630..342230f 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -27,12 +27,29 @@
#include "H5Bprivate.h"
#include "H5Pprivate.h"
+/*
+ * This file needs to access private information from the H5F package.
+ * This file also needs to access the file testing code.
+ */
+#define H5F_PACKAGE
+#define H5F_TESTING
+#include "H5Fpkg.h" /* File access */
+
+#define BAD_USERBLOCK_SIZE1 (hsize_t)1
+#define BAD_USERBLOCK_SIZE2 (hsize_t)2
+#define BAD_USERBLOCK_SIZE3 (hsize_t)3
+#define BAD_USERBLOCK_SIZE4 (hsize_t)64
+#define BAD_USERBLOCK_SIZE5 (hsize_t)511
+#define BAD_USERBLOCK_SIZE6 (hsize_t)513
+#define BAD_USERBLOCK_SIZE7 (hsize_t)6144
+
#define F1_USERBLOCK_SIZE (hsize_t)0
#define F1_OFFSET_SIZE sizeof(haddr_t)
#define F1_LENGTH_SIZE sizeof(hsize_t)
#define F1_SYM_LEAF_K 4
#define F1_SYM_INTERN_K 16
#define FILE1 "tfile1.h5"
+#define SFILE1 "sys_file1"
#define F2_USERBLOCK_SIZE (hsize_t)512
#define F2_OFFSET_SIZE 8
@@ -79,6 +96,37 @@
#define TESTA_NX 4
#define TESTA_NY 5
+#define USERBLOCK_SIZE ((hsize_t) 512)
+
+/* Declarations for test_filespace_*() */
+#define FILENAME_LEN 1024 /* length of file name */
+#define CORE_INCREMENT 1024 /* core file */
+#define FAMILY_SIZE 1024 /* family file */
+#define DSETNAME "dset" /* Name of dataset */
+#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */
+#define READ_OLD_BUFSIZE 1024 /* Buffer for holding file data */
+#define FILE5 "tfile5.h5" /* Test file */
+#define TEST_THRESHOLD10 10 /* Free space section threshold */
+
+const char *OLD_FILENAME[] = { /* Files created under 1.6 branch and 1.8 branch */
+ "filespace_1_6.h5", /* 1.6 HDF5 file */
+ "filespace_1_8.h5" /* 1.8 HDF5 file */
+};
+const char *FILESPACE_NAME[] = {
+ "tfilespace",
+ NULL
+};
+
+const char *FILENAME[] = {
+ "sec2_tfile",
+ "split_tfile",
+ "stdio_tfile",
+ "core_tfile",
+ "family_tfile",
+ NULL
+};
+
+
static void
create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *);
static void
@@ -198,6 +246,36 @@ test_file_create(void)
tmpl1 = H5Pcreate(H5P_FILE_CREATE);
CHECK(tmpl1, FAIL, "H5Pcreate");
+ /* Try setting some bad userblock sizes */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE1);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE2);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE3);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE4);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE5);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE6);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+ H5E_BEGIN_TRY {
+ ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE7);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Pset_userblock");
+
/* Set the new file-creation parameters */
ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE);
CHECK(ret, FAIL, "H5Pset_userblock");
@@ -223,7 +301,7 @@ test_file_create(void)
{
hid_t dataset_id, dataspace_id; /* identifiers */
hsize_t dims[F2_RANK];
- int data[F2_DIM0][F2_DIM1];
+ unsigned data[F2_DIM0][F2_DIM1];
unsigned i,j;
/* Create the data space for the dataset. */
@@ -233,7 +311,7 @@ test_file_create(void)
CHECK(dataspace_id, FAIL, "H5Screate_simple");
/* Create the dataset. */
- dataset_id = H5Dcreate2(fid2, F2_DSET, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset_id = H5Dcreate2(fid2, F2_DSET, H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset_id, FAIL, "H5Dcreate2");
for(i = 0; i < F2_DIM0; i++)
@@ -241,7 +319,7 @@ test_file_create(void)
data[i][j] = i * 10 + j;
/* Write data to the new dataset */
- ret = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
CHECK(ret, FAIL, "H5Dwrite");
/* End access to the dataset and release resources used by it. */
@@ -765,7 +843,7 @@ static void
create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
hid_t *ret_gid2, hid_t *ret_gid3)
{
- int oid_count;
+ ssize_t oid_count;
herr_t ret;
/* Check reference counts of file IDs and opened object IDs.
@@ -794,7 +872,7 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
{
hid_t dataset_id, dataspace_id; /* identifiers */
hsize_t dims[F2_RANK];
- int data[F2_DIM0][F2_DIM1];
+ unsigned data[F2_DIM0][F2_DIM1];
unsigned i,j;
/* Create the data space for the dataset. */
@@ -804,7 +882,7 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
CHECK(dataspace_id, FAIL, "H5Screate_simple");
/* Create the dataset. */
- dataset_id = H5Dcreate2(fid1, "/dset", H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset_id = H5Dcreate2(fid1, "/dset", H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset_id, FAIL, "H5Dcreate2");
for(i = 0; i < F2_DIM0; i++)
@@ -812,8 +890,7 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
data[i][j] = i * 10 + j;
/* Write data to the new dataset */
- ret = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, data);
+ ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
CHECK(ret, FAIL, "H5Dwrite");
if(ret_did != NULL)
@@ -1033,7 +1110,7 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1,
hid_t gid2, hid_t gid3)
{
hid_t fid3, fid4;
- int oid_count;
+ ssize_t oid_count, ret_count;
herr_t ret;
/* Create two new files */
@@ -1079,8 +1156,8 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1,
oid_list = (hid_t*)calloc((size_t)oid_count, sizeof(hid_t));
if(oid_list != NULL) {
- ret = H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, oid_count, oid_list);
- CHECK(ret, FAIL, "H5Fget_obj_ids");
+ ret_count = H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)oid_count, oid_list);
+ CHECK(ret_count, FAIL, "H5Fget_obj_ids");
}
for(i=0; i<oid_count; i++) {
@@ -1191,6 +1268,8 @@ static void
test_file_freespace(void)
{
hid_t file; /* File opened with read-write permission */
+ h5_stat_size_t empty_filesize; /* Size of file when empty */
+ h5_stat_size_t mod_filesize; /* Size of file after being modified */
hssize_t free_space; /* Amount of free space in file */
hid_t dspace; /* Dataspace ID */
hid_t dset; /* Dataset ID */
@@ -1202,10 +1281,20 @@ test_file_freespace(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File Free Space\n"));
- /* Create the file (with read-write permission) */
+ /* Create an "empty" file */
file = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(file, FAIL, "H5Fcreate");
+ ret = H5Fclose(file);
+ CHECK_I(ret, "H5Fclose");
+
+ /* Get the "empty" file size */
+ empty_filesize = h5_get_file_size(FILE1, H5P_DEFAULT);
+
+ /* Re-open the file (with read-write permission) */
+ file = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK_I(file, "H5Fopen");
+
/* Check that the free space is 0 */
free_space = H5Fget_freespace(file);
CHECK(free_space, FAIL, "H5Fget_freespace");
@@ -1244,7 +1333,7 @@ test_file_freespace(void)
/* Check that there is the right amount of free space in the file */
free_space = H5Fget_freespace(file);
CHECK(free_space, FAIL, "H5Fget_freespace");
- VERIFY(free_space, 2376, "H5Fget_freespace");
+ VERIFY(free_space, 2008, "H5Fget_freespace");
/* Delete datasets in file */
for(u = 0; u < 10; u++) {
@@ -1261,6 +1350,12 @@ test_file_freespace(void)
/* Close file */
ret = H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get the file size after modifications*/
+ mod_filesize = h5_get_file_size(FILE1, H5P_DEFAULT);
+
+ /* Check that the file reverted to empty size */
+ VERIFY(mod_filesize, empty_filesize, "H5Fget_freespace");
} /* end test_file_freespace() */
/****************************************************************
@@ -1324,7 +1419,7 @@ test_file_ishdf5(void)
/* Create non-HDF5 file and check it */
fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666);
- CHECK(ret, FAIL, "HDopen");
+ CHECK(fd, FAIL, "HDopen");
/* Initialize information to write */
for(u=0; u<1024; u++)
@@ -1837,6 +1932,1276 @@ test_file_double_datatype_open(void)
/****************************************************************
**
+** test_userblock_file_size(): low-level file test routine.
+** This test checks that the presence of a userblock
+** affects the file size in the expected manner, and that
+** the filesize is not changed by reopening the file. It
+** creates two files which are identical except that one
+** contains a userblock, and verifies that their file sizes
+** differ exactly by the userblock size.
+**
+*****************************************************************/
+static void
+test_userblock_file_size(void)
+{
+ hid_t file1_id, file2_id;
+ hid_t group1_id, group2_id;
+ hid_t dset1_id, dset2_id;
+ hid_t space_id;
+ hid_t fcpl2_id;
+ hsize_t dims[2] = {3, 4};
+ hsize_t filesize1, filesize2, filesize;
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing file size with user block\n"));
+
+ /* Create property list with userblock size set */
+ fcpl2_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl2_id, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl2_id, USERBLOCK_SIZE);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create files. Onyl file2 with have a userblock. */
+ file1_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file1_id, FAIL, "H5Fcreate");
+ file2_id = H5Fcreate(FILE2, H5F_ACC_TRUNC, fcpl2_id, H5P_DEFAULT);
+ CHECK(file2_id, FAIL, "H5Fcreate");
+
+ /* Create groups */
+ group1_id = H5Gcreate2(file1_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(group1_id, FAIL, "H5Gcreate2");
+ group2_id = H5Gcreate2(file2_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(group2_id, FAIL, "H5Gcreate2");
+
+ /* Create dataspace */
+ space_id = H5Screate_simple(2, dims, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+
+ /* Create datasets */
+ dset1_id = H5Dcreate2(file1_id, DSET2, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset1_id, FAIL, "H5Dcreate2");
+ dset2_id = H5Dcreate2(file2_id, DSET2, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset2_id, FAIL, "H5Dcreate2");
+
+ /* Close IDs */
+ ret = H5Dclose(dset1_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Dclose(dset2_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Gclose(group1_id);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Gclose(group2_id);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Pclose(fcpl2_id);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close files */
+ ret = H5Fclose(file1_id);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Fclose(file2_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Reopen files */
+ file1_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(file1_id, FAIL, "H5Fopen");
+ file2_id = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(file2_id, FAIL, "H5Fopen");
+
+ /* Check file sizes */
+ ret = H5Fget_filesize(file1_id, &filesize1);
+ CHECK(ret, FAIL, "H5Fget_filesize");
+ ret = H5Fget_filesize(file2_id, &filesize2);
+ CHECK(ret, FAIL, "H5Fget_filesize");
+
+ /* Verify that the file sizes differ exactly by the userblock size */
+ VERIFY_TYPE((unsigned long long)filesize2, (unsigned long long)(filesize1 + USERBLOCK_SIZE), unsigned long long, "%llu", "H5Fget_filesize");
+
+ /* Close files */
+ ret = H5Fclose(file1_id);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Fclose(file2_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Reopen files */
+ file1_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(file1_id, FAIL, "H5Fopen");
+ file2_id = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(file2_id, FAIL, "H5Fopen");
+
+ /* Verify file sizes did not change */
+ ret = H5Fget_filesize(file1_id, &filesize);
+ CHECK(ret, FAIL, "H5Fget_filesize");
+ VERIFY(filesize, filesize1, "H5Fget_filesize");
+ ret = H5Fget_filesize(file2_id, &filesize);
+ CHECK(ret, FAIL, "H5Fget_filesize");
+ VERIFY(filesize, filesize2, "H5Fget_filesize");
+
+ /* Close files */
+ ret = H5Fclose(file1_id);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Fclose(file2_id);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* end test_userblock_file_size() */
+
+/****************************************************************
+**
+** test_cached_stab_info(): low-level file test routine.
+** This test checks that new files are created with cached
+** symbol table information in the superblock (when using
+** the old format). This is necessary to ensure backwards
+** compatibility with versions from 1.3.0 to 1.6.3.
+**
+*****************************************************************/
+static void
+test_cached_stab_info(void)
+{
+ hid_t file_id;
+ hid_t group_id;
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing cached symbol table information\n"));
+
+ /* Create file */
+ file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fcreate");
+
+ /* Create group */
+ group_id = H5Gcreate2(file_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(group_id, FAIL, "H5Gcreate2");
+
+ /* Close file and group */
+ ret = H5Gclose(group_id);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Reopen file */
+ file_id = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fopen");
+
+ /* Verify the cached symbol table information */
+ ret = H5F_check_cached_stab_test(file_id);
+ CHECK(ret, FAIL, "H5F_check_cached_stab_test");
+
+ /* Close file */
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* end test_cached_stab_info() */
+
+/****************************************************************
+**
+** test_rw_noupdate(): low-level file test routine.
+** This test checks to ensure that opening and closing a file
+** with read/write permissions does not write anything to the
+** file if the file does not change.
+**
+** Programmer: Mike McGreevy
+** mamcgree@hdfgroup.org
+** June 29, 2009
+**
+*****************************************************************/
+static void
+test_rw_noupdate(void)
+{
+ int fd; /* File Descriptor */
+ h5_stat_t sb1, sb2; /* Info from 'stat' call */
+ double diff; /* Difference in modification times */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing to verify that nothing is written if nothing is changed.\n"));
+
+ /* First make sure the stat function behaves as we expect - the modification time
+ * is the time that the file was modified last time. */
+ fd = HDopen(SFILE1, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ CHECK(fd, FAIL, "HDopen");
+ ret = HDclose(fd);
+ CHECK(ret, FAIL, "HDclose");
+
+ /* Determine File's Initial Timestamp */
+ ret = HDstat(SFILE1, &sb1);
+ VERIFY(ret, 0, "HDstat");
+
+ /* Wait for 2 seconds */
+ /* (This ensures a system time difference between the two file accesses) */
+ HDsleep(2);
+
+ fd = HDopen(SFILE1, O_RDWR, 0666);
+ CHECK(fd, FAIL, "HDopen");
+ ret = HDclose(fd);
+ CHECK(ret, FAIL, "HDclose");
+
+ /* Determine File's New Timestamp */
+ ret = HDstat(SFILE1, &sb2);
+ VERIFY(ret, 0, "HDstat");
+
+ /* Get difference between timestamps */
+ diff = HDdifftime(sb2.st_mtime, sb1.st_mtime);
+
+ /* Check That Timestamps Are Equal */
+ if(diff > 0.0) {
+ /* Output message about test being performed */
+ MESSAGE(1, ("Testing to verify that nothing is written if nothing is changed: This test is skipped on this system because the modification time from stat is the same as the last access time (We know OpenVMS behaves in this way).\n"));
+ } /* end if */
+ else {
+ hid_t file_id; /* HDF5 File ID */
+
+ /* Create and Close a HDF5 File */
+ file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fcreate");
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Determine File's Initial Timestamp */
+ ret = HDstat(FILE1, &sb1);
+ VERIFY(ret, 0, "HDfstat");
+
+ /* Wait for 2 seconds */
+ /* (This ensures a system time difference between the two file accesses) */
+ HDsleep(2);
+
+ /* Open and Close File With Read/Write Permission */
+ file_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fopen");
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Determine File's New Timestamp */
+ ret = HDstat(FILE1, &sb2);
+ VERIFY(ret, 0, "HDstat");
+
+ /* Ensure That Timestamps Are Equal */
+ diff = HDdifftime(sb2.st_mtime, sb1.st_mtime);
+ ret = (diff > 0.0);
+ VERIFY(ret, 0, "Timestamp");
+ } /* end else */
+} /* end test_rw_noupdate() */
+
+/****************************************************************
+**
+** test_userblock_alignment_helper1(): helper routine for
+** test_userblock_alignment() test, to handle common testing
+**
+** Programmer: Quincey Koziol
+** koziol@hdfgroup.org
+** Septmber 10, 2009
+**
+*****************************************************************/
+static int
+test_userblock_alignment_helper1(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */
+ herr_t ret; /* Generic return value */
+
+ /* Create a file with FAPL & FCPL */
+ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Only proceed further if file ID is OK */
+ if(fid > 0) {
+ hid_t gid; /* Group ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t did; /* Dataset ID */
+ int val = 2; /* Dataset value */
+
+ /* Create a group */
+ gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Create a dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+ did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dcreate2");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Write value to dataset */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &val);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close group */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end if */
+
+ return((GetTestNumErrs() == curr_num_errs) ? 0 : -1);
+} /* end test_userblock_alignment_helper1() */
+
+/****************************************************************
+**
+** test_userblock_alignment_helper2(): helper routine for
+** test_userblock_alignment() test, to handle common testing
+**
+** Programmer: Quincey Koziol
+** koziol@hdfgroup.org
+** Septmber 10, 2009
+**
+*****************************************************************/
+static int
+test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw)
+{
+ hid_t fid; /* File ID */
+ int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */
+ herr_t ret; /* Generic return value */
+
+ /* Re-open file */
+ fid = H5Fopen(FILE1, (open_rw ? H5F_ACC_RDWR : H5F_ACC_RDONLY), fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Only proceed further if file ID is OK */
+ if(fid > 0) {
+ hid_t gid; /* Group ID */
+ hid_t did; /* Dataset ID */
+ int val = -1; /* Dataset value */
+
+ /* Open group */
+ gid = H5Gopen2(fid, "group1", H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+
+ /* Open dataset */
+ did = H5Dopen2(gid, "dataset", H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dopen2");
+
+ /* Read value from dataset */
+ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &val);
+ CHECK(ret, FAIL, "H5Dread");
+ VERIFY(val, 2, "H5Dread");
+
+ /* Close dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Only create new objects if file is open R/W */
+ if(open_rw) {
+ hid_t gid2; /* Group ID */
+
+ /* Create a new group */
+ gid2 = H5Gcreate2(gid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Close new group */
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+ } /* end if */
+
+ /* Close group */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end if */
+
+ return((GetTestNumErrs() == curr_num_errs) ? 0 : -1);
+} /* end test_userblock_alignment_helper2() */
+
+/****************************************************************
+**
+** test_userblock_alignment(): low-level file test routine.
+** This test checks to ensure that files with both a userblock and a
+** object [allocation] alignment size set interact properly.
+**
+** Programmer: Quincey Koziol
+** koziol@hdfgroup.org
+** Septmber 8, 2009
+**
+*****************************************************************/
+static void
+test_userblock_alignment(void)
+{
+ hid_t fid; /* File ID */
+ hid_t fcpl; /* File creation property list ID */
+ hid_t fapl; /* File access property list ID */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing that non-zero userblocks and object alignment interact correctly.\n"));
+
+ /* Case 1:
+ * Userblock size = 0, alignment != 0
+ * Outcome:
+ * Should succeed
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)0);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* Case 2:
+ * Userblock size = 512, alignment = 16
+ * (userblock is integral mult. of alignment)
+ * Outcome:
+ * Should succeed
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* Case 3:
+ * Userblock size = 512, alignment = 512
+ * (userblock is equal to alignment)
+ * Outcome:
+ * Should succeed
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* Case 4:
+ * Userblock size = 512, alignment = 3
+ * (userblock & alignment each individually valid, but userblock is
+ * non-integral multiple of alignment)
+ * Outcome:
+ * Should fail at file creation
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Create a file with FAPL & FCPL */
+ H5E_BEGIN_TRY {
+ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
+ } H5E_END_TRY;
+ VERIFY(fid, FAIL, "H5Fcreate");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* Case 5:
+ * Userblock size = 512, alignment = 1024
+ * (userblock & alignment each individually valid, but userblock is
+ * less than alignment)
+ * Outcome:
+ * Should fail at file creation
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Create a file with FAPL & FCPL */
+ H5E_BEGIN_TRY {
+ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
+ } H5E_END_TRY;
+ VERIFY(fid, FAIL, "H5Fcreate");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+
+ /* Case 6:
+ * File created with:
+ * Userblock size = 512, alignment = 512
+ * File re-opened for read-only & read-write access with:
+ * Userblock size = 512, alignment = 1024
+ * Outcome:
+ * Should succeed
+ */
+ /* Create file creation property list with user block */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_userblock(fcpl, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_userblock");
+
+ /* Create file access property list with alignment */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper1(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper1");
+
+ /* Change alignment in FAPL */
+ ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024);
+ CHECK(ret, FAIL, "H5Pset_alignment");
+
+ /* Call helper routines to perform file manipulations */
+ ret = test_userblock_alignment_helper2(fapl, FALSE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+ ret = test_userblock_alignment_helper2(fapl, TRUE);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper2");
+
+ /* Release property lists */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+} /* end test_userblock_alignment() */
+
+/****************************************************************
+**
+** test_free_sections():
+** This routine does the actual work of checking information for
+** free space sections available in a file in various situations.
+**
+*****************************************************************/
+static void
+test_free_sections(hid_t fapl, char *fname)
+{
+ hid_t file; /* File ID */
+ hid_t fcpl; /* File creation property list template */
+ hssize_t free_space; /* Amount of free space in file */
+ hid_t dspace; /* Dataspace ID */
+ hid_t dset; /* Dataset ID */
+ hid_t dcpl; /* Dataset creation property list */
+ unsigned u; /* Local index variable */
+ char name[32]; /* Dataset name */
+ hssize_t nsects; /* # of free-space sections */
+ hssize_t saved_nsects; /* saved copy for the # of free-space sections */
+ int i; /* local index variable */
+ hsize_t total; /* sum of the free-space section sizes */
+ hsize_t last_size; /* size of last free-space section */
+ H5F_sect_info_t *sect_info; /* array to hold the free-space information */
+ H5F_sect_info_t *saved_sect_info; /* array to hold the free-space information */
+ herr_t ret; /* return value */
+
+ /* Create file-creation template */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+
+ /* Set file space strategy and free space section threshold */
+ ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+
+ /* Create the file */
+ file = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ dspace = H5Screate(H5S_SCALAR);
+ CHECK(dspace, FAIL, "H5Screate");
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Set the space allocation time to early */
+ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
+ CHECK(ret, FAIL, "H5Pset_alloc_time");
+
+ /* Create datasets in file */
+ for(u = 0; u < 10; u++) {
+ sprintf(name, "Dataset %u", u);
+ dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate2");
+
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ } /* end for */
+
+ /* Close dataspace */
+ ret = H5Sclose(dspace);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close dataset creation property list */
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Delete odd-numbered datasets in file */
+ for(u = 0; u < 10; u++) {
+ sprintf(name, "Dataset %u", u);
+ if(u % 2) {
+ ret = H5Ldelete(file, name, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Ldelete");
+ } /* end if */
+ } /* end for */
+
+ /* Close file */
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-open the file with read-only permission */
+ file = H5Fopen(fname, H5F_ACC_RDONLY, fapl);
+ CHECK_I(file, "H5Fopen");
+
+ /* Get the amount of free space in the file */
+ free_space = H5Fget_freespace(file);
+ CHECK(free_space, FAIL, "H5Fget_freespace");
+
+ /* Get the # of free-space sections in the file */
+ saved_nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, NULL);
+ CHECK(saved_nsects, FAIL, "H5Fget_free_sections");
+
+ /* Allocate storage for the free space section information */
+ saved_sect_info = (H5F_sect_info_t *)HDcalloc((size_t)saved_nsects, sizeof(H5F_sect_info_t));
+ CHECK(saved_sect_info, NULL, "HDcalloc");
+
+ /* Should return failure when nsects is 0 with a nonnull sect_info */
+ nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, saved_sect_info);
+ VERIFY(nsects, FAIL, "H5Fget_free_sections");
+
+ /* Verify the correct # of free-space sections */
+ nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)saved_nsects, saved_sect_info);
+ VERIFY(nsects, saved_nsects, "H5Fget_free_sections");
+
+ /* Verify the amount of free-space is correct */
+ total = 0;
+ for(i = 0; i < nsects; i++)
+ total += saved_sect_info[i].size;
+ VERIFY(free_space, total, "H5Fget_free_sections");
+
+ /* save the last section's size */
+ last_size = saved_sect_info[nsects-1].size;
+
+ /* Allocate storage for -1 free space section information */
+ sect_info = (H5F_sect_info_t *)HDcalloc((size_t)(saved_nsects - 1), sizeof(H5F_sect_info_t));
+ CHECK(sect_info, NULL, "HDcalloc");
+
+ /* Retrieve free space info for -1 sections */
+ nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(saved_nsects - 1), sect_info);
+ VERIFY(nsects, saved_nsects, "H5Fget_free_sections");
+
+ /* Verify the amount of free-space is correct */
+ total = 0;
+ for(i = 0; i < (saved_nsects - 1); i++) {
+ VERIFY(sect_info[i].addr, saved_sect_info[i].addr, "H5Fget_free_sections");
+ VERIFY(sect_info[i].size, saved_sect_info[i].size, "H5Fget_free_sections");
+ total += sect_info[i].size;
+ }
+
+ VERIFY(((hsize_t)free_space - last_size), total, "H5Fget_free_sections");
+ HDfree(sect_info);
+
+ /* Allocate storage for +1 free space section information */
+ sect_info = (H5F_sect_info_t *)HDcalloc((size_t)(saved_nsects + 1), sizeof(H5F_sect_info_t));
+ CHECK(sect_info, NULL, "HDcalloc");
+
+ /* Retrieve free-space info for +1 sections */
+ nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(saved_nsects + 1), sect_info);
+ VERIFY(nsects, saved_nsects, "H5Fget_free_sections");
+
+ /* Verify free-space info is correct */
+ total = 0;
+ for(i = 0; i < nsects; i++) {
+ VERIFY(sect_info[i].addr, saved_sect_info[i].addr, "H5Fget_free_sections");
+ VERIFY(sect_info[i].size, saved_sect_info[i].size, "H5Fget_free_sections");
+ total += sect_info[i].size;
+ }
+
+ VERIFY(sect_info[nsects].addr, 0, "H5Fget_free_sections");
+ VERIFY(sect_info[nsects].size, 0, "H5Fget_free_sections");
+ VERIFY(free_space, total, "H5Fget_free_sections");
+ HDfree(sect_info);
+
+ /* Verify that there is no free-space section for this type */
+ nsects = H5Fget_free_sections(file, H5FD_MEM_BTREE, (size_t)0, NULL);
+ VERIFY(nsects, 0, "H5Fget_free_sections");
+
+ /* Close file */
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Pclose(fcpl);
+ CHECK(fcpl, FAIL, "H5Pclose");
+
+ HDfree(saved_sect_info);
+
+} /* end test_free_sections() */
+
+/****************************************************************
+**
+** test_filespace_sects():
+** This test checks free space section info for
+** files created with sec2 and split drivers.
+**
+*****************************************************************/
+static void
+test_filespace_sects(void)
+{
+ hid_t fapl_sec2; /* File access property id with sec2 driver */
+ hid_t fapl_split; /* File access property id with split driver */
+ hid_t fapl_core; /* File access property id with core driver */
+ hid_t fapl_stdio; /* File access property id with stdio driver */
+ hid_t fapl_family; /* File access property id with family driver */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ herr_t ret; /* Return value */
+
+ /* SEC2 */
+ MESSAGE(5, ("Testing File free space information for a sec2 file\n"));
+
+ fapl_sec2 = H5Pcreate(H5P_FILE_ACCESS);
+
+ ret = H5Pset_fapl_sec2(fapl_sec2);
+ CHECK(ret, FAIL, "H5Pset_fapl_sec2");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl_sec2, filename, sizeof(filename));
+
+ /* perform free space information test for file with sec2 driver */
+ test_free_sections(fapl_sec2, filename);
+
+ /* close fapl_sec2 and remove the file */
+ h5_cleanup(FILENAME, fapl_sec2);
+
+
+ /* SPLIT */
+ MESSAGE(5, ("Testing File free space information for a split file\n"));
+
+ fapl_split = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl_split, FAIL, "h5_fileaccess");
+
+ ret = H5Pset_fapl_split(fapl_split, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Pset_fapl_split");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[1], fapl_split, filename, sizeof(filename));
+
+ /* perform free space information test for file with split driver */
+ test_free_sections(fapl_split, filename);
+
+ /* close fapl and remove the file */
+ h5_cleanup(FILENAME, fapl_split);
+
+
+ /* STDIO */
+ MESSAGE(5, ("Testing File free space information for a stdio file\n"));
+
+ fapl_stdio = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl_stdio, FAIL, "h5_fileaccess");
+
+ ret = H5Pset_fapl_stdio(fapl_stdio);
+ CHECK(ret, FAIL, "H5Pset_fapl_split");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[2], fapl_stdio, filename, sizeof(filename));
+
+ /* perform free space information test for file with stdio driver */
+ test_free_sections(fapl_stdio, filename);
+
+ /* close fapl and remove the file */
+ h5_cleanup(FILENAME, fapl_split);
+
+ /* CORE */
+ MESSAGE(5, ("Testing File free space information for a core file\n"));
+
+ fapl_core = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl_core, FAIL, "h5_fileaccess");
+
+ ret = H5Pset_fapl_core(fapl_core, (size_t)CORE_INCREMENT, TRUE);
+ CHECK(ret, FAIL, "H5Pset_fapl_core");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[3], fapl_core, filename, sizeof(filename));
+
+ /* perform free space information test for file with core driver */
+ test_free_sections(fapl_core, filename);
+
+ /* close fapl_ and remove the file */
+ h5_cleanup(FILENAME, fapl_core);
+
+
+ /* FAMILY */
+ MESSAGE(5, ("Testing File free space information for a family file\n"));
+
+ fapl_family = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl_family, FAIL, "h5_fileaccess");
+
+ ret = H5Pset_fapl_family(fapl_family, (hsize_t)FAMILY_SIZE, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Pset_fapl_family");
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[4], fapl_family, filename, sizeof(filename));
+
+ /* perform free space information test for file with family driver */
+ test_free_sections(fapl_family, filename);
+
+ /* close fapl and remove the file */
+ h5_cleanup(FILENAME, fapl_family);
+
+} /* end test_filespace_sects() */
+
+/****************************************************************
+**
+** test_filespace_info():
+** Verify that the public routines H5Pget/set_file_space()
+** retrieve and set the file space strategy and free space
+** section threshold as specified.
+**
+****************************************************************/
+static void
+test_filespace_info(void)
+{
+ hid_t fid1, fid2; /* HDF5 File IDs */
+ hid_t fapl, new_fapl; /* File access property */
+ hid_t fcpl, fcpl1, fcpl2; /* File creation property */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ H5F_file_space_type_t strategy, fs_type, def_type; /* File space handling strategy */
+ hsize_t threshold, fs_size, def_size; /* Free space section threshold */
+ hbool_t new_format; /* new format or old format */
+ herr_t ret; /* return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing File Space Management public routines: H5Pget/set_file_space()\n"));
+
+ fapl = h5_fileaccess();
+ h5_fixname(FILESPACE_NAME[0], fapl, filename, sizeof filename);
+
+ new_fapl = H5Pcopy(fapl);
+ CHECK(new_fapl, FAIL, "H5Pcopy");
+
+ /* Set the "use the latest version of the format" bounds */
+ ret = H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create file-creation template */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+
+ /* Get default file space information */
+ ret = H5Pget_file_space(fcpl, &def_type, &def_size);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+
+ /* Test with old & new format groups */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
+
+ /* Set the FAPL for the type of format */
+ if(new_format) {
+ MESSAGE(5, ("Testing with new group format\n"));
+ my_fapl = new_fapl;
+ } /* end if */
+ else {
+ MESSAGE(5, ("Testing with old group format\n"));
+ my_fapl = fapl;
+ } /* end else */
+
+ /* Test with different sized free space section threshold */
+ for(fs_size = 0; fs_size <= TEST_THRESHOLD10; fs_size++) {
+
+ /* Test with different file space handling strategies */
+ for(fs_type = 0; fs_type < H5F_FILE_SPACE_NTYPES; H5_INC_ENUM(H5F_file_space_type_t, fs_type)) {
+
+ /* Get a copy of the default file creation property */
+ fcpl1 = H5Pcopy(fcpl);
+ CHECK(fcpl1, FAIL, "H5Pcopy");
+
+ /* Set file space strategy and free space section threshold */
+ ret = H5Pset_file_space(fcpl1, fs_type, fs_size);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+
+ /* Get the file space info from the creation property */
+ ret = H5Pget_file_space(fcpl1, &strategy, &threshold);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+
+ /* A 0 value for strategy retains existing strategy in use */
+ VERIFY(strategy, (H5F_file_space_type_t)(fs_type ? fs_type : def_type), "H5Pget_file_space");
+ /* A 0 value for threshold retains existing threshold in use */
+ VERIFY(threshold, (hsize_t)(fs_size ? fs_size : def_size), "H5Pget_file_space");
+
+ /* Create the file with the specified file space info */
+ fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl1, my_fapl);
+ CHECK(ret, FAIL, "H5Fcreate");
+
+ /* Close the file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-open the file */
+ fid2 = H5Fopen(filename, H5F_ACC_RDWR, my_fapl);
+ CHECK(ret, FAIL, "H5Fopen");
+
+ /* Get the file's creation property */
+ fcpl2 = H5Fget_create_plist(fid2);
+ CHECK(fcpl2, FAIL, "H5Fget_create_plist");
+
+ strategy = threshold = 0;
+
+ /* Get the file space info from the creation property list */
+ ret = H5Pget_file_space(fcpl2, &strategy, &threshold);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+
+ VERIFY(strategy, (H5F_file_space_type_t)(fs_type ? fs_type : def_type), "H5Pget_file_space");
+ VERIFY(threshold, (hsize_t)(fs_size ? fs_size : def_size), "H5Pget_file_space");
+
+ /* Close the file */
+ ret = H5Fclose(fid2);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Release file-creation template */
+ ret = H5Pclose(fcpl1);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fcpl2);
+ CHECK(ret, FAIL, "H5Pclose");
+ } /* end for file space strategy type */
+ } /* end for free space threshold */
+
+ h5_cleanup(FILESPACE_NAME, my_fapl);
+
+ } /* end for new/old format */
+
+ /* Close the file creation property list */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+} /* test_filespace_info() */
+
+/****************************************************************
+**
+** test_filespace_compatible():
+** Verify that the branch with file space management enhancement
+** can open, read and modify 1.6 HDF5 file and 1.8 HDF5 file.
+** Also verify the correct file space strategy/threshold in use
+** and the amount of free space.
+**
+****************************************************************/
+static void
+test_filespace_compatible(void)
+{
+ int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
+ hid_t fid; /* File id */
+ hid_t fcpl; /* File creation property list template */
+ hid_t did; /* Dataset id */
+ int check[100]; /* Temporary buffer for verifying dataset data */
+ int rdbuf[100]; /* Temporary buffer for reading in dataset data */
+ uint8_t buf[READ_OLD_BUFSIZE]; /* temporary buffer for reading */
+ ssize_t nread; /* Number of bytes read in */
+ char *srcdir = HDgetenv("srcdir"); /* where the src code is located */
+ unsigned i, j; /* Local index variable */
+ hssize_t free_space; /* Amount of free space in the file */
+ hsize_t threshold; /* Free space section threshold */
+ H5F_file_space_type_t strategy; /* File space handling strategy */
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing File space compatibility for 1.6 and 1.8 files\n"));
+
+ for(j = 0; j < NELMTS(OLD_FILENAME); j++) {
+ char filename[FILENAME_LEN] = ""; /* old test file name */
+
+ /* Generate correct name for test file by prepending the source path */
+ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(OLD_FILENAME[j]) + 1) < sizeof(filename))) {
+ HDstrcpy(filename, srcdir);
+ HDstrcat(filename, "/");
+ }
+ HDstrcat(filename, OLD_FILENAME[j]);
+
+ /* Copy old file into test file */
+ fd_old = HDopen(filename, O_RDONLY, 0666);
+ CHECK(fd_old, FAIL, "HDopen");
+ fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ CHECK(fd_new, FAIL, "HDopen");
+
+ /* Copy data */
+ while((nread = HDread(fd_old, buf, (size_t)READ_OLD_BUFSIZE)) > 0)
+ HDwrite(fd_new, buf, (size_t)nread);
+
+ /* Close the files */
+ ret = HDclose(fd_old);
+ CHECK(ret, FAIL, "HDclose");
+ ret = HDclose(fd_new);
+ CHECK(ret, FAIL, "HDclose");
+
+ /* Open the test file */
+ fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* There should not be any free space in the file */
+ free_space = H5Fget_freespace(fid);
+ CHECK(free_space, FAIL, "H5Fget_freespace");
+ VERIFY(free_space, (hssize_t)0, "H5Fget_freespace");
+
+ /* Get the file's file creation property list */
+ /* Retrieve the file space handling stretegy and threshold */
+ fcpl = H5Fget_create_plist(fid);
+ CHECK(fcpl, FAIL, "H5Fget_create_plist");
+ ret = H5Pget_file_space(fcpl, &strategy, &threshold);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+
+ /* File space handling strategy should be H5F_FILE_SPACE_ALL = 2 */
+ /* Free space section threshold should be 1 */
+ VERIFY(strategy, 2, "H5Pget_file_space");
+ VERIFY(threshold, 1, "H5Pget_file_space");
+
+ /* Generate raw data */
+ for(i = 0; i < 100; i++)
+ check[i] = (int)i;
+
+ /* Open and read the dataset */
+ did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dopen");
+ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Verify the data read is correct */
+ for(i = 0; i < 100; i++)
+ VERIFY(rdbuf[i], check[i], "test_compatible");
+
+ /* Close the dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Remove the dataset */
+ ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Ldelete");
+
+ /* Close the file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-Open the file */
+ fid = H5Fopen(FILE5, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* The dataset should not be there */
+ did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT);
+ VERIFY(did, FAIL, "H5Dopen");
+
+ /* There should not be any free space in the file */
+ free_space = H5Fget_freespace(fid);
+ CHECK(free_space, FAIL, "H5Fget_freespace");
+ VERIFY(free_space, (hssize_t)0, "H5Fget_freespace");
+
+ /* Close the file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
+} /* test_filespace_compatible */
+
+/****************************************************************
+**
+** test_deprec():
+** Test deprecated functionality.
+**
+****************************************************************/
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+static void
+test_deprec(void)
+{
+ hid_t file; /* File IDs for old & new files */
+ hid_t fcpl; /* File creation property list */
+ unsigned super; /* Superblock version # */
+ unsigned freelist; /* Free list version # */
+ unsigned stab; /* Symbol table entry version # */
+ unsigned shhdr; /* Shared object header version # */
+ H5F_info1_t finfo; /* global information about file */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing deprecated routines\n"));
+
+ /* Creating a file with the default file creation property list should
+ * create a version 0 superblock
+ */
+
+ /* Create file with default file creation property list */
+ file= H5Fcreate(FILE1, H5F_ACC_TRUNC , H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ /* Get the file's version information */
+ ret = H5Fget_info1(file, &finfo);
+ CHECK(ret, FAIL, "H5Fget_info1");
+ VERIFY(finfo.super_ext_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1");
+
+ /* Get the file's dataset creation property list */
+ fcpl = H5Fget_create_plist(file);
+ CHECK(fcpl, FAIL, "H5Fget_create_plist");
+
+ /* Get the file's version information */
+ ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
+ CHECK(ret, FAIL, "H5Pget_version");
+ VERIFY(super,0,"H5Pget_version");
+ VERIFY(freelist,0,"H5Pget_version");
+ VERIFY(stab,0,"H5Pget_version");
+ VERIFY(shhdr,0,"H5Pget_version");
+
+ /* Close FCPL */
+ ret=H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close file */
+ ret=H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Create a file creation property list */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+
+ /* Set a property in the FCPL that will push the superblock version up */
+ ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_VFD, (hsize_t)0);
+ CHECK(ret, FAIL, "H5Pset_file_space");
+
+ /* Creating a file with the non-default file creation property list should
+ * create a version 2 superblock
+ */
+
+ /* Create file with custom file creation property list */
+ file= H5Fcreate(FILE1, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ /* Close FCPL */
+ ret=H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Get the file's version information */
+ ret = H5Fget_info1(file, &finfo);
+ CHECK(ret, FAIL, "H5Fget_info1");
+ VERIFY(finfo.super_ext_size, 40,"H5Fget_info1");
+ VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1");
+
+ /* Get the file's dataset creation property list */
+ fcpl = H5Fget_create_plist(file);
+ CHECK(fcpl, FAIL, "H5Fget_create_plist");
+
+ /* Get the file's version information */
+ ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
+ CHECK(ret, FAIL, "H5Pget_version");
+ VERIFY(super,2,"H5Pget_version");
+ VERIFY(freelist,0,"H5Pget_version");
+ VERIFY(stab,0,"H5Pget_version");
+ VERIFY(shhdr,0,"H5Pget_version");
+
+ /* Close FCPL */
+ ret=H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close file */
+ ret=H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-open the file */
+ file = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ /* Get the file's version information */
+ ret = H5Fget_info1(file, &finfo);
+ CHECK(ret, FAIL, "H5Fget_info1");
+ VERIFY(finfo.super_ext_size, 40,"H5Fget_info1");
+ VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1");
+ VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1");
+
+ /* Get the file's creation property list */
+ fcpl = H5Fget_create_plist(file);
+ CHECK(fcpl, FAIL, "H5Fget_create_plist");
+
+ /* Get the file's version information */
+ ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
+ CHECK(ret, FAIL, "H5Pget_version");
+ VERIFY(super,2,"H5Pget_version");
+ VERIFY(freelist,0,"H5Pget_version");
+ VERIFY(stab,0,"H5Pget_version");
+ VERIFY(shhdr,0,"H5Pget_version");
+
+ /* Close FCPL */
+ ret=H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close file */
+ ret=H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_deprec */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+/****************************************************************
+**
** test_file(): Main low-level file I/O test routine.
**
****************************************************************/
@@ -1866,7 +3231,17 @@ test_file(void)
test_file_double_dataset_open(); /* Test opening same dataset from two files works properly */
test_file_double_datatype_open(); /* Test opening same named datatype from two files works properly */
#endif /*H5_CANNOT_OPEN_TWICE*/
-} /* test_file() */
+ test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */
+ test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */
+ test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */
+ test_userblock_alignment(); /* Tests that files created with a userblock and alignment interact properly */
+ test_filespace_sects(); /* Test file free space section information */
+ test_filespace_info(); /* Test file creation public routines:H5Pget/set_file_space */
+ test_filespace_compatible();/* Test compatibility for file space management */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ test_deprec(); /* Test deprecated routines */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+} /* test_file() */
/*-------------------------------------------------------------------------
@@ -1886,8 +3261,11 @@ test_file(void)
void
cleanup_file(void)
{
+ HDremove(SFILE1);
HDremove(FILE1);
HDremove(FILE2);
HDremove(FILE3);
HDremove(FILE4);
+ HDremove(FILE5);
}
+
diff --git a/test/tgenprop.c b/test/tgenprop.c
index 931133e..8fb2e23 100644
--- a/test/tgenprop.c
+++ b/test/tgenprop.c
@@ -367,11 +367,11 @@ test_genprop_class_iter(void)
/****************************************************************
**
-** test_genprop_cls_cb1(): Property List callback for test_genprop_class_callback
+** test_genprop_cls_*_cb1(): Property List callbacks for test_genprop_class_callback
**
****************************************************************/
static herr_t
-test_genprop_cls_cb1(hid_t list_id, void *create_data)
+test_genprop_cls_crt_cb1(hid_t list_id, void *create_data)
{
struct { /* Struct for iterations */
int count;
@@ -385,18 +385,33 @@ test_genprop_cls_cb1(hid_t list_id, void *create_data)
}
static herr_t
-test_genprop_cls_cb2(hid_t new_list_id, hid_t UNUSED old_list_id, void *create_data)
+test_genprop_cls_cpy_cb1(hid_t new_list_id, hid_t UNUSED old_list_id, void *copy_data)
{
struct { /* Struct for iterations */
int count;
hid_t id;
- } *count_struct=create_data;
+ } *count_struct=copy_data;
count_struct->count++;
count_struct->id=new_list_id;
return(SUCCEED);
}
+
+static herr_t
+test_genprop_cls_cls_cb1(hid_t list_id, void *create_data)
+{
+ struct { /* Struct for iterations */
+ int count;
+ hid_t id;
+ } *count_struct=create_data;
+
+ count_struct->count++;
+ count_struct->id=list_id;
+
+ return(SUCCEED);
+}
+
/****************************************************************
**
** test_genprop_class_callback(): Test basic generic property list code.
@@ -407,20 +422,22 @@ static void
test_genprop_class_callback(void)
{
hid_t cid1; /* Generic Property class ID */
+ hid_t cid2; /* Generic Property class ID */
hid_t lid1; /* Generic Property list ID */
hid_t lid2; /* Generic Property list ID */
+ hid_t lid3; /* Generic Property list ID */
size_t nprops; /* Number of properties in class */
struct { /* Struct for callbacks */
int count;
hid_t id;
- } crt_cb_struct, cls_cb_struct;
+ } crt_cb_struct, cpy_cb_struct, cls_cb_struct;
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Generic Property List Class Callback Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME,test_genprop_cls_cb1,&crt_cb_struct,NULL, NULL,test_genprop_cls_cb1,&cls_cb_struct);
+ cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, test_genprop_cls_crt_cb1, &crt_cb_struct, test_genprop_cls_cpy_cb1, &cpy_cb_struct, test_genprop_cls_cls_cb1, &cls_cb_struct);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with no callbacks) */
@@ -435,18 +452,16 @@ test_genprop_class_callback(void)
ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
CHECK_I(ret, "H5Pregister2");
- /* Insert fourth property into class (with no callbacks) */
- ret = H5Pregister2(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- CHECK_I(ret, "H5Pregister2");
-
/* Check the number of properties in class */
ret = H5Pget_nprops(cid1,&nprops);
CHECK_I(ret, "H5Pget_nprops");
- VERIFY(nprops, 4, "H5Pget_nprops");
+ VERIFY(nprops, 3, "H5Pget_nprops");
/* Initialize class callback structs */
crt_cb_struct.count=0;
crt_cb_struct.id=(-1);
+ cpy_cb_struct.count=0;
+ cpy_cb_struct.id=(-1);
cls_cb_struct.count=0;
cls_cb_struct.id=(-1);
@@ -461,7 +476,7 @@ test_genprop_class_callback(void)
/* Check the number of properties in list */
ret = H5Pget_nprops(lid1,&nprops);
CHECK_I(ret, "H5Pget_nprops");
- VERIFY(nprops, 4, "H5Pget_nprops");
+ VERIFY(nprops, 3, "H5Pget_nprops");
/* Create another property list from the class */
lid2 = H5Pcreate(cid1);
@@ -474,7 +489,20 @@ test_genprop_class_callback(void)
/* Check the number of properties in list */
ret = H5Pget_nprops(lid2,&nprops);
CHECK_I(ret, "H5Pget_nprops");
- VERIFY(nprops, 4, "H5Pget_nprops");
+ VERIFY(nprops, 3, "H5Pget_nprops");
+
+ /* Create another property list by copying an existing list */
+ lid3 = H5Pcopy(lid1);
+ CHECK_I(lid3, "H5Pcopy");
+
+ /* Verify that the copy callback occurred */
+ VERIFY(cpy_cb_struct.count, 1, "H5Pcopy");
+ VERIFY(cpy_cb_struct.id, lid3, "H5Pcopy");
+
+ /* Check the number of properties in list */
+ ret = H5Pget_nprops(lid3, &nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 3, "H5Pget_nprops");
/* Close first list */
ret = H5Pclose(lid1);
@@ -492,9 +520,75 @@ test_genprop_class_callback(void)
VERIFY(cls_cb_struct.count, 2, "H5Pclose");
VERIFY(cls_cb_struct.id, lid2, "H5Pclose");
- /* Close class */
+ /* Close third list */
+ ret = H5Pclose(lid3);
+ CHECK_I(ret, "H5Pclose");
+
+ /* Verify that the close callback occurred */
+ VERIFY(cls_cb_struct.count, 3, "H5Pclose");
+ VERIFY(cls_cb_struct.id, lid3, "H5Pclose");
+
+ /* Create another new generic class, derived from first class */
+ cid2 = H5Pcreate_class(cid1, CLASS2_NAME, test_genprop_cls_crt_cb1, &crt_cb_struct, test_genprop_cls_cpy_cb1, &cpy_cb_struct, test_genprop_cls_cls_cb1, &cls_cb_struct);
+ CHECK_I(cid2, "H5Pcreate_class");
+
+ /* Insert fourth property into class (with no callbacks) */
+ ret = H5Pregister2(cid2, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ CHECK_I(ret, "H5Pregister2");
+
+ /* Check the number of properties in class */
+ /* (only reports the number of properties in 2nd class) */
+ ret = H5Pget_nprops(cid2, &nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 1, "H5Pget_nprops");
+
+ /* Create a property list from the 2nd class */
+ lid1 = H5Pcreate(cid2);
+ CHECK_I(lid1, "H5Pcreate");
+
+ /* Verify that both of the creation callbacks occurred */
+ VERIFY(crt_cb_struct.count, 4, "H5Pcreate");
+ VERIFY(crt_cb_struct.id, lid1, "H5Pcreate");
+
+ /* Check the number of properties in list */
+ ret = H5Pget_nprops(lid1, &nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 4, "H5Pget_nprops");
+
+ /* Create another property list by copying existing list */
+ lid2 = H5Pcopy(lid1);
+ CHECK_I(lid2, "H5Pcopy");
+
+ /* Verify that both of the copy callbacks occurred */
+ VERIFY(cpy_cb_struct.count, 3, "H5Pcopy");
+ VERIFY(cpy_cb_struct.id, lid2, "H5Pcopy");
+
+ /* Check the number of properties in list */
+ ret = H5Pget_nprops(lid2, &nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 4, "H5Pget_nprops");
+
+ /* Close first list */
+ ret = H5Pclose(lid1);
+ CHECK_I(ret, "H5Pclose");
+
+ /* Verify that both of the close callbacks occurred */
+ VERIFY(cls_cb_struct.count, 5, "H5Pclose");
+ VERIFY(cls_cb_struct.id, lid1, "H5Pclose");
+
+ /* Close second list */
+ ret = H5Pclose(lid2);
+ CHECK_I(ret, "H5Pclose");
+
+ /* Verify that both of the close callbacks occurred */
+ VERIFY(cls_cb_struct.count, 7, "H5Pclose");
+ VERIFY(cls_cb_struct.id, lid2, "H5Pclose");
+
+ /* Close classes */
ret = H5Pclose_class(cid1);
CHECK_I(ret, "H5Pclose_class");
+ ret = H5Pclose_class(cid2);
+ CHECK_I(ret, "H5Pclose_class");
} /* end test_genprop_class_callback() */
/****************************************************************
@@ -891,6 +985,26 @@ typedef struct {
/* Global variables for Callback information */
prop_cb_info prop1_cb_info; /* Callback statistics for property #1 */
prop_cb_info prop2_cb_info; /* Callback statistics for property #2 */
+prop_cb_info prop3_cb_info; /* Callback statistics for property #3 */
+
+/****************************************************************
+**
+** test_genprop_cls_cpy_cb2(): Property Class callback for test_genprop_list_callback
+**
+****************************************************************/
+static herr_t
+test_genprop_cls_cpy_cb2(hid_t new_list_id, hid_t UNUSED old_list_id, void *create_data)
+{
+ struct { /* Struct for iterations */
+ int count;
+ hid_t id;
+ } *count_struct=create_data;
+
+ count_struct->count++;
+ count_struct->id=new_list_id;
+
+ return(SUCCEED);
+}
/****************************************************************
**
@@ -974,12 +1088,26 @@ test_genprop_prop_cop_cb1(const char *name, size_t size, void *value)
**
****************************************************************/
static int
-test_genprop_prop_cmp_cb1(const void UNUSED *value1, const void UNUSED *value2, size_t UNUSED size)
+test_genprop_prop_cmp_cb1(const void *value1, const void *value2, size_t size)
{
/* Set the information from the comparison call */
prop1_cb_info.cmp_count++;
- return(0);
+ return(HDmemcmp(value1, value2, size));
+}
+
+/****************************************************************
+**
+** test_genprop_prop_cmp_cb3(): Property comparison callback for test_genprop_list_callback
+**
+****************************************************************/
+static int
+test_genprop_prop_cmp_cb3(const void *value1, const void *value2, size_t size)
+{
+ /* Set the information from the comparison call */
+ prop3_cb_info.cmp_count++;
+
+ return(HDmemcmp(value1, value2, size));
}
/****************************************************************
@@ -1036,6 +1164,7 @@ test_genprop_list_callback(void)
int prop1_new_value=20; /* Property #1 new value */
float prop2_value; /* Value for property #2 */
char prop3_value[10];/* Property #3 value */
+ char prop3_new_value[10]="10 chairs"; /* Property #3 new value */
double prop4_value; /* Property #4 value */
struct { /* Struct for callbacks */
int count;
@@ -1047,7 +1176,7 @@ test_genprop_list_callback(void)
MESSAGE(5, ("Testing Basic Generic Property List Property Callback Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL,test_genprop_cls_cb2,&cop_cb_struct,NULL, NULL);
+ cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL,test_genprop_cls_cpy_cb2,&cop_cb_struct,NULL, NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with callbacks) */
@@ -1058,8 +1187,8 @@ test_genprop_list_callback(void)
ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL,test_genprop_prop_del_cb2,NULL, NULL, NULL);
CHECK_I(ret, "H5Pregister2");
- /* Insert third property into class (with no callbacks) */
- ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ /* Insert third property into class (with only compare callback) */
+ ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, test_genprop_prop_cmp_cb3, NULL);
CHECK_I(ret, "H5Pregister2");
/* Insert fourth property into class (with no callbacks) */
@@ -1078,11 +1207,19 @@ test_genprop_list_callback(void)
/* Initialize callback information for properties tracked */
HDmemset(&prop1_cb_info,0,sizeof(prop_cb_info));
HDmemset(&prop2_cb_info,0,sizeof(prop_cb_info));
+ HDmemset(&prop3_cb_info,0,sizeof(prop_cb_info));
/* Create a property list from the class */
lid1 = H5Pcreate(cid1);
CHECK_I(lid1, "H5Pcreate");
+ /* The compare callback should have been called once on property 1 (to check
+ * if the create callback modified the value) */
+ VERIFY(prop1_cb_info.cmp_count, 1, "H5Pequal");
+ /* The compare callback should not have been called on property 3, as there
+ * is no create callback */
+ VERIFY(prop3_cb_info.cmp_count, 0, "H5Pequal");
+
/* Verify creation callback information for properties tracked */
VERIFY(prop1_cb_info.crt_count, 1, "H5Pcreate");
if(HDstrcmp(prop1_cb_info.crt_name, PROP1_NAME)!=0)
@@ -1094,6 +1231,9 @@ test_genprop_list_callback(void)
ret = H5Pget(lid1, PROP1_NAME,&prop1_value);
CHECK_I(ret, "H5Pget");
VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget");
+ /* The compare callback should have been called once (to check if the get
+ * callback modified the value) */
+ VERIFY(prop1_cb_info.cmp_count, 2, "H5Pequal");
ret = H5Pget(lid1, PROP2_NAME,&prop2_value);
CHECK_I(ret, "H5Pget");
/* Verify the floating-poing value in this way to avoid compiler warning. */
@@ -1106,6 +1246,9 @@ test_genprop_list_callback(void)
CHECK_I(ret, "H5Pget");
if(HDmemcmp(&prop3_value, PROP3_DEF_VALUE, PROP3_SIZE)!=0)
TestErrPrintf("Property #3 doesn't match!, line=%d\n",__LINE__);
+ /* The compare callback should not have been called, as there is no get
+ * callback for this property */
+ VERIFY(prop3_cb_info.cmp_count, 0, "H5Pequal");
ret = H5Pget(lid1, PROP4_NAME,&prop4_value);
CHECK_I(ret, "H5Pget");
/* Verify the floating-poing value in this way to avoid compiler warning. */
@@ -1133,6 +1276,18 @@ test_genprop_list_callback(void)
if(HDmemcmp(prop1_cb_info.set_value,&prop1_new_value, PROP1_SIZE)!=0)
TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__);
+ /* The compare callback should have been called once (to check if the new
+ * value needed to be copied onto the property list) */
+ VERIFY(prop1_cb_info.cmp_count, 3, "H5Pequal");
+
+ /* Set value of property #3 to different value */
+ ret = H5Pset(lid1, PROP3_NAME,prop3_new_value);
+ CHECK_I(ret, "H5Pset");
+
+ /* The compare callback should have been called once (to check if the new
+ * value needed to be copied onto the property list) */
+ VERIFY(prop3_cb_info.cmp_count, 1, "H5Pequal");
+
/* Check new value of tracked properties */
ret = H5Pget(lid1, PROP1_NAME,&prop1_value);
CHECK_I(ret, "H5Pget");
@@ -1178,7 +1333,8 @@ test_genprop_list_callback(void)
VERIFY(ret, 1, "H5Pequal");
/* Verify compare callback information for properties tracked */
- VERIFY(prop1_cb_info.cmp_count, 1, "H5Pequal");
+ VERIFY(prop1_cb_info.cmp_count, 4, "H5Pequal");
+ VERIFY(prop3_cb_info.cmp_count, 2, "H5Pequal");
/* Close first list */
ret = H5Pclose(lid1);
@@ -1322,7 +1478,7 @@ test_genprop_class_addprop(void)
CHECK_I(cid, "H5Pcreate_class");
/* Check existence of an original property */
- ret = H5Pexist(cid,H5D_CRT_DATA_PIPELINE_NAME);
+ ret = H5Pexist(cid,H5O_CRT_PIPELINE_NAME);
VERIFY(ret, 0, "H5Pexist");
/* Insert first property into class (with no callbacks) */
@@ -1334,7 +1490,7 @@ test_genprop_class_addprop(void)
CHECK(pid, FAIL, "H5Pcreate");
/* Check existence of an original property */
- ret = H5Pexist(pid, H5D_CRT_DATA_PIPELINE_NAME);
+ ret = H5Pexist(pid, H5O_CRT_PIPELINE_NAME);
VERIFY(ret, 1, "H5Pexist");
/* Check existence of added property */
diff --git a/test/th5o.c b/test/th5o.c
index e6071e9..6091776 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -229,7 +229,7 @@ test_h5o_close(void)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
}
-
+
/****************************************************************
**
@@ -834,7 +834,7 @@ test_h5o_link(void)
/* Read the data back */
ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dread");
-
+
/* Verify the data */
for(i = 0; i < TEST6_DIM1; i++)
for(j = 0; j < TEST6_DIM2; j++)
@@ -878,7 +878,7 @@ test_h5o_link(void)
for(i = 0; i < TEST6_DIM1; i++)
for(j = 0; j < TEST6_DIM2; j++)
VERIFY(wdata[i][j], rdata[i][j], "H5Dread");
-
+
/* Close open IDs */
ret = H5Dclose(dset_id);
CHECK(ret, FAIL, "H5Dclose");
diff --git a/test/th5s.c b/test/th5s.c
index 5bf7845..e21dee2 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -39,14 +39,12 @@
#define NULLATTR "null_attribute"
/* 3-D dataset with fixed dimensions */
-#define SPACE1_NAME "Space1"
#define SPACE1_RANK 3
#define SPACE1_DIM1 3
#define SPACE1_DIM2 15
#define SPACE1_DIM3 13
/* 4-D dataset with one unlimited dimension */
-#define SPACE2_NAME "Space2"
#define SPACE2_RANK 4
#define SPACE2_DIM1 0
#define SPACE2_DIM2 15
@@ -58,13 +56,10 @@
#define SPACE2_MAX4 23
/* Scalar dataset with simple datatype */
-#define SPACE3_NAME "Scalar1"
#define SPACE3_RANK 0
unsigned space3_data=65;
/* Scalar dataset with compound datatype */
-#define SPACE4_NAME "Scalar2"
-#define SPACE4_RANK 0
#define SPACE4_FIELDNAME1 "c1"
#define SPACE4_FIELDNAME2 "u"
#define SPACE4_FIELDNAME3 "f"
diff --git a/test/theap.c b/test/theap.c
index 0c39868..230ec4d 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -93,7 +93,7 @@ test_heap_init(void)
/* Create randomized set of numbers */
curr_time=time(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
for(u=0; u<NUM_ELEMS; u++)
/* Generate random numbers from -1000 to 1000 */
rand_num[u].val=(int)(HDrandom()%2001)-1001;
diff --git a/test/tid.c b/test/tid.c
index 8eb4e24..9bb93e7 100644
--- a/test/tid.c
+++ b/test/tid.c
@@ -112,7 +112,7 @@ static int basic_id_test(void)
H5E_END_TRY
VERIFY(testSize, -1, "H5Iget_name");
- if(testSize != 0)
+ if(testSize != -1)
goto out;
/* Make sure H5Iremove_verify catches objects of the wrong type */
@@ -332,6 +332,123 @@ out:
}
+/* Test the H5Iis_valid function */
+static int test_is_valid(void)
+{
+ hid_t dtype; /* datatype id */
+ int nmembs1; /* number of type memnbers */
+ int nmembs2;
+ htri_t tri_ret; /* htri_t return value */
+ herr_t ret; /* return value */
+
+ /* Create a datatype id */
+ dtype = H5Tcopy(H5T_NATIVE_INT);
+ CHECK(dtype, FAIL, "H5Tcopy");
+ if (dtype < 0)
+ goto out;
+
+ /* Check that the ID is valid */
+ tri_ret = H5Iis_valid(dtype);
+ VERIFY(tri_ret, TRUE, "H5Iis_valid");
+ if (tri_ret != TRUE)
+ goto out;
+
+ /* Artificially manipulate the reference counts so app_count is 0, and dtype
+ * appears to be an internal id. This takes advantage of the fact that
+ * H5Ipkg is included.
+ */
+ ret = H5I_inc_ref(dtype, FALSE);
+ CHECK(ret, FAIL, "H5I_inc_ref");
+ if (ret < 0)
+ goto out;
+ ret = H5I_dec_ref(dtype, TRUE);
+ CHECK(ret, FAIL, "H5I_dec_ref");
+ if (ret < 0)
+ goto out;
+
+ /* Check that dtype is invalid */
+ tri_ret = H5Iis_valid(dtype);
+ VERIFY(tri_ret, FALSE, "H5Iis_valid");
+ if (tri_ret != FALSE)
+ goto out;
+
+ /* Close dtype and verify that it has been closed */
+ nmembs1 = H5I_nmembers(H5I_DATATYPE);
+ CHECK(nmembs1, FAIL, "H5I_nmembers");
+ if (nmembs1 < 0)
+ goto out;
+ ret = H5I_dec_ref(dtype, FALSE);
+ CHECK(ret, FAIL, "H5I_dec_ref");
+ if (ret < 0)
+ goto out;
+ nmembs2 = H5I_nmembers(H5I_DATATYPE);
+ VERIFY(nmembs2, nmembs1 - 1, "H5I_nmembers");
+ if (nmembs2 != nmembs1 - 1)
+ goto out;
+
+ /* Check that dtype is invalid */
+ tri_ret = H5Iis_valid(dtype);
+ VERIFY(tri_ret, FALSE, "H5Iis_valid");
+ if (tri_ret != FALSE)
+ goto out;
+
+ /* Check that an id of -1 is invalid */
+ tri_ret = H5Iis_valid(-1);
+ VERIFY(tri_ret, FALSE, "H4Iis_valid");
+ if (tri_ret != FALSE)
+ goto out;
+
+ return 0;
+
+out:
+ /* Don't attempt to close dtype as we don't know the exact state of the
+ * reference counts. Every state in this function will be automatically
+ * closed at library exit anyways, as internal count is never > 1.
+ */
+ return -1;
+}
+
+/* Test the H5Iget_type function */
+static int test_get_type(void)
+{
+ hid_t dtype; /* datatype id */
+ H5I_type_t type_ret; /* return value */
+
+ /* Create a datatype id */
+ dtype = H5Tcopy(H5T_NATIVE_INT);
+ CHECK(dtype, FAIL, "H5Tcopy");
+ if (dtype < 0)
+ goto out;
+
+ /* Check that the ID is correct */
+ type_ret = H5Iget_type(dtype);
+ VERIFY(type_ret, H5I_DATATYPE, "H5Iget_type");
+ if (type_ret == H5I_BADID)
+ goto out;
+
+ /* Check that the ID is correct */
+ type_ret = H5Iget_type(H5T_STRING);
+ VERIFY(type_ret, H5I_BADID, "H5Iget_type");
+ if (type_ret != H5I_BADID)
+ goto out;
+
+ /* Check that the ID is correct */
+ type_ret = H5Iget_type(-1);
+ VERIFY(type_ret, H5I_BADID, "H5Iget_type");
+ if (type_ret != H5I_BADID)
+ goto out;
+
+ H5Tclose(dtype);
+
+ return 0;
+
+out:
+ if(dtype != H5I_INVALID_HID)
+ H5Tclose(dtype);
+
+ return -1;
+}
+
/* Test boundary cases with lots of types */
/* Type IDs range from H5I_NTYPES to MAX_NUM_TYPES. The system will assign */
@@ -418,8 +535,10 @@ out:
void test_ids(void)
{
- basic_id_test();
- id_predefined_test();
- test_id_type_list();
+ if (basic_id_test() < 0) TestErrPrintf("Basic ID test failed\n");
+ if (id_predefined_test() < 0) TestErrPrintf("Predefined ID type test failed\n");
+ if (test_is_valid() < 0) TestErrPrintf("H5Iis_valid test failed\n");
+ if (test_get_type() < 0) TestErrPrintf("H5Iget_type test failed\n");
+ if (test_id_type_list() < 0) TestErrPrintf("ID type list test failed\n");
}
diff --git a/test/tmisc.c b/test/tmisc.c
index 7543ceb..55e4c27 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -300,6 +300,16 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#define MISC27_FILE "tbad_msg_count.h5"
#define MISC27_GROUP "Group"
+/* Definitions for misc. test #28 */
+#define MISC28_FILE "tmisc28.h5"
+#define MISC28_SIZE 10
+#define MISC28_NSLOTS 10000
+
+/* Definitions for misc. test #29 */
+#define MISC29_ORIG_FILE "specmetaread.h5"
+#define MISC29_COPY_FILE "tmisc29.h5"
+#define MISC29_DSETNAME "dset2"
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -1792,11 +1802,10 @@ test_misc11(void)
unsigned sym_ik; /* Symbol table B-tree initial 'K' value */
unsigned istore_ik; /* Indexed storage B-tree initial 'K' value */
unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */
- unsigned super; /* Superblock version # */
- unsigned freelist; /* Free list version # */
- unsigned stab; /* Symbol table entry version # */
- unsigned shhdr; /* Shared object header version # */
unsigned nindexes; /* Shared message number of indexes */
+ H5F_info2_t finfo; /* global information about file */
+ H5F_file_space_type_t strategy; /* File/free space strategy */
+ hsize_t threshold; /* Free-space section threshold */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -1810,21 +1819,12 @@ test_misc11(void)
file= H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC , H5P_DEFAULT, H5P_DEFAULT);
CHECK(file, FAIL, "H5Fcreate");
- /* Get the file's dataset creation property list */
- fcpl = H5Fget_create_plist(file);
- CHECK(fcpl, FAIL, "H5Fget_create_plist");
-
/* Get the file's version information */
- ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
- CHECK(ret, FAIL, "H5Pget_version");
- VERIFY(super,0,"H5Pget_version");
- VERIFY(freelist,0,"H5Pget_version");
- VERIFY(stab,0,"H5Pget_version");
- VERIFY(shhdr,0,"H5Pget_version");
-
- /* Close FCPL */
- ret=H5Pclose(fcpl);
- CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Fget_info2(file, &finfo);
+ CHECK(ret, FAIL, "H5Fget_info2");
+ VERIFY(finfo.super.version, 0,"H5Fget_info2");
+ VERIFY(finfo.free.version, 0,"H5Fget_info2");
+ VERIFY(finfo.sohm.version, 0,"H5Fget_info2");
/* Close file */
ret=H5Fclose(file);
@@ -1851,6 +1851,9 @@ test_misc11(void)
ret=H5Pset_shared_mesg_nindexes(fcpl,MISC11_NINDEXES);
CHECK(ret, FAIL, "H5Pset_shared_mesg");
+ ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_VFD, 0);
+ CHECK(ret, FAIL, "H5Pset_file_space");
+
/* Creating a file with the non-default file creation property list should
* create a version 1 superblock
*/
@@ -1863,21 +1866,12 @@ test_misc11(void)
ret=H5Pclose(fcpl);
CHECK(ret, FAIL, "H5Pclose");
- /* Get the file's dataset creation property list */
- fcpl = H5Fget_create_plist(file);
- CHECK(fcpl, FAIL, "H5Fget_create_plist");
-
/* Get the file's version information */
- ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
- CHECK(ret, FAIL, "H5Pget_version");
- VERIFY(super,2,"H5Pget_version");
- VERIFY(freelist,0,"H5Pget_version");
- VERIFY(stab,0,"H5Pget_version");
- VERIFY(shhdr,0,"H5Pget_version");
-
- /* Close FCPL */
- ret=H5Pclose(fcpl);
- CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Fget_info2(file, &finfo);
+ CHECK(ret, FAIL, "H5Fget_info2");
+ VERIFY(finfo.super.version, 2,"H5Fget_info2");
+ VERIFY(finfo.free.version, 0,"H5Fget_info2");
+ VERIFY(finfo.sohm.version, 0,"H5Fget_info2");
/* Close file */
ret=H5Fclose(file);
@@ -1887,17 +1881,16 @@ test_misc11(void)
file = H5Fopen(MISC11_FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK(file, FAIL, "H5Fcreate");
- /* Get the file's dataset creation property list */
+ /* Get the file's creation property list */
fcpl = H5Fget_create_plist(file);
CHECK(fcpl, FAIL, "H5Fget_create_plist");
/* Get the file's version information */
- ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
- CHECK(ret, FAIL, "H5Pget_version");
- VERIFY(super,2,"H5Pget_version");
- VERIFY(freelist,0,"H5Pget_version");
- VERIFY(stab,0,"H5Pget_version");
- VERIFY(shhdr,0,"H5Pget_version");
+ ret = H5Fget_info2(file, &finfo);
+ CHECK(ret, FAIL, "H5Fget_info2");
+ VERIFY(finfo.super.version, 2,"H5Fget_info2");
+ VERIFY(finfo.free.version, 0,"H5Fget_info2");
+ VERIFY(finfo.sohm.version, 0,"H5Fget_info2");
/* Retrieve all the property values & check them */
ret=H5Pget_userblock(fcpl,&userblock);
@@ -1922,6 +1915,11 @@ test_misc11(void)
CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes");
VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes");
+ ret = H5Pget_file_space(fcpl, &strategy, &threshold);
+ CHECK(ret, FAIL, "H5Pget_file_space");
+ VERIFY(strategy, 4, "H5Pget_file_space");
+ VERIFY(threshold, 1, "H5Pget_file_space");
+
/* Close file */
ret=H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
@@ -2268,7 +2266,7 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz
VERIFY(ret, 0, "HDfclose");
/* Close the new file */
- ret=fclose(new_fp);
+ ret=HDfclose(new_fp);
VERIFY(ret, 0, "HDfclose");
/* Free the copy buffer */
@@ -3774,6 +3772,7 @@ test_misc23(void)
tmp_id=0, create_id=H5P_DEFAULT, access_id=H5P_DEFAULT;
char objname[MISC23_NAME_BUF_SIZE]; /* Name of object */
H5O_info_t oinfo;
+ htri_t tri_status;
herr_t status;
/* Output message about test being performed */
@@ -3989,7 +3988,7 @@ test_misc23(void)
status = H5Tcommit2(group_id, "B13/C12/dtype", tmp_id, create_id, H5P_DEFAULT, access_id);
CHECK(status, FAIL, "H5Tcommit2");
-
+
status = H5Tclose(tmp_id);
CHECK(status, FAIL, "H5Tclose");
@@ -4017,6 +4016,87 @@ test_misc23(void)
status = H5Pclose(create_id);
CHECK(status, FAIL, "H5Pclose");
+ /**********************************************************************
+ * test H5Lcopy()
+ **********************************************************************/
+
+ /* Create link creation property list */
+ create_id = H5Pcreate(H5P_LINK_CREATE);
+ CHECK(create_id, FAIL, "H5Pcreate");
+
+ /* Set flag for intermediate group creation */
+ status = H5Pset_create_intermediate_group(create_id, TRUE);
+ CHECK(status, FAIL, "H5Pset_create_intermediate_group");
+
+ status = H5Lcopy(file_id, "/A/B01/grp", file_id, "/A/B16/grp", create_id, access_id);
+ CHECK(status, FAIL, "H5Lcopy");
+
+ tri_status = H5Lexists(file_id, "/A/B16/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ tri_status = H5Lexists(file_id, "/A/B01/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ /**********************************************************************
+ * test H5Lmove()
+ **********************************************************************/
+
+ status = H5Lmove(file_id, "/A/B16/grp", file_id, "/A/B17/grp", create_id, access_id);
+ CHECK(status, FAIL, "H5Lmove");
+
+ tri_status = H5Lexists(file_id, "/A/B17/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ tri_status = H5Lexists(file_id, "/A/B16/grp", access_id);
+ VERIFY(tri_status, FALSE, "H5Lexists");
+
+ /**********************************************************************
+ * test H5Lcreate_hard()
+ **********************************************************************/
+
+ status = H5Lcreate_hard(file_id, "/A/B01/grp", file_id, "/A/B18/grp", create_id, access_id);
+ CHECK(status, FAIL, "H5Lcreate_hard");
+
+ tri_status = H5Lexists(file_id, "/A/B18/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ /**********************************************************************
+ * test H5Lcreate_soft()
+ **********************************************************************/
+
+ status = H5Lcreate_soft("/A/B01/grp", file_id, "/A/B19/grp", create_id, access_id);
+ CHECK(status, FAIL, "H5Lcreate_soft");
+
+ tri_status = H5Lexists(file_id, "/A/B19/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ /**********************************************************************
+ * test H5Lcreate_external()
+ **********************************************************************/
+
+ status = H5Lcreate_external("fake_filename", "fake_path", file_id, "/A/B20/grp", create_id, access_id);
+ CHECK(status, FAIL, "H5Lcreate_external");
+
+ tri_status = H5Lexists(file_id, "/A/B20/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ /**********************************************************************
+ * test H5Lcreate_ud()
+ **********************************************************************/
+
+ status = H5Lcreate_ud(file_id, "/A/B21/grp", H5L_TYPE_EXTERNAL, "file\0obj", (size_t) 9, create_id, access_id);
+ CHECK(status, FAIL, "H5Lcreate_ud");
+
+ tri_status = H5Lexists(file_id, "/A/B21/grp", access_id);
+ VERIFY(tri_status, TRUE, "H5Lexists");
+
+ /**********************************************************************
+ * close
+ **********************************************************************/
+
+ status = H5Pclose(create_id);
+ CHECK(status, FAIL, "H5Pclose");
+
status = H5Gclose(group_id);
CHECK(status, FAIL, "H5Gclose");
@@ -4854,6 +4934,216 @@ test_misc27(void)
CHECK(ret, FAIL, "H5Fclose");
} /* end test_misc27() */
+
+/****************************************************************
+**
+** test_misc28(): Ensure that the dataset chunk cache will hold
+** the correct number of chunks in cache without
+** evicting them.
+**
+****************************************************************/
+static void
+test_misc28(void)
+{
+ hid_t fid; /* File ID */
+ hid_t sidf; /* File Dataspace ID */
+ hid_t sidm; /* Memory Dataspace ID */
+ hid_t did; /* Dataset ID */
+ hid_t dcpl, fapl; /* Property List IDs */
+ hsize_t dims[] = {MISC28_SIZE, MISC28_SIZE};
+ hsize_t mdims[] = {MISC28_SIZE};
+ hsize_t cdims[] = {1, 1};
+ hsize_t start[] = {0,0};
+ hsize_t count[] = {MISC28_SIZE, 1};
+ size_t nbytes_used;
+ int nused;
+ char buf[MISC28_SIZE];
+ int i;
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Dataset chunk cache\n"));
+
+ /* Create the fapl and set the cache size. Set nelmts to larger than the
+ * file size so we can be guaranteed that no chunks will be evicted due to
+ * a hash collision. Set nbytes to fit exactly 1 column of chunks (10
+ * bytes). */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+ ret = H5Pset_cache(fapl, MISC28_NSLOTS, MISC28_NSLOTS, MISC28_SIZE, 0.75);
+ CHECK(ret, FAIL, "H5Pset_cache");
+
+ /* Create the dcpl and set the chunk size */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_chunk(dcpl, 2, cdims);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+
+
+ /* Create a new file and datasets within that file that use these
+ * property lists
+ */
+ fid = H5Fcreate(MISC28_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ sidf = H5Screate_simple(2, dims, NULL);
+ CHECK(sidf, FAIL, "H5Screate_simple");
+
+ did = H5Dcreate2(fid, "dataset", H5T_NATIVE_CHAR, sidf, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ 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");
+
+ /* Initialize write buffer */
+ for(i=0; i<MISC28_SIZE; i++)
+ buf[i] = i;
+
+ /* Create memory dataspace and selection in file dataspace */
+ sidm = H5Screate_simple(1, mdims, NULL);
+ CHECK(sidm, FAIL, "H5Screate_simple");
+
+ ret = H5Sselect_hyperslab(sidf, H5S_SELECT_SET, start, NULL, count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Write hypserslab */
+ ret = H5Dwrite(did, H5T_NATIVE_CHAR, sidm, sidf, H5P_DEFAULT, buf);
+ 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");
+
+ /* Initialize write buffer */
+ for(i=0; i<MISC28_SIZE; i++)
+ buf[i] = MISC28_SIZE - 1 - i;
+
+ /* Select new hyperslab */
+ start[1] = 1;
+ ret = H5Sselect_hyperslab(sidf, H5S_SELECT_SET, start, NULL, count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Write hyperslab */
+ ret = H5Dwrite(did, H5T_NATIVE_CHAR, sidm, sidf, H5P_DEFAULT, buf);
+ 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");
+
+ /* Close dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+
+ /* Re open dataset */
+ did = H5Dopen2(fid, "dataset", H5P_DEFAULT);
+ 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");
+
+ /* Select hyperslabe for reading */
+ start[1] = 0;
+ ret = H5Sselect_hyperslab(sidf, H5S_SELECT_SET, start, NULL, count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Read hypserslab */
+ ret = H5Dread(did, H5T_NATIVE_CHAR, sidm, sidf, H5P_DEFAULT, buf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Verify the data read */
+ for(i=0; i<MISC28_SIZE; i++)
+ 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");
+
+ /* Select new hyperslab */
+ start[1] = 1;
+ ret = H5Sselect_hyperslab(sidf, H5S_SELECT_SET, start, NULL, count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Read hyperslab */
+ ret = H5Dread(did, H5T_NATIVE_CHAR, sidm, sidf, H5P_DEFAULT, buf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Verify the data read */
+ for(i=0; i<MISC28_SIZE; i++)
+ 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");
+
+ /* Close dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+
+ /* Close the dataspaces and file */
+ ret = H5Sclose(sidf);
+ CHECK_I(ret, "H5Sclose");
+ ret = H5Sclose(sidm);
+ CHECK_I(ret, "H5Sclose");
+ ret = H5Fclose(fid);
+ CHECK_I(ret, "H5Fclose");
+
+ /* Close the property lists. */
+ ret = H5Pclose(dcpl);
+ CHECK_I(ret, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK_I(ret, "H5Pclose");
+} /* end test_misc28() */
+
+
+/****************************************************************
+**
+** test_misc29(): Ensure that speculative metadata reads don't
+** get raw data into the metadata accumulator.
+**
+****************************************************************/
+static void
+test_misc29(void)
+{
+ hid_t fid; /* File ID */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Speculative metadata reads\n"));
+
+ /* Make a copy of the data file from svn. */
+ ret = h5_make_local_copy(MISC29_ORIG_FILE, MISC29_COPY_FILE);
+ CHECK(ret, -1, "h5_make_local_copy");
+
+ /* Open the copied file */
+ fid = H5Fopen(MISC29_COPY_FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Delete the last dataset */
+ ret = H5Ldelete(fid, MISC29_DSETNAME, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Ldelete");
+
+ /* Close the file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* end test_misc29() */
+
/****************************************************************
**
** test_misc(): Main misc. test routine.
@@ -4896,7 +5186,8 @@ test_misc(void)
test_misc25c(); /* Exercise another null object header message merge bug */
test_misc26(); /* Test closing property lists with long filter pipelines */
test_misc27(); /* Test opening file with object that has bad # of object header messages */
-
+ test_misc28(); /* Test that chunks are cached appropriately */
+ test_misc29(); /* Test that speculative metadata reads are handled correctly */
} /* test_misc() */
@@ -4950,5 +5241,7 @@ cleanup_misc(void)
HDremove(MISC25A_FILE);
HDremove(MISC25C_FILE);
HDremove(MISC26_FILE);
+ HDremove(MISC28_FILE);
+ HDremove(MISC29_COPY_FILE);
}
diff --git a/test/trefer.c b/test/trefer.c
index f8e2287..dbf12bc 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -30,18 +30,15 @@
#define FILE3 "trefer3.h5"
/* 1-D dataset with fixed dimensions */
-#define SPACE1_NAME "Space1"
#define SPACE1_RANK 1
#define SPACE1_DIM1 4
/* 2-D dataset with fixed dimensions */
-#define SPACE2_NAME "Space2"
#define SPACE2_RANK 2
#define SPACE2_DIM1 10
#define SPACE2_DIM2 10
/* Larger 1-D dataset with fixed dimensions */
-#define SPACE3_NAME "Space3"
#define SPACE3_RANK 1
#define SPACE3_DIM1 100
@@ -407,7 +404,7 @@ test_reference_region(void)
coord1[7][0] = 9; coord1[7][1] = 0;
coord1[8][0] = 7; coord1[8][1] = 1;
coord1[9][0] = 3; coord1[9][1] = 3;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
ret = (int)H5Sget_select_npoints(sid2);
@@ -679,7 +676,7 @@ test_reference_region_1D(void)
coord1[7][0] = 89;
coord1[8][0] = 97;
coord1[9][0] = 03;
- ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
ret = (int)H5Sget_select_npoints(sid3);
@@ -1264,7 +1261,7 @@ test_reference_compat(void)
coord1[7][0] = 9; coord1[7][1] = 0;
coord1[8][0] = 7; coord1[8][1] = 1;
coord1[9][0] = 3; coord1[9][1] = 3;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Create second dataset region */
diff --git a/test/trefstr.c b/test/trefstr.c
index 81394f2..c39a6eb 100644
--- a/test/trefstr.c
+++ b/test/trefstr.c
@@ -290,7 +290,6 @@ test_refstr_wrap(void)
static void
test_refstr_own(void)
{
- static const char *FUNC = "test_refstr_own";
H5RS_str_t *rs; /* Ref-counted string created */
char *s; /* Pointer to string to transfer */
const char *t; /* Temporary pointers to string */
diff --git a/test/tselect.c b/test/tselect.c
index 23afc46..5845a9b 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -164,21 +164,21 @@
/* Location comparison function */
-int compare_size_t(const void *s1, const void *s2);
+static int compare_size_t(const void *s1, const void *s2);
-herr_t test_select_hyper_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
-herr_t test_select_point_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
-herr_t test_select_all_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
-herr_t test_select_none_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
-herr_t test_select_hyper_iter2(void *_elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_operator_data);
-herr_t test_select_hyper_iter3(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
+static herr_t test_select_hyper_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
+static herr_t test_select_point_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
+static herr_t test_select_all_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
+static herr_t test_select_none_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
+static herr_t test_select_hyper_iter2(void *_elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_operator_data);
+static herr_t test_select_hyper_iter3(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
/****************************************************************
**
** test_select_hyper_iter1(): Iterator for checking hyperslab iteration
**
****************************************************************/
-herr_t
+static herr_t
test_select_hyper_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *_operator_data)
{
uint8_t *tbuf=(uint8_t *)_elem, /* temporary buffer pointer */
@@ -367,7 +367,7 @@ struct pnt_iter {
** (This is really ugly code, not a very good example of correct usage - QAK)
**
****************************************************************/
-herr_t
+static herr_t
test_select_point_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *_operator_data)
{
uint8_t *elem=(uint8_t *)_elem; /* Pointer to the element to examine */
@@ -447,7 +447,7 @@ test_select_point(hid_t xfer_plist)
coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Verify correct elements selected */
@@ -472,7 +472,7 @@ test_select_point(hid_t xfer_plist)
coord1[7][0]=1; coord1[7][1]=14; coord1[7][2]= 6;
coord1[8][0]=2; coord1[8][1]= 2; coord1[8][2]= 5;
coord1[9][0]=0; coord1[9][1]= 6; coord1[9][2]=13;
- ret = H5Sselect_elements(sid1, H5S_SELECT_APPEND, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_APPEND, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Verify correct elements selected */
@@ -497,7 +497,7 @@ test_select_point(hid_t xfer_plist)
coord2[7][0]=29; coord2[7][1]= 4;
coord2[8][0]= 8; coord2[8][1]= 8;
coord2[9][0]=19; coord2[9][1]=17;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord2);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Verify correct elements selected */
@@ -526,7 +526,7 @@ test_select_point(hid_t xfer_plist)
coord2[7][0]=12; coord2[7][1]= 2;
coord2[8][0]=21; coord2[8][1]=12;
coord2[9][0]= 9; coord2[9][1]=18;
- ret = H5Sselect_elements(sid2, H5S_SELECT_PREPEND, (size_t)POINT1_NPOINTS, coord2);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_PREPEND, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Verify correct elements selected */
@@ -568,7 +568,7 @@ test_select_point(hid_t xfer_plist)
coord3[7][0]= 1; coord3[7][1]=22;
coord3[8][0]=12; coord3[8][1]=21;
coord3[9][0]=11; coord3[9][1]= 6;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord3);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord3);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Verify correct elements selected */
@@ -592,7 +592,7 @@ test_select_point(hid_t xfer_plist)
coord3[7][0]= 9; coord3[7][1]=16;
coord3[8][0]=12; coord3[8][1]=22;
coord3[9][0]=13; coord3[9][1]= 9;
- ret = H5Sselect_elements(sid2, H5S_SELECT_APPEND, (size_t)POINT1_NPOINTS, coord3);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_APPEND, (size_t)POINT1_NPOINTS, (const hsize_t *)coord3);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Verify correct elements selected */
@@ -641,7 +641,7 @@ test_select_point(hid_t xfer_plist)
**
**
****************************************************************/
-herr_t
+static herr_t
test_select_all_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *_operator_data)
{
uint8_t *tbuf=(uint8_t *)_elem, /* temporary buffer pointer */
@@ -661,7 +661,7 @@ test_select_all_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, c
** (This is never supposed to be called, so it always returns -1)
**
****************************************************************/
-herr_t
+static herr_t
test_select_none_iter1(void UNUSED *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void UNUSED *_operator_data)
{
return(-1);
@@ -945,7 +945,7 @@ test_select_combo(void)
coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Select 1x10 hyperslab for writing memory dataset */
@@ -1012,7 +1012,7 @@ test_select_combo(void)
HDfree(rbuf);
} /* test_select_combo() */
-int
+static int
compare_size_t(const void *s1, const void *s2)
{
if(*(const size_t *)s1<*(const size_t *)s2)
@@ -1780,7 +1780,7 @@ test_select_point_copy(void)
coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Select sequence of ten points for write dataset */
@@ -1794,7 +1794,7 @@ test_select_point_copy(void)
coord2[7][0]=29; coord2[7][1]= 4;
coord2[8][0]= 8; coord2[8][1]= 8;
coord2[9][0]=19; coord2[9][1]=17;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord2);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Make a copy of the dataspace to write */
@@ -1838,7 +1838,7 @@ test_select_point_copy(void)
coord3[7][0]= 1; coord3[7][1]=22;
coord3[8][0]=12; coord3[8][1]=21;
coord3[9][0]=11; coord3[9][1]= 6;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord3);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord3);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Make a copy of the dataspace to read */
@@ -2227,7 +2227,7 @@ test_select_point_offset(void)
coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord1);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Check a valid offset */
@@ -2262,7 +2262,7 @@ test_select_point_offset(void)
coord2[7][0]=23; coord2[7][1]= 4;
coord2[8][0]= 8; coord2[8][1]= 8;
coord2[9][0]=19; coord2[9][1]=17;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord2);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Choose a valid offset for the memory dataspace */
@@ -2298,7 +2298,7 @@ test_select_point_offset(void)
coord3[7][0]= 1; coord3[7][1]=22;
coord3[8][0]=12; coord3[8][1]=21;
coord3[9][0]=11; coord3[9][1]= 6;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord3);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord3);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Read selection from disk */
@@ -3714,7 +3714,7 @@ test_select_hyper_nota_2d(void)
** test_select_hyper_iter2(): Iterator for checking hyperslab iteration
**
****************************************************************/
-herr_t
+static herr_t
test_select_hyper_iter2(void *_elem, hid_t UNUSED type_id, unsigned ndim, const hsize_t *point, void *_operator_data)
{
int *tbuf=(int *)_elem, /* temporary buffer pointer */
@@ -4248,7 +4248,7 @@ test_select_point_chunk(void)
points[6][1]=1;
points[7][0]=6; /* In same chunk as point #3, but "earlier" in chunk */
points[7][1]=6;
- ret = H5Sselect_elements(pnt1_space, H5S_SELECT_SET, (size_t)SPACE7_NPOINTS, points);
+ ret = H5Sselect_elements(pnt1_space, H5S_SELECT_SET, (size_t)SPACE7_NPOINTS, (const hsize_t *)points);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Create 1st hyperslab selection */
@@ -4284,7 +4284,7 @@ test_select_point_chunk(void)
points[6][1]=2;
points[7][0]=7; /* In same chunk as point #3, but "earlier" in chunk */
points[7][1]=7;
- ret = H5Sselect_elements(pnt2_space, H5S_SELECT_SET, (size_t)SPACE7_NPOINTS, points);
+ ret = H5Sselect_elements(pnt2_space, H5S_SELECT_SET, (size_t)SPACE7_NPOINTS, (const hsize_t *)points);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Create 2nd hyperslab selection */
@@ -4570,7 +4570,7 @@ test_select_combine(void)
none_id=H5Scopy(base_id);
CHECK(none_id, FAIL, "H5Scopy");
error=H5Sselect_none(none_id);
- CHECK(error, FAIL, "H5Sselect_all");
+ CHECK(error, FAIL, "H5Sselect_none");
sel_type=H5Sget_select_type(none_id);
VERIFY(sel_type, H5S_SEL_NONE, "H5Sget_select_type");
@@ -4900,7 +4900,7 @@ typedef struct {
** test_select_hyper_iter3(): Iterator for checking hyperslab iteration
**
****************************************************************/
-herr_t
+static herr_t
test_select_hyper_iter3(void *_elem, hid_t UNUSED type_id, unsigned ndim, const hsize_t *point, void *_operator_data)
{
unsigned short *tbuf=(unsigned short *)_elem; /* temporary buffer pointer */
@@ -5038,7 +5038,7 @@ test_select_fill_point(hssize_t *offset)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Select "point" selection */
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET,num_points,points);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET,num_points,(const hsize_t *)points);
CHECK(ret, FAIL, "H5Sselect_elements");
if(offset!=NULL) {
@@ -5576,7 +5576,7 @@ test_scalar_select(void)
/* Select one element in memory with a point selection */
coord1[0]=0; coord1[1]= 2;
- ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)1, &coord1);
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)1, (const hsize_t *)&coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Write single point to disk */
@@ -5695,7 +5695,7 @@ test_scalar_select2(void)
/* Select one element in memory with a point selection */
coord1[0]=0;
H5E_BEGIN_TRY {
- ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)1, &coord1);
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)&coord1);
} H5E_END_TRY;
VERIFY(ret, FAIL, "H5Sselect_elements");
@@ -5763,7 +5763,7 @@ test_scalar_select3(void)
/* Select one element in file with a point selection */
coord1[0] = 0; coord1[1] = 2;
- ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, &coord1);
+ ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, (const hsize_t *)&coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Write single point to disk */
@@ -5924,7 +5924,7 @@ test_shape_same(void)
/* Select sequence of ten points for multiple point selection */
coord1[0][0] = 2; coord1[0][1] = 2;
- ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, coord1);
+ ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Create dataspace for multiple point selection */
@@ -5942,7 +5942,7 @@ test_shape_same(void)
coord2[7][0]=1; coord2[7][1]=0;
coord2[8][0]=5; coord2[8][1]=1;
coord2[9][0]=9; coord2[9][1]=3;
- ret = H5Sselect_elements(mult_pt_sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, coord2);
+ ret = H5Sselect_elements(mult_pt_sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Create dataspace for single hyperslab selection */
@@ -6623,7 +6623,7 @@ test_shape_same(void)
for(v=0; v<2; v++) {
coord2[v][0]=u; coord2[v][1]=(v*2)+2;
} /* end for */
- ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (size_t)2, coord2);
+ ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (size_t)2, (const hsize_t *)coord2);
CHECK(ret, FAIL, "H5Sselect_elements");
} /* end for */
@@ -7975,7 +7975,7 @@ test_select_bounds(void)
coord[1][0]= 3; coord[1][1]= 96;
coord[2][0]= 96; coord[2][1]= 3;
coord[3][0]= 96; coord[3][1]= 96;
- ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE11_NPOINTS, coord);
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE11_NPOINTS, (const hsize_t *)coord);
CHECK(ret, FAIL, "H5Sselect_elements");
/* Get bounds for point selection */
diff --git a/test/tskiplist.c b/test/tskiplist.c
index 6f56c39..8510db2 100644
--- a/test/tskiplist.c
+++ b/test/tskiplist.c
@@ -71,7 +71,7 @@ test_skiplist_init(void)
/* Initialize random number seed */
curr_time = HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create randomized set of numbers */
for(u=0; u<NUM_ELEMS; u++) {
@@ -121,7 +121,7 @@ test_skiplist_create(void)
MESSAGE(6, ("Testing Creating & Closing Skip Lists\n"));
/* Try creating a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Try closing the skip list */
@@ -151,7 +151,7 @@ test_skiplist_insert(void)
MESSAGE(7, ("Testing Insertion Into Skip List\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -212,7 +212,7 @@ test_skiplist_insert_many(void)
MESSAGE(7, ("Testing Insertion of Many Items Into Skip List\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -286,7 +286,7 @@ test_skiplist_remove(void)
MESSAGE(7, ("Testing Removal From Skip List\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -365,7 +365,7 @@ test_skiplist_remove_many(void)
MESSAGE(7, ("Testing Removal of Many Items From Skip List\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -465,7 +465,7 @@ test_skiplist_firstnext(void)
MESSAGE(7, ("Testing Iterating Over Skip List With First/Next\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -558,7 +558,7 @@ test_skiplist_string(void)
MESSAGE(7, ("Testing Skip List With String Keys\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_STR);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -620,7 +620,7 @@ test_skiplist_iterate(void)
MESSAGE(7, ("Testing Iterating Over Skip List\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -670,7 +670,7 @@ test_skiplist_hsize(void)
MESSAGE(7, ("Testing Skip List With hsize_t Keys\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_HSIZE, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_HSIZE);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -725,7 +725,7 @@ test_skiplist_unsigned(void)
MESSAGE(7, ("Testing Skip List With unsigned Keys\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -778,7 +778,7 @@ test_skiplist_lastprev(void)
MESSAGE(7, ("Testing Iterating Over Skip List With Last/Prev\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Check that the skip list has no elements */
@@ -846,7 +846,7 @@ test_skiplist_find(void)
MESSAGE(7, ("Testing Skip List 'Find' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -902,7 +902,7 @@ test_skiplist_add(void)
MESSAGE(7, ("Testing Skip List 'Add' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -964,7 +964,7 @@ test_skiplist_destroy(void)
MESSAGE(7, ("Testing Skip List 'Destroy' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -1000,7 +1000,7 @@ test_skiplist_free(void)
MESSAGE(7, ("Testing Skip List 'Free' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_INT);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -1056,7 +1056,7 @@ test_skiplist_less(void)
MESSAGE(7, ("Testing Skip List 'Less' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -1120,7 +1120,7 @@ test_skiplist_greater(void)
MESSAGE(7, ("Testing Skip List 'Greater' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -1165,6 +1165,164 @@ test_skiplist_greater(void)
/****************************************************************
**
+** test_skiplist_below(): Test H5SL (skip list) code.
+** Tests 'below' operation in skip lists.
+**
+****************************************************************/
+static void
+test_skiplist_below(void)
+{
+ H5SL_t *slist; /* Skip list created */
+ H5SL_node_t *node; /* Skip list node */
+ size_t u; /* Local index variable */
+ unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
+ /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
+ unsigned *found_item; /* Item found in skip list */
+ unsigned find_item; /* Item to add to skip list */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(7, ("Testing Skip List 'Below' Operation\n"));
+
+ /* Create a skip list */
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
+ CHECK(slist, NULL, "H5SL_create");
+
+ /* Insert objects into the skip list */
+ for(u = 0; u < 10; u++) {
+ ret = H5SL_insert(slist, &data[u], &data[u]);
+ CHECK(ret, FAIL, "H5SL_insert");
+ } /* end for */
+
+ /* Check for exact match of items in various positions */
+ find_item = 20;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_below");
+ find_item = 90;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_below");
+ find_item = 5;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_below");
+
+ /* Find item less than a missing key, in various positions */
+ find_item = 19;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 15, "H5SL_below");
+ find_item = 89;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 80, "H5SL_below");
+ find_item = 100;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 90, "H5SL_below");
+ find_item = 9;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 5, "H5SL_below");
+ find_item = 4;
+ node = H5SL_less(slist, &find_item);
+ VERIFY(node, NULL, "H5SL_below");
+
+ /* Close the skip list */
+ ret = H5SL_close(slist);
+ CHECK(ret, FAIL, "H5SL_close");
+
+} /* end test_skiplist_below() */
+
+/****************************************************************
+**
+** test_skiplist_above(): Test H5SL (skip list) code.
+** Tests 'above' operation in skip lists.
+**
+****************************************************************/
+static void
+test_skiplist_above(void)
+{
+ H5SL_t *slist; /* Skip list created */
+ H5SL_node_t *node; /* Skip list node */
+ size_t u; /* Local index variable */
+ unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
+ /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
+ unsigned *found_item; /* Item found in skip list */
+ unsigned find_item; /* Item to add to skip list */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(7, ("Testing Skip List 'Above' Operation\n"));
+
+ /* Create a skip list */
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
+ CHECK(slist, NULL, "H5SL_create");
+
+ /* Insert objects into the skip list */
+ for(u = 0; u < 10; u++) {
+ ret = H5SL_insert(slist, &data[u], &data[u]);
+ CHECK(ret, FAIL, "H5SL_insert");
+ } /* end for */
+
+ /* Check for exact match of items in various positions */
+ find_item = 20;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_above");
+ find_item = 90;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_above");
+ find_item = 5;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_above");
+
+ /* Find item greater than a missing key, in various positions */
+ find_item = 19;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 20, "H5SL_above");
+ find_item = 89;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 90, "H5SL_above");
+ find_item = 100;
+ node = H5SL_above(slist, &find_item);
+ VERIFY(node, NULL, "H5SL_above");
+ find_item = 6;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 10, "H5SL_above");
+ find_item = 4;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 5, "H5SL_above");
+
+ /* Close the skip list */
+ ret = H5SL_close(slist);
+ CHECK(ret, FAIL, "H5SL_close");
+
+} /* end test_skiplist_above() */
+
+/****************************************************************
+**
** test_skiplist_remote_first(): Test H5SL (skip list) code.
** Tests 'remove first' operation in skip lists.
**
@@ -1180,10 +1338,10 @@ test_skiplist_remove_first(void)
herr_t ret; /* Generic return value */
/* Output message about test being performed */
- MESSAGE(7, ("Testing Skip List 'Greater' Operation\n"));
+ MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n"));
/* Create a skip list */
- slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED);
CHECK(slist, NULL, "H5SL_create");
/* Insert objects into the skip list */
@@ -1210,6 +1368,51 @@ test_skiplist_remove_first(void)
/****************************************************************
**
+** test_skiplist_remote_first_many(): Test H5SL (skip list) code.
+** Tests 'remove first' operation in large skip lists.
+**
+****************************************************************/
+static void
+test_skiplist_remove_first_many(void)
+{
+ H5SL_t *slist; /* Skip list created */
+ size_t u; /* Local index variable */
+ int *found_item; /* Item found in skip list */
+ int prev_item = INT_MIN; /* Previously found item in skip list */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n"));
+
+ /* Create a skip list */
+ slist = H5SL_create(H5SL_TYPE_INT);
+ CHECK(slist, NULL, "H5SL_create");
+
+ /* Insert objects into the skip list */
+ for(u = 0; u < NUM_ELEMS; u++) {
+ ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
+ CHECK(ret, FAIL, "H5SL_insert");
+ } /* end for */
+
+ /* Remove objects from the skip list */
+ for(u = 0; u < NUM_ELEMS; u++) {
+ found_item = (int *)H5SL_remove_first(slist);
+ VERIFY(*found_item > prev_item, TRUE, "H5SL_remove_first");
+ prev_item = *found_item;
+ } /* end for */
+
+ /* Check for removing object from empty list */
+ found_item = (int *)H5SL_remove_first(slist);
+ VERIFY(found_item, NULL, "H5SL_remove_first");
+
+ /* Close the skip list */
+ ret = H5SL_close(slist);
+ CHECK(ret, FAIL, "H5SL_close");
+
+} /* end test_skiplist_remove_first() */
+
+/****************************************************************
+**
** test_skiplist(): Main H5SL testing routine.
**
****************************************************************/
@@ -1240,7 +1443,10 @@ test_skiplist(void)
test_skiplist_free(); /* Test 'free' operation */
test_skiplist_less(); /* Test 'less' operation */
test_skiplist_greater(); /* Test 'greater' operation */
- test_skiplist_remove_first(); /* Test 'remove first' operation */
+ test_skiplist_below(); /* Test 'below' operation */
+ test_skiplist_above(); /* Test 'above' operation */
+ test_skiplist_remove_first(); /* Test 'remove first' operation */
+ test_skiplist_remove_first_many(); /* Test 'remove first' operation on large skip lists */
} /* end test_skiplist() */
diff --git a/test/tsohm.c b/test/tsohm.c
index e213d25..b5b489b 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -23,6 +23,14 @@
#include "testhdf5.h"
+/*
+ * This file needs to access private information from the H5F package.
+ * This file also needs to access the file testing code.
+ */
+#define H5F_PACKAGE
+#define H5F_TESTING
+#include "H5Fpkg.h" /* File access */
+
/* Default SOHM values */
#define DEF_NUM_INDEXES 0
const unsigned def_type_flags[H5O_SHMESG_MAX_NINDEXES] = {0,0,0,0,0,0};
@@ -150,6 +158,10 @@ typedef struct size2_helper_struct {
/* Number of dimensions in extend_dset test */
#define EXTEND_NDIMS 2
+/* Dimensions for external_dtype test */
+#define NX 10
+#define NY 10
+
/* Helper function prototypes */
static hid_t make_dtype_1(void);
static hid_t make_dtype_2(void);
@@ -532,8 +544,12 @@ error:
static hid_t
close_reopen_file(hid_t file, const char* filename, hid_t fapl_id)
{
- if(H5Fclose(file) < 0) goto error;
- return H5Fopen(filename, H5F_ACC_RDWR, fapl_id);
+ hid_t fid;
+
+ if(H5Fclose(file) < 0) FAIL_STACK_ERROR
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) FAIL_STACK_ERROR
+
+ return(fid);
error:
return -1;
@@ -586,19 +602,19 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
dim1[0] = 1;
if((space_id=H5Screate_simple(1,dim1,NULL)) < 0) TEST_ERROR
- if((dset_id = H5Dcreate2(file,DSETNAME[0],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file,DSETNAME[0],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Test writing and reading */
- if(H5Dwrite(dset_id,dtype1_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&wdata) < 0) TEST_ERROR
+ if(H5Dwrite(dset_id,dtype1_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&wdata) < 0) FAIL_STACK_ERROR
- if(H5Dread(dset_id,dtype1_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&rdata) < 0) TEST_ERROR
+ if(H5Dread(dset_id,dtype1_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&rdata) < 0) FAIL_STACK_ERROR
if(rdata.i1!=wdata.i1 || rdata.i2!=wdata.i2 || HDstrcmp(rdata.str, wdata.str)) {
H5_FAILED(); AT();
printf("incorrect read data\n");
goto error;
} /* end if */
- if(H5Dclose(dset_id) < 0) TEST_ERROR
+ if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR
/* Close and re-open the file if requested*/
if(test_file_closing) {
@@ -606,8 +622,8 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
}
/* Create more datasets with the same datatype */
- if((dset_id = H5Dcreate2(file,DSETNAME[1],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Dclose(dset_id) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file,DSETNAME[1],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR
/* Close and re-open the file if requested*/
if(test_file_closing) {
@@ -719,7 +735,6 @@ static void test_sohm_size1(void)
hid_t file = -1;
hid_t fcpl_id = -1;
hid_t fapl_id = -1;
- hsize_t norm_oh_size;
hsize_t sohm_oh_size;
hsize_t sohm_btree_oh_size;
h5_stat_size_t norm_empty_filesize;
@@ -763,23 +778,18 @@ static void test_sohm_size1(void)
CHECK_I(ret, "H5Fclose");
/* Get the file size */
- norm_empty_filesize = h5_get_file_size(FILENAME);
+ norm_empty_filesize = h5_get_file_size(FILENAME, fapl_id);
/* Add a bunch of large datatypes to the file */
file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
CHECK_I(file, "H5Fopen");
file = size1_helper(file, FILENAME, fapl_id, 0);
CHECK_I(file, "size1_helper");
-
- /* Get the size of a dataset object header */
- ret = H5Oget_info_by_name(file, DSETNAME[0], &oinfo, H5P_DEFAULT);
- CHECK_I(ret, "H5Oget_info_by_name");
ret = H5Fclose(file);
CHECK_I(ret, "H5Fclose");
- norm_oh_size = oinfo.hdr.space.total;
/* Get the new file size */
- norm_final_filesize = h5_get_file_size(FILENAME);
+ norm_final_filesize = h5_get_file_size(FILENAME, fapl_id);
/* Use the same property list to create a new file. */
file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
@@ -795,7 +805,7 @@ static void test_sohm_size1(void)
CHECK_I(ret, "H5Fclose");
/* Get the file size */
- norm_final_filesize2 = h5_get_file_size(FILENAME);
+ norm_final_filesize2 = h5_get_file_size(FILENAME, fapl_id);
@@ -819,7 +829,7 @@ static void test_sohm_size1(void)
ret = H5Fclose(file);
CHECK_I(ret, "H5Fclose");
- sohm_empty_filesize = h5_get_file_size(FILENAME);
+ sohm_empty_filesize = h5_get_file_size(FILENAME, fapl_id);
/* Add a bunch of datatypes to this file */
file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
@@ -835,7 +845,7 @@ static void test_sohm_size1(void)
sohm_oh_size = oinfo.hdr.space.total;
/* Get the new file size */
- sohm_final_filesize = h5_get_file_size(FILENAME);
+ sohm_final_filesize = h5_get_file_size(FILENAME, fapl_id);
/* Use the same property list to create a new file. */
file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
@@ -851,7 +861,7 @@ static void test_sohm_size1(void)
CHECK_I(ret, "H5Fclose");
/* Get the file size */
- sohm_final_filesize2 = h5_get_file_size(FILENAME);
+ sohm_final_filesize2 = h5_get_file_size(FILENAME, fapl_id);
@@ -874,7 +884,7 @@ static void test_sohm_size1(void)
ret = H5Fclose(file);
CHECK_I(ret, "H5Fclose");
- sohm_btree_empty_filesize = h5_get_file_size(FILENAME);
+ sohm_btree_empty_filesize = h5_get_file_size(FILENAME, fapl_id);
/* Add a bunch of datatypes to this file */
file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
@@ -890,7 +900,7 @@ static void test_sohm_size1(void)
sohm_btree_oh_size = oinfo.hdr.space.total;
/* Get the new file size */
- sohm_btree_final_filesize = h5_get_file_size(FILENAME);
+ sohm_btree_final_filesize = h5_get_file_size(FILENAME, fapl_id);
/* Use the same property list to create a new file. */
file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
@@ -906,7 +916,7 @@ static void test_sohm_size1(void)
CHECK_I(ret, "H5Fclose");
/* Get the file size */
- sohm_btree_final_filesize2 = h5_get_file_size(FILENAME);
+ sohm_btree_final_filesize2 = h5_get_file_size(FILENAME, fapl_id);
@@ -915,13 +925,6 @@ static void test_sohm_size1(void)
* headers. How the SOHM messages are stored shouldn't affect the
* size of the object header.
*/
- /* JAMES: this fails because while the headers are the same size, the
- * SOHM header is broken up by the SOHM table, so has to have a
- * continuation message and a NULL message.
-
- if(sohm_oh_size >= norm_oh_size)
- VERIFY(sohm_oh_size, 1, "H5Oget_info_by_name");
- */
if(sohm_oh_size != sohm_btree_oh_size)
VERIFY(sohm_btree_oh_size, 1, "H5Oget_info_by_name");
@@ -1072,7 +1075,7 @@ static void sohm_attr_helper(hid_t fcpl_id)
attr_id = H5Acreate2(group_id, "attribute", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
CHECK_I(attr_id, "H5Acreate2");
-
+
/* Open the attribute to get another handle */
attr_id2 = H5Aopen(group_id, "attribute", H5P_DEFAULT);
CHECK_I(attr_id2, "H5Aopen");
@@ -1177,7 +1180,7 @@ static void test_sohm_attrs(void)
sohm_attr_helper(fcpl_id);
-
+
/* Run test with all three kinds of message shared */
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_ATTR_FLAG, 2);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
@@ -1366,14 +1369,14 @@ static void
size2_dump_struct(const char *name, size2_helper_struct *sizes)
{
puts(name);
- printf(" empty size: %llu\n", sizes->empty_size);
- printf(" first dataset: %llu \tdelta: %llu\n", sizes->first_dset, sizes->first_dset - sizes->empty_size);
- printf("second dataset: %llu \tdelta: %llu\n", sizes->second_dset, sizes->second_dset - sizes->first_dset);
- printf(" dsets 1: %llu \tdelta: %llu\n", sizes->dsets1, sizes->dsets1 - sizes->second_dset);
- printf(" dsets 2: %llu \tdelta: %llu\n", sizes->dsets2, sizes->dsets2 - sizes->dsets1);
- printf(" interleaved: %llu \tdelta: %llu\n", sizes->interleaved, sizes->interleaved - sizes->dsets2);
- printf(" attributes: %llu \tdelta: %llu\n", sizes->attrs1, sizes->attrs1 - sizes->interleaved);
- printf(" attributes 2: %llu \tdelta: %llu\n", sizes->attrs2, sizes->attrs2 - sizes->attrs1);
+ printf(" empty size: %llu\n", (unsigned long long)sizes->empty_size);
+ printf(" first dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->first_dset, (unsigned long long)(sizes->first_dset - sizes->empty_size));
+ printf("second dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->second_dset, (unsigned long long)(sizes->second_dset - sizes->first_dset));
+ printf(" dsets 1: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets1, (unsigned long long)(sizes->dsets1 - sizes->second_dset));
+ printf(" dsets 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets2, (unsigned long long)(sizes->dsets2 - sizes->dsets1));
+ printf(" interleaved: %llu \tdelta: %llu\n", (unsigned long long)sizes->interleaved, (unsigned long long)(sizes->interleaved - sizes->dsets2));
+ printf(" attributes: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs1, (unsigned long long)(sizes->attrs1 - sizes->interleaved));
+ printf(" attributes 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs2, (unsigned long long)(sizes->attrs2 - sizes->attrs1));
}
@@ -1441,7 +1444,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(ret, "H5Fclose");
/* Get the file size */
- ret_sizes->empty_size = h5_get_file_size(FILENAME);
+ ret_sizes->empty_size = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Re-open the file and set up messages to write */
file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
@@ -1544,9 +1547,9 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
/* Get the file's size now */
if(x == 0)
- ret_sizes->first_dset = h5_get_file_size(FILENAME);
- else
- ret_sizes->second_dset = h5_get_file_size(FILENAME);
+ ret_sizes->first_dset = h5_get_file_size(FILENAME, H5P_DEFAULT);
+ else
+ ret_sizes->second_dset = h5_get_file_size(FILENAME, H5P_DEFAULT);
file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK_I(file_id, "H5Fopen");
@@ -1561,7 +1564,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
/* Close file and get its size now */
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- ret_sizes->dsets1 = h5_get_file_size(FILENAME);
+ ret_sizes->dsets1 = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Now create a new group filled with datasets that use all different messages */
@@ -1602,7 +1605,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(ret, "H5Gclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- ret_sizes->dsets2 = h5_get_file_size(FILENAME);
+ ret_sizes->dsets2 = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Create a new group and interleave writes of datasets types 1 and 2. */
@@ -1656,7 +1659,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(ret, "H5Gclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- ret_sizes->interleaved = h5_get_file_size(FILENAME);
+ ret_sizes->interleaved = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Create lots of new attribute messages on the group
* (using different strings for the attribute)
@@ -1699,7 +1702,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(ret, "H5Gclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- ret_sizes->attrs1 = h5_get_file_size(FILENAME);
+ ret_sizes->attrs1 = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Create all of the attributes again on the other group */
@@ -1738,7 +1741,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(ret, "H5Gclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- ret_sizes->attrs2 = h5_get_file_size(FILENAME);
+ ret_sizes->attrs2 = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Close everything */
@@ -1978,7 +1981,7 @@ static void size2_verify(void)
* function size2_helper. The test measures the size of the
* file at various points. Once all of the files have been
* generated, the test compares the measured sizes of the files.
- *
+ *
*
* Programmer: James Laird
* Friday, November 17, 2006
@@ -1998,7 +2001,7 @@ static void test_sohm_size2(int close_reopen)
/* Sizes for files that don't share all kinds of messages */
size2_helper_struct share_some_med, share_some_btree;
/* Sizes for files that share different sizes of messages */
- size2_helper_struct share_some_toobig_index, share_tiny_index, type_space_index;
+ size2_helper_struct share_some_toobig_index, share_tiny_index, type_space_index;
herr_t ret;
if(close_reopen == 0)
@@ -2336,8 +2339,10 @@ static void test_sohm_size2(int close_reopen)
if((list_index_big.attrs1 - list_index_big.interleaved) >=
(list_index_small.attrs1 - list_index_small.interleaved))
VERIFY(0, 1, "h5_get_file_size");
+
+ /* Give it some overhead (for checkin to move messages into continuation message) */
if((list_index_small.attrs1 - list_index_small.interleaved) >
- (btree_index.attrs1 - btree_index.interleaved))
+ ((btree_index.attrs1 - btree_index.interleaved) * OVERHEAD_ALLOWED))
VERIFY(0, 1, "h5_get_file_size");
@@ -2619,7 +2624,7 @@ static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id,
CHECK_I(attr_id, "H5Acreate2");
/* Write to attribute */
- ret = H5Awrite(attr_id, H5T_NATIVE_CHAR, &wdata);
+ ret = H5Awrite(attr_id, H5T_NATIVE_CHAR, &wdata);
CHECK_I(ret, "H5Awrite");
ret = H5Aclose(attr_id);
@@ -2723,7 +2728,7 @@ static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id)
/* Close file and get filesize */
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- norm_filesize = h5_get_file_size(FILENAME);
+ norm_filesize = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Create a new file with messages 0 to (HALF_DELETE_NUM_MESGS - 1) */
file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
@@ -2755,7 +2760,7 @@ static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id)
/* Close file and get filesize */
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- deleted_filesize = h5_get_file_size(FILENAME);
+ deleted_filesize = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* The two filesizes should be almost the same */
if(norm_filesize > deleted_filesize * OVERHEAD_ALLOWED)
@@ -2950,7 +2955,7 @@ test_sohm_delete_revert_helper(hid_t fcpl_id)
/* Close the file and get its size */
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- initial_filesize = h5_get_file_size(FILENAME);
+ initial_filesize = h5_get_file_size(FILENAME, H5P_DEFAULT);
/* Re-create the file and create a dataset in it */
@@ -2969,7 +2974,7 @@ test_sohm_delete_revert_helper(hid_t fcpl_id)
/* Close the file and get its size */
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- deleted_filesize = h5_get_file_size(FILENAME);
+ deleted_filesize = h5_get_file_size(FILENAME, H5P_DEFAULT);
VERIFY(deleted_filesize, initial_filesize, "h5_get_file_size");
@@ -2999,7 +3004,7 @@ test_sohm_delete_revert_helper(hid_t fcpl_id)
/* Close the file and get its size */
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
- deleted_filesize = h5_get_file_size(FILENAME);
+ deleted_filesize = h5_get_file_size(FILENAME, H5P_DEFAULT);
VERIFY(deleted_filesize, initial_filesize, "h5_get_file_size");
@@ -3134,7 +3139,7 @@ static void test_sohm_extlink_helper(hid_t src_fcpl_id, hid_t dst_fcpl_id)
dset_id = H5Dcreate2(src_file_id, "ext_link/dataset", H5T_NATIVE_FLOAT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK_I(dset_id, "H5Dcreate2");
- /* Close the dataset and both files to make sure everything gets flushed
+ /* Close the dataset and both files to make sure everything gets flushed
* out of memory
*/
ret = H5Dclose(dset_id);
@@ -3784,8 +3789,176 @@ test_sohm_extend_dset(void)
}
+/*-------------------------------------------------------------------------
+ * Function: test_sohm_external_dtype
+ *
+ * Purpose: When a datatype is a SOHM type in one file, test that the
+ * second file using the same datatype actually save it in
+ * the file, too.
+ *
+ * Programmer: Raymond Lu
+ * 13 October, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+test_sohm_external_dtype(void)
+{
+ typedef struct s1_t {
+ int a;
+ int b;
+ } s1_t;
+ s1_t *s_ptr, *orig;
+ hid_t fcpl, file1, file2;
+ hid_t dataset1, dataset2;
+ hid_t s1_tid, dset1_tid, dset2_tid, space;
+ hsize_t dims[2] = {NX, NY};
+ H5T_class_t dtype_class;
+ size_t dmsg_count;
+ unsigned x, i;
+ herr_t ret;
+
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl, "H5Pcreate");
+
+ /* Set up index values for sohm */
+ ret = H5Pset_shared_mesg_nindexes(fcpl, TEST_NUM_INDEXES);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+
+ for(x=0; x<TEST_NUM_INDEXES; ++x)
+ {
+ ret = H5Pset_shared_mesg_index(fcpl, x, test_type_flags[x], test_minsizes[x]);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+ }
+
+ ret = H5Pset_shared_mesg_phase_change(fcpl, TEST_L2B, TEST_B2L);
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+
+ /* Create the data space */
+ space = H5Screate_simple(2, dims, NULL);
+ CHECK_I(space, "H5Screate_simple");
+
+ /* Create a data type for s1_t */
+ s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
+ CHECK_I(s1_tid, "H5Tcreate");
+
+ ret = H5Tinsert(s1_tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT);
+ CHECK_I(ret, "H5Tinsert");
+
+ ret = H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT);
+ CHECK_I(ret, "H5Tinsert");
+
+ /* Create the first file for this test */
+ file1 = H5Fcreate(FILENAME_SRC, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
+ CHECK_I(file1, "H5Fcreate");
+
+ /* Check on datatype storage status. It should be zero now. */
+ ret = H5F_get_sohm_mesg_count_test(file1, H5O_DTYPE_ID, &dmsg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(dmsg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* Create data set */
+ dataset1 = H5Dcreate2(file1, "dataset_1", s1_tid, space, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
+ CHECK_I(dataset1, "H5Dcreate2");
+
+ /* Check on datatype storage status. It should be 1 now. */
+ ret = H5F_get_sohm_mesg_count_test(file1, H5O_DTYPE_ID, &dmsg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(dmsg_count, 1, "H5F_get_sohm_mesg_count_test");
+
+ /* Retieve the dataset's datatype */
+ dset1_tid = H5Dget_type(dataset1);
+ CHECK_I(dset1_tid, "H5Dget_type");
+
+ /* Allocate space and initialize data */
+ orig = (s1_t*)malloc(NX * NY * sizeof(s1_t));
+ for(i=0; i<NX*NY; i++) {
+ s_ptr = (s1_t*)orig + i;
+ s_ptr->a = i*3 + 1;
+ s_ptr->b = i*3 + 2;
+ }
+
+ /* Write the data to the dataset1 */
+ ret = H5Dwrite(dataset1, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig);
+ CHECK_I(ret, "H5Dwrite");
+
+ ret = H5Dclose(dataset1);
+ CHECK_I(ret, "H5Dclose");
+
+ /* Create the second file for this test */
+ file2 = H5Fcreate(FILENAME_DST, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
+ CHECK_I(file2, "H5Fcreate");
+
+ /* Check on datatype storage status. It should be zero now. */
+ ret = H5F_get_sohm_mesg_count_test(file2, H5O_DTYPE_ID, &dmsg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(dmsg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* Create a data set using the datatype of the dataset in the first file. */
+ dataset2 = H5Dcreate2(file2, "dataset_2", dset1_tid, space, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
+ CHECK_I(dataset2, "H5Dcreate2");
+
+ /* Check on datatype storage status. It should be 1 now. */
+ ret = H5F_get_sohm_mesg_count_test(file2, H5O_DTYPE_ID, &dmsg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(dmsg_count, 1, "H5F_get_sohm_mesg_count_test");
+
+ /* Write the data to the dataset2 */
+ ret = H5Dwrite(dataset2, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig);
+ CHECK_I(ret, "H5Dwrite");
+
+ ret = H5Dclose(dataset2);
+ CHECK_I(ret, "H5Dclose");
+
+ /* Close file 1 and the dataset's datatype in file 1. Verify that the datatype in
+ * file 2 is still accessible. */
+ ret = H5Tclose(dset1_tid);
+ CHECK_I(ret, "H5Tclose");
+
+ ret = H5Fclose(file1);
+ CHECK_I(ret, "H5Fclose");
+
+ /* Open the dataset in file 2 */
+ dataset2 = H5Dopen2(file2, "dataset_2", H5P_DEFAULT);
+ CHECK_I(dataset2, "H5Dopen2");
+
+ /* Retieve the dataset's datatype */
+ dset2_tid = H5Dget_type(dataset2);
+ CHECK_I(dset2_tid, "H5Dget_type");
+
+ /* Verify the datatype is compound */
+ dtype_class = H5Tget_class(dset2_tid);
+ VERIFY(dtype_class, H5T_COMPOUND, "H5Tget_class");
+
+ ret = H5Tclose(dset2_tid);
+ CHECK_I(ret, "H5Tclose");
+
+ ret = H5Dclose(dataset2);
+ CHECK_I(ret, "H5Dclose");
+
+ /* Finishing test and release resources */
+ ret = H5Sclose(space);
+ CHECK_I(ret, "H5Sclose");
+
+ ret = H5Tclose(s1_tid);
+ CHECK_I(ret, "H5Tclose");
+
+ ret = H5Pclose(fcpl);
+ CHECK_I(ret, "H5Pclose");
+
+ ret = H5Fclose(file2);
+ CHECK_I(ret, "H5Fclose");
+
+ free(orig);
+}
+
+
/****************************************************************
-**
+**
** test_sohm(): Main Shared Object Header Message testing routine.
**
****************************************************************/
@@ -3808,11 +3981,10 @@ test_sohm(void)
#ifndef H5_CANNOT_OPEN_TWICE /* On VMS this test fails since it tries to
open target file the second time */
test_sohm_extlink(); /* Test SOHMs when external links are used */
-
#endif /* H5_CANNOT_OPEN_TWICE */
test_sohm_extend_dset(); /* Test extending shared datasets */
-
+ test_sohm_external_dtype(); /* Test using datatype in another file */
} /* test_sohm() */
diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c
index 7659a3e..b3d056f 100644
--- a/test/ttsafe_error.c
+++ b/test/ttsafe_error.c
@@ -169,10 +169,10 @@ void *tts_error_thread(void UNUSED *arg)
int ret;
/* preserve previous error stack handler */
- H5Eget_auto2(H5E_DEFAULT, &old_error_cb, &old_error_client_data);
+ H5Eget_auto2(H5E_DEFAULT, &old_error_cb, &old_error_client_data);
/* set each thread's error stack handler */
- H5Eset_auto2(H5E_DEFAULT, error_callback, NULL);
+ H5Eset_auto2(H5E_DEFAULT, error_callback, NULL);
/* define dataspace for dataset */
dimsf[0] = 1;
@@ -198,7 +198,7 @@ void *tts_error_thread(void UNUSED *arg)
assert(ret >= 0);
/* turn our error stack handler off */
- H5Eset_auto2(H5E_DEFAULT, old_error_cb, old_error_client_data);
+ H5Eset_auto2(H5E_DEFAULT, old_error_cb, old_error_client_data);
return NULL;
}
diff --git a/test/ttst.c b/test/ttst.c
index c267404..4ffe4cd 100644
--- a/test/ttst.c
+++ b/test/ttst.c
@@ -124,7 +124,7 @@ test_tst_init(void)
for(u=0; u<num_uniq_words; u++)
rand_uniq_words[u]=uniq_words[u];
curr_time=HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
for(u=0; u<num_uniq_words; u++) {
v=u+(HDrandom()%(num_uniq_words-u));
if(u!=v) {
diff --git a/test/tunicode.c b/test/tunicode.c
index 767928e..892e563 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -779,13 +779,12 @@ void dump_string(const char * string)
unsigned int length;
unsigned int x;
- printf("The string was:\n");
- printf(string);
+ printf("The string was:\n %s", string);
printf("Or in hex:\n");
length = strlen(string);
- for(x=0; x<length; x++)
+ for(x=0; x<length; x++)
printf("%x ", string[x] & (0x000000FF));
printf("\n");
@@ -808,7 +807,7 @@ void test_unicode(void)
MESSAGE(5, ("Testing UTF-8 Encoding\n"));
/* Create a random string with length NUM_CHARS */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
HDmemset(test_string, 0, sizeof(test_string));
for(x=0; x<NUM_CHARS; x++)
diff --git a/test/tvlstr.c b/test/tvlstr.c
index d87268e..a411b86 100644
--- a/test/tvlstr.c
+++ b/test/tvlstr.c
@@ -62,7 +62,7 @@ void test_vlstr_free_custom(void *mem, void *info);
void *test_vlstr_alloc_custom(size_t size, void *info)
{
void *ret_value=NULL; /* Pointer to return */
- int *mem_used=(int *)info; /* Get the pointer to the memory used */
+ size_t *mem_used=(size_t *)info; /* Get the pointer to the memory used */
size_t extra; /* Extra space needed */
/*
@@ -90,7 +90,7 @@ void *test_vlstr_alloc_custom(size_t size, void *info)
void test_vlstr_free_custom(void *_mem, void *info)
{
unsigned char *mem;
- int *mem_used=(int *)info; /* Get the pointer to the memory used */
+ size_t *mem_used=(size_t *)info; /* Get the pointer to the memory used */
size_t extra; /* Extra space needed */
/*
@@ -132,8 +132,8 @@ test_vlstrings_basic(void)
hsize_t dims1[] = {SPACE1_DIM1};
hsize_t size; /* Number of bytes which will be used */
unsigned i; /* counting variable */
- int str_used; /* String data in memory */
- int mem_used=0; /* Memory used during allocation */
+ size_t str_used; /* String data in memory */
+ size_t mem_used=0; /* Memory used during allocation */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -196,26 +196,26 @@ test_vlstrings_basic(void)
VERIFY(size,(hsize_t)str_used,"H5Dvlen_get_buf_size");
/* Read dataset from disk */
- ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata);
+ ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, xfer_pid, rdata);
CHECK(ret, FAIL, "H5Dread");
/* Make certain the correct amount of memory has been used */
VERIFY(mem_used,str_used,"H5Dread");
/* Compare data read in */
- for(i=0; i<SPACE1_DIM1; i++) {
- if(HDstrlen(wdata[i])!=strlen(rdata[i])) {
+ for(i = 0; i < SPACE1_DIM1; i++) {
+ if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
continue;
} /* end if */
- if( HDstrcmp(wdata[i],rdata[i]) != 0 ) {
+ if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]);
continue;
} /* end if */
} /* end for */
/* Reclaim the read VL data */
- ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
+ ret = H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
/* Make certain the VL memory has been freed */
diff --git a/test/tvltypes.c b/test/tvltypes.c
index 1ea0eaa..ab4d880 100644
--- a/test/tvltypes.c
+++ b/test/tvltypes.c
@@ -30,7 +30,7 @@
/* 1-D dataset with fixed dimensions */
#define SPACE1_RANK 1
-#define SPACE1_DIM1 4
+#define SPACE1_DIM1 4
/* 2-D dataset with fixed dimensions */
#define SPACE2_RANK 2
@@ -42,7 +42,7 @@
#define SPACE3_DIM1 128
#define L1_INCM 16
#define L2_INCM 8
-#define L3_INCM 3
+#define L3_INCM 3
/* 1-D dataset with fixed dimensions */
#define SPACE4_RANK 1
@@ -1159,7 +1159,7 @@ test_vltypes_compound_vlen_vlen(void)
** test_vltypes_compound_vlstr(): Test VL datatype code.
** Tests VL datatypes of compound datatypes with VL string.
** Dataset is extensible chunked, and data is rewritten with
-** shorter VL data.
+** shorter VL data.
**
****************************************************************/
static void
@@ -2387,7 +2387,7 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void)
/****************************************************************
**
-** test_vltypes_fill_value(): Test fill value for VL data.
+** test_vltypes_fill_value(): Test fill value for VL data.
** One tests data space isn't allocated; another tests data
** space is allocated.
**
@@ -2431,7 +2431,7 @@ test_vltypes_fill_value(void)
hsize_t large_select_count[] = {SPACE4_DIM_LARGE / 2}; /* Count of large non-contiguous element selection */
hsize_t select_block[] = {1}; /* Block size of non-contiguous element selection */
hid_t dcpl_id, xfer_pid;
- hid_t dset_id;
+ hid_t dset_id;
hsize_t small_dims[] = {SPACE4_DIM_SMALL};
hsize_t large_dims[] = {SPACE4_DIM_LARGE};
size_t dset_elmts; /* Number of elements in a particular dataset */
@@ -2831,7 +2831,7 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
- ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
+ ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Dclose(dset_id);
@@ -3001,7 +3001,7 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
- ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
+ ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Dclose(dset_id);
@@ -3097,7 +3097,7 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
- ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
+ ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Dclose(dset_id);
diff --git a/test/unlink.c b/test/unlink.c
index 868f765..9bd6f42 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -44,8 +44,6 @@ const char *FILENAME[] = {
NULL
};
-#define THE_OBJECT "/foo"
-
/* Macros for test_create_unlink() & test_filespace */
#define GROUPNAME "group"
#define GROUP2NAME "group2"
@@ -527,16 +525,6 @@ test_filespace(hid_t fapl)
size_t rdcc_nelmts;
size_t rdcc_nbytes;
double rdcc_w0;
- const char *envval = NULL;
- int ExpressMode;
-
- /* Don't run some tests for some drivers */
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
-
- /* See if some tests can be skipped */
- ExpressMode = GetTestExpress();
puts("Testing file space gets reused:");
@@ -564,7 +552,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) TEST_ERROR
/* Get the size of an empty file */
- if((empty_size=h5_get_file_size(filename))<0) TEST_ERROR
+ if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Create common objects for datasets */
@@ -602,7 +590,7 @@ test_filespace(hid_t fapl)
if((space = H5Screate_simple(FILESPACE_NDIMS, dims, NULL)) < 0) TEST_ERROR
/* Create buffer for writing dataset */
- if((data = HDmalloc(sizeof(int)*FILESPACE_DIM0*FILESPACE_DIM1*FILESPACE_DIM2))==NULL) TEST_ERROR
+ if(NULL == (data = (int *)HDmalloc(sizeof(int) * FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2))) TEST_ERROR
/* Create single dataset (with contiguous storage & late allocation), remove it & verify file size */
@@ -622,7 +610,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -647,7 +635,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename))<0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -672,7 +660,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename))<0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -697,7 +685,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -722,7 +710,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -746,7 +734,7 @@ test_filespace(hid_t fapl)
for(u = 0; u < FILESPACE_REWRITE; u++) {
/* Set buffer to some compressible values */
for(v = 0, tmp_data = data; v < (FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2); v++)
- *tmp_data++ = v * u;
+ *tmp_data++ = (int)(v * u);
/* Write the buffer to the dataset */
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
@@ -769,7 +757,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl_nocache)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -794,7 +782,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -858,7 +846,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -886,7 +874,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -911,7 +899,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -943,7 +931,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -973,7 +961,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -984,92 +972,83 @@ test_filespace(hid_t fapl)
/* Create complex group hiearchy, remove it & verify file size */
TESTING(" complex group hierarchy");
- if (ExpressMode > 1 && !HDstrcmp(envval, "direct")) {
- /* This test case with Direct driver has a poor performance on
- * NCSA copper, though it works. Skip it for now and worry
- * about the performance later.
- */
- SKIPPED();
- } else {
+ /* Create file */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
- /* Create file */
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
+ /* Create a complex group hierarchy to remove */
+ for(u = 0; u < FILESPACE_TOP_GROUPS; u++) {
+ /* Create group */
+ sprintf(objname,"%s %u",GROUPNAME,u);
+ if((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Create a complex group hierarchy to remove */
- for(u = 0; u < FILESPACE_TOP_GROUPS; u++) {
+ /* Create nested groups inside top groups */
+ for(v = 0; v < FILESPACE_NESTED_GROUPS; v++) {
/* Create group */
- sprintf(objname,"%s %u",GROUPNAME,u);
- if((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Create nested groups inside top groups */
- for(v = 0; v < FILESPACE_NESTED_GROUPS; v++) {
- /* Create group */
- sprintf(objname, "%s %u", GROUP2NAME, v);
- if((group2 = H5Gcreate2(group, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Create datasets inside nested groups */
- for(w = 0; w < FILESPACE_NDATASETS; w++) {
- /* Create & close a dataset */
- sprintf(objname, "%s %u", DATASETNAME, w);
- if((dataset = H5Dcreate2(group2, objname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR
- } /* end for */
-
- /* Close nested group */
- if(H5Gclose(group2) < 0) FAIL_STACK_ERROR
+ sprintf(objname, "%s %u", GROUP2NAME, v);
+ if((group2 = H5Gcreate2(group, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Create datasets inside nested groups */
+ for(w = 0; w < FILESPACE_NDATASETS; w++) {
+ /* Create & close a dataset */
+ sprintf(objname, "%s %u", DATASETNAME, w);
+ if((dataset = H5Dcreate2(group2, objname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR
} /* end for */
- /* Close top group */
- if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ /* Close nested group */
+ if(H5Gclose(group2) < 0) FAIL_STACK_ERROR
} /* end for */
- /* Remove complex group hierarchy */
- /* (Remove them in reverse order just to make file size calculation easier -QAK) */
- for(u = FILESPACE_TOP_GROUPS; u > 0; u--) {
- /* Open group */
- sprintf(objname, "%s %u", GROUPNAME, (u - 1));
- if((group = H5Gopen2(file, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Open nested groups inside top groups */
- for(v = 0; v < FILESPACE_NESTED_GROUPS; v++) {
- /* Create group */
- sprintf(objname, "%s %u", GROUP2NAME, v);
- if((group2 = H5Gopen2(group, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Remove datasets inside nested groups */
- for(w = 0; w < FILESPACE_NDATASETS; w++) {
- /* Remove dataset */
- sprintf(objname, "%s %u", DATASETNAME, w);
- if(H5Ldelete(group2, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
- } /* end for */
-
- /* Close nested group */
- if(H5Gclose(group2) < 0) FAIL_STACK_ERROR
-
- /* Remove nested group */
- sprintf(objname, "%s %u",GROUP2NAME, v);
- if(H5Ldelete(group, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ /* Close top group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ } /* end for */
+
+ /* Remove complex group hierarchy */
+ /* (Remove them in reverse order just to make file size calculation easier -QAK) */
+ for(u = FILESPACE_TOP_GROUPS; u > 0; u--) {
+ /* Open group */
+ sprintf(objname, "%s %u", GROUPNAME, (u - 1));
+ if((group = H5Gopen2(file, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Open nested groups inside top groups */
+ for(v = 0; v < FILESPACE_NESTED_GROUPS; v++) {
+ /* Create group */
+ sprintf(objname, "%s %u", GROUP2NAME, v);
+ if((group2 = H5Gopen2(group, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Remove datasets inside nested groups */
+ for(w = 0; w < FILESPACE_NDATASETS; w++) {
+ /* Remove dataset */
+ sprintf(objname, "%s %u", DATASETNAME, w);
+ if(H5Ldelete(group2, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
} /* end for */
- /* Close top group */
- if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ /* Close nested group */
+ if(H5Gclose(group2) < 0) FAIL_STACK_ERROR
- /* Remove top group */
- sprintf(objname, "%s %u", GROUPNAME, (u - 1));
- if(H5Ldelete(file, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ /* Remove nested group */
+ sprintf(objname, "%s %u",GROUP2NAME, v);
+ if(H5Ldelete(group, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
} /* end for */
- /* Close file */
- if(H5Fclose(file) < 0) FAIL_STACK_ERROR
+ /* Close top group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
- /* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ /* Remove top group */
+ sprintf(objname, "%s %u", GROUPNAME, (u - 1));
+ if(H5Ldelete(file, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ } /* end for */
- /* Verify the file is correct size */
- if(file_size != empty_size) TEST_ERROR
+ /* Close file */
+ if(H5Fclose(file) < 0) FAIL_STACK_ERROR
- PASSED();
- }
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
+
+ /* Verify the file is correct size */
+ if(file_size != empty_size) TEST_ERROR
+
+ PASSED();
/* Create dataset and duplicate dataset, remove original & verify file size */
@@ -1098,7 +1077,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename))<0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -1132,7 +1111,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -1170,7 +1149,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -1220,7 +1199,7 @@ test_filespace(hid_t fapl)
if(H5Fclose(file) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size) TEST_ERROR
@@ -1508,8 +1487,8 @@ delete_node(hid_t pid, hid_t id)
static int
test_unlink_rightleaf(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1517,7 +1496,7 @@ test_unlink_rightleaf(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc(ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1535,8 +1514,10 @@ test_unlink_rightleaf(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) TEST_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Close root group ID */
if(H5Gclose(rootid) < 0) TEST_ERROR
@@ -1548,6 +1529,20 @@ test_unlink_rightleaf(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_rightleaf() */
@@ -1571,8 +1566,8 @@ error:
static int
test_unlink_rightnode(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1580,7 +1575,7 @@ test_unlink_rightnode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc(ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1591,8 +1586,10 @@ test_unlink_rightnode(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Unlink specific objects to trigger deletion of right leaf in non-leaf node */
if(H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@@ -1611,6 +1608,20 @@ test_unlink_rightnode(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_rightnode() */
@@ -1634,8 +1645,8 @@ error:
static int
test_unlink_middlenode(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 250; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1643,7 +1654,7 @@ test_unlink_middlenode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc(ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1654,8 +1665,10 @@ test_unlink_middlenode(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Unlink specific objects to trigger deletion of all leafs in "interior" non-leaf node */
if(H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@@ -1817,6 +1830,20 @@ test_unlink_middlenode(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_middlenode() */
@@ -1840,7 +1867,7 @@ error:
static int
test_resurrect_dataset(hid_t fapl)
{
- hid_t f =-1, s =-1, d =-1;
+ hid_t f = -1, s = -1, d = -1;
char filename[1024];
TESTING("resurrecting dataset after deletion");
@@ -2165,7 +2192,7 @@ test_full_group_compact(hid_t fapl)
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
/* Get the size of the file with only the objects to keep */
- if((keep_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((keep_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Re-open the file */
if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
@@ -2229,7 +2256,7 @@ test_full_group_compact(hid_t fapl)
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != keep_size) TEST_ERROR
@@ -2299,7 +2326,7 @@ test_full_group_dense(hid_t fapl)
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
/* Get the size of the file with only the objects to keep */
- if((keep_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((keep_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Re-open the file */
if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
@@ -2375,7 +2402,7 @@ test_full_group_dense(hid_t fapl)
if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
/* Get the size of the file */
- if((file_size = h5_get_file_size(filename)) < 0) TEST_ERROR
+ if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR
/* Verify the file is correct size */
if(file_size != keep_size) TEST_ERROR
@@ -2413,132 +2440,123 @@ error:
int
main(void)
{
- const char *envval = NULL;
-
- /* Don't run this test using the wrong file drivers */
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
- if(HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) {
- hid_t fapl, fapl2, file;
- int nerrors = 0;
- char filename[1024];
- hbool_t new_format;
-
- /* Metadata cache parameters */
- int mdc_nelmts;
- size_t rdcc_nelmts;
- size_t rdcc_nbytes;
- double rdcc_w0;
-
- /* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
-
- /* Open */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Copy the file access property list */
- if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
-
- /* Test with old & new format groups */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
-
- /* Set the FAPL for the type of format */
- if(new_format) {
- puts("\nTesting with new group format:");
- my_fapl = fapl2;
- } /* end if */
- else {
- puts("Testing with old group format:");
- my_fapl = fapl;
- } /* end else */
-
- h5_fixname(FILENAME[0], my_fapl, filename, sizeof filename);
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR
-
- /* Tests */
- nerrors += test_one(file);
- nerrors += test_many(file);
- nerrors += test_symlink(file);
- nerrors += test_rename(file);
-
- nerrors += test_new_move(my_fapl);
- nerrors += check_new_move(my_fapl);
- nerrors += test_filespace(my_fapl);
-
- /* Test creating & unlinking lots of objects with default FAPL */
- nerrors += test_create_unlink("create and unlink large number of objects", my_fapl);
-
- {
- hid_t fapl_small_mdc;
-
- /* Make copy of regular fapl, to turn down the elements in the metadata cache */
- if((fapl_small_mdc = H5Pcopy(my_fapl)) < 0)
- goto error;
-
- /* Get FAPL cache settings */
- if(H5Pget_cache(fapl_small_mdc, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
- printf("H5Pget_cache failed\n");
-
- /* Change FAPL cache settings */
- mdc_nelmts=1;
- if(H5Pset_cache(fapl_small_mdc, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
- printf("H5Pset_cache failed\n");
-
- /* Test creating & unlinking lots of objects with a 1-element metadata cache FAPL */
- nerrors += test_create_unlink("create and unlink large number of objects with small cache", fapl_small_mdc);
-
- if(H5Pclose(fapl_small_mdc) < 0) TEST_ERROR
- } /* end block */
-
- nerrors += test_link_slashes(my_fapl);
- nerrors += test_unlink_slashes(my_fapl);
-
- /* Test specific B-tree removal issues */
- /* (only for old format groups) */
- if(!new_format) {
- nerrors += test_unlink_rightleaf(file);
- nerrors += test_unlink_rightnode(file);
- nerrors += test_unlink_middlenode(file);
- } /* end if */
+ hid_t fapl, fapl2, file;
+ int nerrors = 0;
+ char filename[1024];
+ hbool_t new_format;
+
+ /* Metadata cache parameters */
+ int mdc_nelmts;
+ size_t rdcc_nelmts;
+ size_t rdcc_nbytes;
+ double rdcc_w0;
- /* Test "resurrecting" objects */
- nerrors += test_resurrect_dataset(my_fapl);
- nerrors += test_resurrect_datatype(my_fapl);
- nerrors += test_resurrect_group(my_fapl);
+ /* Set the random # seed */
+ HDsrandom((unsigned)HDtime(NULL));
- /* Test unlinking chunked datasets */
- nerrors += test_unlink_chunked_dataset(my_fapl);
+ /* Open */
+ h5_reset();
+ fapl = h5_fileaccess();
- /* Test unlinked groups which still have objects in them */
- /* (only for new format groups) */
- if(new_format) {
- nerrors += test_full_group_compact(my_fapl);
- nerrors += test_full_group_dense(my_fapl);
- } /* end if */
+ /* Copy the file access property list */
+ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
- /* Close */
- if(H5Fclose(file) < 0) TEST_ERROR
- } /* end for */
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ /* Test with old & new format groups */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
- /* Close 2nd FAPL */
- H5Pclose(fapl2);
+ /* Set the FAPL for the type of format */
+ if(new_format) {
+ puts("\nTesting with new group format:");
+ my_fapl = fapl2;
+ } /* end if */
+ else {
+ puts("Testing with old group format:");
+ my_fapl = fapl;
+ } /* end else */
+
+ h5_fixname(FILENAME[0], my_fapl, filename, sizeof filename);
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR
+
+ /* Tests */
+ nerrors += test_one(file);
+ nerrors += test_many(file);
+ nerrors += test_symlink(file);
+ nerrors += test_rename(file);
+
+ nerrors += test_new_move(my_fapl);
+ nerrors += check_new_move(my_fapl);
+ nerrors += test_filespace(my_fapl);
+
+ /* Test creating & unlinking lots of objects with default FAPL */
+ nerrors += test_create_unlink("create and unlink large number of objects", my_fapl);
+
+ {
+ hid_t fapl_small_mdc;
+
+ /* Make copy of regular fapl, to turn down the elements in the metadata cache */
+ if((fapl_small_mdc = H5Pcopy(my_fapl)) < 0)
+ goto error;
+
+ /* Get FAPL cache settings */
+ if(H5Pget_cache(fapl_small_mdc, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
+ printf("H5Pget_cache failed\n");
+
+ /* Change FAPL cache settings */
+ mdc_nelmts=1;
+ if(H5Pset_cache(fapl_small_mdc, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
+ printf("H5Pset_cache failed\n");
+
+ /* Test creating & unlinking lots of objects with a 1-element metadata cache FAPL */
+ nerrors += test_create_unlink("create and unlink large number of objects with small cache", fapl_small_mdc);
+
+ if(H5Pclose(fapl_small_mdc) < 0) TEST_ERROR
+ } /* end block */
+
+ nerrors += test_link_slashes(my_fapl);
+ nerrors += test_unlink_slashes(my_fapl);
+
+ /* Test specific B-tree removal issues */
+ /* (only for old format groups) */
+ if(!new_format) {
+ nerrors += test_unlink_rightleaf(file);
+ nerrors += test_unlink_rightnode(file);
+ nerrors += test_unlink_middlenode(file);
+ } /* end if */
- if (nerrors) {
- printf("***** %d FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S");
- exit(1);
- }
+ /* Test "resurrecting" objects */
+ nerrors += test_resurrect_dataset(my_fapl);
+ nerrors += test_resurrect_datatype(my_fapl);
+ nerrors += test_resurrect_group(my_fapl);
- puts("All unlink tests passed.");
- h5_cleanup(FILENAME, fapl);
+ /* Test unlinking chunked datasets */
+ nerrors += test_unlink_chunked_dataset(my_fapl);
+
+ /* Test unlinked groups which still have objects in them */
+ /* (only for new format groups) */
+ if(new_format) {
+ nerrors += test_full_group_compact(my_fapl);
+ nerrors += test_full_group_dense(my_fapl);
+ } /* end if */
+
+ /* Close */
+ if(H5Fclose(file) < 0) TEST_ERROR
+ } /* end for */
+
+ /* Close 2nd FAPL */
+ H5Pclose(fapl2);
+
+ if (nerrors) {
+ printf("***** %d FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S");
+ exit(1);
}
- else
- puts("All unlink tests skipped - Incompatible with current Virtual File Driver");
+
+ puts("All unlink tests passed.");
+
+ h5_cleanup(FILENAME, fapl);
return 0;
diff --git a/test/vfd.c b/test/vfd.c
index b5ca096..bd642be 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -44,6 +44,7 @@ const char *FILENAME[] = {
"sec2_file",
"core_file",
"family_file",
+ "new_family_v16_",
"multi_file",
"direct_file",
NULL
@@ -156,7 +157,7 @@ test_direct(void)
size_t fbsize;
size_t cbsize;
int *points, *check, *p1, *p2;
- int wdata2[DSET2_DIM] = {11,12,13,14};
+ int wdata2[DSET2_DIM] = {11,12,13,14};
int rdata2[DSET2_DIM];
int i, j, n;
#endif /*H5_HAVE_DIRECT*/
@@ -173,7 +174,7 @@ test_direct(void)
fapl = h5_fileaccess();
if(H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0)
TEST_ERROR;
- h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[5], fapl, filename, sizeof filename);
/* Verify the file access properties */
if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0)
@@ -183,7 +184,7 @@ test_direct(void)
if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0)
TEST_ERROR;
-
+
H5E_BEGIN_TRY {
file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
} H5E_END_TRY;
@@ -212,10 +213,11 @@ test_direct(void)
if(H5Fget_filesize(file, &file_size) < 0)
TEST_ERROR;
- /* There is no garantee the size of metadata in file is constant.
- * Just try to check if it's reasonable. It's 2KB right now.
+ /* There is no guarantee of the number of metadata allocations, but it's
+ * 4 currently and the size of the file should be between 3 & 4 file buffer
+ * sizes..
*/
- if(file_size<1*KB || file_size>4*KB)
+ if(file_size < (FBSIZE * 3) || file_size >= (FBSIZE * 4))
TEST_ERROR;
/* Allocate aligned memory for data set 1. For data set 1, everything is aligned including
@@ -351,7 +353,7 @@ error:
* Added test for H5Fget_filesize.
*
* Raymond Lu, 2006-11-30
- * Enabled the driver to read an existing file depending on
+ * Enabled the driver to read an existing file depending on
* the setting of the backing_store and file open flags.
*-------------------------------------------------------------------------
*/
@@ -408,7 +410,7 @@ test_core(void)
TEST_ERROR;
- /* Open the file with backing store off for read and write.
+ /* Open the file with backing store off for read and write.
* Changes won't be saved in file. */
if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, FALSE) < 0)
TEST_ERROR;
@@ -468,7 +470,7 @@ test_core(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
- /* Open the file with backing store on for read and write.
+ /* Open the file with backing store on for read and write.
* Changes will be saved in file. */
if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
TEST_ERROR;
@@ -801,9 +803,12 @@ static herr_t
test_family_compat(void)
{
hid_t file = (-1), fapl;
+ hid_t dset;
+ char dname[]="dataset";
char filename[1024];
- char pathname[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ char pathname[1024], pathname_individual[1024];
+ char newname[1024], newname_individual[1024];
+ int counter = 0;
TESTING("FAMILY file driver backward compatibility");
@@ -814,24 +819,53 @@ test_family_compat(void)
TEST_ERROR;
h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[3], fapl, newname, sizeof newname);
pathname[0] = '\0';
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(pathname))) {
- HDstrcpy(pathname, srcdir);
- HDstrcat(pathname, "/");
- }
HDstrcat(pathname, filename);
- if((file = H5Fopen(pathname, H5F_ACC_RDONLY, fapl)) < 0)
+ /* The following code makes the copies of the family files in the source directory.
+ * Since we're going to open the files with write mode, this protects the original
+ * files.
+ */
+ sprintf(newname_individual, newname, counter);
+ sprintf(pathname_individual, pathname, counter);
+
+ while (h5_make_local_copy(pathname_individual, newname_individual) >= 0) {
+ counter++;
+ sprintf(newname_individual, newname, counter);
+ sprintf(pathname_individual, pathname, counter);
+ }
+
+ /* Make sure we can open the file. Use the read and write mode to flush the
+ * superblock. */
+ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR;
+
+ if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(dset) < 0)
TEST_ERROR;
if(H5Fclose(file) < 0)
TEST_ERROR;
- if(H5Pclose(fapl) < 0)
+ /* Open the file again to make sure it isn't corrupted. */
+ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR;
+
+ if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(dset) < 0)
+ TEST_ERROR;
+
+ if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_cleanup(FILENAME, fapl);
+
PASSED();
return 0;
@@ -839,6 +873,7 @@ test_family_compat(void)
error:
H5E_BEGIN_TRY {
H5Fclose(file);
+ H5Pclose(fapl);
} H5E_END_TRY;
return -1;
@@ -943,7 +978,7 @@ test_multi(void)
sprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b');
memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE];
memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/4;
-
+
sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r');
memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW];
memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2;
@@ -955,7 +990,7 @@ test_multi(void)
if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0)
TEST_ERROR;
- h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR;