summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST12
-rw-r--r--configure.ac8
-rw-r--r--test/CMakeLists.txt92
-rw-r--r--test/CMakeTests.cmake12
-rw-r--r--test/Makefile.am49
-rw-r--r--test/dynlib1.c95
-rw-r--r--test/dynlib2.c92
-rw-r--r--test/dynlib3.c103
-rw-r--r--test/dynlib4.c102
-rw-r--r--test/filter_plugin.c1511
-rw-r--r--test/filter_plugin1_dsets.c93
-rw-r--r--test/filter_plugin2_dsets.c88
-rw-r--r--test/filter_plugin3_dsets.c119
-rw-r--r--test/filter_plugin4_groups.c106
-rw-r--r--test/plugin.c1217
-rw-r--r--test/test_filter_plugin.sh.in (renamed from test/test_plugin.sh.in)46
-rw-r--r--tools/test/h5diff/Makefile.am3
-rw-r--r--tools/test/h5dump/Makefile.am3
-rw-r--r--tools/test/h5ls/Makefile.am3
-rw-r--r--tools/test/h5repack/Makefile.am5
20 files changed, 2021 insertions, 1738 deletions
diff --git a/MANIFEST b/MANIFEST
index 4270479..230bf1f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -936,10 +936,6 @@
./test/dt_arith.c
./test/dtypes.c
./test/dtransform.c
-./test/dynlib1.c
-./test/dynlib2.c
-./test/dynlib3.c
-./test/dynlib4.c
./test/earray.c
./test/efc.c
./test/enc_dec_plist.c
@@ -967,6 +963,11 @@
./test/fill_old.h5
./test/fillval.c
./test/filter_fail.c
+./test/filter_plugin.c
+./test/filter_plugin1_dsets.c
+./test/filter_plugin2_dsets.c
+./test/filter_plugin3_dsets.c
+./test/filter_plugin4_groups.c
./test/flush1.c
./test/flush2.c
./test/flushrefresh.c
@@ -1030,7 +1031,6 @@
./test/page_buffer.c
./test/paged_nopersist.h5
./test/paged_persist.h5
-./test/plugin.c
./test/reserved.c
./test/pool.c
./test/set_extent.c
@@ -1065,12 +1065,12 @@
./test/testerror.sh.in
./test/testlinks_env.sh.in
./test/test_filenotclosed.sh.in
+./test/test_filter_plugin.sh.in
./test/testflushrefresh.sh.in
./test/testframe.c
./test/testhdf5.c
./test/testhdf5.h
./test/testlibinfo.sh.in
-./test/test_plugin.sh.in
./test/test_usecases.sh.in
./test/testmeta.c
./test/testswmr.sh.in
diff --git a/configure.ac b/configure.ac
index 3dbd95c..d8f3873 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3369,17 +3369,17 @@ AC_CONFIG_FILES([src/libhdf5.settings
Makefile
src/Makefile
test/Makefile
+ test/H5srcdir_str.h
test/testcheck_version.sh
test/testerror.sh
test/testflushrefresh.sh
- test/H5srcdir_str.h
test/testlibinfo.sh
test/testlinks_env.sh
- test/test_filenotclosed.sh
test/testswmr.sh
- test/test_plugin.sh
- test/test_usecases.sh
test/testvdsswmr.sh
+ test/test_filenotclosed.sh
+ test/test_filter_plugin.sh
+ test/test_usecases.sh
testpar/Makefile
tools/Makefile
tools/lib/Makefile
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 8522c1d..0a2afbf 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -70,73 +70,73 @@ if (BUILD_SHARED_LIBS)
endif ()
#-----------------------------------------------------------------------------
-# If plugin library tests can be tested
+# If filter plugin tests can be tested
#-----------------------------------------------------------------------------
# make plugins dir
- file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir1")
- file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir2")
+ file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/filter_plugin_dir1")
+ file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/filter_plugin_dir2")
#-----------------------------------------------------------------------------
- # Define Plugin Test Sources
+ # Define Filter Plugin Test Sources
#-----------------------------------------------------------------------------
- set (TEST_PLUGIN_LIBS
- dynlib1
- dynlib3
+ set (FILTER_PLUGINS_FOR_DIR1
+ filter_plugin1_dsets
+ filter_plugin3_dsets
)
- set (TEST2_PLUGIN_LIBS
- dynlib2
- dynlib4
+ set (FILTER_PLUGINS_FOR_DIR2
+ filter_plugin2_dsets
+ filter_plugin4_groups
)
- foreach (test_lib ${TEST_PLUGIN_LIBS})
- set (HDF5_TEST_PLUGIN_LIB_CORENAME "${test_lib}")
- set (HDF5_TEST_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}")
- set (HDF5_TEST_PLUGIN_LIB_TARGET ${HDF5_TEST_PLUGIN_LIB_CORENAME})
+ foreach (plugin_name ${FILTER_PLUGINS_FOR_DIR1})
+ set (HDF5_TEST_PLUGIN_CORENAME "${plugin_name}")
+ set (HDF5_TEST_PLUGIN_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_CORENAME}")
+ set (HDF5_TEST_PLUGIN_TARGET ${HDF5_TEST_PLUGIN_CORENAME})
add_definitions (${HDF_EXTRA_C_FLAGS})
INCLUDE_DIRECTORIES (${HDF5_SRC_DIR})
- add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c)
- TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ")
- target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
- H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
- set_target_properties (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN)
+ add_library (${HDF5_TEST_PLUGIN_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${plugin_name}.c)
+ TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_TARGET} SHARED " " " ")
+ target_link_libraries (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_LIB_TARGET})
+ H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_PLUGIN_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
+ set_target_properties (${HDF5_TEST_PLUGIN_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN)
#-----------------------------------------------------------------------------
- # Copy plugin library to a plugins folder
+ # Copy the filter plugin to a plugins folder
#-----------------------------------------------------------------------------
add_custom_command (
- TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET}
+ TARGET ${HDF5_TEST_PLUGIN_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
- "$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
- "${CMAKE_BINARY_DIR}/testdir1/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
+ "$<TARGET_FILE:${HDF5_TEST_PLUGIN_TARGET}>"
+ "${CMAKE_BINARY_DIR}/filter_plugin_dir1/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_TARGET}>"
)
endforeach ()
- foreach (test_lib ${TEST2_PLUGIN_LIBS})
- set (HDF5_TEST_PLUGIN_LIB_CORENAME "${test_lib}")
- set (HDF5_TEST_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}")
- set (HDF5_TEST_PLUGIN_LIB_TARGET ${HDF5_TEST_PLUGIN_LIB_CORENAME})
+ foreach ( plugin_name ${FILTER_PLUGINS_FOR_DIR2})
+ set (HDF5_TEST_PLUGIN_CORENAME "${plugin_name}")
+ set (HDF5_TEST_PLUGIN_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_CORENAME}")
+ set (HDF5_TEST_PLUGIN_TARGET ${HDF5_TEST_PLUGIN_CORENAME})
add_definitions (${HDF_EXTRA_C_FLAGS})
INCLUDE_DIRECTORIES (${HDF5_SRC_DIR})
- add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c)
- TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ")
- target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
- H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
- set_target_properties (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN)
+ add_library (${HDF5_TEST_PLUGIN_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${plugin_name}.c)
+ TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_TARGET} SHARED " " " ")
+ target_link_libraries (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_LIB_TARGET})
+ H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_PLUGIN_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
+ set_target_properties (${HDF5_TEST_PLUGIN_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN)
#-----------------------------------------------------------------------------
- # Copy plugin library to a plugins folder
+ # Copy the filter plugin to a plugins folder
#-----------------------------------------------------------------------------
add_custom_command (
- TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET}
+ TARGET ${HDF5_TEST_PLUGIN_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
- "$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
- "${CMAKE_BINARY_DIR}/testdir2/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
+ "$<TARGET_FILE:${HDF5_TEST_PLUGIN_TARGET}>"
+ "${CMAKE_BINARY_DIR}/filter_plugin_dir2/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_TARGET}>"
)
endforeach ()
@@ -411,17 +411,17 @@ endif ()
### P L U G I N T E S T S
##############################################################################
if (BUILD_SHARED_LIBS)
- add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c)
- TARGET_NAMING (plugin SHARED)
- TARGET_C_PROPERTIES (plugin SHARED " " " ")
- target_link_libraries (plugin ${HDF5_TEST_LIB_TARGET})
- set_target_properties (plugin PROPERTIES FOLDER test)
+ add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c)
+ TARGET_NAMING (filter_plugin SHARED)
+ TARGET_C_PROPERTIES (filter_plugin SHARED " " " ")
+ target_link_libraries (filter_plugin ${HDF5_TEST_LIB_TARGET})
+ set_target_properties (filter_plugin PROPERTIES FOLDER test)
else ()
- add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c)
- TARGET_NAMING (plugin STATIC)
- TARGET_C_PROPERTIES (plugin STATIC " " " ")
- target_link_libraries (plugin ${HDF5_TEST_LIB_TARGET})
- set_target_properties (plugin PROPERTIES FOLDER test)
+ add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c)
+ TARGET_NAMING (filter_plugin STATIC)
+ TARGET_C_PROPERTIES (filter_plugin STATIC " " " ")
+ target_link_libraries (filter_plugin ${HDF5_TEST_LIB_TARGET})
+ set_target_properties (filter_plugin PROPERTIES FOLDER test)
endif ()
##############################################################################
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index 61ac3d2..973d389 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -1,4 +1,4 @@
-#
+
# Copyright by The HDF Group.
# All rights reserved.
#
@@ -520,7 +520,7 @@ set (test_CLEANFILES
multi_file-r.h5
multi_file-s.h5
core_file
- plugin.h5
+ filter_plugin.h5
new_move_a.h5
new_move_b.h5
ntypes.h5
@@ -1013,7 +1013,7 @@ if (BUILD_SHARED_LIBS)
endif ()
##############################################################################
-### P L U G I N T E S T S
+### F I L T E R P L U G I N T E S T S
##############################################################################
if (WIN32)
set (CMAKE_SEP "\;")
@@ -1023,9 +1023,9 @@ else ()
set (BIN_REL_PATH "../")
endif ()
-add_test (NAME H5PLUGIN-plugin COMMAND $<TARGET_FILE:plugin>)
-set_tests_properties (H5PLUGIN-plugin PROPERTIES
- ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}"
+add_test (NAME H5PLUGIN-filter_plugin COMMAND $<TARGET_FILE:filter_plugin>)
+set_tests_properties (H5PLUGIN-filter_plugin PROPERTIES
+ ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/filter_plugin_dir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/filter_plugin_dir2;srcdir=${HDF5_TEST_BINARY_DIR}"
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}
)
diff --git a/test/Makefile.am b/test/Makefile.am
index ba2d79b..4f192ac 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -26,11 +26,12 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src
# testlibinfo.sh:
# testcheck_version.sh: tcheck_version
# testlinks_env.sh: links_env
-# test_filenotclosed.sh: filenotclosed.c
# testflushrefresh.sh: flushrefresh
-# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes
# testswmr.sh: swmr*
# testvdsswmr.sh: vds_swmr*
+# test_filenotclosed.sh: filenotclosed.c
+# test_filter_plugin.sh: filter_plugin.c
+# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes
TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filenotclosed.sh\
testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh
SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_filenotclosed$(EXEEXT) \
@@ -40,8 +41,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_
swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \
vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT)
if HAVE_SHARED_CONDITIONAL
- TEST_SCRIPT += test_plugin.sh
- SCRIPT_DEPEND += plugin$(EXEEXT)
+ TEST_SCRIPT += test_filter_plugin.sh
+ SCRIPT_DEPEND += filter_plugin$(EXEEXT)
endif
check_SCRIPTS = $(TEST_SCRIPT)
@@ -81,7 +82,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \
swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \
swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer
if HAVE_SHARED_CONDITIONAL
- check_PROGRAMS+= plugin
+ check_PROGRAMS+= filter_plugin
endif
# These programs generate test files for the tests. They don't need to be
@@ -102,29 +103,17 @@ endif
if HAVE_SHARED_CONDITIONAL
# The libh5test library provides common support code for the tests.
- # The libdynlib1, libdynlib2, libdynlib3, and libdynlib4 library for testing plugin module plugin.c.
- # Build them as shared libraries if configure is enabled for shared library.
- noinst_LTLIBRARIES=libh5test.la libdynlib1.la libdynlib2.la libdynlib3.la libdynlib4.la
- libdynlib1_la_SOURCES=dynlib1.c
- libdynlib2_la_SOURCES=dynlib2.c
- libdynlib3_la_SOURCES=dynlib3.c
- libdynlib4_la_SOURCES=dynlib4.c
- libdynlib1_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
- libdynlib2_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
- libdynlib3_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
- libdynlib4_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
-
- libdynlib1.la: $(libdynlib1_la_OBJECTS) $(libdynlib1_la_DEPENDENCIES) $(EXTRA_libdynlib1_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlib1_la_LINK) $(am_libdynlib1_la_rpath) $(libdynlib1_la_OBJECTS) $(libdynlib1_la_LIBADD)
-
- libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_libdynlib2_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlib2_la_LINK) $(am_libdynlib2_la_rpath) $(libdynlib2_la_OBJECTS) $(libdynlib2_la_LIBADD)
-
- libdynlib3.la: $(libdynlib3_la_OBJECTS) $(libdynlib3_la_DEPENDENCIES) $(EXTRA_libdynlib3_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlib3_la_LINK) $(am_libdynlib3_la_rpath) $(libdynlib3_la_OBJECTS) $(libdynlib3_la_LIBADD)
-
- libdynlib4.la: $(libdynlib4_la_OBJECTS) $(libdynlib4_la_DEPENDENCIES) $(EXTRA_libdynlib4_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlib4_la_LINK) $(am_libdynlib4_la_rpath) $(libdynlib4_la_OBJECTS) $(libdynlib4_la_LIBADD)
+ # The filter_plugin* libraries are for use in filter_plugin.c.
+ # Build them as shared libraries if that option was enabled in configure.
+ noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la
+ libfilter_plugin1_dsets_la_SOURCES=filter_plugin1_dsets.c
+ libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c
+ libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c
+ libfilter_plugin4_groups_la_SOURCES=filter_plugin4_groups.c
+ libfilter_plugin1_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
+ libfilter_plugin2_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
+ libfilter_plugin3_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
+ libfilter_plugin4_groups_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
else
# The libh5test library provides common support code for the tests.
noinst_LTLIBRARIES=libh5test.la
@@ -185,7 +174,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \
getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \
family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \
- multi_file-[rs].h5 core_file plugin.h5 \
+ multi_file-[rs].h5 core_file filter_plugin.h5 \
new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \
dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \
unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \
@@ -215,7 +204,7 @@ use_append_mchunks_SOURCES=use_append_mchunks.c use_common.c
use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c
# Temporary files.
-DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh \
+DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \
testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh
include $(top_srcdir)/config/conclude.am
diff --git a/test/dynlib1.c b/test/dynlib1.c
deleted file mode 100644
index e9137fb..0000000
--- a/test/dynlib1.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Programmer: Raymond Lu
- * 13 February 2013
- *
- * Purpose: Tests the plugin module (H5PL)
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "H5PLextern.h"
-
-#define H5Z_FILTER_DYNLIB1 257
-
-static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
-
-/* This message derives from H5Z */
-const H5Z_class2_t H5Z_DYNLIB1[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_DYNLIB1, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "dynlib1", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */
-}};
-
-H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
-const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;}
-
-/*-------------------------------------------------------------------------
- * Function: H5Z_filter_dynlib1
- *
- * Purpose: A dynlib1 filter method that adds on and subtract from
- * the original value with another value. It will be built
- * as a shared library. plugin.c test will load and use
- * this filter library.
- *
- * Return: Success: Data chunk size
- *
- * Failure: 0
- *
- * Programmer: Raymond Lu
- * 29 March 2013
- *
- *-------------------------------------------------------------------------
- */
-static size_t
-H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
-{
- int *int_ptr = (int *)*buf; /* Pointer to the data values */
- size_t buf_left = *buf_size; /* Amount of data buffer left to process */
- int add_on = 0;
-
- /* Check for the correct number of parameters */
- if(cd_nelmts == 0)
- return(0);
-
- /* Check that permanent parameters are set correctly */
- if(cd_values[0] > 9)
- return(0);
-
- add_on = (int)cd_values[0];
-
- if(flags & H5Z_FLAG_REVERSE) { /*read*/
- /* Substract the "add on" value to all the data values */
- while(buf_left > 0) {
- *int_ptr++ -= add_on;
- buf_left -= sizeof(int);
- } /* end while */
- } /* end if */
- else { /*write*/
- /* Add the "add on" value to all the data values */
- while(buf_left > 0) {
- *int_ptr++ += add_on;
- buf_left -= sizeof(int);
- } /* end while */
- } /* end else */
-
- return nbytes;
-} /* end H5Z_filter_dynlib1() */
-
diff --git a/test/dynlib2.c b/test/dynlib2.c
deleted file mode 100644
index 2574d4d..0000000
--- a/test/dynlib2.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Programmer: Raymond Lu
- * 13 February 2013
- *
- * Purpose: Tests the plugin module (H5PL)
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "H5PLextern.h"
-
-#define H5Z_FILTER_DYNLIB2 258
-#define MULTIPLIER 3
-
-static size_t H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
-
-/* This message derives from H5Z */
-const H5Z_class2_t H5Z_DYNLIB2[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_DYNLIB2, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "dynlib2", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)H5Z_filter_dynlib2, /* The actual filter function */
-}};
-
-H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
-const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB2;}
-
-/*-------------------------------------------------------------------------
- * Function: H5Z_filter_dynlib2
- *
- * Purpose: A dynlib2 filter method that multiplies the original value
- * during write and divide the original value during read. It
- * will be built as a shared library. plugin.c test will load
- * and use this filter library.
- *
- * Return: Success: Data chunk size
- *
- * Failure: 0
- *
- * Programmer: Raymond Lu
- * 29 March 2013
- *
- *-------------------------------------------------------------------------
- */
-static size_t
-H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
-{
- int *int_ptr = (int *)*buf; /* Pointer to the data values */
- size_t buf_left = *buf_size; /* Amount of data buffer left to process */
-
- /* Check for the correct number of parameters */
- if(cd_nelmts > 0)
- return(0);
-
- /* Assignment to eliminate unused parameter warning. */
- cd_values = cd_values;
-
- if(flags & H5Z_FLAG_REVERSE) { /*read*/
- /* Divide the original value with MULTIPLIER */
- while(buf_left > 0) {
- *int_ptr++ /= MULTIPLIER;
- buf_left -= sizeof(int);
- } /* end while */
- } /* end if */
- else { /*write*/
- /* Multiply the original value with MULTIPLIER */
- while(buf_left > 0) {
- *int_ptr++ *= MULTIPLIER;
- buf_left -= sizeof(int);
- } /* end while */
- } /* end else */
-
- return nbytes;
-} /* end H5Z_filter_dynlib2() */
-
diff --git a/test/dynlib3.c b/test/dynlib3.c
deleted file mode 100644
index 8871321..0000000
--- a/test/dynlib3.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Programmer: Raymond Lu
- * 1 April 2013
- *
- * Purpose: Tests the plugin module (H5PL)
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "H5PLextern.h"
-
-#define H5Z_FILTER_DYNLIB3 259
-#define SUFFIX_LEN 8
-#define GROUP_SUFFIX ".h5group"
-
-static size_t H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
-
-/* This message derives from H5Z */
-const H5Z_class2_t H5Z_DYNLIB3[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_DYNLIB3, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "dynlib3", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)H5Z_filter_dynlib3, /* The actual filter function */
-}};
-
-H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
-const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB3;}
-
-/*-------------------------------------------------------------------------
- * Function: H5Z_filter_dynlib3
- *
- * Purpose: A dynlib3 filter method that is used to test groups. It
- * appends the suffix ".h5group" to each group name during
- * write and takes it out during read.
- *
- * Return: Success: Data chunk size
- *
- * Failure: 0
- *
- * Programmer: Raymond Lu
- * 1 April 2013
- *
- *-------------------------------------------------------------------------
- */
-static size_t
-H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
-{
- size_t ret_value; /* Return value */
-
- /* Check for the correct number of parameters */
- if(cd_nelmts > 0)
- return(0);
-
- /* Assignment to eliminate unused parameter warning. */
- cd_values = cd_values;
-
- if(flags & H5Z_FLAG_REVERSE) { /*read*/
- ret_value = *buf_size = nbytes - SUFFIX_LEN;
- } /* end if */
- else { /*write*/
- void *outbuf = NULL; /* Pointer to new buffer */
- unsigned char *dst; /* Temporary pointer to destination buffer */
-
- dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0));
-
- /* Copy raw data */
- memcpy((void*)dst, (void*)(*buf), nbytes);
-
- /* Append suffix to raw data for storage */
- dst += nbytes;
- memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN);
-
- /* Free input buffer */
- H5free_memory(*buf);
-
- /* Set return values */
- *buf_size = nbytes + SUFFIX_LEN;
- *buf = outbuf;
- outbuf = NULL;
- ret_value = *buf_size;
- } /* end else */
-
- return ret_value;
-} /* H5Z_filter_dynlib3() */
-
diff --git a/test/dynlib4.c b/test/dynlib4.c
deleted file mode 100644
index 06d90ff..0000000
--- a/test/dynlib4.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Purpose: Tests the plugin module (H5PL)
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "H5PLextern.h"
-
-#define H5Z_FILTER_DYNLIB4 260
-
-#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str)
-
-static size_t H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
-
-/* This message derives from H5Z */
-const H5Z_class2_t H5Z_DYNLIB4[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_DYNLIB4, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "dynlib4", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */
-}};
-
-H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
-const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;}
-
-/*-------------------------------------------------------------------------
- * Function: H5Z_filter_dynlib4
- *
- * Purpose: A dynlib4 filter method that adds on and subtract from
- * the original value with another value. It will be built
- * as a shared library. plugin.c test will load and use
- * this filter library. Designed to call a HDF function.
- *
- * Return: Success: Data chunk size
- *
- * Failure: 0
- *
- *-------------------------------------------------------------------------
- */
-static size_t
-H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
-{
- int *int_ptr = (int *)*buf; /* Pointer to the data values */
- size_t buf_left = *buf_size; /* Amount of data buffer left to process */
- int add_on = 0;
- unsigned ver_info[3];
-
- /* Check for the library version */
- if(H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) {
- PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion");
- return(0);
- }
- /* Check for the correct number of parameters */
- if(cd_nelmts == 0)
- return(0);
-
- /* Check that permanent parameters are set correctly */
- if(cd_values[0] > 9)
- return(0);
-
- if(ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) {
- PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match");
- return(0);
- }
-
- add_on = (int)cd_values[0];
-
- if(flags & H5Z_FLAG_REVERSE) { /*read*/
- /* Substract the "add on" value to all the data values */
- while(buf_left > 0) {
- *int_ptr++ -= add_on;
- buf_left -= sizeof(int);
- } /* end while */
- } /* end if */
- else { /*write*/
- /* Add the "add on" value to all the data values */
- while(buf_left > 0) {
- *int_ptr++ += add_on;
- buf_left -= sizeof(int);
- } /* end while */
- } /* end else */
-
- return nbytes;
-} /* end H5Z_filter_dynlib4() */
-
diff --git a/test/filter_plugin.c b/test/filter_plugin.c
new file mode 100644
index 0000000..8b7e0e4
--- /dev/null
+++ b/test/filter_plugin.c
@@ -0,0 +1,1511 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*
+ * Purpose: Tests the plugin module (H5PL)
+ */
+
+#include "h5test.h"
+#include "H5srcdir.h"
+
+/*
+ * This file needs to access private datatypes from the H5Z and H5PL package.
+ */
+#define H5PL_FRIEND
+#include "H5PLpkg.h"
+#define H5Z_FRIEND
+#include "H5Zpkg.h"
+
+/* Filters IDs for test filter plugins */
+#define FILTER1_ID 257
+#define FILTER2_ID 258
+#define FILTER3_ID 259
+#define FILTER4_ID 260
+
+const char *FILENAME[] = {
+ "filter_plugin",
+ NULL
+};
+#define FILENAME_BUF_SIZE 1024
+
+/* Dataset names */
+#define DSET_DEFLATE_NAME "deflate dset"
+#define DSET_FILTER1_NAME "filter 1 dset"
+#define DSET_FILTER2_NAME "filter 2 dset"
+#define DSET_FILTER3_NAME "filter 3 dset"
+
+/* Array sizes used throughout the test */
+#define DSET_DIM1 100
+#define DSET_DIM2 200
+#define CHUNK_DIM1 2
+#define CHUNK_DIM2 25
+#define HYPERSLAB_OFFSET1 7
+#define HYPERSLAB_OFFSET2 30
+#define HYPERSLAB_SIZE1 4
+#define HYPERSLAB_SIZE2 50
+
+/* Global size arrays */
+const hsize_t sizes_g[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */
+const hsize_t hs_sizes_g[2] = {HYPERSLAB_SIZE1, HYPERSLAB_SIZE2}; /* Hyperslab sizes */
+const hsize_t hs_offsets_g[2] = {HYPERSLAB_OFFSET1, HYPERSLAB_OFFSET2}; /* Hyperslab offsets */
+const hsize_t chunk_sizes_g[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */
+
+/* Limit random number within 20000 */
+#define RANDOM_LIMIT 20000
+
+/* Things used in the groups + filter plugins test */
+#define N_SUBGROUPS 1000
+#define SUBGROUP_PREFIX "subgroup_"
+#define TOP_LEVEL_GROUP_NAME "top-level group"
+
+/* Global arrays in which to save data */
+int **orig_deflate_g = NULL;
+int **orig_dynlib1_g = NULL;
+int **orig_dynlib2_g = NULL;
+int **orig_dynlib4_g = NULL;
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: free_2D_array
+ *
+ * Purpose: Free up a dynamic 2D pseudo array and set the pointer to NULL
+ * Designed to be callable in error conditions so NULLs are okay
+ *
+ * Return: SUCCEED (always)
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+free_2D_array(int ***arr) {
+
+ if (arr && *arr && (*arr)[0])
+ HDfree((*arr)[0]);
+ if (arr && *arr)
+ HDfree(*arr);
+ *arr = NULL;
+
+ return SUCCEED;
+} /* end free_2D_array() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: allocate_and_init_2D_array
+ *
+ * Purpose: Initialize an array as a pseudo 2D array and copy in some
+ * initial values.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+allocate_and_init_2D_array(int ***arr, const hsize_t *sizes, int **initial_values) {
+
+ size_t r, c; /* Data rows and columns */
+ size_t i; /* Iterator */
+ size_t n_bytes; /* # of bytes to copy */
+
+ r = (size_t)sizes[0];
+ c = (size_t)sizes[1];
+
+ /* Allocate and set up pseudo-2D array */
+ if (NULL == (*arr = (int **)HDcalloc(r, sizeof(int *))))
+ TEST_ERROR;
+ if (NULL == ((*arr)[0] = (int *)HDcalloc(r * c, sizeof(int))))
+ TEST_ERROR;
+ for (i = 0; i < r; i++)
+ (*arr)[i] = (**arr + c * i);
+
+ /* Copy over the data elements */
+ if (initial_values) {
+ n_bytes = r * c * sizeof(int);
+ HDmemcpy((*arr)[0], initial_values[0], n_bytes);
+ }
+
+ return SUCCEED;
+error:
+ free_2D_array(arr);
+
+ return FAIL;
+} /* end allocate_and_init_2D_array() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: compare_2D_arrays
+ *
+ * Purpose: Compare two pseudo 2D arrays
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_t *are_same) {
+ hsize_t i, j; /* index variables */
+
+ *are_same = TRUE;
+
+ /* Check all the array values. This could optionally emit any
+ * bad data, but it's not clear how that would help debugging.
+ */
+ for (i = 0; i < sizes[0]; i++)
+ for (j = 0; j < sizes[1]; j++)
+ if (dset1[i][j] != dset2[i][j]) {
+ *are_same = FALSE;
+ return SUCCEED;
+ }
+
+ return SUCCEED;
+
+} /* end compare_2D_arrays() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: ensure_filter_works
+ *
+ * Purpose: Tests writing entire data and partial data with filters
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id)
+{
+ hid_t did = -1; /* Dataset ID */
+ hid_t dxpl_id = -1; /* Dataset xfer property list ID */
+ hid_t write_dxpl_id = -1; /* Dataset xfer property list ID for writing */
+ hid_t sid = -1; /* Dataspace ID */
+ void *tconv_buf = NULL; /* Temporary conversion buffer */
+ int **orig = NULL; /* Data written to the dataset */
+ int **read = NULL; /* Data read from the dataset */
+ size_t r, c; /* Data rows and columns */
+ size_t hs_r, hs_c, hs_offr, hs_offc; /* Hypserslab sizes and offsets */
+ size_t i, j; /* Local index variables */
+ int n = 0; /* Value written to point array */
+ hbool_t are_same; /* Output from dataset compare function */
+ int ***save_array = NULL; /* (Global) array where the final data go */
+
+ /* initialize */
+ r = (size_t)sizes_g[0];
+ c = (size_t)sizes_g[1];
+
+ /* Create the data space */
+ if ((sid = H5Screate_simple(2, sizes_g, NULL)) < 0)
+ TEST_ERROR;
+
+ /* Allocate memory for the data buffers
+ * We're using the hacky way of doing 2D arrays that uses a
+ * single data buffer but which allows normal 2D access.
+ */
+ if (allocate_and_init_2D_array(&orig, sizes_g, NULL) < 0)
+ TEST_ERROR;
+ if (allocate_and_init_2D_array(&read, sizes_g, NULL) < 0)
+ TEST_ERROR;
+
+ /* Create a small conversion buffer to test strip mining. We
+ * might as well test all we can!
+ */
+ if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR;
+ if (NULL == (tconv_buf = HDcalloc((size_t)1000, sizeof(char))))
+ TEST_ERROR;
+ if (H5Pset_buffer(dxpl_id, (size_t)1000, tconv_buf, NULL) < 0)
+ TEST_ERROR;
+ if ((write_dxpl_id = H5Pcopy(dxpl_id)) < 0)
+ TEST_ERROR;
+
+ TESTING(" filters (setup)");
+
+ /* Check if all the filters are available */
+ if (H5Pall_filters_avail(dcpl_id) != TRUE)
+ TEST_ERROR;
+
+ /* Create the dataset */
+ if ((did = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ PASSED();
+
+ /*----------------------------------------------------------------------
+ * STEP 1: Read uninitialized data. It should be zero.
+ *----------------------------------------------------------------------
+ */
+ TESTING(" filters (uninitialized read)");
+
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0)
+ TEST_ERROR;
+
+ /* The input buffer was calloc'd and has not been initialized yet */
+ if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0)
+ TEST_ERROR;
+ if (FALSE == are_same)
+ TEST_ERROR;
+
+ PASSED();
+
+ /*----------------------------------------------------------------------
+ * STEP 2: Test filters by setting up a chunked dataset and writing
+ * to it.
+ *----------------------------------------------------------------------
+ */
+ TESTING(" filters (write)");
+
+ n = 0;
+ for (i = 0; i < r; i++)
+ for (j = 0; j < c; j++)
+ orig[i][j] = n++;
+
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0)
+ TEST_ERROR;
+
+ PASSED();
+
+ /*----------------------------------------------------------------------
+ * STEP 3: Try to read the data we just wrote.
+ *----------------------------------------------------------------------
+ */
+ TESTING(" filters (read)");
+
+ /* Read the dataset back */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0)
+ TEST_ERROR;
+
+ /* Check that the values read are the same as the values written */
+ if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0)
+ TEST_ERROR;
+ if (FALSE == are_same)
+ TEST_ERROR;
+
+ PASSED();
+
+ /*----------------------------------------------------------------------
+ * STEP 4: Write new data over the top of the old data. The new data is
+ * random thus not very compressible, and will cause the chunks to move
+ * around as they grow. We only change values for the left half of the
+ * dataset although we rewrite the whole thing.
+ *----------------------------------------------------------------------
+ */
+ TESTING(" filters (modify)");
+
+ for (i = 0; i < r; i++)
+ for (j = 0; j < c / 2; j++)
+ orig[i][j] = (int)HDrandom() % RANDOM_LIMIT;
+
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0)
+ TEST_ERROR;
+
+ /* Read the dataset back and check it */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0)
+ TEST_ERROR;
+
+ /* Check that the values read are the same as the values written */
+ if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0)
+ TEST_ERROR;
+ if (FALSE == are_same)
+ TEST_ERROR;
+
+ PASSED();
+
+ /*----------------------------------------------------------------------
+ * STEP 5: Close the dataset and then open it and read it again. This
+ * insures that the filters message is picked up properly from the
+ * object header.
+ *----------------------------------------------------------------------
+ */
+ TESTING(" filters (re-open)");
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+ if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0)
+ TEST_ERROR;
+
+ /* Check that the values read are the same as the values written */
+ if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0)
+ TEST_ERROR;
+ if (FALSE == are_same)
+ TEST_ERROR;
+
+ PASSED();
+
+ /*----------------------------------------------------------------------
+ * STEP 6: Test partial I/O by writing to and then reading from a
+ * hyperslab of the dataset. The hyperslab does not line up on chunk
+ * boundaries (we know that case already works from above tests).
+ *----------------------------------------------------------------------
+ */
+ TESTING(" filters (partial I/O)");
+
+ hs_r = (size_t)hs_sizes_g[0];
+ hs_c = (size_t)hs_sizes_g[1];
+ hs_offr = (size_t)hs_offsets_g[0];
+ hs_offc = (size_t)hs_offsets_g[1];
+ for (i = 0; i < hs_r; i++)
+ for (j = 0; j < hs_c; j++)
+ orig[hs_offr + i][hs_offc + j] = (int)HDrandom() % RANDOM_LIMIT;
+
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offsets_g, NULL, hs_sizes_g, NULL) < 0)
+ TEST_ERROR;
+
+ /* Use the "read" DXPL because partial I/O on corrupted data test
+ * needs to ignore errors during writing
+ */
+ if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, *orig) < 0)
+ TEST_ERROR;
+
+ if (H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, *read) < 0)
+ TEST_ERROR;
+
+ /* Check that the values read are the same as the values written */
+ if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0)
+ TEST_ERROR;
+ if (FALSE == are_same)
+ TEST_ERROR;
+
+ PASSED();
+
+ /* Save the data written to the file for later comparison when the file
+ * is reopened for read test.
+ */
+ if (!HDstrcmp(name, DSET_DEFLATE_NAME))
+ save_array = &orig_deflate_g;
+ else if (!HDstrcmp(name, DSET_FILTER1_NAME))
+ save_array = &orig_dynlib1_g;
+ else if (!HDstrcmp(name, DSET_FILTER2_NAME))
+ save_array = &orig_dynlib2_g;
+ else if (!HDstrcmp(name, DSET_FILTER3_NAME))
+ save_array = &orig_dynlib4_g;
+ else
+ TEST_ERROR;
+ if (allocate_and_init_2D_array(save_array, sizes_g, orig) < 0)
+ TEST_ERROR;
+
+ /* Clean up and exit */
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+ if (H5Sclose(sid) < 0)
+ TEST_ERROR;
+ if (H5Pclose(dxpl_id) < 0)
+ TEST_ERROR;
+ if (H5Pclose(write_dxpl_id) < 0)
+ TEST_ERROR;
+
+ free_2D_array(&orig);
+ free_2D_array(&read);
+
+ HDfree(tconv_buf);
+
+ return SUCCEED;
+
+error:
+ /* Clean up objects used for this test */
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(dxpl_id);
+ H5Pclose(write_dxpl_id);
+ } H5E_END_TRY
+
+ /* NULLs are okay here */
+ free_2D_array(&orig);
+ free_2D_array(&read);
+
+ if (tconv_buf)
+ HDfree(tconv_buf);
+
+ return FAIL;
+} /* end ensure_filter_works() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_dataset_write_with_filters
+ *
+ * Purpose: Tests creating datasets and writing data with dynamically loaded filters
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_dataset_write_with_filters(hid_t fid)
+{
+ hid_t dcpl_id = -1; /* Dataset creation property list ID */
+ unsigned int compress_level; /* Deflate compression level */
+ unsigned int filter1_data; /* Data used by filter 1 */
+ unsigned int libver_values[4]; /* Used w/ the filter that makes HDF5 calls */
+
+ /*----------------------------------------------------------
+ * STEP 1: Test deflation by itself.
+ *----------------------------------------------------------
+ */
+ HDputs("Testing dataset writes with deflate filter");
+#ifdef H5_HAVE_FILTER_DEFLATE
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0)
+ TEST_ERROR;
+ compress_level = 6;
+ if (H5Pset_deflate(dcpl_id, compress_level) < 0)
+ TEST_ERROR;
+
+ /* Ensure the filter works */
+ if (ensure_filter_works(fid, DSET_DEFLATE_NAME, dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Clean up objects used for this test */
+ if (H5Pclose(dcpl_id) < 0)
+ TEST_ERROR;
+#else /* H5_HAVE_FILTER_DEFLATE */
+ SKIPPED();
+ HDputs(" Deflate filter not enabled");
+#endif /* H5_HAVE_FILTER_DEFLATE */
+
+ /*----------------------------------------------------------
+ * STEP 2: Test filter plugin 1 by itself.
+ *----------------------------------------------------------
+ */
+ HDputs(" dataset writes with filter plugin 1");
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0)
+ TEST_ERROR;
+
+ /* Set up the filter, passing in the amount the filter will add and subtract
+ * from each data element. Note that this value has an arbitrary max of 9.
+ */
+ filter1_data = 9;
+ if (H5Pset_filter(dcpl_id, FILTER1_ID, H5Z_FLAG_MANDATORY, (size_t)1, &filter1_data) < 0)
+ TEST_ERROR;
+
+ /* Ensure the filter works */
+ if (ensure_filter_works(fid, DSET_FILTER1_NAME, dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Clean up objects used for this test */
+ if (H5Pclose(dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Unregister the dynamic filter for testing purpose. The next time when this test is run for
+ * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
+ * for this filter.
+ */
+ if (H5Zunregister(FILTER1_ID) < 0)
+ TEST_ERROR;
+
+ /*----------------------------------------------------------
+ * STEP 3: Test filter plugin 2 by itself.
+ *----------------------------------------------------------
+ */
+ HDputs(" dataset writes with filter plugin 2");
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0)
+ TEST_ERROR;
+ if (H5Pset_filter(dcpl_id, FILTER2_ID, H5Z_FLAG_MANDATORY, 0, NULL) < 0)
+ TEST_ERROR;
+
+ /* Ensure the filter works */
+ if (ensure_filter_works(fid, DSET_FILTER2_NAME, dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Clean up objects used for this test */
+ if (H5Pclose(dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Unregister the dynamic filter for testing purpose. The next time when this test is run for
+ * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
+ * for this filter.
+ */
+ if (H5Zunregister(FILTER2_ID) < 0)
+ TEST_ERROR;
+
+ /*----------------------------------------------------------
+ * STEP 4: Test filter plugin 3 by itself.
+ * (This filter plugin makes HDF5 API calls)
+ *----------------------------------------------------------
+ */
+ HDputs(" dataset writes with filter plugin 3");
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0)
+ TEST_ERROR;
+
+ /* Set the add/subtract value for the filter */
+ libver_values[0] = 9;
+
+ /* Get the library bounds and add to the filter data */
+ if (H5get_libversion(&libver_values[1], &libver_values[2], &libver_values[3]) < 0)
+ TEST_ERROR;
+ if (H5Pset_filter(dcpl_id, FILTER3_ID, H5Z_FLAG_MANDATORY, (size_t)4, libver_values) < 0)
+ TEST_ERROR;
+
+ /* Ensure the filter works */
+ if (ensure_filter_works(fid, DSET_FILTER3_NAME, dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Clean up objects used for this test */
+ if (H5Pclose(dcpl_id) < 0)
+ TEST_ERROR;
+
+ /* Unregister the dynamic filter for testing purpose. The next time when this test is run for
+ * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
+ * for this filter.
+ */
+ if (H5Zunregister(FILTER3_ID) < 0)
+ TEST_ERROR;
+
+ return SUCCEED;
+
+error:
+ /* Clean up objects used for this test */
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl_id);
+ } H5E_END_TRY
+
+ return FAIL;
+} /* end test_dataset_write_with_filters() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_read_data
+ *
+ * Purpose: Tests reading data and compares values
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_read_data(hid_t did, int *origin_data)
+{
+ int **check = NULL;
+ int *data_p = origin_data;
+ size_t i, j; /* Local index variables */
+
+ if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0)
+ TEST_ERROR;
+
+ /* Read the dataset back */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, *check) < 0)
+ TEST_ERROR;
+
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < sizes_g[0]; i++)
+ for(j = 0; j < sizes_g[1]; j++) {
+ if(*data_p != check[i][j])
+ TEST_ERROR
+ data_p++;
+ }
+
+ free_2D_array(&check);
+
+ PASSED();
+
+ return SUCCEED;
+
+error:
+ free_2D_array(&check);
+
+ return FAIL;
+} /* end test_read_data() */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_dataset_read_with_filters
+ *
+ * Purpose: Tests reading datasets created with dynamically-loaded
+ * filter plugins.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_dataset_read_with_filters(hid_t fid)
+{
+ hid_t did = -1; /* Dataset ID */
+
+ /*----------------------------------------------------------
+ * STEP 1: Test deflation by itself.
+ *----------------------------------------------------------
+ */
+ TESTING("dataset read I/O with deflate filter");
+
+#ifdef H5_HAVE_FILTER_DEFLATE
+ if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE)
+ TEST_ERROR;
+
+ if ((did = H5Dopen2(fid, DSET_DEFLATE_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if (test_read_data(did, orig_deflate_g[0]) < 0)
+ TEST_ERROR;
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+
+#else /* H5_HAVE_FILTER_DEFLATE */
+ SKIPPED();
+ HDputs(" Deflate filter not enabled");
+#endif /* H5_HAVE_FILTER_DEFLATE */
+
+ /*----------------------------------------------------------
+ * STEP 2: Test filter plugin 1 by itself.
+ *----------------------------------------------------------
+ */
+ TESTING(" dataset reads with filter plugin 1");
+
+ if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if (test_read_data(did, orig_dynlib1_g[0]) < 0)
+ TEST_ERROR;
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+
+ /*----------------------------------------------------------
+ * STEP 3: Test filter plugin 2 by itself.
+ *----------------------------------------------------------
+ */
+ TESTING(" dataset reads with filter plugin 2");
+
+ if ((did = H5Dopen2(fid, DSET_FILTER2_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if (test_read_data(did, orig_dynlib2_g[0]) < 0)
+ TEST_ERROR;
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+
+ /*----------------------------------------------------------
+ * STEP 4: Test filter plugin 3 by itself.
+ *----------------------------------------------------------
+ */
+ TESTING(" dataset reads with filter plugin 3");
+
+ if ((did = H5Dopen2(fid, DSET_FILTER3_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if (test_read_data(did, orig_dynlib4_g[0]) < 0)
+ TEST_ERROR;
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+
+ return SUCCEED;
+
+error:
+ /* Clean up objects used for this test */
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ } H5E_END_TRY
+
+ return FAIL;
+} /* end test_dataset_read_with_filters() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: ensure_data_read_fails
+ *
+ * Purpose: Tests not reading data
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+ensure_data_read_fails(hid_t did)
+{
+ int **check = NULL;
+ herr_t ret = FAIL;
+
+ if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0)
+ TEST_ERROR;
+
+ /* Read the dataset back (should fail) */
+ H5E_BEGIN_TRY {
+ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, *check);
+ } H5E_END_TRY
+ if(ret >= 0)
+ TEST_ERROR;
+
+ free_2D_array(&check);
+
+ PASSED();
+
+ return SUCCEED;
+
+error:
+ free_2D_array(&check);
+ return FAIL;
+} /* end ensure_data_read_fails() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_no_read_when_plugins_disabled
+ *
+ * Purpose: Ensures we can't read data from a dataset that requires a
+ * filter located in a plugin.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_no_read_when_plugins_disabled(hid_t fid)
+{
+ hid_t did = -1; /* Dataset ID */
+ unsigned plugin_flags; /* Plugin access flags */
+
+ TESTING("filter plugin 1 with filter plugins disabled");
+
+ /* Get the existing plugin flags */
+ if (H5PLget_loading_state(&plugin_flags) < 0)
+ TEST_ERROR;
+
+ /* Disable filter plugins and use the new flags */
+ plugin_flags &= (unsigned)(~H5PL_FILTER_PLUGIN);
+ if (H5PLset_loading_state(plugin_flags) < 0)
+ TEST_ERROR;
+
+ /* Open a dataset that requires a filter plugin to read the data */
+ if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Make sure we can't read the data */
+ if (ensure_data_read_fails(did) < 0)
+ TEST_ERROR;
+
+ /* Close down */
+ if (H5Dclose(did) < 0)
+ TEST_ERROR;
+
+ /* Re-enable filter plugins */
+ plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN;
+ if (H5PLset_loading_state(plugin_flags) < 0)
+ TEST_ERROR;
+
+ return SUCCEED;
+
+error:
+ /* Clean up objects used for this test */
+ H5E_BEGIN_TRY {
+ plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN;
+ H5PLset_loading_state(plugin_flags);
+ H5Dclose(did);
+ } H5E_END_TRY
+
+ return FAIL;
+} /* end test_no_read_when_plugins_disabled() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_creating_groups_using_plugins
+ *
+ * Purpose: Tests creating group with dynamically loaded filters
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_creating_groups_using_plugins(hid_t fid)
+{
+ hid_t gcpl_id = -1;
+ hid_t gid = -1;
+ hid_t sub_gid = -1;
+ int i;
+ char subgroup_name[256];
+
+ TESTING("creating groups with filter plugin 4");
+
+ if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ TEST_ERROR;
+
+ /* Use a filter plugin for creating groups */
+ if (H5Pset_filter(gcpl_id, FILTER4_ID, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0)
+ TEST_ERROR;
+
+ /* Create a group using this filter */
+ if ((gid = H5Gcreate2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create multiple groups under the top-level group */
+ for (i = 0; i < N_SUBGROUPS; i++) {
+ char *sp = subgroup_name;
+
+ sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX);
+ HDsprintf(sp, "%d", i);
+
+ if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if (H5Gclose(sub_gid) < 0)
+ TEST_ERROR;
+ }
+
+ /* Close everything */
+ if (H5Gclose(gid) < 0)
+ TEST_ERROR;
+ if (H5Pclose(gcpl_id) < 0)
+ TEST_ERROR;
+
+ PASSED();
+
+ return SUCCEED;
+
+error:
+ /* Clean up objects used for this test */
+ H5E_BEGIN_TRY {
+ H5Gclose(sub_gid);
+ H5Gclose(gid);
+ H5Pclose(gcpl_id);
+ } H5E_END_TRY
+
+ return FAIL;
+} /* end test_creating_groups_using_plugins() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_opening_groups_using_plugins
+ *
+ * Purpose: Tests opening group with dynamically loaded filters
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_opening_groups_using_plugins(hid_t fid)
+{
+ hid_t gid = -1;
+ hid_t sub_gid = -1;
+ int i;
+ char subgroup_name[256];
+
+ TESTING("opening groups with filter plugin 4");
+
+ /* Open the top group */
+ if ((gid = H5Gopen2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Open all the sub-groups under the top-level group */
+ for (i = 0; i < N_SUBGROUPS; i++) {
+ char *sp = subgroup_name;
+
+ sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX);
+ HDsprintf(sp, "%d", i);
+
+ if ((sub_gid = H5Gopen2(gid, subgroup_name, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if (H5Gclose(sub_gid) < 0)
+ TEST_ERROR;
+ }
+
+ /* Close the top-level group */
+ if (H5Gclose(gid) < 0)
+ TEST_ERROR;
+
+ PASSED();
+
+ return SUCCEED;
+
+error:
+ /* Clean up objects used for this test */
+ H5E_BEGIN_TRY {
+ H5Gclose(gid);
+ H5Gclose(sub_gid);
+ } H5E_END_TRY
+
+ return FAIL;
+} /* end test_opening_groups_using_plugins() */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_path_api_calls
+ *
+ * Purpose: Tests the H5PL API calls that manipulate the plugin search
+ * paths.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_path_api_calls(void)
+{
+ unsigned int n_starting_paths;
+ unsigned int u;
+ unsigned int n_paths;
+ herr_t ret;
+ ssize_t path_len = -1;
+ char path[256];
+ char temp_name[256];
+
+ HDputs("Testing access to the filter path table");
+
+ if (H5Zfilter_avail(FILTER1_ID) != TRUE)
+ TEST_ERROR;
+
+ /* Set the number of paths to create for this test.
+ *
+ * This should be set high enough to ensure that at least one array
+ * expansion will take place. See H5PLpath.c for details.
+ */
+ n_starting_paths = 42;
+
+ /* Check that initialization is correct */
+ TESTING(" initialize");
+
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths != 2)
+ TEST_ERROR;
+
+ PASSED();
+
+ /****************/
+ /* H5PLremove() */
+ /****************/
+
+ /* Remove all the current paths */
+ TESTING(" remove");
+
+ /* Get the current size */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+
+ /* Remove all existing paths */
+ for (u = n_paths; u > 0; u--)
+ if (H5PLremove(u-1) < 0) {
+ HDfprintf(stderr," at %u: %s\n", u, path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table is empty */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths > 0)
+ TEST_ERROR;
+
+ PASSED();
+
+
+ TESTING(" remove (index 0 in empty table)");
+
+ /* Try to remove index zero in an empty list (SHOULD FAIL) */
+ H5E_BEGIN_TRY {
+ ret = H5PLremove(0);
+ } H5E_END_TRY
+ if (ret >= 0)
+ TEST_ERROR;
+
+ PASSED();
+
+
+ /****************/
+ /* H5PLappend() */
+ /****************/
+
+ TESTING(" append");
+
+ /* Add a bunch of paths to the path table */
+ for (u = 0; u < n_starting_paths; u++) {
+ HDsprintf(path, "a_path_%u", u);
+ if (H5PLappend(path) < 0) {
+ HDfprintf(stderr," at %u: %s\n", u, path);
+ TEST_ERROR;
+ }
+ }
+
+ PASSED();
+
+
+ /**********************/
+ /* H5PLremove() again */
+ /**********************/
+
+ TESTING(" remove (index too high)");
+
+ /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */
+ H5E_BEGIN_TRY {
+ ret = H5PLremove(n_starting_paths);
+ } H5E_END_TRY
+
+ if (ret >= 0)
+ TEST_ERROR
+
+ PASSED();
+
+
+ /*************/
+ /* H5PLget() */
+ /*************/
+
+ TESTING(" get (path name)");
+
+ /* Get the path length by passing in NULL */
+ if ((path_len = H5PLget(0, NULL, 0)) <= 0) {
+ HDfprintf(stderr," get path 0 length failed\n");
+ TEST_ERROR;
+ }
+ if (path_len != 8)
+ TEST_ERROR;
+
+ /* Get the path */
+ if ((path_len = H5PLget(0, path, 256)) <= 0) {
+ HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path);
+ TEST_ERROR;
+ }
+ if (HDstrcmp(path, "a_path_0") != 0) {
+ HDfprintf(stderr," get 0: %s\n", path);
+ TEST_ERROR;
+ }
+
+ PASSED();
+
+
+ TESTING(" get (high and low indices)");
+
+ /* Get path at index 1 */
+ if ((path_len = H5PLget(1, path, 256)) <= 0)
+ TEST_ERROR;
+ if (HDstrcmp(path, "a_path_1") != 0) {
+ HDfprintf(stderr," get 1: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Get path at the last index */
+ if ((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0)
+ TEST_ERROR;
+ HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1);
+ if (HDstrcmp(path, temp_name) != 0) {
+ HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path);
+ TEST_ERROR;
+ }
+
+ PASSED();
+
+
+ TESTING(" get (index too high)");
+
+ /* Get path at the last + 1 index (SHOULD FAIL) */
+ H5E_BEGIN_TRY {
+ path_len = H5PLget(n_starting_paths, NULL, 0);
+ } H5E_END_TRY
+ if (path_len > 0)
+ TEST_ERROR;
+
+ PASSED();
+
+
+ /*****************/
+ /* H5PLprepend() */
+ /*****************/
+
+ /* We'll remove a path at an arbitrary index and then
+ * prepend a new path.
+ */
+
+ TESTING(" remove (arbitrary index 1)");
+
+ /* Remove one path */
+ if (H5PLremove(8) < 0)
+ TEST_ERROR;
+
+ /* Verify that the entries were moved */
+ if ((path_len = H5PLget(8, path, 256)) <= 0)
+ TEST_ERROR;
+ if (HDstrcmp(path, "a_path_9") != 0) {
+ HDfprintf(stderr," get 8: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table shrank */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths != n_starting_paths - 1)
+ TEST_ERROR;
+
+ PASSED();
+
+
+ TESTING(" prepend");
+
+ /* Prepend one path */
+ HDsprintf(path, "a_path_%d", n_starting_paths + 1);
+ if (H5PLprepend(path) < 0) {
+ HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table increased */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths != n_starting_paths)
+ TEST_ERROR;
+
+ /* Verify that the entries were moved */
+ if (H5PLget(8, path, 256) <= 0)
+ TEST_ERROR;
+ if (HDstrcmp(path, "a_path_7") != 0) {
+ HDfprintf(stderr," get 8: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Verify that the path was inserted at index zero */
+ if (H5PLget(0, path, 256) <= 0)
+ TEST_ERROR;
+ HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1);
+ if (HDstrcmp(path, temp_name) != 0) {
+ HDfprintf(stderr," get 0: %s\n", path);
+ TEST_ERROR;
+ }
+
+ PASSED();
+
+
+ /*****************/
+ /* H5PLreplace() */
+ /*****************/
+
+ TESTING(" replace");
+
+ /* Replace one path at index 1 */
+ HDsprintf(path, "a_path_%u", n_starting_paths + 4);
+ if (H5PLreplace(path, 1) < 0) {
+ HDfprintf(stderr," replace 1: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table size remained the same */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths != n_starting_paths)
+ TEST_ERROR;
+
+ /* Verify that the entries were not moved by
+ * inspecting the paths at indices +/- 1.
+ */
+
+ /* Check path at index 0 */
+ if (H5PLget(0, path, 256) <= 0)
+ TEST_ERROR;
+ HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1);
+ if (HDstrcmp(path, temp_name) != 0) {
+ HDfprintf(stderr," get 0: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Check path at index 2 */
+ if (H5PLget(2, path, 256) <= 0)
+ TEST_ERROR;
+ if (HDstrcmp(path, "a_path_1") != 0) {
+ HDfprintf(stderr," get 2: %s\n", path);
+ TEST_ERROR;
+ }
+
+ PASSED();
+
+
+ /****************/
+ /* H5PLinsert() */
+ /****************/
+
+ /* We'll remove a path at an arbitrary index and then
+ * insert a new path.
+ */
+
+ TESTING(" remove (arbitrary index 2)");
+
+ /* Remove one path */
+ if (H5PLremove(4) < 0)
+ TEST_ERROR;
+
+ /* Verify that the entries were moved */
+ if (H5PLget(4, path, 256) <= 0)
+ TEST_ERROR;
+ if (HDstrcmp(path, "a_path_4") != 0) {
+ HDfprintf(stderr," get 4: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table size */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths != n_starting_paths - 1)
+ TEST_ERROR;
+ PASSED();
+
+
+ TESTING(" insert");
+
+ /* Insert one path at index 3*/
+ HDsprintf(path, "a_path_%d", n_starting_paths + 5);
+ if (H5PLinsert(path, 3) < 0) {
+ HDfprintf(stderr," insert 3: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Verify that the entries were moved */
+ if (H5PLget(4, path, 256) <= 0)
+ TEST_ERROR;
+ if (HDstrcmp(path, "a_path_2") != 0) {
+ HDfprintf(stderr," get 4: %s\n", path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table size increased */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths != n_starting_paths)
+ TEST_ERROR;
+
+ PASSED();
+
+
+ /****************/
+ /* H5PLremove() */
+ /****************/
+
+ /* Remove all the current paths */
+ TESTING(" remove (all)");
+
+ /* Get the current size */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+
+ /* Remove all existing paths */
+ for (u = n_paths; u > 0; u--)
+ if (H5PLremove(u-1) < 0) {
+ HDfprintf(stderr," at %u: %s\n", u, path);
+ TEST_ERROR;
+ }
+
+ /* Verify the table is empty */
+ if (H5PLsize(&n_paths) < 0)
+ TEST_ERROR;
+ if (n_paths > 0)
+ TEST_ERROR;
+
+ PASSED();
+
+
+ return SUCCEED;
+
+error:
+ return FAIL;
+} /* end test_path_api_calls() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: disable_chunk_cache
+ *
+ * Purpose: Turns the chunk cache off
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+disable_chunk_cache(hid_t fapl_id) {
+ int mdc_nelmts;
+ size_t rdcc_nelmts;
+ size_t rdcc_nbytes;
+ double rdcc_w0;
+
+ if (H5Pget_cache(fapl_id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
+ TEST_ERROR;
+ rdcc_nbytes = 0;
+ if (H5Pset_cache(fapl_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
+ TEST_ERROR;
+
+ return SUCCEED;
+error:
+ return FAIL;
+} /* end disable_chunk_cache() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Tests the plugin module (H5PL)
+ *
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ char filename[FILENAME_BUF_SIZE];
+ hid_t fid = -1;
+ hid_t old_ff_fapl_id = -1;
+ hid_t new_ff_fapl_id = -1;
+ unsigned new_format;
+ int nerrors = 0;
+
+ /* Testing setup */
+ h5_reset();
+
+ /*******************************************************************/
+ /* ENSURE THAT WRITING TO DATASETS AND CREATING GROUPS WORKS */
+ /*******************************************************************/
+
+ /* Get a VFD-dependent filename */
+ if ((old_ff_fapl_id = h5_fileaccess()) < 0)
+ TEST_ERROR;
+
+ /* Turn off the chunk cache, so all the chunks are immediately written to disk */
+ if (disable_chunk_cache(old_ff_fapl_id) < 0)
+ TEST_ERROR;
+
+ /* Copy the file access property list and set the latest file format on it */
+ if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
+ TEST_ERROR;
+ if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ /* Fix up the filename for the VFD */
+ h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename));
+
+ /* Test with old & new format groups */
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl_id;
+
+ /* Set the FAPL for the type of format */
+ if (new_format) {
+ HDputs("\nTesting with new file format:");
+ my_fapl_id = new_ff_fapl_id;
+ }
+ else {
+ HDputs("Testing with old file format:");
+ my_fapl_id = old_ff_fapl_id;
+ }
+
+ /* Create the file for this test */
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl_id)) < 0)
+ TEST_ERROR;
+
+ /* Test creating datasets and writing to them using plugin filters */
+ nerrors += (test_dataset_write_with_filters(fid) < 0 ? 1 : 0);
+
+ /* Test creating groups using dynamically-loaded plugin filters */
+ nerrors += (test_creating_groups_using_plugins(fid) < 0 ? 1 : 0);
+
+ if (H5Fclose(fid) < 0)
+ TEST_ERROR;
+ } /* end for */
+
+ /* Close FAPLs */
+ if (H5Pclose(old_ff_fapl_id) < 0)
+ TEST_ERROR;
+ if (H5Pclose(new_ff_fapl_id) < 0)
+ TEST_ERROR;
+
+ /* Restore the default error handler (set in h5_reset()) */
+ h5_restore_err();
+
+ /*******************************************************************/
+ /* ENSURE THAT READING FROM DATASETS AND OPENING GROUPS WORKS */
+ /*******************************************************************/
+
+ HDputs("\nTesting reading data with with dynamic plugin filters:");
+
+ /* Close the library so that all loaded plugin libraries are unloaded */
+ h5_reset();
+ if ((old_ff_fapl_id = h5_fileaccess()) < 0)
+ TEST_ERROR;
+
+ /* Reopen the file for testing data reading */
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0)
+ TEST_ERROR;
+
+ /* Read the data with filters */
+ nerrors += (test_dataset_read_with_filters(fid) < 0 ? 1 : 0);
+
+ /* Test creating groups using dynamically-loaded plugin filters */
+ nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0);
+
+ /* Restore the default error handler (set in h5_reset()) */
+ h5_restore_err();
+
+ /*******************************************************************/
+ /* ENSURE THAT DISABLING FILTER PLUGINS VIA THE FILTER FLAGS WORKS */
+ /*******************************************************************/
+
+ /* Close the library so that all loaded plugin libraries are unloaded */
+ h5_reset();
+ if ((old_ff_fapl_id = h5_fileaccess()) < 0)
+ TEST_ERROR;
+
+ /* Reopen the file for testing data reading */
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0)
+ TEST_ERROR;
+
+ /* When filters are disabled, make sure we can't read data from a
+ * dataset that requires a filter plugin.
+ */
+ nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0);
+
+ if (H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ /************************************/
+ /* TEST THE FILTER PLUGIN API CALLS */
+ /************************************/
+
+ /* Test the APIs for access to the filter plugin path table */
+ nerrors += (test_path_api_calls() < 0 ? 1 : 0);
+
+ /*********************/
+ /* CLEAN UP AND EXIT */
+ /*********************/
+
+ /* Free up saved arrays */
+ free_2D_array(&orig_deflate_g);
+ free_2D_array(&orig_dynlib1_g);
+ free_2D_array(&orig_dynlib2_g);
+ free_2D_array(&orig_dynlib4_g);
+
+ if (nerrors)
+ TEST_ERROR;
+
+ HDprintf("All plugin tests passed.\n");
+ h5_cleanup(FILENAME, old_ff_fapl_id);
+
+ HDexit(EXIT_SUCCESS);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(fid);
+ H5Pclose(old_ff_fapl_id);
+ H5Pclose(new_ff_fapl_id);
+ } H5E_END_TRY
+
+ /* Free up saved arrays (NULLs okay) */
+ free_2D_array(&orig_deflate_g);
+ free_2D_array(&orig_dynlib1_g);
+ free_2D_array(&orig_dynlib2_g);
+ free_2D_array(&orig_dynlib4_g);
+
+ nerrors = MAX(1, nerrors);
+ HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
+ HDexit(EXIT_FAILURE);
+} /* end main() */
+
diff --git a/test/filter_plugin1_dsets.c b/test/filter_plugin1_dsets.c
new file mode 100644
index 0000000..b74e086
--- /dev/null
+++ b/test/filter_plugin1_dsets.c
@@ -0,0 +1,93 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: Test dataset filter plugin for the filter_pluging.c test.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "H5PLextern.h"
+
+#define FILTER1_ID 257
+
+static size_t add_sub_value(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+
+/* Filter class struct */
+const H5Z_class2_t FILTER_INFO[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ FILTER1_ID, /* Filter ID number */
+ 1, /* Encoding enabled */
+ 1, /* Decoding enabled */
+ "test filter plugin 1", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)add_sub_value, /* The actual filter function */
+}};
+
+H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
+const void *H5PLget_plugin_info(void) {return FILTER_INFO;}
+
+
+/*-------------------------------------------------------------------------
+ * Function: add_sub_value
+ *
+ * Purpose: On write:
+ * Adds a caller-supplied value to the element
+ * On read:
+ * Subtracts a caller-supplied value from the element
+ *
+ * Return: Success: Data chunk size in bytes
+ * Failure: 0
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+add_sub_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
+ size_t nbytes, size_t *buf_size, void **buf)
+{
+ int *int_ptr = (int *)*buf; /* Pointer to the data values */
+ size_t buf_left = *buf_size; /* Amount of data buffer left to process */
+ int value = 0; /* Data value to add/subtract */
+
+ /* Check for the correct number of parameters */
+ if (0 == cd_nelmts)
+ return 0;
+
+ /* Check that permanent parameters are set correctly */
+ if (cd_values[0] > 9)
+ return 0;
+
+ value = (int)cd_values[0];
+
+ if (flags & H5Z_FLAG_REVERSE) {
+ /* READ - Substract the given value from all the data values */
+ while (buf_left > 0) {
+ *int_ptr++ -= value;
+ buf_left -= sizeof(int);
+ }
+ }
+ else {
+ /* WRITE - Add the given value to all the data values */
+ while (buf_left > 0) {
+ *int_ptr++ += value;
+ buf_left -= sizeof(int);
+ }
+ }
+
+ return nbytes;
+
+} /* end add_sub_value() */
+
diff --git a/test/filter_plugin2_dsets.c b/test/filter_plugin2_dsets.c
new file mode 100644
index 0000000..6a79148
--- /dev/null
+++ b/test/filter_plugin2_dsets.c
@@ -0,0 +1,88 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: Test dataset filter plugin for the filter_pluging.c test.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "H5PLextern.h"
+
+#define FILTER2_ID 258
+#define MULTIPLIER 3
+
+static size_t mult_div_value(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+
+/* Filter class struct */
+const H5Z_class2_t FILTER_INFO[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ FILTER2_ID, /* Filter ID number */
+ 1, /* Encoding enabled */
+ 1, /* Decoding enabled */
+ "test filter plugin 2", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)mult_div_value, /* The actual filter function */
+}};
+
+H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
+const void *H5PLget_plugin_info(void) {return FILTER_INFO;}
+
+
+/*-------------------------------------------------------------------------
+ * Function: mult_div_value
+ *
+ * Purpose: On write:
+ * Multiplies an element by a constant value.
+ * On read:
+ * Divides an element by a constant value.
+ *
+ * Return: Success: Data chunk size in bytes
+ * Failure: 0
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+mult_div_value(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf)
+{
+ int *int_ptr = (int *)*buf; /* Pointer to the data values */
+ size_t buf_left = *buf_size; /* Amount of data buffer left to process */
+
+ /* Check for the correct number of parameters */
+ if (cd_nelmts > 0)
+ return 0;
+
+ /* Assignment to eliminate unused parameter warning */
+ cd_values = cd_values;
+
+ if (flags & H5Z_FLAG_REVERSE) {
+ /* READ - Divide the original value by MULTIPLIER */
+ while (buf_left > 0) {
+ *int_ptr++ /= MULTIPLIER;
+ buf_left -= sizeof(int);
+ }
+ }
+ else {
+ /* WRITE - Multiply the original value by MULTIPLIER */
+ while (buf_left > 0) {
+ *int_ptr++ *= MULTIPLIER;
+ buf_left -= sizeof(int);
+ }
+ }
+
+ return nbytes;
+} /* end mult_div_value() */
+
diff --git a/test/filter_plugin3_dsets.c b/test/filter_plugin3_dsets.c
new file mode 100644
index 0000000..b43020f
--- /dev/null
+++ b/test/filter_plugin3_dsets.c
@@ -0,0 +1,119 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: Test dataset filter plugin for the filter_pluging.c test.
+ * This filter makes an HDF5 API call to ensure that works correctly.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "H5PLextern.h"
+
+#define FILTER3_ID 259
+
+#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str)
+
+static size_t add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+
+/* Filter class struct */
+const H5Z_class2_t FILTER_INFO[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ FILTER3_ID, /* Filter ID number */
+ 1, /* Encoding enabled */
+ 1, /* Decoding enabled */
+ "test filter plugin 3", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)add_sub_value_hdf5, /* The actual filter function */
+}};
+
+H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
+const void *H5PLget_plugin_info(void) {return FILTER_INFO;}
+
+
+/*-------------------------------------------------------------------------
+ * Function: add_sub_value_hdf5
+ *
+ * Purpose: On write:
+ * Adds a caller-supplied value to the element
+ * On read:
+ * Subtracts a caller-supplied value from the element
+ *
+ * NOTE: This filter is identical to filter #1 only it makes
+ * an HDF5 library call to ensure doing that doesn't
+ * cause problems.
+ *
+ * Return: Success: Data chunk size in bytes
+ * Failure: 0
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
+ size_t nbytes, size_t *buf_size, void **buf)
+{
+ int *int_ptr = (int *)*buf; /* Pointer to the data values */
+ size_t buf_left = *buf_size; /* Amount of data buffer left to process */
+ int value = 0; /* Data value to add/subtract */
+ unsigned majnum = 0; /* Output data from the HDF5 library call */
+ unsigned minnum = 0;
+ unsigned relnum = 0;
+
+ /* Check for the library version.
+ * We don't do anything with this information - it's just to ensure that
+ * HDF5 library calls work properly from inside filter plugins.
+ */
+ if (H5get_libversion(&majnum, &minnum, &relnum) < 0) {
+ PUSH_ERR("filter plugin 3", H5E_CALLBACK, "H5get_libversion");
+ return 0;
+ }
+
+ /* Check for the correct number of parameters */
+ if (cd_nelmts == 0)
+ return 0;
+
+ /* Check that permanent parameters are set correctly */
+ if (cd_values[0] > 9)
+ return 0;
+
+ /* Ensure that the version numbers match what was passed in.
+ * Again, this is trivial work, just to ensure that the library calls are
+ * working properly.
+ */
+ if (majnum != cd_values[1] || minnum != cd_values[2]) {
+ PUSH_ERR("filter plugin 3", H5E_CALLBACK, "library versions do not match");
+ return 0;
+ }
+
+ value = (int)cd_values[0];
+
+ if (flags & H5Z_FLAG_REVERSE) {
+ /* READ - Substract the given value from all the data values */
+ while (buf_left > 0) {
+ *int_ptr++ -= value;
+ buf_left -= sizeof(int);
+ }
+ }
+ else {
+ /* WRITE - Add the given value to all the data values */
+ while (buf_left > 0) {
+ *int_ptr++ += value;
+ buf_left -= sizeof(int);
+ }
+ }
+
+ return nbytes;
+} /* end add_sub_value_hdf5() */
+
diff --git a/test/filter_plugin4_groups.c b/test/filter_plugin4_groups.c
new file mode 100644
index 0000000..88ea20d
--- /dev/null
+++ b/test/filter_plugin4_groups.c
@@ -0,0 +1,106 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: Test group filter plugin for the filter_pluging.c test.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "H5PLextern.h"
+
+#define FILTER4_ID 260
+#define SUFFIX_LEN 8
+#define GROUP_SUFFIX ".h5group"
+
+static size_t append_to_group_name(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+
+/* Filter class struct */
+const H5Z_class2_t FILTER_INFO[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ FILTER4_ID, /* Filter ID number */
+ 1, /* Encoding enabled */
+ 1, /* Decoding enabled */
+ "test filter plugin 4", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)append_to_group_name, /* The actual filter function */
+}};
+
+H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
+const void *H5PLget_plugin_info(void) {return FILTER_INFO;}
+
+
+/*-------------------------------------------------------------------------
+ * Function: append_to_group_name
+ *
+ * Purpose: On write:
+ * Appends the suffix ".h5group" to the group name
+ * On read:
+ * Removes the ".h5group" suffix from the group name
+ *
+ * Return: Success: Data size in bytes
+ * Failure: 0
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+append_to_group_name(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf)
+{
+ size_t new_name_size = 0; /* Return value */
+
+ /* Check for the correct number of parameters */
+ if (cd_nelmts > 0)
+ return 0;
+
+ /* Assignment to eliminate unused parameter warning. */
+ cd_values = cd_values;
+
+ if (flags & H5Z_FLAG_REVERSE) {
+ /* READ - Remove the suffix from the group name */
+ new_name_size = *buf_size = nbytes - SUFFIX_LEN;
+ }
+ else {
+ /* WRITE - Append the suffix to the group name */
+ void *outbuf = NULL; /* Pointer to new buffer */
+ unsigned char *dst = NULL; /* Temporary pointer to destination buffer */
+
+ /* Get memory for the new, larger string buffer using the
+ * library's memory allocator.
+ */
+ if (NULL == (dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0))))
+ return 0;
+
+ /* Copy raw data */
+ memcpy((void *)dst, (const void *)(*buf), nbytes);
+
+ /* Append suffix to raw data for storage */
+ dst += nbytes;
+ memcpy((void *)dst, (const void *)GROUP_SUFFIX, SUFFIX_LEN);
+
+ /* Free the passed-in buffer using the library's allocator */
+ H5free_memory(*buf);
+
+ /* Set return values */
+ *buf_size = nbytes + SUFFIX_LEN;
+ *buf = outbuf;
+ outbuf = NULL;
+ new_name_size = *buf_size;
+ }
+
+ return new_name_size;
+} /* append_to_group_name() */
+
diff --git a/test/plugin.c b/test/plugin.c
deleted file mode 100644
index ea199f6..0000000
--- a/test/plugin.c
+++ /dev/null
@@ -1,1217 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Purpose: Tests the plugin module (H5PL)
- */
-
-#include "h5test.h"
-#include "H5srcdir.h"
-
-/*
- * This file needs to access private datatypes from the H5Z and H5PL package.
- */
-#define H5PL_FRIEND
-#include "H5PLpkg.h"
-#define H5Z_FRIEND
-#include "H5Zpkg.h"
-
-/* Filters for HDF5 internal test */
-#define H5Z_FILTER_DYNLIB1 257
-#define H5Z_FILTER_DYNLIB2 258
-#define H5Z_FILTER_DYNLIB3 259
-#define H5Z_FILTER_DYNLIB4 260
-
-const char *FILENAME[] = {
- "plugin",
- NULL
-};
-#define FILENAME_BUF_SIZE 1024
-
-/* Dataset names for testing filters */
-#define DSET_DEFLATE_NAME "deflate"
-#define DSET_DYNLIB1_NAME "dynlib1"
-#define DSET_DYNLIB2_NAME "dynlib2"
-#define DSET_DYNLIB4_NAME "dynlib4"
-
-/* Parameters for internal filter test */
-#define FILTER_CHUNK_DIM1 2
-#define FILTER_CHUNK_DIM2 25
-#define FILTER_HS_OFFSET1 7
-#define FILTER_HS_OFFSET2 30
-#define FILTER_HS_SIZE1 4
-#define FILTER_HS_SIZE2 50
-
-/* Shared global arrays */
-#define DSET_DIM1 100
-#define DSET_DIM2 200
-
-/* Limit random number within 20000 */
-#define RANDOM_LIMIT 20000
-
-#define GROUP_ITERATION 1000
-
-int points_deflate[DSET_DIM1][DSET_DIM2],
- points_dynlib1[DSET_DIM1][DSET_DIM2],
- points_dynlib2[DSET_DIM1][DSET_DIM2],
- points_dynlib4[DSET_DIM1][DSET_DIM2],
- points_bzip2[DSET_DIM1][DSET_DIM2];
-
-
-/*-------------------------------------------------------------------------
- * Function: test_filter_internal
- *
- * Purpose: Tests writing entire data and partial data with filters
- *
- * Return: Success: 0
- * Failure: -1
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
-{
- herr_t ret_value = -1;
- hid_t dataset = -1; /* Dataset ID */
- hid_t dxpl = -1; /* Dataset xfer property list ID */
- hid_t write_dxpl = -1; /* Dataset xfer property list ID for writing */
- hid_t sid = -1; /* Dataspace ID */
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
- const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */
- const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */
- void *tconv_buf = NULL; /* Temporary conversion buffer */
- int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2];
- size_t i, j; /* Local index variables */
- int n = 0;
-
- /* Create the data space */
- if((sid = H5Screate_simple(2, size, NULL)) < 0) TEST_ERROR
-
- /*
- * Create a small conversion buffer to test strip mining. We
- * might as well test all we can!
- */
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
- tconv_buf = HDmalloc((size_t)1000);
- if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) TEST_ERROR
- if((write_dxpl = H5Pcopy(dxpl)) < 0) TEST_ERROR;
-
- TESTING(" filters (setup)");
-
- /* Check if all the filters are available */
- if(H5Pall_filters_avail(dcpl) != TRUE) {
- H5_FAILED();
- HDprintf(" Line %d: Incorrect filter availability\n", __LINE__);
- TEST_ERROR
- } /* end if */
-
- /* Create the dataset */
- if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
-
- PASSED();
-
- /*----------------------------------------------------------------------
- * STEP 1: Read uninitialized data. It should be zero.
- *----------------------------------------------------------------------
- */
- TESTING(" filters (uninitialized read)");
-
- if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
-
- for(i=0; i<(size_t)size[0]; i++)
- for(j=0; j<(size_t)size[1]; j++)
- if(0 != check[i][j]) {
- H5_FAILED();
- HDprintf(" Read a non-zero value.\n");
- HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- TEST_ERROR
- } /* end if */
- PASSED();
-
- /*----------------------------------------------------------------------
- * STEP 2: Test filters by setting up a chunked dataset and writing
- * to it.
- *----------------------------------------------------------------------
- */
- TESTING(" filters (write)");
-
- n = 0;
- for(i=0; i<size[0]; i++)
- for(j=0; j<size[1]; j++)
- points[i][j] = (int)(n++);
-
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) TEST_ERROR;
-
- PASSED();
-
- /*----------------------------------------------------------------------
- * STEP 3: Try to read the data we just wrote.
- *----------------------------------------------------------------------
- */
- TESTING(" filters (read)");
-
- /* Read the dataset back */
- if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
-
- /* Check that the values read are the same as the values written */
- for(i=0; i<size[0]; i++)
- for(j=0; j<size[1]; j++)
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- HDfprintf(stderr," Read different values than written.\n");
- HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- HDfprintf(stderr," At original: %d\n", (int)points[i][j]);
- HDfprintf(stderr," At returned: %d\n", (int)check[i][j]);
- TEST_ERROR
- } /* end if */
-
- PASSED();
-
- /*----------------------------------------------------------------------
- * STEP 4: Write new data over the top of the old data. The new data is
- * random thus not very compressible, and will cause the chunks to move
- * around as they grow. We only change values for the left half of the
- * dataset although we rewrite the whole thing.
- *----------------------------------------------------------------------
- */
- TESTING(" filters (modify)");
-
- for(i=0; i<size[0]; i++)
- for(j=0; j<size[1]/2; j++)
- points[i][j] = (int)HDrandom () % RANDOM_LIMIT;
-
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) TEST_ERROR;
-
- /* Read the dataset back and check it */
- if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
-
- /* Check that the values read are the same as the values written */
- for(i=0; i<size[0]; i++)
- for(j=0; j<size[1]; j++)
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- HDprintf(" Read different values than written.\n");
- HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- TEST_ERROR
- } /* end if */
-
- PASSED();
-
- /*----------------------------------------------------------------------
- * STEP 5: Close the dataset and then open it and read it again. This
- * insures that the filters message is picked up properly from the
- * object header.
- *----------------------------------------------------------------------
- */
- TESTING(" filters (re-open)");
-
- if(H5Dclose(dataset) < 0) TEST_ERROR;
- if((dataset = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR;
-
- /* Check that the values read are the same as the values written */
- for(i = 0; i < size[0]; i++)
- for(j = 0; j < size[1]; j++)
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- HDprintf(" Read different values than written.\n");
- HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- TEST_ERROR
- } /* end if */
-
- PASSED();
-
- /*----------------------------------------------------------------------
- * STEP 6: Test partial I/O by writing to and then reading from a
- * hyperslab of the dataset. The hyperslab does not line up on chunk
- * boundaries (we know that case already works from above tests).
- *----------------------------------------------------------------------
- */
- TESTING(" filters (partial I/O)");
-
- for(i=0; i<(size_t)hs_size[0]; i++)
- for(j=0; j<(size_t)hs_size[1]; j++)
- points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom() % RANDOM_LIMIT;
-
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) TEST_ERROR;
- /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0) TEST_ERROR;
-
- if(H5Dread(dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0) TEST_ERROR;
-
- /* Check that the values read are the same as the values written */
- for(i=0; i<(size_t)hs_size[0]; i++)
- for(j=0; j<(size_t)hs_size[1]; j++)
- if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] != check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]) {
- H5_FAILED();
- HDfprintf(stderr," Read different values than written.\n");
- HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)((size_t)hs_offset[0]+i), (unsigned long)((size_t)hs_offset[1]+j));
- HDfprintf(stderr," At original: %d\n", (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
- HDfprintf(stderr," At returned: %d\n", (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
- TEST_ERROR
- } /* end if */
-
- PASSED();
-
- /* Save the data written to the file for later comparison when the file
- * is reopened for read test */
- for(i=0; i<size[0]; i++)
- for(j=0; j<size[1]; j++)
- if(!HDstrcmp(name, DSET_DEFLATE_NAME))
- points_deflate[i][j] = points[i][j];
- else if(!HDstrcmp(name, DSET_DYNLIB1_NAME))
- points_dynlib1[i][j] = points[i][j];
- else if(!HDstrcmp(name, DSET_DYNLIB2_NAME))
- points_dynlib2[i][j] = points[i][j];
- else if(!HDstrcmp(name, DSET_DYNLIB4_NAME))
- points_dynlib4[i][j] = points[i][j];
-
- ret_value = 0;
-
-error:
- /* Clean up objects used for this test */
- H5E_BEGIN_TRY {
- H5Dclose(dataset);
- H5Sclose(sid);
- H5Pclose(dxpl);
- } H5E_END_TRY
-
- if(tconv_buf)
- HDfree(tconv_buf);
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_filters_for_datasets
- *
- * Purpose: Tests creating datasets and writing data with dynamically loaded filters
- *
- * Return: Success: 0
- * Failure: -1
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_filters_for_datasets(hid_t file)
-{
- herr_t ret_value = -1;
- hid_t dc = -1; /* Dataset creation property list ID */
- const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
- unsigned int compress_level = 9;
- unsigned int dynlib4_values[4];
-
- /*----------------------------------------------------------
- * STEP 1: Test deflation by itself.
- *----------------------------------------------------------
- */
- HDputs("Testing deflate filter");
-#ifdef H5_HAVE_FILTER_DEFLATE
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
- if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR
- if(H5Pset_deflate(dc, 6) < 0) TEST_ERROR
-
- if(test_filter_internal(file, DSET_DEFLATE_NAME, dc) < 0) TEST_ERROR
- /* Clean up objects used for this test */
- if(H5Pclose(dc) < 0) TEST_ERROR
-#else /* H5_HAVE_FILTER_DEFLATE */
- SKIPPED();
- HDputs(" Deflate filter not enabled");
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
- /*----------------------------------------------------------
- * STEP 2: Test DYNLIB1 by itself.
- *----------------------------------------------------------
- */
- HDputs(" DYNLIB1 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
- if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR
- if(H5Pset_filter(dc, H5Z_FILTER_DYNLIB1, H5Z_FLAG_MANDATORY, (size_t)1, &compress_level) < 0) TEST_ERROR
-
- if(test_filter_internal(file, DSET_DYNLIB1_NAME, dc) < 0) TEST_ERROR
-
- /* Clean up objects used for this test */
- if(H5Pclose(dc) < 0) TEST_ERROR
-
- /* Unregister the dynamic filter DYNLIB1 for testing purpose. The next time when this test is run for
- * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
- * for this filter. */
- if(H5Zunregister(H5Z_FILTER_DYNLIB1) < 0) TEST_ERROR
-
- /*----------------------------------------------------------
- * STEP 3: Test DYNLIB2 by itself.
- *----------------------------------------------------------
- */
- HDputs(" DYNLIB2 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
- if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR
- if(H5Pset_filter(dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL) < 0) TEST_ERROR
-
- if(test_filter_internal(file,DSET_DYNLIB2_NAME,dc) < 0) TEST_ERROR
-
- /* Clean up objects used for this test */
- if(H5Pclose(dc) < 0) TEST_ERROR
-
- /* Unregister the dynamic filter DYNLIB2 for testing purpose. The next time when this test is run for
- * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
- * for this filter. */
- if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) TEST_ERROR
-
- /*----------------------------------------------------------
- * STEP 4: Test DYNLIB4 by itself.
- *----------------------------------------------------------
- */
- HDputs(" DYNLIB4 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
- if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR
- dynlib4_values[0] = 9;
- if(H5get_libversion(&dynlib4_values[1], &dynlib4_values[2], &dynlib4_values[3]) < 0) TEST_ERROR
- if(H5Pset_filter(dc, H5Z_FILTER_DYNLIB4, H5Z_FLAG_MANDATORY, (size_t)4, dynlib4_values) < 0) TEST_ERROR
-
- if(test_filter_internal(file, DSET_DYNLIB4_NAME, dc) < 0) TEST_ERROR
-
- /* Clean up objects used for this test */
- if(H5Pclose(dc) < 0) TEST_ERROR
-
- /* Unregister the dynamic filter DYNLIB4 for testing purpose. The next time when this test is run for
- * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
- * for this filter. */
- if(H5Zunregister(H5Z_FILTER_DYNLIB4) < 0) TEST_ERROR
-
- ret_value = 0;
-
-error:
- /* Clean up objects used for this test */
- H5E_BEGIN_TRY {
- H5Pclose(dc);
- } H5E_END_TRY
-
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_read_data
- *
- * Purpose: Tests reading data and compares values
- *
- * Return: Success: 0
- * Failure: -1
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_read_data(hid_t dataset, int *origin_data)
-{
- herr_t ret_value = -1;
- int check[DSET_DIM1][DSET_DIM2];
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
- int *data_p = origin_data;
- size_t i, j; /* Local index variables */
-
- /* Read the dataset back */
- if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) TEST_ERROR;
-
- /* Check that the values read are the same as the values written */
- for(i=0; i<size[0]; i++)
- for(j=0; j<size[1]; j++) {
- if(*data_p != check[i][j]) {
- H5_FAILED();
- HDfprintf(stderr," Read different values than written.\n");
- HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- HDfprintf(stderr," At original: %d\n", *data_p);
- HDfprintf(stderr," At returned: %d\n", (int)check[i][j]);
- TEST_ERROR
- } /* end if */
- data_p++;
- }
-
- PASSED();
- ret_value = 0;
-
-error:
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_read_with_filters
- *
- * Purpose: Tests reading dataset created with dynamically loaded filters
- *
- * Return: Success: 0
- * Failure: -1
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_read_with_filters(hid_t file)
-{
- herr_t ret_value = -1;
- hid_t dset = -1; /* Dataset ID */
-
- /*----------------------------------------------------------
- * STEP 1: Test deflation by itself.
- *----------------------------------------------------------
- */
- TESTING("deflate filter");
-
-#ifdef H5_HAVE_FILTER_DEFLATE
- if(H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) TEST_ERROR
-
- if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
-
- if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR
-
- if(H5Dclose(dset) < 0) TEST_ERROR
-
- /* Clean up objects used for this test */
-#else /* H5_HAVE_FILTER_DEFLATE */
- SKIPPED();
- HDputs(" Deflate filter not enabled");
-#endif /* H5_HAVE_FILTER_DEFLATE */
-
- /*----------------------------------------------------------
- * STEP 2: Test DYNLIB1 by itself.
- *----------------------------------------------------------
- */
- TESTING(" DYNLIB1 filter");
-
- if((dset = H5Dopen2(file, DSET_DYNLIB1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR
-
- if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR
-
- if(H5Dclose(dset) < 0) TEST_ERROR
-
- /*----------------------------------------------------------
- * STEP 3: Test Bogus2 by itself.
- *----------------------------------------------------------
- */
- TESTING(" DYNLIB2 filter");
-
- if((dset = H5Dopen2(file, DSET_DYNLIB2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR
-
- if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR
-
- if(H5Dclose(dset) < 0) TEST_ERROR
-
- /*----------------------------------------------------------
- * STEP 4: Test DYNLIB4 by itself.
- *----------------------------------------------------------
- */
- TESTING(" DYNLIB4 filter");
-
- if((dset = H5Dopen2(file,DSET_DYNLIB4_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
-
- if(test_read_data(dset, (int *)points_dynlib4) < 0) TEST_ERROR
-
- if(H5Dclose(dset) < 0) TEST_ERROR
-
- ret_value = 0;
-
-error:
- /* Clean up objects used for this test */
- H5E_BEGIN_TRY {
- H5Dclose(dset);
- } H5E_END_TRY
-
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_noread_data
- *
- * Purpose: Tests not reading data
- *
- * Return: Success: 0
- * Failure: -1
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_noread_data(hid_t dataset)
-{
- herr_t ret_value = -1;
- int check[DSET_DIM1][DSET_DIM2];
- herr_t ret = -1;
-
- /* Read the dataset back */
- H5E_BEGIN_TRY {
- ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check);
- } H5E_END_TRY
- if(ret >= 0)
- TEST_ERROR
-
- PASSED();
- ret_value = 0;
-
-error:
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_noread_with_filters
- *
- * Purpose: Tests reading dataset created with dynamically loaded filters disabled
- *
- * Return: Success: 0
- * Failure: -1
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_noread_with_filters(hid_t file)
-{
- herr_t ret_value = -1;
- hid_t dset = -1; /* Dataset ID */
- unsigned plugin_state; /* status of plugins */
-
- TESTING("DYNLIB1 filter with plugins disabled");
-
- /* disable filter plugin */
- if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR
-
- plugin_state = plugin_state & (unsigned)(~H5PL_FILTER_PLUGIN);
-
- if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
-
- if((dset = H5Dopen2(file, DSET_DYNLIB1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR
-
- if(test_noread_data(dset) < 0) TEST_ERROR
-
- if(H5Dclose(dset) < 0) TEST_ERROR
-
- ret_value = 0;
-
-error:
- /* re-enable filter plugin */
- plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
- H5PLset_loading_state(plugin_state);
-
- /* Clean up objects used for this test */
- H5E_BEGIN_TRY {
- H5Dclose(dset);
- } H5E_END_TRY
-
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_filters_for_groups
- *
- * Purpose: Tests creating group with dynamically loaded filters
- *
- * Return: Success: 0
- * Failure: -1
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_filters_for_groups(hid_t file)
-{
- herr_t ret_value = -1;
- hid_t gcpl = -1;
- hid_t gid = -1;
- hid_t group = -1;
- int i;
- char gname[256];
-
- TESTING("DYNLIB3 filter for group");
-
- if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR
-
- /* Use DYNLIB3 for creating groups */
- if(H5Pset_filter (gcpl, H5Z_FILTER_DYNLIB3, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) TEST_ERROR
-
- /* Create a group using this filter */
- if((gid = H5Gcreate2(file, "group1", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
-
- /* Create multiple groups under "group1" */
- for(i=0; i < GROUP_ITERATION; i++) {
- HDsprintf(gname, "group_%d", i);
- if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(group) < 0) TEST_ERROR
- }
-
- /* Close the group */
- if(H5Gclose(gid) < 0) TEST_ERROR
-
- /* Clean up objects used for this test */
- if(H5Pclose(gcpl) < 0) TEST_ERROR
-
- PASSED();
-
- ret_value = 0;
-
-error:
- /* Clean up objects used for this test */
- H5E_BEGIN_TRY {
- H5Gclose(group);
- H5Gclose(gid);
- H5Pclose(gcpl);
- } H5E_END_TRY
-
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
- * Function: test_groups_with_filters
- *
- * Purpose: Tests opening group with dynamically loaded filters
- *
- * Return: Success: 0
- * Failure: -1
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_groups_with_filters(hid_t file)
-{
- herr_t ret_value = -1;
- hid_t gid = -1;
- hid_t group = -1;
- int i;
- char gname[256];
-
- TESTING("opening groups with DYNLIB3 filter");
-
- /* Open the top group */
- if((gid = H5Gopen2(file, "group1", H5P_DEFAULT)) < 0) TEST_ERROR
-
- /* Create multiple groups under "group1" */
- for(i=0; i < GROUP_ITERATION; i++) {
- HDsprintf(gname, "group_%d", i);
- if((group = H5Gopen2(gid, gname, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(group) < 0) TEST_ERROR
- }
-
- /* Close the group */
- if(H5Gclose(gid) < 0) TEST_ERROR
-
- PASSED();
-
- ret_value = 0;
-
-error:
- /* Clean up objects used for this test */
- H5E_BEGIN_TRY {
- H5Gclose(group);
- H5Gclose(gid);
- } H5E_END_TRY
-
- return ret_value;
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: test_path_api_calls
- *
- * Purpose: Tests the H5PL API calls that manipulate the plugin search
- * paths.
- *
- * Return: SUCCEED/FAIL
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-test_path_api_calls(void)
-{
- unsigned int n_starting_paths;
- unsigned int u;
- unsigned int n_paths;
- herr_t ret;
- ssize_t path_len = -1;
- char path[256];
- char temp_name[256];
-
- HDputs("Testing access to the filter path table");
-
- if(H5Zfilter_avail(H5Z_FILTER_DYNLIB1) != TRUE)
- TEST_ERROR
-
- /* Set the number of paths to create for this test.
- *
- * This should be set high enough to ensure that at least one array
- * expansion will take place. See H5PLpath.c for details.
- */
- n_starting_paths = 42;
-
- /* Check that initialization is correct */
- TESTING(" initialize");
-
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths != 2)
- TEST_ERROR
-
- PASSED();
-
- /****************/
- /* H5PLremove() */
- /****************/
-
- /* Remove all the current paths */
- TESTING(" remove");
-
- /* Get the current size */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
-
- /* Remove all existing paths */
- for(u = n_paths; u > 0; u--)
- if(H5PLremove(u-1) < 0) {
- HDfprintf(stderr," at %u: %s\n", u, path);
- TEST_ERROR
- }
-
- /* Verify the table is empty */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths > 0)
- TEST_ERROR
-
- PASSED();
-
-
- TESTING(" remove (index 0 in empty table)");
-
- /* Try to remove index zero in an empty list (SHOULD FAIL) */
- H5E_BEGIN_TRY {
- ret = H5PLremove(0);
- } H5E_END_TRY
- if(ret >= 0)
- TEST_ERROR
-
- PASSED();
-
-
- /****************/
- /* H5PLappend() */
- /****************/
-
- TESTING(" append");
-
- /* Add a bunch of paths to the path table */
- for(u = 0; u < n_starting_paths; u++) {
- HDsprintf(path, "a_path_%u", u);
- if(H5PLappend(path) < 0) {
- HDfprintf(stderr," at %u: %s\n", u, path);
- TEST_ERROR
- }
- }
-
- PASSED();
-
-
- /**********************/
- /* H5PLremove() again */
- /**********************/
-
- TESTING(" remove (index too high)");
-
- /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */
- H5E_BEGIN_TRY {
- ret = H5PLremove(n_starting_paths);
- } H5E_END_TRY
-
- if(ret >= 0)
- TEST_ERROR
-
- PASSED();
-
-
- /*************/
- /* H5PLget() */
- /*************/
-
- TESTING(" get (path name)");
-
- /* Get the path length by passing in NULL */
- if((path_len = H5PLget(0, NULL, 0)) <= 0) {
- HDfprintf(stderr," get path 0 length failed\n");
- TEST_ERROR
- }
- if(path_len != 8)
- TEST_ERROR
-
- /* Get the path */
- if((path_len = H5PLget(0, path, 256)) <= 0) {
- HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path);
- TEST_ERROR
- }
- if(HDstrcmp(path, "a_path_0") != 0) {
- HDfprintf(stderr," get 0: %s\n", path);
- TEST_ERROR
- }
-
- PASSED();
-
-
- TESTING(" get (high and low indices)");
-
- /* Get path at index 1 */
- if((path_len = H5PLget(1, path, 256)) <= 0)
- TEST_ERROR
- if(HDstrcmp(path, "a_path_1") != 0) {
- HDfprintf(stderr," get 1: %s\n", path);
- TEST_ERROR
- }
-
- /* Get path at the last index */
- if((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0)
- TEST_ERROR
- HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1);
- if(HDstrcmp(path, temp_name) != 0) {
- HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path);
- TEST_ERROR
- }
-
- PASSED();
-
-
- TESTING(" get (index too high)");
-
- /* Get path at the last + 1 index (SHOULD FAIL) */
- H5E_BEGIN_TRY {
- path_len = H5PLget(n_starting_paths, NULL, 0);
- } H5E_END_TRY
- if(path_len > 0)
- TEST_ERROR
-
- PASSED();
-
-
- /*****************/
- /* H5PLprepend() */
- /*****************/
-
- /* We'll remove a path at an arbitrary index and then
- * prepend a new path.
- */
-
- TESTING(" remove (arbitrary index 1)");
-
- /* Remove one path */
- if(H5PLremove(8) < 0)
- TEST_ERROR
-
- /* Verify that the entries were moved */
- if((path_len = H5PLget(8, path, 256)) <= 0)
- TEST_ERROR
- if(HDstrcmp(path, "a_path_9") != 0) {
- HDfprintf(stderr," get 8: %s\n", path);
- TEST_ERROR
- }
-
- /* Verify the table shrank */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths != n_starting_paths - 1)
- TEST_ERROR
-
- PASSED();
-
-
- TESTING(" prepend");
-
- /* Prepend one path */
- HDsprintf(path, "a_path_%d", n_starting_paths + 1);
- if(H5PLprepend(path) < 0) {
- HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path);
- TEST_ERROR
- }
-
- /* Verify the table increased */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths != n_starting_paths)
- TEST_ERROR
-
- /* Verify that the entries were moved */
- if(H5PLget(8, path, 256) <= 0)
- TEST_ERROR
- if(HDstrcmp(path, "a_path_7") != 0) {
- HDfprintf(stderr," get 8: %s\n", path);
- TEST_ERROR
- }
-
- /* Verify that the path was inserted at index zero */
- if(H5PLget(0, path, 256) <= 0)
- TEST_ERROR
- HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1);
- if(HDstrcmp(path, temp_name) != 0) {
- HDfprintf(stderr," get 0: %s\n", path);
- TEST_ERROR
- }
-
- PASSED();
-
-
- /*****************/
- /* H5PLreplace() */
- /*****************/
-
- TESTING(" replace");
-
- /* Replace one path at index 1 */
- HDsprintf(path, "a_path_%u", n_starting_paths + 4);
- if(H5PLreplace(path, 1) < 0) {
- HDfprintf(stderr," replace 1: %s\n", path);
- TEST_ERROR
- }
-
- /* Verify the table size remained the same */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths != n_starting_paths)
- TEST_ERROR
-
- /* Verify that the entries were not moved by
- * inspecting the paths at indices +/- 1.
- */
-
- /* Check path at index 0 */
- if(H5PLget(0, path, 256) <= 0)
- TEST_ERROR
- HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1);
- if(HDstrcmp(path, temp_name) != 0) {
- HDfprintf(stderr," get 0: %s\n", path);
- TEST_ERROR
- }
-
- /* Check path at index 2 */
- if(H5PLget(2, path, 256) <= 0)
- TEST_ERROR
- if(HDstrcmp(path, "a_path_1") != 0) {
- HDfprintf(stderr," get 2: %s\n", path);
- TEST_ERROR
- }
-
- PASSED();
-
-
- /****************/
- /* H5PLinsert() */
- /****************/
-
- /* We'll remove a path at an arbitrary index and then
- * insert a new path.
- */
-
- TESTING(" remove (arbitrary index 2)");
-
- /* Remove one path */
- if(H5PLremove(4) < 0)
- TEST_ERROR
-
- /* Verify that the entries were moved */
- if(H5PLget(4, path, 256) <= 0)
- TEST_ERROR
- if(HDstrcmp(path, "a_path_4") != 0) {
- HDfprintf(stderr," get 4: %s\n", path);
- TEST_ERROR
- }
-
- /* Verify the table size */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths != n_starting_paths - 1)
- TEST_ERROR
- PASSED();
-
-
- TESTING(" insert");
-
- /* Insert one path at index 3*/
- HDsprintf(path, "a_path_%d", n_starting_paths + 5);
- if(H5PLinsert(path, 3) < 0) {
- HDfprintf(stderr," insert 3: %s\n", path);
- TEST_ERROR
- }
-
- /* Verify that the entries were moved */
- if(H5PLget(4, path, 256) <= 0)
- TEST_ERROR
- if(HDstrcmp(path, "a_path_2") != 0) {
- HDfprintf(stderr," get 4: %s\n", path);
- TEST_ERROR
- }
-
- /* Verify the table size increased */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths != n_starting_paths)
- TEST_ERROR
-
- PASSED();
-
-
- /****************/
- /* H5PLremove() */
- /****************/
-
- /* Remove all the current paths */
- TESTING(" remove (all)");
-
- /* Get the current size */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
-
- /* Remove all existing paths */
- for(u = n_paths; u > 0; u--)
- if(H5PLremove(u-1) < 0) {
- HDfprintf(stderr," at %u: %s\n", u, path);
- TEST_ERROR
- }
-
- /* Verify the table is empty */
- if(H5PLsize(&n_paths) < 0)
- TEST_ERROR
- if(n_paths > 0)
- TEST_ERROR
-
- PASSED();
-
-
- return SUCCEED;
-
-error:
- return FAIL;
-} /* end test_path_api_calls() */
-
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Tests the plugin module (H5PL)
- *
- * Return: EXIT_SUCCESS/EXIT_FAILURE
- *
- *-------------------------------------------------------------------------
- */
-int
-main(void)
-{
- char filename[FILENAME_BUF_SIZE];
- hid_t file = -1;
- hid_t fapl = -1;
- hid_t fapl2 = -1;
- unsigned new_format;
- int mdc_nelmts;
- size_t rdcc_nelmts;
- size_t rdcc_nbytes;
- double rdcc_w0;
- int nerrors = 0;
-
- /* Testing setup */
- h5_reset();
-
- if ((fapl = h5_fileaccess()) < 0)
- TEST_ERROR
-
- /* Turn off the chunk cache, so all the chunks are immediately written to disk */
- if (H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
- TEST_ERROR
- rdcc_nbytes = 0;
- if (H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
- TEST_ERROR
-
- /* Copy the file access property list */
- if ((fapl2 = H5Pcopy(fapl)) < 0)
- TEST_ERROR
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- TEST_ERROR
-
- h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
-
- /* Test with old & new format groups */
- for (new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
-
- /* Set the FAPL for the type of format */
- if (new_format) {
- HDputs("\nTesting with new file format:");
- my_fapl = fapl2;
- }
- else {
- HDputs("Testing with old file format:");
- my_fapl = fapl;
- }
-
- /* Create the file for this test */
- if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0)
- TEST_ERROR
-
- /* Test dynamically loaded filters for chunked dataset */
- nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0);
-
- /* Test dynamically loaded filters for groups */
- nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0);
-
- if (H5Fclose(file) < 0)
- TEST_ERROR
- } /* end for */
-
- /* Close FAPL */
- if (H5Pclose(fapl2) < 0)
- TEST_ERROR
- if (H5Pclose(fapl) < 0)
- TEST_ERROR
-
- /* Restore the default error handler (set in h5_reset()) */
- h5_restore_err();
-
- HDputs("\nTesting reading data with with dynamic plugin filters:");
-
- /* Close the library so that all loaded plugin libraries are unloaded */
- h5_reset();
- if ((fapl = h5_fileaccess()) < 0)
- TEST_ERROR
-
- /* Reopen the file for testing data reading */
- if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
- TEST_ERROR
-
- /* Read the data with filters */
- nerrors += (test_read_with_filters(file) < 0 ? 1 : 0);
-
- /* Open the groups with filters */
- nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0);
-
- /* Restore the default error handler (set in h5_reset()) */
- h5_restore_err();
-
- /* Close the library so that all loaded plugin libraries are unloaded */
- h5_reset();
- if ((fapl = h5_fileaccess()) < 0)
- TEST_ERROR
-
- /* Reopen the file for testing data reading */
- if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
- TEST_ERROR
-
- /* Read the data with disabled filters */
- nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0);
-
- if (H5Fclose(file) < 0)
- TEST_ERROR
-
- /* Test the APIs for access to the filter plugin path table */
- nerrors += (test_path_api_calls() < 0 ? 1 : 0);
-
- if (nerrors)
- TEST_ERROR
-
- HDprintf("All plugin tests passed.\n");
- h5_cleanup(FILENAME, fapl);
-
- HDexit(EXIT_SUCCESS);
-
-error:
- nerrors = MAX(1, nerrors);
- HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
- HDexit(EXIT_FAILURE);
-} /* end main() */
-
diff --git a/test/test_plugin.sh.in b/test/test_filter_plugin.sh.in
index c90a978..0a45c0f 100644
--- a/test/test_plugin.sh.in
+++ b/test/test_filter_plugin.sh.in
@@ -13,7 +13,7 @@
srcdir=@srcdir@
TOP_BUILDDIR=@top_builddir@
-# Determine backward compatibility options enabled
+# Determine if backward compatibility options enabled
DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
EXIT_SUCCESS=0
@@ -23,21 +23,21 @@ nerrors=0
verbose=yes
exit_code=$EXIT_SUCCESS
-TEST_NAME=plugin
+TEST_NAME=filter_plugin
TEST_BIN=`pwd`/$TEST_NAME
FROM_DIR=`pwd`/.libs
case $(uname) in
CYGWIN* )
- PLUGIN_LIB1="$FROM_DIR/cygdynlib1* $FROM_DIR/cygdynlib3*"
- PLUGIN_LIB2="$FROM_DIR/cygdynlib2* $FROM_DIR/cygdynlib4*"
+ PLUGINS_FOR_DIR1="$FROM_DIR/cygfilter_plugin1* $FROM_DIR/cygfilter_plugin3*"
+ PLUGINS_FOR_DIR2="$FROM_DIR/cygfilter_plugin2* $FROM_DIR/cygfilter_plugin4*"
;;
*)
- PLUGIN_LIB1="$FROM_DIR/libdynlib1.* $FROM_DIR/libdynlib3.*"
- PLUGIN_LIB2="$FROM_DIR/libdynlib2.* $FROM_DIR/libdynlib4.*"
+ PLUGINS_FOR_DIR1="$FROM_DIR/libfilter_plugin1* $FROM_DIR/libfilter_plugin3*"
+ PLUGINS_FOR_DIR2="$FROM_DIR/libfilter_plugin2* $FROM_DIR/libfilter_plugin4*"
;;
esac
-PLUGIN_LIBDIR1=testdir1
-PLUGIN_LIBDIR2=testdir2
+PLUGIN_DIR1=filter_plugin_dir1
+PLUGIN_DIR2=filter_plugin_dir2
CP="cp -p" # Use -p to preserve mode,ownership,timestamps
RM="rm -rf"
@@ -50,34 +50,34 @@ TESTING() {
}
# Main Body
-# Create test directories if not exists yet.
-test -d $PLUGIN_LIBDIR1 || mkdir -p $PLUGIN_LIBDIR1
+# Create test directories if necessary.
+test -d $PLUGIN_DIR1 || mkdir -p $PLUGIN_DIR1
if [ $? != 0 ]; then
- echo "Failed to create test directory($PLUGIN_LIBDIR1)"
+ echo "Failed to create filter plugin test directory ($PLUGIN_DIR1)"
exit $EXIT_FAILURE
fi
-test -d $PLUGIN_LIBDIR2 || mkdir -p $PLUGIN_LIBDIR2
+test -d $PLUGIN_DIR2 || mkdir -p $PLUGIN_DIR2
if [ $? != 0 ]; then
- echo "Failed to create test directory($PLUGIN_LIBDIR2)"
+ echo "Failed to create filter plugin test directory ($PLUGIN_DIR2)"
exit $EXIT_FAILURE
fi
-# copy plugin library for test
-$CP $PLUGIN_LIB1 $PLUGIN_LIBDIR1
+# Copy plugins for the tests.
+$CP $PLUGINS_FOR_DIR1 $PLUGIN_DIR1
if [ $? != 0 ]; then
- echo "Failed to copy plugin library ($PLUGIN_LIB1) for test."
+ echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR1) to test directory."
exit $EXIT_FAILURE
fi
-$CP $PLUGIN_LIB2 $PLUGIN_LIBDIR2
+$CP $PLUGINS_FOR_DIR2 $PLUGIN_DIR2
if [ $? != 0 ]; then
- echo "Failed to copy plugin library ($PLUGIN_LIB2) for test."
+ echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR2) to test directory."
exit $EXIT_FAILURE
fi
# setup plugin path
-ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR1}:${PLUGIN_LIBDIR2}"
+ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_DIR1}:${PLUGIN_DIR2}"
# Run the test
$ENVCMD $TEST_BIN
@@ -87,9 +87,9 @@ fi
############################################
# HDFFV-9655 test for relative path disabled
-# setup plugin path relative to test
+# setup filter plugin path relative to test
# actual executable is in the .libs folder
-#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_LIBDIR1}:@/../${PLUGIN_LIBDIR2}"
+#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_DIR1}:@/../${PLUGIN_DIR2}"
#
# Run the test
#$ENVCMD $TEST_BIN
@@ -103,11 +103,11 @@ if test $nerrors -ne 0 ; then
echo "$nerrors errors encountered"
exit_code=$EXIT_FAILURE
else
- echo "All Plugin API tests passed."
+ echo "All filter plugin tests passed."
exit_code=$EXIT_SUCCESS
fi
# Clean up temporary files/directories and leave
-$RM $PLUGIN_LIBDIR1 $PLUGIN_LIBDIR2
+$RM $PLUGIN_DIR1 $PLUGIN_DIR2
exit $exit_code
diff --git a/tools/test/h5diff/Makefile.am b/tools/test/h5diff/Makefile.am
index d2b5ebb..4d43a2a 100644
--- a/tools/test/h5diff/Makefile.am
+++ b/tools/test/h5diff/Makefile.am
@@ -53,9 +53,6 @@ if HAVE_SHARED_CONDITIONAL
noinst_LTLIBRARIES=libdynlibdiff.la
libdynlibdiff_la_SOURCES=dynlib_diff.c
libdynlibdiff_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
-
- libdynlibdiff.la: $(libdynlibdiff_la_OBJECTS) $(libdynlibdiff_la_DEPENDENCIES) $(EXTRA_libdynlibdiff_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlibdiff_la_LINK) $(am_libdynlibdiff_la_rpath) $(libdynlibdiff_la_OBJECTS) $(libdynlibdiff_la_LIBADD)
endif
# Temporary files. *.h5 are generated by h5diff. They should
diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am
index 1454987..be21119 100644
--- a/tools/test/h5dump/Makefile.am
+++ b/tools/test/h5dump/Makefile.am
@@ -42,9 +42,6 @@ if HAVE_SHARED_CONDITIONAL
noinst_LTLIBRARIES=libdynlibdump.la
libdynlibdump_la_SOURCES=dynlib_dump.c
libdynlibdump_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
-
- libdynlibdump.la: $(libdynlibdump_la_OBJECTS) $(libdynlibdump_la_DEPENDENCIES) $(EXTRA_libdynlibdump_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlibdump_la_LINK) $(am_libdynlibdump_la_rpath) $(libdynlibdump_la_OBJECTS) $(libdynlibdump_la_LIBADD)
endif
# Temporary files. *.h5 are generated by h5dumpgentest. They should
diff --git a/tools/test/h5ls/Makefile.am b/tools/test/h5ls/Makefile.am
index ec8b8c3..a49c2e8 100644
--- a/tools/test/h5ls/Makefile.am
+++ b/tools/test/h5ls/Makefile.am
@@ -39,9 +39,6 @@ if HAVE_SHARED_CONDITIONAL
noinst_LTLIBRARIES=libdynlibls.la
libdynlibls_la_SOURCES=dynlib_ls.c
libdynlibls_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
-
- libdynlibls.la: $(libdynlibls_la_OBJECTS) $(libdynlibls_la_DEPENDENCIES) $(EXTRA_libdynlibls_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlibls_la_LINK) $(am_libdynlibls_la_rpath) $(libdynlibls_la_OBJECTS) $(libdynlibls_la_LIBADD)
endif
diff --git a/tools/test/h5repack/Makefile.am b/tools/test/h5repack/Makefile.am
index d4dc843..fbe88bd 100644
--- a/tools/test/h5repack/Makefile.am
+++ b/tools/test/h5repack/Makefile.am
@@ -50,11 +50,6 @@ if HAVE_SHARED_CONDITIONAL
libdynlibvers_la_SOURCES=dynlib_vrpk.c
libdynlibadd_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
libdynlibvers_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
-
- libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD)
- libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $(EXTRA_libdynlibvers_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD)
endif