summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-09-01 10:27:45 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-09-01 10:27:45 (GMT)
commit642f392ba3e2d30ae2a82e32f249461121d17cbc (patch)
treebbce1ae1606153f323156f207b50d88d7fba2ddf /tools/h5repack
parentc034336452ee48574f0dd65bf053079f9801e269 (diff)
downloadhdf5-642f392ba3e2d30ae2a82e32f249461121d17cbc.zip
hdf5-642f392ba3e2d30ae2a82e32f249461121d17cbc.tar.gz
hdf5-642f392ba3e2d30ae2a82e32f249461121d17cbc.tar.bz2
[svn-r19330] Description:
Bring r19109:19328 from trunk to revise_chunks branch. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/CMakeLists.txt136
-rwxr-xr-xtools/h5repack/h5repack.sh.in50
-rw-r--r--tools/h5repack/h5repack_copy.c16
-rw-r--r--tools/h5repack/h5repack_refs.c27
4 files changed, 168 insertions, 61 deletions
diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt
index adec48a..d767de1 100644
--- a/tools/h5repack/CMakeLists.txt
+++ b/tools/h5repack/CMakeLists.txt
@@ -4,11 +4,11 @@ PROJECT (HDF5_TOOLS_H5REPACK)
#-----------------------------------------------------------------------------
# Setup include Directories
#-----------------------------------------------------------------------------
-INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib)
-INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test)
+INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib)
+INCLUDE_DIRECTORIES (${HDF5_TEST_SRC_DIR})
# --------------------------------------------------------------------
-# Add h5Repack executables and tests
+# Add h5Repack executables
# --------------------------------------------------------------------
SET (REPACK_COMMON_SRCS
${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_copy.c
@@ -19,7 +19,7 @@ SET (REPACK_COMMON_SRCS
${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_verify.c
${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack.c
)
-INCLUDE_DIRECTORIES (${HDF5_TEST_SOURCE_DIR})
+
ADD_EXECUTABLE (h5repack ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c)
H5_NAMING (h5repack)
IF (WIN32)
@@ -36,7 +36,16 @@ TARGET_LINK_LIBRARIES (h5repack ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
SET (H5_DEP_EXECUTABLES h5repack)
+##############################################################################
+##############################################################################
+### T E S T I N G ###
+##############################################################################
+##############################################################################
+
IF (BUILD_TESTING)
+ # --------------------------------------------------------------------
+ # Add h5Repack test executables
+ # --------------------------------------------------------------------
ADD_EXECUTABLE (testh5repack_detect_szip ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c)
H5_NAMING (testh5repack_detect_szip)
IF (WIN32)
@@ -80,39 +89,16 @@ IF (BUILD_TESTING)
TARGET_LINK_LIBRARIES (h5repacktest ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
ADD_TEST (NAME h5repacktest COMMAND $<TARGET_FILE:h5repacktest>)
-
- SET (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
- h5repacktest
- testh5repack_detect_szip
- )
-
-
- SET (INFO_FILE testfiles/h5repack.info)
-
- SET (FILE0 h5repack_fill.h5)
- SET (FILE1 h5repack_objs.h5)
- SET (FILE2 h5repack_attr.h5)
- SET (FILE3 h5repack_hlink.h5)
- SET (FILE4 h5repack_layout.h5)
- SET (FILE5 h5repack_early.h5)
- SET (FILE7 h5repack_szip.h5)
- SET (FILE8 h5repack_deflate.h5)
- SET (FILE9 h5repack_shuffle.h5)
- SET (FILE10 h5repack_fletcher.h5)
- SET (FILE11 h5repack_filters.h5)
- SET (FILE12 h5repack_nbit.h5)
- SET (FILE13 h5repack_soffset.h5)
- SET (FILE14 h5repack_layouto.h5 ) # A file with an older version of the layout message (copy of test/tlayouto.h5)
- SET (FILE15 h5repack_named_dtypes.h5)
- SET (FILE16 tfamily%05d.h5) # located in common testfiles folder
- SET (FILE_REF h5repack_refs.h5)
- #-- Copy all the HDF5 files from the test directory into the source directory
+ # --------------------------------------------------------------------
+ # Copy all the HDF5 files from the test directory into the source directory
+ # --------------------------------------------------------------------
SET (HDF5_REFERENCE_TEST_FILES
h5repack_ext.bin
ublock.bin
h5repack.info
h5repack_attr.h5
+ h5repack_attr_refs.h5
h5repack_deflate.h5
h5repack_early.h5
h5repack_ext.h5
@@ -142,6 +128,7 @@ IF (BUILD_TESTING)
tfamily00008.h5
tfamily00009.h5
tfamily00010.h5
+ h5repack_filters.h5.ddl
)
FOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES})
@@ -162,14 +149,22 @@ IF (BUILD_TESTING)
TARGET h5repack
POST_BUILD
COMMAND ${CMAKE_COMMAND}
- ARGS -E copy_if_different ${HDF5_TOOLS_SOURCE_DIR}/testfiles/${h5c_file} ${dest}
+ ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5c_file} ${dest}
)
ENDFOREACH (h5c_file ${HDF5_COMMON_TEST_FILES})
-
+
+##############################################################################
+##############################################################################
+### T H E T E S T S M A C R O S ###
+##############################################################################
+##############################################################################
MACRO (ADD_H5_TEST testname testtype testfile)
IF (${testtype} STREQUAL "SKIP")
- MESSAGE (STATUS "SKIP ${testfile} ${ARGN}")
+ ADD_TEST (
+ NAME H5REPACK-${testname}
+ COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out.${testfile}"
+ )
ELSE (${testtype} STREQUAL "SKIP")
ADD_TEST (
NAME H5REPACK-${testname}
@@ -182,6 +177,58 @@ IF (BUILD_TESTING)
ENDIF (${testtype} STREQUAL "SKIP")
ENDMACRO (ADD_H5_TEST testname testfile testtype)
+ MACRO (ADD_H5_CMP_TEST testname testfilter testtype resultcode resultfile)
+ IF (${testtype} STREQUAL "SKIP")
+ ADD_TEST (
+ NAME H5REPACK-${testname}
+ COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out.${resultfile}"
+ )
+ ELSE (${testtype} STREQUAL "SKIP")
+ ADD_TEST (
+ NAME H5REPACK-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5repack>"
+ -D "TEST_ARGS:STRING=${ARGN};testfiles/${resultfile};testfiles/out.${resultfile}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_FILTER:STRING=${testfilter}"
+ -D "TEST_REFERENCE=testfiles/${resultfile}.ddl"
+ -P "${HDF5_RESOURCES_DIR}/runTest.cmake"
+ )
+ ENDIF (${testtype} STREQUAL "SKIP")
+ ENDMACRO (ADD_H5_CMP_TEST file)
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+
+ # --------------------------------------------------------------------
+ # test file names
+ # --------------------------------------------------------------------
+ SET (INFO_FILE testfiles/h5repack.info)
+
+ SET (FILE0 h5repack_fill.h5)
+ SET (FILE1 h5repack_objs.h5)
+ SET (FILE2 h5repack_attr.h5)
+ SET (FILE3 h5repack_hlink.h5)
+ SET (FILE4 h5repack_layout.h5)
+ SET (FILE5 h5repack_early.h5)
+ SET (FILE7 h5repack_szip.h5)
+ SET (FILE8 h5repack_deflate.h5)
+ SET (FILE9 h5repack_shuffle.h5)
+ SET (FILE10 h5repack_fletcher.h5)
+ SET (FILE11 h5repack_filters.h5)
+ SET (FILE12 h5repack_nbit.h5)
+ SET (FILE13 h5repack_soffset.h5)
+ SET (FILE14 h5repack_layouto.h5 ) # A file with an older version of the layout message (copy of test/tlayouto.h5)
+ SET (FILE15 h5repack_named_dtypes.h5)
+ SET (FILE16 tfamily%05d.h5) # located in common testfiles folder
+ SET (FILE_REF h5repack_refs.h5)
+ SET (FILE_ATTR_REF h5repack_attr_refs.h5)
+
#
# The tests
# We use the files generated by h5repacktst
@@ -306,6 +353,14 @@ IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_SHUFFLE
SET (TESTTYPE "SKIP")
ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE)
ADD_H5_TEST (all_filters ${TESTTYPE} ${arg})
+
+# verbose gzip with individual object
+SET (arg ${FILE11} -v -f /dset_deflate:GZIP=9)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_CMP_TEST (gzip_verbose_filters "O?...ing file[^\n]+\n" ${TESTTYPE} 0 ${arg})
###########################################################
# the following tests assume the input files have filters
@@ -550,11 +605,22 @@ ADD_H5_TEST (committed_dt "TEST" ${FILE15})
# tests family driver (file is located in common testfiles folder, uses TOOLTEST1
#ADD_H5_TEST ( family "FAMILY" ${FILE16})
-# test various references (bug 1814)
+# test various references (bug 1814 and 1726)
ADD_H5_TEST (bug1814 "TEST" ${FILE_REF})
+
+# test attribute with various references (bug 1797)
+# the references in attribute of compund or vlen datatype
+# TODO: include this test when code portion is completed.
+ADD_H5_TEST (bug1797 "SKIP" ${FILE_ATTR_REF})
ENDIF (BUILD_TESTING)
+##############################################################################
+##############################################################################
+### I N S T A L L A T I O N ###
+##############################################################################
+##############################################################################
+
#-----------------------------------------------------------------------------
# Rules for Installation of tools using make Install target
#-----------------------------------------------------------------------------
diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in
index 2b63fc0..d889b55 100755
--- a/tools/h5repack/h5repack.sh.in
+++ b/tools/h5repack/h5repack.sh.in
@@ -183,6 +183,48 @@ TOOLTEST1()
fi
rm -f $outfile
}
+
+# Call h5repack and compare output to a text file for -v option
+#
+TOOLTESTV()
+{
+ # Run test.
+ TESTING $H5REPACK $@
+ expect="$srcdir/../testfiles/$1.ddl"
+ actual="../testfiles/`basename $1 .ddl`.out"
+ actual_err="../testfiles/`basename $1 .ddl`.err"
+
+ infile=$srcdir/testfiles/$1
+ path=`pwd`
+ outfile=$path/out.$1
+ shift
+ $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile >$actual 2>$actual_err
+ cp $actual $actual_sav
+ STDOUT_FILTER $actual
+ cat $actual_err >> $actual
+
+ if cmp -s $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.ddl) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && diff -c $expect $actual |sed 's/^/ /'
+ fi
+
+ rm -f $actual $actual_err $actual_sav
+}
+
+STDOUT_FILTER() {
+ result_file=$1
+ tmp_file=/tmp/h5test_tmp_$$
+ # Filter name of files.
+ cp $result_file $tmp_file
+ sed -e '/^Opening file/d' -e '/^Making file/d' \
+ < $tmp_file > $result_file
+ # cleanup
+ rm -f $tmp_file
+}
#
# The tests
@@ -286,6 +328,14 @@ if test $USE_FILTER_SZIP_ENCODER != "yes" -o $USE_FILTER_SZIP != "yes" -o $USE_F
else
TOOLTEST $arg
fi
+
+# verbose gzip with individual object
+arg="$FILE11 -v -f /dset_deflate:GZIP=9"
+if test $USE_FILTER_DEFLATE != "yes" ; then
+ SKIP $arg
+else
+ TOOLTEST $arg
+fi
###########################################################
# the following tests assume the input files have filters
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index c3475aa..b736c22 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -686,19 +686,15 @@ int do_copy_objects(hid_t fidin,
req_filter = 1;
/* check if filters were requested for individual objects */
- for( u = 0; u < options->op_tbl->nelems; u++)
- {
+ for (u = 0; u < options->op_tbl->nelems; u++) {
int k;
- for( k = 0; k < options->op_tbl->objs[u].nfilters; k++)
- {
- if ( options->op_tbl->objs[u].filter->filtn > 0 )
- {
-
- req_filter = 1;
-
+ if (strcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) {
+ for (k = 0; k < options->op_tbl->objs[u].nfilters; k++) {
+ if (options->op_tbl->objs[u].filter->filtn > 0) {
+ req_filter = 1;
+ }
}
-
}
}
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index fcdfbd5..aa2e823 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -707,34 +707,29 @@ error:
*
*-------------------------------------------------------------------------
*/
-
-static const char* MapIdToName(hid_t refobj_id,
- trav_table_t *travt)
+static const char*
+MapIdToName(hid_t refobj_id, trav_table_t *travt)
{
- unsigned int i;
+ unsigned int u;
const char* ret = NULL;
- H5O_info_t ref_oinfo; /* Stat for the refobj id */
/* linear search */
- for(i = 0; i < travt->nobjs; i++)
- {
- if(travt->objs[i].type == H5O_TYPE_DATASET ||
- travt->objs[i].type == H5O_TYPE_GROUP ||
- travt->objs[i].type == H5O_TYPE_NAMED_DATATYPE)
- {
+ for(u = 0; u < travt->nobjs; u++) {
+ if(travt->objs[u].type == H5O_TYPE_DATASET ||
+ travt->objs[u].type == H5O_TYPE_GROUP ||
+ travt->objs[u].type == H5O_TYPE_NAMED_DATATYPE) {
H5O_info_t ref_oinfo; /* Stat for the refobj id */
/* obtain information to identify the referenced object uniquely */
if(H5Oget_info(refobj_id, &ref_oinfo) < 0)
goto out;
- if(ref_oinfo.addr == travt->objs[i].objno)
- {
- ret = travt->objs[i].name;
+ if(ref_oinfo.addr == travt->objs[u].objno) {
+ ret = travt->objs[u].name;
goto out;
- }
+ } /* end if */
} /* end if */
- } /* i */
+ } /* u */
out:
return ret;