summaryrefslogtreecommitdiffstats
path: root/tools/test
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-01-18 18:51:56 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-01-18 18:51:56 (GMT)
commit95242bbd5ce97f48e94bab11e8f736a60c0f509b (patch)
treeb285919a49150c86a2e04838176d481df32d8461 /tools/test
parent509b6c24a7793b8fddd15a6abb6f9573f7adae3e (diff)
parente4b314c47c1c50b326c5f72254a662c284a26b97 (diff)
downloadhdf5-95242bbd5ce97f48e94bab11e8f736a60c0f509b.zip
hdf5-95242bbd5ce97f48e94bab11e8f736a60c0f509b.tar.gz
hdf5-95242bbd5ce97f48e94bab11e8f736a60c0f509b.tar.bz2
Merge pull request #253 in HDFFV/hdf5 from ~BYRN/hdf5_adb:develop to develop
* commit 'e4b314c47c1c50b326c5f72254a662c284a26b97': Fix indentation Fix script varnames Chnage test dir to avoid parallel test collisions Add autotools version of plugin tests for UD filters HDFFV-9994 add h5ls reference file to copy HDFFV-9994 - correct reference file HDFFV-9994 add UD tests for tools Add goto error for dataset read failure. Fixed comments
Diffstat (limited to 'tools/test')
-rw-r--r--tools/test/h5diff/CMakeLists.txt28
-rw-r--r--tools/test/h5diff/CMakeTests.cmake54
-rw-r--r--tools/test/h5diff/Makefile.am16
-rw-r--r--tools/test/h5diff/dynlib_diff.c94
-rw-r--r--tools/test/h5diff/h5diff_plugin.sh.in315
-rw-r--r--tools/test/h5diff/testfiles/h5diff_ud.txt11
-rw-r--r--tools/test/h5diff/testfiles/h5diff_udfail.txt12
-rw-r--r--tools/test/h5diff/testfiles/tudfilter.h5bin0 -> 4816 bytes
-rw-r--r--tools/test/h5diff/testfiles/tudfilter2.h5bin0 -> 4816 bytes
-rw-r--r--tools/test/h5dump/CMakeLists.txt28
-rw-r--r--tools/test/h5dump/CMakeTests.cmake36
-rw-r--r--tools/test/h5dump/Makefile.am16
-rw-r--r--tools/test/h5dump/dynlib_dump.c94
-rw-r--r--tools/test/h5dump/h5dump_plugin.sh.in241
-rw-r--r--tools/test/h5dump/h5dumpgentest.c132
-rw-r--r--tools/test/h5ls/CMakeLists.txt28
-rw-r--r--tools/test/h5ls/CMakeTests.cmake34
-rw-r--r--tools/test/h5ls/Makefile.am16
-rw-r--r--tools/test/h5ls/dynlib_ls.c94
-rw-r--r--tools/test/h5ls/h5ls_plugin.sh.in253
-rw-r--r--tools/test/h5repack/CMakeTests.cmake2
21 files changed, 1501 insertions, 3 deletions
diff --git a/tools/test/h5diff/CMakeLists.txt b/tools/test/h5diff/CMakeLists.txt
index 1d13e14..f6951a3 100644
--- a/tools/test/h5diff/CMakeLists.txt
+++ b/tools/test/h5diff/CMakeLists.txt
@@ -19,4 +19,32 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib)
#add_test (NAME h5diffgentest COMMAND $<TARGET_FILE:h5diffgentest>)
endif ()
+ #-----------------------------------------------------------------------------
+ # If plugin library tests can be tested
+ #-----------------------------------------------------------------------------
+ set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibdiff")
+ set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}")
+ set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME})
+ add_definitions (${HDF_EXTRA_C_FLAGS})
+ INCLUDE_DIRECTORIES (${HDF5_SRC_DIR})
+
+ add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_diff.c)
+ TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ")
+ target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+ H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
+
+ # make plugins dir
+ file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
+ #-----------------------------------------------------------------------------
+ # Copy plugin library to a plugins folder
+ #-----------------------------------------------------------------------------
+ add_custom_command (
+ TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET}
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different
+ "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>"
+ "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>"
+ )
+
include (CMakeTests.cmake)
diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake
index 8a2781e..d098746 100644
--- a/tools/test/h5diff/CMakeTests.cmake
+++ b/tools/test/h5diff/CMakeTests.cmake
@@ -55,6 +55,8 @@
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmptest2.he5
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmpSingleSiteBethe.reference.h5
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmpSingleSiteBethe.output.h5
+ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter.h5
+ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter2.h5
# tools/testfiles/vds
${HDF5_TOOLS_DIR}/testfiles/vds/1_a.h5
${HDF5_TOOLS_DIR}/testfiles/vds/1_b.h5
@@ -259,6 +261,8 @@
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_90.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_tmp1.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_tmp2.txt
+ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_ud.txt
+ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v1.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v2.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v3.txt
@@ -376,6 +380,51 @@
endif ()
ENDMACRO ()
+ MACRO (ADD_H5_UD_TEST testname resultcode resultfile)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ # Remove any output file left over from previous test run
+ add_test (
+ NAME H5DIFF_UD-${testname}-clearall-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ testfiles/${resultfile}.out
+ testfiles/${resultfile}.out.err
+ )
+ if (${resultcode} STREQUAL "2")
+ add_test (
+ NAME H5DIFF_UD-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.txt"
+ -D "TEST_APPEND=EXIT CODE:"
+ -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
+ -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ else ()
+ add_test (
+ NAME H5DIFF_UD-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.txt"
+ -D "TEST_APPEND=EXIT CODE:"
+ -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
+ -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ endif ()
+ set_tests_properties (H5DIFF_UD-${testname} PROPERTIES DEPENDS H5DIFF_UD-${testname}-clearall-objects)
+ endif ()
+ ENDMACRO ()
+
##############################################################################
##############################################################################
### T H E T E S T S ###
@@ -1393,3 +1442,8 @@ ADD_H5_TEST (h5diff_v1 0 -v ${FILEV1} ${FILEV2})
ADD_H5_TEST (h5diff_v2 0 -r ${FILEV1} ${FILEV2})
ADD_H5_TEST (h5diff_v3 0 -c ${FILEV1} ${FILEV2})
+##############################################################################
+### P L U G I N T E S T S
+##############################################################################
+ADD_H5_UD_TEST (h5diff_plugin_test 0 h5diff_ud -v tudfilter.h5 tudfilter2.h5)
+ADD_H5_UD_TEST (h5diff_plugin_fail 2 h5diff_udfail -v tudfilter.h5 tudfilter2.h5)
diff --git a/tools/test/h5diff/Makefile.am b/tools/test/h5diff/Makefile.am
index c366199..1d700ea 100644
--- a/tools/test/h5diff/Makefile.am
+++ b/tools/test/h5diff/Makefile.am
@@ -38,6 +38,11 @@ check_PROGRAMS=$(TEST_PROG)
check_SCRIPTS=$(TEST_SCRIPT) $(TEST_SCRIPT_PARA)
# The parallel test script testph5diff.sh actually depends on testh5diff.sh.
SCRIPT_DEPEND=../../src/h5diff/h5diff$(EXEEXT) $(H5PDIFF) ../../src/h5diff/testh5diff.sh
+if HAVE_SHARED_CONDITIONAL
+if USE_PLUGINS_CONDITIONAL
+ TEST_SCRIPT += h5diff_plugin.sh
+endif
+endif
# Source files for the program
h5diffgentest_SOURCES=h5diffgentest.c
@@ -45,9 +50,20 @@ h5diffgentest_SOURCES=h5diffgentest.c
# Programs depend on the main HDF5 library and tools library
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+if HAVE_SHARED_CONDITIONAL
+ # Build it as shared library if configure is enabled for shared library.
+ lib_LTLIBRARIES=libdynlibdiff.la
+ libdynlibdiff_la_SOURCES=dynlib_diff.c
+
+install-exec-hook:
+ $(RM) $(DESTDIR)$(libdir)/*dynlib*
+endif
+
# Temporary files. *.h5 are generated by h5diff. They should
# be copied to the testfiles/ directory if update is required
CHECK_CLEANFILES+=*.h5 expect_sorted actual_sorted
+DISTCLEANFILES=h5diff_plugin.sh
+
include $(top_srcdir)/config/conclude.am
diff --git a/tools/test/h5diff/dynlib_diff.c b/tools/test/h5diff/dynlib_diff.c
new file mode 100644
index 0000000..0d8be2b
--- /dev/null
+++ b/tools/test/h5diff/dynlib_diff.c
@@ -0,0 +1,94 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic document set and is *
+ * linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access *
+ * to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*
+ * Programmer: Raymond Lu
+ * 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/tools/test/h5diff/h5diff_plugin.sh.in b/tools/test/h5diff/h5diff_plugin.sh.in
new file mode 100644
index 0000000..ffd2ea1
--- /dev/null
+++ b/tools/test/h5diff/h5diff_plugin.sh.in
@@ -0,0 +1,315 @@
+#! /bin/sh
+#
+# 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.
+#
+srcdir=@srcdir@
+TOP_BUILDDIR=@top_builddir@
+
+# Determine backward compatibility options enabled
+DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
+
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+H5DIFF=../../src/h5diff/h5diff # The tool name
+H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary
+
+nerrors=0
+verbose=yes
+h5haveexitcode=yes # default is yes
+
+TEST_NAME=ud_plugin
+FROM_DIR=`pwd`/.libs
+PLUGIN_LIB="$FROM_DIR/libdynlibdiff.*"
+PLUGIN_LIBDIR=testdir3
+RM='rm -rf'
+
+RM='rm -rf'
+CMP='cmp -s'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+# source dirs
+SRC_TOOLS="$srcdir/../.."
+
+# testfiles source dirs for tools
+SRC_H5DIFF_TESTFILES="$SRC_TOOLS/test/h5diff/testfiles"
+
+TESTDIR=./testplug
+test -d $TESTDIR || mkdir $TESTDIR
+
+######################################################################
+# test files
+# --------------------------------------------------------------------
+# All the test files copy from source directory to test directory
+# NOTE: Keep this framework to add/remove test files.
+# Any test files from other tools can be used in this framework.
+# This list are also used for checking exist.
+# Comment '#' without space can be used.
+# --------------------------------------------------------------------
+LIST_HDF5_TEST_FILES="
+$SRC_H5DIFF_TESTFILES/tudfilter.h5
+$SRC_H5DIFF_TESTFILES/tudfilter2.h5
+$SRC_H5DIFF_TESTFILES/h5diff_ud.txt
+$SRC_H5DIFF_TESTFILES/h5diff_udfail.txt
+"
+
+# Main Body
+# Create test directories if not exists yet.
+test -d $PLUGIN_LIBDIR || mkdir -p $PLUGIN_LIBDIR
+if [ $? != 0 ]; then
+ echo "Failed to create test directory($PLUGIN_LIBDIR)"
+ exit $EXIT_FAILURE
+fi
+
+# copy plugin library for test
+$CP $PLUGIN_LIB $PLUGIN_LIBDIR
+if [ $? != 0 ]; then
+ echo "Failed to copy plugin library ($PLUGIN_LIB) for test."
+ exit $EXIT_FAILURE
+fi
+
+# setup plugin path
+ENVCMD="env HDF5_PLUGIN_PATH=../${PLUGIN_LIBDIR}"
+
+#
+# copy test files and expected output files from source dirs to test dir
+#
+COPY_TESTFILES="$LIST_HDF5_TEST_FILES"
+
+COPY_TESTFILES_TO_TESTDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_TESTFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $TESTDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_TESTFILES_AND_TESTDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=$SRC_H5DIFF_TESTFILES
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $TESTDIR
+ fi
+}
+
+# Parse option
+# -p run ph5diff tests
+# -h print help page
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -p) # reset the tool name and bin to run ph5diff tests
+ TESTNAME=ph5diff
+ H5DIFF=../../src/h5diff/ph5diff # The tool name
+ H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary
+ pmode=yes
+ shift
+ ;;
+ -h) # print help page
+ echo "$0 [-p] [-h]"
+ echo " -p run ph5diff tests"
+ echo " -h print help page"
+ shift
+ exit 0
+ ;;
+ *) # unknown option
+ echo "$0: Unknown option ($1)"
+ exit 1
+ ;;
+ esac
+done
+
+# RUNSERIAL is used. Check if it can return exit code from executalbe correctly.
+if [ -n "$RUNSERIAL_NOEXITCODE" ]; then
+ echo "***Warning*** Serial Exit Code is not passed back to shell corretly."
+ echo "***Warning*** Exit code checking is skipped."
+ h5haveexitcode=no
+fi
+
+
+# Print a $* message left justified in a field of 70 characters
+#
+MESSAGE() {
+ SPACES=" "
+ echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+#
+TESTING() {
+ SPACES=" "
+ echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Verifying".
+#
+VERIFY() {
+ MESSAGE "Verifying $*"
+}
+
+# Source in the output filter function definitions.
+. $srcdir/../../../bin/output_filter.sh
+
+# Run a test and print PASS or *FAIL*. If a test fails then increment
+# the `nerrors' global variable and (if $verbose is set) display the
+# difference between the actual output and the expected output. The
+# expected output is given as the first argument to this function and
+# the actual output file is calculated by replacing the `.ddl' with
+# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a
+# non-zero value.
+#
+# Need eval before the RUNCMD command because some machines like
+# AIX, has RUNPARALLEL in the style as
+# MP_PROCS=3 MP_TASKS_PER_NODE=3 poe ./a.out
+# that throws the shell script off.
+#
+TOOLTEST() {
+ expect="$TESTDIR/$1"
+ actual="$TESTDIR/`basename $1 .txt`.out"
+ actual_err="$TESTDIR/`basename $1 .txt`.err"
+ actual_sav=${actual}-sav
+ actual_err_sav=${actual_err}-sav
+ shift
+ if test -n "$pmode"; then
+ RUNCMD=$RUNPARALLEL
+ else
+ RUNCMD=$RUNSERIAL
+ fi
+
+ # Run test.
+ TESTING $H5DIFF $@
+ (
+ #echo "#############################"
+ #echo "Expected output for '$H5DIFF $@'"
+ #echo "#############################"
+ cd $TESTDIR
+ eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@"
+ ) >$actual 2>$actual_err
+ EXIT_CODE=$?
+ # save actual and actual_err in case they are needed later.
+ cp $actual $actual_sav
+ STDOUT_FILTER $actual
+ cp $actual_err $actual_err_sav
+ STDERR_FILTER $actual_err
+ cat $actual_err >> $actual
+ # don't add exit code check in pmode, as it causes failure. (exit code
+ # is from mpirun not tool)
+ # if any problem occurs relate to an exit code, it will be caught in
+ # serial mode, so the test is fullfilled.
+ if test $h5haveexitcode = 'yes' -a -z "$pmode"; then
+ echo "EXIT CODE: $EXIT_CODE" >> $actual
+ fi
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ elif test $h5haveexitcode = 'yes' -a -z "$pmode"; then
+ echo "*FAILED*"
+ echo " Expected result ($expect) differs from actual result ($actual)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ else
+ # parallel mode output are often of different ordering from serial
+ # output. If the sorted expected and actual files compare the same,
+ # it is safe to assume the actual output match the expected file.
+ expect_sorted=expect_sorted
+ actual_sorted=actual_sorted
+ sort $expect -o $expect_sorted
+ sort $actual -o $actual_sorted
+ # remove "EXIT CODE:" line from expect file. test for exit code
+ # is done by serial mode.
+ grep -v "EXIT CODE:" $expect_sorted > $expect_sorted.noexit
+ mv $expect_sorted.noexit $expect_sorted
+ if $CMP $expect_sorted $actual_sorted; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ nerrors="`expr $nerrors + 1`"
+ if test yes = "$verbose"; then
+ echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)"
+ $DIFF $expect_sorted $actual_sorted |sed 's/^/ /'
+ echo "====The actual output ($actual_sav)"
+ sed 's/^/ /' < $actual_sav
+ echo "====The actual stderr ($actual_err_sav)"
+ sed 's/^/ /' < $actual_err_sav
+ echo "====End of actual stderr ($actual_err_sav)"
+ echo ""
+ fi
+ fi
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err $actual_sav $actual_err_sav
+ rm -f $actual_sorted $expect_sorted
+ fi
+}
+
+##############################################################################
+### T H E T E S T S
+##############################################################################
+# prepare for test
+COPY_TESTFILES_TO_TESTDIR
+
+# Run the test
+TOOLTEST h5diff_ud.txt -v tudfilter.h5 tudfilter2.h5
+
+# print results
+if test $nerrors -ne 0 ; then
+ echo "$nerrors errors encountered"
+ exit_code=$EXIT_FAILURE
+else
+ echo "All Plugin API tests passed."
+ exit_code=$EXIT_SUCCESS
+fi
+
+# Clean up temporary files/directories
+CLEAN_TESTFILES_AND_TESTDIR
+
+# Clean up temporary files/directories and leave
+$RM $PLUGIN_LIBDIR
+
+exit $exit_code
diff --git a/tools/test/h5diff/testfiles/h5diff_ud.txt b/tools/test/h5diff/testfiles/h5diff_ud.txt
new file mode 100644
index 0000000..7c9bb5e
--- /dev/null
+++ b/tools/test/h5diff/testfiles/h5diff_ud.txt
@@ -0,0 +1,11 @@
+
+file1 file2
+---------------------------------------
+ x x /
+ x x /dynlib2
+
+group : </> and </>
+0 differences found
+dataset: </dynlib2> and </dynlib2>
+0 differences found
+EXIT CODE: 0
diff --git a/tools/test/h5diff/testfiles/h5diff_udfail.txt b/tools/test/h5diff/testfiles/h5diff_udfail.txt
new file mode 100644
index 0000000..7eb1155
--- /dev/null
+++ b/tools/test/h5diff/testfiles/h5diff_udfail.txt
@@ -0,0 +1,12 @@
+
+file1 file2
+---------------------------------------
+ x x /
+ x x /dynlib2
+
+group : </> and </>
+0 differences found
+dataset: </dynlib2> and </dynlib2>
+0 differences found
+warning: dataset </dynlib2> cannot be read, user defined filter is not available
+EXIT CODE: 2
diff --git a/tools/test/h5diff/testfiles/tudfilter.h5 b/tools/test/h5diff/testfiles/tudfilter.h5
new file mode 100644
index 0000000..eaf6a43
--- /dev/null
+++ b/tools/test/h5diff/testfiles/tudfilter.h5
Binary files differ
diff --git a/tools/test/h5diff/testfiles/tudfilter2.h5 b/tools/test/h5diff/testfiles/tudfilter2.h5
new file mode 100644
index 0000000..eaf6a43
--- /dev/null
+++ b/tools/test/h5diff/testfiles/tudfilter2.h5
Binary files differ
diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt
index cc399d1..89c7534 100644
--- a/tools/test/h5dump/CMakeLists.txt
+++ b/tools/test/h5dump/CMakeLists.txt
@@ -6,6 +6,34 @@ PROJECT (HDF5_TOOLS_TEST_H5DUMP)
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib)
+ #-----------------------------------------------------------------------------
+ # If plugin library tests can be tested
+ #-----------------------------------------------------------------------------
+ set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibdump")
+ set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}")
+ set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME})
+ add_definitions (${HDF_EXTRA_C_FLAGS})
+ INCLUDE_DIRECTORIES (${HDF5_SRC_DIR})
+
+ add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_dump.c)
+ TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ")
+ target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+ H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
+
+ # make plugins dir
+ file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
+ #-----------------------------------------------------------------------------
+ # Copy plugin library to a plugins folder
+ #-----------------------------------------------------------------------------
+ add_custom_command (
+ TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET}
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different
+ "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>"
+ "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>"
+ )
+
# --------------------------------------------------------------------
# Add the h5dump test executable
# --------------------------------------------------------------------
diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake
index ddfbfbc..1a335b2 100644
--- a/tools/test/h5dump/CMakeTests.cmake
+++ b/tools/test/h5dump/CMakeTests.cmake
@@ -166,6 +166,7 @@
${HDF5_TOOLS_DIR}/testfiles/tstring2.ddl
${HDF5_TOOLS_DIR}/testfiles/tstringe.ddl
${HDF5_TOOLS_DIR}/testfiles/tszip.ddl
+ ${HDF5_TOOLS_DIR}/testfiles/tudfilter.ddl
${HDF5_TOOLS_DIR}/testfiles/tudlink-1.ddl
${HDF5_TOOLS_DIR}/testfiles/tudlink-2.ddl
${HDF5_TOOLS_DIR}/testfiles/tuserfilter.ddl
@@ -291,6 +292,7 @@
${HDF5_TOOLS_DIR}/testfiles/tstr.h5
${HDF5_TOOLS_DIR}/testfiles/tstr2.h5
${HDF5_TOOLS_DIR}/testfiles/tstr3.h5
+ ${HDF5_TOOLS_DIR}/testfiles/tudfilter.h5
${HDF5_TOOLS_DIR}/testfiles/tudlink.h5
${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.h5
${HDF5_TOOLS_DIR}/testfiles/tvldtypes2.h5
@@ -680,9 +682,36 @@
endif ()
ENDMACRO ()
+ MACRO (ADD_H5_UD_TEST testname resultcode resultfile)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ # Remove any output file left over from previous test run
+ add_test (
+ NAME H5DUMP_UD-${testname}-clearall-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ testfiles/std/${resultfile}.out
+ testfiles/std/${resultfile}.out.err
+ )
+ add_test (
+ NAME H5DUMP_UD-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.ddl"
+ -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
+ -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5DUMP_UD-${testname} PROPERTIES DEPENDS H5DUMP_UD-${testname}-clearall-objects)
+ endif ()
+ ENDMACRO ()
+
##############################################################################
##############################################################################
-### T H E T E S T S HDF5_ENABLE_USING_MEMCHECKER ###
+### T H E T E S T S ###
##############################################################################
##############################################################################
@@ -1421,3 +1450,8 @@
# test for non-existing file
ADD_H5_TEST (non_existing 1 --enable-error-stack tgroup.h5 non_existing.h5)
+
+##############################################################################
+### P L U G I N T E S T S
+##############################################################################
+ADD_H5_UD_TEST (h5dump_plugin_test 0 tudfilter --enable-error-stack tudfilter.h5)
diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am
index aed34ec..a3d1df7 100644
--- a/tools/test/h5dump/Makefile.am
+++ b/tools/test/h5dump/Makefile.am
@@ -30,13 +30,27 @@ TEST_SCRIPT=testh5dump.sh testh5dumppbits.sh testh5dumpvds.sh testh5dumpxml.sh
check_PROGRAMS=$(TEST_PROG) binread
check_SCRIPTS=$(TEST_SCRIPT)
SCRIPT_DEPEND=../../src/h5dump/h5dump$(EXEEXT)
+if HAVE_SHARED_CONDITIONAL
+if USE_PLUGINS_CONDITIONAL
+ TEST_SCRIPT += h5dump_plugin.sh
+endif
+endif
# All the programs depend on the hdf5 and h5tools libraries
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+if HAVE_SHARED_CONDITIONAL
+ # Build it as shared library if configure is enabled for shared library.
+ lib_LTLIBRARIES=libdynlibdump.la
+ libdynlibdump_la_SOURCES=dynlib_dump.c
+
+install-exec-hook:
+ $(RM) $(DESTDIR)$(libdir)/*dynlib*
+endif
+
# Temporary files. *.h5 are generated by h5dumpgentest. They should
# copied to the testfiles/ directory if update is required.
CHECK_CLEANFILES+=*.h5 *.bin
-DISTCLEANFILES=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh
+DISTCLEANFILES=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh h5dump_plugin.sh
include $(top_srcdir)/config/conclude.am
diff --git a/tools/test/h5dump/dynlib_dump.c b/tools/test/h5dump/dynlib_dump.c
new file mode 100644
index 0000000..0d8be2b
--- /dev/null
+++ b/tools/test/h5dump/dynlib_dump.c
@@ -0,0 +1,94 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic document set and is *
+ * linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access *
+ * to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*
+ * Programmer: Raymond Lu
+ * 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/tools/test/h5dump/h5dump_plugin.sh.in b/tools/test/h5dump/h5dump_plugin.sh.in
new file mode 100644
index 0000000..d19981e
--- /dev/null
+++ b/tools/test/h5dump/h5dump_plugin.sh.in
@@ -0,0 +1,241 @@
+#! /bin/sh
+#
+# 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.
+#
+srcdir=@srcdir@
+TOP_BUILDDIR=@top_builddir@
+
+# Determine backward compatibility options enabled
+DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
+
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+H5DUMP=../../src/h5dump/h5dump # The h5dump tool name
+H5DUMP_BIN=`pwd`/$H5DUMP # The path of the h5dump tool binary
+
+nerrors=0
+verbose=yes
+h5haveexitcode=yes # default is yes
+
+TEST_NAME=ud_plugin
+FROM_DIR=`pwd`/.libs
+PLUGIN_LIB="$FROM_DIR/libdynlibdump.*"
+PLUGIN_LIBDIR=testdir3
+RM='rm -rf'
+
+RM='rm -rf'
+GREP='grep'
+CMP='cmp'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+# source dirs
+SRC_TOOLS="$srcdir/../.."
+
+# testfiles source dirs for tools
+SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles"
+SRC_H5DUMP_TESTFILES="$SRC_TOOLS_TESTFILES"
+
+TESTDIR=./testplug
+test -d $TESTDIR || mkdir $TESTDIR
+
+######################################################################
+# test files
+# --------------------------------------------------------------------
+# All the test files copy from source directory to test directory
+# NOTE: Keep this framework to add/remove test files.
+# Any test files from other tools can be used in this framework.
+# This list are also used for checking exist.
+# Comment '#' without space can be used.
+# --------------------------------------------------------------------
+LIST_HDF5_TEST_FILES="
+$SRC_H5DUMP_TESTFILES/tudfilter.h5
+$SRC_H5DUMP_TESTFILES/tudfilter.ddl
+"
+
+# RUNSERIAL is used. Check if it can return exit code from executable correctly.
+if [ -n "$RUNSERIAL_NOEXITCODE" ]; then
+ echo "***Warning*** Serial Exit Code is not passed back to shell correctly."
+ echo "***Warning*** Exit code checking is skipped."
+ h5haveexitcode=no
+fi
+
+# Main Body
+# Create test directories if not exists yet.
+test -d $PLUGIN_LIBDIR || mkdir -p $PLUGIN_LIBDIR
+if [ $? != 0 ]; then
+ echo "Failed to create test directory($PLUGIN_LIBDIR)"
+ exit $EXIT_FAILURE
+fi
+
+# copy plugin library for test
+$CP $PLUGIN_LIB $PLUGIN_LIBDIR
+if [ $? != 0 ]; then
+ echo "Failed to copy plugin library ($PLUGIN_LIB) for test."
+ exit $EXIT_FAILURE
+fi
+
+# setup plugin path
+ENVCMD="env HDF5_PLUGIN_PATH=../${PLUGIN_LIBDIR}"
+
+#
+# copy test files and expected output files from source dirs to test dir
+#
+COPY_TESTFILES="$LIST_HDF5_TEST_FILES"
+
+COPY_TESTFILES_TO_TESTDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_TESTFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $TESTDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_TESTFILES_AND_TESTDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=$SRC_H5DUMP_TESTFILES
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $TESTDIR
+ fi
+}
+
+# Print a $* message left justified in a field of 70 characters
+#
+MESSAGE() {
+ SPACES=" "
+ echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+#
+TESTING() {
+ SPACES=" "
+ echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Verifying".
+#
+VERIFY() {
+ MESSAGE "Verifying $*"
+}
+
+# Source in the output filter function definitions.
+. $srcdir/../../../bin/output_filter.sh
+
+# Run a test and print PASS or *FAIL*. If a test fails then increment
+# the `nerrors' global variable and (if $verbose is set) display the
+# difference between the actual output and the expected output. The
+# expected output is given as the first argument to this function and
+# the actual output file is calculated by replacing the `.ddl' with
+# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a
+# non-zero value.
+# If $1 == ignorecase then do caseless CMP and DIFF.
+# ADD_H5_TEST
+TOOLTEST() {
+ expect="$TESTDIR/$1"
+ actual="$TESTDIR/`basename $1 .ddl`.out"
+ actual_err="$TESTDIR/`basename $1 .ddl`.err"
+ actual_sav=${actual}-sav
+ actual_err_sav=${actual_err}-sav
+ shift
+
+ # Run test.
+ TESTING $H5DUMP $@
+ (
+ cd $TESTDIR
+ $ENVCMD $RUNSERIAL $H5DUMP_BIN "$@"
+ ) >$actual 2>$actual_err
+
+ # save actual and actual_err in case they are needed later.
+ cp $actual $actual_sav
+ STDOUT_FILTER $actual
+ cp $actual_err $actual_err_sav
+ STDERR_FILTER $actual_err
+ cat $actual_err >> $actual
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ elif $CMP $expect $actual > /dev/null 2>&1 ; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.ddl) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext
+ fi
+
+}
+
+##############################################################################
+### T H E T E S T S
+##############################################################################
+# prepare for test
+COPY_TESTFILES_TO_TESTDIR
+
+# Run the test
+TOOLTEST tudfilter.ddl --enable-error-stack tudfilter.h5
+
+# print results
+if test $nerrors -ne 0 ; then
+ echo "$nerrors errors encountered"
+ exit_code=$EXIT_FAILURE
+else
+ echo "All Plugin API tests passed."
+ exit_code=$EXIT_SUCCESS
+fi
+
+# Clean up temporary files/directories
+CLEAN_TESTFILES_AND_TESTDIR
+
+# Clean up temporary files/directories and leave
+$RM $PLUGIN_LIBDIR
+
+exit $exit_code
diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c
index 335eafa..7df9cbb 100644
--- a/tools/test/h5dump/h5dumpgentest.c
+++ b/tools/test/h5dump/h5dumpgentest.c
@@ -114,6 +114,7 @@
#define FILE81 "tints4dims.h5"
#define FILE82 "tcompound_complex2.h5"
#define FILE83 "tvlenstr_array.h5"
+#define FILE84 "tudfilter.h5"
/*-------------------------------------------------------------------------
* prototypes
@@ -153,6 +154,23 @@ const H5Z_class2_t H5Z_MYFILTER[1] = {{
myfilter, /* The actual filter function */
}};
+#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 */
+}};
+
/* A UD link traversal function. Shouldn't actually be called. */
static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group,
@@ -10286,6 +10304,118 @@ static void gent_vlenstr_array(void)
H5Fclose(file);
}
+/*-------------------------------------------------------------------------
+ * Function: gent_udfilter
+ *
+ * Purpose: Generate a file to be used in testing user defined filter plugin3.
+ *-------------------------------------------------------------------------
+ */
+static void gent_udfilter(void)
+{
+ hid_t fid; /* file id */
+ hid_t dcpl; /* dataset creation property list */
+ hid_t sid; /* dataspace ID */
+ hid_t tid; /* datatype ID */
+
+ hsize_t dims1[RANK] = {DIM1,DIM2};
+ hsize_t chunk_dims[RANK] = {CDIM1,CDIM2};
+ int buf1[DIM1][DIM2];
+ int i, j, n, ret;
+
+ for(i=n=0; i<DIM1; i++){
+ for(j=0; j<DIM2; j++){
+ buf1[i][j]=n++;
+ }
+ }
+
+ /* create a file */
+ fid = H5Fcreate(FILE84, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ HDassert(fid>=0);
+
+ /* create a space */
+ sid = H5Screate_simple(SPACE2_RANK, dims1, NULL);
+
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ HDassert(dcpl>=0);
+
+ ret = H5Pset_layout(dcpl, H5D_CHUNKED);
+ HDassert(ret >= 0);
+
+ ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims);
+ HDassert(ret >= 0);
+
+ ret = H5Zregister (H5Z_DYNLIB2);
+ HDassert(ret >= 0);
+
+ ret = H5Pset_filter (dcpl, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL);
+ HDassert(ret >= 0);
+
+ ret=make_dset(fid, "dynlib2", sid, H5T_NATIVE_INT, dcpl, buf1);
+ HDassert(ret >= 0);
+
+ /* remove the filters from the dcpl */
+ ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL);
+ HDassert(ret >= 0);
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ ret = H5Sclose(sid);
+ HDassert(ret >= 0);
+
+ ret = H5Pclose(dcpl);
+ HDassert(ret >= 0);
+
+ ret = H5Fclose(fid);
+ HDassert(ret >= 0);
+}
+
+/*-------------------------------------------------------------------------
+ * 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. tools tests will load
+ * and use this filter as a plugin library.
+ *
+ * Return: Success: Data chunk size
+ *
+ * Failure: 0
+ *-------------------------------------------------------------------------
+ */
+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() */
/*-------------------------------------------------------------------------
* Function: main
@@ -10383,6 +10513,8 @@ int main(void)
gent_intsfourdims();
+ gent_udfilter();
+
return 0;
}
diff --git a/tools/test/h5ls/CMakeLists.txt b/tools/test/h5ls/CMakeLists.txt
index 3280f7f..c21ca92 100644
--- a/tools/test/h5ls/CMakeLists.txt
+++ b/tools/test/h5ls/CMakeLists.txt
@@ -6,6 +6,34 @@ PROJECT (HDF5_TOOLS_TEST_H5LS)
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib)
+ #-----------------------------------------------------------------------------
+ # If plugin library tests can be tested
+ #-----------------------------------------------------------------------------
+ set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibls")
+ set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}")
+ set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME})
+ add_definitions (${HDF_EXTRA_C_FLAGS})
+ INCLUDE_DIRECTORIES (${HDF5_SRC_DIR})
+
+ add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_ls.c)
+ TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ")
+ target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+ H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
+
+ # make plugins dir
+ file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
+ #-----------------------------------------------------------------------------
+ # Copy plugin library to a plugins folder
+ #-----------------------------------------------------------------------------
+ add_custom_command (
+ TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET}
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different
+ "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>"
+ "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>"
+ )
+
include (CMakeTests.cmake)
include (CMakeTestsVDS.cmake)
diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake
index 936f025..fc15986 100644
--- a/tools/test/h5ls/CMakeTests.cmake
+++ b/tools/test/h5ls/CMakeTests.cmake
@@ -29,6 +29,7 @@
${HDF5_TOOLS_DIR}/testfiles/tslink.h5
${HDF5_TOOLS_DIR}/testfiles/tsoftlinks.h5
${HDF5_TOOLS_DIR}/testfiles/tstr.h5
+ ${HDF5_TOOLS_DIR}/testfiles/tudfilter.h5
${HDF5_TOOLS_DIR}/testfiles/tudlink.h5
${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.h5
${HDF5_TOOLS_DIR}/testfiles/tdset_idx.h5
@@ -87,6 +88,7 @@
${HDF5_TOOLS_DIR}/testfiles/tsaf.ls
${HDF5_TOOLS_DIR}/testfiles/tslink-1.ls
${HDF5_TOOLS_DIR}/testfiles/tstr-1.ls
+ ${HDF5_TOOLS_DIR}/testfiles/tudfilter.ls
${HDF5_TOOLS_DIR}/testfiles/tudlink-1.ls
${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.ls
${HDF5_TOOLS_DIR}/testfiles/tvldtypes2le.ls
@@ -135,6 +137,33 @@
endif ()
ENDMACRO ()
+ MACRO (ADD_H5_UD_TEST testname resultcode resultfile)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ # Remove any output file left over from previous test run
+ add_test (
+ NAME H5LS_UD-${testname}-clearall-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ testfiles/${resultfile}.out
+ testfiles/${resultfile}.out.err
+ )
+ add_test (
+ NAME H5LS_UD-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5ls>"
+ -D "TEST_ARGS=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.ls"
+ -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
+ -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5LS_UD-${testname} PROPERTIES DEPENDS H5LS_UD-${testname}-clearall-objects)
+ endif ()
+ ENDMACRO ()
+
##############################################################################
##############################################################################
### T H E T E S T S ###
@@ -410,3 +439,8 @@
ADD_H5_TEST (tdset_idx 0 -w80 -d tdset_idx.h5)
endif (USE_FILTER_DEFLATE)
+
+##############################################################################
+### P L U G I N T E S T S
+##############################################################################
+ADD_H5_UD_TEST (h5ls_plugin_test 0 tudfilter -w80 -v -d tudfilter.h5)
diff --git a/tools/test/h5ls/Makefile.am b/tools/test/h5ls/Makefile.am
index 6f3d3dd..170aa63 100644
--- a/tools/test/h5ls/Makefile.am
+++ b/tools/test/h5ls/Makefile.am
@@ -27,8 +27,24 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
TEST_SCRIPT=testh5ls.sh testh5lsvds.sh
check_SCRIPTS=$(TEST_SCRIPT)
SCRIPT_DEPEND=../../src/h5ls/h5ls$(EXEEXT)
+if HAVE_SHARED_CONDITIONAL
+if USE_PLUGINS_CONDITIONAL
+ TEST_SCRIPT += h5ls_plugin.sh
+endif
+endif
# All programs depend on the hdf5 and h5tools libraries
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+if HAVE_SHARED_CONDITIONAL
+ # Build it as shared library if configure is enabled for shared library.
+ lib_LTLIBRARIES=libdynlibls.la
+ libdynlibls_la_SOURCES=dynlib_ls.c
+
+install-exec-hook:
+ $(RM) $(DESTDIR)$(libdir)/*dynlib*
+endif
+
+DISTCLEANFILES=h5ls_plugin.sh
+
include $(top_srcdir)/config/conclude.am
diff --git a/tools/test/h5ls/dynlib_ls.c b/tools/test/h5ls/dynlib_ls.c
new file mode 100644
index 0000000..0d8be2b
--- /dev/null
+++ b/tools/test/h5ls/dynlib_ls.c
@@ -0,0 +1,94 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic document set and is *
+ * linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access *
+ * to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*
+ * Programmer: Raymond Lu
+ * 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/tools/test/h5ls/h5ls_plugin.sh.in b/tools/test/h5ls/h5ls_plugin.sh.in
new file mode 100644
index 0000000..3436071
--- /dev/null
+++ b/tools/test/h5ls/h5ls_plugin.sh.in
@@ -0,0 +1,253 @@
+#! /bin/sh
+#
+# 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.
+#
+srcdir=@srcdir@
+TOP_BUILDDIR=@top_builddir@
+
+# Determine backward compatibility options enabled
+DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
+
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+H5LS=../../src/h5ls/h5ls # The tool name
+H5LS_BIN=`pwd`/$H5LS # The path of the tool binary
+
+nerrors=0
+verbose=yes
+h5haveexitcode=yes # default is yes
+
+TEST_NAME=ud_plugin
+FROM_DIR=`pwd`/.libs
+PLUGIN_LIB="$FROM_DIR/libdynlibls.*"
+PLUGIN_LIBDIR=testdir3
+RM='rm -rf'
+
+RM='rm -rf'
+GREP='grep'
+CMP='cmp -s'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+# source dirs
+SRC_TOOLS="$srcdir/../.."
+
+# testfiles source dirs for tools
+SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles"
+SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES"
+
+TESTDIR=./testplug
+test -d $TESTDIR || mkdir $TESTDIR
+
+######################################################################
+# test files
+# --------------------------------------------------------------------
+# All the test files copy from source directory to test directory
+# NOTE: Keep this framework to add/remove test files.
+# Any test files from other tools can be used in this framework.
+# This list are also used for checking exist.
+# Comment '#' without space can be used.
+# --------------------------------------------------------------------
+LIST_HDF5_TEST_FILES="
+$SRC_TOOLS_TESTFILES/tudfilter.h5
+$SRC_TOOLS_TESTFILES/tudfilter.ls
+"
+
+# RUNSERIAL is used. Check if it can return exit code from executable correctly.
+if [ -n "$RUNSERIAL_NOEXITCODE" ]; then
+ echo "***Warning*** Serial Exit Code is not passed back to shell correctly."
+ echo "***Warning*** Exit code checking is skipped."
+ h5haveexitcode=no
+fi
+
+# Main Body
+# Create test directories if not exists yet.
+test -d $PLUGIN_LIBDIR || mkdir -p $PLUGIN_LIBDIR
+if [ $? != 0 ]; then
+ echo "Failed to create test directory($PLUGIN_LIBDIR)"
+ exit $EXIT_FAILURE
+fi
+
+# copy plugin library for test
+$CP $PLUGIN_LIB $PLUGIN_LIBDIR
+if [ $? != 0 ]; then
+ echo "Failed to copy plugin library ($PLUGIN_LIB) for test."
+ exit $EXIT_FAILURE
+fi
+
+# setup plugin path
+ENVCMD="env HDF5_PLUGIN_PATH=../${PLUGIN_LIBDIR}"
+
+#
+# copy test files and expected output files from source dirs to test dir
+#
+COPY_TESTFILES="$LIST_HDF5_TEST_FILES"
+
+COPY_TESTFILES_TO_TESTDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_TESTFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $TESTDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_TESTFILES_AND_TESTDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=$SRC_H5LS_TESTFILES
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $TESTDIR
+ fi
+}
+
+# Print a $* message left justified in a field of 70 characters
+#
+MESSAGE() {
+ SPACES=" "
+ echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+#
+TESTING() {
+ SPACES=" "
+ echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Verifying".
+#
+VERIFY() {
+ MESSAGE "Verifying $*"
+}
+
+# Source in the output filter function definitions.
+. $srcdir/../../../bin/output_filter.sh
+
+# Run a test and print PASS or *FAIL*. For now, if h5ls can complete
+# with exit status 0, consider it pass. If a test fails then increment
+# the `nerrors' global variable and (if $verbose is set) display up to $NLINS
+# lines of the actual output from the tool test. The actual output is not
+# removed if $HDF5_NOCLEANUP has a non-zero value.
+# Arguemnts:
+# $1 -- actual output filename to use
+# $2 and on -- argument for the h5ls tool
+TOOLTEST() {
+ expect="$TESTDIR/$1"
+ actual="$TESTDIR/`basename $1 .ls`.out"
+ actual_err="$TESTDIR/`basename $1 .ls`.err"
+ actual_sav=${actual}-sav
+ actual_err_sav=${actual_err}-sav
+ shift
+ retvalexpect=$1
+ shift
+
+ # Run test.
+ # Stderr is included in stdout so that the diff can detect
+ # any unexpected output from that stream too.
+ TESTING $H5LS $@
+ (
+ cd $TESTDIR
+ $ENVCMD $RUNSERIAL $H5LS_BIN "$@"
+ ) >$actual 2>$actual_err
+
+ exitcode=$?
+ # save actual and actual_err in case they are needed later.
+ cp $actual $actual_sav
+ STDOUT_FILTER $actual
+ cp $actual_err $actual_err_sav
+ STDERR_FILTER $actual_err
+ cat $actual_err >> $actual
+ if [ $h5haveexitcode = 'yes' -a $exitcode -ne $retvalexpect ]; then
+ echo "*FAILED*"
+ nerrors="`expr $nerrors + 1`"
+ if [ yes = "$verbose" ]; then
+ echo "test returned with exit code $exitcode"
+ echo "test output: (up to $NLINES lines)"
+ head -$NLINES $actual
+ echo "***end of test output***"
+ echo ""
+ fi
+ elif [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err $actual_sav $actual_err_sav
+ fi
+}
+
+##############################################################################
+### T H E T E S T S
+##############################################################################
+# prepare for test
+COPY_TESTFILES_TO_TESTDIR
+
+# Run the test
+TOOLTEST tudfilter.ls 0 -w80 -v -d tudfilter.h5
+
+# print results
+if test $nerrors -ne 0 ; then
+ echo "$nerrors errors encountered"
+ exit_code=$EXIT_FAILURE
+else
+ echo "All Plugin API tests passed."
+ exit_code=$EXIT_SUCCESS
+fi
+
+# Clean up temporary files/directories
+CLEAN_TESTFILES_AND_TESTDIR
+
+# Clean up temporary files/directories and leave
+$RM $PLUGIN_LIBDIR
+
+exit $exit_code
diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake
index b610d23..ccd8d88 100644
--- a/tools/test/h5repack/CMakeTests.cmake
+++ b/tools/test/h5repack/CMakeTests.cmake
@@ -1151,7 +1151,7 @@
set (TESTRETVAL 255)
if (WIN32)
set (TESTRETVAL -1)
- endif()
+ endif ()
ADD_H5_CMP_TEST (plugin_zero "" "TEST" ${TESTRETVAL} h5repack_layout.h5 -v -f UD=250,0)
if (HDF5_TEST_VFD)