[svn-r1172] Purpose:

New feature

Problem:
    The h5toh4 converter tester - testh5toh4, is set up to place output
    files in same directory as input files.  A difficulty comes up when
    the input files come off a write-protected media, such-as CDROM.

Solution:
    Rather than using "cd" to change directory and referencing files by
    short filename only, "input directory" and "output directory" are
    defined explicitly, and files are always referenced with pathnames
    included.  For cases when the converter generates the output filename,
    a copy of the input file is first placed in the "output directory".
    The copied input file is used by h5toh4 and then removed.

    On Solaris2.5, the following sequence of commands seemed to work fine:
    $ gunzip < hdf5-1.1.72.tar.gz | tar xf -
    $ chmod -R ugo-w hdf5-1.1.72
    $ mkdir build
    $ cd build
    $ ../hdf5-1.1.72/configure --enable-production --disable-debug \
    $   --with-hdf4=...  --with-zlib=...
    $ make check

    This change should allow the tester to be used when the hdf5 source
    is on a read only media like a CDROM.

Platform tested:
    Solaris2.5
This commit is contained in:
Paul Harten 1999-04-02 16:38:30 -05:00
parent 5e31902765
commit e5376cafb4
14 changed files with 194 additions and 79 deletions

View File

@ -1,4 +1,4 @@
File name: testfiles/tall.hdf
File name: ./testfiles/tall.hdf
Vgroup:0
@ -287,7 +287,7 @@ Entries:-
Vgroup:16
tag = 1965; reference = 40;
name = tall.hdf; class = CDF0.0;
name = ./testfiles/tall.hdf; class = CDF0.0;
number of entries = 10;
number of attributes = 0
Entries:-
@ -437,7 +437,7 @@ Graphical representation of the file:-
-- SciData dimension record
-- Numeric Data Group
File name: testfiles/tall.hdf
File name: ./testfiles/tall.hdf
Vdata: 0
tag = 1962; reference = 3;
@ -571,7 +571,7 @@ Loc. Data
20 116 ; 49 ; 46 ; 49 ;
24 46 ; 49 ; 0 ;
File name: testfiles/tall.hdf
File name: ./testfiles/tall.hdf
Variable Name = dset1.1.1
Index = 0

View File

@ -1,4 +1,4 @@
File name: testfiles/tattr.hdf
File name: ./testfiles/tattr.hdf
Vgroup:0
@ -28,7 +28,7 @@ Graphical representation of the file:-
vg0
File name: testfiles/tattr.hdf
File name: ./testfiles/tattr.hdf
Vdata: 0
tag = 1962; reference = 3;
@ -90,4 +90,4 @@ Vdata: 4
Loc. Data
0 115 116 114 105 110 103 32 97 116 116 114 105 98 117 116 101 0 ;
File name: testfiles/tattr.hdf
File name: ./testfiles/tattr.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/tcompound.hdf
File name: ./testfiles/tcompound.hdf
Vgroup:0
@ -76,7 +76,7 @@ Graphical representation of the file:-
vg2 -- vd
File name: testfiles/tcompound.hdf
File name: ./testfiles/tcompound.hdf
Vdata: 0
tag = 1962; reference = 3;
@ -140,4 +140,4 @@ Loc. Data
0 0 0.000000 ; 1 0.100000 ; 2 0.200000 ;
3 3 0.300000 ; 4 0.400000 ;
File name: testfiles/tcompound.hdf
File name: ./testfiles/tcompound.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/tcompound2.hdf
File name: ./testfiles/tcompound2.hdf
Vgroup:0
@ -76,7 +76,7 @@ Graphical representation of the file:-
vg2 -- vd
File name: testfiles/tcompound2.hdf
File name: ./testfiles/tcompound2.hdf
Vdata: 0
tag = 1962; reference = 3;
@ -144,4 +144,4 @@ Loc. Data
3 3 3.000000 ; 4 4.000000 ; 5 5.000000 ;
File name: testfiles/tcompound2.hdf
File name: ./testfiles/tcompound2.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/tdset.hdf
File name: ./testfiles/tdset.hdf
Vgroup:0
@ -127,7 +127,7 @@ Entries:-
Vgroup:7
tag = 1965; reference = 19;
name = tdset.hdf; class = CDF0.0;
name = ./testfiles/tdset.hdf; class = CDF0.0;
number of entries = 6;
number of attributes = 0
Entries:-
@ -208,7 +208,7 @@ Graphical representation of the file:-
-- SciData dimension record
-- Numeric Data Group
File name: testfiles/tdset.hdf
File name: ./testfiles/tdset.hdf
Vdata: 0
tag = 1962; reference = 7;
@ -258,7 +258,7 @@ Vdata: 3
Loc. Data
0 20 ;
File name: testfiles/tdset.hdf
File name: ./testfiles/tdset.hdf
Variable Name = dset1
Index = 0

View File

@ -1,4 +1,4 @@
File name: testfiles/tdset2.hdf
File name: ./testfiles/tdset2.hdf
Vgroup:0
@ -127,7 +127,7 @@ Entries:-
Vgroup:7
tag = 1965; reference = 19;
name = tdset2.hdf; class = CDF0.0;
name = ./testfiles/tdset2.hdf; class = CDF0.0;
number of entries = 6;
number of attributes = 0
Entries:-
@ -208,7 +208,7 @@ Graphical representation of the file:-
-- SciData dimension record
-- Numeric Data Group
File name: testfiles/tdset2.hdf
File name: ./testfiles/tdset2.hdf
Vdata: 0
tag = 1962; reference = 7;
@ -258,7 +258,7 @@ Vdata: 3
Loc. Data
0 10 ;
File name: testfiles/tdset2.hdf
File name: ./testfiles/tdset2.hdf
Variable Name = dset1
Index = 0

View File

@ -1,4 +1,4 @@
File name: testfiles/tgroup.hdf
File name: ./testfiles/tgroup.hdf
Vgroup:0
@ -234,6 +234,6 @@ Graphical representation of the file:-
vg13
File name: testfiles/tgroup.hdf
File name: ./testfiles/tgroup.hdf
File name: testfiles/tgroup.hdf
File name: ./testfiles/tgroup.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/thlink.hdf
File name: ./testfiles/thlink.hdf
Vgroup:0
@ -84,7 +84,7 @@ Entries:-
Vgroup:5
tag = 1965; reference = 11;
name = thlink.hdf; class = CDF0.0;
name = ./testfiles/thlink.hdf; class = CDF0.0;
number of entries = 2;
number of attributes = 0
Entries:-
@ -128,7 +128,7 @@ Graphical representation of the file:-
-- SciData dimension record
-- Numeric Data Group
File name: testfiles/thlink.hdf
File name: ./testfiles/thlink.hdf
Vdata: 0
tag = 1962; reference = 7;
@ -142,7 +142,7 @@ Vdata: 0
Loc. Data
0 5 ;
File name: testfiles/thlink.hdf
File name: ./testfiles/thlink.hdf
Variable Name = dset1
Index = 0

View File

@ -1,4 +1,4 @@
File name: testfiles/tloop.hdf
File name: ./testfiles/tloop.hdf
Vgroup:0
@ -48,6 +48,6 @@ Entries:-
Graphical representation of the file:-
(vg#: vgroup; vd: vdata)
File name: testfiles/tloop.hdf
File name: ./testfiles/tloop.hdf
File name: testfiles/tloop.hdf
File name: ./testfiles/tloop.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/tmany.hdf
File name: ./testfiles/tmany.hdf
Vgroup:0
@ -254,7 +254,7 @@ Entries:-
Vgroup:15
tag = 1965; reference = 31;
name = tmany.hdf; class = CDF0.0;
name = ./testfiles/tmany.hdf; class = CDF0.0;
number of entries = 6;
number of attributes = 0
Entries:-
@ -359,7 +359,7 @@ Graphical representation of the file:-
-- SciData dimension record
-- Numeric Data Group
File name: testfiles/tmany.hdf
File name: ./testfiles/tmany.hdf
Vdata: 0
tag = 1962; reference = 5;
@ -474,7 +474,7 @@ Vdata: 7
Loc. Data
0 10 ;
File name: testfiles/tmany.hdf
File name: ./testfiles/tmany.hdf
Variable Name = link3
Index = 0

View File

@ -1,4 +1,4 @@
File name: testfiles/tslink.hdf
File name: ./testfiles/tslink.hdf
Vgroup:0
@ -15,6 +15,6 @@ Graphical representation of the file:-
vg0
File name: testfiles/tslink.hdf
File name: ./testfiles/tslink.hdf
File name: testfiles/tslink.hdf
File name: ./testfiles/tslink.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/tstr.hdf
File name: ./testfiles/tstr.hdf
Vgroup:0
@ -37,7 +37,7 @@ Graphical representation of the file:-
-- vd
-- vd
File name: testfiles/tstr.hdf
File name: ./testfiles/tstr.hdf
Vdata: 0
tag = 1962; reference = 3;
@ -101,4 +101,4 @@ Loc. Data
2 115 49 50 51 52 53 54 55 56 57 48 49 50 51 52 53 54 55 56 57 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 ;
File name: testfiles/tstr.hdf
File name: ./testfiles/tstr.hdf

View File

@ -1,4 +1,4 @@
File name: testfiles/tstr2.hdf
File name: ./testfiles/tstr2.hdf
Vgroup:0
@ -151,7 +151,7 @@ Graphical representation of the file:-
vg6 -- vd
File name: testfiles/tstr2.hdf
File name: ./testfiles/tstr2.hdf
Vdata: 0
tag = 1962; reference = 4;
@ -301,4 +301,4 @@ Loc. Data
9 84 104 105 115 32 105 115 32 114 111 119 32 57 32 111 102 32 116 121 112 101 32 72 53 84 95 83 84 82 95 83 80 65 67 69 80 65 68 32 111 102 32 115 116 114 105 110 103 32 97 ;
File name: testfiles/tstr2.hdf
File name: ./testfiles/tstr2.hdf

View File

@ -8,6 +8,15 @@ RM='rm -f'
SED='sed '
H4DUMP='hdp'
# The build (current) directory might be different than the source directory.
if test "X$srcdir" = X; then
srcdir=.
fi
mkdir testfiles >/dev/null 2>&1
INDIR="$srcdir/testfiles"
OUTDIR="./testfiles"
nerrors=0
verbose=yes
@ -31,9 +40,117 @@ CONVERT()
# Run h5toh4 convert.
TESTING $h5toh4 $@
(
cd testfiles
../$h5toh4 "$@" 2>/dev/null
)
case "$1" in
"-m")
if [ $# -eq 2 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $OUTDIR
set - $1 $OUTDIR/$2
$h5toh4 "$@" 2>/dev/null
$RM $2
fi
elif [ $# -eq 3 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3
$h5toh4 "$@" 2>/dev/null
$RM $2 $3
fi
elif [ $# -eq 4 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3 $INDIR/$4
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $INDIR/$4 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3 $OUTDIR/$4
$h5toh4 "$@" 2>/dev/null
$RM $2 $3 $4
fi
elif [ $# -eq 5 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3 $OUTDIR/$4 $OUTDIR/$5
$h5toh4 "$@" 2>/dev/null
$RM $2 $3 $4 $5
fi
elif [ $# -eq 6 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3 $OUTDIR/$4 $OUTDIR/$5 $OUTDIR/$6
$h5toh4 "$@" 2>/dev/null
$RM $2 $3 $4 $5 $6
fi
elif [ $# -eq 7 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $INDIR/$7
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $INDIR/$7 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3 $OUTDIR/$4 $OUTDIR/$5 $OUTDIR/$6 $OUTDIR/$7
$h5toh4 "$@" 2>/dev/null
$RM $2 $3 $4 $5 $6 $7
fi
elif [ $# -eq 8 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $INDIR/$7 $INDIR/$8
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $INDIR/$7 $INDIR/$8 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3 $OUTDIR/$4 $OUTDIR/$5 $OUTDIR/$6 $OUTDIR/$7 $OUTDIR/$8
$h5toh4 "$@" 2>/dev/null
$RM $2 $3 $4 $5 $6 $7 $8
fi
else
if test "$INDIR" = "$OUTDIR"; then
set - $1 $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $INDIR/$7 $INDIR/$8 $INDIR/$9
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$2 $INDIR/$3 $INDIR/$4 $INDIR/$5 $INDIR/$6 $INDIR/$7 $INDIR/$8 $INDIR/$9 $OUTDIR
set - $1 $OUTDIR/$2 $OUTDIR/$3 $OUTDIR/$4 $OUTDIR/$5 $OUTDIR/$6 $OUTDIR/$7 $OUTDIR/$8 $OUTDIR/$9
$h5toh4 "$@" 2>/dev/null
$RM $2 $3 $4 $5 $6 $7 $8 $9
fi
fi
;;
* )
if [ $# -eq 1 ]
then
if test "$INDIR" = "$OUTDIR"; then
set - $INDIR/$1
$h5toh4 "$@" 2>/dev/null
else
cp $INDIR/$1 $OUTDIR
set - $OUTDIR/$1
$h5toh4 "$@" 2>/dev/null
$RM $1
fi
else
set - $INDIR/$1 $OUTDIR/$2
$h5toh4 "$@" 2>/dev/null
fi
;;
esac
)
case "$1" in
@ -43,29 +160,27 @@ CONVERT()
shift
for i in $@
do
h4file=testfiles/`echo $i | $SED -e s/\.h5/.hdf/g`
h4file=`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) 2>/dev/null
if test "tloop.hdf" = "$h4file"; then
($H4DUMP dumpvg "$OUTDIR/$h4file" |head -50 >"$OUTDIR/$actual") 2>/dev/null
else
$H4DUMP dumpvg $h4file > $actual
$H4DUMP dumpvg "$OUTDIR/$h4file" > "$OUTDIR/$actual"
fi
$H4DUMP dumpvd $h4file >> $actual
$H4DUMP dumpsds $h4file >> $actual
$H4DUMP dumpvd "$OUTDIR/$h4file" >> "$OUTDIR/$actual"
$H4DUMP dumpsds "$OUTDIR/$h4file" >> "$OUTDIR/$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
tr '\n' ' ' <"$OUTDIR/$actual" |tr -s ' \t' |fold >"$OUTDIR/$actual-norm"
tr '\n' ' ' <"$INDIR/$expect" |tr -s ' \t' |fold >"$OUTDIR/$expect-norm"
if $cmp $expect-norm $actual-norm; then
if $cmp "$OUTDIR/$expect-norm" "$OUTDIR/$actual-norm"; then
set unrelated
else
if test "passed" = "$multirun"; then
@ -74,14 +189,14 @@ CONVERT()
nerrors="`expr $nerrors + 1`"
multirun=failed
fi
test yes = "$verbose" && $diff $expect $actual |sed 's/^/ /'
test yes = "$verbose" && $diff "$INDIR/$expect" "$OUTDIR/$actual" |sed 's/^/ /'
fi
# Clean up output file
rm -f $expect-norm $actual-norm
$RM "$OUTDIR/$expect-norm" "$OUTDIR/$actual-norm"
if [ X = ${HDF5_NOCLEANUP:-X} ]; then
rm -f $actual
rm -f $h4file
$RM "$OUTDIR/$actual"
$RM "$OUTDIR/$h4file"
fi
done
if test "passed" = "$multirun"; then
@ -95,44 +210,44 @@ CONVERT()
if [ $# -eq 1 ]
then
h4file=testfiles/`echo $1 | $SED -e s/\.h5/.hdf/`
h4file=`echo $1 | $SED -e s/\.h5/.hdf/`
else
h4file=testfiles/$2
h4file=$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) 2>/dev/null
if test "tloop.hdf" = "$h4file"; then
($H4DUMP dumpvg "$OUTDIR/$h4file" |head -50 >"$OUTDIR/$actual") 2>/dev/null
else
$H4DUMP dumpvg $h4file > $actual
$H4DUMP dumpvg "$OUTDIR/$h4file" > "$OUTDIR/$actual"
fi
$H4DUMP dumpvd $h4file >> $actual
$H4DUMP dumpsds $h4file >> $actual
$H4DUMP dumpvd "$OUTDIR/$h4file" >> "$OUTDIR/$actual"
$H4DUMP dumpsds "$OUTDIR/$h4file" >> "$OUTDIR/$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
tr '\n' ' ' <"$OUTDIR/$actual" |tr -s ' \t' |fold >"$OUTDIR/$actual-norm"
tr '\n' ' ' <"$INDIR/$expect" |tr -s ' \t' |fold >"$OUTDIR/$expect-norm"
if $cmp $expect-norm $actual-norm; then
if $cmp "$OUTDIR/$expect-norm" "$OUTDIR/$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/^/ /'
test yes = "$verbose" && $diff "$INDIR/$expect" "$OUTDIR/$actual" |sed 's/^/ /'
fi
# Clean up output file
rm -f $expect-norm $actual-norm
$RM "$OUTDIR/$expect-norm" "$OUTDIR/$actual-norm"
if [ X = ${HDF5_NOCLEANUP:-X} ]; then
rm -f $actual
rm -f $h4file
$RM "$OUTDIR/$actual"
$RM "$OUTDIR/$h4file"
fi
;;
@ -148,7 +263,7 @@ CONVERT()
##############################################################################
##############################################################################
$RM ./testfiles/*.hdf ./testfiles/*.tmp
$RM $OUTDIR/*.hdf $OUTDIR/*.tmp
#
# The HDF4 filenames are created based upon the HDF5 filenames
@ -199,7 +314,7 @@ CONVERT tstr2.h5
# being that the HDF4 filenames are given explicitly.
#
$RM ./testfiles/*.tmp
$RM $OUTDIR/*.tmp
CONVERT tgroup.h5 tgroup.hdf
CONVERT tdset.h5 tdset.hdf
CONVERT tattr.h5 tattr.hdf
@ -219,7 +334,7 @@ CONVERT tstr2.h5 tstr2.hdf
# Here, multiple conversion are done on HDF5 files at one time.
#
$RM ./testfiles/*.hdf ./testfiles/*.tmp
$RM $OUTDIR/*.hdf $OUTDIR/*.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