[svn-r3489] Purpose:

Code Movement
Description:
    Moved tools code into their own separate subdirectories
Platforms tested:
    Linux, Kelgia
This commit is contained in:
Bill Wendling 2001-02-22 16:53:56 -05:00
parent 416a86e3ce
commit 2821175f3f
9 changed files with 5358 additions and 0 deletions

0
tools/h5ls/Dependencies Normal file
View File

55
tools/h5ls/Makefile.in Normal file
View File

@ -0,0 +1,55 @@
## HDF5 Library Makefile(.in)
##
## Copyright (C) 2001 National Center for Supercomputing Applications.
## All rights reserved.
##
##
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
SUBDIRS=
@COMMENCE@
## Add include directory to the C preprocessor flags, add -lh5tools and
## -lhdf5 to the list of libraries.
##
CPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_srcdir)/tools/lib @CPPFLAGS@
## Test programs and scripts.
##
TEST_PROGS=
TEST_SCRIPTS=$(srcdir)/testh5ls.sh
## These are our main targets: library and tools.
##
LIBTOOLS=../lib/libh5tools.la
LIBHDF5=$(top_builddir)/src/libhdf5.la
PUB_PROGS=h5ls
PROGS=$(PUB_PROGS) $(TEST_PROGS)
## Source and object files for the library; do not install
LIB_SRC=
LIB_OBJ=$(LIB_SRC:.c=.lo)
PUB_LIB=
## Source and object files for programs...
PROG_SRC=h5ls.c
PROG_OBJ=$(PROG_SRC:.c=.lo)
PRIVATE_HDR=
## Source and object files for the tests
TEST_SRC=
TEST_OBJ=$(TEST_SRC:.c=.lo)
## Programs have to be built before they can be tested!
check test _test: $(PROGS)
## How to build the programs... They all depend on the hdf5 library and
## the tools library compiled in this directory.
$(PROGS): $(LIBTOOLS) $(LIBHDF5)
h5ls: h5ls.lo
@$(LT_LINK_EXE) $(CFLAGS) -o $@ h5ls.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
@CONCLUDE@

2166
tools/h5ls/h5ls.c Normal file

File diff suppressed because it is too large Load Diff

143
tools/h5ls/testh5ls.sh Executable file
View File

@ -0,0 +1,143 @@
#! /bin/sh
#
# Copyright (C) 2001 National Center for Supercomputing Applications
# All rights reserved.
#
# Tests for the h5ls tool
H5LS=h5ls # The tool name
H5LS_BIN=`pwd`/$H5LS # The path of the tool binary
CMP='cmp -s'
DIFF='diff -c'
NLINES=20 # Max. lines of output to display if test fails
nerrors=0
verbose=yes
# The build (current) directory might be different than the source directory.
if test -z "$srcdir"; then
srcdir=.
fi
test -d ../testfiles || mkdir ../testfiles
# 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'
}
# 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="$srcdir/../testfiles/$1"
actual="../testfiles/`basename $1 .ls`.out"
shift
# Run test.
# Stderr is included in stdout so that the diff can detect
# any unexpected output from that stream too.
TESTING $H5LS $@
(
echo "#############################"
echo " output for '$H5LS $@'"
echo "#############################"
cd $srcdir/../testfiles
$RUNSERIAL $H5LS_BIN "$@"
) >$actual 2>&1
exitcode=$?
if [ $exitcode -ne 0 ]; 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
fi
}
##############################################################################
##############################################################################
### T H E T E S T S ###
##############################################################################
##############################################################################
# Toss in a bunch of tests. Not sure if they are the right kinds.
# test the help syntax
TOOLTEST help-1.ls -w80 -h
TOOLTEST help-2.ls -w80 -help
TOOLTEST help-3.ls -w80 -?
# test simple command
TOOLTEST tall-1.ls -w80 tall.h5
TOOLTEST tall-2.ls -w80 -r -d tall.h5
TOOLTEST tgroup.ls -w80 tgroup.h5
# test for displaying groups
TOOLTEST tgroup-1.ls -w80 -r -g tgroup.h5
# test for displaying simple space datasets
TOOLTEST tdset-1.ls -w80 -r -d tdset.h5
# test for displaying soft links
TOOLTEST tslink-1.ls -w80 -r tslink.h5
# tests for hard links
TOOLTEST thlink-1.ls -w80 thlink.h5
# tests for compound data types
TOOLTEST tcomp-1.ls -w80 -r -d tcompound.h5
#test for the nested compound type
TOOLTEST tnestcomp-1.ls -w80 -r -d tnestedcomp.h5
# test for loop detection
TOOLTEST tloop-1.ls -w80 -r -d tloop.h5
# test for string
TOOLTEST tstr-1.ls -w80 -r -d tstr.h5
# test test file created from lib SAF team
TOOLTEST tsaf.ls -w80 -r -d tsaf.h5
# test for variable length data types
TOOLTEST tvldtypes1.ls -w80 -r -d tvldtypes1.h5
# test for array data types
TOOLTEST tarray1.ls -w80 -r -d tarray1.h5
# test for empty data
TOOLTEST tempty.ls -w80 -d tempty.h5
if test $nerrors -eq 0 ; then
echo "All h5ls tests passed."
fi
exit $nerrors

View File

60
tools/h5toh4/Makefile.in Normal file
View File

@ -0,0 +1,60 @@
## HDF5 Library Makefile(.in)
##
## Copyright (C) 2001 National Center for Supercomputing Applications.
## All rights reserved.
##
##
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
SUBDIRS=
@COMMENCE@
## Add include directory to the C preprocessor flags, add -lh5tools and
## -lhdf5 to the list of libraries.
##
CPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_srcdir)/tools/lib @CPPFLAGS@
## Test programs and scripts.
##
TEST_PROGS=
TEST_SCRIPTS=@TESTH5TOH4@
## These are our main targets: library and tools.
##
LIBTOOLS=../lib/libh5tools.la
LIBHDF5=$(top_builddir)/src/libhdf5.la
PUB_PROGS=@H5TOH4@
PROGS=$(PUB_PROGS) $(TEST_PROGS)
## Source and object files for the library; do not install
##
LIB_SRC=
LIB_OBJ=$(LIB_SRC:.c=.lo)
PUB_LIB=
## Source and object files for programs...
##
PROG_SRC=h5toh4.c
PROG_OBJ=$(PROG_SRC:.c=.lo)
PRIVATE_HDR=h5toh4.h
## Source and object files for the tests
##
TEST_SRC=
TEST_OBJ=$(TEST_SRC:.c=.lo)
## Programs have to be built before they can be tested!
##
check test _test: $(PROGS)
## How to build the programs... They all depend on the hdf5 library and
## the tools library compiled in this directory.
##
$(PROGS): $(LIBTOOLS) $(LIBHDF5)
h5toh4: h5toh4.lo
@$(LT_LINK_EXE) $(CFLAGS) -o $@ h5toh4.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
@CONCLUDE@

2592
tools/h5toh4/h5toh4.c Normal file

File diff suppressed because it is too large Load Diff

43
tools/h5toh4/h5toh4.h Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright © 1998 NCSA
* All rights reserved.
*
* Programmer: Paul Harten <pharten@ncsa.uiuc.edu>
* Friday, October 16th, 1998
*
* Purpose: Convert H5 files to H4 files.
*/
#ifndef _H5TOH4_H
#define _H5TOH4_H
#include "hdf.h"
#include "mfhdf.h"
#include "hdf5.h"
#ifdef H5_HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
typedef struct op_data_t {
/*
* information being carried between iterations.
*
*/
int32 hfile_id;
int32 vgroup_id;
int32 sd_id;
int32 sds_id;
int32 vdata_id;
int32 obj_idx;
} op_data_t;
#ifdef H5TOH4_DEBUG
#define DEBUG_PRINT(s1,s2,s3,n1) ( fprintf(stderr,s1,s2,s3,n1) )
#else
#define DEBUG_PRINT(s1,s2,s3,n1) ( fprintf(stderr," ") )
#endif
#endif

299
tools/h5toh4/testh5toh4.sh Executable file
View File

@ -0,0 +1,299 @@
#! /bin/sh
#
# Copyright (C) 1997-2001 National Center for Supercomputing Applications.
# All rights reserved.
#
H5TOH4=h5toh4 # a relative name
H5TOH4_BIN=`pwd`/$H5TOH4 # an absolute command path
cmp='cmp -s'
diff='diff -c'
RM='rm -f'
SED='sed '
H4DUMP='hdp'
# Verify if $H4DUMP is a valid command.
tmpfile=/tmp/testh5toh4.$$
$H4DUMP -H > $tmpfile
if test -s "$tmpfile"; then
# Find out which version of hdp is being used. Over simplified
# algorithm but will do the job for now.
if ( grep -s 'NCSA HDF Version 4.1 Release [3-9]' $tmpfile > /dev/null )
then
H4DUMPVER=413
else
H4DUMPVER=0
echo " Some tests maybe skipped because your version of $H4DUMP does"
echo " not handle loops in Vgroups correctly. You need version"
echo " 4.1 Release 3 or later. Visit http://hdf.ncsa.uiuc.edu"
echo " or email hdfhelp@ncsa.uiuc.edu for more information."
fi
else
echo " Could not run the '$H4DUMP' command. The test can still proceed"
echo " but it may fail if '$H4DUMP' is needed to verify the output."
echo " You can make sure '$H4DUMP' is among your shell PATH and run"
echo " the test again. You may also visit http://hdf.ncsa.uiuc.edu"
echo " or email hdfhelp@ncsa.uiuc.edu for more information."
H4DUMP=:
H4DUMPVER=0
fi
$RM $tmpfile
# The build (current) directory might be different than the source directory.
if test -z "$srcdir"; then
srcdir=.
fi
mkdir ../testfiles >/dev/null 2>&1
SRCDIR="$srcdir/../testfiles"
OUTDIR="../testfiles/Results"
test -d $OUTDIR || mkdir $OUTDIR
nerrors=0
verbose=yes
# 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'
}
# 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 and the expected hdf4 files. The
# expected hdf4 files are in testfiles/Expected directory.
# The actual hdf4 file is not removed if $HDF5_NOCLEANUP is to a non-null
# value.
CONVERT() {
# Run h5toh4 convert.
TESTING $H5TOH4 $@
#
# Set up arguments to run the conversion test.
# The converter assumes all hdf5 files has the .h5 suffix as in the form
# of foo.h5. It creates the corresponding hdf4 files with the .hdf suffix
# as in the form of foo.hdf. One exception is that if exactly two file
# names are given, it treats the first argument as an hdf5 file and creates
# the corresponding hdf4 file with the name as the second argument, WITOUT
# any consideration of the suffix. (For this test script, in order to
# match the output hdf4 file with the expected hdf4 file, it expects the
# second file of the two-files tests has the .hdf suffix too.)
#
# If SRCDIR != OUTDIR, need to copy the input hdf5 files from the SRCDIR
# to the OUTDIR and transform the input file pathname because of the suffix
# convention mentioned above. This way, the hdf4 files are always created
# in the OUTDIR directory.
#
INFILES=""
OUTFILES=""
MULTIRUN=""
case "$1" in
"-m") # multiple files conversion
MULTIRUN="-m"
shift
for f in $*
do
if test "$SRCDIR" != "$OUTDIR"; then
cp $SRCDIR/$f $OUTDIR/$f
fi
INFILES="$INFILES $f"
OUTFILES="$OUTFILES `basename $f .h5`.hdf"
shift
done
;;
* ) # Single file conversion
case $# in
1) if test "$SRCDIR" != "$OUTDIR"; then
cp $SRCDIR/$1 $OUTDIR/$1
fi
INFILES="$1"
OUTFILES="`basename $1 .h5`.hdf"
;;
2) # hdf4 file specified
if test "$SRCDIR" != "$OUTDIR"; then
cp $SRCDIR/$1 $OUTDIR/$1
fi
INFILES="$1"
OUTFILES="$2"
;;
*) # Illegal
echo "Illegal arguments"
exit 1
;;
esac
;;
esac
# run the conversion and remove input files that have been copied over
(
cd $OUTDIR
$H5TOH4_BIN $MULTIRUN $INFILES 2>/dev/null
if test "$SRCDIR" != "$OUTDIR"; then
$RM $INFILES
fi
)
# Verify results
result="passed"
for f in $OUTFILES
do
if $cmp $SRCDIR/Expected/$f $OUTDIR/$f
then
:
else
# Use hdp to dump the files and verify the output.
# Filter out the output of "reference = ..." because
# reference numbers are immaterial in general.
outfile=`basename $f .hdf`
expect_out=$outfile.expect
actual_out=$outfile.actual
if [ $outfile = "tloop" -a $H4DUMPVER -lt 413 ]
then
echo " -SKIP-"
result="skipped"
touch $expect_out $actual_out # fake them
else
(cd $SRCDIR/Expected
$H4DUMP dumpvg $outfile.hdf
$H4DUMP dumpvd $outfile.hdf
$H4DUMP dumpsds $outfile.hdf ) |
sed -e 's/reference = [0-9]*;//' > $expect_out
(cd $OUTDIR
$H4DUMP dumpvg $outfile.hdf
$H4DUMP dumpvd $outfile.hdf
$H4DUMP dumpsds $outfile.hdf ) |
sed -e 's/reference = [0-9]*;//' > $actual_out
fi
if [ "passed" = $result -a ! -s $actual_out ] ; then
echo "*FAILED*"
nerrors="`expr $nerrors + 1`"
result=failed
test yes = "$verbose" &&
echo " H4DUMP failed to produce valid output"
elif $cmp $expect_out $actual_out; then
:
else
if test "passed" = $result; then
echo "*FAILED*"
nerrors="`expr $nerrors + 1`"
result=failed
fi
test yes = "$verbose" &&
echo " Actual result (*.actual) differs from expected result (*.expect)" &&
$diff $expect_out $actual_out |sed 's/^/ /'
fi
fi
# Clean up output file
if test -z "$HDF5_NOCLEANUP"; then
$RM $expect_out $actual_out
$RM $OUTDIR/$f
fi
done
if test "passed" = "$result"; then
echo " PASSED"
fi
}
##############################################################################
##############################################################################
### T H E T E S T S ###
##############################################################################
##############################################################################
$RM $OUTDIR/*.hdf $OUTDIR/*.tmp
#
# The HDF4 filenames are created based upon the HDF5 filenames
# without the extension.
#
# test for converting H5 groups to H4 Vgroups.
CONVERT tgroup.h5
# test for converting H5 datasets to H4 SDS's.
CONVERT tdset.h5
# test for converting H5 attributes to H4 attributes.
CONVERT tattr.h5
# test for converting H5 soft links.
CONVERT tslink.h5
# test for converting H5 hard links.
CONVERT thlink.h5
# test for converting H5 compound data type to H4 Vdata.
CONVERT tcompound.h5
# test for converting all H5 objects at in same file.
CONVERT tall.h5
# tests for converting H5 objects with loops.
CONVERT tloop.h5
# test for converting extendable H5 datasets to H4 SDS's.
CONVERT tdset2.h5
# test for converting extendable H5 datasets with compound data type to H4 Vdata.
CONVERT tcompound2.h5
# tests for converting H5 objects from many different pathways.
CONVERT tmany.h5
# tests for converting H5 string objects.
CONVERT tstr.h5
# tests for converting more H5 string objects.
CONVERT tstr2.h5
#
# The test for conversion are the same as above with the only difference
# being that the HDF4 filenames are given explicitly.
#
$RM $OUTDIR/*.tmp
CONVERT tgroup.h5 tgroup.hdf
CONVERT tdset.h5 tdset.hdf
CONVERT tattr.h5 tattr.hdf
CONVERT tslink.h5 tslink.hdf
CONVERT thlink.h5 thlink.hdf
CONVERT tcompound.h5 tcompound.hdf
CONVERT tall.h5 tall.hdf
CONVERT tloop.h5 tloop.hdf
CONVERT tdset2.h5 tdset2.hdf
CONVERT tcompound2.h5 tcompound2.hdf
CONVERT tmany.h5 tmany.hdf
CONVERT tstr.h5 tstr.hdf
CONVERT tstr2.h5 tstr2.hdf
#
# Again, the test for conversion are the same as the first set of test.
# Here, multiple conversion are done on HDF5 files at one time.
#
$RM $OUTDIR/*.hdf $OUTDIR/*.tmp
CONVERT -m tgroup.h5 tdset.h5 tattr.h5 tslink.h5 thlink.h5
CONVERT -m tcompound.h5 tall.h5
CONVERT -m tloop.h5
CONVERT -m tdset2.h5 tcompound2.h5 tmany.h5
CONVERT -m tstr.h5 tstr2.h5
if test $nerrors -eq 0 ; then
echo "All h5toh4 tests passed."
fi
if test -z "$HDF5_NOCLEANUP"; then
$RM -r $OUTDIR
fi
exit $nerrors