summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST5
-rwxr-xr-xbin/trace3
-rwxr-xr-xconfigure3
-rw-r--r--configure.ac1
-rw-r--r--hl/test/Makefile.am8
-rw-r--r--hl/test/Makefile.in41
-rw-r--r--hl/test/ld_mx.c353
-rw-r--r--hl/test/test_ld.sh.in102
-rw-r--r--hl/test/testfiles/test_ld_out131
-rw-r--r--hl/test/testfiles/test_ld_out272
-rw-r--r--hl/tools/h5watch/h5watch.c7
-rw-r--r--src/H5Dint.c11
-rw-r--r--src/H5F.c149
-rw-r--r--src/H5Fint.c2
-rw-r--r--src/H5Fio.c7
-rw-r--r--src/H5Fpkg.h13
-rw-r--r--src/H5Fsuper.c18
-rw-r--r--src/H5Fsuper_cache.c24
-rw-r--r--src/H5Gint.c11
-rw-r--r--src/H5O.c8
-rw-r--r--src/H5Oflush.c129
-rw-r--r--src/H5Opkg.h2
-rw-r--r--src/H5Oprivate.h7
-rw-r--r--src/H5T.c13
-rw-r--r--test/Makefile.am2
-rw-r--r--test/Makefile.in26
-rw-r--r--test/cork.c2177
-rw-r--r--test/swmr_start_write.c156
-rw-r--r--test/test_swmr.c1907
-rw-r--r--test/tfile.c1280
-rw-r--r--test/th5o.c363
31 files changed, 4362 insertions, 2569 deletions
diff --git a/MANIFEST b/MANIFEST
index 49cef15..b68947b 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -967,6 +967,7 @@
./test/cache_common.h
./test/cache_tagging.c
./test/cmpd_dset.c
+./test/cork.c
./test/corrupt_stab_msg.h5
./test/cross_read.c
./test/dangle.c
@@ -2366,7 +2367,6 @@
./hl/test/image24pixel.txt
./hl/test/image24plane.txt
./hl/test/image8.txt
-./hl/test/ld_mx.c
./hl/test/Makefile.am
./hl/test/Makefile.in
./hl/test/pal_rgb.h
@@ -2377,12 +2377,9 @@
./hl/test/test_dset_opt.c
./hl/test/test_ds_le.h5
./hl/test/test_file_image.c
-./hl/test/testfiles/test_ld_out1
-./hl/test/testfiles/test_ld_out2
./hl/test/test_image.c
./hl/test/test_ld.c
./hl/test/test_ld.h5
-./hl/test/test_ld.sh.in
./hl/test/test_lite.c
./hl/test/test_packet.c
./hl/test/test_table_be.h5
diff --git a/bin/trace b/bin/trace
index da6673c..bf5ed21 100755
--- a/bin/trace
+++ b/bin/trace
@@ -100,6 +100,7 @@ $Source = "";
"H5A_operator2_t" => "x",
"H5A_info_t" => "x",
"H5AC_cache_config_t" => "x",
+ "H5D_append_cb_t" => "x",
"H5D_gather_func_t" => "x",
"H5D_operator_t" => "x",
"H5D_scatter_func_t" => "x",
@@ -109,8 +110,10 @@ $Source = "";
"H5E_walk_t" => "x",
"H5E_walk1_t" => "x",
"H5E_walk2_t" => "x",
+ "H5F_flush_cb_t" => "x",
"H5F_info1_t" => "x",
"H5F_info2_t" => "x",
+ "H5F_retry_info_t" => "x",
"H5FD_t" => "x",
"H5FD_class_t" => "x",
"H5FD_stream_fapl_t" => "x",
diff --git a/configure b/configure
index e2d3797..731312f 100755
--- a/configure
+++ b/configure
@@ -30091,7 +30091,7 @@ else
fi
-ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/testflushrefresh.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh test/testswmr.sh test/test_plugin.sh test/test_usecases.sh testpar/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumppbits.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5import/h5importtestutil.sh tools/h5diff/Makefile tools/h5diff/testh5diff.sh tools/h5diff/testph5diff.sh tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5repack/h5repack_plugin.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/h5copy/testh5copy.sh tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5clear.sh tools/misc/testh5mkgrp.sh tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile tools/perform/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/test/test_ld.sh hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh hl/tools/h5watch/Makefile hl/tools/h5watch/testh5watch.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh"
+ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/testflushrefresh.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh test/testswmr.sh test/test_plugin.sh test/test_usecases.sh testpar/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumppbits.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5import/h5importtestutil.sh tools/h5diff/Makefile tools/h5diff/testh5diff.sh tools/h5diff/testph5diff.sh tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5repack/h5repack_plugin.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/h5copy/testh5copy.sh tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5clear.sh tools/misc/testh5mkgrp.sh tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile tools/perform/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh hl/tools/h5watch/Makefile hl/tools/h5watch/testh5watch.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh"
cat >confcache <<\_ACEOF
@@ -31419,7 +31419,6 @@ do
"hl/src/Makefile") CONFIG_FILES="$CONFIG_FILES hl/src/Makefile" ;;
"hl/test/Makefile") CONFIG_FILES="$CONFIG_FILES hl/test/Makefile" ;;
"hl/test/H5srcdir_str.h") CONFIG_FILES="$CONFIG_FILES hl/test/H5srcdir_str.h" ;;
- "hl/test/test_ld.sh") CONFIG_FILES="$CONFIG_FILES hl/test/test_ld.sh" ;;
"hl/tools/Makefile") CONFIG_FILES="$CONFIG_FILES hl/tools/Makefile" ;;
"hl/tools/gif2h5/Makefile") CONFIG_FILES="$CONFIG_FILES hl/tools/gif2h5/Makefile" ;;
"hl/tools/gif2h5/h52giftest.sh") CONFIG_FILES="$CONFIG_FILES hl/tools/gif2h5/h52giftest.sh" ;;
diff --git a/configure.ac b/configure.ac
index be91848..08dfa93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2880,7 +2880,6 @@ AC_CONFIG_FILES([src/libhdf5.settings
hl/src/Makefile
hl/test/Makefile
hl/test/H5srcdir_str.h
- hl/test/test_ld.sh
hl/tools/Makefile
hl/tools/gif2h5/Makefile
hl/tools/gif2h5/h52giftest.sh
diff --git a/hl/test/Makefile.am b/hl/test/Makefile.am
index 7e6a8e9..324c4f9 100644
--- a/hl/test/Makefile.am
+++ b/hl/test/Makefile.am
@@ -23,11 +23,6 @@ include $(top_srcdir)/config/commence.am
# Add include directories to C preprocessor flags
AM_CPPFLAGS+=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_builddir)/test -I$(top_srcdir)/test -I$(top_srcdir)/hl/src
-# Test script
-TEST_SCRIPT = test_ld.sh
-check_SCRIPTS = $(TEST_SCRIPT)
-SCRIPT_DEPEND = ld_mx$(EXEEXT)
-
# The tests depend on the hdf5, hdf5 test, and hdf5_hl libraries
LDADD=$(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
@@ -35,7 +30,7 @@ LDADD=$(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
# order to be executed, generally most specific tests to least specific tests.
TEST_PROG=test_lite test_image test_file_image test_table test_ds test_packet test_dset_opt \
test_ld test_dset_append
-check_PROGRAMS=$(TEST_PROG) ld_mx
+check_PROGRAMS=$(TEST_PROG)
# These programs generate test files for the tests. They don't need to be
# compiled every time we want to test the library. However, putting
@@ -53,6 +48,5 @@ CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-9].h5 test_ds10.h5 \
test_image[1-3].h5 file_img[1-2].h5 test_lite[1-4].h5 test_table.h5 \
test_packet_table.h5 test_packet_compress.h5 test_detach.h5 \
test_dectris.h5
-DISTCLEANFILES=test_ld.sh
include $(top_srcdir)/config/conclude.am
diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in
index 23aab728..982ff3f 100644
--- a/hl/test/Makefile.in
+++ b/hl/test/Makefile.in
@@ -99,12 +99,11 @@ host_triplet = @host@
DIST_COMMON = $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am $(top_srcdir)/bin/mkinstalldirs \
- $(srcdir)/H5srcdir_str.h.in $(srcdir)/test_ld.sh.in \
- $(top_srcdir)/bin/depcomp $(top_srcdir)/bin/test-driver \
- COPYING
-check_PROGRAMS = $(am__EXEEXT_1) ld_mx$(EXEEXT)
+ $(srcdir)/H5srcdir_str.h.in $(top_srcdir)/bin/depcomp \
+ $(top_srcdir)/bin/test-driver COPYING
+check_PROGRAMS = $(am__EXEEXT_1)
@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2)
-TESTS = $(am__EXEEXT_1) $(TEST_SCRIPT)
+TESTS = $(am__EXEEXT_1)
subdir = hl/test
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \
@@ -113,7 +112,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/H5config.h
-CONFIG_CLEAN_FILES = H5srcdir_str.h test_ld.sh
+CONFIG_CLEAN_FILES = H5srcdir_str.h
CONFIG_CLEAN_VPATH_FILES =
am__EXEEXT_1 = test_lite$(EXEEXT) test_image$(EXEEXT) \
test_file_image$(EXEEXT) test_table$(EXEEXT) test_ds$(EXEEXT) \
@@ -133,10 +132,6 @@ gen_test_ld_SOURCES = gen_test_ld.c
gen_test_ld_OBJECTS = gen_test_ld.$(OBJEXT)
gen_test_ld_LDADD = $(LDADD)
gen_test_ld_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
-ld_mx_SOURCES = ld_mx.c
-ld_mx_OBJECTS = ld_mx.$(OBJEXT)
-ld_mx_LDADD = $(LDADD)
-ld_mx_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
test_ds_SOURCES = test_ds.c
test_ds_OBJECTS = test_ds.$(OBJEXT)
test_ds_LDADD = $(LDADD)
@@ -207,10 +202,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = gen_test_ds.c gen_test_ld.c ld_mx.c test_ds.c \
- test_dset_append.c test_dset_opt.c test_file_image.c \
- test_image.c test_ld.c test_lite.c test_packet.c test_table.c
-DIST_SOURCES = gen_test_ds.c gen_test_ld.c ld_mx.c test_ds.c \
+SOURCES = gen_test_ds.c gen_test_ld.c test_ds.c test_dset_append.c \
+ test_dset_opt.c test_file_image.c test_image.c test_ld.c \
+ test_lite.c test_packet.c test_table.c
+DIST_SOURCES = gen_test_ds.c gen_test_ld.c test_ds.c \
test_dset_append.c test_dset_opt.c test_file_image.c \
test_image.c test_ld.c test_lite.c test_packet.c test_table.c
am__can_run_installinfo = \
@@ -717,11 +712,6 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 \
test_table.h5 test_packet_table.h5 test_packet_compress.h5 \
test_detach.h5 test_dectris.h5
-# Test script
-TEST_SCRIPT = test_ld.sh
-check_SCRIPTS = $(TEST_SCRIPT)
-SCRIPT_DEPEND = ld_mx$(EXEEXT)
-
# The tests depend on the hdf5, hdf5 test, and hdf5_hl libraries
LDADD = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5)
@@ -737,7 +727,6 @@ TEST_PROG = test_lite test_image test_file_image test_table test_ds test_packet
# can be built by hand. They can also be built by specifying
# --enable-build-all at configure time.
BUILD_ALL_PROGS = gen_test_ds gen_test_ld
-DISTCLEANFILES = test_ld.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.,
@@ -795,8 +784,6 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
H5srcdir_str.h: $(top_builddir)/config.status $(srcdir)/H5srcdir_str.h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-test_ld.sh: $(top_builddir)/config.status $(srcdir)/test_ld.sh.in
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
@@ -824,10 +811,6 @@ gen_test_ld$(EXEEXT): $(gen_test_ld_OBJECTS) $(gen_test_ld_DEPENDENCIES) $(EXTRA
@rm -f gen_test_ld$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gen_test_ld_OBJECTS) $(gen_test_ld_LDADD) $(LIBS)
-ld_mx$(EXEEXT): $(ld_mx_OBJECTS) $(ld_mx_DEPENDENCIES) $(EXTRA_ld_mx_DEPENDENCIES)
- @rm -f ld_mx$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(ld_mx_OBJECTS) $(ld_mx_LDADD) $(LIBS)
-
test_ds$(EXEEXT): $(test_ds_OBJECTS) $(test_ds_DEPENDENCIES) $(EXTRA_test_ds_DEPENDENCIES)
@rm -f test_ds$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_ds_OBJECTS) $(test_ds_LDADD) $(LIBS)
@@ -872,7 +855,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_test_ds.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_test_ld.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ld_mx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ds.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dset_append.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dset_opt.Po@am__quote@
@@ -1081,7 +1063,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
echo "$$col$$br$$std"; \
fi; \
$$success || exit 1
-recheck: all $(check_PROGRAMS) $(check_SCRIPTS)
+recheck: all $(check_PROGRAMS)
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@set +e; $(am__set_TESTS_bases); \
bases=`for i in $$bases; do echo $$i; done \
@@ -1201,7 +1183,7 @@ distdir: $(DISTFILES)
fi; \
done
check-am: all-am
- $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS)
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(PROGRAMS) all-local
@@ -1235,7 +1217,6 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
- -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
diff --git a/hl/test/ld_mx.c b/hl/test/ld_mx.c
deleted file mode 100644
index 9d45823..0000000
--- a/hl/test/ld_mx.c
+++ /dev/null
@@ -1,353 +0,0 @@
-#include "h5hltest.h"
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-
-/* Size of data buffer */
-#define TEST_BUF_SIZE 100
-
-/* Note: These two defines should be the same as the defines in test_ld.sh.in */
-/* The message sent by extend_dset that the file is done with file open releasing the file lock */
-#define WRITER_MESSAGE "LD_WRITER_MESSAGE"
-/* The message sent by monitor_dset that it is done setting up */
-#define READER_MESSAGE "LD_READER_MESSAGE"
-
-/*
- * Test variations (incremental) for one-dimensional dataset:
- * Varies from 10->13->12->12->1->3
- */
-#define ONE_NTESTS 5
-int one_tests[ONE_NTESTS] = {3, -1, 0, -11, 2};
-
-/*
- * Test variations (incremental) for two-dimensional dataset:
- * Varies from {4,10}->{6,12}->{8,1}->{10,1}->
- * {3,3}->{2,2}->{1,2}->
- * {1,4}->{1,3}->{1,3}
- */
-#define TWO_NTESTS 9
-int two_tests[TWO_NTESTS][2] = { {2, 2}, {2, -11}, {2, 0},
- {-7, 2}, {-1, -1}, {-1, 0},
- {0, 2}, {0, -1}, {0, 0}
- };
-
-/*
- * Extend the specified dataset in the file with "monitor_dset" monitoring
- * the dataset on the other end:
- * 1) Extend the dataset according to the variations: ONE_NTESTS, TWO_NTESTS
- * 2) Write to the dataset (currently, only for integer dataset)
- * 3) Flush the dataset
- *
- * Due to the implementation of file locking, coordination is needed in file
- * opening for the writer/reader tests to proceed as expected:
- * --it will send the WRITER_MESSAGE when the file open is done:
- * to notify monitor_dset() to start monitoring the dataset
- * --it will wait for the READER_MESSAGE from monitor_dset() before extending
- * the dataset
- */
-static int
-extend_dset(const char *file, char *dname)
-{
- hid_t fid; /* file id */
- hid_t fapl; /* file access property list */
- hid_t did; /* dataset id */
- hid_t dtype; /* dataset's datatype */
- hid_t sid; /* dataspace id */
- int i, j, k; /* local index variable */
- int ndims; /* number of dimensions */
- int buf[TEST_BUF_SIZE]; /* buffer for data */
- hsize_t cur_dims[2]; /* current dimension sizes */
- hsize_t ext_dims[2]; /* new dimension sizes after extension */
-
- /* Create a file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- goto done;
-
- /* Set to use latest library format */
- if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0)
- goto done;
-
- /* Open the file with SWMR write */
- if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0)
- goto done;
-
- /* Send message that "extend_dset" (this routine) is done with H5Fopen--the file lock is released */
- h5_send_message(WRITER_MESSAGE);
-
- /* Open the dataset */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto done;
-
- /* Get the dataset's data space */
- if((sid = H5Dget_space(did)) < 0)
- goto done;
-
- /* Get the # of dimensions for the dataset */
- if((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
- goto done;
-
- /* Initialize data written to the dataset */
- HDmemset(buf, 0, sizeof(buf));
- for(k = 0; k < TEST_BUF_SIZE; k++)
- buf[k] = k;
-
- /* Wait for message from "monitor_dset" before starting to extend the dataset */
- if(h5_wait_message(READER_MESSAGE) < 0)
- goto done;
-
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < (ndims == 1 ? ONE_NTESTS: TWO_NTESTS); i++) {
- HDsleep(2);
-
- /* Get the dataset's current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
- goto done;
-
- /* Set up the new extended dimension sizes */
- for(j = 0; j < ndims; j++)
- ext_dims[j] = cur_dims[j] + (ndims == 1 ? (hsize_t)one_tests[i] : (hsize_t)two_tests[i][j]);
-
- /* Extend the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
- goto done;
-
- /* Get the dataset's data type */
- if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
- goto done;
-
- /* Write to the whole dataset after extension */
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- goto done;
-
- /* Flush the data */
- if(H5Dflush(did) < 0)
- goto done;
-
- } /* end for ONE_NTESTS or TWO_NTESTS */
-
- /* Closing */
- if(H5Tclose(dtype) < 0) goto done;
- if(H5Sclose(sid) < 0) goto done;
- if(H5Dclose(did) < 0) goto done;
- if(H5Pclose(fapl) < 0) goto done;
- if(H5Fclose(fid) < 0) goto done;
-
- return(0);
-
-done:
- H5E_BEGIN_TRY
- H5Tclose(dtype);
- H5Sclose(sid);
- H5Dclose(did);
- H5Pclose(fapl);
- H5Fclose(fid);
- H5E_END_TRY
-
- return(-1);
-} /* extend_dset() */
-
-
-/*
- * Monitor the specified dataset in the file while "extend_dset" is extending
- * and writing to the dataset on the other end:
- *
- * 1) Retrieve the dataset's current dimension sizes
- * 2) If there are changes in dimension sizes:
- * print the dimension sizes
- * retrieve the appended data and print them
- *
- * Due to the implementation of file locking, coordination is needed in file
- * opening for the writer/reader tests to proceed as expected:
- * --it will wait for the WRITER_MESSAGE from extend_dset() before opening
- * the test file
- * --it will send the READER_MESSAGE when the setup is done:
- * to notify extend_dset() to start extending the dataset
- */
-static int
-monitor_dset(const char *fname, char *dname)
-{
- hid_t fid; /* file id */
- hid_t fapl; /* file access property list */
- hid_t did; /* dataset id */
- hid_t sid; /* dataspace id */
- int ndims; /* # of dimensions in the dataspace */
- int i, u; /* local index variable */
- hsize_t cur_dims[H5S_MAX_RANK]; /* current dimension sizes */
- hsize_t prev_dims[H5S_MAX_RANK]; /* previous dimension sizes */
- int buf[TEST_BUF_SIZE]; /* Buffer for data */
- herr_t ret_value = 0; /* return value */
-
- /* Wait for message from "extend_dset" before opening the file */
- if(h5_wait_message(WRITER_MESSAGE) < 0)
- goto done;
-
- /* Create a file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- goto done;
-
- /* Set to use latest library format */
- if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0)
- goto done;
-
- /* Open the file with SWMR access */
- if((fid = H5Fopen(fname, H5F_ACC_SWMR_READ, fapl)) < 0) {
- ret_value = -1;
- goto done;
- }
-
- HDfprintf(stdout, "Monitoring dataset %s...\n", dname);
-
- /* Open the dataset for minitoring */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) {
- HDfprintf(stdout, "error in opening dataset \"%s\"\n", dname);
- ret_value = -1;
- goto done;
- }
-
- /* Get the dataset's data space */
- if((sid = H5Dget_space(did)) < 0) {
- HDfprintf(stdout, "error in getting dataspace id for dataset \"%s\"\n", dname);
- ret_value = -1;
- goto done;
- }
-
- /* Get the dataset's dimension sizes */
- if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) {
- HDfprintf(stdout, "unable to get dimensions sizes for \"%s\"\n", dname);
- ret_value = -1;
- goto done;
- }
-
- /* Send message that "monitor_dset" (this routine) is done with setting up */
- h5_send_message(READER_MESSAGE);
-
- /* Monitor the dataset for changes */
- while(1) {
-
- /* Refresh the dataset */
- if(H5Drefresh(did) < 0) {
- ret_value = -1;
- goto done;
- }
-
- /* Get the dataset's current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0) {
- HDfprintf(stdout, "unable to get dimension sizes for \"%s\"\n", dname);
- ret_value = -1;
- goto done;
- }
-
- /* Check for changes in dimension sizes */
- for(u = 0; u < ndims; u++) {
- if(cur_dims[u] != prev_dims[u]) {
- break;
- }
- }
-
- /* Printing only when there are changes */
- if(u < ndims) {
- /* Print the current dimension sizes */
- HDfprintf(stdout, "\n");
- for(i = 0; i < ndims; i++)
- HDfprintf(stdout, "%d ", (int)cur_dims[i]);
- HDfprintf(stdout, "\n");
-
- /* Get data appended to the dataset and print the data */
- HDmemset(buf, 0, sizeof(buf));
- if(H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, buf) >= 0) {
-
- for(i = 0; i < TEST_BUF_SIZE; i++) {
- if(i % 10)
- HDfprintf(stdout, "%d ", buf[i]);
- else
- HDfprintf(stdout, "\n%d ", buf[i]);
- }
- HDfprintf(stdout, "\n");
- }
-
- /* Flush the output to stdout */
- HDfflush(stdout);
- /* Update the dimension sizes */
- HDmemcpy(prev_dims, cur_dims, ndims * sizeof(hsize_t));
- }
- HDsleep(1);
- } /* end for */
-
-done:
- /* Closing */
- H5E_BEGIN_TRY
- H5Sclose(sid);
- H5Dclose(did);
- H5Pclose(fapl);
- H5E_END_TRY
-
- return(ret_value);
-} /* monitor_dset() */
-
-/* Usage:
- * ld_mx -m fname dname -- to monitor the file's dataset
- * or
- * ld_mx -x fname dname -- to extend the file's dataset
- */
-/* This file is a combination of ld_monitor.c and ld_extend.c which are svn deleted */
-int
-main(int argc, char *argv[])
-{
- char *dname = NULL; /* dataset name */
- char *fname = NULL; /* file name */
- int opt = 0;
- unsigned int monitor = 0, extend = 0;
-
- if(argc != 4) {
- fprintf(stderr, "Usage: ld_mx -m fname dname for monitoring the dataset 'dname' in the file 'fname'\n");
- fprintf(stderr, "Usage: ld_mx -x fname dname for extending the dataset 'dname' in the file 'fname'\n");
- goto done;
- }
- /* Parse command line options */
- while((opt = getopt(argc, argv, "mx")) != -1) {
- switch(opt) {
- case 'm': /* monitor dataset */
- monitor = 1;
- break;
-
- case 'x': /* extend dataset */
- extend = 1;
- break;
- default:
- printf("Invalid option encountered\n");
- break;
- }
- }
-
- if((extend && monitor) || (!extend && !monitor)) {
- fprintf(stderr, "Usage: ldmx -m/-x fname dname\n");
- goto done;
- }
-
- if(optind != 2) {
- fprintf(stderr, "Usage: ldmx -m/-x fname dname\n");
- goto done;
- }
-
- fname = HDstrdup(argv[optind++]);
- dname = HDstrdup(argv[optind++]);
-
-
- if(extend) {
- if(extend_dset(fname, dname) < 0)
- goto done;
- } else if(monitor) {
- if(monitor_dset(fname, dname) < 0)
- goto done;
- }
-
- exit(EXIT_SUCCESS);
-
-done:
- if(dname) HDfree(dname);
- if(fname) HDfree(fname);
- exit(EXIT_FAILURE);
-} /* main() */
diff --git a/hl/test/test_ld.sh.in b/hl/test/test_ld.sh.in
deleted file mode 100644
index b263f2a..0000000
--- a/hl/test/test_ld.sh.in
+++ /dev/null
@@ -1,102 +0,0 @@
-#! /bin/sh
-#
-# Copyright by The HDF Group.
-# Copyright by the Board of Trustees of the University of Illinois.
-# All rights reserved.
-#
-# This file is part of HDF5. The full HDF5 copyright notice, including
-# terms governing use, modification, and redistribution, is contained in
-# the files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
-#
-#
-# Concurrent tests for H5LD* routines
-#
-# Determine backward compatibility options eneabled
-DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
-
-CMP='cmp -s'
-DIFF='diff -c'
-LD_MONITOR='ld_mx -m'
-LD_MONITOR_BIN=`pwd`/$LD_MONITOR
-LD_EXTEND='ld_mx -x'
-LD_EXTEND_BIN=`pwd`/$LD_EXTEND
-# These two message files should be the same as the two defines in ./ld_mx.c
-READER_MESSAGE='LD_READER_MESSAGE'
-WRITER_MESSAGE='LD_WRITER_MESSAGE'
-#
-nerrors=0
-verbose=yes
-
-# The build (current) directory might be different than the source directory.
-if test -z "$srcdir"; then
- srcdir=.
-fi
-
-test -d ./testfiles || mkdir ./testfiles
-
-# Print a line-line message left justified in a field of 70 characters
-# beginning with the word "Testing".
-#
-TESTING() {
- SPACES=" "
- echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
-}
-
-# $1 -- the hdf5 file to be monitored and extended
-# $2 -- the dataset name to be monitored and extended
-# $3 -- the expected output from monitoring the dataset
-TESTLD() {
- expect="$srcdir/testfiles/$3" # the expected output
- actual="./testfiles/$3.OUT" # the actual output
- FNAME="`basename $1 .h5`_$2.h5" # the HDF5 file
- cp $srcdir/$1 ./$FNAME # copy the file to a temporary file
-#
- rm -f $WRITER_MESSAGE # remove the message file just to be sure
- rm -f $READER_MESSAGE # remove the message file just to be sure
-#
- $LD_EXTEND_BIN $FNAME $2 & # extend the dataset
- EXTEND_PID=$! # get the id of the "extend" process
- $LD_MONITOR_BIN $FNAME $2 > $actual 2>&1 & # monitor the dataset in the file
- MONITOR_PID=$! # get the id of the "monitor" process
- wait $EXTEND_PID # wait for the completion of the "extend" process
-#
- sleep 1 # sleep to ensure that the monitoring completes
- kill $MONITOR_PID # kill the "monitor" process
-#
- if $CMP $expect $actual; then # compare the output with the expected output
- echo " PASSED"
- else
- echo "*FAILED*"
- echo " Expected result differs from actual result"
- nerrors="`expr $nerrors + 1`"
- test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
- fi
- if test -z "$HDF5_NOCLEANUP"; then # clean up output file, temporary HDF5 file
- rm -f $actual $FNAME
- fi
-}
-
-##############################################################################
-##############################################################################
-### T H E T E S T S ###
-##############################################################################
-##############################################################################
-
-# Monitor DSET_ONE while extending the dataset
-TESTLD test_ld.h5 DSET_ONE test_ld_out1
-#
-#
-# Monitor DSET_TWO while extending the dataset
-TESTLD test_ld.h5 DSET_TWO test_ld_out2
-#
-#
-if test $nerrors -eq 0 ; then
- echo "All high level H5LD concurrent tests passed."
-fi
-
-exit $nerrors
diff --git a/hl/test/testfiles/test_ld_out1 b/hl/test/testfiles/test_ld_out1
deleted file mode 100644
index dda3552..0000000
--- a/hl/test/testfiles/test_ld_out1
+++ /dev/null
@@ -1,31 +0,0 @@
-Monitoring dataset DSET_ONE...
-
-13
-
-10 11 12 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-
-12
-
-1
-
-3
-
-1 2 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
diff --git a/hl/test/testfiles/test_ld_out2 b/hl/test/testfiles/test_ld_out2
deleted file mode 100644
index 7a98c19..0000000
--- a/hl/test/testfiles/test_ld_out2
+++ /dev/null
@@ -1,72 +0,0 @@
-Monitoring dataset DSET_TWO...
-
-6 12
-
-10 11 22 23 34 35 46 47 48 49
-50 51 52 53 54 55 56 57 58 59
-60 61 62 63 64 65 66 67 68 69
-70 71 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-
-8 1
-
-6 7 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-
-10 1
-
-8 9 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-
-3 3
-
-1 2 4 5 7 8 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-
-2 2
-
-1 2
-
-1 4
-
-2 3 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-0 0 0 0 0 0 0 0 0 0
-
-1 3
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index c5f6f8d..7bb86a2 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -28,7 +28,7 @@
*/
#define PROGRAMNAME "h5watch" /* Name of tool */
#define FIELD_SEP "," /* nested field separator */
-#define DEFAULT_RETRY 10 /* number of times to try opening the file */
+#define DEFAULT_RETRY 50 /* number of times to try opening the file */
/*
@@ -66,6 +66,7 @@ static void parse_command_line(int argc, const char *argv[]);
* The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
+static const char *s_opts ="?";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h' },
@@ -697,7 +698,7 @@ parse_command_line(int argc, const char *argv[])
}
/* parse command line options */
- while ((opt = get_option(argc, argv, NULL, l_opts)) != EOF) {
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
case '?':
case 'h': /* --help */
@@ -905,7 +906,7 @@ main(int argc, const char *argv[])
*dname = '\0';
} /* end while */
/* Try opening the file again if somehow unstable */
- } while(g_retry-- > 0 && fid == FAIL && !HDsleep(g_polling_interval));
+ } while(g_retry-- > 0 && fid == FAIL);
if(fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 9c077c9..ee0f49f 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1635,7 +1635,8 @@ herr_t
H5D_close(H5D_t *dataset)
{
unsigned free_failed = FALSE;
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t corked; /* Whether the dataset is corked or not */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1706,6 +1707,14 @@ H5D_close(H5D_t *dataset)
#endif /* NDEBUG */
} /* end switch */ /*lint !e788 All appropriate cases are covered */
+ /* Uncork cache entries with object address tag */
+ if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status")
+ else if(corked) {
+ if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to uncork an object")
+ }
+
/* If the dataset is opened for SWMR access, shut that down */
if(dataset->shared->is_swimming)
if(H5D__swmr_teardown(dataset, H5AC_dxpl_id) < 0)
diff --git a/src/H5F.c b/src/H5F.c
index e798493..6673096 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1599,22 +1599,33 @@ done:
* Function: H5Fstart_swmr_write
*
* Purpose: To enable SWMR writing mode for the file
- * 1) Mark the file in SWMR writing mode
- * 2) Set metadata read attempts and retries info
- * 3) Disable accumulator
- * 4) Flush the data buffers
- * 5) Evict all cache entries except the superblock
- * 6) Unlock the file
- * Fail when:
- * 1) There are opened objects
- * 2) The file is not opened with latest library format
- * 3) The file is not opened with H5F_ACC_RDWR
- * 4) The file is already marked for SWMR writing
- *
+ * 1) Refresh opened objects: part 1
+ * 2) Flush & reset accumulator
+ * 3) Mark the file in SWMR writing mode
+ * 4) Set metadata read attempts and retries info
+ * 5) Disable accumulator
+ * 6) Evict all cache entries except the superblock
+ * 7) Refresh opened objects (part 2)
+ * 8) Unlock the file
+ *
+ * Pre-conditions:
+ * 1) The file is opened with latest library format
+ * 2) The file is opened with H5F_ACC_RDWR
+ * 3) The file is not already marked for SWMR writing
+ * 4) Current implementaion for opened objects:
+ * --only allow datasets and groups without attributes
+ * --disallow named datatype with/without attributes
+ * --disallow opened attributes attached to objects
+ * NOTE: Currently, only opened groups and datasets are allowed
+ * when enabling SWMR via H5Fstart_swmr_write().
+ * Will later implement a different approach--
+ * set up flush dependency/proxy even for file opened without
+ * SWMR to resolve issues with opened objects.
+ *
* Return: Non-negative on success/negative on failure
*
* Programmer:
- * Vailin Choi; Dec 2013
+ * Vailin Choi; Feb 2014
*
*-------------------------------------------------------------------------
*/
@@ -1622,8 +1633,15 @@ herr_t
H5Fstart_swmr_write(hid_t file_id)
{
H5F_t *file; /* File info */
+ size_t grp_dset_count=0; /* # of open objects: groups & datasets */
+ size_t nt_attr_count=0; /* # of opened named datatypes + opened attributes */
+ hid_t *obj_ids=NULL; /* List of ids */
+ H5G_loc_t *obj_glocs=NULL; /* Group location of the object */
+ H5O_loc_t *obj_olocs=NULL; /* Object location */
+ H5G_name_t *obj_paths=NULL; /* Group hierarchy path */
+ size_t u; /* Local index variable */
+ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */
H5F_io_info_t fio_info; /* I/O info for operation */
- hbool_t setup = FALSE;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -1633,12 +1651,6 @@ H5Fstart_swmr_write(hid_t file_id)
if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
- /* ???How about nopen_files from (H5F_mount_count_ids(file, &nopen_files, &nopen_objs) */
- /* For now, just check nopen_objs */
- if((H5F_addr_defined(file->shared->sblock->ext_addr) && file->nopen_objs > 1) ||
- (!H5F_addr_defined(file->shared->sblock->ext_addr) && file->nopen_objs > 0))
- HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't start SWMR writing, there are objects still open")
-
/* Should have write permission */
if((H5F_INTENT(file) & H5F_ACC_RDWR) == 0)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "no write intent on file")
@@ -1653,20 +1665,55 @@ H5Fstart_swmr_write(hid_t file_id)
HDassert(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS);
- /* Turn on SWMR write in shared file open flags */
- file->shared->flags |= H5F_ACC_SWMR_WRITE;
+ /* Flush data buffers */
+ if(H5F_flush(file, H5AC_dxpl_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
+
+ /* Get the # of opened named datatypes and attributes */
+ if(H5F_get_obj_count(file, H5F_OBJ_LOCAL|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
+ if(nt_attr_count)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file")
+
+ /* Get the # of opened datasets and groups */
+ if(H5F_get_obj_count(file, H5F_OBJ_LOCAL|H5F_OBJ_GROUP|H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
+
+ /* Allocate space for group and object locations */
+ if(grp_dset_count) {
+ if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t")
+ if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t")
+ if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t")
+ if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t")
+ }
- /* Mark the file in SWMR writing mode */
- file->shared->sblock->status_flags |= H5F_SUPER_SWMR_WRITE_ACCESS;
+ /* Get the list of opened object ids (groups & datasets) */
+ if(grp_dset_count) {
+ if(H5F_get_obj_ids(file, H5F_OBJ_LOCAL|H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed")
+ }
- /* Set up metadata read attempts */
- file->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS;
+ /* Refresh opened objects (groups, datasets) in the file */
+ for(u = 0; u < grp_dset_count; u++) {
+ H5O_loc_t *oloc; /* object location */
- setup = TRUE;
+ /* Set up the id's group location */
+ obj_glocs[u].oloc = &obj_olocs[u];
+ obj_glocs[u].path = &obj_paths[u];
+ H5G_loc_reset(&obj_glocs[u]);
- /* Initialize "retries" and "retries_nbins" */
- if(H5F_set_retries(file) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins")
+ /* get the id's object location */
+ if((oloc = H5O_get_loc(obj_ids[u])) == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
+
+ /* Refresh (part 1) */
+ if(H5O_refresh_metadata_close(obj_ids[u], *oloc, &obj_glocs[u], H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object")
+ }
/* Set up I/O info for operation */
fio_info.f = file;
@@ -1677,28 +1724,50 @@ H5Fstart_swmr_write(hid_t file_id)
if(H5F__accum_reset(&fio_info, TRUE) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator")
+ /* Turn on SWMR write in shared file open flags */
+ file->shared->flags |= H5F_ACC_SWMR_WRITE;
+
+ /* Mark the file in SWMR writing mode */
+ file->shared->sblock->status_flags |= H5F_SUPER_SWMR_WRITE_ACCESS;
+
+ /* Set up metadata read attempts */
+ file->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS;
+
+ /* Initialize "retries" and "retries_nbins" */
+ if(H5F_set_retries(file) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins")
+
/* Turn off usage of accumulator */
file->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA;
if(H5FD_set_feature_flags(file->shared->lf, file->shared->feature_flags) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD")
+
+ setup = TRUE;
/* Mark superblock as dirty */
if(H5F_super_dirty(file) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
- /* Flush data buffers */
- if(H5F_flush(file, H5AC_dxpl_id, FALSE) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
+ /* Flush the superblock */
+ if(H5F_flush_tagged_metadata(file, (haddr_t)0, H5AC_dxpl_id) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock")
/* Evict all flushed entries in the cache except the pinned superblock */
if(H5F_evict_cache_entries(file, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict file's cached information")
+ /* Refresh (part 2: reopen) the objects (groups & datasets) in the file */
+ for(u = 0; u < grp_dset_count; u++) {
+ if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object")
+ }
+
/* Unlock the file */
if(H5FD_unlock(file->shared->lf) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to unlock the file")
done:
- if(ret_value < 0 && file && setup) {
+ if(ret_value < 0 && setup) {
+ HDassert(file);
/* Re-enable accumulator */
file->shared->feature_flags |= (unsigned)H5FD_FEAT_ACCUMULATE_METADATA;
@@ -1724,5 +1793,15 @@ done:
if(H5F_flush_tagged_metadata(file, (haddr_t)0, H5AC_dxpl_id) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock")
}
+ /* Free memory */
+ if(obj_ids)
+ H5MM_xfree(obj_ids);
+ if(obj_glocs)
+ H5MM_xfree(obj_glocs);
+ if(obj_olocs)
+ H5MM_xfree(obj_olocs);
+ if(obj_paths)
+ H5MM_xfree(obj_paths);
+
FUNC_LEAVE_API(ret_value)
} /* end H5Fstart_swmr_write() */
diff --git a/src/H5Fint.c b/src/H5Fint.c
index d7e89f2..c7a3013 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -1181,7 +1181,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
} else if (1 == shared->nrefs) {
/* Read the superblock if it hasn't been read before. */
- if(H5F__super_read(file, dxpl_id) < 0)
+ if(H5F__super_read(file, dxpl_id, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
/* Open the root group */
diff --git a/src/H5Fio.c b/src/H5Fio.c
index 2af10a9..fafe5e8 100644
--- a/src/H5Fio.c
+++ b/src/H5Fio.c
@@ -252,8 +252,8 @@ H5F_evict_tagged_metadata(H5F_t * f, haddr_t tag, hid_t dxpl_id)
HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict tagged metadata")
/* Re-read the superblock. */
- if (H5F__super_read(f, dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "unable to read superblock")
+ if(H5F__super_read(f, dxpl_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "unable to read superblock")
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -292,8 +292,7 @@ H5F_evict_cache_entries(H5F_t *f, hid_t dxpl_id)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status")
/* Verify status of the superblock entry in the cache */
- if(!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED) ||
- (status & H5AC_ES__IS_DIRTY) || (status & H5AC_ES__IS_PROTECTED))
+ if(!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED))
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status")
/* Get the number of cache entries */
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 47072ac..0bc7f5c 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -141,6 +141,17 @@
/* Size of file consistency flags (status_flags) in the superblock */
#define H5F_SUPER_STATUS_FLAGS_SIZE(v) (v >= 2 ? 1 : 4)
+/*
+ * User data for superblock protect in H5F_super_read:
+ * dirtied: the superblock is modifed or not
+ * initial read: superlock read upon the file's initial open--
+ * whether to skip the check for truncated file in H5F_sblock_load()
+ */
+typedef struct H5F_super_ud_t {
+ hbool_t dirtied;
+ hbool_t initial_read;
+} H5F_super_ud_t;
+
/* Forward declaration external file cache struct used below (defined in
* H5Fefc.c) */
typedef struct H5F_efc_t H5F_efc_t;
@@ -331,7 +342,7 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop
/* Superblock related routines */
H5_DLL herr_t H5F__super_init(H5F_t *f, hid_t dxpl_id);
-H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t dxpl_id);
+H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read);
H5_DLL herr_t H5F__super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size);
H5_DLL herr_t H5F__super_free(H5F_super_t *sblock);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index a24bbd8..d5e378e 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -254,18 +254,22 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F__super_read(H5F_t *f, hid_t dxpl_id)
+H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read)
{
H5P_genplist_t *dxpl; /* DXPL object */
H5F_super_t * sblock = NULL; /* Superblock structure */
unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */
- haddr_t super_addr; /* Absolute address of superblock */
- H5AC_protect_t rw; /* Read/write permissions for file */
- hbool_t dirtied = FALSE; /* Bool for sblock protect call */
- herr_t ret_value = SUCCEED; /* Return value */
+ haddr_t super_addr; /* Absolute address of superblock */
+ H5AC_protect_t rw; /* read/write permissions for file */
+ H5F_super_ud_t udata; /* User data passed to sblock protect */
+ herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_PACKAGE_TAG(dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL)
+ udata.dirtied = FALSE; /* Boolean (dirtied or not ) for sblock protect call */
+ udata.initial_read = initial_read; /* Indicate superblock read for initial file open: */
+ /* whether to skip the check for truncated file in H5F_sblock_load() */
+
/* Get the DXPL plist object for DXPL ID */
if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
@@ -290,11 +294,11 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id)
rw = H5AC_READ;
/* Look up the superblock */
- if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &dirtied, rw)))
+ if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw)))
HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock")
/* Mark the superblock dirty if it was modified during loading or VFD indicated to do so */
- if((H5AC_WRITE == rw) && (dirtied || H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_SBLK_LOAD)))
+ if((H5AC_WRITE == rw) && (udata.dirtied || H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_SBLK_LOAD)))
sblock_flags |= H5AC__DIRTIED_FLAG;
/* Pin the superblock in the cache */
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index c55abbe..ad0bdae 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -139,7 +139,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
size_t variable_size; /*variable sizeof superblock */
uint8_t *p; /* Temporary pointer into encoding buffer */
unsigned super_vers; /* Superblock version */
- hbool_t *dirtied = (hbool_t *)_udata; /* Set up dirtied out value */
+ H5F_super_ud_t *udata = (H5F_super_ud_t *)_udata;
unsigned tries, max_tries; /* The # of read attempts to try */
unsigned retries; /* The # of retries */
uint32_t computed_chksum; /* Computed checksum */
@@ -151,7 +151,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_eq(addr, 0));
- HDassert(dirtied);
+ HDassert(udata);
/* Short cuts */
shared = f->shared;
@@ -374,7 +374,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "failed to set base address for file driver")
/* Indicate that the superblock should be marked dirty */
- *dirtied = TRUE;
+ udata->dirtied = TRUE;
} /* end if */
/* This step is for h5repart tool only. If user wants to change file driver
@@ -387,7 +387,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
sblock->driver_addr = HADDR_UNDEF;
/* Indicate that the superblock should be marked dirty */
- *dirtied = TRUE;
+ udata->dirtied = TRUE;
} /* end if */
/* Decode the optional driver information block */
@@ -479,7 +479,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "failed to set base address for file driver")
/* Indicate that the superblock should be marked dirty */
- *dirtied = TRUE;
+ udata->dirtied = TRUE;
} /* end if */
/* Get the B-tree internal node values, etc */
@@ -505,7 +505,17 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
* as the file can appear truncated if only part of it has been
* been flushed to disk by the single writer process.)
*/
- if (!(H5F_INTENT(f) & H5F_ACC_SWMR_READ)) {
+ /* Can skip this test when it is not the initial file open--
+ * H5F_super_read() call from H5F_evict_tagged_metadata() for
+ * refreshing object.
+ * When flushing file buffers and fractal heap is involved,
+ * the library will allocate actual space for tmp addresses
+ * via the file layer. The aggregator allocates a block,
+ * thus the eoa might be greater than eof.
+ * Note: the aggregator is changed again after being reset
+ * earlier before H5AC_flush due to allocation of tmp addresses.
+ */
+ if (!(H5F_INTENT(f) & H5F_ACC_SWMR_READ) && udata->initial_read) {
if(HADDR_UNDEF == (eof = H5FD_get_eof(lf, H5FD_MEM_DEFAULT)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to determine file size")
@@ -558,7 +568,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda
/* Check for ignoring the driver info for this file */
if(H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) {
/* Indicate that the superblock should be marked dirty */
- *dirtied = TRUE;
+ udata->dirtied = TRUE;
} /* end if */
else {
/* Retrieve the 'driver info' structure */
diff --git a/src/H5Gint.c b/src/H5Gint.c
index 04b21a5..53e503a 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -503,7 +503,8 @@ done:
herr_t
H5G_close(H5G_t *grp)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t corked; /* Whether the group is corked or not */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -516,6 +517,14 @@ H5G_close(H5G_t *grp)
if(0 == grp->shared->fo_count) {
HDassert(grp != H5G_rootof(H5G_fileof(grp)));
+ /* Uncork cache entries with object address tag */
+ if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status")
+ else if(corked) {
+ if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__UNCORK, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to uncork an object")
+ }
+
/* Remove the group from the list of opened objects in the file */
if(H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
diff --git a/src/H5O.c b/src/H5O.c
index 877dbc5..bc40147 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1574,14 +1574,6 @@ H5O_close(H5O_loc_t *loc)
} /* end if */
#endif
- /* Uncork cache entries with tag: addr */
- if(H5AC_cork(loc->file, loc->addr, H5AC__GET_CORKED, &corked) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status")
- else if(corked) {
- if(H5AC_cork(loc->file, loc->addr, H5AC__UNCORK, NULL) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to uncork an object")
- }
-
/*
* If the file open object count has reached the number of open mount points
* (each of which has a group open in the file) attempt to close the file.
diff --git a/src/H5Oflush.c b/src/H5Oflush.c
index e30094e..20e9c2d 100644
--- a/src/H5Oflush.c
+++ b/src/H5Oflush.c
@@ -194,7 +194,7 @@ herr_t
H5Orefresh(hid_t oid)
{
H5O_loc_t *oloc; /* object location */
- hid_t ret_value = SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", oid);
@@ -203,9 +203,10 @@ H5Orefresh(hid_t oid)
if((oloc = H5O_get_loc(oid)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
- /* Private function */
- if ((H5O_refresh_metadata(oid, *oloc, H5AC_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh object")
+ /* Private function */
+ if(H5O_refresh_metadata(oid, *oloc, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
+
done:
FUNC_LEAVE_API(ret_value)
@@ -215,30 +216,72 @@ done:
/*-------------------------------------------------------------------------
* Function: H5O_refresh_metadata
*
- * Purpose: Internal routine that refreshes all buffers associated with
- * an object.
+ * Purpose: Refreshes all buffers associated with an object.
+ * This is based on the original H5O_refresh_metadata() but
+ * is split into 2 routines.
+ * (This is done so that H5Fstart_swmr_write() can use these
+ * 2 routines to refresh opened objects. This may be
+ * restored back to the original code when H5Fstart_swmr_write()
+ * uses a different approach to handle issues with opened objects.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy/Vailin Choi
+ * July 28, 2010/Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
+{
+ H5G_loc_t obj_loc;
+ H5O_loc_t obj_oloc;
+ H5G_name_t obj_path;
+ hid_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ if((H5O_refresh_metadata_close(oid, oloc, &obj_loc, H5AC_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
+
+ if((H5O_refresh_metadata_reopen(oid, &obj_loc, H5AC_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5O_refresh_metadata() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_refresh_metadata_close
+ *
+ * Purpose: This is the first part of the original routine H5O_refresh_metadata().
+ * (1) Save object location information.
+ * (2) Get object cork status
+ * (3) Close the object
+ * (4) Flush and evict object metadata
+ * (5) Re-cork the object if needed
*
* Return: Success: Non-negative
* Failure: Negative
*
- * Programmer: Mike McGreevy
- * July 28, 2010
+ * Programmer: Mike McGreevy/Vailin Choi
+ * July 28, 2010/Feb 2014
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
+H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t dxpl_id)
{
- void *object = NULL; /* Dataset for this operation */
haddr_t tag = 0;
H5O_t *oh = NULL;
- H5G_loc_t obj_loc;
H5G_loc_t tmp_loc;
- H5G_name_t obj_path;
- H5O_loc_t obj_oloc;
hbool_t corked;
hid_t ret_value = SUCCEED;
- H5I_type_t type;
FUNC_ENTER_NOAPI(FAIL)
@@ -246,15 +289,9 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
if(NULL == (oh = H5O_protect(&oloc, dxpl_id, H5AC_READ)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object's object header")
- /* Get object's type */
- type = H5I_get_type(oid);
-
/* Make deep local copy of object's location information */
H5G_loc(oid, &tmp_loc);
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
- H5G_loc_copy(&obj_loc, &tmp_loc, H5_COPY_DEEP);
+ H5G_loc_copy(obj_loc, &tmp_loc, H5_COPY_DEEP);
/* Get object header's address (i.e. the tag value for this object) */
if(HADDR_UNDEF == (tag = H5O_OH_GET_ADDR(oh)))
@@ -289,26 +326,60 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to cork the object")
}
- switch (type)
- {
+done:
+ if(oh && H5O_unprotect(&oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5O_refresh_metadata_close() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_refresh_metadata_reopen
+ *
+ * Purpose: This is the second part of the original routine H5O_refresh_metadata().
+ * (1) Re-open object with the saved object location information.
+ * (2) Re-register object ID with the re-opened object.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Mike McGreevy/Vailin Choi
+ * July 28, 2010/Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id)
+{
+ void *object = NULL; /* Dataset for this operation */
+ H5I_type_t type;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Get object's type */
+ type = H5I_get_type(oid);
+
+ switch(type) {
case(H5I_GROUP):
/* Re-open the group */
- if(NULL == (object = H5G_open(&obj_loc, dxpl_id)))
+ if(NULL == (object = H5G_open(obj_loc, dxpl_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
break;
case(H5I_DATATYPE):
/* Re-open the named datatype */
- if(NULL == (object = H5T_open(&obj_loc, dxpl_id)))
+ if(NULL == (object = H5T_open(obj_loc, dxpl_id)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
break;
case(H5I_DATASET):
/* Re-open the dataset */
- if(NULL == (object = H5D_open(&obj_loc, H5P_DATASET_ACCESS_DEFAULT, dxpl_id)))
+ if(NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT, dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset")
break;
@@ -336,10 +407,6 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to re-register object atom")
done:
- /* Unprotect object header on failure */
- if(oh && H5O_unprotect(&oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
FUNC_LEAVE_NOAPI(ret_value);
-} /* H5O_refresh_metadata */
+} /* H5O_refresh_metadata_reopen() */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 1955ec4..e6b7c03 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -635,7 +635,7 @@ H5_DLL herr_t H5O_proxy_undepend(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
/* These functions operate on object locations */
-H5_DLL H5O_loc_t *H5O_get_loc(hid_t id);
+/* H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); */
/* Testing functions */
#ifdef H5O_TESTING
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 7fde2eb..2c4f7ac 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -833,9 +833,13 @@ H5_DLL herr_t H5O_msg_unlock(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_
/* Object metadata flush/evict routines */
H5_DLL herr_t H5O_flush_metadata(const H5O_loc_t *oloc, hid_t dxpl_id);
-H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id);
H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id);
+H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id);
+H5_DLL herr_t H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t dxpl_id);
+H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id);
+
+
/* Object copying routines */
H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
@@ -855,6 +859,7 @@ H5_DLL herr_t H5O_loc_reset(H5O_loc_t *loc);
H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc);
H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc);
+H5_DLL H5O_loc_t *H5O_get_loc(hid_t id);
/* Storage operators */
H5_DLL void *H5O_storage_copy(const void *mesg, void *dest);
diff --git a/src/H5T.c b/src/H5T.c
index c5dd6f9..9578612 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3594,7 +3594,8 @@ done:
herr_t
H5T_close(H5T_t *dt)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t corked; /* Whether the named datatype is corked or not */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -3604,6 +3605,16 @@ H5T_close(H5T_t *dt)
dt->shared->fo_count--;
if(dt->shared->state != H5T_STATE_OPEN || dt->shared->fo_count == 0) {
+ /* Uncork cache entries with object address tag for named datatype only */
+ if(dt->shared->state == H5T_STATE_OPEN && dt->shared->fo_count == 0) {
+ if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status")
+ else if(corked) {
+ if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__UNCORK, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to uncork an object")
+ }
+ }
+
if(H5T__free(dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype");
diff --git a/test/Makefile.am b/test/Makefile.am
index 13b8624..a205cde 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -58,7 +58,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
twriteorder big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf farray earray btree2 fheap file_image unregister test_swmr
+ freespace mf farray earray btree2 fheap file_image unregister cork test_swmr
bin_PROGRAMS=swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \
swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \
diff --git a/test/Makefile.in b/test/Makefile.in
index 27c397c..4fa74c6 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -215,7 +215,7 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \
freespace$(EXEEXT) mf$(EXEEXT) farray$(EXEEXT) earray$(EXEEXT) \
btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT) \
- unregister$(EXEEXT) test_swmr$(EXEEXT)
+ unregister$(EXEEXT) cork$(EXEEXT) test_swmr$(EXEEXT)
@HAVE_SHARED_CONDITIONAL_TRUE@am__EXEEXT_2 = plugin$(EXEEXT)
am__EXEEXT_3 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \
gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \
@@ -275,6 +275,10 @@ cmpd_dset_SOURCES = cmpd_dset.c
cmpd_dset_OBJECTS = cmpd_dset.$(OBJEXT)
cmpd_dset_LDADD = $(LDADD)
cmpd_dset_DEPENDENCIES = libh5test.la $(LIBHDF5)
+cork_SOURCES = cork.c
+cork_OBJECTS = cork.$(OBJEXT)
+cork_LDADD = $(LDADD)
+cork_DEPENDENCIES = libh5test.la $(LIBHDF5)
cross_read_SOURCES = cross_read.c
cross_read_OBJECTS = cross_read.$(OBJEXT)
cross_read_LDADD = $(LDADD)
@@ -658,7 +662,7 @@ SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \
$(libdynlib3_la_SOURCES) $(libh5test_la_SOURCES) accum.c \
accum_swmr_reader.c app_ref.c atomic_reader.c atomic_writer.c \
big.c bittests.c btree2.c cache.c cache_api.c cache_tagging.c \
- cmpd_dset.c cross_read.c dangle.c dsets.c dt_arith.c \
+ cmpd_dset.c cork.c cross_read.c dangle.c dsets.c dt_arith.c \
dtransform.c dtypes.c earray.c efc.c enc_dec_plist.c \
enc_dec_plist_with_endianess.c enum.c err_compat.c \
error_test.c extend.c external.c farray.c fheap.c file_image.c \
@@ -683,8 +687,8 @@ DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \
$(am__libdynlib3_la_SOURCES_DIST) $(libh5test_la_SOURCES) \
accum.c accum_swmr_reader.c app_ref.c atomic_reader.c \
atomic_writer.c big.c bittests.c btree2.c cache.c cache_api.c \
- cache_tagging.c cmpd_dset.c cross_read.c dangle.c dsets.c \
- dt_arith.c dtransform.c dtypes.c earray.c efc.c \
+ cache_tagging.c cmpd_dset.c cork.c cross_read.c dangle.c \
+ dsets.c dt_arith.c dtransform.c dtypes.c earray.c efc.c \
enc_dec_plist.c enc_dec_plist_with_endianess.c enum.c \
err_compat.c error_test.c extend.c external.c farray.c fheap.c \
file_image.c fillval.c filter_fail.c flush1.c flush2.c \
@@ -1244,7 +1248,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
twriteorder big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf farray earray btree2 fheap file_image unregister test_swmr
+ freespace mf farray earray btree2 fheap file_image unregister cork test_swmr
# These programs generate test files for the tests. They don't need to be
@@ -1540,6 +1544,10 @@ cmpd_dset$(EXEEXT): $(cmpd_dset_OBJECTS) $(cmpd_dset_DEPENDENCIES) $(EXTRA_cmpd_
@rm -f cmpd_dset$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(cmpd_dset_OBJECTS) $(cmpd_dset_LDADD) $(LIBS)
+cork$(EXEEXT): $(cork_OBJECTS) $(cork_DEPENDENCIES) $(EXTRA_cork_DEPENDENCIES)
+ @rm -f cork$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(cork_OBJECTS) $(cork_LDADD) $(LIBS)
+
cross_read$(EXEEXT): $(cross_read_OBJECTS) $(cross_read_DEPENDENCIES) $(EXTRA_cross_read_DEPENDENCIES)
@rm -f cross_read$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(cross_read_OBJECTS) $(cross_read_LDADD) $(LIBS)
@@ -1891,6 +1899,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache_tagging.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmpd_dset.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cork.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cross_read.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dangle.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsets.Po@am__quote@
@@ -2583,6 +2592,13 @@ unregister.log: unregister$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+cork.log: cork$(EXEEXT)
+ @p='cork$(EXEEXT)'; \
+ b='cork'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
test_swmr.log: test_swmr$(EXEEXT)
@p='test_swmr$(EXEEXT)'; \
b='test_swmr'; \
diff --git a/test/cork.c b/test/cork.c
new file mode 100644
index 0000000..bb2b7fb
--- /dev/null
+++ b/test/cork.c
@@ -0,0 +1,2177 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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: Vailin Choi
+ * Feb 20, 2014
+ *
+ * This file contains tests for H5Ocork/H5Ouncork/H5Ois_corked.
+ */
+#include "hdf5.h"
+#include "testhdf5.h"
+#include "h5test.h"
+#include "H5Iprivate.h"
+#include "H5ACprivate.h"
+#include "H5ACpublic.h"
+#include "cache_common.h"
+#include "H5HLprivate.h"
+
+/* ============ */
+/* Test Defines */
+/* ============ */
+
+#define FILENAME "test_cork.h5"
+#define ATTR "ATTR"
+#define DSET "DSET"
+#define DSET_BT1 "DSET_BT1"
+#define DSET_COMPACT "DSET_COMPACT"
+#define DSET_CONTIG "DSET_CONTIG"
+#define DSET_EA "DSET_EA"
+#define DSET_BT2 "DSET_BT2"
+#define DSET_FA "DSET_FA"
+#define DSET_NONE "DSET_NONE"
+#define GRP "GRP"
+#define GRP2 "GRP2"
+#define GRP3 "GRP3"
+#define DT "DT"
+#define DT2 "DT2"
+#define DT3 "DT3"
+#define GRP_ATTR "GRP_ATTR"
+#define DSET_ATTR "DSET_ATTR"
+#define DT_ATTR "DT_ATTR"
+
+#define RANK 2
+#define DIM0 5
+#define DIM1 10
+#define DIMS0 50
+#define DIMS1 100
+
+
+/* ===================== */
+/* Function Declarations */
+/* ===================== */
+
+/* Helper Functions */
+static void print_entry_type_to_screen(int id);
+static int print_index(hid_t fid);
+static int verify_cork_tag(hid_t fid, haddr_t tag, hbool_t status);
+
+/* Tests */
+static int test_objs_cork(hbool_t newformat);
+static int test_dset_cork(hbool_t newformat);
+static int verify_old_dset_cork(void);
+static int verify_obj_dset_cork(hbool_t swmr);
+static int verify_dset_cork(hbool_t swmr);
+static int verify_group_cork(hbool_t swmr);
+static int verify_named_cork(hbool_t swmr);
+static int verify_multiple_cork(hbool_t swmr);
+
+/* ================ */
+/* Helper Functions */
+/* ================ */
+
+
+/*-------------------------------------------------------------------------
+ *
+ * Function: print_entry_type_to_screen
+ * (copied from cache_tagging.c)
+ *
+ * Purpose: DEBUG CODE (for when verbose is set).
+ *
+ * Prints type of entry to stdout.
+ *
+ * Return: void
+ *
+ * Programmer: Mike McGreevy
+ * September 3, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+print_entry_type_to_screen(int id)
+{
+ printf("Type = ");
+
+ switch (id) {
+
+ case 0:
+ printf("B-tree Node");
+ break;
+ case 1:
+ printf("Symbol Table Node");
+ break;
+ case 2:
+ printf("Local Heap Prefix");
+ break;
+ case 3:
+ printf("Local Heap Data Block");
+ break;
+ case 4:
+ printf("Global Heap");
+ break;
+ case 5:
+ printf("Object Header");
+ break;
+ case 6:
+ printf("Object Header Chunk");
+ break;
+ case 7:
+ printf("v2 B-tree Header");
+ break;
+ case 8:
+ printf("v2 B-tree Internal Node");
+ break;
+ case 9:
+ printf("v2 B-tree Leaf Node");
+ break;
+ case 10:
+ printf("Fractal Heap Header");
+ break;
+ case 11:
+ printf("Fractal Heap Direct Block");
+ break;
+ case 12:
+ printf("Fractal Heap Indirect Block");
+ break;
+ case 13:
+ printf("Free Space Header");
+ break;
+ case 14:
+ printf("Free Space Section");
+ break;
+ case 15:
+ printf("Shared Object Header Message Master Table");
+ break;
+ case 16:
+ printf("Shared Message Index Stored As A List");
+ break;
+ case 17:
+ printf("Extensible Array Header");
+ break;
+ case 18:
+ printf("Extensible Array Index Block");
+ break;
+ case 19:
+ printf("Extensible Array Super Block");
+ break;
+ case 20:
+ printf("Extensible Array Data Block");
+ break;
+ case 21:
+ printf("Extensible Array Data Block Page");
+ break;
+ case 22:
+ printf("Chunk Proxy");
+ break;
+ case 23:
+ printf("Fixed Array Header");
+ break;
+ case 24:
+ printf("Fixed Array Data Block");
+ break;
+ case 25:
+ printf("Fixed Array Data Block Page");
+ break;
+ case 26:
+ printf("File Superblock");
+ break;
+ case 27:
+ printf("Test Entry");
+ break;
+ case 28:
+ printf("Number of Types");
+ break;
+ default:
+ printf("*Unknown*");
+ break;
+
+ } /* end switch */
+
+} /* print_entry_type_to_screen */
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_index()
+ *
+ * Purpose: DEBUG CODE (for when verbose is set).
+ * (copied from cache_tagging.c)
+ *
+ * Prints cache index to screen, including address of entries,
+ * tag values of entries, and entry types.
+ *
+ * Return: void
+ *
+ * Programmer: Mike McGreevy
+ * January 25, 2010
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int print_index(hid_t fid) {
+
+ H5F_t * f = NULL; /* File Pointer */
+ H5C_t * cache_ptr = NULL; /* Cache Pointer */
+ int i = 0; /* Iterator */
+ H5C_cache_entry_t *next_entry_ptr = NULL; /* entry pointer */
+
+ /* Get Internal File / Cache Pointers */
+ if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR;
+ cache_ptr = f->shared->cache;
+
+ /* Initial (debugging) loop */
+ printf("CACHE SNAPSHOT:\n");
+ for (i = 0; i < H5C__HASH_TABLE_LEN; i++) {
+ next_entry_ptr = cache_ptr->index[i];
+
+ while (next_entry_ptr != NULL) {
+ printf("Addr = %u, ", (unsigned int)next_entry_ptr->addr);
+ printf("Tag = %u, ", (unsigned int)next_entry_ptr->tag);
+ printf("Dirty = %d, ", (int)next_entry_ptr->is_dirty);
+ printf("Protected = %d, ", (int)next_entry_ptr->is_protected);
+ printf("Pinned = %d, ", (int)next_entry_ptr->is_pinned);
+ printf("Corked = %d, ", (int)next_entry_ptr->is_corked);
+ print_entry_type_to_screen(next_entry_ptr->type->id);
+ printf("\n");
+ next_entry_ptr = next_entry_ptr->ht_next;
+ } /* end if */
+
+ } /* end for */
+ printf("\n");
+
+ return 0;
+
+error:
+
+ return -1;
+
+} /* print_index */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_cork_tag()
+ *
+ * Purpose: This routine verifies that all cache entries associated with
+ * the object tag are marked with the desired "cork" status.
+ *
+ * Return: 0 on Success, -1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_cork_tag(hid_t fid, haddr_t tag, hbool_t status)
+{
+ int i = 0; /* Iterator */
+ H5F_t * f = NULL; /* File Pointer */
+ H5C_t * cache_ptr = NULL; /* Cache Pointer */
+ H5C_cache_entry_t *next_entry_ptr = NULL; /* entry pointer */
+
+ /* Get Internal File / Cache Pointers */
+ if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR;
+ cache_ptr = f->shared->cache;
+
+ for (i = 0; i < H5C__HASH_TABLE_LEN; i++) {
+
+ next_entry_ptr = cache_ptr->index[i];
+
+ while (next_entry_ptr != NULL) {
+
+ if (next_entry_ptr->tag == tag && next_entry_ptr->is_corked != status)
+ TEST_ERROR;
+
+ next_entry_ptr = next_entry_ptr->ht_next;
+
+ } /* end if */
+
+ } /* for */
+
+ return 0;
+
+error:
+ return -1;
+} /* verify_cork_tag */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_old_dset_cork
+ *
+ * Purpose: This function verifies corking operation for datasets
+ * created with old library format. Cache entries associated with the
+ * object tag are checked for the correct cork status.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_old_dset_cork(void)
+{
+ /* Variable Declarations */
+ int verbose = FALSE; /* Verbose file outout */
+ hid_t fid = -1; /* File ID */
+ hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */
+ hid_t dcpl = -1, dcpl2 = -1, dcpl3 = -1; /* Dataset creation property lists */
+ hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */
+ hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */
+ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */
+ int buf[100][20]; /* Data buffer */
+ int i = 0, j = 0; /* Local index variable */
+ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */
+ hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */
+
+ /* Testing Macro */
+ TESTING("cork status for datasets with old format");
+
+ /* Create the file */
+ if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Create dcpl */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use chunked dataset */
+ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR
+
+ /* Create chunked dataset with v1-btree indexing: DSET_BT1 */
+ if((sid = H5Screate_simple(2, dims, max_dims)) < 0)
+ TEST_ERROR;
+ if((did = H5Dcreate2(fid, DSET_BT1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Get dataset object header address: DSET_BT1 */
+ if(H5Oget_info(did, &oinfo) < 0 ) TEST_ERROR;
+
+ /* Cork the dataset: DSET_BT1 */
+ if(H5Ocork(did) < 0 ) TEST_ERROR;
+
+ /* Verify cork status */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Initialize data buffer */
+ for(i = 0; i < (int)dims[0]; i++) {
+ for(j = 0; j < (int)dims[1]; j++) {
+ buf[i][j] = (i + 1) * (j + 1);
+ }
+ }
+
+ /* Write to the dataset: DSET_BT1 */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ TEST_ERROR;
+
+ /* Verify the cork status for DSET_BT1 */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Create compact dataset: DSET_COMPACT */
+ if((sid2 = H5Screate_simple(2, dims2, NULL)) < 0)
+ FAIL_STACK_ERROR
+ if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_layout(dcpl2, H5D_COMPACT) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0)
+ FAIL_STACK_ERROR
+ if((did2 = H5Dcreate2(fid, DSET_COMPACT, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get dataset object address */
+ if(H5Oget_info(did2, &oinfo2) < 0 ) TEST_ERROR;
+
+ /* Cork the dataset: DSET_COMPACT */
+ if(H5Ocork(did2) < 0 ) TEST_ERROR;
+
+ /* Verify cork status */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(did) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid) < 0 ) TEST_ERROR;
+ if(H5Pclose(dcpl) < 0 ) TEST_ERROR;
+
+ if(H5Dclose(did2) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid2) < 0 ) TEST_ERROR;
+ if(H5Pclose(dcpl2) < 0 ) TEST_ERROR;
+
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ /* Reopen the file */
+ if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR;
+
+ /* Initialize data buffer */
+ for(i = 0; i < (int)dims[0]; i++) {
+ for(j = 0; j < (int)dims[1]; j++) {
+ buf[i][j] = (i + 1) * (j + 1);
+ }
+ }
+
+ /* Open and write to the dataset: DSET_BT1 */
+ if((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0 ) TEST_ERROR;
+
+ /* Create contiguous dataset: DSET_CONTIG */
+ if((sid3 = H5Screate_simple(2, dims2, NULL)) < 0)
+ FAIL_STACK_ERROR
+ if((dcpl3 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_layout(dcpl3, H5D_CONTIGUOUS) < 0)
+ FAIL_STACK_ERROR
+ if((did3 = H5Dcreate2(fid, DSET_CONTIG, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl3, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get dataset object address: DSET_CONTIG */
+ if(H5Oget_info(did3, &oinfo3) < 0 ) TEST_ERROR;
+
+ /* Cork the dataset: DSET_CONTIG */
+ if(H5Ocork(did3) < 0 ) TEST_ERROR;
+
+ /* Verify the cork status for DSET_CONTIG */
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Verify the cork status for DSET_BT1 */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Un-cork the dataset: DSET_CONTIG */
+ if(H5Ouncork(did3) < 0 ) TEST_ERROR;
+
+ /* Verify the cork status for DSET_CONTIG */
+ if(verify_cork_tag(fid, oinfo3.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(did3) < 0 ) TEST_ERROR;
+ if(H5Pclose(dcpl3) < 0 ) TEST_ERROR;
+ if(H5Dclose(did) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Sclose(sid2);
+ H5Sclose(sid3);
+ H5Dclose(did);
+ H5Dclose(did2);
+ H5Dclose(did3);
+ H5Pclose(dcpl);
+ H5Pclose(dcpl2);
+ H5Pclose(dcpl3);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* verify_old_dset_cork */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_obj_dset_cork
+ *
+ * Purpose: This function verifies corking operations for dataset objects.
+ * Cache entries associated with the object tag are checked
+ * for the correct cork status.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_obj_dset_cork(hbool_t swmr)
+{
+ /* Variable Declarations */
+ int verbose = FALSE; /* Verbose file outout */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t sid = -1, sid2 = -1; /* Dataspace IDs */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hid_t oid = -1; /* Object ID */
+ hid_t dcpl2; /* Dataset creation property list */
+ int i = 0; /* Local index variable */
+ hsize_t dim[1] = {100}; /* Dataset dimension size */
+ hsize_t chunk_dim[1] = {7}; /* Dataset chunk dimension size */
+ H5O_info_t oinfo, oinfo2; /* Object metadata information */
+ char attrname[500]; /* Name of attribute */
+ unsigned flags; /* File access flags */
+
+ if(swmr) {
+ TESTING("cork status for dataset objects with attributes (SWMR)");
+ } else {
+ TESTING("cork status for dataset objects with attributes");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 )
+ TEST_ERROR;
+ /* Set to use latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR;
+
+ /* Create the file with/without SWMR access */
+ flags = H5F_ACC_TRUNC;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0 )
+ TEST_ERROR;
+
+ /* Create dataspace */
+ if((sid = H5Screate(H5S_SCALAR)) < 0 ) TEST_ERROR;
+
+ /* Create dataset: DSET */
+ if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Get dataset object header address */
+ if(H5Oget_info(did, &oinfo) < 0 ) TEST_ERROR;
+
+ /* Cork the dataset: DSET */
+ if(H5Ocork(did) < 0 ) TEST_ERROR;
+
+ /* Attach and write to an attribute to the dataset: DSET */
+ if((aid = H5Acreate2(did, ATTR, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Close the attribute */
+ if(H5Aclose(aid) < 0)
+ TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Create dcpl */
+ if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0 ) TEST_ERROR;
+ /* Set to early allocation for dataset space */
+ if(H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0)
+ TEST_ERROR
+
+ /* Create chunked dataset with implicit indexing: DSET_NONE */
+ if(H5Pset_chunk(dcpl2, 1, chunk_dim) < 0) FAIL_STACK_ERROR
+ if((sid2 = H5Screate_simple(1, dim, NULL)) < 0)
+ TEST_ERROR;
+ if((did2 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Get dataset object header address */
+ if(H5Oget_info(did2, &oinfo2) < 0 ) TEST_ERROR;
+
+ /* Cork the dataset: DSET_NONE */
+ if(H5Ocork(did2) < 0 ) TEST_ERROR;
+
+ /* Attach 8 attributes to the dataset */
+ for(i = 0;i < 8; i++) {
+ sprintf(attrname, "attr %d", i);
+ if((aid = H5Acreate2(did2, attrname, H5T_NATIVE_UINT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+ if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0 )
+ TEST_ERROR;
+ if(H5Aclose(aid) < 0 ) TEST_ERROR;
+ } /* end for */
+
+ /* Verify cork status of the dataset: DSET_NONE */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Oclose(did) < 0 ) TEST_ERROR;
+ if(H5Oclose(did2) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid2) < 0 ) TEST_ERROR;
+ if(H5Pclose(dcpl2) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ /* Re-open the file */
+ flags = H5F_ACC_RDWR;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fopen(FILENAME, flags, fapl)) < 0)
+ TEST_ERROR;
+
+ /* Open the dataset object: DSET_NONE */
+ if((oid = H5Oopen(fid, DSET_NONE, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo2.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Open the attribute attached to the dataset object: DSET_NONE */
+ if((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Cork the dataset: DSET_NONE */
+ if(H5Ocork(oid) < 0) TEST_ERROR
+
+ /* Verify cork status of the dataset: DSET_NONE */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Close the attribute */
+ if(H5Aclose(aid) < 0 ) TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Oclose(oid) < 0 ) TEST_ERROR;
+ if(H5Pclose(fapl) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Aclose(aid);
+ H5Sclose(sid);
+ H5Sclose(sid2);
+ H5Dclose(did);
+ H5Dclose(did2);
+ H5Oclose(oid);
+ H5Pclose(dcpl2);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* verify_obj_dset_cork */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_dset_cork
+ *
+ * Purpose: This function verifies corking operations for chunked datasets
+ * with different indexing types.
+ * Cache entries associated with the object tag are checked
+ * for the correct cork status.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_dset_cork(hbool_t swmr)
+{
+ /* Variable Declarations */
+ int verbose = FALSE; /* Verbose file outout */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
+ hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */
+ hid_t dcpl = -1; /* Dataset creation property list */
+ hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */
+ hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */
+ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */
+ int buf[100][20]; int i = 0, j = 0; /* Data buffer */
+ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */
+ unsigned flags; /* File access flags */
+
+ /* Testing Macro */
+ if(swmr) {
+ TESTING("cork status for chunked datasets with different indexing types (SWMR)");
+ } else {
+ TESTING("cork status for chunked datasets with different indexing types");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 )
+ TEST_ERROR;
+ /* Set to use latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR;
+
+ /* Create the file */
+ flags = H5F_ACC_TRUNC;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0 )
+ TEST_ERROR;
+
+ /* Create dcpl */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use chunked dataset */
+ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR
+
+ /* Create chunked dataset with extensive array indexing: DSET_EA */
+ if((sid = H5Screate_simple(2, dims, max_dims)) < 0)
+ TEST_ERROR;
+ if((did = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Get dataset object header address: DSET_EA */
+ if(H5Oget_info(did, &oinfo) < 0 ) TEST_ERROR;
+
+ /* Cork the dataset: DSET_EA */
+ if(H5Ocork(did) < 0 ) TEST_ERROR;
+
+ /* Verify cork status */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Create chunked dataset with fixed array indexing: DSET_FA */
+ if((sid2 = H5Screate_simple(2, dims, NULL)) < 0)
+ TEST_ERROR;
+ if((did2 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Get dataset object header address: DSET_FA */
+ if(H5Oget_info(did2, &oinfo2) < 0 )
+ TEST_ERROR;
+
+ /* Cork the dataset: DSET_FA */
+ if(H5Ocork(did2) < 0 ) TEST_ERROR;
+
+ /* Uncork the dataset: DSET_EA */
+ if(H5Ouncork(did) < 0 ) TEST_ERROR;
+
+ /* Verify the cork status for DSET_FA */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Verify the cork status for DSET_EA */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Create chunked dataset with v2-Btree indexing */
+ max_dims[0] = H5S_UNLIMITED;
+ if((sid3 = H5Screate_simple(2, dims, max_dims)) < 0)
+ TEST_ERROR;
+ if((did3 = H5Dcreate2(fid, DSET_BT2, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+
+ /* Get dataset object header address: DSET_BT2 */
+ if(H5Oget_info(did3, &oinfo3) < 0 )
+ TEST_ERROR;
+
+ /* Cork the dataset: DSET_BT2 */
+ if(H5Ocork(did3) < 0 ) TEST_ERROR;
+
+ /* Verify the cork status for DSET_BT2 */
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(did3) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid3) < 0 ) TEST_ERROR;
+
+ if(H5Dclose(did2) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid2) < 0 ) TEST_ERROR;
+
+ if(H5Dclose(did) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid) < 0 ) TEST_ERROR;
+
+ if(H5Pclose(dcpl) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ /* Reopen the file */
+ flags = H5F_ACC_RDWR;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fopen(FILENAME, flags, fapl)) < 0 ) TEST_ERROR;
+
+ /* Initialize data buffer */
+ for(i = 0; i < (int)dims[0]; i++) {
+ for(j = 0; j < (int)dims[1]; j++) {
+ buf[i][j] = (i + 1) * (j + 1);
+ }
+ }
+
+ /* Open and write to the dataset: DSET_EA */
+ if((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0 ) TEST_ERROR;
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ TEST_ERROR;
+
+ /* Verify the cork status for DSET_EA */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Open and write to the dataset: DSET_FA */
+ if((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0 ) TEST_ERROR;
+ if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ TEST_ERROR;
+
+ /* Cork the dataset: DSET_FA */
+ if(H5Ocork(did2) < 0 ) TEST_ERROR;
+
+ /* Verify the cork status for DSET_FA */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Open and write to the dataset: DSET_BT2 */
+ if((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0 ) TEST_ERROR;
+ if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ TEST_ERROR;
+
+ /* Verify the cork status for DSET_BT2 */
+ if(verify_cork_tag(fid, oinfo3.addr, FALSE) < 0 )
+ TEST_ERROR;
+
+ /* Cork the dataset: DSET_BT2 */
+ if(H5Ocork(did3) < 0 ) TEST_ERROR;
+
+ /* Verify the cork status for DSET_BT2 */
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0 )
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(did) < 0 ) TEST_ERROR;
+ if(H5Dclose(did2) < 0 ) TEST_ERROR;
+ if(H5Dclose(did3) < 0 ) TEST_ERROR;
+ if(H5Pclose(fapl) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Sclose(sid2);
+ H5Sclose(sid3);
+ H5Dclose(did);
+ H5Dclose(did2);
+ H5Dclose(did3);
+ H5Pclose(dcpl);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* verify_dset_cork */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_group_cork
+ *
+ * Purpose: This function verifies corking operations for groups.
+ * Cache entries associated with the object tag are checked
+ * for the correct cork status.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_group_cork(hbool_t swmr)
+{
+ /* Variable Declarations */
+ int verbose = FALSE; /* Verbose file outout */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
+ hid_t gid = -1, gid2 = -1, gid3 = -1; /* Group IDs */
+ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ char attrname[500]; /* Name of attribute */
+ unsigned flags; /* File access flags */
+ int i = 0; /* Local index variable */
+
+ /* Testing Macro */
+ if(swmr) {
+ TESTING("cork status for groups (SWMR)");
+ } else {
+ TESTING("cork status for groups");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 )
+ TEST_ERROR;
+ /* Set to use latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR;
+
+ /* Create the file */
+ flags = H5F_ACC_TRUNC;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0 )
+ TEST_ERROR;
+
+ /* Create 3 groups */
+ if((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if((gid3 = H5Gcreate2(gid2, GRP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Cork the second group: GRP2 */
+ if(H5Ocork(gid2) < 0) TEST_ERROR
+
+ /* Get group object header addresses */
+ if(H5Oget_info(gid, &oinfo) < 0) TEST_ERROR;
+ if(H5Oget_info(gid2, &oinfo2) < 0) TEST_ERROR;
+ if(H5Oget_info(gid3, &oinfo3) < 0) TEST_ERROR;
+
+ /* Verify cork status of the groups */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0)
+ TEST_ERROR;
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0)
+ TEST_ERROR;
+ if(verify_cork_tag(fid, oinfo3.addr, FALSE) < 0)
+ TEST_ERROR;
+
+ /* Close the second group: GRP2 */
+ if(H5Gclose(gid2) < 0 ) TEST_ERROR;
+
+ /* Re-open the second group: GRP2 */
+ if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify cork status of the second group: GRP2 */
+ if(verify_cork_tag(fid, oinfo2.addr, FALSE) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Gclose(gid) < 0 ) TEST_ERROR;
+ if(H5Gclose(gid2) < 0 ) TEST_ERROR;
+ if(H5Gclose(gid3) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+ /* Re-open the file and the three groups */
+ flags = H5F_ACC_RDWR;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fopen(FILENAME, flags, fapl)) < 0 )
+ FAIL_STACK_ERROR
+ if((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((gid3 = H5Gopen2(gid2, GRP3, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create dataspace */
+ if((sid = H5Screate(H5S_SCALAR)) < 0 ) TEST_ERROR;
+
+ /* Attach 8 attributes to the third group: GRP3 */
+ for(i = 0;i < 8; i++) {
+ sprintf(attrname, "attr %d", i);
+ if((aid = H5Acreate2(gid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+ if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
+ TEST_ERROR;
+ /* Cork the third group while attaching attributes */
+ if(i == 3) {
+ if(H5Ocork(gid3) < 0) TEST_ERROR
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0)
+ TEST_ERROR;
+ }
+ if(H5Aclose(aid) < 0 ) TEST_ERROR;
+ } /* end for */
+
+ /* Verify cork status of the third group: GRP3 */
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Gclose(gid) < 0) TEST_ERROR;
+ if(H5Gclose(gid2) < 0) TEST_ERROR;
+ if(H5Gclose(gid3) < 0) TEST_ERROR;
+ if(H5Sclose(sid) < 0) TEST_ERROR;
+ if(H5Pclose(fapl) < 0) TEST_ERROR;
+ if(H5Fclose(fid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid);
+ H5Gclose(gid2);
+ H5Gclose(gid3);
+ H5Sclose(sid);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* verify_group_cork */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_named_cork
+ *
+ * Purpose: This function verifies corking operations for named datatypes.
+ * Cache entries associated with the object tag are checked
+ * for the correct cork status.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_named_cork(hbool_t swmr)
+{
+ /* Variable Declarations */
+ int verbose = FALSE; /* Verbose file outout */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
+ hid_t tid = -1, tid2 = -1, tid3 = -1; /* Datatype IDs */
+ hid_t gid = -1, gid2 = -1; /* Group IDs */
+ H5O_info_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t did; /* Dataset ID */
+ char attrname[500]; /* Name of attribute */
+ unsigned flags; /* File access flags */
+ int i = 0; /* Local index variable */
+
+ /* Testing Macro */
+ if(swmr) {
+ TESTING("cork status for named datatypes (SWMR)");
+ } else {
+ TESTING("cork status for named datatypes");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 )
+ TEST_ERROR;
+ /* Set to use latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR;
+
+ /* Create the file */
+ flags = H5F_ACC_TRUNC;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0 )
+ TEST_ERROR;
+
+ /* Create 3 copies of datatypes */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+ if((tid2 = H5Tcopy(H5T_NATIVE_LONG)) < 0) TEST_ERROR;
+ if((tid3 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) TEST_ERROR;
+
+ /* Commit datatype /DT */
+ if(H5Tcommit2(fid, DT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* Create /GRP */
+ if((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ /* Commit datatype /GRP/DT2 */
+ if(H5Tcommit2(gid, DT2, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* Create /GRP/GRP2 */
+ if((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ /* Commit datatype /GRP/GRP2/DT3 */
+ if(H5Tcommit2(gid2, DT3, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* Cork 2 named datatypes: /DT and /GRP/GRP2/DT3 */
+ if(H5Ocork(tid) < 0) TEST_ERROR
+ if(H5Ocork(tid3) < 0) TEST_ERROR
+
+ /* Get named datatype object header addresses */
+ if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR;
+ if(H5Oget_info(tid2, &oinfo2) < 0) TEST_ERROR;
+ if(H5Oget_info(tid3, &oinfo3) < 0) TEST_ERROR;
+
+ /* Verify cork status of the named datatypes */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0)
+ TEST_ERROR;
+ if(verify_cork_tag(fid, oinfo2.addr, FALSE) < 0)
+ TEST_ERROR;
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Close the datatypes */
+ if(H5Tclose(tid) < 0 ) TEST_ERROR;
+ if(H5Tclose(tid2) < 0 ) TEST_ERROR;
+ if(H5Tclose(tid3) < 0 ) TEST_ERROR;
+
+ /* Re-open the named datatypes */
+ if((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify cork status of the named datatypes */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0)
+ TEST_ERROR;
+ if(verify_cork_tag(fid, oinfo2.addr, FALSE) < 0)
+ TEST_ERROR;
+ if(verify_cork_tag(fid, oinfo3.addr, FALSE) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Tclose(tid) < 0 ) TEST_ERROR;
+ if(H5Tclose(tid2) < 0 ) TEST_ERROR;
+ if(H5Tclose(tid3) < 0 ) TEST_ERROR;
+ if(H5Gclose(gid) < 0 ) TEST_ERROR;
+ if(H5Gclose(gid2) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+
+
+ /* Re-open the file and the three groups */
+ flags = H5F_ACC_RDWR;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid = H5Fopen(FILENAME, flags, fapl)) < 0 )
+ FAIL_STACK_ERROR
+ if((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open the named datatypes */
+ if((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Cork the datatype: DT2 */
+ if(H5Ocork(tid2) < 0) TEST_ERROR
+
+ /* Create dataspace */
+ if((sid = H5Screate(H5S_SCALAR)) < 0 ) TEST_ERROR;
+
+ /* Attach 8 attributes to datatype: DT3 */
+ for(i = 0;i < 8; i++) {
+ sprintf(attrname, "attr %d", i);
+ if((aid = H5Acreate2(tid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 )
+ TEST_ERROR;
+ if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
+ TEST_ERROR;
+ /* Cork the datatype while attaching attributes */
+ if(i == 3) {
+ if(H5Ocork(tid3) < 0) TEST_ERROR
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0)
+ TEST_ERROR;
+ }
+ if(H5Aclose(aid) < 0 ) TEST_ERROR;
+ } /* end for */
+
+ /* Create a dataset with named datatype: DT */
+ if((did = H5Dcreate2(fid, DSET, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get dataset object header address */
+ if(H5Oget_info(did, &oinfo4) < 0) TEST_ERROR;
+
+ /* Cork the dataset: DSET */
+ if(H5Ocork(did) < 0) TEST_ERROR
+
+ /* Verify cork status of the datatype: DT */
+ if(verify_cork_tag(fid, oinfo.addr, FALSE) < 0)
+ TEST_ERROR;
+ /* Verify cork status of the datatype: DT2 */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0)
+ TEST_ERROR;
+ /* Verify cork status of the datatype: DT3 */
+ if(verify_cork_tag(fid, oinfo3.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Un-cork the datatype: DT3 */
+ if(H5Ouncork(tid3) < 0) TEST_ERROR
+ /* Verify cork status of the datatype: DT3 */
+ if(verify_cork_tag(fid, oinfo3.addr, FALSE) < 0)
+ TEST_ERROR;
+
+ /* Cork the datatype: DT */
+ if(H5Ocork(tid) < 0) TEST_ERROR
+
+ /* Verify cork status of the datatype: DT */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0)
+ TEST_ERROR;
+ /* Verify cork status of the datatype: DT2 */
+ if(verify_cork_tag(fid, oinfo2.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo4.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Close the dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* Verify cork status of the datatype: DT */
+ if(verify_cork_tag(fid, oinfo.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Verify cork status of the dataset: DSET */
+ if(verify_cork_tag(fid, oinfo4.addr, FALSE) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Tclose(tid) < 0 ) TEST_ERROR;
+ if(H5Tclose(tid2) < 0 ) TEST_ERROR;
+ if(H5Tclose(tid3) < 0 ) TEST_ERROR;
+ if(H5Gclose(gid) < 0 ) TEST_ERROR;
+ if(H5Gclose(gid2) < 0 ) TEST_ERROR;
+ if(H5Sclose(sid) < 0 ) TEST_ERROR;
+ if(H5Fclose(fid) < 0 ) TEST_ERROR;
+ if(H5Pclose(fapl) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid3);
+ H5Gclose(gid);
+ H5Gclose(gid2);
+ H5Dclose(did);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* verify_named_cork */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_multiple_cork
+ *
+ * Purpose: This function verifies corking operations when there are
+ * multiple opens of files, objects, attributes.
+ * (based on test_attr_bug5() in tattr.c)
+ * Cache entries associated with the object tag are checked
+ * for the correct cork status.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+verify_multiple_cork(hbool_t swmr)
+{
+ /* Variable Declarations */
+ int verbose = FALSE; /* Verbose file outout */
+ hid_t fid1 = -1, fid2 = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
+ hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */
+ hid_t gid1 = -1, gid2 = -1; /* Group IDs */
+ hid_t did1 = -1, did2 = -1; /* Dataset ID */
+ hid_t aidg1 = -1, aidg2 = -1; /* Attribute ID */
+ hid_t aidd1 = -1, aidd2 = -1; /* Attribute ID */
+ hid_t aidt1 = -1, aidt2 = -1; /* Attribute ID */
+ hid_t sid = -1; /* Dataspace ID */
+ H5O_info_t oinfo1, oinfo2, oinfo3; /* Object metadata information */
+ hsize_t dim[1] = {5}; /* Dimension sizes */
+ unsigned flags; /* File access flags */
+ hbool_t corked; /* Cork status */
+ herr_t ret; /* Return value */
+
+ /* Testing Macro */
+ if(swmr) {
+ TESTING("cork status for multiple opens (SWMR)");
+ } else {
+ TESTING("cork status for multiple opens");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 )
+ TEST_ERROR
+ /* Set to use latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR
+
+ /* Create the file */
+ flags = H5F_ACC_TRUNC;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid1 = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0 )
+ TEST_ERROR
+
+ /* Open root group */
+ if((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create and commit datatype */
+ if((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0)
+ TEST_ERROR
+ if(H5Tcommit2(fid1, DT, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Create dataset */
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ TEST_ERROR
+ if((did1 = H5Dcreate2(fid1, DSET, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create attribute on root group */
+ if((aidg1 = H5Acreate2(gid1, GRP_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create attribute on dataset */
+ if((aidd1 = H5Acreate2(did1, DSET_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create attribute on datatype */
+ if((aidt1 = H5Acreate2(tid1, DT_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Aclose(aidt1) < 0) TEST_ERROR
+ if(H5Aclose(aidd1) < 0) TEST_ERROR
+ if(H5Aclose(aidg1) < 0) TEST_ERROR
+ if(H5Dclose(did1) < 0) TEST_ERROR
+ if(H5Tclose(tid1) < 0) TEST_ERROR
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+ if(H5Fclose(fid1) < 0) TEST_ERROR
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* Open the file twice: fid1, fid2 */
+ flags = H5F_ACC_RDWR;
+ if(swmr)
+ flags |= H5F_ACC_SWMR_WRITE;
+ if((fid1 = H5Fopen(FILENAME, flags, fapl)) < 0)
+ TEST_ERROR
+ if((fid2 = H5Fopen(FILENAME, flags, fapl)) < 0)
+ TEST_ERROR
+
+ /* Open the root group twice: gid1, gid2 */
+ if((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((gid2 = H5Gopen2(fid2, "/", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Open the root group attribute twice: aidg1, aidg2 */
+ if((aidg1 = H5Aopen(gid1, GRP_ATTR, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((aidg2 = H5Aopen(gid2, GRP_ATTR, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Cork the group: gid2 */
+ if(H5Ocork(gid2) < 0)
+ TEST_ERROR
+
+ /* Verify cork status of the group: gid2 */
+ if(H5Oget_info(gid2, &oinfo1) < 0) TEST_ERROR;
+ if(verify_cork_tag(fid2, oinfo1.addr, TRUE) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the group: gid1 */
+ if(H5Ois_corked(gid1, &corked) < 0)
+ TEST_ERROR;
+ if(!corked) TEST_ERROR
+
+ /* Open the dataset twice: did1, did2 */
+ if((did1 = H5Dopen2(fid1, DSET, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((did2 = H5Dopen2(fid2, DSET, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Open the dataset attribute twice: aidd1, aidd2 */
+ if((aidd1 = H5Aopen(did1, DSET_ATTR, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((aidd2 = H5Aopen(did2, DSET_ATTR, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Cork the dataset: did1 */
+ if(H5Ocork(did1) < 0)
+ TEST_ERROR
+
+ /* Verify cork status of the dataset: did1 */
+ if(H5Oget_info(did1, &oinfo2) < 0) TEST_ERROR;
+ if(verify_cork_tag(fid1, oinfo2.addr, TRUE) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset: did2 */
+ if(H5Ois_corked(did2, &corked) < 0)
+ TEST_ERROR;
+ if(!corked) TEST_ERROR
+
+ /* Open the datatype twice: tid1, tid2 */
+ if((tid1 = H5Topen2(fid1, DT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((tid2 = H5Topen2(fid2, DT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Open the datatype attribute twice: aidt1, aidt2 */
+ if((aidt1 = H5Aopen(tid1, DT_ATTR, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((aidt2 = H5Aopen(tid2, DT_ATTR, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Cork the datatype: tid2 */
+ if(H5Ocork(tid2) < 0)
+ TEST_ERROR
+
+ /* Verify cork status of the datatype: tid2 */
+ if(H5Oget_info(tid2, &oinfo3) < 0) TEST_ERROR;
+ if(verify_cork_tag(fid2, oinfo3.addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* Check cork status of the datatype: tid1 */
+ if(H5Ois_corked(tid1, &corked) < 0)
+ TEST_ERROR;
+ if(!corked) TEST_ERROR
+
+ /* Uncork the group: gid1 */
+ if(H5Ouncork(gid1) < 0)
+ TEST_ERROR
+
+ /* Verify cork status of the group: gid1 */
+ if(H5Oget_info(gid1, &oinfo1) < 0) TEST_ERROR;
+ if(verify_cork_tag(fid1, oinfo1.addr, FALSE) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the group: gid2 */
+ if(H5Ois_corked(gid2, &corked) < 0)
+ TEST_ERROR;
+ if(corked) TEST_ERROR
+
+ /* Close the group: gid2 */
+ if(H5Gclose(gid2) < 0) TEST_ERROR
+
+ /* Check cork status of the group: gid1 */
+ if(H5Ois_corked(gid1, &corked) < 0)
+ TEST_ERROR;
+ if(corked) TEST_ERROR
+
+ /* Verify cork status of the group: gid1 */
+ if(verify_cork_tag(fid1, oinfo1.addr, FALSE) < 0)
+ TEST_ERROR
+
+ /* Close the group: gid1 */
+ if(H5Gclose(gid1) < 0) TEST_ERROR
+
+ /* Uncork the dataset: gid2 */
+ if(H5Ouncork(did2) < 0)
+ TEST_ERROR
+
+ /* Verify cork status of the dataset: did2 */
+ if(H5Oget_info(did2, &oinfo2) < 0) TEST_ERROR;
+ if(verify_cork_tag(fid2, oinfo2.addr, FALSE) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset: did1 */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR;
+ if(corked) TEST_ERROR
+
+ /* Close the dataset: did2 */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* Check cork status of the dataset: did1 */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR;
+ if(corked) TEST_ERROR
+
+ /* Verify cork status of the dataset: did1 */
+ if(verify_cork_tag(fid1, oinfo2.addr, FALSE) < 0)
+ TEST_ERROR
+
+ /* Close the dataset: did1 */
+ if(H5Dclose(did1) < 0) TEST_ERROR
+
+ /* Check cork status of the datatype: tid1 */
+ if(H5Ois_corked(tid1, &corked) < 0)
+ TEST_ERROR;
+ if(!corked) TEST_ERROR
+
+ /* Close datatype: tid1 */
+ if(H5Tclose(tid1) < 0) TEST_ERROR
+
+ /* Check cork status of the datatype: tid2 */
+ if(H5Ois_corked(tid2, &corked) < 0)
+ TEST_ERROR;
+ if(!corked) TEST_ERROR
+
+ /* Close datatype: tid2 */
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+
+ /* Should fail to cork the attribute: aidg2; not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ocork(aidg2);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Should fail to uncork the attribute: aidd1; not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ocork(aidd1);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Should fail to check cork status of the attribute: aidt2; not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ois_corked(aidt2, &corked);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Close all attributes */
+ if(H5Aclose(aidg1) < 0) TEST_ERROR
+ if(H5Aclose(aidg2) < 0) TEST_ERROR
+ if(H5Aclose(aidd1) < 0) TEST_ERROR
+ if(H5Aclose(aidd2) < 0) TEST_ERROR
+ if(H5Aclose(aidt1) < 0) TEST_ERROR
+ if(H5Aclose(aidt2) < 0) TEST_ERROR
+
+ /* Should fail to cork the file: fid1; not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ois_corked(fid1, &corked);
+ ret = H5Ocork(fid1);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Should fail to uncork the file: fid2; not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ouncork(fid2);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Pclose(fapl) < 0) TEST_ERROR
+ if(H5Fclose(fid1) < 0) TEST_ERROR
+ if(H5Fclose(fid2) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid1);
+ H5Tclose(tid2);
+ H5Gclose(gid1);
+ H5Gclose(gid2);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Aclose(aidg1);
+ H5Aclose(aidg2);
+ H5Aclose(aidd1);
+ H5Aclose(aidt1);
+ H5Aclose(aidt2);
+ H5Aclose(aidd2);
+ H5Pclose(fapl);
+ H5Fclose(fid1);
+ H5Fclose(fid1);
+ } H5E_END_TRY;
+ return 1;
+} /* verify_multiple_cork */
+
+/*-------------------------------------------------------------------------
+ * Function: test_objs_cork
+ *
+ * Purpose: This function verifies H5Ocork/H5Ouncork/H5Ois_corked public
+ * routines are working as specified.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_objs_cork(hbool_t newformat)
+{
+ hid_t fid; /* HDF5 File ID */
+ hid_t fapl; /* File access property list */
+ hid_t gid, did, tid; /* Object IDs */
+ hid_t sid; /* Dataspace ID */
+ hid_t aid; /* Attribute ID */
+ hsize_t dims[RANK]; /* Dataset dimension sizes */
+ hbool_t corked; /* Cork status of an object */
+ herr_t ret; /* Return value */
+
+ /* Testing Macro */
+ if(newformat) {
+ TESTING("H5Ocork/H5Ouncork/H5Ois_corked (new library format)");
+ } else {
+ TESTING("H5Ocork/H5Ouncork/H5Ois_corked (old library format)");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 )
+ TEST_ERROR;
+
+ /* Set to use latest format */
+ if(newformat) {
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR;
+ }
+
+ /* Create an HDF5 file */
+ if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create group */
+ if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the group: not corked */
+ if(H5Ois_corked(gid, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Cork the group: an object */
+ if(H5Ocork(gid) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the group: corked */
+ if(H5Ois_corked(gid, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the group */
+ if(H5Gclose(gid) < 0)
+ TEST_ERROR
+
+ /* Create a transient copy of a native type */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ TEST_ERROR
+
+ /* Should fail to cork the datatype: not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ocork(tid);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Create a named datatype */
+ if(H5Tcommit2(fid, "group/datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the named datatype: not corked */
+ if(H5Ois_corked(tid, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Cork the named datatype: an object */
+ if(H5Ocork(tid) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the named datatype: corked */
+ if(H5Ois_corked(tid, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the named datatype */
+ if(H5Tclose(tid) < 0)
+ TEST_ERROR
+
+ /* Create dataspace */
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ if((sid = H5Screate_simple(RANK, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Should fail to uncork the dataspace: not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ouncork(sid);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Create dataset. */
+ if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create attribute on the dataset */
+ if((aid = H5Acreate2(did, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Should fail to check cork status of the attribute: not an object */
+ H5E_BEGIN_TRY {
+ ret = H5Ois_corked(aid, &corked);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset: not corked */
+ if(H5Ois_corked(did, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Cork the dataset: an object */
+ if(H5Ocork(did) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset: corked */
+ if(H5Ois_corked(did, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the dataset and dataspace */
+ if(H5Dclose(did) < 0)
+ TEST_ERROR
+
+ /* Open the group */
+ if((gid = H5Oopen(fid, "group", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the group */
+ if(H5Ois_corked(gid, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Cork the group */
+ if(H5Ocork(gid) < 0)
+ TEST_ERROR
+
+ /* Should fail to cork the group again */
+ H5E_BEGIN_TRY {
+ ret = H5Ocork(gid);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Check cork status of the group */
+ if(H5Ois_corked(gid, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Open the named datatype */
+ if((tid = H5Oopen(fid, "group/datatype", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the named datatype */
+ if(H5Ois_corked(tid, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Should fail to un-cork the named datatype that is not corked yet */
+ H5E_BEGIN_TRY {
+ ret = H5Ouncork(tid);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Cork the named datatype */
+ if(H5Ocork(tid) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the named datatype */
+ if(H5Ois_corked(tid, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Open the dataset */
+ if((did = H5Oopen(fid, "/dataset", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset */
+ if(H5Ois_corked(did, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Cork the dataset */
+ if(H5Ocork(did) < 0)
+ TEST_ERROR
+
+ /* Check cork status of dataset */
+ if(H5Ois_corked(did, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Un-cork the dataset */
+ if(H5Ouncork(did) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset */
+ if(H5Ois_corked(did, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Closing */
+ if(H5Tclose(tid) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Sclose(sid) < 0) TEST_ERROR
+ if(H5Aclose(aid) < 0) TEST_ERROR
+ if(H5Pclose(fapl) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Aclose(aid);
+ H5Dclose(did);
+ H5Gclose(gid);
+ H5Tclose(tid);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+
+} /* test_objs_cork() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_dset_cork
+ *
+ * Purpose: This function verifies H5Ocork/H5Ouncork/H5Ois_corked are
+ * working as specified when manipulating datasets.
+ *
+ * Return: 0 on Success, 1 on Failure
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_dset_cork(hbool_t newformat)
+{
+ hid_t fid; /* File ID */
+ hid_t fapl; /* File access property list */
+ hid_t gid; /* Groupd ID */
+ hid_t did1, did2; /* Dataset IDs */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t sid; /* Dataspace ID */
+ hid_t dcpl; /* Dataset creation property list */
+ hsize_t dims[RANK]; /* Dataset dimensions */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */
+ hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */
+ int fillval = 0; /* Fill value */
+ int i, j, k = 0; /* Local index variables */
+ int data[DIMS0][DIMS1]; /* Data buffer */
+ int rbuf[DIMS0][DIMS1]; /* Data buffer */
+ hbool_t corked; /* Cork status of an object */
+ herr_t ret; /* Value returned from API calls */
+
+ /* Testing Macro */
+ if(newformat) {
+ TESTING("H5Ocork/H5Ouncork/H5Ois_corked (new library format)");
+ } else {
+ TESTING("H5Ocork/H5Ouncork/H5Ois_corked (old library format)");
+ }
+
+ /* Create fapl */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
+
+ /* Set to use latest format */
+ if(newformat) {
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 )
+ TEST_ERROR;
+ }
+
+ /* Create a new HDF5 file */
+ if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create a group */
+ if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Commit the datatype with the group */
+ if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ TEST_ERROR
+ if(H5Tcommit2(gid, "datatype", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Cork the named datatype */
+ if(H5Ocork(tid1) < 0)
+ TEST_ERROR
+
+ /* Set up dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR
+
+ /* Enable chunking */
+ if(H5Pset_chunk(dcpl, RANK, cdims) < 0)
+ TEST_ERROR
+
+ /* Set up a fill value */
+ if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0)
+ TEST_ERROR
+
+ /* Create dataspace */
+ dims[0] = DIMS0;
+ dims[1] = DIMS1;
+ if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ TEST_ERROR
+
+ /* Create the dataset inside the group with the named datatype */
+ if((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the named datatype */
+ if(H5Ois_corked(tid1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Cork the dataset */
+ if(H5Ocork(did1) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Check cork status of the group */
+ if(H5Ois_corked(gid, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Initialize the buffer */
+ for(i = 0; i < DIMS0;i++)
+ for(j = 0;j < DIMS1;j++)
+ data[i][j] = k++;
+
+ /* Write to the dataset */
+ if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0)
+ TEST_ERROR
+
+ /* Flush the dataset */
+ if(H5Oflush(did1) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Check cork status of the named datatype */
+ if(H5Ois_corked(tid1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the dataset */
+ if(H5Dclose(did1) < 0)
+ TEST_ERROR
+
+ /* Open the dataset again */
+ if((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Read from the dataset */
+ if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ TEST_ERROR
+
+ /* Cork the dataset */
+ if(H5Ocork(did1) < 0)
+ TEST_ERROR
+
+ /* Delete the dataset */
+ if(H5Ldelete(gid, "dataset", H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the dataset */
+ if(H5Oclose(did1) < 0) TEST_ERROR
+
+ /* Create the dataset again */
+ if((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Cork the dataset */
+ if(H5Ocork(did1) < 0)
+ TEST_ERROR
+
+ /* Write to the dataset */
+ if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0)
+ TEST_ERROR
+
+ /* Refresh the dataset */
+ if(H5Drefresh(did1) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the dataset */
+ if(H5Dclose(did1) < 0) TEST_ERROR
+
+ /* First open of the dataset */
+ if((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Second open of the dataset */
+ if((did2 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Cork the first opened dataset */
+ if(H5Ocork(did1) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the first opened dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Check cork status of the second opened dataset */
+ if(H5Ois_corked(did2, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the second opened dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* Check cork status of the first opened dataset */
+ if(H5Ois_corked(did1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Close the first opened dastaset */
+ if(H5Dclose(did1) < 0) TEST_ERROR
+
+ /* Check cork status of the named datatype */
+ if(H5Ois_corked(tid1, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Second open of the named datatype */
+ if((tid2 = H5Topen2(gid, "datatype", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the second opened named datatype */
+ if(H5Ois_corked(tid2, &corked) < 0)
+ TEST_ERROR
+ if(!corked) TEST_ERROR
+
+ /* Uncork the second opened named datatype */
+ if(H5Ouncork(tid2) < 0)
+ TEST_ERROR
+
+ /* Check cork status of the second opened named datatype */
+ if(H5Ois_corked(tid2, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Check cork status of the first opened named datatype */
+ if(H5Ois_corked(tid1, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Close the first opened datatype */
+ if(H5Tclose(tid1) < 0) TEST_ERROR
+
+ /* Close the second opened datatype */
+ if(H5Tclose(tid2) < 0) TEST_ERROR
+
+ /* Check cork status of the group */
+ if(H5Ois_corked(gid, &corked) < 0)
+ TEST_ERROR
+ if(corked) TEST_ERROR
+
+ /* Closing */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Sclose(sid) < 0) TEST_ERROR
+ if(H5Pclose(fapl) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Tclose(tid1);
+ H5Tclose(tid2);
+ H5Pclose(dcpl);
+ H5Gclose(gid);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+
+} /* test_dset_cork() */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Run tests to verify the library's corking operations.
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Vailin Choi; Feb 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ unsigned nerrs = 0; /* Error Encountered */
+
+ /* Test for dataset created with old library format */
+ nerrs += verify_old_dset_cork();
+
+ /* Tests with new/old library format */
+ /* This is the test moved from th5o.c: test_h5o_cork() */
+ nerrs += test_objs_cork(TRUE);
+ nerrs += test_objs_cork(FALSE);
+ /* This is the test moved from th5o.c: test_h5o_cork_dataset() */
+ nerrs += test_dset_cork(TRUE);
+ nerrs += test_dset_cork(FALSE);
+
+ /* Tests with/without SWMR access */
+ nerrs += verify_obj_dset_cork(TRUE);
+ nerrs += verify_obj_dset_cork(FALSE);
+ nerrs += verify_dset_cork(TRUE);
+ nerrs += verify_dset_cork(FALSE);
+ nerrs += verify_group_cork(TRUE);
+ nerrs += verify_group_cork(FALSE);
+ nerrs += verify_named_cork(TRUE);
+ nerrs += verify_named_cork(FALSE);
+ nerrs += verify_multiple_cork(TRUE);
+ nerrs += verify_multiple_cork(FALSE);
+
+ /* Delete test files */
+ HDremove(FILENAME);
+
+ /* Return Errors */
+ return(nerrs > 0);
+
+} /* main */
diff --git a/test/swmr_start_write.c b/test/swmr_start_write.c
index 86742b5..72e9ba9 100644
--- a/test/swmr_start_write.c
+++ b/test/swmr_start_write.c
@@ -42,6 +42,7 @@
static hid_t create_file(const char *filename, unsigned verbose,
const char *index_type, unsigned random_seed);
+static int create_datasets(hid_t fid, int comp_level, unsigned verbose);
static int create_close_datasets(hid_t fid, int comp_level, unsigned verbose);
static int open_datasets(hid_t fid, unsigned verbose);
static hid_t open_file(const char *filename, unsigned verbose);
@@ -103,38 +104,10 @@ create_file(const char *filename, unsigned verbose,
if(!strcmp(index_type, "b2"))
max_dims[0] = H5S_UNLIMITED;
-#ifdef QAK
- /* Increase the initial size of the metadata cache */
- {
- H5AC_cache_config_t mdc_config;
-
- mdc_config.version = H5AC__CURR_CACHE_CONFIG_VERSION;
- H5Pget_mdc_config(fapl, &mdc_config);
- fprintf(stderr, "mdc_config.initial_size = %lu\n", (unsigned long)mdc_config.initial_size);
- fprintf(stderr, "mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length);
- mdc_config.set_initial_size = 1;
- mdc_config.initial_size = 16 * 1024 * 1024;
- /* mdc_config.epoch_length = 5000; */
- H5Pset_mdc_config(fapl, &mdc_config);
- }
-#endif /* QAK */
-
-#ifdef QAK
- H5Pset_small_data_block_size(fapl, (hsize_t)(50 * CHUNK_SIZE * DTYPE_SIZE));
-#endif /* QAK */
-
-#ifdef QAK
- H5Pset_fapl_log(fapl, "append.log", H5FD_LOG_ALL, (size_t)(512 * 1024 * 1024));
-#endif /* QAK */
-
/* Create file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
return -1;
-#ifdef QAK
- H5Pset_link_phase_change(fcpl, 0, 0);
-#endif /* QAK */
-
/* Emit informational message */
if(verbose)
fprintf(stderr, "Creating file without SWMR access\n");
@@ -168,6 +141,69 @@ create_file(const char *filename, unsigned verbose,
/*-------------------------------------------------------------------------
+ * Function: create_datasets
+ *
+ * Purpose: Create datasets (and keep them opened) which will be used for testing
+ * H5Fstart_swmr_write().
+ *
+ * Parameters:
+ * fid: file ID for the SWMR test file
+ * comp_level: the compresssion level
+ * verbose: whether verbose console output is desired.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+create_datasets(hid_t fid, int comp_level, unsigned verbose)
+{
+ hid_t dcpl; /* Dataset creation property list */
+ hid_t tid; /* Datatype for dataset elements */
+ hid_t sid; /* Dataspace ID */
+ hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */
+ hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */
+ hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */
+ unsigned u, v; /* Local index variable */
+
+ /* Create datatype for creating datasets */
+ if((tid = create_symbol_datatype()) < 0)
+ return -1;
+
+ /* Create dataspace for creating datasets */
+ if((sid = H5Screate_simple(2, dims, max_dims)) < 0)
+ return -1;
+
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ return -1;
+ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ return -1;
+ if(comp_level >= 0) {
+ if(H5Pset_deflate(dcpl, (unsigned)comp_level) < 0)
+ return -1;
+ } /* end if */
+
+ /* Emit informational message */
+ if(verbose)
+ fprintf(stderr, "Creating datasets\n");
+
+ /* Create the datasets */
+ for(u = 0; u < NLEVELS; u++)
+ for(v = 0; v < symbol_count[u]; v++) {
+
+ if((symbol_info[u][v].dsid = H5Dcreate2(fid, symbol_info[u][v].name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ return -1;
+ symbol_info[u][v].nrecords = 0;
+
+ } /* end for */
+
+ return 0;
+} /* create_datasets() */
+
+
+/*-------------------------------------------------------------------------
* Function: create_close_datasets
*
* Purpose: Create and close datasets which will be used for testing
@@ -394,11 +430,6 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f
/* Get the coordinate to write */
start[1] = symbol->nrecords;
- /* Cork the metadata cache, to prevent the object header from being
- * flushed before the data has been written */
- /*if(H5Fset_mdc_config(fid, &mdc_config_cork) < 0)
- return(-1);*/
-
/* Extend the dataset's dataspace to hold the new record */
symbol->nrecords++;
dim[1] = symbol->nrecords;
@@ -417,10 +448,6 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f
if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0)
return -1;
- /* Uncork the metadata cache */
- /*if(H5Fset_mdc_config(fid, &mdc_config_orig) < 0)
- return -1;*/
-
/* Close the dataset's dataspace */
if(H5Sclose(file_sid) < 0)
return -1;
@@ -490,15 +517,11 @@ usage(void)
} /* usage() */
/*
- * Can test with different scenarios as listed below. Scenario (1) is tested here.
- * 1) create_file(), create_close_datasets(), H5Fstart_swmr_write(), open_datasets(), add_records(), H5Fclose().
- * 2) create_file(), H5Fstart_swmr_write(), create_close_datasets(), open_datasets(), add_records(), H5Fclose().
- * 3) create_file(), H5Fclose(),
- * open_file(), create_close_datasets(), H5Fstart_swmr_write(), open_datasets(), add_records(), H5Fclose().
- * 4) create_file(), create_close_datasets(), H5Fclose(),
- * open_file(), H5Fstart_swmr_write(), open_datasets(), add_records(), H5Fclose().
- * 5) create_file(), H5Fclose(),
- * open_file(), H5Fstart_swmr_write(), create_close_datasets(), open_datasets(), add_records(), H5Fclose().
+ * Can test with different scenarios as below:
+ * 1) create_file(), create_datasets(), H5Fstart_swmr_write(), add_records(), H5Fclose().
+ * 2) create_file(), create_close_datasets(), open_datasets(), H5Fstart_swmr_write(), add_records(), H5Fclose().
+ * 3) create_file(), create_close_datasets(), H5Fclose(),
+ * open_file(), open_dataset(), H5Fstart_swmr_write(), add_records(), H5Fclose().
*/
int main(int argc, const char *argv[])
{
@@ -609,13 +632,36 @@ int main(int argc, const char *argv[])
exit(1);
}
- /* Create and close the datasets in the file */
- if(create_close_datasets(fid, comp_level, verbose) < 0) {
+ /* Emit informational message */
+ if(verbose)
+ fprintf(stderr, "Generating symbol names\n");
+
+ /* Generate dataset names */
+ if(generate_symbols() < 0)
+ return -1;
+
+ /* Create the datasets in the file */
+ if(create_datasets(fid, comp_level, verbose) < 0) {
fprintf(stderr, "Error creating datasets...\n");
exit(1);
}
+ /* Enable SWMR writing mode */
+ if(H5Fstart_swmr_write(fid) < 0) {
+ fprintf(stderr, "Error starting SWMR writing mode...\n");
+ exit(1);
+ }
+
#ifdef OUT
+ /* Emit informational message */
+ if(verbose)
+ fprintf(stderr, "Creating and closing datasets: %s\n", FILENAME);
+
+ /* Create and close the datasets in the file */
+ if(create_close_datasets(fid, comp_level, verbose) < 0) {
+ fprintf(stderr, "Error creating datasets...\n");
+ exit(1);
+ }
/* Close the file */
if(H5Fclose(fid) < 0) {
@@ -628,13 +674,7 @@ int main(int argc, const char *argv[])
fprintf(stderr, "Error opening the file...\n");
exit(1);
}
-#endif
- /* Enable SWMR writing mode */
- if(H5Fstart_swmr_write(fid) < 0) {
- fprintf(stderr, "Error starting SWMR writing mode...\n");
- exit(1);
- }
/* Emit informational message */
if(verbose)
@@ -654,6 +694,14 @@ int main(int argc, const char *argv[])
exit(1);
} /* end if */
+
+ /* Enable SWMR writing mode */
+ if(H5Fstart_swmr_write(fid) < 0) {
+ fprintf(stderr, "Error starting SWMR writing mode...\n");
+ exit(1);
+ }
+#endif
+
/* Send a message to indicate "H5Fopen" is complete--releasing the file lock */
h5_send_message(WRITER_MESSAGE);
diff --git a/test/test_swmr.c b/test/test_swmr.c
index 45dd794..76def9e 100644
--- a/test/test_swmr.c
+++ b/test/test_swmr.c
@@ -17,7 +17,9 @@
*
* Test program: test_swmr
*
-* To test SWMR related public routines:
+* To test new public routines from SWMR project:
+* H5Pget/set_metadata_read_attempts()
+* H5Fget_metadata_read_retry_info()
* H5Fstart_swmr_write()
* H5Pget/set_object_flush_cb()
* H5Pget/set_append_flush()
@@ -27,6 +29,7 @@
#include "hdf5.h"
#include "h5test.h"
#include "H5srcdir.h"
+#include "H5Iprivate.h"
/*
* This file needs to access private information from the H5F package.
@@ -36,6 +39,7 @@
#define H5F_TESTING
#include "H5Fpkg.h" /* File access */
+
const char *FILENAME[] = {
"test_swmr", /* 0 */
NULL
@@ -46,6 +50,10 @@ const char *FILENAME[] = {
/* Name of message file that is used by test_start_swmr_write_concur() */
#define DONE_MESSAGE "DONE_MESSAGE" /* The message file to create */
+/* Tests for H5Pget/set_metadata_read_attempts(), H5Fget_metadata_read_retry_info */
+static int test_metadata_read_attempts(hid_t in_fapl);
+static int test_metadata_read_retry_info(hid_t in_fapl);
+
/* Tests for H5Fstart_swmr_write() */
static int test_start_swmr_write(hid_t in_fapl);
static int test_err_start_swmr_write(hid_t in_fapl);
@@ -63,28 +71,1375 @@ static int test_append_flush_dataset_chunked(hid_t in_fapl);
static int test_append_flush_dataset_fixed(hid_t in_fapl);
static int test_append_flush_dataset_multiple(hid_t in_fapl);
+
+/*
+ * Tests for H5Pget/set_metadata_read_attemps(), H5Fget_metadata_read_retry_info()
+ */
+
+/*
+ * test_metadata_read_attempts():
+ *
+ * Checks the following two public routines work as specified:
+ * H5Pset_metadata_read_attempts()
+ * H5Pget_metadata_read_attempts()
+ */
+static int
+test_metadata_read_attempts(hid_t in_fapl)
+{
+ hid_t fapl; /* File access property list */
+ hid_t file_fapl; /* The file's access property list */
+ hid_t fid, fid1, fid2; /* File IDs */
+ unsigned attempts; /* The # of read attempts */
+ char filename[NAME_BUF_SIZE]; /* File name */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ TESTING("H5Pget/set_metadata_read_attempts()");
+
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /*
+ * Set A:
+ * Tests on verifying the # of read attempts when:
+ * --setting/getting read attempts from a
+ * file access property list.
+ */
+ /* Get # of read attempts -- should be the default: 1 */
+ if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != 1) TEST_ERROR
+
+ /* Set the # of read attempts to 0--should fail */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_metadata_read_attempts(fapl, 0);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Set the # of read attempts to a # > 0--should succeed */
+ if(H5Pset_metadata_read_attempts(fapl, 9) < 0)
+ TEST_ERROR
+
+ /* Retrieve the # of read attempts -- should be 9 */
+ if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != 9) TEST_ERROR
+
+ /* Set the # of read attempts to the default for non-SWMR access: H5F_METADATA_READ_ATTEMPTS --should succeed */
+ if(H5Pset_metadata_read_attempts(fapl, H5F_METADATA_READ_ATTEMPTS) < 0)
+ TEST_ERROR
+
+ /* Retrieve the # of read attempts -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Set the # of read attempts to the default for SWMR access: H5F_SWMR_METADATA_READ_ATEMPTS --should succeed */
+ if(H5Pset_metadata_read_attempts(fapl, H5F_SWMR_METADATA_READ_ATTEMPTS) < 0)
+ TEST_ERROR
+
+ /* Retrieve the # of read attempts -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Set B:
+ * Tests on verifying read attempts when:
+ * --create a file with non-SWMR access
+ * --opening files with SWMR access
+ * --using default or non-default file access property list
+ */
+ /* Test 1 */
+ /* Create a file with non-SWMR access and default fapl */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 2 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access and default read attempts */
+ if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 3 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 9) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access and fapl (non-default & set to 9) */
+ if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be 9 */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != 9) TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 4 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access and fapl (non-default & set to 1) */
+ if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be 1 */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != 1) TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 5 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR_READ and fapl (non-default read attempts but unset) */
+ if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Set C:
+ * Tests on verifying read attempts when:
+ * --create a file with SWMR access
+ * --opening files with non-SWMR access
+ * --using default or non-default file access property list
+ */
+ /* Test 1 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a file with non-SWMR access and default read attempts */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 2 */
+ /* Open the file with non-SWMR access and default fapl */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 3 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 9) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with non-SWMR access and fapl (non-default & set to 9) */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 4 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with non-SWMR access and fapl (non-default & set to 1) */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be 1 */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != 1) TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test 5 */
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with non-SWMR_READ and fapl (non-default but unset) */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 9) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open file again with non-SWMR access and default fapl */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open file again with SWMR access and default read attempts */
+ if((fid = H5Fopen(filename, H5F_ACC_SWMR_READ, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Set D:
+ * Tests on verifying read attempts when:
+ * --create with non-SWMR access
+ * --opening files with SWMR access
+ * --H5reopen the files
+ */
+
+ /* Create a file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open file again with SWMR access and default read attempts */
+ if((fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 9) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open file again with SWMR access and fapl (non-default & set to 9) */
+ if((fid2 = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open fid1 */
+ if((fid = H5Freopen(fid1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open fid2 */
+ if((fid = H5Freopen(fid2)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS, not 9 */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close all the files */
+ if(H5Fclose(fid1) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(fid2) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Set E:
+ * Tests on verifying read attempts when:
+ * --create with SWMR access
+ * --opening files with non-SWMR access
+ * --H5reopen the files
+ */
+
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open file again with non-SWMR access and default fapl */
+ if((fid1 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a copy of the parameter fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the # of read attempts */
+ if(H5Pset_metadata_read_attempts(fapl, 9) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open file again with non-SWMR access and fapl (non-default & set to 9) */
+ if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close fapl */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open fid1 */
+ if((fid = H5Freopen(fid1)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open fid2 */
+ if((fid = H5Freopen(fid2)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get file's fapl */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR
+
+ /* Close the file's fapl */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close all the files */
+ if(H5Fclose(fid1) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(fid2) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ H5Pclose(file_fapl);
+ H5Fclose(fid);
+ H5Fclose(fid1);
+ H5Fclose(fid2);
+ } H5E_END_TRY;
+
+ return -1;
+
+
+} /* test_metadata_read_attempts() */
+
+/*
+ * test_metadata_read_retry_info():
+ *
+ * Checks whether the public routine H5Fget_metadata_read_retry_info
+ * works as specified.
+ *
+ */
+static int
+test_metadata_read_retry_info(hid_t in_fapl)
+{
+ hid_t fapl, new_fapl; /* File access property list */
+ hid_t fid, fid1; /* File IDs */
+ H5F_retry_info_t info, info1; /* The collection of metadata retries */
+ H5F_t *f = NULL, *f1 = NULL; /* Internal file object pointers */
+ unsigned i, j, n; /* Local index variables */
+ hid_t did1, did2; /* Dataset IDs */
+ hid_t sid; /* Dataspace ID */
+ hid_t dcpl; /* Dataset creation property list */
+ hsize_t dims[2] = {6, 10}; /* Dataset dimensions */
+ char filename[NAME_BUF_SIZE]; /* File name */
+ int buf[6][10], chkbuf1[6][10], chkbuf2[6][10]; /* Buffers for data */
+ hsize_t max_dims_1un[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimensions */
+ hsize_t max_dims_2un[2] = {500, H5S_UNLIMITED}; /* Dataset maximum dimensions */
+ hsize_t chunk_dims[2] = {2, 2}; /* Chunk dimensions */
+
+ /* Output message about test being performed */
+ TESTING("H5Fset_metadata_read_retry_info()");
+
+ /* Get a copy of the parameter in_fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a file without SWMR access */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a chunked dataset with 1 unlimited dimension: extensible array indexing will be used */
+ if((sid = H5Screate_simple(2, dims, max_dims_1un)) < 0)
+ FAIL_STACK_ERROR
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ FAIL_STACK_ERROR
+ if((did1 = H5Dcreate2(fid, "DSET_1UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a chunked dataset with 2 unlimited dimension: v2 Btree indexing will be used */
+ if((sid = H5Screate_simple(2, dims, max_dims_2un)) < 0)
+ FAIL_STACK_ERROR
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ FAIL_STACK_ERROR
+ if((did2 = H5Dcreate2(fid, "DSET_2UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Initialize buffer data */
+ for(i = n = 0; i < 6; i++)
+ for(j = 0; j < 10; j++)
+ buf[i][j] = (int)n++;
+
+ /* Write to the 2 datasets */
+ if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ FAIL_STACK_ERROR
+ if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ FAIL_STACK_ERROR
+
+ /* Closing */
+ if(H5Dclose(did1) < 0)
+ FAIL_STACK_ERROR
+ if(H5Dclose(did2) < 0)
+ FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Case 1: tests on nbins
+ */
+ /*
+ * Open a file without SWMR access, default # of read attempts--
+ * info.nbins should be 0
+ * info.retries should all be NULL
+ */
+ /* Open the file without SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the dataset */
+ if((did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the dataset */
+ if((did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retries information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 0 */
+ if(info.nbins != 0) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL) TEST_ERROR
+
+ /* Closing */
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+
+ /*
+ * Open a file with SWMR access, default # of read attempts--
+ * info.nbins should be 2
+ * info.retries should all be NULL
+ */
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retries information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 2 */
+ if(info.nbins != 2) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+
+ /*
+ * Open a file with SWMR access, # of read_attempts is 10:
+ * info.nbins should be 1
+ * info.retries should all be NULL
+ */
+ if((new_fapl = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Pset_metadata_read_attempts(new_fapl, 10) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retry information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 1 */
+ if(info.nbins != 1) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /*
+ * Open a file with SWMR access, # of read attempts is 101:
+ * info.nbins should be 3
+ * info.retries should all be NULL
+ */
+ if((new_fapl = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_metadata_read_attempts(new_fapl, 101) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retry information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 3 */
+ if(info.nbins != 3) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /*
+ * Open a file with SWMR access, # of read_attempts is 10000:
+ * info.nbins should be 4
+ * info.retries should all be NULL
+ */
+ if((new_fapl = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Pset_metadata_read_attempts(new_fapl, 10000) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retry information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 4 */
+ if(info.nbins != 4) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /*
+ * Open a file with SWMR access, # of read_attempts is 1:
+ * info.nbins should be 0
+ * info.retries should all be NULL
+ */
+ if((new_fapl = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ if(H5Pset_metadata_read_attempts(new_fapl, 1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retry information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 0 */
+ if(info.nbins != 0) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+
+ /*
+ * Case 2: tests on retries info
+ */
+
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the dataset */
+ if((did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Read data from the dataset */
+ if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the dataset */
+ if((did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Read data from the dataset */
+ if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retry information */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 2 */
+ if(info.nbins != 2) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ TEST_ERROR
+
+ /* Get a pointer to the internal file object */
+ if((f = (H5F_t *)H5I_object(fid)) == NULL)
+ FAIL_STACK_ERROR
+
+ /*
+ * Increment 1st set of retries for metadata items:
+ * a) v2 B-tree leaf node--retries[4][1]
+ * b) Extensive array data block--retries[15][1]
+ * c) File's superblock--retries[20][0]
+ */
+
+ /* v2 B-tree leaf node: log retry 99 for 500 times */
+ for(i = 0; i < 500; i++) {
+ if(H5F_track_metadata_read_retries(f, H5AC_BT2_LEAF_ID, 99) < 0)
+ FAIL_STACK_ERROR
+ }
+
+ /* Extensive array data block: log retry 10 for 1000 times */
+ for(i = 0; i < 1000; i++)
+ if(H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 10) < 0)
+ FAIL_STACK_ERROR
+
+ /* File's superblock: log retry 1 for 1 time */
+ if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the collection of metadata read retries */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify retries for v2 B-tree leaf node */
+ if(info.retries[4][0] != 0) TEST_ERROR
+ if(info.retries[4][1] != 500) TEST_ERROR
+
+ /* Verify retries for extensive array data block */
+ if(info.retries[15][0] != 0) TEST_ERROR
+ if(info.retries[15][1] != 1000) TEST_ERROR
+
+ /* Verify retries for file's superblock */
+ if(info.retries[20][0] != 1) TEST_ERROR
+ if(info.retries[20][1] != 0) TEST_ERROR
+
+ /* Free memory for info.retries */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ if(info.retries[i] != NULL)
+ HDfree(info.retries[i]);
+ }
+
+ /*
+ * Increment 2nd set of retries for metadata items:
+ * a) Object header--retries[0][0]
+ * b) Extensive array datablock--retries[15][0]
+ * c) Fixed array header--retries[17][1]
+ * d) File's superblock--retries[20][0]
+ */
+
+ /* Object header: log retry 5 for 5 times */
+ for(i = 0; i < 5; i++) {
+ if(H5F_track_metadata_read_retries(f, H5AC_OHDR_ID, 5) < 0)
+ TEST_ERROR
+ }
+
+ /* Extensive array data block: log retry 4 for 1 time */
+ if(H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 4) < 0)
+ TEST_ERROR
+
+ /* Fixed array header : log retry 50 for 10000 times */
+ for(i = 0; i < 10000; i++) {
+ if(H5F_track_metadata_read_retries(f, H5AC_FARRAY_HDR_ID, 50) < 0)
+ TEST_ERROR
+ }
+
+ /* File's superblock: log retry 1 for 1 more time */
+ if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the collection of metadata read retries */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /*
+ * Verify info has both previous + current retries information:
+ */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ switch(i) {
+ case 0: /* Object header */
+ if(info.retries[i][0] != 5) TEST_ERROR
+ if(info.retries[i][1] != 0) TEST_ERROR
+ break;
+
+ case 4: /* v2 B-tree leaf node */
+ if(info.retries[i][0] != 0) TEST_ERROR
+ if(info.retries[i][1] != 500) TEST_ERROR
+ break;
+
+ case 15: /* Extensive array data block */
+ if(info.retries[i][0] != 1) TEST_ERROR
+ if(info.retries[i][1] != 1000) TEST_ERROR
+ break;
+
+ case 17: /* Fixed array header */
+ if(info.retries[i][0] != 0) TEST_ERROR
+ if(info.retries[i][1] != 10000) TEST_ERROR
+ break;
+
+ case 20: /* File's superblock */
+ if(info.retries[i][0] != 2) TEST_ERROR
+ if(info.retries[i][1] != 0) TEST_ERROR
+ break;
+
+ default:
+ if(info.retries[i] != NULL) TEST_ERROR
+ break;
+ }
+ }
+
+ /* Free memory for info.retries */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ HDfree(info.retries[i]);
+
+ /* Closing */
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /* Get a copy of the file access property list */
+ if((new_fapl = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the number of metadata read attempts to 101 */
+ if(H5Pset_metadata_read_attempts(new_fapl, 101) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if((f = (H5F_t *)H5I_object(fid)) == NULL)
+ FAIL_STACK_ERROR
+
+ /* File's superblock: log retry 1 for 1 time */
+ if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the collection of metadata read retries */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 3 */
+ if(info.nbins != 3) TEST_ERROR
+
+ /* Verify retries info */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ switch(i) {
+ case 20: /* File's superblock */
+ if(info.retries[i][0] != 1) TEST_ERROR
+ if(info.retries[i][1] != 0) TEST_ERROR
+ if(info.retries[i][2] != 0) TEST_ERROR
+ break;
+
+ default:
+ if(info.retries[i] != NULL) TEST_ERROR
+ break;
+ }
+ }
+
+ /* Free memory */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ if(info.retries[i] != NULL)
+ HDfree(info.retries[i]);
+
+ /* Closing */
+ if(H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /*
+ * Case 3: Tests on retrieving the collection of retries
+ * when H5Fopen and H5Freopen the same file.
+ */
+
+ /*
+ * Open a file without SWMR access, default # of read attempts--
+ * H5Freopen the same file--
+ * Both files should:
+ * nbins should be 0
+ * retries should all be NULL
+ */
+ /* Open the file without SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Re-open fid */
+ if((fid1 = H5Freopen(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retries information for fid */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve retries information for fid1*/
+ if(H5Fget_metadata_read_retry_info(fid1, &info1)< 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 0 */
+ if(info.nbins != 0) TEST_ERROR
+ if(info1.nbins != 0) TEST_ERROR
+
+ /* Should be all NULL */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ if(info.retries[i] != NULL) TEST_ERROR
+ if(info1.retries[i] != NULL) TEST_ERROR
+ }
+
+ /* Closing */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
+
+ /*
+ * Open a file with SWMR access, default # of read attempts:
+ * --increment retries for metadata item: fixed array data block page (retries[19][0])
+ * H5Freopen the same file:
+ * --increment retries for metadata item: free-space sections (retries[9][1])--
+ */
+ /* Open the file with SWMR access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object for fid */
+ if((f = (H5F_t *)H5I_object(fid)) == NULL)
+ FAIL_STACK_ERROR
+
+ /* Re-open fid */
+ if((fid1 = H5Freopen(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object for fid1 */
+ if((f1 = (H5F_t *)H5I_object(fid1)) == NULL)
+ FAIL_STACK_ERROR
+
+ /* For fid: fixed array data block page--log retry 9 for 500 times */
+ for(i = 0; i < 500; i++) {
+ if(H5F_track_metadata_read_retries(f, H5AC_FARRAY_DBLK_PAGE_ID, 9) < 0)
+ FAIL_STACK_ERROR
+ }
+
+ /* For fid1: free-space sections--log retry 99 for 1000 times */
+ for(i = 0; i < 1000; i++) {
+ if(H5F_track_metadata_read_retries(f1, H5AC_FSPACE_SINFO_ID, 99) < 0)
+ FAIL_STACK_ERROR
+ }
+
+ /* Retrieve the collection of metadata read retries for fid */
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the collection of metadata read retries for fid1 */
+ if(H5Fget_metadata_read_retry_info(fid1, &info1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Verify nbins for fid & fid1: should be 2 */
+ if(info.nbins != 2) TEST_ERROR
+ if(info1.nbins != 2) TEST_ERROR
+
+ /* Verify retries for fid: fixed array data block page */
+ if(info.retries[19][0] != 500) TEST_ERROR
+ if(info.retries[19][1] != 0) TEST_ERROR
+
+ /* Verify retries for fid: free-space sections */
+ /* (Since file was re-opened) */
+ if(info.retries[9][0] != 0) TEST_ERROR
+ if(info.retries[9][1] != 1000) TEST_ERROR
+
+ /* Verify retries for fid1: free-space sections */
+ if(info1.retries[9][0] != 0) TEST_ERROR
+ if(info1.retries[9][1] != 1000) TEST_ERROR
+
+ /* Verify retries for fid1: fixed array data block page */
+ /* (Since file was re-opened) */
+ if(info1.retries[19][0] != 500) TEST_ERROR
+ if(info1.retries[19][1] != 0) TEST_ERROR
+
+ /* Free memory for info.retries and info1.retries */
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ if(info.retries[i] != NULL)
+ HDfree(info.retries[i]);
+ if(info1.retries[i] != NULL)
+ HDfree(info1.retries[i]);
+ } /* end for */
+
+ /* Closing */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
+
+ if(H5Pclose(fapl) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ H5Pclose(new_fapl);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Sclose(sid);
+ H5Pclose(dcpl);
+ H5Fclose(fid);
+ H5Fclose(fid1);
+ } H5E_END_TRY;
+
+ return -1;
+
+} /* test_metadata_read_retry_info() */
+
+
+
/*
* Tests for H5Fstart_swmr_write()
*/
/*
- * Verify SWMR writing is enabled via H5Fstart_swmr_write().
+ * test_start_swmr_write():
+ *
+ * Verify SWMR writing is enabled via H5Fstart_swmr_write():
+ * Case A) when creating a file
+ * Case B) when opening a file
*/
static int
test_start_swmr_write(hid_t in_fapl)
{
hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* A copy of file access property */
+ hid_t gid = -1; /* Group ID */
hid_t file_fapl = -1; /* File access property for the file */
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
+ hid_t did1 = -1, did2 = -1; /* Dataset IDs */
+ hid_t sid1 = -1, sid2; /* Dataspace IDs */
+ hsize_t dim[1] = {10}; /* Dimension sizes */
hsize_t dims[2] = {5, 10}; /* Dimension sizes */
- int buf[50]; /* Data buffer */
+ int buf[50], rbuf[50]; /* Data buffer */
+ int wdata[10], rdata[10]; /* Data buffer */
int i; /* Local index variable */
unsigned attempts; /* The retrieved # of read attempts */
char filename[NAME_BUF_SIZE]; /* File name */
- TESTING("H5Fstart_swmr_write()");
+ TESTING("H5Fstart_swmr_write() when creating/opening a file");
/* Get a copy of the parameter fapl */
if((fapl = H5Pcopy(in_fapl)) < 0)
@@ -97,6 +1452,10 @@ test_start_swmr_write(hid_t in_fapl)
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+ /*
+ * Case A: when creating a file
+ */
+
/* Create the file to work on */
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
@@ -109,53 +1468,155 @@ test_start_swmr_write(hid_t in_fapl)
if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
FAIL_STACK_ERROR
+ /* Should be 1 */
+ if(attempts != H5F_METADATA_READ_ATTEMPTS)
+ TEST_ERROR;
+
/* Close the property list */
if(H5Pclose(file_fapl) < 0)
FAIL_STACK_ERROR;
+ /* Create a dataset */
+ if((sid1 = H5Screate_simple(2, dims, NULL)) < 0)
+ FAIL_STACK_ERROR;
+ if((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Initialize data buffer */
+ for(i = 0; i < 50; i++)
+ buf[i] = i;
+
+ /* Write to the dataset */
+ if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Enable SWMR writing */
+ if(H5Fstart_swmr_write(fid) < 0)
+ TEST_ERROR;
+
+ /* Read from the dataset */
+ if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Verify the data is correct */
+ if(HDmemcmp(buf, rbuf, sizeof(rbuf)))
+ TEST_ERROR
+
+ /* Close the dataset */
+ if(H5Dclose(did1) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Close the dataspace */
+ if(H5Sclose(sid1) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Get the file's access_property list */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+
+ /* Should be 100 */
+ if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
+ TEST_ERROR;
+
+ /* Close the file access property list */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Open the file again */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Get the file's access_property list */
+ if((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Retrieve the # of read attempts */
+ if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
+ FAIL_STACK_ERROR
+
/* Should be 1 */
if(attempts != H5F_METADATA_READ_ATTEMPTS)
TEST_ERROR;
- /* Create a dataset */
- if((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ /* Close the property list */
+ if(H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Open the first dataset */
+ if((did1 = H5Dopen(fid, "dataset1", H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Create a group */
+ if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create dataspace */
+ if((sid2 = H5Screate_simple(1, dim, NULL)) < 0)
FAIL_STACK_ERROR;
- if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+
+ /* Create a second dataset */
+ if((did2 = H5Dcreate2(gid, "dataset2", H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
- /* Close the dataset */
- if(H5Dclose(did) < 0)
+ /* Initialize data buffer to all 1s */
+ HDmemset(wdata, 1, sizeof(wdata));
+
+ /* Write to the second dataset */
+ if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0)
FAIL_STACK_ERROR;
/* Enable SWMR writing */
if(H5Fstart_swmr_write(fid) < 0)
TEST_ERROR;
- /* Open the dataset */
- if((did = H5Dopen2(fid, "dataset", H5P_DEFAULT)) < 0)
+ /* Read from the second dataset */
+ if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0)
FAIL_STACK_ERROR;
- /* Initialize data buffer */
- for(i = 0; i < 50; i++)
- buf[i] = i;
+ /* Verify the data is correct */
+ if(HDmemcmp(wdata, rdata, sizeof(rdata)))
+ TEST_ERROR
- /* Write to the dataset */
- if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ /* Close the second dataset */
+ if(H5Dclose(did2) < 0)
FAIL_STACK_ERROR;
- /* Close the dataset */
- if(H5Dclose(did) < 0)
+ /* Close the dataspace */
+ if(H5Sclose(sid2) < 0)
FAIL_STACK_ERROR;
- /* Close the dataspace */
- if(H5Sclose(sid) < 0)
+ /* Close the group */
+ if(H5Gclose(gid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Clear the data buffer */
+ HDmemset(rbuf, 1, sizeof(rbuf));
+
+ /* Read from the first dataset */
+ if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Verify the data is correct */
+ if(HDmemcmp(buf, rbuf, sizeof(rbuf)))
+ TEST_ERROR
+
+ /* Close the first dataset */
+ if(H5Dclose(did1) < 0)
FAIL_STACK_ERROR;
/* Get the file's access_property list */
if((file_fapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR
- /* Retrieve the # of read attempts from file's fapl */
+ /* Retrieve the # of read attempts */
if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0)
FAIL_STACK_ERROR
@@ -163,11 +1624,15 @@ test_start_swmr_write(hid_t in_fapl)
if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS)
TEST_ERROR;
- /* Closing */
+ /* Close the file's file access property list */
if(H5Pclose(file_fapl) < 0)
FAIL_STACK_ERROR;
+
+ /* Close the file access property list */
if(H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
+
+ /* Close the file */
if(H5Fclose(fid) < 0)
FAIL_STACK_ERROR;
@@ -180,35 +1645,39 @@ error:
H5Fclose(fid);
H5Pclose(fapl);
H5Pclose(file_fapl);
- H5Dclose(did);
- H5Sclose(sid);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Sclose(sid1);
+ H5Sclose(sid2);
} H5E_END_TRY;
return -1;
} /* test_start_swmr_write() */
/*
- * Verify failures in enabling SWMR writing mode via H5Fstart_swmr_write():
- * When creating a file:
- * (1) the file is created with SWMR write access
- * (2) the file is not created with the latest format
- * (3) there are opened objects in the file
- * When opening a file with the latest format:
- * (1) the file is already opened with SWMR write access
- * (2) the file is opened with read access only
- * (3) the file is opened with SWMR read access only
- * (4) there are opened objects in the file
- * When opening a file without the latest format:
- * (1) the file is not opened with the latest format
- * (2) the file is opened with read access only
- * (3) the file is opened with SWMR read access only
- * When there are multiple opens for the file:
- * (1) create a file, enable SWMR writing mode twice (fail second time)
- * (2) create a file and enable SWMR writing mode
- * reopen the same file and enable SWMR writing mode (fail)
- * (3) create a file, open the same file
- * enable SWMR writing for the file created
- * enable SWMR writing for the file opened (fail)
+ * test_err_start_swmr_write():
+ *
+ * Verify failure conditions in enabling SWMR writing mode via H5Fstart_swmr_write():
+ * (A) When creating a file:
+ * (1) the file is created with SWMR write access
+ * (2) the file is not created with the latest format
+ * (3) there are opened named datatype in the file
+ * (B) When opening a file with the latest format:
+ * (1) the file is already opened with SWMR write access
+ * (2) the file is opened with read access only
+ * (3) the file is opened with SWMR read access only
+ * (4) there are opened named datatype/attribute in the file
+ * (C) When opening a file without the latest format:
+ * (1) the file is not opened with the latest format
+ * (2) the file is opened with read access only
+ * (3) the file is opened with SWMR read access only
+ * (D) When there are multiple opens for the file:
+ * (1) create a file, enable SWMR writing mode twice (fail second time)
+ * (2) create a file and enable SWMR writing mode
+ * reopen the same file and enable SWMR writing mode (fail)
+ * (3) create a file, open the same file
+ * enable SWMR writing for the file created
+ * enable SWMR writing for the file opened (fail)
*/
static int
test_err_start_swmr_write(hid_t in_fapl)
@@ -219,8 +1688,8 @@ test_err_start_swmr_write(hid_t in_fapl)
hid_t gid = -1; /* Group ID */
hid_t did = -1; /* Dataset ID */
hid_t sid = -1; /* Dataspace ID */
+ hid_t aid = -1; /* Attribute ID */
hid_t tid = -1; /* Datatype ID */
- hsize_t dims[2] = {5, 10}; /* Dimension size */
herr_t ret; /* Return value */
char filename[NAME_BUF_SIZE]; /* File name */
@@ -235,10 +1704,10 @@ test_err_start_swmr_write(hid_t in_fapl)
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
- TESTING("H5Fstart_swmr_write() failure conditions");
+ TESTING("H5Fstart_swmr_write() on failure conditions");
/*
- * When creating a file:
+ * (A) When creating a file:
*/
/* Case 1 */
@@ -282,50 +1751,35 @@ test_err_start_swmr_write(hid_t in_fapl)
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
- /* Create a group */
- if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR;
-
- /* Create a dataset in the group */
- if((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ /* Create and commit a named datatype */
+ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
FAIL_STACK_ERROR;
- if((did = H5Dcreate2(gid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR
-
- /* Should fail to enable SWMR writing mode: there are opened objects */
- H5E_BEGIN_TRY {
- ret = H5Fstart_swmr_write(fid);
- } H5E_END_TRY;
- if(ret >= 0)
- TEST_ERROR;
-
- /* Close the dataset */
- if(H5Dclose(did) < 0)
+ if(H5Tcommit2(fid, "TID", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
- /* Fail to enable SWMR writing mode */
+ /* Cannot enable SWMR writing mode when there is an opened named datatype */
H5E_BEGIN_TRY {
- ret = H5Fstart_swmr_write(fid);
+ ret = H5Fstart_swmr_write(fid);
} H5E_END_TRY;
if(ret >= 0)
- TEST_ERROR;
+ TEST_ERROR
- /* Close the group */
- if(H5Gclose(gid) < 0)
+ /* Close the datatype */
+ if(H5Tclose(tid) < 0)
FAIL_STACK_ERROR;
/* Should succeed in enabling SWMR writing */
if(H5Fstart_swmr_write(fid) < 0)
TEST_ERROR;
- /* Closing */
- if(H5Sclose(sid) < 0)
- FAIL_STACK_ERROR;
+ /* Close the file */
if(H5Fclose(fid) < 0)
FAIL_STACK_ERROR;
+
+
/*
- * When opening a file with latest format:
+ * (B) When opening a file with latest format:
*/
/* Create and close a file with latest format */
@@ -397,27 +1851,51 @@ test_err_start_swmr_write(hid_t in_fapl)
if(H5Tcommit2(fid, "TID", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
- /* Should fail to enable SWMR writing mode */
+ /* Create dataspace */
+ if((sid = H5Screate(H5S_SCALAR)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Attach an attribute to the named datatype */
+ if((aid = H5Acreate2(tid, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Should fail to enable SWMR writing when there are opened named datatype and attribute */
H5E_BEGIN_TRY {
- ret = H5Fstart_swmr_write(fid);
+ ret = H5Fstart_swmr_write(fid);
} H5E_END_TRY;
if(ret >= 0)
- TEST_ERROR;
+ TEST_ERROR
/* Close the datatype */
if(H5Tclose(tid) < 0)
FAIL_STACK_ERROR;
+ /* Still fail to enable SWMR writing when the attribute is still opened */
+ H5E_BEGIN_TRY {
+ ret = H5Fstart_swmr_write(fid);
+ } H5E_END_TRY;
+ if(ret >= 0)
+ TEST_ERROR
+
+ /* Close the attribute */
+ if(H5Aclose(aid) < 0)
+ FAIL_STACK_ERROR;
+
/* Should succeed in enabling SWMR writing */
if(H5Fstart_swmr_write(fid) < 0)
TEST_ERROR;
+ /* Close the dataspace */
+ if(H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR;
+
/* Close the file */
if(H5Fclose(fid) < 0)
FAIL_STACK_ERROR;
+
/*
- * Opening a file without latest format:
+ * (C) Opening a file without latest format:
*/
/* Case 1 */
@@ -479,7 +1957,7 @@ test_err_start_swmr_write(hid_t in_fapl)
FAIL_STACK_ERROR;
/*
- * Failure cases for multiple opens
+ * (D) Failure cases for multiple opens
*/
/* Case 1 */
@@ -510,7 +1988,7 @@ test_err_start_swmr_write(hid_t in_fapl)
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR;
- /* Should succeed in starting SWMR writing mode */
+ /* Should succeed in enabling SWMR writing mode */
if(H5Fstart_swmr_write(fid) < 0)
TEST_ERROR
@@ -567,6 +2045,9 @@ test_err_start_swmr_write(hid_t in_fapl)
error:
H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Gclose(gid);
+ H5Dclose(did);
H5Fclose(fid);
H5Pclose(fapl);
} H5E_END_TRY;
@@ -574,20 +2055,20 @@ error:
return -1;
} /* test_err_start_swmr_write() */
-
/*
* test_start_swmr_write_concur():
- * Verify concurrent access for H5Fstart_swmr_write()--
- * (1) Open a file with write access
- * Concurrent open of the file with read & SWMR read (fail)
- * (2) Open a file with write access; enable SWMR writing mode
- * Concurrent open of the file with read & SWMR read (succeed)
- * (3) Open a file with write access; enable SWMR writing mode
- * Concurrent open of the file with read only (fail)
- * (4) Open a file with write access; enable SWMR writing mode
- * Concurrent open of the file with write access (fail)
- * (5) Open a file with write access; enable SWMR writing mode
- * Concurrent open of the file with write and SWMR write access (fail)
+ *
+ * Verify concurrent access for H5Fstart_swmr_write()--
+ * (1) Parent: open a file with write access
+ * Child: concurrent open of the file with read & SWMR read (fail)
+ * (2) Parent: open a file with write access; enable SWMR writing mode
+ * Child: concurrent open of the file with read & SWMR read (succeed)
+ * (3) Parent: open a file with write access; enable SWMR writing mode
+ * Child: Concurrent open of the file with read only (fail)
+ * (4) Parent: open a file with write access; enable SWMR writing mode
+ * Child: concurrent open of the file with write access (fail)
+ * (5) Parent: open a file with write access; enable SWMR writing mode
+ * Child: concurrent open of the file with write and SWMR write access (fail)
*/
static int
test_start_swmr_write_concur(hid_t in_fapl)
@@ -599,7 +2080,7 @@ test_start_swmr_write_concur(hid_t in_fapl)
pid_t tmppid; /* Child process ID returned by waitpid */
int child_status; /* Status passed to waitpid */
int child_wait_option=0; /* Options passed to waitpid */
- int child_ret_value; /* Exit status of the child */
+ int child_exit_val; /* Exit status of the child */
char filename[NAME_BUF_SIZE]; /* File name */
/* Output message about test being performed */
@@ -670,19 +2151,17 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0)
FAIL_STACK_ERROR
- /* Check if child terminated normally */
- if((ret = WIFEXITED(child_status)) < 0)
- FAIL_STACK_ERROR
-
/* Check exit status of child process */
- if((child_ret_value = WEXITSTATUS(child_status)) != 0)
- TEST_ERROR
+ if(WIFEXITED(child_status)) {
+ if((child_exit_val = WEXITSTATUS(child_status)) != 0)
+ TEST_ERROR
+ } else /* child process terminated abnormally */
+ TEST_ERROR
/* Close the file */
if(H5Fclose(fid) < 0)
FAIL_STACK_ERROR
-
/*
* Case (2):
* Verify concurrent file open with H5F_ACC_RDONLY|H5F_ACC_SWMR_READ
@@ -704,14 +2183,10 @@ test_start_swmr_write_concur(hid_t in_fapl)
exit(1);
/* Should succeed in opening the test file */
- if((child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) {
- TEST_ERROR
+ if((child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0)
exit(1);
- }
- if(H5Fclose(child_fid) < 0) {
- FAIL_STACK_ERROR
+ if(H5Fclose(child_fid) < 0)
exit(1);
- }
exit(0);
}
@@ -730,12 +2205,11 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0)
FAIL_STACK_ERROR
- /* Check if child terminated normally */
- if((ret = WIFEXITED(child_status)) < 0)
- FAIL_STACK_ERROR
-
/* Check exit status of child process */
- if((child_ret_value = WEXITSTATUS(child_status)) != 0)
+ if(WIFEXITED(child_status)) {
+ if((child_exit_val = WEXITSTATUS(child_status)) != 0)
+ TEST_ERROR
+ } else /* Child process terminated abnormally */
TEST_ERROR
/* Close the file */
@@ -786,13 +2260,12 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0)
FAIL_STACK_ERROR
- /* Check if child terminated normally */
- if((ret = WIFEXITED(child_status)) < 0)
- FAIL_STACK_ERROR
-
/* Check exit status of child process */
- if((child_ret_value = WEXITSTATUS(child_status)) != 0)
- TEST_ERROR;
+ if(WIFEXITED(child_status)) {
+ if((child_exit_val = WEXITSTATUS(child_status)) != 0)
+ TEST_ERROR
+ } else /* Child process terminated abnormally */
+ TEST_ERROR
/* Close the file */
if(H5Fclose(fid) < 0)
@@ -811,7 +2284,6 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((childpid = HDfork()) < 0)
FAIL_STACK_ERROR
-
if(childpid == 0) { /* Child process */
/* Wait till parent process completes the open */
@@ -842,13 +2314,12 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0)
FAIL_STACK_ERROR
- /* Check if child terminated normally */
- if((ret = WIFEXITED(child_status)) < 0)
- FAIL_STACK_ERROR
-
/* Check exit status of child process */
- if((child_ret_value = WEXITSTATUS(child_status)) != 0)
- TEST_ERROR;
+ if(WIFEXITED(child_status)) {
+ if((child_exit_val = WEXITSTATUS(child_status)) != 0)
+ TEST_ERROR
+ } else /* Child process terminated abnormally */
+ TEST_ERROR
/* Close the file */
if(H5Fclose(fid) < 0)
@@ -867,7 +2338,6 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((childpid = HDfork()) < 0)
FAIL_STACK_ERROR
-
if(childpid == 0) { /* Child process */
/* Wait till parent process completes the open */
@@ -898,13 +2368,12 @@ test_start_swmr_write_concur(hid_t in_fapl)
if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0)
FAIL_STACK_ERROR
- /* Check if child terminated normally */
- if((ret = WIFEXITED(child_status)) < 0)
- FAIL_STACK_ERROR
-
/* Check exit status of child process */
- if((child_ret_value = WEXITSTATUS(child_status)) != 0)
- TEST_ERROR;
+ if(WIFEXITED(child_status)) {
+ if((child_exit_val = WEXITSTATUS(child_status)) != 0)
+ TEST_ERROR
+ } else /* Child process terminated abnormally */
+ TEST_ERROR
/* Close the file */
if(H5Fclose(fid) < 0)
@@ -926,7 +2395,7 @@ error:
return -1;
#endif
-} /* end test_start_swmr_write_concur() */
+} /* test_start_swmr_write_concur() */
/*
@@ -935,7 +2404,7 @@ error:
/* The callback function for object flush property */
static herr_t
-flush_cb(hid_t obj_id, void *_udata)
+flush_cb(hid_t H5_ATTR_UNUSED obj_id, void *_udata)
{
unsigned *flush_ct = (unsigned*)_udata;
++(*flush_ct);
@@ -944,8 +2413,8 @@ flush_cb(hid_t obj_id, void *_udata)
/*
* test_object_flush_cb()
- * To verify the public routines H5Pget/set_object_flush_cb()
- * work as specified:
+ *
+ * Verify the public routines H5Pget/set_object_flush_cb() work as specified:
* 1) To verify the failure condition in setting object flush property
* 2) To verify the object flush property values retrieved from a default
* file access property list.
@@ -1200,7 +2669,7 @@ error:
/* The callback function for append flush property */
static herr_t
-append_cb(hid_t dset_id, hsize_t *cur_dims, void *_udata)
+append_cb(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void *_udata)
{
unsigned *count = (unsigned *)_udata;
++(*count++);
@@ -1210,7 +2679,7 @@ append_cb(hid_t dset_id, hsize_t *cur_dims, void *_udata)
/* The callback function for append flush property */
static herr_t
-append_cb2(hid_t dset_id, hsize_t *cur_dims, void *_udata)
+append_cb2(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void *_udata)
{
unsigned *count = (unsigned *)_udata;
++(*count++);
@@ -1221,8 +2690,9 @@ append_cb2(hid_t dset_id, hsize_t *cur_dims, void *_udata)
/*
* test_append_flush_generic()
- * To verify H5Pget/set_append_flush() work as specified for
- * a generic dataset access property list:
+ *
+ * Verify H5Pget/set_append_flush() work as specified for a generic dataset
+ * access property list:
* 1) To verify the append flush property values retrieved from a default
* access property list.
* -- zero boundary, null callback function, null user data
@@ -1327,7 +2797,7 @@ test_append_flush_generic(void)
TEST_ERROR
/* Invalid boundary size: negative value */
- boundary[0] = -1;
+ boundary[0] = (hsize_t)-1;
boundary[1] = 1;
H5E_BEGIN_TRY {
ret = H5Pset_append_flush(dapl, 2, boundary, append_cb, &count);
@@ -1391,18 +2861,19 @@ error:
/*
* test_append_flush_dataset_chunked()
- * To verify H5Pget/set_append_flush() work as specified for
- * a chunked dataset's access property list:
- * 1) To verify the append flush property values retrieved from a default access
- * property list:
- * -- zero boundary, null callback function, null user data
- * 2) To verify failure in creating dataset when:
- * -- the rank set in append flush property is not the same as the dataset's rank
- * -- boundary (non-zero) is set for a non-extendible dimension
- * 3) To verify the append flush property values retrieved from a non-default
- * access property list:
- * -- the set callback function, the set user data
- * -- the # of boundary sizes retrieved does not exceed MIN(input ndims, the ndims set)
+ *
+ * Verify H5Pget/set_append_flush() work as specified for a chunked dataset's
+ * access property list:
+ * 1) To verify the append flush property values retrieved from a default
+ * access property list:
+ * -- zero boundary, null callback function, null user data
+ * 2) To verify failure in creating dataset when:
+ * -- the rank set in append flush property is not the same as the dataset's rank
+ * -- boundary (non-zero) is set for a non-extendible dimension
+ * 3) To verify the append flush property values retrieved from a non-default
+ * access property list:
+ * -- the set callback function, the set user data
+ * -- the # of boundary sizes retrieved does not exceed MIN(input ndims, the ndims set)
*/
static int
test_append_flush_dataset_chunked(hid_t in_fapl)
@@ -1612,12 +3083,13 @@ error:
/*
* test_append_flush_dataset_fixed():
- * To verify H5Pget/set_append_flush() work as specified for
- * a non-chunked (fixed size) dataset's access property list:
+ *
+ * Verify H5Pget/set_append_flush() work as specified for a
+ * non-chunked (fixed size) dataset's access property list:
* (1) To verify success in creating the dataset--whatever is set for the append flush property setting
* (2) To verify that default append flush property values are retrieved for both
* default or non-default access property list:
- * -- zero boundary, null callback function, null user data
+ * -- zero boundary, null callback function, null user data
*/
static int
test_append_flush_dataset_fixed(hid_t in_fapl)
@@ -1817,8 +3289,9 @@ error:
/*
* test_append_flush_multiple()
- * To verify H5Pget/set_append_flush() work as specified for
- * multiple opens of a dataset:
+ *
+ * Verify H5Pget/set_append_flush() work as specified for multiple opens
+ * of a dataset:
* (1) did1 = H5Dcreate(...dapl1...)
* did2 = H5Dopen2(...dapl2)
* H5Pget_append_flush(did1...)
@@ -2055,9 +3528,110 @@ error:
return -1;
} /* test_append_flush_dataset_multiple() */
+#ifdef OUT
+/*
+ * This exposes a bug for H5Orefresh while handling opened objects for H5Fstart_swmr_write().
+ * The boolean to skip file truncation test when reading in superblock will fix the problem.
+ * Will work to move that to test/flushrefresh.c later.
+ */
+static int
+test_bug_refresh(hid_t in_fapl)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t fapl;
+ H5F_t *f;
+ hid_t gid1, gid2, gid3, gid4, gid5, gid6, gid7, gid8, gid9;
+ char filename[NAME_BUF_SIZE]; /* File name */
+
+ /* Create a copy of the input parameter in_fapl */
+ if((fapl = H5Pcopy(in_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set the filename to use for this test (dependent on fapl) */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ TESTING("H5Orefresh failure conditions");
+
+ /* Create a file with the latest format */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(fid)))
+ FAIL_STACK_ERROR
+
+ /* Create groups: compact to dense storage */
+ if((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid2 = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid3 = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid4 = H5Gcreate2(fid, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid5 = H5Gcreate2(fid, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid6 = H5Gcreate2(fid, "group6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid7 = H5Gcreate2(fid, "group7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid8 = H5Gcreate2(fid, "group8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+ if((gid9 = H5Gcreate2(fid, "group9", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+
+ if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) TEST_ERROR
+
+ if(H5Grefresh(gid1) < 0) TEST_ERROR
+ if(H5Grefresh(gid2) < 0) TEST_ERROR
+ if(H5Grefresh(gid3) < 0) TEST_ERROR
+ if(H5Grefresh(gid4) < 0) TEST_ERROR
+ if(H5Grefresh(gid5) < 0) TEST_ERROR
+ if(H5Grefresh(gid6) < 0) TEST_ERROR
+ if(H5Grefresh(gid7) < 0) TEST_ERROR
+ if(H5Grefresh(gid8) < 0) TEST_ERROR
+ if(H5Grefresh(gid9) < 0) TEST_ERROR
+
+ H5Gclose(gid1);
+ H5Gclose(gid2);
+ H5Gclose(gid3);
+ H5Gclose(gid4);
+ H5Gclose(gid5);
+ H5Gclose(gid6);
+ H5Gclose(gid7);
+ H5Gclose(gid8);
+ H5Gclose(gid9);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid1);
+ H5Gclose(gid2);
+ H5Gclose(gid3);
+ H5Gclose(gid4);
+ H5Gclose(gid5);
+ H5Gclose(gid6);
+ H5Gclose(gid7);
+ H5Gclose(gid8);
+ H5Gclose(gid9);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ return -1;
+} /* test_bug_refresh() */
+#endif
+
/****************************************************************
**
-** test_file(): Main low-level file I/O test routine.
+** Tests for new public routines introduced from the SWMR project.
**
****************************************************************/
int
@@ -2072,6 +3646,15 @@ main(void)
/* Get file access property list */
fapl = h5_fileaccess();
+#ifdef OUT
+ nerrors += test_bug_refresh(fapl);
+#endif
+
+ /* Tests on H5Pget/set_metadata_read_attempts() and H5Fget_metadata_read_retry_info() */
+ /* These two tests are moved from tfile.c */
+ nerrors += test_metadata_read_attempts(fapl);
+ nerrors += test_metadata_read_retry_info(fapl);
+
/* Tests on H5Fstart_swmr_write() */
nerrors += test_start_swmr_write(fapl);
nerrors += test_err_start_swmr_write(fapl);
@@ -2089,7 +3672,7 @@ main(void)
if(nerrors)
goto error;
- printf("All tests passed for H5Fstart_swmr_write(), H5Pget/set_object_flush_cb(), H5Pget/set_append_flush().\n");
+ printf("All tests passed.\n");
h5_cleanup(FILENAME, fapl);
diff --git a/test/tfile.c b/test/tfile.c
index d49d5d7..677e381 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -3613,1284 +3613,6 @@ test_libver_macros2(void)
/****************************************************************
**
-** test_metadata_read_attempts():
-** This test checks whether the following two public routines work as
-** specified in the reference manuals:
-** H5Pset_metadata_read_attempts()
-** H5Pget_metadata_read_attempts()
-**
-*****************************************************************/
-static void
-test_metadata_read_attempts(void)
-{
- hid_t fapl; /* File access property list */
- hid_t file_fapl; /* The file's access property list */
- hid_t fid, fid1, fid2; /* File IDs */
- unsigned attempts; /* The # of read attempts */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(5, ("Testing H5Pget/set_metadata_read_attempts()\n"));
-
- /*
- * Set A:
- * Tests on verifying the # of read attempts when:
- * --setting/getting read attempts from a
- * file access property list.
- */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Get # of read attempts -- should be the default: 1 */
- ret = H5Pget_metadata_read_attempts(fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, 1, "H5Pget_metadata_read_attempts");
-
- /* Set the # of read attempts to 0--should fail */
- ret = H5Pset_metadata_read_attempts(fapl, 0);
- VERIFY(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Set the # of read attempts to a # > 0--should succeed */
- ret = H5Pset_metadata_read_attempts(fapl, 9);
- VERIFY(ret, 0, "H5Pset_metadata_read_attempts");
-
- /* Retrieve the # of read attempts -- should be 9 */
- ret = H5Pget_metadata_read_attempts(fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, 9, "H5Pget_metadata_read_attempts");
-
- /* Set the # of read attempts to the default for non-SWMR access: H5F_METADATA_READ_ATTEMPTS --should succeed */
- ret = H5Pset_metadata_read_attempts(fapl, H5F_METADATA_READ_ATTEMPTS);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
-
- /* Retrieve the # of read attempts -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Set the # of read attempts to the default for SWMR access: H5F_SWMR_METADATA_READ_ATEMPTS --should succeed */
- ret = H5Pset_metadata_read_attempts(fapl, H5F_SWMR_METADATA_READ_ATTEMPTS);
- VERIFY(ret, 0, "H5Pset_metadata_read_attempts");
-
- /* Retrieve the # of read attempts -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /*
- * Set B:
- * Tests on verifying read attempts when:
- * --create a file with non-SWMR access
- * --opening files with SWMR access
- * --using default or non-default file access property list
- */
- /* Test 1 */
- /* Create a file with non-SWMR access and default fapl */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 2 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Open the file with SWMR access and default read attempts */
- fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Fget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 3 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 9);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with SWMR access and fapl (non-default & set to 9) */
- fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be 9 */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, 9, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 4 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 1);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with SWMR access and fapl (non-default & set to 1) */
- fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be 1 */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, 1, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 5 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Open the file with SWMR_READ and fapl (non-default read attempts but unset) */
- fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /*
- * Set C:
- * Tests on verifying read attempts when:
- * --create a file with SWMR access
- * --opening files with non-SWMR access
- * --using default or non-default file access property list
- */
- /* Test 1 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Create a file with non-SWMR access and default read attempts */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 2 */
- /* Open the file with non-SWMR access and default fapl */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 3 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 9);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with non-SWMR access and fapl (non-default & set to 9) */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 4 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 1);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with non-SWMR access and fapl (non-default & set to 1) */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be 1 */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, 1, "H5Fget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Test 5 */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Open the file with non-SWMR_READ and fapl (non-default but unset) */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Pget_access_plist");
-
- /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Fget_metadata_read_attempts");
-
- /* Close the file */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
-
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 9);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Create a file */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Open file again with non-SWMR access and default fapl */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Open file again with SWMR access and default read attempts */
- fid = H5Fopen(FILE1, H5F_ACC_SWMR_READ, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Set D:
- * Tests on verifying read attempts when:
- * --create with non-SWMR access
- * --opening files with SWMR access
- * --H5reopen the files
- */
-
- /* Create a file */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Open file again with SWMR access and default read attempts */
- fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl);
- CHECK(fid1, FAIL, "H5Fopen");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 9);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open file again with SWMR access and fapl (non-default & set to 9) */
- fid2 = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
- CHECK(fid2, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Re-open fid1 */
- fid = H5Freopen(fid1);
- CHECK(fid, FAIL, "H5Freopen");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Re-open fid2 */
- fid = H5Freopen(fid2);
- CHECK(fid, FAIL, "H5Pclose");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS, not 9 */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close all the files */
- ret=H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
- ret=H5Fclose(fid2);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Set E:
- * Tests on verifying read attempts when:
- * --create with SWMR access
- * --opening files with non-SWMR access
- * --H5reopen the files
- */
-
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Create a file */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl);
- CHECK(fid1, FAIL, "H5Fcreate");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Open file again with non-SWMR access and default fapl */
- fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
- CHECK(fid2, FAIL, "H5Fopen");
-
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set the # of read attempts */
- ret = H5Pset_metadata_read_attempts(fapl, 9);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open file again with non-SWMR access and fapl (non-default & set to 9) */
- fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
- CHECK(fid2, FAIL, "H5Fopen");
-
- /* Close fapl */
- ret = H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Re-open fid1 */
- fid = H5Freopen(fid1);
- CHECK(fid, FAIL, "H5Freopen");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
- /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Fget_metadata_read_attempts");
-
- /* Close the file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Re-open fid2 */
- fid = H5Freopen(fid2);
- CHECK(fid, FAIL, "H5Freopen");
-
- /* Get file's fapl */
- file_fapl = H5Fget_access_plist(fid);
- CHECK(file_fapl, FAIL, "H5Fget_access_plist");
-
- /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */
- ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
- CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
-
- /* Close the file's fapl */
- ret = H5Pclose(file_fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close all the files */
- ret=H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
- ret=H5Fclose(fid2);
- CHECK(ret, FAIL, "H5Fclose");
-
-} /* end test_metadata_read_attempts() */
-
-/****************************************************************
-**
-** test_metadata_read_retry_info():
-** This test checks whether the public routine H5Fget_metadata_read_retry_info
-** works as specified in the reference manual.
-**
-*****************************************************************/
-static void
-test_metadata_read_retry_info(void)
-{
- hid_t fapl, new_fapl; /* File access property list */
- hid_t fid, fid1; /* File IDs */
- H5F_retry_info_t info, info1; /* The collection of metadata retries */
- H5F_t *f = NULL, *f1 = NULL; /* Internal file object pointers */
- unsigned i, j, n; /* Local index variables */
- herr_t ret; /* Generic return value */
- hid_t did1, did2; /* Dataset IDs */
- hid_t sid; /* Dataspace ID */
- hid_t dcpl; /* Dataset creation property list */
- hsize_t dims[2] = {6, 10}; /* Dataset dimensions */
- int buf[6][10], chkbuf1[6][10], chkbuf2[6][10]; /* Buffers for data */
- hsize_t max_dims_1un[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimensions */
- hsize_t max_dims_2un[2] = {500, H5S_UNLIMITED}; /* Dataset maximum dimensions */
- hsize_t chunk_dims[2] = {2, 2}; /* Chunk dimensions */
-
-
- /* Output message about test being performed */
- MESSAGE(5, ("Testing H5Fget_metadata_read_retry_info()\n"));
-
- /*
- * Set up file for testing
- */
- /* Create a file access property list */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
-
- /* Set to use latest library format */
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Create a file without SWMR access */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Create a chunked dataset with 1 unlimited dimension: extensible array indexing will be used */
- sid = H5Screate_simple(2, dims, max_dims_1un);
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- ret = H5Pset_chunk(dcpl, 2, chunk_dims);
- did1 = H5Dcreate2(fid, "DSET_1UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
-
- /* Create a chunked dataset with 2 unlimited dimension: v2 Btree indexing will be used */
- sid = H5Screate_simple(2, dims, max_dims_2un);
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- ret = H5Pset_chunk(dcpl, 2, chunk_dims);
- did2 = H5Dcreate2(fid, "DSET_2UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
-
- /* Initialize buffer data */
- for(i = n = 0; i < 6; i++)
- for(j = 0; j < 10; j++)
- buf[i][j] = (int)n++;
-
- /* Write to the 2 datasets */
- ret = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- ret = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
-
- /* Closing */
- ret = H5Dclose(did1);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Dclose(did2);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Sclose");
- ret = H5Pclose(dcpl);
- CHECK(ret, FAIL, "H5Pclose");
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Case 1: tests on nbins
- */
- /*
- * Open a file without SWMR access, default # of read attempts--
- * info.nbins should be 0
- * info.retries should all be NULL
- */
- /* Open the file without SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Open the dataset */
- did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT);
- CHECK(did1, FAIL, "H5Dopen");
- ret = H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1);
- CHECK(ret, FAIL, "H5Dopen");
-
- /* Open the dataset */
- did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT);
- CHECK(did2, FAIL, "H5Dopen");
- ret = H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2);
- CHECK(ret, FAIL, "H5Dopen");
-
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 0 */
- VERIFY(info.nbins, 0, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Closing */
- ret=H5Dclose(did1);
- CHECK(ret, FAIL, "H5Dclose");
- ret=H5Dclose(did2);
- CHECK(ret, FAIL, "H5Dclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Open a file with SWMR access, default # of read attempts--
- * info.nbins should be 2
- * info.retries should all be NULL
- */
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 2 */
- VERIFY(info.nbins, 2, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Closing */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
-
- /*
- * Open a file with SWMR access, # of read_attempts is 10:
- * info.nbins should be 1
- * info.retries should all be NULL
- */
- new_fapl = H5Pcopy(fapl);
- ret = H5Pset_metadata_read_attempts(new_fapl, 10);
- CHECK(ret, FAIL, "H5Pset_metadatda_read_attempts");
-
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Retrieve retry information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 1 */
- VERIFY(info.nbins, 1, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Closing */
- ret=H5Pclose(new_fapl);
- CHECK(ret, FAIL, "H5Pclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Open a file with SWMR access, # of read attempts is 101:
- * info.nbins should be 3
- * info.retries should all be NULL
- */
- new_fapl = H5Pcopy(fapl);
- ret = H5Pset_metadata_read_attempts(new_fapl, 101);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Retrieve retry information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 3 */
- VERIFY(info.nbins, 3, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Closing */
- ret=H5Pclose(new_fapl);
- CHECK(ret, FAIL, "H5Pclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Open a file with SWMR access, # of read_attempts is 10000:
- * info.nbins should be 4
- * info.retries should all be NULL
- */
- new_fapl = H5Pcopy(fapl);
- CHECK(new_fapl, FAIL, "H5Pcopy");
-
- ret = H5Pset_metadata_read_attempts(new_fapl, 10000);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Retrieve retry information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 4 */
- VERIFY(info.nbins, 4, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Closing */
- ret=H5Pclose(new_fapl);
- CHECK(ret, FAIL, "H5Pclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Open a file with SWMR access, # of read_attempts is 1:
- * info.nbins should be 0
- * info.retries should all be NULL
- */
- new_fapl = H5Pcopy(fapl);
- CHECK(new_fapl, FAIL, "H5Pcopy");
-
- ret = H5Pset_metadata_read_attempts(new_fapl, 1);
- CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
-
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Retrieve retry information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 0 */
- VERIFY(info.nbins, 0, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Closing */
- ret=H5Pclose(new_fapl);
- CHECK(ret, FAIL, "H5Pclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
-
- /*
- * Case 2: tests on retries info
- */
-
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Open the dataset */
- did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT);
- CHECK(did1, FAIL, "H5Dopen");
-
- /* Read data from the dataset */
- ret = H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Open the dataset */
- did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT);
- CHECK(did2, FAIL, "H5Dopen");
-
- /* Read data from the dataset */
- ret = H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Retrieve retry information */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 2 */
- VERIFY(info.nbins, 2, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
-
- /* Get a pointer to the internal file object */
- f = (H5F_t *)H5I_object(fid);
- CHECK(f, NULL, "H5I_object");
-
- /*
- * Increment 1st set of retries for metadata items:
- * a) v2 B-tree leaf node--retries[4][1]
- * b) Extensive array data block--retries[15][1]
- * c) File's superblock--retries[20][0]
- */
-
- /* v2 B-tree leaf node: log retry 99 for 500 times */
- for(i = 0; i < 500; i++) {
- ret = H5F_track_metadata_read_retries(f, H5AC_BT2_LEAF_ID, 99);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
- }
-
- /* Extensive array data block: log retry 10 for 1000 times */
- for(i = 0; i < 1000; i++) {
- ret = H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 10);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
- }
-
- /* File's superblock: log retry 1 for 1 time */
- ret = H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
-
- /* Retrieve the collection of metadata read retries */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for v2 B-tree leaf node */
- VERIFY(info.retries[4][0], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[4][1], 500, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for extensive array data block */
- VERIFY(info.retries[15][0], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[15][1], 1000, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for file's superblock */
- VERIFY(info.retries[20][0], 1, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[20][1], 0, "H5Fget_metadata_read_retry_info");
-
- /* Free memory for info.retries */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
- if(info.retries[i] != NULL)
- HDfree(info.retries[i]);
- }
-
- /*
- * Increment 2nd set of retries for metadata items:
- * a) Object header--retries[0][0]
- * b) Extensive array datablock--retries[15][0]
- * c) Fixed array header--retries[17][1]
- * d) File's superblock--retries[20][0]
- */
-
- /* Object header: log retry 5 for 5 times */
- for(i = 0; i < 5; i++) {
- ret = H5F_track_metadata_read_retries(f, H5AC_OHDR_ID, 5);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
- }
-
- /* Extensive array data block: log retry 4 for 1 time */
- ret = H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 4);
-
- /* Fixed array header : log retry 50 for 10000 times */
- for(i = 0; i < 10000; i++) {
- ret = H5F_track_metadata_read_retries(f, H5AC_FARRAY_HDR_ID, 50);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
- }
-
- /* File's superblock: log retry 1 for 1 more time */
- ret = H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
-
- /* Retrieve the collection of metadata read retries */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /*
- * Verify info has both previous + current retries information:
- */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
- switch(i) {
- case 0: /* Object header */
- VERIFY(info.retries[i][0], 5, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retry_info");
- break;
-
- case 4: /* v2 B-tree leaf node */
- VERIFY(info.retries[i][0], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][1], 500, "H5Fget_metadata_read_retry_info");
- break;
-
- case 15: /* Extensive array data block */
- VERIFY(info.retries[i][0], 1, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][1], 1000, "H5Fget_metadata_read_retry_info");
- break;
-
- case 17: /* Fixed array header */
- VERIFY(info.retries[i][0], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][1], 10000, "H5Fget_metadata_read_retry_info");
- break;
-
- case 20: /* File's superblock */
- VERIFY(info.retries[i][0], 2, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retry_info");
- break;
-
- default:
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
- break;
- }
- }
-
- /* Free memory for info.retries */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- if(info.retries[i] != NULL)
- HDfree(info.retries[i]);
-
- /* Closing */
- ret=H5Dclose(did1);
- CHECK(ret, FAIL, "H5Dclose");
- ret=H5Dclose(did2);
- CHECK(ret, FAIL, "H5Dclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Get a copy of the file access property list */
- new_fapl = H5Pcopy(fapl);
-
- /* Set the number of metadata read attempts to 101 */
- ret = H5Pset_metadata_read_attempts(new_fapl, 101);
-
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Get a pointer to the internal file object */
- f = (H5F_t *)H5I_object(fid);
- CHECK(f, NULL, "H5I_object");
-
- /* File's superblock: log retry 1 for 1 time */
- H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1);
-
- /* Retrieve the collection of metadata read retries */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 3 */
- VERIFY(info.nbins, 3, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries info */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
- switch(i) {
- case 20: /* File's superblock */
- VERIFY(info.retries[i][0], 1, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[i][2], 0, "H5Fget_metadata_read_retry_info");
- break;
-
- default:
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
- break;
- }
- }
-
- /* Free memory */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
- if(info.retries[i] != NULL)
- HDfree(info.retries[i]);
-
- /* Closing */
- ret=H5Pclose(new_fapl);
- CHECK(ret, FAIL, "H5Pclose");
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Case 3: Tests on retrieving the collection of retries
- * when H5Fopen and H5Freopen the same file.
- */
-
- /*
- * Open a file without SWMR access, default # of read attempts--
- * H5Freopen the same file--
- * Both files should:
- * nbins should be 0
- * retries should all be NULL
- */
- /* Open the file without SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Re-open fid */
- fid1 = H5Freopen(fid);
- CHECK(fid, FAIL, "H5Freopen");
-
- /* Retrieve retries information for fid */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Retrieve retries information for fid1*/
- ret = H5Fget_metadata_read_retry_info(fid1, &info1);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Should be 0 */
- VERIFY(info.nbins, 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info1.nbins, 0, "H5Fget_metadata_read_retry_info");
-
- /* Should be all NULL */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
- VERIFY(info1.retries[i], NULL, "H5Fget_metadata_read_retry_info");
- }
-
- /* Closing */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
- ret=H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
-
- /*
- * Open a file with SWMR access, default # of read attempts:
- * --increment retries for metadata item: fixed array data block page (retries[19][0])
- * H5Freopen the same file:
- * --increment retries for metadata item: free-space sections (retries[9][1])--
- */
- /* Open the file with SWMR access */
- fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Get a pointer to the internal file object for fid */
- f = (H5F_t *)H5I_object(fid);
- CHECK(f, NULL, "H5I_object");
-
- /* Re-open fid */
- fid1 = H5Freopen(fid);
- CHECK(fid, FAIL, "H5Freopen");
-
- /* Get a pointer to the internal file object for fid1 */
- f1 = (H5F_t *)H5I_object(fid1);
- CHECK(f, NULL, "H5I_object");
-
- /* For fid: fixed array data block page--log retry 9 for 500 times */
- for(i = 0; i < 500; i++) {
- ret = H5F_track_metadata_read_retries(f, H5AC_FARRAY_DBLK_PAGE_ID, 9);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
- }
-
- /* For fid1: free-space sections--log retry 99 for 1000 times */
- for(i = 0; i < 1000; i++) {
- ret = H5F_track_metadata_read_retries(f1, H5AC_FSPACE_SINFO_ID, 99);
- CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
- }
-
- /* Retrieve the collection of metadata read retries for fid */
- ret = H5Fget_metadata_read_retry_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Retrieve the collection of metadata read retries for fid1 */
- ret = H5Fget_metadata_read_retry_info(fid1, &info1);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
-
- /* Verify nbins for fid & fid1: should be 2 */
- VERIFY(info.nbins, 2, "H5Fget_metadata_read_retry_info");
- VERIFY(info1.nbins, 2, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for fid: fixed array data block page */
- VERIFY(info.retries[19][0], 500, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[19][1], 0, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for fid: free-space sections */
- /* (Since file was re-opened) */
- VERIFY(info.retries[9][0], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info.retries[9][1], 1000, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for fid1: free-space sections */
- VERIFY(info1.retries[9][0], 0, "H5Fget_metadata_read_retry_info");
- VERIFY(info1.retries[9][1], 1000, "H5Fget_metadata_read_retry_info");
-
- /* Verify retries for fid1: fixed array data block page */
- /* (Since file was re-opened) */
- VERIFY(info1.retries[19][0], 500, "H5Fget_metadata_read_retry_info");
- VERIFY(info1.retries[19][1], 0, "H5Fget_metadata_read_retry_info");
-
- /* Free memory for info.retries and info1.retries */
- for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
- if(info.retries[i] != NULL)
- HDfree(info.retries[i]);
- if(info1.retries[i] != NULL)
- HDfree(info1.retries[i]);
- } /* end for */
-
- /* Closing */
- ret=H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
- ret=H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
-
- ret=H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-} /* end test_metadata_read_retry_info() */
-
-/****************************************************************
-**
** test_file_lock_same():
** With the implementation of file locking, this test checks file
** open with different combinations of flags.
@@ -6370,8 +5092,6 @@ test_file(void)
test_libver_bounds(); /* Test compatibility for file space management */
test_libver_macros(); /* Test the macros for library version comparison */
test_libver_macros2(); /* Test the macros for library version comparison */
- test_metadata_read_attempts(); /* Tests for public routines H5Fget/set_metadata_read_attempts() */
- test_metadata_read_retry_info(); /* Tests for public routine H5Fget_metadata_read_retry_info() */
/*
* The two tests: test_swmr_write() and test_swmr_read() are removed.
* They are covered by the following new tests.
diff --git a/test/th5o.c b/test/th5o.c
index a5a0727..3e6b8cb 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -29,10 +29,6 @@
#define DIM0 5
#define DIM1 10
-/* For test: test_h5o_cork_dataset() */
-#define DIMS0 50
-#define DIMS1 100
-
#define TEST6_DIM1 100
#define TEST6_DIM2 100
@@ -1339,358 +1335,6 @@ test_h5o_getinfo_same_file(void)
} /* test_h5o_getinfo_same_file() */
-/*
- * Test H5Ocork/H5Ouncork/H5Ois_corked public routines:
- * cork objects: group, dataset, named datatype
- * cork a corked object
- * uncork a non-corked object
- * cork a non-object
- */
-static void
-test_h5o_cork(void)
-{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype; /* Object identifiers */
- hid_t dspace; /* Dataspace ID */
- hsize_t dims[RANK]; /* Dataset dimension sizes */
- hbool_t corked; /* Cork status of an object */
- herr_t ret; /* Return value */
-
- /* Create a new HDF5 file */
- fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Create a group, dataset, and committed datatype within the file */
- /* Create the group */
- grp = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(grp, FAIL, "H5Gcreate2");
- ret = H5Gclose(grp);
- CHECK(ret, FAIL, "H5Gclose");
-
- /* Commit the type inside the group */
- dtype = H5Tcopy(H5T_NATIVE_INT);
- CHECK(dtype, FAIL, "H5Tcopy");
- ret = H5Tcommit2(fid, "group/datatype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Tcommit2");
- ret = H5Tclose(dtype);
- CHECK(ret, FAIL, "H5Tclose");
-
- /* Create the data space for the dataset. */
- dims[0] = DIM0;
- dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
- CHECK(dspace, FAIL, "H5Screate_simple");
-
- /* Cork the dataspace: should fail */
- ret = H5Ocork(dspace);
- VERIFY(ret, FAIL, "H5Ocork");
-
- /* Create the dataset. */
- dset = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Dcreate2");
- ret = H5Dclose(dset);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Sclose(dspace);
- CHECK(ret, FAIL, "H5Sclose");
-
- /* Open the group */
- grp = H5Oopen(fid, "group", H5P_DEFAULT);
- CHECK(grp, FAIL, "H5Oopen");
-
- /* Open the datatype */
- dtype = H5Oopen(fid, "group/datatype", H5P_DEFAULT);
- CHECK(dtype, FAIL, "H5Oopen");
-
- /* Open the dataset */
- dset = H5Oopen(fid, "/dataset", H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Oopen");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Cork the dataset */
- ret = H5Ocork(dset);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Check cork status of group */
- ret = H5Ois_corked(grp, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Cork the group */
- ret = H5Ocork(grp);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of group */
- ret = H5Ois_corked(grp, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Cork the group again: should fail */
- ret = H5Ocork(grp);
- VERIFY(ret, FAIL, "H5Ois_corked");
-
- /* Uncork the group */
- ret = H5Ouncork(grp);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of group */
- ret = H5Ois_corked(grp, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Check cork status of datatype */
- ret = H5Ois_corked(dtype, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Cork the datatype */
- ret = H5Ocork(dtype);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of datatype*/
- ret = H5Ois_corked(dtype, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Uncork the datatype */
- ret = H5Ouncork(dtype);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of datatype*/
- ret = H5Ois_corked(dtype, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Uncork the datatype that is not corked */
- ret = H5Ouncork(dtype);
- VERIFY(ret, FAIL, "H5Ois_corked");
-
- ret = H5Oclose(dtype);
- CHECK(ret, FAIL, "H5Oclose");
- ret = H5Oclose(grp);
- CHECK(ret, FAIL, "H5Oclose");
- ret = H5Oclose(dset);
- CHECK(ret, FAIL, "H5Oclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
-} /* test_h5o_cork() */
-
-/*
- * Test H5Ocork/H5Ouncork/H5Ois_corked with dataset activities:
- * H5Oflush, H5Orefresh
- * H5Ldelete
- * H5Dread/H5Dwrite
- * H5Dopen the dataset twice
- */
-static void
-test_h5o_cork_dataset(void)
-{
- hid_t fid; /* File ID */
- hid_t grp, dset, dset2, dtype; /* Object IDs */
- hid_t sid; /* Dataspace ID */
- hid_t dcpl; /* Dataset creation property list */
- hsize_t dims[RANK]; /* Dataset dimensions */
- hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */
- hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */
- int fillval = 0; /* Fill value */
- int i, j, k = 0; /* Local index variables */
- int data[DIMS0][DIMS1]; /* Data buffer */
- int rbuf[DIMS0][DIMS1]; /* Data buffer */
- hbool_t corked; /* Cork status of an object */
- herr_t ret; /* Value returned from API calls */
-
- /* Create a new HDF5 file */
- fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Create a group */
- grp = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(grp, FAIL, "H5Gcreate2");
- ret = H5Gclose(grp);
- CHECK(ret, FAIL, "H5Gclose");
-
- /* Commit the type inside the group */
- dtype = H5Tcopy(H5T_NATIVE_INT);
- CHECK(dtype, FAIL, "H5Tcopy");
- ret = H5Tcommit2(fid, "group/datatype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Tcommit2");
- ret = H5Tclose(dtype);
- CHECK(ret, FAIL, "H5Tclose");
-
- /* Set up dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
-
- /* Enable chunking */
- ret = H5Pset_chunk(dcpl, RANK, cdims);
- CHECK(ret, FAIL, "H5Pset_chunk");
-
- /* Set up a fill value */
- ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- CHECK(ret, FAIL, "H5Pset_fill_value");
-
- /* Create the data space for the dataset. */
- dims[0] = DIMS0;
- dims[1] = DIMS1;
- sid = H5Screate_simple(RANK, dims, maxdims);
- CHECK(sid, FAIL, "H5Screate_simple");
-
- /* Create the dataset. */
- dset = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Dcreate2");
-
- /* Open group */
- grp = H5Oopen(fid, "group", H5P_DEFAULT);
- CHECK(grp, FAIL, "H5Oopen");
-
- /* Open the datatype */
- dtype = H5Oopen(fid, "group/datatype", H5P_DEFAULT);
- CHECK(dtype, FAIL, "H5Oopen");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Cork the dataset */
- ret = H5Ocork(dset);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Initialize the buffer */
- for(i = 0; i < DIMS0;i++)
- for(j = 0;j < DIMS1;j++)
- data[i][j] = k++;
-
- /* Write to the dataset */
- ret = H5Dwrite(dset, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Flush the dataset */
- ret = H5Oflush(dset);
- CHECK(ret, FAIL, "H5Oflush");
-
- /* Close the dataset */
- ret = H5Oclose(dset);
- CHECK(ret, FAIL, "H5Oclose");
-
- /* Open the dataset again */
- dset = H5Dopen2(fid, "dataset", H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Dopen2");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, FALSE, "H5Ois_corked");
-
- /* Cork the dataset */
- ret = H5Ocork(dset);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Delete the dataset */
- ret = H5Ldelete(fid, "dataset", H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Ldelete");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Close the dataset */
- ret = H5Oclose(dset);
- CHECK(ret, FAIL, "H5Oclose");
-
- /* Create the dataset. */
- dset = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Dcreate2");
-
- /* Cork the dataset */
- ret = H5Ocork(dset);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Write to the dataset */
- ret = H5Dwrite(dset, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Refresh the dataset */
- ret = H5Drefresh(dset);
- CHECK(ret, FAIL, "H5Drefresh");
-
- /* Check cork status of dataset */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Close the dataset */
- ret = H5Dclose(dset);
- CHECK(ret, FAIL, "H5Dclose");
-
- /* Open the dataset */
- dset = H5Dopen2(fid, "dataset", H5P_DEFAULT);
- CHECK(dset, FAIL, "H5Dopen2");
-
- /* Read from the dataset */
- ret = H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Re-open the dataset */
- dset2 = H5Dopen2(fid, "dataset", H5P_DEFAULT);
- CHECK(dset2, FAIL, "H5Dopen2");
-
- /* Cork the dataset of the first open */
- ret = H5Ocork(dset);
- CHECK(ret, FAIL, "H5Ocork");
-
- /* Check cork status of the first open */
- ret = H5Ois_corked(dset, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Check cork status of the second open */
- ret = H5Ois_corked(dset2, &corked);
- CHECK(ret, FAIL, "H5Ocork");
- VERIFY(corked, TRUE, "H5Ois_corked");
-
- /* Close the dataset of the second open */
- ret = H5Dclose(dset2);
- CHECK(ret, FAIL, "H5Dclose");
-
- /* Close the dastaset */
- ret = H5Dclose(dset);
- CHECK(ret, FAIL, "H5Dclose");
-
- /* Close the datatype */
- ret = H5Oclose(dtype);
- CHECK(ret, FAIL, "H5Oclose");
-
- /* Close the group */
- ret = H5Oclose(grp);
- CHECK(ret, FAIL, "H5Oclose");
-
- /* Close the dataspace */
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Oclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
-} /* test_h5o_cork_dataset() */
/****************************************************************
@@ -1715,13 +1359,6 @@ test_h5o(void)
#ifndef H5_CANNOT_OPEN_TWICE /* OpenVMS can't open a file twice */
test_h5o_getinfo_same_file(); /* Test info for objects in the same file */
#endif /* H5_CANNOT_OPEN_TWICE */
- /*
- * NEED: more work on tests for corking/uncorking objects such as:
- * verify cache entries are corked/uncorked
- * object data are correct
- */
- test_h5o_cork(); /* Test H5Ocork/H5Ouncork/H5Ois_corked public routines */
- test_h5o_cork_dataset(); /* Test H5Ocork/H5Ouncork/H5Ois_corked public routines */
} /* test_h5o() */