summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
commitd2b87ec47ebdb096c331c7b62a195b9cea2f33ae (patch)
treea066f01361afaf5df457cef612bb0bb9fd80fe18 /test
parentee5a1e07350f0dcf3ef07d9443aa2f4c073392f4 (diff)
downloadhdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.zip
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.gz
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.bz2
[svn-r17896] Description:
Bring r17546:17895 from trunk to revise_chunks branch. Changes to fixed and extensible array dataset chunk indexing code to accommodate changes to private APIs in those interfaces. Also, other adjustments to source code and expected output in response to changes on the trunk. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am51
-rw-r--r--test/Makefile.in70
-rw-r--r--test/app_ref.c4
-rw-r--r--test/btree2.c4674
-rw-r--r--test/cmpd_dset.c434
-rw-r--r--test/dsets.c31
-rw-r--r--test/dtypes.c54
-rw-r--r--test/earray.c31
-rw-r--r--test/farray.c62
-rw-r--r--test/fheap.c4
-rw-r--r--test/filespace_1_6.h5bin0 -> 2448 bytes
-rw-r--r--test/filespace_1_8.h5bin0 -> 2448 bytes
-rw-r--r--test/gen_filespace.c81
-rw-r--r--test/gen_specmetaread.c96
-rw-r--r--test/gheap.c131
-rw-r--r--test/h5test.c60
-rw-r--r--test/h5test.h1
-rw-r--r--test/links.c446
-rw-r--r--test/mf.c1365
-rwxr-xr-xtest/objcopy.c521
-rw-r--r--test/ohdr.c20
-rw-r--r--test/specmetaread.h5bin0 -> 1752 bytes
-rw-r--r--test/stab.c78
-rw-r--r--test/tcheck_version.c28
-rw-r--r--test/tconfig.c30
-rw-r--r--test/testcheck_version.sh.in35
-rw-r--r--test/tfile.c705
-rw-r--r--test/tgenprop.c147
-rw-r--r--test/tmisc.c107
-rw-r--r--test/tunicode.c5
-rw-r--r--test/vfd.c34
31 files changed, 6567 insertions, 2738 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 48ce292..2d5d0b7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -64,7 +64,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta
# so do not appear in this list.
BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \
gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \
- gen_nullspace gen_udlinks space_overflow
+ gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread
if BUILD_ALL_CONDITIONAL
noinst_PROGRAMS=$(BUILD_ALL_PROGS)
@@ -105,29 +105,30 @@ flush2.chkexe_: flush1.chkexe_
# specifying a file prefix or low-level driver. Changing the file
# 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 chunk_cache.h5 big_chunk.h5 chunk_fast.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 swmr_data.h5
+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 chunk_cache.h5 big_chunk.h5 chunk_fast.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 swmr_data.h5
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
@@ -136,6 +137,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 febdc45..c95c3c2 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -96,7 +96,8 @@ am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(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 = $(bin_PROGRAMS) $(noinst_PROGRAMS)
app_ref_SOURCES = app_ref.c
app_ref_OBJECTS = app_ref.$(OBJEXT)
@@ -214,6 +215,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)
@@ -250,6 +255,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)
@@ -386,11 +395,12 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.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_filters.c gen_idx.c \
- gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
- gen_new_super.c gen_noencoder.c gen_nullspace.c gen_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 \
+ gen_cross.c gen_deflate.c gen_filespace.c gen_filters.c \
+ gen_idx.c gen_new_array.c gen_new_fill.c gen_new_group.c \
+ gen_new_mtime.c gen_new_super.c gen_noencoder.c \
+ gen_nullspace.c gen_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 swmr_generator.c \
swmr_reader.c swmr_writer.c tcheck_version.c \
$(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
@@ -400,13 +410,14 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.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_filters.c gen_idx.c \
- gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
- gen_new_super.c gen_noencoder.c gen_nullspace.c gen_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 swmr_generator.c \
- swmr_reader.c swmr_writer.c tcheck_version.c \
+ gen_bogus.c gen_cross.c gen_deflate.c gen_filespace.c \
+ gen_filters.c gen_idx.c gen_new_array.c gen_new_fill.c \
+ gen_new_group.c gen_new_mtime.c gen_new_super.c \
+ gen_noencoder.c gen_nullspace.c gen_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 \
+ swmr_generator.c swmr_reader.c swmr_writer.c tcheck_version.c \
$(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
vfd.c
ETAGS = etags
@@ -417,6 +428,16 @@ 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@
@@ -430,21 +451,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@
@@ -467,7 +485,7 @@ F9XMODEXT = @F9XMODEXT@
F9XMODFLAG = @F9XMODFLAG@
F9XSUFFIXFLAG = @F9XSUFFIXFLAG@
FC = @FC@
-FCFLAGS = @FCFLAGS@ @H5_FCFLAGS@
+FCFLAGS = @FCFLAGS@
FCFLAGS_f90 = @FCFLAGS_f90@
FCLIBS = @FCLIBS@
FGREP = @FGREP@
@@ -724,7 +742,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_idx gen_new_array \
gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \
- gen_nullspace gen_udlinks space_overflow
+ gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread
# The libh5test library provides common support code for the tests.
@@ -749,7 +767,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.,
@@ -965,6 +983,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)
@@ -992,6 +1013,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)
@@ -1110,6 +1134,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_bogus.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_cross.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_deflate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_filespace.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_filters.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_idx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_new_array.Po@am__quote@
@@ -1119,6 +1144,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@
diff --git a/test/app_ref.c b/test/app_ref.c
index cb8be6a..611d255 100644
--- a/test/app_ref.c
+++ b/test/app_ref.c
@@ -85,8 +85,8 @@ 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]);
+ fprintf(stderr, "%s ID reference count: %n", IDNAME[i], &n);
+ fprintf(stderr, "%*d\n", (n < ERR_WIDTH) ? (ERR_WIDTH - n) : 0, rc[i]);
}
}
diff --git a/test/btree2.c b/test/btree2.c
index dc0caa5..6006dc8 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)))
+ 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)))
+ 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
@@ -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
@@ -220,40 +459,45 @@ remove_cb(const void *_record, void *_op_data)
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_basic(hid_t fapl)
+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 = (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
+
+ 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,50 +505,57 @@ test_insert_basic(hid_t fapl)
/* Attempt to find record in B-tree with no records */
idx = 0;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, NULL) != FALSE)
+ 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;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) != FALSE)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Try again with NULL 'op' */
/* (Should not be found, but not fail) */
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, NULL, NULL) != FALSE)
+ 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) != TRUE)
+ 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) != TRUE)
+ 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)
@@ -312,45 +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;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) != FALSE)
+ 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) != TRUE)
+ 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)
@@ -358,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);
@@ -396,7 +665,6 @@ error:
* left and right leaf nodes after the split
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -405,128 +673,120 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_split_root(hid_t fapl)
+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 = (H5F_t *)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;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) != FALSE)
+ 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) != TRUE)
+ 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) != TRUE)
+ 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)
@@ -534,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;
@@ -572,7 +839,6 @@ error:
* redistribution
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -581,77 +847,70 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level1_2leaf_redistrib(hid_t fapl)
+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 = (H5F_t *)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();
@@ -660,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)
@@ -716,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;
@@ -732,7 +990,6 @@ error:
* split, adding another node to the B-tree
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -741,83 +998,75 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level1_side_split(hid_t fapl)
+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 = (H5F_t *)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();
/*
@@ -825,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)
@@ -886,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;
@@ -912,118 +1158,110 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level1_3leaf_redistrib(hid_t fapl)
+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 = (H5F_t *)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
@@ -1034,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;
@@ -1051,7 +1291,6 @@ error:
* add records until a 3 node split occurs
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -1060,98 +1299,89 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level1_middle_split(hid_t fapl)
+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 = (H5F_t *)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
@@ -1162,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;
@@ -1175,7 +1407,6 @@ error:
* records to make a level 2 B-tree
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -1184,85 +1415,81 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_make_level2(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -1272,49 +1499,40 @@ test_insert_make_level2(hid_t fapl)
/* Attempt to find non-existant record in level-2 B-tree */
/* (Should not be found, but not fail) */
idx = INSERT_SPLIT_ROOT_NREC * 30;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) != FALSE)
+ 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) != TRUE)
+ 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) != TRUE)
+ 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) != TRUE)
+ 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)
@@ -1322,19 +1540,24 @@ 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)
FAIL_STACK_ERROR
@@ -1345,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;
@@ -1368,128 +1593,96 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level2_leaf_redistrib(hid_t fapl)
+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 = (H5F_t *)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
@@ -1497,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)
- 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)
+ if(check_node_depth(bt2, dxpl, (hsize_t)630, (unsigned)1) < 0) /* Record in middle node 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)
+ 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
@@ -1610,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;
@@ -1633,248 +1802,204 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level2_leaf_split(hid_t fapl)
+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 = (H5F_t *)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
@@ -1885,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;
@@ -1909,165 +2036,142 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level2_2internal_redistrib(hid_t fapl)
+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 = (H5F_t *)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
@@ -2078,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;
@@ -2102,174 +2208,148 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level2_2internal_split(hid_t fapl)
+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 = (H5F_t *)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
@@ -2280,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;
@@ -2305,173 +2387,147 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level2_3internal_redistrib(hid_t fapl)
+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 = (H5F_t *)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
@@ -2482,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;
@@ -2507,179 +2565,151 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_level2_3internal_split(hid_t fapl)
+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 = (H5F_t *)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
@@ -2690,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;
@@ -2712,13 +2744,16 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_insert_lots(hid_t fapl)
+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 */
@@ -2743,22 +2778,23 @@ 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 = (hsize_t *)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++) {
+ 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)
@@ -2766,29 +2802,30 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
- FAIL_STACK_ERROR
+ 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
@@ -2801,17 +2838,19 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
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)))
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 */
@@ -2821,7 +2860,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Attempt to find non-existant record in level-4 B-tree */
/* (Should not be found, but not fail) */
idx = INSERT_MANY * 2;
- if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx) != FALSE)
+ if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE)
TEST_ERROR
/* Find random records */
@@ -2830,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) != TRUE)
+ 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)
@@ -2855,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 */
@@ -2868,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
@@ -2896,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);
@@ -2909,7 +2959,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -2918,39 +2967,33 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_basic(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -2960,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)
@@ -2970,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 */
@@ -2984,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 */
@@ -2994,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)
@@ -3004,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 */
@@ -3014,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 */
@@ -3022,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 */
@@ -3034,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 */
@@ -3060,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)
@@ -3072,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 */
@@ -3082,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 */
@@ -3090,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 */
@@ -3099,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 */
@@ -3107,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 */
@@ -3115,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 */
@@ -3124,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 */
@@ -3132,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 */
@@ -3140,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 */
@@ -3149,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 */
@@ -3157,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 */
@@ -3165,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
@@ -3182,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;
@@ -3194,7 +3267,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3203,48 +3275,41 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_noredistrib(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -3252,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 */
@@ -3262,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 */
@@ -3280,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 */
@@ -3305,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 */
@@ -3327,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 */
@@ -3342,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 */
@@ -3364,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 */
@@ -3379,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;
- if (H5Fclose(file)<0) TEST_ERROR
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED();
return 0;
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
return 1;
@@ -3417,7 +3490,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3426,59 +3498,48 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_redistrib(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -3486,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 */
@@ -3505,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 */
@@ -3515,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 */
@@ -3540,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 */
@@ -3550,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 */
@@ -3575,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 */
@@ -3585,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
@@ -3605,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;
@@ -3617,7 +3687,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3626,61 +3695,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_2leaf_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -3688,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 */
@@ -3707,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 */
@@ -3716,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();
@@ -3729,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 */
@@ -3762,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 */
@@ -3771,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
@@ -3789,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;
@@ -3801,7 +3866,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3810,61 +3874,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_3leaf_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -3872,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 */
@@ -3891,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 */
@@ -3899,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
@@ -3917,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;
@@ -3929,7 +3992,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -3938,71 +4000,56 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_promote(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4010,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 */
@@ -4029,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 */
@@ -4067,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 */
@@ -4078,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 */
@@ -4112,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 */
@@ -4123,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;
@@ -4173,7 +4219,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4182,61 +4227,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_promote_2leaf_redistrib(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4244,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 */
@@ -4265,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 */
@@ -4275,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 */
@@ -4283,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
@@ -4314,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;
@@ -4326,7 +4367,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4335,61 +4375,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_promote_3leaf_redistrib(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4397,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 */
@@ -4418,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 */
@@ -4428,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 */
@@ -4437,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
@@ -4467,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;
@@ -4479,7 +4515,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4488,61 +4523,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_promote_2leaf_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4550,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 */
@@ -4571,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 */
@@ -4581,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 */
@@ -4589,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
@@ -4615,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;
@@ -4627,7 +4660,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4636,61 +4668,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_promote_3leaf_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4698,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 */
@@ -4719,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 */
@@ -4729,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 */
@@ -4737,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
@@ -4763,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;
@@ -4775,7 +4805,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4784,55 +4813,47 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level1_collapse(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4840,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 */
@@ -4859,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 */
@@ -4868,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 */
@@ -4885,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
@@ -4902,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;
@@ -4914,7 +4944,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -4923,61 +4952,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_promote(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -4985,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 */
@@ -5012,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 */
@@ -5033,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 */
@@ -5052,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 */
@@ -5073,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 */
@@ -5092,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 */
@@ -5113,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 */
@@ -5132,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 */
@@ -5167,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
@@ -5193,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;
@@ -5205,7 +5230,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5214,61 +5238,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_promote_2internal_redistrib(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -5276,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 */
@@ -5303,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 */
@@ -5313,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
@@ -5346,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;
@@ -5358,7 +5380,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5367,61 +5388,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_promote_3internal_redistrib(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -5429,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 */
@@ -5456,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 */
@@ -5466,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
@@ -5499,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;
@@ -5511,7 +5530,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5520,61 +5538,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_promote_2internal_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -5582,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 */
@@ -5610,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 */
@@ -5621,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 */
@@ -5629,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
@@ -5655,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;
@@ -5667,7 +5681,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5676,61 +5689,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_promote_3internal_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -5738,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 */
@@ -5766,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 */
@@ -5777,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 */
@@ -5785,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
@@ -5811,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;
@@ -5823,7 +5832,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5832,61 +5840,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_2internal_merge_left(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -5894,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 */
@@ -5913,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 */
@@ -5921,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
@@ -5939,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;
@@ -5951,7 +5958,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -5960,61 +5966,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_2internal_merge_right(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -6022,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 */
@@ -6041,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 */
@@ -6049,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
@@ -6067,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;
@@ -6079,7 +6084,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -6088,61 +6092,50 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_3internal_merge(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -6150,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 */
@@ -6169,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 */
@@ -6177,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
@@ -6195,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;
@@ -6207,7 +6210,6 @@ error:
* Purpose: Basic tests for the B-tree v2 code
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -6216,62 +6218,51 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_level2_collapse_right(hid_t fapl)
+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 = (H5F_t *)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 */
@@ -6279,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 */
@@ -6298,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 */
@@ -6307,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
@@ -6322,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;
@@ -6342,11 +6344,13 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-gen_l4_btree2(const char *filename, hid_t fapl, haddr_t *bt2_addr,
- const hsize_t *records)
+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;
- 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 */
hsize_t record; /* Record to insert into tree */
unsigned u; /* Local index variable */
H5B2_stat_t bt2_stat; /* Statistics about B-tree created */
@@ -6359,25 +6363,28 @@ gen_l4_btree2(const char *filename, hid_t fapl, haddr_t *bt2_addr,
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)
+ 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
@@ -6386,6 +6393,8 @@ gen_l4_btree2(const char *filename, hid_t fapl, haddr_t *bt2_addr,
error:
H5E_BEGIN_TRY {
+ if(bt2)
+ H5B2_close(bt2, dxpl);
H5Fclose(file);
} H5E_END_TRY;
@@ -6409,17 +6418,19 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_remove_lots(const char *env_h5_drvr, hid_t fapl)
+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 */
@@ -6462,7 +6473,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
/* Generate the v2 B-tree to test */
- if(gen_l4_btree2(filename, fapl, &bt2_addr, records))
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
TEST_ERROR
/* Check for VFD which stores data in multiple files */
@@ -6514,11 +6525,15 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
records[swap_idx] = temp_rec;
} /* end for */
+ /* Re-open v2 B-tree */
+ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr)))
+ 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 */
@@ -6526,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 */
@@ -6535,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
@@ -6569,7 +6589,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end if */
else {
/* Re-generate the v2 B-tree to test */
- if(gen_l4_btree2(filename, fapl, &bt2_addr, records))
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
TEST_ERROR
} /* end else */
@@ -6585,6 +6605,10 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
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)))
+ FAIL_STACK_ERROR
+
/* Remove all records */
for(u = 0; u < INSERT_MANY; u++) {
/* Pick a record index to remove from randomly */
@@ -6592,7 +6616,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
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 */
@@ -6600,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 */
@@ -6609,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
@@ -6643,7 +6672,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end if */
else {
/* Re-generate the v2 B-tree to test */
- if(gen_l4_btree2(filename, fapl, &bt2_addr, records))
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
TEST_ERROR
} /* end else */
@@ -6660,11 +6689,15 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
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)))
+ 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 */
@@ -6672,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 */
@@ -6681,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
@@ -6715,7 +6753,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
} /* end if */
else {
/* Re-generate the v2 B-tree to test */
- if(gen_l4_btree2(filename, fapl, &bt2_addr, records))
+ if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records))
TEST_ERROR
} /* end else */
@@ -6732,11 +6770,15 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
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)))
+ 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 */
@@ -6744,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 */
@@ -6753,13 +6795,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
@@ -6775,6 +6822,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;
@@ -6796,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
@@ -6805,13 +6853,15 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_find_neighbor(hid_t fapl)
+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 */
@@ -6819,106 +6869,96 @@ test_find_neighbor(hid_t fapl)
herr_t ret; /* Generic error return value */
/* Allocate space for the records */
- if((records = (hsize_t *)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 = (H5F_t *)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
@@ -6930,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
@@ -7003,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);
@@ -7017,7 +7067,6 @@ error:
* code to delete a B-tree from a file
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -7026,15 +7075,17 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_delete(hid_t fapl)
+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 */
@@ -7065,16 +7116,19 @@ test_delete(hid_t fapl)
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, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close the file */
@@ -7102,29 +7156,32 @@ test_delete(hid_t fapl)
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, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close file */
@@ -7152,29 +7209,32 @@ test_delete(hid_t fapl)
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, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close file */
@@ -7202,29 +7262,32 @@ test_delete(hid_t fapl)
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, NULL, NULL) < 0)
FAIL_STACK_ERROR
/* Close file */
@@ -7245,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;
@@ -7258,7 +7323,6 @@ error:
* code to modify an existing record in the B-tree
*
* Return: Success: 0
- *
* Failure: 1
*
* Programmer: Quincey Koziol
@@ -7267,13 +7331,15 @@ error:
*-------------------------------------------------------------------------
*/
static unsigned
-test_modify(hid_t fapl)
+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 */
@@ -7281,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 = (H5F_t *)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
@@ -7319,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)
@@ -7329,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) != TRUE)
+ if(H5B2_find(bt2, dxpl, &record, find_cb, &found) != TRUE)
FAIL_STACK_ERROR
if(found != 4331)
TEST_ERROR
@@ -7363,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)
@@ -7373,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) != TRUE)
+ if(H5B2_find(bt2, dxpl, &record, find_cb, &found) != TRUE)
STACK_ERROR
if(found != 5352)
TEST_ERROR
@@ -7407,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)
@@ -7417,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) != TRUE)
+ if(H5B2_find(bt2, dxpl, &record, find_cb, &found) != TRUE)
STACK_ERROR
if(found != 9448)
TEST_ERROR
@@ -7451,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
@@ -7467,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;
@@ -7490,8 +7561,11 @@ 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;
@@ -7503,64 +7577,80 @@ main(void)
h5_reset();
fapl = h5_fileaccess();
ExpressMode = GetTestExpress();
- if (ExpressMode > 1)
+ 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(envval, 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);
+ /* 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;
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index 53c63d7..b154f51 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -199,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) {
@@ -209,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;
+ }
/*
*######################################################################
@@ -1738,7 +1750,8 @@ error:
* Function: test_pack_ooo
*
* Purpose: Test inserting fields into a compound out of offset order.
- * Verifies that the compound
+ * Verifies that the compound is correctly marked as packed
+ * or non-packed.
*
* Return: Success: 0
*
@@ -1760,6 +1773,8 @@ test_pack_ooo(void)
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));
@@ -1787,171 +1802,353 @@ test_pack_ooo(void)
/* Generate order to insert inner compound type */
sub_cmpd_order = HDrand() % PACK_NMEMBS;
- TESTING("random member insertion with empty compound subtype");
+ 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...");
- /* Create inner compound type. It will be empty for the first run */
- if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR
+ TESTING("random member insertion with empty compound subtype");
- /* Create main compound type, with extra space at the end */
- if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + 1)) < 0) PACK_OOO_ERROR
+ /* Create inner compound type. It will be empty for the first run */
+ if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 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 */
+ /* Create main compound type, with extra space at the end */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
- /* 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
+ /* 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 */
- /* Close the main compound */
- if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ /* 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
- PASSED();
+ /* Close the main compound */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
- TESTING("random member insertion with full compound subtype");
+ PASSED();
- /* Complete the inner compound type */
- if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR
+ TESTING("random member insertion with full compound subtype");
- /* Recreate main compound type */
- if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + 1)) < 0) PACK_OOO_ERROR
+ /* Complete the inner compound type */
+ if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 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 */
+ /* Recreate main compound type */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
- /* 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) 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 */
- /* Close */
- if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
- if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
+ /* 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
- PASSED();
+ /* Close */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
- TESTING("reverse member insertion with empty compound subtype");
+ PASSED();
- /* Create inner compound type. It will be empty for the first run */
- if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR
+ TESTING("reverse member insertion with empty compound subtype");
- /* Create main compound type, with extra space at the end */
- if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + 1)) < 0) PACK_OOO_ERROR
+ /* Create inner compound type. It will be empty for the first run */
+ if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 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 */
+ /* Create main compound type, with extra space at the end */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
- /* 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
+ /* 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 */
- /* Close the main compound */
- if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ /* 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
- PASSED();
+ /* Close the main compound */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
- TESTING("reverse member insertion with full compound subtype");
+ PASSED();
- /* Complete the inner compound type */
- if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR
+ TESTING("reverse member insertion with full compound subtype");
- /* Recreate main compound type */
- if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + 1)) < 0) PACK_OOO_ERROR
+ /* Complete the inner compound type */
+ if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 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 */
+ /* Recreate main compound type */
+ if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR
- /* 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) 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 */
- /* Close */
- if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
- if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
+ /* 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
- PASSED();
+ /* Close */
+ if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR
+ if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
- TESTING("forward member insertion with empty compound subtype");
+ PASSED();
- /* Create inner compound type. It will be empty for the first run */
- if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR
+ TESTING("forward member insertion with empty compound subtype");
- /* Create main compound type, with extra space at the end */
- if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + 1)) < 0) PACK_OOO_ERROR
+ /* Create inner compound type. It will be empty for the first run */
+ if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 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
+ /* 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; /* File ID */
+ hid_t dtype, dtype_tmp; /* Datatype IDs */
+ H5T_t *dt; /* 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(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
- if(dt->shared->u.compnd.packed) PACK_OOO_ERROR
+ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE)))
+ TEST_ERROR
+ if(dt->shared->u.compnd.packed) TEST_ERROR
- /* Close the main compound */
- if(H5Tclose(cmpd) < 0) PACK_OOO_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
- PASSED();
+ /* Commit the datatype */
+ if(H5Tcommit2(file, "dtype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
- TESTING("forward member insertion with full compound subtype");
+ /* 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
- /* Complete the inner compound type */
- if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR
+ /* Open the type */
+ if((dtype_tmp = H5Topen2(file, "dtype", H5P_DEFAULT)) < 0) TEST_ERROR
- /* Recreate main compound type */
- if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + 1)) < 0) PACK_OOO_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
- /* 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 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(cmpd, H5I_DATATYPE))) PACK_OOO_ERROR
- if(!dt->shared->u.compnd.packed) PACK_OOO_ERROR
+ 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(cmpd) < 0) PACK_OOO_ERROR
- if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR
+ 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 */
/*-------------------------------------------------------------------------
@@ -2007,6 +2204,9 @@ main (int argc, char *argv[])
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/dsets.c b/test/dsets.c
index 2066860..07ee0d0 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -42,6 +42,7 @@
#define H5Z_PACKAGE
#include "H5Zpkg.h"
+
const char *FILENAME[] = {
"dataset", /* 0 */
"compact_dataset", /* 1 */
@@ -157,6 +158,7 @@ const char *FILENAME[] = {
/* 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"
@@ -1724,6 +1726,8 @@ error:
* Monday, June 7, 2004
*
* Modifications:
+ * Make copy of data file since the test writes to the file.
+ * Larry Knox, October 14, 2009
*
*-------------------------------------------------------------------------
*/
@@ -1741,20 +1745,14 @@ test_filter_noencoder(const char *dset_name)
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, H5P_DEFAULT);
+
+ /* 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);
@@ -1836,6 +1834,7 @@ error:
H5Pclose(dcpl_id);
if(file_id != -1)
H5Fclose(file_id);
+
return -1;
}
#endif /* H5_HAVE_FILTER_SZIP */
@@ -8322,6 +8321,10 @@ main(void)
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/dtypes.c b/test/dtypes.c
index 545a098..2619f1b 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -3707,10 +3707,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;
@@ -6242,10 +6273,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;
diff --git a/test/earray.c b/test/earray.c
index fe5cb99..c1584f9 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -423,8 +423,7 @@ error:
*/
static int
reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
- H5EA_t **ea, haddr_t ea_addr, const H5EA_class_t *ea_cls,
- const earray_test_param_t *tparam)
+ 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) */
@@ -452,7 +451,7 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
/* Re-open array, if given */
if(ea) {
- if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, ea_cls, NULL)))
+ if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL)))
FAIL_STACK_ERROR
} /* end if */
} /* end if */
@@ -577,7 +576,7 @@ HDsystem("cp earray.h5 earray.h5.save");
#endif /* QAK */
/* Delete array */
- if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_addr) < 0)
+ if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL) < 0)
FAIL_STACK_ERROR
/* Close the file */
@@ -1055,11 +1054,11 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
FAIL_STACK_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, NULL, tparam) < 0)
+ 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, cparam->cls, NULL)))
+ if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -1124,7 +1123,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
TEST_ERROR
/* Open the array again, through the first file handle */
- if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL)))
+ if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -1139,7 +1138,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
ea2 = NULL;
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Re-open the file */
@@ -1151,7 +1150,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
FAIL_STACK_ERROR
/* Open the extensible array through the second file handle */
- if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL)))
+ if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -1230,11 +1229,11 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
TEST_ERROR
/* Open the array again */
- if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL)))
+ 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) < 0)
+ if(H5EA_delete(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL) < 0)
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -1250,7 +1249,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
/* 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, cparam->cls, NULL);
+ ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL);
} H5E_END_TRY;
if(ea2) {
/* Close opened array */
@@ -1266,12 +1265,12 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
ea = NULL;
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, NULL, tparam) < 0)
+ 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, cparam->cls, NULL);
+ ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened array */
@@ -2472,7 +2471,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
TEST_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Verify high-water # of elements written */
@@ -2646,7 +2645,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
TEST_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, cparam->cls, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Verify high-water # of elements written */
diff --git a/test/farray.c b/test/farray.c
index c7a2796..b949263 100644
--- a/test/farray.c
+++ b/test/farray.c
@@ -263,8 +263,7 @@ set_fa_state(const H5FA_create_t *cparam, farray_state_t *state)
*/
static int
reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
- H5FA_t **fa, haddr_t fa_addr, const H5FA_class_t *fa_cls,
- const farray_test_param_t *tparam)
+ 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) */
@@ -292,7 +291,7 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
/* Re-open array, if given */
if(fa) {
- if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, fa_cls, NULL)))
+ if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL)))
FAIL_STACK_ERROR
} /* end if */
} /* end if */
@@ -317,12 +316,12 @@ error:
*/
static int
create_array(H5F_t *f, hid_t dxpl, const H5FA_create_t *cparam,
- H5FA_t **fa, haddr_t *fa_addr, void *cb)
+ 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, cb)))
+ if(NULL == (*fa = H5FA_create(f, dxpl, cparam, NULL)))
FAIL_STACK_ERROR
/* Check status of array */
@@ -397,7 +396,7 @@ finish(hid_t file, hid_t fapl, H5F_t *f, H5FA_t *fa, haddr_t fa_addr)
FAIL_STACK_ERROR
/* Delete array */
- if(H5FA_delete(f, H5P_DATASET_XFER_DEFAULT, fa_addr) < 0)
+ if(H5FA_delete(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL) < 0)
FAIL_STACK_ERROR
/* Close the file */
@@ -509,7 +508,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t UNUSED *tpara
TESTING("fixed array creation");
/* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr, NULL) < 0)
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
TEST_ERROR
PASSED()
@@ -569,7 +568,7 @@ test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
TESTING("create, close & reopen fixed array");
/* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr, NULL) < 0)
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
TEST_ERROR
/* Close the fixed array */
@@ -577,11 +576,11 @@ test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
FAIL_STACK_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, NULL, tparam) < 0)
+ 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, cparam->cls, NULL)))
+ if(NULL == (fa = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -639,11 +638,11 @@ test_open_twice(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
TESTING("open fixed array twice");
/* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr, NULL) < 0)
+ 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, cparam->cls, NULL)))
+ if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -658,7 +657,7 @@ test_open_twice(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
fa2 = NULL;
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, cparam->cls, tparam) < 0)
+ if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0)
TEST_ERROR
/* Re-open the file */
@@ -670,7 +669,8 @@ test_open_twice(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
FAIL_STACK_ERROR
/* Open the fixed array through the second file handle */
- if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, cparam->cls, NULL))) FAIL_STACK_ERROR
+ 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)
@@ -741,15 +741,15 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
TESTING("deleting open fixed array");
/* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr, NULL) < 0)
+ 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, cparam->cls, NULL)))
+ 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) < 0)
+ if(H5FA_delete(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL) < 0)
FAIL_STACK_ERROR
/* Verify the creation parameters */
@@ -765,7 +765,7 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
/* 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, cparam->cls, NULL);
+ fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL);
} H5E_END_TRY;
if(fa2) {
/* Close opened array */
@@ -781,12 +781,12 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam)
fa = NULL;
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, NULL, tparam) < 0)
+ 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, cparam->cls, NULL);
+ fa = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL);
} H5E_END_TRY;
if(fa) {
/* Close opened array */
@@ -1185,7 +1185,7 @@ static const farray_iter_t fa_iter_cyc = {
*-------------------------------------------------------------------------
*/
static int
-check_elmt(farray_test_param_t *tparam, void *_relmt, void *_welmt)
+check_elmt(void *_relmt, void *_welmt)
{
uint64_t *relmt = (uint64_t *)_relmt;
uint64_t *welmt = (uint64_t *)_welmt;
@@ -1245,7 +1245,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
TEST_ERROR
/* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr, NULL) < 0)
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
TEST_ERROR
/* Verify the creation parameters */
@@ -1253,7 +1253,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
TEST_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, cparam->cls, tparam) < 0)
+ 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)
@@ -1289,7 +1289,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
FAIL_STACK_ERROR
/* Verify that the retrieved is correct */
- if(check_elmt(tparam, &relmt, NULL))
+ if(check_elmt(&relmt, NULL))
TEST_ERROR
} /* end for */
@@ -1316,7 +1316,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
FAIL_STACK_ERROR
/* Verify that the retrieved element is correct */
- if(check_elmt(tparam, &relmt, NULL))
+ if(check_elmt(&relmt, NULL))
TEST_ERROR
/* Set element of array */
@@ -1330,7 +1330,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
FAIL_STACK_ERROR
/* Verify that the retrieved element is correct */
- if(check_elmt(tparam, &relmt, &welmt))
+ if(check_elmt(&relmt, &welmt))
TEST_ERROR
} /* end for */
@@ -1400,7 +1400,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
TEST_ERROR
/* Create array */
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr, NULL) < 0)
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0)
TEST_ERROR
/* Verify the creation parameters */
@@ -1408,7 +1408,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
TEST_ERROR
/* Check for closing & re-opening the file */
- if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, cparam->cls, tparam) < 0)
+ 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)
@@ -1434,7 +1434,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
FAIL_STACK_ERROR
/* Verify that the retrieved is correct */
- if(check_elmt(tparam, &relmt, NULL))
+ if(check_elmt(&relmt, NULL))
TEST_ERROR
/* Set element of array */
@@ -1454,7 +1454,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
FAIL_STACK_ERROR
/* Verify that the retrieved is correct */
- if(check_elmt(tparam, &relmt, &welmt))
+ if(check_elmt(&relmt, &welmt))
TEST_ERROR
if(check_rest) {
@@ -1466,7 +1466,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam,
FAIL_STACK_ERROR
/* Verify that the retrieved is correct */
- if(check_elmt(tparam, &relmt, NULL))
+ if(check_elmt(&relmt, NULL))
TEST_ERROR
} /* end for */
} /* end if */
diff --git a/test/fheap.c b/test/fheap.c
index f45f856..26bcaec 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -2769,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
@@ -2799,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
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/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/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 360f1d9..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:
@@ -1093,3 +1091,55 @@ 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 e3b3596..315b504 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -152,6 +152,7 @@ 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, 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/links.c b/test/links.c
index 7c32238..60607c9 100644
--- a/test/links.c
+++ b/test/links.c
@@ -141,7 +141,7 @@ const char *FILENAME[] = {
#define FAMILY_SIZE 1024
#define CORE_INCREMENT 1024
-#define NUM400 400
+#define NUM40 40
/* do not do check_all_closed() for "ext*" files and "tmp/ext*" */
#define EXTSTOP 12
@@ -176,6 +176,8 @@ const char *FILENAME[] = {
#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"
@@ -1792,6 +1794,30 @@ 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, fapl)) < 0) TEST_ERROR
@@ -3409,8 +3435,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
@@ -3418,25 +3444,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
@@ -3793,7 +3811,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
cwdpath[NAME_BUF_SIZE];
hid_t core_fapl, space, dset, did, dapl_id, dcpl;
hsize_t dims[2];
- int points[NUM400][NUM400];
+ int points[NUM40][NUM40];
h5_stat_size_t filesize, new_filesize;
int i, j, n;
@@ -3827,8 +3845,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
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] = NUM400;
- dims[1] = NUM400;
+ dims[0] = NUM40;
+ dims[1] = NUM40;
if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
/* Create dataset creation property list */
@@ -3874,8 +3892,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
}
/* Initialize the dataset */
- for(i = n = 0; i < NUM400; i++)
- for(j = 0; j < NUM400; j++)
+ for(i = n = 0; i < NUM40; i++)
+ for(j = 0; j < NUM40; j++)
points[i][j] = n++;
/* Write the data to the dataset */
@@ -5299,7 +5317,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
@@ -8520,6 +8539,386 @@ error:
/*-------------------------------------------------------------------------
+ * 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
@@ -12971,7 +13370,6 @@ main(void)
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;
@@ -13025,7 +13423,6 @@ main(void)
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;
@@ -13037,6 +13434,7 @@ main(void)
nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0;
#endif
+
/* 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.
@@ -13045,7 +13443,6 @@ main(void)
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;
@@ -13058,6 +13455,7 @@ main(void)
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 */
diff --git a/test/mf.c b/test/mf.c
index 3c88501..ca89b79 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -19,6 +19,7 @@
* 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"
@@ -39,7 +40,14 @@
#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
@@ -60,6 +68,12 @@
#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
@@ -105,6 +119,11 @@ static unsigned test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t
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
@@ -5846,6 +5865,1345 @@ error:
} /* 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)
{
@@ -5930,6 +7288,12 @@ main(void)
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);
@@ -5947,3 +7311,4 @@ error:
} H5E_END_TRY;
return (1);
} /* main() */
+
diff --git a/test/objcopy.c b/test/objcopy.c
index 29c98b5..9d67d3e 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -88,6 +88,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"
@@ -850,8 +851,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 */
@@ -878,7 +953,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 */
@@ -7212,6 +7287,443 @@ 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, tid2; /* Datatype IDs */
+ hid_t sid = -1; /* Dataspace 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(): 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
@@ -7629,6 +8141,9 @@ 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_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);
diff --git a/test/ohdr.c b/test/ohdr.c
index df5f63b..16ffc7c 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -57,7 +57,7 @@ test_cont(char *filename, hid_t fapl)
{
hid_t file=-1;
H5F_t *f = NULL;
- H5O_info_t oinfo;
+ H5O_hdr_info_t hdr_info;
H5O_loc_t oh_locA, oh_locB;
time_t time_new;
const char *short_name = "T";
@@ -105,18 +105,18 @@ test_cont(char *filename, hid_t fapl)
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_info(&oh_locA, H5P_DATASET_XFER_DEFAULT, FALSE, &oinfo) < 0)
+ if(H5O_get_hdr_info(&oh_locA, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
FAIL_STACK_ERROR
- nchunks = oinfo.hdr.nchunks;
+ 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_info(&oh_locA, H5P_DATASET_XFER_DEFAULT, FALSE, &oinfo) < 0)
+ if(H5O_get_hdr_info(&oh_locA, H5P_DATASET_XFER_DEFAULT, &hdr_info) < 0)
FAIL_STACK_ERROR
- if (oinfo.hdr.nchunks >= nchunks)
+ if(hdr_info.nchunks >= nchunks)
TEST_ERROR
if(H5O_close(&oh_locA) < 0)
@@ -164,7 +164,7 @@ 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;
@@ -240,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();
@@ -267,9 +267,9 @@ main(void)
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();
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 319046e..c2655a8 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"
@@ -665,45 +666,22 @@ error:
static int
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], H5P_DEFAULT, 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(FILE_OLD_GROUPS_COPY, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR
/* Open copied file */
- if((fid = H5Fopen(filename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 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
@@ -1106,46 +1084,13 @@ error:
static int
corrupt_stab_msg(void)
{
- char testfile[512]=""; /* Character buffer for corrected test file name */
- char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */
- FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */
- void *copy_buf; /* Pointer to buffer for copying data */
- size_t written; /* Amount of data written to new file */
- size_t read_in; /* Amount of data read in from old file */
hid_t fid = (-1); /* File ID */
hid_t did = (-1); /* Dataset ID */
TESTING("corrupt symbol table message");
- /* Generate the correct name for the test file, by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(CORRUPT_STAB_FILE) + 1) < sizeof(testfile))) {
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, CORRUPT_STAB_FILE);
-
- /* Open the temporary file */
- if(NULL == (tmp_fp = HDfopen(CORRUPT_STAB_TMP_FILE,"wb"))) TEST_ERROR
-
- /* Open the old file */
- if(NULL == (old_fp = fopen(testfile,"rb"))) TEST_ERROR
-
- /* Allocate space for the copy buffer */
- if(NULL == (copy_buf = HDmalloc((size_t)CORRUPT_STAB_COPY_BUF_SIZE))) TEST_ERROR
-
- /* Copy data from the old file to the new file */
- while((read_in = HDfread(copy_buf, (size_t)1, (size_t)CORRUPT_STAB_COPY_BUF_SIZE, old_fp)) > 0)
- /* Write the data to the new file */
- if(read_in != (written = HDfwrite(copy_buf, (size_t)1, read_in, tmp_fp))) TEST_ERROR
-
- /* Close the old file */
- if(HDfclose(old_fp)) TEST_ERROR
-
- /* Close the new file */
- if(HDfclose(tmp_fp)) TEST_ERROR
-
- /* Free the copy buffer */
- free(copy_buf);
+ /* 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 */
@@ -1186,8 +1131,6 @@ corrupt_stab_msg(void)
if(H5Fclose(fid) < 0) TEST_ERROR
#endif /* H5_STRICT_FORMAT_CHECKS */
- /* Remove temporary file */
- if(HDremove(CORRUPT_STAB_TMP_FILE)) TEST_ERROR
PASSED();
@@ -1198,7 +1141,6 @@ error:
H5Dclose(did);
H5Fclose(fid);
} H5E_END_TRY;
- HDremove(CORRUPT_STAB_TMP_FILE);
return 1;
} /* end old_api() */
@@ -1266,6 +1208,10 @@ main(void)
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;
diff --git a/test/tcheck_version.c b/test/tcheck_version.c
index 7a34b26..91d98ef 100644
--- a/test/tcheck_version.c
+++ b/test/tcheck_version.c
@@ -25,14 +25,19 @@
*
* Programmer: Albert Cheng
* September 20, 2009
+ * Modifications:
+ * Added abort signal intercept. AKC - 2009/10/16 -
*/
-
-#include <stdlib.h>
-#include "hdf5.h"
+#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;
@@ -90,10 +95,27 @@ parse(int ac, char **av)
}
}
+/* 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 355191d..47eed64 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);
/*-------------------------------------------------------------------------
@@ -69,6 +70,7 @@ test_configure(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing configure definitions\n"));
test_config_ctypes();
+ test_exit_definitions();
}
@@ -202,3 +204,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/testcheck_version.sh.in b/test/testcheck_version.sh.in
index 593a466..6e80654 100644
--- a/test/testcheck_version.sh.in
+++ b/test/testcheck_version.sh.in
@@ -27,6 +27,7 @@ Static_exec=@STATIC_EXEC@
CMP='cmp -s'
DIFF='diff -c'
+RM='rm -f'
# Function definitions
#
@@ -116,9 +117,9 @@ TESTING() {
TEST_NAME=tcheck_version # The test name
TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary
- expect=expected_out
- actual=actual_out
- actual_err=actual_err_out
+ expect=${TEST_NAME}_expect.out
+ actual=${TEST_NAME}_actual.out
+ actual_err=${TEST_NAME}_actual.err
arguments=
h5DisableVersion="$1"
@@ -136,7 +137,7 @@ TESTING() {
if [ "$wrongversionnumbers" = none ]; then
# OK: No warning, exit 0
cp /dev/null $expect
- expected_code=0
+ expect_code=0
else
arguments=-t"$wrongversionnumbers"
# calculate mismatched version numbers by listing.
@@ -152,16 +153,16 @@ TESTING() {
1)
# W2/OK: Different Warning, exit 0.
WarnMesg2 > $expect
- expected_code=0
+ expect_code=0
;;
[2-9]|[1-9][0-9]*)
# OK: No warning, exit 0
cp /dev/null $expect
- expected_code=0
+ expect_code=0
;;
*) # W/A: Warning, abort and exit non-0.
WarnMesg > $expect
- expected_code=134 # Signal Abort exit code (128+6)
+ expect_code=6 # Signal Abort exit code (128+6)
;;
esac
fi
@@ -174,9 +175,9 @@ TESTING() {
ret_code=$?
cat $actual_err >> $actual
- if [ \( $expected_code -ne $ret_code \) ]; then
+ if [ \( $expect_code -ne $ret_code \) ]; then
echo "*FAILED*"
- echo " Expected exit code ($expected_code) differs from actual code ($ret_code)"
+ echo " Expected exit code ($expect_code) differs from actual code ($ret_code)"
nerrors="`expr $nerrors + 1`"
elif $CMP $expect $actual; then
echo " PASSED"
@@ -187,9 +188,11 @@ TESTING() {
test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
fi
- # Clean up output file
+ # Clean up output file.
+ # Also clean the core file generated by H5check_version's abort.
if test -z "$HDF5_NOCLEANUP"; then
- rm -f $expected_out $actual_out $actual_err
+ $RM $expect $actual $actual_err
+ $RM core
fi
}
@@ -221,7 +224,15 @@ 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).
diff --git a/test/tfile.c b/test/tfile.c
index 7755e7b..d1cb25d 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -98,6 +98,35 @@
#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
@@ -2504,6 +2533,534 @@ test_userblock_alignment(void)
/****************************************************************
**
+** 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_swmr_write(): low-level file test routine.
** This test checks that the H5F_ACC_SWMR_WRITE access flag is
** working properly.
@@ -2700,6 +3257,147 @@ test_swmr_read(void)
/****************************************************************
**
+** 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.
**
****************************************************************/
@@ -2733,8 +3431,14 @@ test_file(void)
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 */
test_swmr_write(); /* Tests for SWMR write access flag */
test_swmr_read(); /* Tests for SWMR read access flag */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ test_deprec(); /* Test deprecated routines */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
} /* test_file() */
@@ -2760,5 +3464,6 @@ cleanup_file(void)
HDremove(FILE2);
HDremove(FILE3);
HDremove(FILE4);
+ HDremove(FILE5);
}
diff --git a/test/tgenprop.c b/test/tgenprop.c
index f87d4ec..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() */
/****************************************************************
@@ -895,6 +989,25 @@ 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);
+}
+
+/****************************************************************
+**
** test_genprop_prop_crt_cb1(): Property creation callback for test_genprop_list_callback
**
****************************************************************/
@@ -1063,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) */
@@ -1365,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) */
@@ -1377,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/tmisc.c b/test/tmisc.c
index b646a69..450743c 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -305,6 +305,11 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#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
@@ -1797,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 */
@@ -1815,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);
@@ -1856,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, (hsize_t)0);
+ CHECK(ret, FAIL, "H5Pset_file_space");
+
/* Creating a file with the non-default file creation property list should
* create a version 1 superblock
*/
@@ -1868,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);
@@ -1892,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);
@@ -1927,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");
@@ -5118,6 +5111,39 @@ test_misc28(void)
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.
@@ -5161,7 +5187,7 @@ test_misc(void)
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() */
@@ -5216,5 +5242,6 @@ cleanup_misc(void)
HDremove(MISC25C_FILE);
HDremove(MISC26_FILE);
HDremove(MISC28_FILE);
+ HDremove(MISC29_COPY_FILE);
}
diff --git a/test/tunicode.c b/test/tunicode.c
index 767928e..efbf80e 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");
diff --git a/test/vfd.c b/test/vfd.c
index c1de28d..f5a29c5 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -28,7 +28,6 @@
#define FAMILY_SIZE2 (5*KB)
#define MULTI_SIZE 128
#define CORE_INCREMENT (4*KB)
-#define FILE_COPY_BUF_SIZE 4096
/*Macros for Direct VFD*/
#define MBOUNDARY 512
@@ -809,11 +808,7 @@ test_family_compat(void)
char filename[1024];
char pathname[1024], pathname_individual[1024];
char newname[1024], newname_individual[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */
- void *copy_buf; /* Pointer to buffer for copying data */
- size_t written; /* Amount of data written to new file */
- size_t read_in; /* Amount of data read in from old file */
int counter = 0;
TESTING("FAMILY file driver backward compatibility");
@@ -828,45 +823,24 @@ test_family_compat(void)
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);
/* 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.
*/
- if(NULL == (copy_buf = HDmalloc((size_t)FILE_COPY_BUF_SIZE))) TEST_ERROR
-
sprintf(newname_individual, newname, counter);
sprintf(pathname_individual, pathname, counter);
- /* Open the original files until no more left. Copy the content into the new files. */
- while((old_fp = HDfopen(pathname_individual,"rb"))) {
- /* Open the new file */
- if(NULL == (tmp_fp = fopen(newname_individual,"wb"))) TEST_ERROR
-
- /* Copy data from the old file to the new file */
- while((read_in = HDfread(copy_buf, (size_t)1, (size_t)FILE_COPY_BUF_SIZE, old_fp)) > 0)
- /* Write the data to the new file */
- if(read_in != (written = HDfwrite(copy_buf, (size_t)1, read_in, tmp_fp))) TEST_ERROR
-
- /* Close the old file */
- if(HDfclose(old_fp)) TEST_ERROR
-
- /* Close the new file */
- if(HDfclose(tmp_fp)) TEST_ERROR
-
+ while (h5_make_local_copy(pathname_individual, newname_individual) >= 0) {
counter++;
sprintf(newname_individual, newname, counter);
sprintf(pathname_individual, pathname, counter);
}
- /* Free the copy buffer */
- free(copy_buf);
+ if ((NULL != (old_fp = HDfopen(pathname_individual,"rb"))) &&
+ (NULL != (tmp_fp = HDfopen(newname_individual,"wb"))))
+ TEST_ERROR;
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */