summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2013-07-30 20:18:27 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2013-07-30 20:18:27 (GMT)
commit4d080e50f6bde9746d2dc12ced01d7f5758965cb (patch)
tree778c7a6ec441bcf5dfc0fa75570b5ec6288cebde /test
parent8e9a3a200bd58bb4a98f32452a60cd2eb23fa26c (diff)
downloadhdf5-4d080e50f6bde9746d2dc12ced01d7f5758965cb.zip
hdf5-4d080e50f6bde9746d2dc12ced01d7f5758965cb.tar.gz
hdf5-4d080e50f6bde9746d2dc12ced01d7f5758965cb.tar.bz2
[svn-r23946] Bring revisions #23597 - #23670 from trunk to revise_chunks.
h5committested.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in28
-rw-r--r--test/fillval.c262
-rw-r--r--test/unregister.c258
4 files changed, 542 insertions, 10 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 0c77646..22b7224 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -47,7 +47,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf farray earray btree2 fheap file_image
+ freespace mf farray earray btree2 fheap file_image unregister
bin_PROGRAMS=swmr_generator swmr_reader swmr_writer swmr_remove_reader \
swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \
@@ -158,7 +158,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 \
earray.h5 efc[0-5].h5 log_vfd_out.log \
new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \
split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \
- file_image_core_test.h5.copy \
+ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \
swmr_data.h5 use_append_chunk.h5 use_append_mchunks.h5 \
flushrefresh.h5 flushrefresh_VERIFICATION_START \
flushrefresh_VERIFICATION_CHECKPOINT1 flushrefresh_VERIFICATION_CHECKPOINT2 \
diff --git a/test/Makefile.in b/test/Makefile.in
index faed943..73da8bd 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -176,7 +176,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \
freespace$(EXEEXT) mf$(EXEEXT) farray$(EXEEXT) earray$(EXEEXT) \
- btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT)
+ btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT) \
+ unregister$(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) \
@@ -547,6 +548,10 @@ unlink_SOURCES = unlink.c
unlink_OBJECTS = unlink.$(OBJEXT)
unlink_LDADD = $(LDADD)
unlink_DEPENDENCIES = libh5test.la $(LIBHDF5)
+unregister_SOURCES = unregister.c
+unregister_OBJECTS = unregister.$(OBJEXT)
+unregister_LDADD = $(LDADD)
+unregister_DEPENDENCIES = libh5test.la $(LIBHDF5)
am_use_append_chunk_OBJECTS = use_append_chunk.$(OBJEXT) \
use_common.$(OBJEXT)
use_append_chunk_OBJECTS = $(am_use_append_chunk_OBJECTS)
@@ -616,8 +621,9 @@ SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \
swmr_generator.c swmr_reader.c swmr_remove_reader.c \
swmr_remove_writer.c swmr_sparse_reader.c swmr_sparse_writer.c \
swmr_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
- $(ttsafe_SOURCES) unlink.c $(use_append_chunk_SOURCES) \
- $(use_append_mchunks_SOURCES) vfd.c
+ $(ttsafe_SOURCES) unlink.c unregister.c \
+ $(use_append_chunk_SOURCES) $(use_append_mchunks_SOURCES) \
+ vfd.c
DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \
$(am__libdynlib2_la_SOURCES_DIST) \
$(am__libdynlib3_la_SOURCES_DIST) $(libh5test_la_SOURCES) \
@@ -640,8 +646,9 @@ DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \
swmr_generator.c swmr_reader.c swmr_remove_reader.c \
swmr_remove_writer.c swmr_sparse_reader.c swmr_sparse_writer.c \
swmr_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
- $(ttsafe_SOURCES) unlink.c $(use_append_chunk_SOURCES) \
- $(use_append_mchunks_SOURCES) vfd.c
+ $(ttsafe_SOURCES) unlink.c unregister.c \
+ $(use_append_chunk_SOURCES) $(use_append_mchunks_SOURCES) \
+ vfd.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -963,8 +970,9 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \
earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \
new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \
split_get_file_image_test-r.h5 file_image_core_test.h5.copy \
- swmr_data.h5 use_append_chunk.h5 use_append_mchunks.h5 \
- flushrefresh.h5 flushrefresh_VERIFICATION_START \
+ unregister_filter_1.h5 unregister_filter_2.h5 swmr_data.h5 \
+ use_append_chunk.h5 use_append_mchunks.h5 flushrefresh.h5 \
+ flushrefresh_VERIFICATION_START \
flushrefresh_VERIFICATION_CHECKPOINT1 \
flushrefresh_VERIFICATION_CHECKPOINT2 \
flushrefresh_VERIFICATION_DONE atomic_data accum_swmr_big.h5 \
@@ -992,7 +1000,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf farray earray btree2 fheap file_image
+ freespace mf farray earray btree2 fheap file_image unregister
# These programs generate test files for the tests. They don't need to be
@@ -1488,6 +1496,9 @@ ttsafe$(EXEEXT): $(ttsafe_OBJECTS) $(ttsafe_DEPENDENCIES) $(EXTRA_ttsafe_DEPENDE
unlink$(EXEEXT): $(unlink_OBJECTS) $(unlink_DEPENDENCIES) $(EXTRA_unlink_DEPENDENCIES)
@rm -f unlink$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(unlink_OBJECTS) $(unlink_LDADD) $(LIBS)
+unregister$(EXEEXT): $(unregister_OBJECTS) $(unregister_DEPENDENCIES) $(EXTRA_unregister_DEPENDENCIES)
+ @rm -f unregister$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(unregister_OBJECTS) $(unregister_LDADD) $(LIBS)
use_append_chunk$(EXEEXT): $(use_append_chunk_OBJECTS) $(use_append_chunk_DEPENDENCIES) $(EXTRA_use_append_chunk_DEPENDENCIES)
@rm -f use_append_chunk$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(use_append_chunk_OBJECTS) $(use_append_chunk_LDADD) $(LIBS)
@@ -1626,6 +1637,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvlstr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvltypes.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unregister.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/use_append_chunk.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/use_append_mchunks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/use_common.Po@am__quote@
diff --git a/test/fillval.c b/test/fillval.c
index 847dfbd..9271f80 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -37,6 +37,7 @@ const char *FILENAME[] = {
"fillval_6",
"fillval_7",
"fillval_8",
+ "fillval_9",
NULL
};
@@ -2085,6 +2086,266 @@ error:
return 1;
}
+/*-------------------------------------------------------------------------
+ * Function: test_partalloc_cases
+ *
+ * Purpose: Tests fill values read and write for datasets.
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Joel Plutchak
+ * April 15, 2013
+ *
+ * Modifications:
+ * This function is called by test_rdwr to write and read
+ * dataset for different cases of chunked datasets with
+ * unallocated chunks.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static int
+test_partalloc_cases(hid_t file, hid_t dcpl, const char *dname, H5D_fill_time_t fill_time)
+{
+ hid_t fspace=-1, dset1=-1, rspace = -1;
+ herr_t ret;
+ hsize_t ds_size[2] = {4, 4};
+ hsize_t max_size[2] = {H5S_UNLIMITED,4};
+ hsize_t chunk_size[2] = {1, 4};
+ int fillval=(-1);
+ int w_values[] = {42}; /* New value to be written */
+ int f_values[4] = {88,88,88,88}; /* pre-seed read buffer with known values */
+ int r_values[4] = {88,88,88,88}; /* pre-seed read buffer with known values */
+ hsize_t coord[1][2]; /* coordinate(s) of point to write */
+ hsize_t start[2], count[2];
+
+ fillval = 0; /* default fill value is zero */
+
+ /* Create dataset with 4x4 integer dataset */
+ if((fspace = H5Screate_simple(2, ds_size, max_size)) < 0)
+ goto error;
+ if((dset1 = H5Dcreate2(file, dname, H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /*
+ * Select a point in the file dataspace.
+ */
+ coord[0][0]=0; coord[0][1]=0;
+ if (H5Sselect_elements( fspace, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord))
+ goto error;
+
+ /*
+ * Write single data point to the dataset.
+ */
+ if ((ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, fspace, H5P_DEFAULT, w_values))< 0) {
+ goto error;
+ }
+
+ /* Read a line/chunk and make sure values are right */
+ rspace = H5Screate_simple(2, chunk_size, NULL);
+
+ /* Read the first row of elements: one known plus three fill */
+ start[0] = 0;
+ start[1] = 0;
+ count[0] = 1;
+ count[1] = 4;
+ if ((ret = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, start, NULL, count, NULL)) < 0)
+ goto error;
+ if ((ret = H5Sselect_all(rspace)) < 0)
+ goto error;
+ if(H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &r_values) < 0)
+ goto error;
+
+ /* Read the third row of elements: all fill */
+ start[0] = 2;
+ start[1] = 0;
+ count[0] = 1;
+ count[1] = 4;
+ if ((ret = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, start, NULL, count, NULL)) < 0)
+ goto error;
+ if(H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &f_values) < 0)
+ goto error;
+
+ if(fill_time != H5D_FILL_TIME_NEVER) {
+ /* check allocated chunk */
+ if ((r_values[0] != w_values[0]) ||
+ (r_values[1] != fillval) ||
+ (r_values[2] != fillval) ||
+ (r_values[3] != fillval)) {
+ H5_FAILED();
+ HDfprintf(stdout, "%u: Allocated chunk value read was not correct.\n", (unsigned)__LINE__);
+ printf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n",
+ (long)r_values[0], (long)r_values[1],
+ (long)r_values[2], (long)r_values[3],
+ (long)w_values[0], (long)fillval,
+ (long)fillval, (long)fillval );
+ goto error;
+ }
+ /* check unallocated chunk */
+ if ((f_values[0] != fillval) ||
+ (f_values[1] != fillval) ||
+ (f_values[2] != fillval) ||
+ (f_values[3] != fillval)) {
+ H5_FAILED();
+ HDfprintf(stdout, "%u: Unallocated chunk value read was not correct.\n", (unsigned)__LINE__);
+ printf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n",
+ (long)f_values[0], (long)f_values[1],
+ (long)f_values[2], (long)f_values[3],
+ (long)fillval, (long)fillval,
+ (long)fillval, (long)fillval );
+ goto error;
+ }
+ /* for the "never fill" case expect to get trash values, so skip */
+ }
+ else if(fill_time == H5D_FILL_TIME_NEVER) {
+ }
+
+ if(H5Sclose(rspace) < 0) goto error;
+ if(H5Dclose(dset1) < 0) goto error;
+ if(H5Sclose(fspace) < 0) goto error;
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset1);
+ H5Sclose(fspace);
+ H5Sclose(rspace);
+ } H5E_END_TRY;
+
+ return 1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_partalloc
+ *
+ * Purpose: Tests fill values for chunked, partially-allocated datasets.
+ * Regression test for HDFFV-8247.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Joel Plutchak
+ * April 15, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_partalloc(hid_t fapl, const char *base_name)
+{
+ char filename[1024];
+ hid_t file=-1, dcpl=-1;
+ hsize_t ch_size[2] = {1, 4};
+ int nerrors=0;
+
+ TESTING("chunked dataset partially allocated I/O");
+
+ h5_fixname(base_name, fapl, filename, sizeof filename);
+ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if(H5Pset_chunk(dcpl, 2, ch_size) < 0) goto error;
+
+ /* I. Test H5D_ALLOC_TIME_LATE space allocation cases */
+ if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, "\nALLOC_TIME_LATE\n" );
+#endif
+
+ /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_ALLOC\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset1", H5D_FILL_TIME_ALLOC);
+
+ /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_NEVER\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset2", H5D_FILL_TIME_NEVER );
+
+ /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_IFSET\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset3", H5D_FILL_TIME_IFSET );
+
+ /* II. Test H5D_ALLOC_TIME_INCR space allocation cases */
+ if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, "\nALLOC_TIME_INCR\n" );
+#endif
+
+ /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_ALLOC\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset4", H5D_FILL_TIME_ALLOC );
+
+ /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_NEVER\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset5", H5D_FILL_TIME_NEVER );
+
+ /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_IFSET\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset6", H5D_FILL_TIME_IFSET );
+
+ /* III. Test H5D_ALLOC_TIME_EARLY space allocation cases */
+ if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, "\nALLOC_TIME_EARLY\n" );
+#endif
+
+ /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_ALLOC\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset7", H5D_FILL_TIME_ALLOC );
+
+ /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_NEVER\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset8", H5D_FILL_TIME_NEVER );
+
+ /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error;
+#ifdef DEBUG
+ fprintf( stdout, " FILL_TIME_IFSET\n" );
+#endif
+ nerrors += test_partalloc_cases(file, dcpl, "dset9", H5D_FILL_TIME_IFSET );
+
+ if(nerrors)
+ goto error;
+ if(H5Pclose(dcpl) < 0) goto error;
+ if(H5Fclose(file) < 0) goto error;
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return nerrors;
+}
+
/*-------------------------------------------------------------------------
* Function: main
@@ -2157,6 +2418,7 @@ main(int argc, char *argv[])
nerrors += test_create(my_fapl, FILENAME[0], H5D_CHUNKED);
nerrors += test_rdwr (my_fapl, FILENAME[2], H5D_CHUNKED);
nerrors += test_extend(my_fapl, FILENAME[4], H5D_CHUNKED);
+ nerrors += test_partalloc(my_fapl, FILENAME[8]);
} /* end if */
/* Contiguous storage layout tests */
diff --git a/test/unregister.c b/test/unregister.c
new file mode 100644
index 0000000..88f4d1b
--- /dev/null
+++ b/test/unregister.c
@@ -0,0 +1,258 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * 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 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: Raymond Lu
+ * 24 April 2013
+ *
+ * Purpose: Tests H5Zunregister function
+ */
+#include "h5test.h"
+
+const char *FILENAME[] = {
+ "unregister_filter_1",
+ "unregister_filter_2",
+ NULL
+};
+
+#define GROUP_NAME "group"
+#define DSET_NAME "dataset"
+#define FILENAME_BUF_SIZE 1024
+#define DSET_DIM1 100
+#define DSET_DIM2 200
+#define FILTER_CHUNK_DIM1 2
+#define FILTER_CHUNK_DIM2 25
+#define GROUP_ITERATION 1000
+
+#define H5Z_FILTER_DUMMY 312
+
+static size_t filter_dummy(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+
+/* Dummy filter for test_unregister_filters only */
+const H5Z_class2_t H5Z_DUMMY[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_DUMMY, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "dummy", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ filter_dummy, /* The actual filter function */
+}};
+
+
+/*-------------------------------------------------------------------------
+ * Function: filter_dummy
+ *
+ * Purpose: A dummy compression method that doesn't do anything. This
+ * filter is only for test_unregister_filters. Please don't
+ * use it for other tests because it may mess up this test.
+ *
+ * Return: Success: Data chunk size
+ *
+ * Failure: 0
+ *
+ * Programmer: Raymond Lu
+ * April 24, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+filter_dummy(unsigned int UNUSED flags, size_t UNUSED cd_nelmts,
+ const unsigned int UNUSED *cd_values, size_t nbytes,
+ size_t UNUSED *buf_size, void UNUSED **buf)
+{
+ return nbytes;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_unregister_filters
+ *
+ * Purpose: Tests unregistering filter before closing the file
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Raymond Lu
+ * 11 April 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_unregister_filters(hid_t my_fapl)
+{
+ hid_t file1, file2;
+ hid_t dc;
+ hid_t gcpl, gid, group;
+ hid_t dataset, space;
+ int i, j, n;
+ char gname[256];
+ char filename[FILENAME_BUF_SIZE];
+ const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
+ hsize_t dims[2];
+ int points[DSET_DIM1][DSET_DIM2];
+ herr_t ret;
+
+ TESTING("Unregistering filter");
+
+ /* Create first file */
+ h5_fixname(FILENAME[0], my_fapl, filename, sizeof filename);
+ if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) goto error;
+
+ /* Create second file */
+ h5_fixname(FILENAME[1], my_fapl, filename, sizeof filename);
+ if((file2 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) goto error;
+
+ /* Register DUMMY filter */
+ if(H5Zregister(H5Z_DUMMY) < 0) goto error;
+
+ if(H5Zfilter_avail(H5Z_FILTER_DUMMY)!=TRUE) goto error;
+
+ if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error;
+
+ /* Use DUMMY filter for creating groups */
+ if(H5Pset_filter (gcpl, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) goto error;
+
+ /* Create a group using this filter */
+ if((gid = H5Gcreate2(file1, GROUP_NAME, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error;
+
+ /* Create multiple groups under the main group */
+ for (i=0; i < GROUP_ITERATION; i++) {
+ sprintf(gname, "group_%d", i);
+ if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
+ if(H5Gclose(group) < 0) goto error;
+ }
+
+ if(H5Fflush(file1, H5F_SCOPE_GLOBAL) < 0) goto error;
+
+ /* Unregister the filter before closing the group. It should fail */
+ H5E_BEGIN_TRY {
+ ret = H5Zunregister(H5Z_FILTER_DUMMY);
+ } H5E_END_TRY;
+ if(ret>=0) {
+ H5_FAILED();
+ printf(" Line %d: Should not be able to unregister filter\n", __LINE__);
+ goto error;
+ } /* end if */
+
+
+ /* Close the group */
+ if(H5Gclose(gid) < 0) goto error;
+
+ /* Clean up objects used for this test */
+ if(H5Pclose (gcpl) < 0) goto error;
+
+ if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
+
+ if(H5Pset_filter(dc, H5Z_FILTER_DUMMY, 0, (size_t)0, NULL) < 0) goto error;
+
+ /* Initialize the dataset */
+ for(i = n = 0; i < DSET_DIM1; i++)
+ for(j = 0; j < DSET_DIM2; j++)
+ points[i][j] = n++;
+
+ /* Create the data space */
+ dims[0] = DSET_DIM1;
+ dims[1] = DSET_DIM2;
+ if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error;
+
+ /* Create a dataset in the first file */
+ if((dataset = H5Dcreate2(file1, DSET_NAME, H5T_NATIVE_INT, space,
+ H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
+
+ /* Write the data to the dataset */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ goto error;
+
+ /* Unregister the filter before closing the dataset. It should fail */
+ /*if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) goto error;*/
+ H5E_BEGIN_TRY {
+ ret = H5Zunregister(H5Z_FILTER_DUMMY);
+ } H5E_END_TRY;
+ if(ret>=0) {
+ H5_FAILED();
+ printf(" Line %d: Should not be able to unregister filter\n", __LINE__);
+ goto error;
+ } /* end if */
+
+ if(H5Dclose(dataset) < 0) goto error;
+
+ /* Create a dataset in the second file */
+ if((dataset = H5Dcreate2(file2, DSET_NAME, H5T_NATIVE_INT, space,
+ H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
+
+ /* Write the data to the dataset */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ goto error;
+
+ if(H5Dclose(dataset) < 0) goto error;
+
+ /* Unregister the filter after closing all objects but before closing files.
+ * It should flush all files. */
+ if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) goto error;
+
+ /* Clean up objects used for this test */
+ if(H5Pclose (dc) < 0) goto error;
+ if(H5Fclose(file1) < 0) goto error;
+ if(H5Fclose(file2) < 0) goto error;
+
+ PASSED();
+ return 0;
+
+error:
+ return -1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Tests unregistering filter with H5Zunregister
+ *
+ * Return: Success: exit(0)
+ *
+ * Failure: exit(1)
+ *
+ * Programmer: Raymond Lu
+ * 11 April 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t fapl;
+ int nerrors = 0;
+
+ /* Testing setup */
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ /* Test unregistering filter in its own file */
+ nerrors += (test_unregister_filters(fapl) < 0 ? 1 : 0);
+
+ if(nerrors)
+ goto error;
+ printf("All dataset tests passed.\n");
+ h5_cleanup(FILENAME, fapl);
+
+ return 0;
+
+error:
+ nerrors = MAX(1, nerrors);
+ printf("***** %d DATASET TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ return 1;
+}
+