diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/CMakeTests.cmake | 184 | ||||
-rw-r--r-- | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/dynlib4.c | 104 | ||||
-rw-r--r-- | test/plugin.c | 39 | ||||
-rw-r--r-- | test/test_plugin.sh.in | 12 |
6 files changed, 198 insertions, 145 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 21db2e9..949a228 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -82,6 +82,7 @@ endif (BUILD_SHARED_LIBS) ) set (TEST2_PLUGIN_LIBS dynlib2 + dynlib4 ) foreach (test_lib ${TEST_PLUGIN_LIBS}) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 8126042..1336349 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -43,41 +43,17 @@ set (HDF5_TEST_FILES ) foreach (h5_tfile ${HDF5_TEST_FILES}) - set (dest "${PROJECT_BINARY_DIR}/H5TEST/${h5_tfile}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/H5TEST/${h5_tfile}" "HDF5_TEST_LIB_files") if (BUILD_SHARED_LIBS) - set (dest "${PROJECT_BINARY_DIR}/H5TEST-shared/${h5_tfile}") - add_custom_command ( - TARGET ${HDF5_TEST_LIBSH_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/H5TEST-shared/${h5_tfile}" "HDF5_TEST_LIBSH_files") endif (BUILD_SHARED_LIBS) endforeach (h5_tfile ${HDF5_TEST_FILES}) if (HDF5_TEST_VFD) foreach (vfdtest ${VFD_LIST}) foreach (h5_tfile ${HDF5_TEST_FILES}) - set (dest "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}" "HDF5_TEST_LIB_files") if (BUILD_SHARED_LIBS) - set (dest "${PROJECT_BINARY_DIR}/${vfdtest}-shared/${h5_tfile}") - add_custom_command ( - TARGET ${HDF5_TEST_LIBSH_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/${vfdtest}-shared/${h5_tfile}" "HDF5_TEST_LIBSH_files") endif (BUILD_SHARED_LIBS) endforeach (h5_tfile ${HDF5_TEST_FILES}) endforeach (vfdtest ${VFD_LIST}) @@ -95,41 +71,17 @@ set (HDF5_REFERENCE_FILES ) foreach (ref_file ${HDF5_REFERENCE_FILES}) - set (dest "${PROJECT_BINARY_DIR}/H5TEST/${ref_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/H5TEST/${ref_file}" "HDF5_TEST_LIB_files") if (BUILD_SHARED_LIBS) - set (dest "${PROJECT_BINARY_DIR}/H5TEST-shared/${ref_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIBSH_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/H5TEST-shared/${ref_file}" "HDF5_TEST_LIBSH_files") endif (BUILD_SHARED_LIBS) endforeach (ref_file ${HDF5_REFERENCE_FILES}) if (HDF5_TEST_VFD) foreach (vfdtest ${VFD_LIST}) foreach (ref_file ${HDF5_REFERENCE_FILES}) - set (dest "${PROJECT_BINARY_DIR}/${vfdtest}/${ref_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/${vfdtest}/${ref_file}" "HDF5_TEST_LIB_files") if (BUILD_SHARED_LIBS) - set (dest "${PROJECT_BINARY_DIR}/${vfdtest}-shared/${ref_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/${vfdtest}-shared/${ref_file}" "HDF5_TEST_LIBSH_files") endif (BUILD_SHARED_LIBS) endforeach (ref_file ${HDF5_REFERENCE_FILES}) endforeach (vfdtest ${VFD_LIST}) @@ -175,49 +127,28 @@ set (HDF5_REFERENCE_TEST_FILES ) foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) - set (dest "${HDF5_TEST_BINARY_DIR}/H5TEST/${h5_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/H5TEST/${h5_file}" "HDF5_TEST_LIB_files") if (BUILD_SHARED_LIBS) - set (dest "${HDF5_TEST_BINARY_DIR}/H5TEST-shared/${h5_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIBSH_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/H5TEST-shared/${h5_file}" "HDF5_TEST_LIBSH_files") endif (BUILD_SHARED_LIBS) endforeach (h5_file ${HDF5_REFERENCE_TEST_FILES}) if (HDF5_TEST_VFD) foreach (vfdtest ${VFD_LIST}) foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) - set (dest "${HDF5_TEST_BINARY_DIR}/${vfdtest}/${h5_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/${vfdtest}/${h5_file}" "HDF5_TEST_LIB_files") if (BUILD_SHARED_LIBS) - set (dest "${HDF5_TEST_BINARY_DIR}/${vfdtest}-shared/${h5_file}") - add_custom_command ( - TARGET ${HDF5_TEST_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} - ) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/${vfdtest}-shared/${h5_file}" "HDF5_TEST_LIBSH_files") endif (BUILD_SHARED_LIBS) endforeach (h5_file ${HDF5_REFERENCE_TEST_FILES}) endforeach (vfdtest ${VFD_LIST}) endif (HDF5_TEST_VFD) +add_custom_target(HDF5_TEST_LIB_files ALL COMMENT "Copying files needed by HDF5_TEST_LIB tests" DEPENDS ${HDF5_TEST_LIB_files_list}) +if (BUILD_SHARED_LIBS) + add_custom_target(HDF5_TEST_LIBSH_files ALL COMMENT "Copying files needed by HDF5_TEST_LIBSH tests" DEPENDS ${HDF5_TEST_LIBSH_files_list}) +endif() # Remove any output file left over from previous test run -add_test ( - NAME H5TEST-clear-testhdf5-objects +add_test (NAME H5TEST-clear-testhdf5-objects COMMAND ${CMAKE_COMMAND} -E remove coord.h5 @@ -274,8 +205,7 @@ else (HDF5_ENABLE_USING_MEMCHECKER) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) if (BUILD_SHARED_LIBS) - add_test ( - NAME H5TEST-shared-clear-testhdf5-objects + add_test (NAME H5TEST-shared-clear-testhdf5-objects COMMAND ${CMAKE_COMMAND} -E remove coord.h5 @@ -314,8 +244,7 @@ endif (HDF5_ENABLE_USING_MEMCHECKER) ############################################################################## # Remove any output file left over from previous test run -add_test ( - NAME H5TEST-clear-objects +add_test (NAME H5TEST-clear-objects COMMAND ${CMAKE_COMMAND} -E remove dt_arith1.h5 @@ -383,8 +312,7 @@ add_test ( foreach (test ${H5_TESTS}) if (${test} STREQUAL "big" AND CYGWIN) - add_test ( - NAME H5TEST-${test} + add_test (NAME H5TEST-${test} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${test}" ) else (${test} STREQUAL "big" AND CYGWIN) @@ -405,8 +333,7 @@ set_tests_properties (H5TEST-objcopy PROPERTIES TIMEOUT 2400) if (BUILD_SHARED_LIBS) # Remove any output file left over from previous test run - add_test ( - NAME H5TEST-shared-clear-objects + add_test (NAME H5TEST-shared-clear-objects COMMAND ${CMAKE_COMMAND} -E remove dt_arith1.h5 @@ -474,8 +401,7 @@ if (BUILD_SHARED_LIBS) foreach (test ${H5_TESTS}) if (${test} STREQUAL "big" AND CYGWIN) - add_test ( - NAME H5TEST-shared-${test} + add_test (NAME H5TEST-shared-${test} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${test}-shared" ) else (${test} STREQUAL "big" AND CYGWIN) @@ -555,8 +481,7 @@ set_tests_properties (H5TEST-ttsafe PROPERTIES #-- Adding test for err_compat if (HDF5_ENABLE_DEPRECATED_SYMBOLS) - add_test ( - NAME H5TEST-clear-err_compat-objects + add_test (NAME H5TEST-clear-err_compat-objects COMMAND ${CMAKE_COMMAND} -E remove err_compat.txt @@ -582,8 +507,7 @@ if (HDF5_ENABLE_DEPRECATED_SYMBOLS) endif (HDF5_ENABLE_DEPRECATED_SYMBOLS) #-- Adding test for error_test -add_test ( - NAME H5TEST-clear-error_test-objects +add_test (NAME H5TEST-clear-error_test-objects COMMAND ${CMAKE_COMMAND} -E remove error_test.txt @@ -608,8 +532,7 @@ set_tests_properties (H5TEST-error_test PROPERTIES ) #-- Adding test for links_env -add_test ( - NAME H5TEST-clear-links_env-objects +add_test (NAME H5TEST-clear-links_env-objects COMMAND ${CMAKE_COMMAND} -E remove links_env.txt @@ -638,8 +561,7 @@ set_tests_properties (H5TEST-links_env PROPERTIES ) #-- Adding test for libinfo -add_test ( - NAME H5TEST-testlibinfo +add_test (NAME H5TEST-testlibinfo COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$<TARGET_FILE:${HDF5_LIB_TARGET}>" -P "${GREP_RUNNER}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST @@ -648,8 +570,7 @@ add_test ( if (BUILD_SHARED_LIBS) #-- Adding test for cache if (NOT CYGWIN) - add_test ( - NAME H5TEST-shared-clear-cache-objects + add_test (NAME H5TEST-shared-clear-cache-objects COMMAND ${CMAKE_COMMAND} -E remove cache_test.h5 @@ -702,8 +623,7 @@ if (BUILD_SHARED_LIBS) #-- Adding test for err_compat if (HDF5_ENABLE_DEPRECATED_SYMBOLS) - add_test ( - NAME H5TEST-shared-clear-err_compat-objects + add_test (NAME H5TEST-shared-clear-err_compat-objects COMMAND ${CMAKE_COMMAND} -E remove err_compat.txt @@ -729,8 +649,7 @@ if (BUILD_SHARED_LIBS) endif (HDF5_ENABLE_DEPRECATED_SYMBOLS) #-- Adding test for error_test - add_test ( - NAME H5TEST-shared-clear-error_test-objects + add_test (NAME H5TEST-shared-clear-error_test-objects COMMAND ${CMAKE_COMMAND} -E remove error_test.txt @@ -755,8 +674,7 @@ if (BUILD_SHARED_LIBS) ) #-- Adding test for links_env - add_test ( - NAME H5TEST-shared-clear-links_env-objects + add_test (NAME H5TEST-shared-clear-links_env-objects COMMAND ${CMAKE_COMMAND} -E remove links_env.txt @@ -785,8 +703,7 @@ if (BUILD_SHARED_LIBS) ) #-- Adding test for libinfo - add_test ( - NAME H5TEST-shared-testlibinfo + add_test (NAME H5TEST-shared-testlibinfo COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$<TARGET_FILE:${HDF5_LIBSH_TARGET}>" -P "${GREP_RUNNER}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared @@ -876,8 +793,7 @@ if (HDF5_TEST_VFD) if (${vfdtest} STREQUAL "flush1" OR ${vfdtest} STREQUAL "flush2") if (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split") if (NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug) - add_test ( - NAME VFD-${vfdname}-${vfdtest} + add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}>" -D "TEST_ARGS:STRING=" @@ -892,8 +808,7 @@ if (HDF5_TEST_VFD) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) - add_test ( - NAME VFD-${vfdname}-${test}-shared + add_test (NAME VFD-${vfdname}-${test}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}-shared>" -D "TEST_ARGS:STRING=" @@ -909,20 +824,17 @@ if (HDF5_TEST_VFD) ) endif (BUILD_SHARED_LIBS) else (NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug) - add_test ( - NAME VFD-${vfdname}-${vfdtest} + add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND ${CMAKE_COMMAND} -E echo "SKIP VFD-${vfdname}-${vfdtest}" ) if (BUILD_SHARED_LIBS) - add_test ( - NAME VFD-${vfdname}-${test}-shared + add_test (NAME VFD-${vfdname}-${test}-shared COMMAND ${CMAKE_COMMAND} -E echo "SKIP VFD-${vfdname}-${vfdtest}-shared" ) endif (BUILD_SHARED_LIBS) endif(NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug) else (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split") - add_test ( - NAME VFD-${vfdname}-${vfdtest} + add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}>" -D "TEST_ARGS:STRING=" @@ -937,8 +849,7 @@ if (HDF5_TEST_VFD) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) - add_test ( - NAME VFD-${vfdname}-${test}-shared + add_test (NAME VFD-${vfdname}-${test}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}-shared>" -D "TEST_ARGS:STRING=" @@ -955,8 +866,7 @@ if (HDF5_TEST_VFD) endif (BUILD_SHARED_LIBS) endif (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split") else (${vfdtest} STREQUAL "flush1" OR ${vfdtest} STREQUAL "flush2") - add_test ( - NAME VFD-${vfdname}-${vfdtest} + add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}>" -D "TEST_ARGS:STRING=" @@ -971,8 +881,7 @@ if (HDF5_TEST_VFD) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) - add_test ( - NAME VFD-${vfdname}-${vfdtest}-shared + add_test (NAME VFD-${vfdname}-${vfdtest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}-shared>" -D "TEST_ARGS:STRING=" @@ -995,8 +904,7 @@ if (HDF5_TEST_VFD) if (WIN32) CHECK_VFD_TEST (${test} ${vfdname} ${resultcode}) else (WIN32) - add_test ( - NAME VFD-${vfdname}-${test} + add_test (NAME VFD-${vfdname}-${test} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${test}>" -D "TEST_ARGS:STRING=" @@ -1011,8 +919,7 @@ if (HDF5_TEST_VFD) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) - add_test ( - NAME VFD-${vfdname}-${test}-shared + add_test (NAME VFD-${vfdname}-${test}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:${test}-shared>" -D "TEST_ARGS:STRING=" @@ -1046,8 +953,7 @@ if (HDF5_TEST_VFD) set_tests_properties (VFD-${vfdname}-istore-shared PROPERTIES TIMEOUT 1200) endif (BUILD_SHARED_LIBS) if (HDF5_TEST_FHEAP_VFD) - add_test ( - NAME VFD-${vfdname}-fheap + add_test (NAME VFD-${vfdname}-fheap COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:fheap>" -D "TEST_ARGS:STRING=" @@ -1063,8 +969,7 @@ if (HDF5_TEST_VFD) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) - add_test ( - NAME VFD-${vfdname}-fheap-shared + add_test (NAME VFD-${vfdname}-fheap-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:fheap-shared>" -D "TEST_ARGS:STRING=" @@ -1121,11 +1026,8 @@ if (HDF5_BUILD_GENERATORS) gen_nullspace gen_udlinks space_overflow - gen_filespace - gen_specmetaread gen_sizes_lheap gen_file_image - gen_plist ) foreach (gen ${H5_GENERATORS}) diff --git a/test/Makefile.am b/test/Makefile.am index 5a676c8..316bf90 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -79,12 +79,13 @@ if HAVE_SHARED_CONDITIONAL # The libh5test library provides common support code for the tests. noinst_LTLIBRARIES=libh5test.la - # The libdynlib1, libdynlib2, and libdynlib3 library for testing plugin module plugin.c. + # The libdynlib1, libdynlib2, libdynlib3, and libdynlib4 library for testing plugin module plugin.c. # Build it as shared library if configure is enabled for shared library. lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la libdynlib1_la_SOURCES=dynlib1.c libdynlib2_la_SOURCES=dynlib2.c libdynlib3_la_SOURCES=dynlib3.c + libdynlib4_la_SOURCES=dynlib4.c install-exec-hook: $(RM) $(DESTDIR)$(libdir)/*dynlib* diff --git a/test/dynlib4.c b/test/dynlib4.c new file mode 100644 index 0000000..8da0270 --- /dev/null +++ b/test/dynlib4.c @@ -0,0 +1,104 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * 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/plugin.c b/test/plugin.c index 74a8f4b..28c7c30 100644 --- a/test/plugin.c +++ b/test/plugin.c @@ -33,6 +33,7 @@ #define H5Z_FILTER_DYNLIB1 257 #define H5Z_FILTER_DYNLIB2 258 #define H5Z_FILTER_DYNLIB3 259 +#define H5Z_FILTER_DYNLIB4 260 const char *FILENAME[] = { "plugin", @@ -44,6 +45,7 @@ const char *FILENAME[] = { #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 @@ -65,6 +67,7 @@ const char *FILENAME[] = { 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]; @@ -306,6 +309,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl) 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]; } } } @@ -344,6 +349,7 @@ test_filters_for_datasets(hid_t file) hid_t dc; /* 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. @@ -402,6 +408,27 @@ test_filters_for_datasets(hid_t file) * for this filter. */ if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) goto error; + /*---------------------------------------------------------- + * STEP 4: Test DYNLIB4 by itself. + *---------------------------------------------------------- + */ + puts("Testing DYNLIB4 filter"); + if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; + dynlib4_values[0] = 9; + if(H5get_libversion(&dynlib4_values[1], &dynlib4_values[2], &dynlib4_values[3]) < 0) goto error; + if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB4, H5Z_FLAG_MANDATORY, (size_t)4, dynlib4_values) < 0) goto error; + + if(test_filter_internal(file,DSET_DYNLIB4_NAME,dc) < 0) goto error; + + /* Clean up objects used for this test */ + if(H5Pclose (dc) < 0) goto 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) goto error; + return 0; error: @@ -519,6 +546,18 @@ test_read_with_filters(hid_t file) if(H5Dclose(dset) < 0) TEST_ERROR + /*---------------------------------------------------------- + * STEP 4: Test DYNLIB4 by itself. + *---------------------------------------------------------- + */ + TESTING("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 + return 0; error: diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in index a6d8c50..d1472fc 100644 --- a/test/test_plugin.sh.in +++ b/test/test_plugin.sh.in @@ -31,12 +31,12 @@ FROM_DIR=`pwd`/.libs case $(uname) in CYGWIN* ) PLUGIN_LIB1="$FROM_DIR/cygdynlib1* $FROM_DIR/cygdynlib3*" - PLUGIN_LIB2="$FROM_DIR/cygdynlib2*" + PLUGIN_LIB2="$FROM_DIR/cygdynlib2* $FROM_DIR/cygdynlib4*" ;; *) PLUGIN_LIB1="$FROM_DIR/libdynlib1.* $FROM_DIR/libdynlib3.*" - PLUGIN_LIB2="$FROM_DIR/libdynlib2.*" - :: + PLUGIN_LIB2="$FROM_DIR/libdynlib2.* $FROM_DIR/libdynlib4.*" + ;; esac PLUGIN_LIBDIR1=testdir1 PLUGIN_LIBDIR2=testdir2 @@ -78,6 +78,12 @@ if [ $? != 0 ]; then exit $EXIT_FAILURE fi +$CP $PLUGIN_LIB4 $PLUGIN_LIBDIR2 +if [ $? != 0 ]; then + echo "Failed to copy plugin library ($PLUGIN_LIB4) for test." + exit $EXIT_FAILURE +fi + # setup plugin path ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR1}:${PLUGIN_LIBDIR2}" |