summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-02-24 13:45:02 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-02-24 13:45:02 (GMT)
commitb2d288804d3f17e824383436d038976c159d0eda (patch)
treec8d45d3cb55a2bf2cdbf9587157c4bcda8697706 /test
parent89629922985edbd558ddf036fbfbbaf29876668a (diff)
downloadhdf5-b2d288804d3f17e824383436d038976c159d0eda.zip
hdf5-b2d288804d3f17e824383436d038976c159d0eda.tar.gz
hdf5-b2d288804d3f17e824383436d038976c159d0eda.tar.bz2
[svn-r11965] Purpose:
Maintenance Description: Remove half-built (half-baked? :-) implementation of B+tree, block tracker and segmented heaps. (In preparation for starting the new heap coding) Platforms tested: FreeBSD 4.11 (sleipnir) Linux 2.4 (heping)
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in82
-rw-r--r--test/b+tree.c210
-rw-r--r--test/blocktrack.c1949
-rw-r--r--test/sheap.c275
5 files changed, 30 insertions, 2490 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 0b1f7f2..8e22514 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -32,7 +32,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
# executed, generally most specific tests to least specific tests.
# As an exception, long-running tests should occur earlier in the list.
# This gives them more time to run when tests are executing in parallel.
-TEST_PROG=testhdf5 lheap ohdr stab gheap btree2 cache cache_api b+tree blocktrack sheap \
+TEST_PROG=testhdf5 lheap ohdr stab gheap btree2 cache cache_api \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
@@ -107,7 +107,7 @@ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5
family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \
new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \
dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \
- unlink_chunked.h5 btree2.h5 blocktrack.h5 sheap.h5 b+tree.h5 \
+ unlink_chunked.h5 btree2.h5 \
objcopy_src.h5 objcopy_dst.h5 objcopy_ext.dat
# Sources for testhdf5 executable
diff --git a/test/Makefile.in b/test/Makefile.in
index f8dac31..2be16e9 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -31,7 +31,7 @@
#
-SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c blocktrack.c btree2.c cache.c cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c sheap.c space_overflow.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
+SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -75,8 +75,7 @@ am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo
libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS)
am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
stab$(EXEEXT) gheap$(EXEEXT) btree2$(EXEEXT) cache$(EXEEXT) \
- cache_api$(EXEEXT) b+tree$(EXEEXT) blocktrack$(EXEEXT) \
- sheap$(EXEEXT) pool$(EXEEXT) hyperslab$(EXEEXT) \
+ cache_api$(EXEEXT) pool$(EXEEXT) hyperslab$(EXEEXT) \
istore$(EXEEXT) bittests$(EXEEXT) dt_arith$(EXEEXT) \
dtypes$(EXEEXT) dsets$(EXEEXT) cmpd_dset$(EXEEXT) \
extend$(EXEEXT) external$(EXEEXT) objcopy$(EXEEXT) \
@@ -97,23 +96,15 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
@BUILD_ALL_CONDITIONAL_TRUE@ gen_nullspace$(EXEEXT) \
@BUILD_ALL_CONDITIONAL_TRUE@ space_overflow$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
-b_tree_SOURCES = b+tree.c
-b_tree_OBJECTS = b+tree.$(OBJEXT)
-b_tree_LDADD = $(LDADD)
-am__DEPENDENCIES_1 = $(top_builddir)/src/libhdf5.la
-b_tree_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
big_SOURCES = big.c
big_OBJECTS = big.$(OBJEXT)
big_LDADD = $(LDADD)
+am__DEPENDENCIES_1 = $(top_builddir)/src/libhdf5.la
big_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
bittests_SOURCES = bittests.c
bittests_OBJECTS = bittests.$(OBJEXT)
bittests_LDADD = $(LDADD)
bittests_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
-blocktrack_SOURCES = blocktrack.c
-blocktrack_OBJECTS = blocktrack.$(OBJEXT)
-blocktrack_LDADD = $(LDADD)
-blocktrack_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
btree2_SOURCES = btree2.c
btree2_OBJECTS = btree2.$(OBJEXT)
btree2_LDADD = $(LDADD)
@@ -274,10 +265,6 @@ set_extent_SOURCES = set_extent.c
set_extent_OBJECTS = set_extent.$(OBJEXT)
set_extent_LDADD = $(LDADD)
set_extent_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
-sheap_SOURCES = sheap.c
-sheap_OBJECTS = sheap.$(OBJEXT)
-sheap_LDADD = $(LDADD)
-sheap_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
space_overflow_SOURCES = space_overflow.c
space_overflow_OBJECTS = space_overflow.$(OBJEXT)
space_overflow_LDADD = $(LDADD)
@@ -330,28 +317,28 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c \
- blocktrack.c btree2.c cache.c cache_api.c cmpd_dset.c dangle.c \
- dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \
- error_test.c extend.c external.c fillval.c flush1.c flush2.c \
- gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c \
- gen_new_group.c gen_new_mtime.c gen_new_super.c \
- gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c \
- istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \
- ohdr.c pool.c reserved.c set_extent.c sheap.c space_overflow.c \
- stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c \
- $(ttsafe_SOURCES) unlink.c vfd.c
-DIST_SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c \
- blocktrack.c btree2.c cache.c cache_api.c cmpd_dset.c dangle.c \
- dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \
- error_test.c extend.c external.c fillval.c flush1.c flush2.c \
- gen_deflate.c gen_filters.c gen_new_array.c gen_new_fill.c \
- gen_new_group.c gen_new_mtime.c gen_new_super.c \
- gen_noencoder.c gen_nullspace.c getname.c gheap.c hyperslab.c \
- istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \
- ohdr.c pool.c reserved.c set_extent.c sheap.c space_overflow.c \
- stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c \
- $(ttsafe_SOURCES) unlink.c vfd.c
+SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \
+ cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c \
+ dtransform.c dtypes.c enum.c err_compat.c error_test.c \
+ extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c \
+ gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \
+ gen_new_mtime.c gen_new_super.c gen_noencoder.c \
+ gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c \
+ links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
+ reserved.c set_extent.c space_overflow.c stab.c stream_test.c \
+ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
+ vfd.c
+DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \
+ cache.c cache_api.c cmpd_dset.c dangle.c dsets.c dt_arith.c \
+ dtransform.c dtypes.c enum.c err_compat.c error_test.c \
+ extend.c external.c fillval.c flush1.c flush2.c gen_deflate.c \
+ gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \
+ gen_new_mtime.c gen_new_super.c gen_noencoder.c \
+ gen_nullspace.c getname.c gheap.c hyperslab.c istore.c lheap.c \
+ links.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
+ reserved.c set_extent.c space_overflow.c stab.c stream_test.c \
+ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
+ vfd.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -612,9 +599,8 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \
family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \
new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \
err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \
- tstint[1-2].h5 unlink_chunked.h5 btree2.h5 blocktrack.h5 \
- sheap.h5 b+tree.h5 objcopy_src.h5 objcopy_dst.h5 \
- objcopy_ext.dat
+ tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \
+ objcopy_dst.h5 objcopy_ext.dat
INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
@@ -626,7 +612,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
# executed, generally most specific tests to least specific tests.
# As an exception, long-running tests should occur earlier in the list.
# This gives them more time to run when tests are executing in parallel.
-TEST_PROG = testhdf5 lheap ohdr stab gheap btree2 cache cache_api b+tree blocktrack sheap \
+TEST_PROG = testhdf5 lheap ohdr stab gheap btree2 cache cache_api \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
@@ -739,18 +725,12 @@ clean-noinstPROGRAMS:
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
-b+tree$(EXEEXT): $(b_tree_OBJECTS) $(b_tree_DEPENDENCIES)
- @rm -f b+tree$(EXEEXT)
- $(LINK) $(b_tree_LDFLAGS) $(b_tree_OBJECTS) $(b_tree_LDADD) $(LIBS)
big$(EXEEXT): $(big_OBJECTS) $(big_DEPENDENCIES)
@rm -f big$(EXEEXT)
$(LINK) $(big_LDFLAGS) $(big_OBJECTS) $(big_LDADD) $(LIBS)
bittests$(EXEEXT): $(bittests_OBJECTS) $(bittests_DEPENDENCIES)
@rm -f bittests$(EXEEXT)
$(LINK) $(bittests_LDFLAGS) $(bittests_OBJECTS) $(bittests_LDADD) $(LIBS)
-blocktrack$(EXEEXT): $(blocktrack_OBJECTS) $(blocktrack_DEPENDENCIES)
- @rm -f blocktrack$(EXEEXT)
- $(LINK) $(blocktrack_LDFLAGS) $(blocktrack_OBJECTS) $(blocktrack_LDADD) $(LIBS)
btree2$(EXEEXT): $(btree2_OBJECTS) $(btree2_DEPENDENCIES)
@rm -f btree2$(EXEEXT)
$(LINK) $(btree2_LDFLAGS) $(btree2_OBJECTS) $(btree2_LDADD) $(LIBS)
@@ -871,9 +851,6 @@ reserved$(EXEEXT): $(reserved_OBJECTS) $(reserved_DEPENDENCIES)
set_extent$(EXEEXT): $(set_extent_OBJECTS) $(set_extent_DEPENDENCIES)
@rm -f set_extent$(EXEEXT)
$(LINK) $(set_extent_LDFLAGS) $(set_extent_OBJECTS) $(set_extent_LDADD) $(LIBS)
-sheap$(EXEEXT): $(sheap_OBJECTS) $(sheap_DEPENDENCIES)
- @rm -f sheap$(EXEEXT)
- $(LINK) $(sheap_LDFLAGS) $(sheap_OBJECTS) $(sheap_LDADD) $(LIBS)
space_overflow$(EXEEXT): $(space_overflow_OBJECTS) $(space_overflow_DEPENDENCIES)
@rm -f space_overflow$(EXEEXT)
$(LINK) $(space_overflow_LDFLAGS) $(space_overflow_OBJECTS) $(space_overflow_LDADD) $(LIBS)
@@ -905,10 +882,8 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/b+tree.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/big.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bittests.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blocktrack.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btree2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache_api.Po@am__quote@
@@ -951,7 +926,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reserved.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_extent.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/space_overflow.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_test.Po@am__quote@
diff --git a/test/b+tree.c b/test/b+tree.c
deleted file mode 100644
index b29c192..0000000
--- a/test/b+tree.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
- * Tuesday, April 19, 2005
- */
-#include "h5test.h"
-
-/*
- * This file needs to access private datatypes from the H5BP package.
- * This file also needs to access the B+ tree testing code.
- */
-#define H5BP_PACKAGE
-#define H5BP_TESTING
-#include "H5BPpkg.h"
-
-/* Other private headers that this test requires */
-#include "H5Iprivate.h"
-
-const char *FILENAME[] = {
- "b+tree",
- NULL
-};
-
-#define NODE_SIZE 512
-
-
-/*-------------------------------------------------------------------------
- * Function: test_create
- *
- * Purpose: Basic tests for the B+ tree code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Tuesday, April 19, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_create(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bpt_addr; /* Address of B+ tree created */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file)))
- STACK_ERROR
-
- /*
- * Test B+ tree creation
- */
- TESTING("B+ tree creation");
- if (H5BP_create(f, H5P_DATASET_XFER_DEFAULT, H5BP_TEST, NODE_SIZE, 100, 40, &bpt_addr/*out*/)<0)
- FAIL_STACK_ERROR
-
- PASSED();
-
- if (H5Fclose(file)<0)
- STACK_ERROR
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_create() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_insert_basic
- *
- * Purpose: Basic tests for the B+ tree code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Tuesday, April 19, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-#ifdef QAK
-static int
-test_insert_basic(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- char *record; /* Record to insert into tree */
- haddr_t bpt_addr; /* Address of B+ tree created */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
- STACK_ERROR
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file)))
- STACK_ERROR
-
- /* Create B+ tree */
- if (H5BP_create(f, H5P_DATASET_XFER_DEFAULT, H5BP_TEST, NODE_SIZE, 100, 40, &bpt_addr/*out*/)<0)
- FAIL_STACK_ERROR
-
- /*
- * Test B+ tree creation
- */
- TESTING("B+ tree single record insert");
- record="Foo!";
- if (H5BP_insert(f, H5P_DATASET_XFER_DEFAULT, H5BP_TEST, bpt_addr, &record)<0)
- FAIL_STACK_ERROR
-
- PASSED();
-
- if (H5Fclose(file)<0)
- STACK_ERROR
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_insert_basic() */
-#endif /* QAK */
-
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Test the B+ tree code
- *
- * Return: Success:
- *
- * Failure:
- *
- * Programmer: Quincey Koziol
- * Tuesday, April 19, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-main(void)
-{
- hid_t fapl=-1;
- int nerrors=0;
-
- /* Reset library */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Test B+ tree creation */
- nerrors += test_create(fapl);
-
- /* Test B+ tree record insertion */
- /* Iteration, find & index routines tested in these routines as well */
-#ifdef QAK
- nerrors += test_insert_basic(fapl);
-#endif /* QAK */
-
- if (nerrors) goto error;
- puts("All B+ tree tests passed.");
-#ifndef QAK
- h5_cleanup(FILENAME, fapl);
-#else /* QAK */
-HDfprintf(stderr,"Uncomment cleanup!\n");
-#endif /* QAK */
- return 0;
-
-error:
- puts("*** TESTS FAILED ***");
- H5E_BEGIN_TRY {
- H5Pclose(fapl);
- } H5E_END_TRY;
- return 1;
-}
-
diff --git a/test/blocktrack.c b/test/blocktrack.c
deleted file mode 100644
index 28d9c28..0000000
--- a/test/blocktrack.c
+++ /dev/null
@@ -1,1949 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
- * Wednesday, March 9, 2005
- */
-#include "h5test.h"
-
-/*
- * This file needs to access private datatypes from the H5BT package.
- * This file also needs to access the block tracker testing code.
- */
-#define H5BT_PACKAGE
-#define H5BT_TESTING
-#include "H5BTpkg.h"
-
-/* Other private headers that this test requires */
-#include "H5Iprivate.h"
-
-const char *FILENAME[] = {
- "blocktrack",
- NULL
-};
-
-#define INSERT_MANY 100
-
-
-/*-------------------------------------------------------------------------
- * Function: iter_cb
- *
- * Purpose: Block tracker iterator callback
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, March 25, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-iter_cb(const H5BT_blk_info_t *record, void *_op_data)
-{
- haddr_t *addr = (haddr_t *)_op_data;
-
- if(record->addr != *addr)
- return(H5B2_ITER_ERROR);
-
- *addr *= 2;
- return(H5B2_ITER_CONT);
-} /* end iter_cb() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_create
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Wednesday, March 9, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_create(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- /*
- * Test block tracker creation
- */
- TESTING("block tracker creation");
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 0) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 0) TEST_ERROR;
- if(max_count != 0) TEST_ERROR;
- if(max_valid != 0) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(min_size != HSIZET_MAX) TEST_ERROR;
- if(min_count != 0) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_create() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_insert_one
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 10, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_insert_one(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- /*
- * Test inserting one block
- */
- TESTING("insert 1 block");
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)10, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 20) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 20) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(min_size != 20) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_insert_one() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_insert_few
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 10, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_insert_few(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- /*
- * Test inserting one block
- */
- TESTING("insert several blocks");
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)10, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 20) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 20) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 20) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)50, (hsize_t)30)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 50) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 20) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)90, (hsize_t)30)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 80) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 20) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)130, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 100) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 20) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)160, (hsize_t)10)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 110) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 10) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_insert_one() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_insert_many
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 10, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_insert_many(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- unsigned u; /* Local index variable */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Test inserting many, non-overlapping, non-mergeable blocks
- */
- TESTING("insert many blocks");
- for(u = 0; u < INSERT_MANY; u++) {
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)(u*50), (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != ((u+1)*20)) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 20) TEST_ERROR;
- if(max_count != (u+1)) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 20) TEST_ERROR;
- if(min_count != (u+1)) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- } /* end for */
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_insert_many() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_insert_overlap
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 10, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_insert_overlap(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- herr_t ret; /* Generic 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) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert first block */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)10, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Test inserting overlapping blocks
- */
- TESTING("insert overlapping blocks");
-
- /* Insert same block again (should fail) */
- H5E_BEGIN_TRY {
- ret = H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)10, (hsize_t)20);
- } H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR;
-
- /* Insert block of different size at same address (should fail) */
- H5E_BEGIN_TRY {
- ret = H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)10, (hsize_t)10);
- } H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR;
-
- /* Insert block which overlaps beginning of existing block (should fail) */
- H5E_BEGIN_TRY {
- ret = H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)5, (hsize_t)10);
- } H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR;
-
- /* Insert block which overlaps end of existing block (should fail) */
- H5E_BEGIN_TRY {
- ret = H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)25, (hsize_t)10);
- } H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR;
-
- /* Insert block which includes existing block (should fail) */
- H5E_BEGIN_TRY {
- ret = H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)5, (hsize_t)30);
- } H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR;
-
- /* Insert block which is inside existing block (should fail) */
- H5E_BEGIN_TRY {
- ret = H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)15, (hsize_t)10);
- } H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_insert_overlap() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_insert_merge
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 10, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_insert_merge(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert first block */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)10, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Test inserting blocks which should merge into existing block(s)
- */
- TESTING("insert block which merges with existing upper block");
-
- /* Insert block which should merge with beginning of existing block */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)8, (hsize_t)2)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 22) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 22) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 22) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- PASSED();
-
- /*
- * Test inserting blocks which should merge into existing block(s)
- */
- TESTING("insert block which merges with existing lower block");
-
- /* Insert block which should merge with end of existing block */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)30, (hsize_t)4)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 26) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 26) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 26) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- PASSED();
-
- /*
- * Test inserting blocks which should merge into existing block(s)
- */
- TESTING("insert block which merges with existing upper & lower blocks");
-
- /* Insert block to merge with */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)40, (hsize_t)10) < 0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert block which should merge with end of existing block */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)34, (hsize_t)6) < 0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 42) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 42) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 42) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_insert_merge() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_remove_whole
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, March 11, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_remove_whole(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert several blocks */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)50, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)100, (hsize_t)15)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)150, (hsize_t)15)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)200, (hsize_t)35)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)250, (hsize_t)35)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Test removing blocks
- */
- TESTING("remove entire block, in middle of block size range");
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)50, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 100) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 35) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 15) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- PASSED();
-
- TESTING("remove entire block, at bottom of block size range");
-
- /* Remove first block at min. size */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)100, (hsize_t)15)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 85) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 35) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 15) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- /* Remove last block at min. size */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)150, (hsize_t)15)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 70) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 35) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 35) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- PASSED();
-
- TESTING("remove entire block, at top of block size range");
-
- /* Remove first block at max. size */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)200, (hsize_t)35)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 35) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 35) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 35) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- /* Remove last block at max. size */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)250, (hsize_t)35)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 0) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 0) TEST_ERROR;
- if(max_count != 0) TEST_ERROR;
- if(max_valid != 0) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != HSIZET_MAX) TEST_ERROR;
- if(min_count != 0) TEST_ERROR;
- if(min_valid != 0) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_remove_whole() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_remove_partial_begin
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, March 11, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_remove_partial_begin(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- hsize_t tot_size; /* Total size of blocks tracked */
- hsize_t max_size; /* Max. size of blocks tracked */
- uint32_t max_count; /* Ref. count of max. size of blocks tracked */
- hbool_t max_valid; /* Is max. size valid over all blocks? */
- hsize_t min_size; /* Min. size of blocks tracked */
- uint32_t min_count; /* Ref. count of min. size of blocks tracked */
- hbool_t min_valid; /* Is min. size valid over all blocks? */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert several blocks */
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)50, (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)100, (hsize_t)15)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)150, (hsize_t)15)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)200, (hsize_t)35)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)250, (hsize_t)35)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Test removing blocks
- */
- TESTING("remove partial block, at beginning of existing block");
-
-/* Remove piece from block in middle of size range */
- /* Remove partial block */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)50, (hsize_t)3)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 117) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 35) TEST_ERROR;
- if(max_count != 2) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 15) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
-/* Remove piece from blocks at max. of size range */
- /* Remove partial block */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)200, (hsize_t)5)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 112) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 35) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 1) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 15) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- /* Remove partial block */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)250, (hsize_t)5)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 107) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 0) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 15) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
-/* Remove piece from blocks at min. of size range */
- /* Remove partial block */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)100, (hsize_t)5)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 102) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 0) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 10) TEST_ERROR;
- if(min_count != 1) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- /* Remove partial block */
- if (H5BT_remove(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)150, (hsize_t)5)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5BT_get_total_size(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &tot_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the size is correct */
- if(tot_size != 97) TEST_ERROR;
-
- if (H5BT_get_max_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &max_size, &max_count, &max_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the max. info is correct */
- if(max_size != 30) TEST_ERROR;
- if(max_count != 1) TEST_ERROR;
- if(max_valid != 0) TEST_ERROR;
-
- if (H5BT_get_min_info(f, H5P_DATASET_XFER_DEFAULT, bt_addr, &min_size, &min_count, &min_valid)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- /* Make certain that the min. info is correct */
- if(min_size != 10) TEST_ERROR;
- if(min_count != 2) TEST_ERROR;
- if(min_valid != 1) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_remove_partial_begin() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_locate
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 24, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_locate(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- haddr_t block_addr; /* Address of block to insert */
- hsize_t block_size; /* Size of block to insert */
- hsize_t search_size; /* Size of block to search for */
- 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) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert blocks */
- block_addr = 2048;
- block_size = 8;
- for(u = 0; u < 10; u++) {
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, block_addr, block_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Increment block address & size for next insertion */
- block_addr *= 2;
- block_size *= 2;
- } /* end for */
-
- TESTING("attempt to locate too large of a block");
-
- search_size = block_size * 2;
- block_addr = HADDR_UNDEF;
- if (H5BT_locate(f, H5P_DATASET_XFER_DEFAULT, bt_addr, search_size, &block_addr, &block_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- if(H5F_addr_defined(block_addr)) TEST_ERROR;
-
- PASSED();
-
- TESTING("locate blocks");
-
- search_size = 8;
- if (H5BT_locate(f, H5P_DATASET_XFER_DEFAULT, bt_addr, search_size, &block_addr, &block_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- if(block_addr != 2048) TEST_ERROR;
- if(block_size != 8) TEST_ERROR;
-
- search_size = 10;
- if (H5BT_locate(f, H5P_DATASET_XFER_DEFAULT, bt_addr, search_size, &block_addr, &block_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- if(block_addr != 4096) TEST_ERROR;
- if(block_size != 16) TEST_ERROR;
-
- search_size = 100;
- if (H5BT_locate(f, H5P_DATASET_XFER_DEFAULT, bt_addr, search_size, &block_addr, &block_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- if(block_addr != 32768) TEST_ERROR;
- if(block_size != 128) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_locate() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_neighbor
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Monday, March 28, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_neighbor(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- H5BT_blk_info_t block; /* Block located */
- haddr_t search_addr; /* Address of block to search for neighbor of */
- 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) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert blocks */
- block.addr = 2048;
- block.len = 8;
- for(u = 0; u < 10; u++) {
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, block.addr, block.len)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Increment block address & size for next insertion */
- block.addr *= 2;
- block.len *= 2;
- } /* end for */
-
- TESTING("attempt to find neighbor of a block");
-
- search_addr = 4097;
- if (H5BT_neighbor(f, H5P_DATASET_XFER_DEFAULT, bt_addr, H5BT_COMPARE_LESS, search_addr, &block)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- if(block.addr != 4096) TEST_ERROR;
- if(block.len != 16) TEST_ERROR;
-
- search_addr = 4096;
- if (H5BT_neighbor(f, H5P_DATASET_XFER_DEFAULT, bt_addr, H5BT_COMPARE_LESS, search_addr, &block)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- if(block.addr != 2048) TEST_ERROR;
- if(block.len != 8) TEST_ERROR;
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_locate() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_iterate
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Friday, March 25, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_iterate(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t bt_addr; /* Address of block tracker created */
- haddr_t block_addr; /* Address of block to insert */
- hsize_t block_size; /* Size of block to insert */
- 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) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert blocks */
- block_addr = 2048;
- block_size = 8;
- for(u = 0; u < 10; u++) {
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, block_addr, block_size)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Increment block address & size for next insertion */
- block_addr *= 2;
- block_size *= 2;
- } /* end for */
-
- TESTING("iterating over blocks");
-
- block_addr = 2048;
- if (H5BT_iterate(f, H5P_DATASET_XFER_DEFAULT, bt_addr, iter_cb, &block_addr)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_iterate() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_delete
- *
- * Purpose: Basic tests for the block tracker code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Monday, March 14, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_delete(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- off_t empty_size; /* Size of an empty file */
- off_t file_size; /* Size of each file created */
- haddr_t bt_addr; /* Address of block tracker created */
- unsigned u; /* Local index variable */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
-/* Create empty file for size comparisons later */
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Close file */
- if(H5Fclose(file)<0) TEST_ERROR;
-
- /* Get the size of an empty file */
- if((empty_size=h5_get_file_size(filename))==0) TEST_ERROR;
-
- TESTING("delete empty block tracker");
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Delete block tracker
- */
- if (H5BT_delete(f, H5P_DATASET_XFER_DEFAULT, bt_addr)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- /* Get the size of the file */
- if((file_size=h5_get_file_size(filename))==0) TEST_ERROR;
-
- /* Verify the file is correct size */
- if(file_size!=empty_size) TEST_ERROR;
-
- PASSED();
-
- TESTING("delete block tracker with many blocks");
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /* Insert many blocks */
- for(u = 0; u < INSERT_MANY; u++) {
- if (H5BT_insert(f, H5P_DATASET_XFER_DEFAULT, bt_addr, (haddr_t)(u*50), (hsize_t)20)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
- } /* end for */
-
- /*
- * Delete block tracker
- */
- if (H5BT_delete(f, H5P_DATASET_XFER_DEFAULT, bt_addr)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- /* Get the size of the file */
- if((file_size=h5_get_file_size(filename))==0) TEST_ERROR;
-
- /* Verify the file is correct size */
- if(file_size!=empty_size) TEST_ERROR;
-
- PASSED();
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_delete() */
-
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Test the block tracker code
- *
- * Return: Success:
- *
- * Failure:
- *
- * Programmer: Quincey Koziol
- * Wednesday, March 9, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-main(void)
-{
- hid_t fapl=-1;
- int nerrors=0;
-
- /* Reset library */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Test block tracker creation */
- nerrors += test_create(fapl);
-
- /* Test block tracker insertion */
- nerrors += test_insert_one(fapl);
- nerrors += test_insert_few(fapl);
- nerrors += test_insert_many(fapl);
- nerrors += test_insert_overlap(fapl);
- nerrors += test_insert_merge(fapl);
-
- /* Test block tracker removal */
- nerrors += test_remove_whole(fapl);
- nerrors += test_remove_partial_begin(fapl);
-
- /* Test block tracker search functions */
- nerrors += test_locate(fapl);
- nerrors += test_neighbor(fapl);
-
- /* Test block tracker iterate */
- nerrors += test_iterate(fapl);
-
- /* Test block tracker deletion */
- nerrors += test_delete(fapl);
-
- if (nerrors) goto error;
- puts("All block tracker tests passed.");
-#ifndef QAK
- h5_cleanup(FILENAME, fapl);
-#else /* QAK */
-HDfprintf(stderr,"Uncomment cleanup!\n");
-#endif /* QAK */
- return 0;
-
-error:
- puts("*** TESTS FAILED ***");
- H5E_BEGIN_TRY {
- H5Pclose(fapl);
- } H5E_END_TRY;
- return 1;
-}
-
diff --git a/test/sheap.c b/test/sheap.c
deleted file mode 100644
index 9b3362c..0000000
--- a/test/sheap.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
- * Wednesday, March 23, 2005
- */
-#include "h5test.h"
-
-/*
- * This file needs to access private datatypes from the H5SH package.
- * This file also needs to access the segmented heap testing code.
- */
-#define H5SH_PACKAGE
-#define H5SH_TESTING
-#include "H5SHpkg.h"
-
-/* Other private headers that this test requires */
-#include "H5Iprivate.h"
-
-const char *FILENAME[] = {
- "sheap",
- NULL
-};
-
-#define SHEAP_TYPE H5SH_META
-#define SHEAP_MIN_SIZE 4096
-#define SHEAP_MAX_EXPAND_SIZE 65536
-
-
-/*-------------------------------------------------------------------------
- * Function: test_create
- *
- * Purpose: Basic tests for the segmented heap code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Wednesday, March 23, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_create(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t sh_addr; /* Address of block tracker created */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- /*
- * Test segmented heap creation
- */
- TESTING("segmented heap creation");
- if (H5SH_create(f, H5P_DATASET_XFER_DEFAULT, &sh_addr/*out*/, SHEAP_TYPE, (hsize_t)SHEAP_MIN_SIZE, (hsize_t)SHEAP_MAX_EXPAND_SIZE)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_create() */
-
-
-/*-------------------------------------------------------------------------
- * Function: test_allocate_simple
- *
- * Purpose: Basic tests for the segmented heap code
- *
- * Return: Success: 0
- *
- * Failure: 1
- *
- * Programmer: Quincey Koziol
- * Thursday, March 24, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_allocate_simple(hid_t fapl)
-{
- hid_t file=-1;
- char filename[1024];
- H5F_t *f=NULL;
- haddr_t sh_addr; /* Address of block tracker created */
- haddr_t obj_addr; /* Address for object */
- hsize_t obj_len; /* Length of object */
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
-
- /* Create the file to work on */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
-
- /* Get a pointer to the internal file object */
- if (NULL==(f=H5I_object(file))) {
- H5Eprint_stack(H5E_DEFAULT, stdout);
- TEST_ERROR;
- } /* end if */
-
- /* Create segmented heap */
- if (H5SH_create(f, H5P_DATASET_XFER_DEFAULT, &sh_addr/*out*/, SHEAP_TYPE, (hsize_t)SHEAP_MIN_SIZE, (hsize_t)SHEAP_MAX_EXPAND_SIZE)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-
- /*
- * Test segmented heap allocation
- */
- TESTING("segmented heap allocate first block");
-
- /* Allocate space for a simple object */
- obj_len = 10;
- if (H5SH_alloc(f, H5P_DATASET_XFER_DEFAULT, sh_addr, obj_len, &obj_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-#ifdef H5_HAVE_LARGE_HSIZET
- if(obj_addr != 530) TEST_ERROR;
-#else /* H5_HAVE_LARGE_HSIZET */
- if(obj_addr != 478) TEST_ERROR;
-#endif /* H5_HAVE_LARGE_HSIZET */
-
- PASSED();
-
- TESTING("segmented heap allocate into free space");
-
- /* Allocate space for a simple object */
- obj_len = 3800;
- if (H5SH_alloc(f, H5P_DATASET_XFER_DEFAULT, sh_addr, obj_len, &obj_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-#ifdef H5_HAVE_LARGE_HSIZET
- if(obj_addr != 540) TEST_ERROR;
-#else /* H5_HAVE_LARGE_HSIZET */
- if(obj_addr != 488) TEST_ERROR;
-#endif /* H5_HAVE_LARGE_HSIZET */
-
- PASSED();
-
- TESTING("segmented heap allocate another heap block");
-
- /* Allocate space for a simple object */
- obj_len = 512;
- if (H5SH_alloc(f, H5P_DATASET_XFER_DEFAULT, sh_addr, obj_len, &obj_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-#ifdef H5_HAVE_LARGE_HSIZET
- if(obj_addr != 5650) TEST_ERROR;
-#else /* H5_HAVE_LARGE_HSIZET */
- if(obj_addr != 5598) TEST_ERROR;
-#endif /* H5_HAVE_LARGE_HSIZET */
-
- PASSED();
-
- TESTING("segmented heap extend heap block");
-
- /* Allocate space for a simple object */
- obj_len = 4096;
- if (H5SH_alloc(f, H5P_DATASET_XFER_DEFAULT, sh_addr, obj_len, &obj_addr/*out*/)<0) {
- H5_FAILED();
- H5Eprint_stack(H5E_DEFAULT, stdout);
- goto error;
- } /* end if */
-#ifdef H5_HAVE_LARGE_HSIZET
- if(obj_addr != 6162) TEST_ERROR;
-#else /* H5_HAVE_LARGE_HSIZET */
- if(obj_addr != 6110) TEST_ERROR;
-#endif /* H5_HAVE_LARGE_HSIZET */
-
- PASSED();
-
- if (H5Fclose(file)<0) TEST_ERROR;
-
- return 0;
-
-error:
- H5E_BEGIN_TRY {
- H5Fclose(file);
- } H5E_END_TRY;
- return 1;
-} /* test_allocate_simple() */
-
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Test the segmented heap code
- *
- * Return: Success:
- *
- * Failure:
- *
- * Programmer: Quincey Koziol
- * Wednesday, March 23, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-main(void)
-{
- hid_t fapl=-1;
- int nerrors=0;
-
- /* Reset library */
- h5_reset();
- fapl = h5_fileaccess();
-
- /* Test segmented heap creation */
- nerrors += test_create(fapl);
-
- /* Test segmented heap allocation */
- nerrors += test_allocate_simple(fapl);
-
- if (nerrors) goto error;
- puts("All segmented heap tests passed.");
-#ifndef QAK
- h5_cleanup(FILENAME, fapl);
-#else /* QAK */
-HDfprintf(stderr,"Uncomment cleanup!\n");
-#endif /* QAK */
- return 0;
-
-error:
- puts("*** TESTS FAILED ***");
- H5E_BEGIN_TRY {
- H5Pclose(fapl);
- } H5E_END_TRY;
- return 1;
-}
-