mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-12-03 02:32:04 +08:00
2aefbf7603
Conform closer to other test print-out. Solution: Added "All h5dump tests passed." statement to output of testh5dump.sh when appropriate. Similarly, added "All h5toh4 tests passed." statement to output of testh5toh4 when appropriate. Also, added the testing of converting H5 files with loop pathways into H4 files with recursive references. Platforms tested: Solaris2.5, Digital Unix 4.0
221 lines
5.6 KiB
Bash
221 lines
5.6 KiB
Bash
#!/bin/sh
|
|
|
|
h5toh4=h5toh4 # a relative name
|
|
cmp='cmp -s'
|
|
diff='diff -c'
|
|
|
|
RM='rm -f'
|
|
SED='sed '
|
|
H4DUMP='hdp'
|
|
|
|
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 '\n'
|
|
}
|
|
|
|
# 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 by adding a `.dmp' extension to the root of
|
|
# the first argument to this function and the actual output file is
|
|
# calculated by replacing the `.dmp' with `.tmp'. The actual output
|
|
# is not removed if $HDF5_NOCLEANUP has a value.
|
|
CONVERT()
|
|
{
|
|
# Run h5toh4 convert.
|
|
TESTING $h5toh4 $@
|
|
(
|
|
cd testfiles
|
|
../$h5toh4 "$@" 2>/dev/null
|
|
)
|
|
|
|
case "$1" in
|
|
|
|
"-m")
|
|
|
|
multirun=passed
|
|
shift
|
|
for i in $@
|
|
do
|
|
h4file=testfiles/`echo $i | $SED -e s/\.h5/.hdf/g`
|
|
|
|
actual=`echo $h4file | $SED -e s/\.hdf/.tmp/`
|
|
expect=`echo $h4file | $SED -e s/\.hdf/.dmp/`
|
|
|
|
if test "testfiles/tloop.hdf" = "$h4file"; then
|
|
$H4DUMP dumpvg $h4file | head -50 > $actual
|
|
else
|
|
$H4DUMP dumpvg $h4file > $actual
|
|
fi
|
|
|
|
$H4DUMP dumpvd $h4file >> $actual
|
|
|
|
$H4DUMP dumpsds $h4file >> $actual
|
|
|
|
# Results. We normalize the result to account for different output
|
|
# widths. That is, the test should succeed if the only
|
|
# differences are in white space. We have to do this the hard way
|
|
# because diff isn't always smart enough.
|
|
tr '\n' ' ' <$actual |tr -s ' \t' |fold >$actual-norm
|
|
tr '\n' ' ' <$expect |tr -s ' \t' |fold >$expect-norm
|
|
|
|
if $cmp $expect-norm $actual-norm; then
|
|
set unrelated
|
|
else
|
|
if test "passed" = "$multirun"; then
|
|
echo "*FAILED*"
|
|
echo " Actual result (*.tmp) differs from expected result (*.dmp)"
|
|
nerrors="`expr $nerrors + 1`"
|
|
multirun=failed
|
|
fi
|
|
test yes = "$verbose" && $diff $expect $actual |sed 's/^/ /'
|
|
fi
|
|
|
|
# Clean up output file
|
|
rm -f $expect-norm $actual-norm
|
|
if [ X = ${HDF5_NOCLEANUP:-X} ]; then
|
|
rm -f $actual
|
|
rm -f $h4file
|
|
fi
|
|
done
|
|
if test "passed" = "$multirun"; then
|
|
echo " PASSED"
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
|
if [ $# -eq 1 ]
|
|
then
|
|
h4file=testfiles/`echo $1 | $SED -e s/\.h5/.hdf/`
|
|
else
|
|
h4file=testfiles/$2
|
|
fi
|
|
|
|
actual=`echo $h4file | $SED -e s/\.hdf/.tmp/`
|
|
expect=`echo $h4file | $SED -e s/\.hdf/.dmp/`
|
|
|
|
if test "testfiles/tloop.hdf" = "$h4file"; then
|
|
$H4DUMP dumpvg $h4file | head -50 > $actual
|
|
else
|
|
$H4DUMP dumpvg $h4file > $actual
|
|
fi
|
|
$H4DUMP dumpvd $h4file >> $actual
|
|
$H4DUMP dumpsds $h4file >> $actual
|
|
|
|
|
|
# Results. We normalize the result to account for different output
|
|
# widths. That is, the test should succeed if the only
|
|
# differences are in white space. We have to do this the hard way
|
|
# because diff isn't always smart enough.
|
|
tr '\n' ' ' <$actual |tr -s ' \t' |fold >$actual-norm
|
|
tr '\n' ' ' <$expect |tr -s ' \t' |fold >$expect-norm
|
|
|
|
if $cmp $expect-norm $actual-norm; then
|
|
echo " PASSED"
|
|
else
|
|
echo "*FAILED*"
|
|
echo " Actual result (*.tmp) differs from expected result (*.dmp)"
|
|
nerrors="`expr $nerrors + 1`"
|
|
test yes = "$verbose" && $diff $expect $actual |sed 's/^/ /'
|
|
fi
|
|
|
|
# Clean up output file
|
|
rm -f $expect-norm $actual-norm
|
|
if [ X = ${HDF5_NOCLEANUP:-X} ]; then
|
|
rm -f $actual
|
|
rm -f $h4file
|
|
fi
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
##############################################################################
|
|
### T H E T E S T S ###
|
|
##############################################################################
|
|
##############################################################################
|
|
|
|
$RM ./testfiles/*.hdf ./testfiles/*.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
|
|
|
|
#
|
|
# The test for conversion are the same as above with the only difference
|
|
# being that the HDF4 filenames are given explicitly.
|
|
#
|
|
|
|
$RM ./testfiles/*.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
|
|
#
|
|
# 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 ./testfiles/*.hdf ./testfiles/*.tmp
|
|
CONVERT -m tgroup.h5 tdset.h5 tattr.h5 tslink.h5 thlink.h5
|
|
CONVERT -m tcompound.h5 tall.h5 tloop.h5
|
|
CONVERT -m tdset2.h5 tcompound2.h5 tmany.h5
|
|
|
|
if test "0" = "$nerrors"; then
|
|
echo "All h5toh4 tests passed."
|
|
fi
|
|
|