summaryrefslogtreecommitdiffstats
path: root/tools/h5jam
diff options
context:
space:
mode:
authorlrknox <lrknox>2017-05-20 02:32:43 (GMT)
committerlrknox <lrknox>2017-05-20 02:32:43 (GMT)
commit3a43f7af3eaf807fbdf4cf26c10eadb67903b4a8 (patch)
treea9af55e96791ecc7845a67a5b2ec6e667a24dd12 /tools/h5jam
parent197b461bceee6b066ba7560766644ad2a26c361c (diff)
parentd2db9140b298cf4ffa75255743a709a8b5362135 (diff)
downloadhdf5-3a43f7af3eaf807fbdf4cf26c10eadb67903b4a8.zip
hdf5-3a43f7af3eaf807fbdf4cf26c10eadb67903b4a8.tar.gz
hdf5-3a43f7af3eaf807fbdf4cf26c10eadb67903b4a8.tar.bz2
Merge branch 'hdf5_1_8' of https://bitbucket.hdfgroup.org/scm/~lrknox/hdf5_lrk into hdf5_1_8
Diffstat (limited to 'tools/h5jam')
-rw-r--r--tools/h5jam/CMakeTests.cmake11
-rw-r--r--tools/h5jam/h5jamgentest.c33
-rw-r--r--tools/h5jam/testh5jam.sh.in382
3 files changed, 222 insertions, 204 deletions
diff --git a/tools/h5jam/CMakeTests.cmake b/tools/h5jam/CMakeTests.cmake
index c9ec521..47276eb 100644
--- a/tools/h5jam/CMakeTests.cmake
+++ b/tools/h5jam/CMakeTests.cmake
@@ -1,3 +1,14 @@
+#
+# 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 COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
##############################################################################
##############################################################################
diff --git a/tools/h5jam/h5jamgentest.c b/tools/h5jam/h5jamgentest.c
index dc3c001..fa8bd4e 100644
--- a/tools/h5jam/h5jamgentest.c
+++ b/tools/h5jam/h5jamgentest.c
@@ -252,7 +252,7 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill)
space = H5Screate_simple(1, dims, NULL);
dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for (i = 0; i < 10; i++)
- dset2_1[i] = (float)(i*0.1F+1);
+ dset2_1[i] = (float)((float)i * 0.1F + 1.0F);
H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1);
H5Sclose(space);
H5Dclose(dataset);
@@ -263,7 +263,7 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill)
dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for (i = 0; i < 3; i++)
for (j = 0; j < 5; j++)
- dset2_2[i][j] = (float)((i+1)*j*0.1F);
+ dset2_2[i][j] = (float)(((float)i + 1.0F) * (float)j * 0.1F);
H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2);
H5Sclose(space);
H5Dclose(dataset);
@@ -279,20 +279,23 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill)
/* If a user block is being used, write to it here */
if(ub_size > 0)
{
- HDassert(ub_size <= BUF_SIZE);
+ ssize_t nbytes;
- fd = HDopen(filename, O_RDWR, 0);
- HDassert(fd >= 0);
+ HDassert(ub_size <= BUF_SIZE);
- /* fill buf with pattern */
- HDmemset(buf, '\0', ub_size);
- bp = buf;
- for (u = 0; u < ub_fill; u++)
- *bp++ = pattern[u % 10];
+ fd = HDopen(filename, O_RDWR, 0);
+ HDassert(fd >= 0);
- HDwrite(fd, buf, ub_size);
+ /* fill buf with pattern */
+ HDmemset(buf, '\0', ub_size);
+ bp = buf;
+ for (u = 0; u < ub_fill; u++)
+ *bp++ = pattern[u % 10];
- HDclose(fd);
+ nbytes = HDwrite(fd, buf, ub_size);
+ HDassert(nbytes >= 0);
+
+ HDclose(fd);
}
}
@@ -303,10 +306,11 @@ create_textfile(const char *name, size_t size)
int fd;
size_t i;
char *bp;
+ ssize_t nbytes;
fd = HDcreat(name,0777);
HDassert(fd >= 0);
- buf = HDcalloc(size, (size_t)1);
+ buf = (char *)HDcalloc(size, (size_t)1);
HDassert(buf);
/* fill buf with pattern */
@@ -314,7 +318,8 @@ create_textfile(const char *name, size_t size)
for(i = 0; i < size; i++)
*bp++ = pattern[i % 10];
- HDwrite(fd, buf, size);
+ nbytes = HDwrite(fd, buf, size);
+ HDassert(nbytes >= 0);
HDfree(buf);
diff --git a/tools/h5jam/testh5jam.sh.in b/tools/h5jam/testh5jam.sh.in
index d17c687..d28db72 100644
--- a/tools/h5jam/testh5jam.sh.in
+++ b/tools/h5jam/testh5jam.sh.in
@@ -107,10 +107,10 @@ COPY_TESTFILES_TO_TESTDIR()
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
+ $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
@@ -154,19 +154,19 @@ SKIP() {
echo " -SKIP-"
}
-#
+#
# COMPARE_FILES a.h5 b.h5
-# Compare two files, skipping the first line. This is used to
+# Compare two files, skipping the first line. This is used to
# compare the output of the dumper, skipping the file name which
# is different.
# The result is stored in 'compval'.
#
cmpval=0;
COMPARE_FILES() {
- $AWK 'NR > 1' $1 > $1.cmp
- $AWK 'NR > 1' $2 > $2.cmp
- $CMP $1.cmp $2.cmp
- cmpval=$?
+ $AWK 'NR > 1' $1 > $1.cmp
+ $AWK 'NR > 1' $2 > $2.cmp
+ $CMP $1.cmp $2.cmp
+ cmpval=$?
rm -f $1.cmp $2.cmp
}
@@ -174,10 +174,10 @@ COMPARE_FILES() {
# Clean up named files.
CLEANUP() {
if test -z "$HDF5_NOCLEANUP"; then
- for i in $*
- do
- rm -f $i
- done
+ for i in $*
+ do
+ rm -f $i
+ done
fi
}
@@ -190,7 +190,7 @@ CLEANUP() {
# the "cat" command.
#
SETUP() {
- cat < $1 > $2
+ cat < $1 > $2
}
#
@@ -233,7 +233,7 @@ CHECKFILE() {
}
#
-# CHECK_UB file.h5 user_block_file origfile.h5
+# CHECK_UB file.h5 user_block_file origfile.h5
#
# Check the user block in 'file.h5' is the same as
# 'user_block' (allowing for padding).
@@ -243,73 +243,73 @@ CHECKFILE() {
# and the test file compared to:
# cat compare_ub user_block_file.
#
-# This test uses './getub' to extract the user block from
+# This test uses './getub' to extract the user block from
# 'file.h5', which is compared to the file described above.
#
# The result is set in variable 'result1'.
#
result1=0;
CHECK_UB_1() {
- hfile="$1"
- ufile="$2"
-
- # check for third argument (the original file)
- origfile="";
- if [ -n "$3" ];
- then
- origfile="$3"
- fi
+ hfile="$1"
+ ufile="$2"
+
+ # check for third argument (the original file)
+ origfile="";
+ if [ -n "$3" ];
+ then
+ origfile="$3"
+ fi
- # find the length of the user block to check
- s1=`cat $ufile | wc -c | sed -e 's/ //g'`
- if [ "$s1" = "0" ];
- then
- echo "File "$ufile" is empty"
- result1=1;
- fi
+ # find the length of the user block to check
+ s1=`cat $ufile | wc -c | sed -e 's/ //g'`
+ if [ "$s1" = "0" ];
+ then
+ echo "File "$ufile" is empty"
+ result1=1;
+ fi
- # Get the size of the original user block, if any.
- if [ -n "$origfile" ];
- then
- # 'tellub' calls H5Fget_user_block to get the size
- # of the user block
- s2=`$JAM_BIN/tellub $origfile`
- if [ "$s2" = "0" ];
- then
- size=$s1;
- cmpfile=$ufile
- else
- cmpfile="tt2"
- size=`expr $s2 + $s1`
- $JAM_BIN/getub -c $s2 $origfile > $cmpfile
- cat $ufile >> $cmpfile
- fi
- else
- # assume no user block
- s2="0"
- size=$s1;
- cmpfile=$ufile
- fi
+ # Get the size of the original user block, if any.
+ if [ -n "$origfile" ];
+ then
+ # 'tellub' calls H5Fget_user_block to get the size
+ # of the user block
+ s2=`$JAM_BIN/tellub $origfile`
+ if [ "$s2" = "0" ];
+ then
+ size=$s1;
+ cmpfile=$ufile
+ else
+ cmpfile="tt2"
+ size=`expr $s2 + $s1`
+ $JAM_BIN/getub -c $s2 $origfile > $cmpfile
+ cat $ufile >> $cmpfile
+ fi
+ else
+ # assume no user block
+ s2="0"
+ size=$s1;
+ cmpfile=$ufile
+ fi
- # Extract 'size' bytes from the front of 'hfile'
- # Compare to 'cmpfile', result is set in result1
- tfile="tt1"
- $JAM_BIN/getub -c $size $hfile > $tfile
- res=`cmp $cmpfile $tfile`
- if [ "$?" != "0" ];
- then
- echo $res
- result1=1;
- else
- result1=0;
- fi
+ # Extract 'size' bytes from the front of 'hfile'
+ # Compare to 'cmpfile', result is set in result1
+ tfile="tt1"
+ $JAM_BIN/getub -c $size $hfile > $tfile
+ res=`cmp $cmpfile $tfile`
+ if [ "$?" != "0" ];
+ then
+ echo $res
+ result1=1;
+ else
+ result1=0;
+ fi
- # clean up
- rm -f $tfile
- if [ "$s2" != "0" ] ;
- then
- rm -f $cmpfile
- fi
+ # clean up
+ rm -f $tfile
+ if [ "$s2" != "0" ] ;
+ then
+ rm -f $cmpfile
+ fi
}
@@ -321,10 +321,10 @@ CHECK_UB_1() {
result2=0;
CHECK_NOUB() {
- hfile="$1"
+ hfile="$1"
- # call 'ubsize' to get the size of the user block
- ubsize=`$JAM_BIN/tellub $hfile`
+ # call 'ubsize' to get the size of the user block
+ ubsize=`$JAM_BIN/tellub $hfile`
if [ "$?" != "0" ];
then
@@ -351,119 +351,119 @@ CHECK_NOUB() {
# 3. check the user block is correct in the output (Check_UB)
# If the user block is correct, print "PASSED", else "*FAILED*"
JAMTEST() {
- ufile="$1"
- ifile="$2"
- compare_test="" # the file to test
- compare_orig="" # the comparison to test against
- cleanup=""
-
- # sort out the arguments for the test and the check
- do_clobber="no"
- if [ "$3" = "--clobber" ];
- then
- # clobber overwrites any existing user block
- do_clobber="yes"
- clobber="--clobber"
- compare_orig=""
- if [ -z "$4" ];
- then
- # output goes to infile, compare ubfile to infile
- ofile=""
- compare_test="$ifile"
- else
- # output goes to $4, compare ofile to ubfile
- ofile="$4"
- compare_test="$ofile"
- fi
- else
- clobber=""
- # add user block to existing ub, if any
- if [ -z "$3" ];
- then
- # output goes to infile, compare ubfile to infile
- ofile=""
- compare_test="$ifile"
- cp $ifile xxofile.h5
- compare_orig="xxofile.h5"
- cleanup="$cleanup $compare_orig"
- else
- # output goes to $3, compare ofile to ubfile
- ofile="$3"
- compare_test="$ofile"
- compare_orig="$ifile"
- fi
- fi
+ ufile="$1"
+ ifile="$2"
+ compare_test="" # the file to test
+ compare_orig="" # the comparison to test against
+ cleanup=""
+
+ # sort out the arguments for the test and the check
+ do_clobber="no"
+ if [ "$3" = "--clobber" ];
+ then
+ # clobber overwrites any existing user block
+ do_clobber="yes"
+ clobber="--clobber"
+ compare_orig=""
+ if [ -z "$4" ];
+ then
+ # output goes to infile, compare ubfile to infile
+ ofile=""
+ compare_test="$ifile"
+ else
+ # output goes to $4, compare ofile to ubfile
+ ofile="$4"
+ compare_test="$ofile"
+ fi
+ else
+ clobber=""
+ # add user block to existing ub, if any
+ if [ -z "$3" ];
+ then
+ # output goes to infile, compare ubfile to infile
+ ofile=""
+ compare_test="$ifile"
+ cp $ifile xxofile.h5
+ compare_orig="xxofile.h5"
+ cleanup="$cleanup $compare_orig"
+ else
+ # output goes to $3, compare ofile to ubfile
+ ofile="$3"
+ compare_test="$ofile"
+ compare_orig="$ifile"
+ fi
+ fi
- # call 'jam' with the appropriate arguments
- if [ -n "$ofile" ];
- then
- TESTING h5jam -u `basename $ufile` -i `basename $ifile` -o `basename $ofile` $clobber
- $JAM_BIN/$JAM -u $ufile -i $ifile -o $ofile $clobber
- else
- TESTING jam -u `basename $ufile` -i `basename $ifile` $clobber
- $JAM_BIN/$JAM -u $ufile -i $ifile $clobber
- fi
+ # call 'jam' with the appropriate arguments
+ if [ -n "$ofile" ];
+ then
+ TESTING h5jam -u `basename $ufile` -i `basename $ifile` -o `basename $ofile` $clobber
+ $JAM_BIN/$JAM -u $ufile -i $ifile -o $ofile $clobber
+ else
+ TESTING jam -u `basename $ufile` -i `basename $ifile` $clobber
+ $JAM_BIN/$JAM -u $ufile -i $ifile $clobber
+ fi
- #echo "CHECK_UB_1 $compare_test $ufile $compare_orig"
- CHECK_UB_1 $compare_test $ufile $compare_orig
+ #echo "CHECK_UB_1 $compare_test $ufile $compare_orig"
+ CHECK_UB_1 $compare_test $ufile $compare_orig
- if [ "$result1" = "0" ] ;
- then
- echo " PASSED"
- else
- echo " *FAILED*"
- nerrors="`expr $nerrors + 1`"
- fi
- CLEANUP $cleanup
+ if [ "$result1" = "0" ] ;
+ then
+ echo " PASSED"
+ else
+ echo " *FAILED*"
+ nerrors="`expr $nerrors + 1`"
+ fi
+ CLEANUP $cleanup
}
-
+
# UNJAMTEST file.h5 [- | --delete] ofile
#
# Test the 'unjam' tool
#
###fix the working directory here and in jamtest
UNJAMTEST () {
- infile="$1"
- ofile="$3"
- if [ "$2" = "-" ];
- then
- uofile="uofile"
- TESTING h5unjam -i `basename $infile` -o `basename $ofile` "> "`basename $uofile`
- $JAM_BIN/$UNJAM -i $infile -o $ofile > $uofile
- else
- if [ "$2" = "--delete" ];
- then
- uofile="none"
- TESTING h5unjam -i `basename $infile` -o `basename $ofile` --delete
- $JAM_BIN/$UNJAM -i $infile -o $ofile --delete
+ infile="$1"
+ ofile="$3"
+ if [ "$2" = "-" ];
+ then
+ uofile="uofile"
+ TESTING h5unjam -i `basename $infile` -o `basename $ofile` "> "`basename $uofile`
+ $JAM_BIN/$UNJAM -i $infile -o $ofile > $uofile
+ else
+ if [ "$2" = "--delete" ];
+ then
+ uofile="none"
+ TESTING h5unjam -i `basename $infile` -o `basename $ofile` --delete
+ $JAM_BIN/$UNJAM -i $infile -o $ofile --delete
- else
- uofile="$2"
- TESTING h5unjam -i `basename $infile` -u `basename $uofile` -o `basename $ofile`
- $JAM_BIN/$UNJAM -i $infile -u $uofile -o $ofile
- fi
- fi
+ else
+ uofile="$2"
+ TESTING h5unjam -i `basename $infile` -u `basename $uofile` -o `basename $ofile`
+ $JAM_BIN/$UNJAM -i $infile -u $uofile -o $ofile
+ fi
+ fi
- result1=0
- result2=0
- cleanup=""
- if [ "$uofile" != "none" ];
- then
- # sets result1
- CHECK_UB_1 $infile $uofile
- CLEANUP $uofile
- fi
+ result1=0
+ result2=0
+ cleanup=""
+ if [ "$uofile" != "none" ];
+ then
+ # sets result1
+ CHECK_UB_1 $infile $uofile
+ CLEANUP $uofile
+ fi
- # sets result2
- CHECK_NOUB $ofile
+ # sets result2
+ CHECK_NOUB $ofile
- if [ "$result1" = "0" -a "$result2" = "0" ];
- then
- echo " PASSED"
- else
- echo " *FAILED*"
- nerrors="`expr $nerrors + 1`"
- fi
+ if [ "$result1" = "0" -a "$result2" = "0" ];
+ then
+ echo " PASSED"
+ else
+ echo " *FAILED*"
+ nerrors="`expr $nerrors + 1`"
+ fi
}
@@ -500,28 +500,30 @@ TOOLTEST_OUTPUT() {
STDOUT_FILTER $actual
cp $actual_err $actual_err_sav
STDERR_FILTER $actual_err
- # combine stderr to stdout for output compare
+ # combine stderr to stdout for output compare
cat $actual_err >> $actual
if [ ! -f $expect ]; then
- # Create the expect file if it doesn't yet exist.
+ # Create the expect file if it doesn't yet exist.
echo " CREATED"
cp $actual $expect
- rm -f $actual $actual_sav $actual_err $actual_err_sav
+ echo " Expected result (*.ls) missing"
+ nerrors="`expr $nerrors + 1`"
+ rm -f $actual $actual_sav $actual_err $actual_err_sav
elif $CMP $expect $actual; then
echo " PASSED"
- rm -f $actual $actual_sav $actual_err $actual_err_sav
+ rm -f $actual $actual_sav $actual_err $actual_err_sav
else
echo "*FAILED*"
- echo " Expected result differs from actual result"
- nerrors="`expr $nerrors + 1`"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
fi
}
##############################################################################
##############################################################################
-### T H E T E S T S ###
+### T H E T E S T S ###
##############################################################################
##############################################################################
# prepare for test
@@ -550,19 +552,19 @@ CHECKFILE $TESTDIR/tall.h5 ta5.h5
CLEANUP ta5.h5
SETUP $TESTDIR/tall.h5 ta6.h5
-JAMTEST $TESTDIR/u10.txt ta6.h5
+JAMTEST $TESTDIR/u10.txt ta6.h5
CHECKFILE $TESTDIR/tall.h5 ta6.h5
CLEANUP ta6.h5
SETUP $TESTDIR/tall.h5 ta7.h5
-JAMTEST $TESTDIR/u511.txt ta7.h5
+JAMTEST $TESTDIR/u511.txt ta7.h5
CHECKFILE $TESTDIR/tall.h5 ta7.h5
CLEANUP ta7.h5
SETUP $TESTDIR/tall.h5 ta8.h5
-JAMTEST $TESTDIR/u512.txt ta8.h5
+JAMTEST $TESTDIR/u512.txt ta8.h5
CHECKFILE $TESTDIR/tall.h5 ta8.h5
CLEANUP ta8.h5
SETUP $TESTDIR/tall.h5 ta9.h5
-JAMTEST $TESTDIR/u513.txt ta9.h5
+JAMTEST $TESTDIR/u513.txt ta9.h5
CHECKFILE $TESTDIR/tall.h5 ta9.h5
CLEANUP ta9.h5
@@ -592,29 +594,29 @@ JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub513.h5 tax9.h5
CHECKFILE $TESTDIR/tall.h5 tax9.h5
CLEANUP tax9.h5
-JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub.h5 --clobber taz2.h5
+JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub.h5 --clobber taz2.h5
CHECKFILE $TESTDIR/tall.h5 taz2.h5
CLEANUP taz2.h5
JAMTEST $TESTDIR/u511.txt $TESTDIR/twithub.h5 --clobber taz3.h5
CHECKFILE $TESTDIR/tall.h5 taz3.h5
CLEANUP taz3.h5
-JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub.h5 --clobber taz4.h5
+JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub.h5 --clobber taz4.h5
CHECKFILE $TESTDIR/tall.h5 taz4.h5
CLEANUP taz4.h5
JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub.h5 --clobber taz5.h5
CHECKFILE $TESTDIR/tall.h5 taz5.h5
CLEANUP taz5.h5
-JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub513.h5 --clobber taz6.h5
+JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub513.h5 --clobber taz6.h5
CHECKFILE $TESTDIR/tall.h5 taz6.h5
CLEANUP taz6.h5
JAMTEST $TESTDIR/u511.txt $TESTDIR/twithub513.h5 --clobber taz7.h5
CHECKFILE $TESTDIR/tall.h5 taz7.h5
CLEANUP taz7.h5
-JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub513.h5 --clobber taz8.h5
+JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub513.h5 --clobber taz8.h5
CHECKFILE $TESTDIR/tall.h5 taz8.h5
CLEANUP taz8.h5
-JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub513.h5 --clobber taz9.h5
+JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub513.h5 --clobber taz9.h5
CHECKFILE $TESTDIR/tall.h5 taz9.h5
CLEANUP taz9.h5
@@ -653,7 +655,7 @@ CHECKFILE $TESTDIR/tall.h5 tay9.h5
CLEANUP tay9.h5
#---------------------------------
-# Testing h5unjam
+# Testing h5unjam
#---------------------------------
# help page
TOOLTEST_OUTPUT UNJAM h5unjam-help.txt 0 -h