2001-02-23 05:53:56 +08:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
2007-02-08 03:56:21 +08:00
|
|
|
# Copyright by The HDF Group.
|
2003-04-01 02:08:23 +08:00
|
|
|
# Copyright by the Board of Trustees of the University of Illinois.
|
|
|
|
# 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 files COPYING and Copyright.html. COPYING can be found at the root
|
|
|
|
# of the source code distribution tree; Copyright.html can be found at the
|
|
|
|
# root level of an installed copy of the electronic HDF5 document set and
|
|
|
|
# is linked from the top-level documents page. It can also be found at
|
2007-02-08 03:56:21 +08:00
|
|
|
# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
|
|
|
|
# access to either file, you may request a copy from help@hdfgroup.org.
|
2001-02-23 05:53:56 +08:00
|
|
|
#
|
|
|
|
# Tests for the h5ls tool
|
|
|
|
|
2010-06-08 07:44:27 +08:00
|
|
|
TESTNAME=h5ls
|
|
|
|
EXIT_SUCCESS=0
|
|
|
|
EXIT_FAILURE=1
|
|
|
|
|
2001-02-23 05:53:56 +08:00
|
|
|
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
|
|
|
|
|
2009-02-27 04:21:50 +08:00
|
|
|
WORDS_BIGENDIAN="@WORDS_BIGENDIAN@"
|
|
|
|
|
2001-02-23 05:53:56 +08:00
|
|
|
nerrors=0
|
|
|
|
verbose=yes
|
2010-06-09 02:22:11 +08:00
|
|
|
h5haveexitcode=yes # default is yes
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# The build (current) directory might be different than the source directory.
|
|
|
|
if test -z "$srcdir"; then
|
|
|
|
srcdir=.
|
|
|
|
fi
|
|
|
|
test -d ../testfiles || mkdir ../testfiles
|
|
|
|
|
2010-06-09 02:22:11 +08:00
|
|
|
# RUNSERIAL is used. Check if it can return exit code from executalbe correctly.
|
|
|
|
if [ -n "$RUNSERIAL_NOEXITCODE" ]; then
|
|
|
|
echo "***Warning*** Serial Exit Code is not passed back to shell corretly."
|
|
|
|
echo "***Warning*** Exit code checking is skipped."
|
|
|
|
h5haveexitcode=no
|
|
|
|
fi
|
|
|
|
|
2001-02-23 05:53:56 +08:00
|
|
|
# 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"
|
2007-12-07 03:21:46 +08:00
|
|
|
actual_err="../testfiles/`basename $1 .ls`.err"
|
2001-02-23 05:53:56 +08:00
|
|
|
shift
|
2007-12-04 05:56:19 +08:00
|
|
|
retvalexpect=$1
|
|
|
|
shift
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# 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 "$@"
|
2007-12-07 03:21:46 +08:00
|
|
|
) >$actual 2>$actual_err
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
exitcode=$?
|
2007-12-07 03:21:46 +08:00
|
|
|
cat $actual_err >> $actual
|
2010-06-09 02:22:11 +08:00
|
|
|
if [ $h5haveexitcode = 'yes' -a $exitcode -ne $retvalexpect ]; then
|
2001-02-23 05:53:56 +08:00
|
|
|
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
|
2007-12-07 03:21:46 +08:00
|
|
|
rm -f $actual $actual_err
|
2001-02-23 05:53:56 +08:00
|
|
|
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
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST help-1.ls 0 -w80 -h
|
|
|
|
TOOLTEST help-2.ls 0 -w80 -help
|
|
|
|
TOOLTEST help-3.ls 0 -w80 -?
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test simple command
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tall-1.ls 0 -w80 tall.h5
|
|
|
|
TOOLTEST tall-2.ls 0 -w80 -r -d tall.h5
|
|
|
|
TOOLTEST tgroup.ls 0 -w80 tgroup.h5
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
TOOLTEST tgroup-3.ls 0 -w80 tgroup.h5/g1
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for displaying groups
|
2007-12-04 05:56:19 +08:00
|
|
|
# The following combination of arguments is expected to return an error message
|
|
|
|
# and return value 1
|
|
|
|
TOOLTEST tgroup-1.ls 1 -w80 -r -g tgroup.h5
|
|
|
|
TOOLTEST tgroup-2.ls 0 -w80 -g tgroup.h5/g1
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for displaying simple space datasets
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tdset-1.ls 0 -w80 -r -d tdset.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for displaying soft links
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tslink-1.ls 0 -w80 -r tslink.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
2010-06-02 23:13:13 +08:00
|
|
|
# test for displaying more soft links with --follow-symlinks
|
|
|
|
TOOLTEST tsoftlinks-1.ls 0 --follow-symlinks tsoftlinks.h5
|
|
|
|
TOOLTEST tsoftlinks-2.ls 0 --follow-symlinks -r tsoftlinks.h5
|
|
|
|
TOOLTEST tsoftlinks-3.ls 0 --follow-symlinks tsoftlinks.h5/group1
|
|
|
|
TOOLTEST tsoftlinks-4.ls 0 --follow-symlinks -r tsoftlinks.h5/group1
|
|
|
|
TOOLTEST tsoftlinks-5.ls 0 --follow-symlinks tsoftlinks.h5/soft_dset1
|
|
|
|
|
|
|
|
# test for displaying external and user-defined links with --follow-symlinks
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST textlink-1.ls 0 -w80 -r textlink.h5
|
2010-06-02 23:13:13 +08:00
|
|
|
TOOLTEST textlinksrc-1.ls 0 -w80 --follow-symlinks -r textlinksrc.h5
|
|
|
|
TOOLTEST textlinksrc-2.ls 0 -w80 --follow-symlinks -rv textlinksrc.h5/ext_link5
|
|
|
|
TOOLTEST textlinksrc-3.ls 0 -w80 --follow-symlinks -r textlinksrc.h5/ext_link1
|
2008-10-07 22:54:26 +08:00
|
|
|
TOOLTEST textlinksrc-4.ls 0 -w80 -r textlinksrc.h5
|
|
|
|
TOOLTEST textlinksrc-5.ls 0 -w80 -r textlinksrc.h5/ext_link1
|
2010-06-02 23:13:13 +08:00
|
|
|
TOOLTEST textlinksrc-6.ls 0 -w80 --follow-symlinks textlinksrc.h5
|
|
|
|
TOOLTEST textlinksrc-7.ls 0 -w80 --follow-symlinks textlinksrc.h5/ext_link1
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tudlink-1.ls 0 -w80 -r tudlink.h5
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2010-06-02 23:13:13 +08:00
|
|
|
# test for displaying external links with -E
|
|
|
|
# the option -E will be depriciated but keep it for backward compatibility
|
|
|
|
TOOLTEST textlinksrc-1-old.ls 0 -w80 -Er textlinksrc.h5
|
|
|
|
TOOLTEST textlinksrc-2-old.ls 0 -w80 -Erv textlinksrc.h5/ext_link5
|
|
|
|
TOOLTEST textlinksrc-3-old.ls 0 -w80 -Er textlinksrc.h5/ext_link1
|
|
|
|
TOOLTEST textlinksrc-6-old.ls 0 -w80 -E textlinksrc.h5
|
|
|
|
TOOLTEST textlinksrc-7-old.ls 0 -w80 -E textlinksrc.h5/ext_link1
|
|
|
|
|
2010-07-08 02:52:04 +08:00
|
|
|
# tests for no-dangling-links
|
|
|
|
# if this option is given on dangling link, h5ls should return exit code 1
|
|
|
|
# when used alone , expect to print out help and return exit code 1
|
|
|
|
TOOLTEST textlinksrc-nodangle-1.ls 1 -w80 --no-dangling-links textlinksrc.h5
|
|
|
|
# external dangling link - expected exit code 1
|
|
|
|
TOOLTEST textlinksrc-nodangle-2.ls 1 -w80 --follow-symlinks --no-dangling-links textlinksrc.h5
|
|
|
|
# soft dangling link - expected exit code 1
|
|
|
|
TOOLTEST tsoftlinks-nodangle-1.ls 1 -w80 --follow-symlinks --no-dangling-links tsoftlinks.h5
|
|
|
|
# when used file with no dangling links - expected exit code 0
|
|
|
|
TOOLTEST thlinks-nodangle-1.ls 0 -w80 --follow-symlinks --no-dangling-links thlink.h5
|
|
|
|
|
|
|
|
|
2001-02-23 05:53:56 +08:00
|
|
|
# tests for hard links
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST thlink-1.ls 0 -w80 thlink.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# tests for compound data types
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tcomp-1.ls 0 -w80 -r -d tcompound.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
#test for the nested compound type
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tnestcomp-1.ls 0 -w80 -r -d tnestedcomp.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for loop detection
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tloop-1.ls 0 -w80 -r -d tloop.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for string
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tstr-1.ls 0 -w80 -r -d tstr.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test test file created from lib SAF team
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tsaf.ls 0 -w80 -r -d tsaf.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for variable length data types
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tvldtypes1.ls 0 -w80 -r -d tvldtypes1.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for array data types
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tarray1.ls 0 -w80 -r -d tarray1.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
|
|
|
# test for empty data
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tempty.ls 0 -w80 -d tempty.h5
|
2001-02-23 05:53:56 +08:00
|
|
|
|
2003-05-23 06:31:07 +08:00
|
|
|
# test for all dataset types written to attributes
|
|
|
|
# enable -S for avoiding printing NATIVE types
|
2007-12-04 05:56:19 +08:00
|
|
|
TOOLTEST tattr2.ls 0 -w80 -v -S tattr2.h5
|
2003-05-23 06:31:07 +08:00
|
|
|
|
2006-08-04 11:59:24 +08:00
|
|
|
# tests for error handling.
|
|
|
|
# test for non-existing file
|
2010-04-28 04:22:48 +08:00
|
|
|
TOOLTEST nosuchfile.ls 1 nosuchfile.h5
|
2006-08-04 11:59:24 +08:00
|
|
|
|
2009-01-13 23:37:37 +08:00
|
|
|
# test for variable length data types in verbose mode
|
2009-02-27 04:21:50 +08:00
|
|
|
if test $WORDS_BIGENDIAN != "yes"; then
|
|
|
|
TOOLTEST tvldtypes2le.ls 0 -v tvldtypes1.h5
|
|
|
|
else
|
|
|
|
TOOLTEST tvldtypes2be.ls 0 -v tvldtypes1.h5
|
|
|
|
fi
|
|
|
|
|
2009-01-13 23:37:37 +08:00
|
|
|
|
|
|
|
# test for dataset region references data types in verbose mode
|
2009-02-27 04:21:50 +08:00
|
|
|
if test $WORDS_BIGENDIAN != "yes"; then
|
|
|
|
TOOLTEST tdataregle.ls 0 -v tdatareg.h5
|
|
|
|
else
|
|
|
|
TOOLTEST tdataregbe.ls 0 -v tdatareg.h5
|
|
|
|
fi
|
|
|
|
|
2009-01-13 23:37:37 +08:00
|
|
|
|
2001-02-23 05:53:56 +08:00
|
|
|
if test $nerrors -eq 0 ; then
|
2010-06-08 07:44:27 +08:00
|
|
|
echo "All $TESTNAME tests passed."
|
|
|
|
exit $EXIT_SUCCESS
|
|
|
|
else
|
|
|
|
echo "$TESTNAME tests failed with $nerrors errors."
|
|
|
|
exit $EXIT_FAILURE
|
2001-02-23 05:53:56 +08:00
|
|
|
fi
|