diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2011-03-07 16:37:49 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2011-03-07 16:37:49 (GMT) |
commit | 79757db4c2ba2181ab88ba23f392790782802645 (patch) | |
tree | 93075de94c95b19ee2ccc2fda9814273dd2a7791 /hl/tools/h5watch/testh5watch.sh.in | |
parent | 727b687ae6c80c9854cb53814fa1c12f27c2994c (diff) | |
download | hdf5-79757db4c2ba2181ab88ba23f392790782802645.zip hdf5-79757db4c2ba2181ab88ba23f392790782802645.tar.gz hdf5-79757db4c2ba2181ab88ba23f392790782802645.tar.bz2 |
[svn-r20196] This checkin consists of the following:
A) - Changes to add the new tool "h5watch" to High Level
- Changes to add three new High Level public routines for retrieving elements appended to a dataset
B) A patch from Mike M. to fix the H5Dflush/refresh problem:
src/H5Dpkg.h
src/H5Dint.c
src/H5D.c
C) Fix for an assertion failure in H5FS_sect_link_size() in H5FSsection.c
src/H5Dbtree2.c
h5committested; tested also on linew, duty, fred.
Diffstat (limited to 'hl/tools/h5watch/testh5watch.sh.in')
-rw-r--r-- | hl/tools/h5watch/testh5watch.sh.in | 372 |
1 files changed, 372 insertions, 0 deletions
diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in new file mode 100644 index 0000000..8451151 --- /dev/null +++ b/hl/tools/h5watch/testh5watch.sh.in @@ -0,0 +1,372 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# 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 +# 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. +# +# Tests for the h5watch tool +# +H5WATCH=h5watch # The tool name +H5WATCH_BIN=`pwd`/$H5WATCH # The path of H5WATCH +EXTEND_DSET=extend_dset # Helper to extend the dataset when watching +EXTEND_BIN=`pwd`/$EXTEND_DSET # The path of EXTEND_DSET +# +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +# +GEN_TEST=h5watchgentest # Generate HDF5 file with various datasets +GEN_TEST_BIN=`pwd`/$GEN_TEST # Path of the binary GEN_TEST +# + +CP='cp' +CMP='cmp -s' +DIFF='diff -c' +KILL='kill' +SLEEP='sleep' +NLINES=20 # Max. lines of output to display if test fails +# +# Mac OS: just to make sure echo "backslash backslash" behaves properly +if test `uname -s` = 'Darwin'; then + ECHO='/bin/echo' +else + ECHO='echo' +fi + +# Global variables +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' +} + +# +# Overall algorithm: +# +# Run a test and print PASSED or FAILED +# If a test did not return with the expected return code, +# increment the `nerrors' global variable and (if $verbose is set) display up to $NLINES +# lines of the actual output from the test. +# If the test did return the expected code, +# compare the actual output with the expected output; +# If the outputs are the same, print PASSED, +# Otherwise print FAILED and the difference between the two outputs. +# The output files are not removed if $HDF5_NOCLEANUP has a non-zero value. +# +# +# TOOLTEST(): +# +# Arguments: +# +# $1 -- expected output +# $2 -- expected return code +# $3 and on -- arguments for h5watch +TOOLTEST() { + expect="$srcdir/../testfiles/$1" + actual="../testfiles/`basename $1 .ddl`.out" + actual_err="../testfiles/`basename $1 .ddl`.err" + shift + retvalexpect=$1 + shift + # Run test. + # Stderr is included in stdout so that the diff can detect + # any unexpected output from that stream too. + TESTING $H5WATCH $@ + ( + $ECHO "#############################" + $ECHO " output for '$H5WATCH $@'" + $ECHO "#############################" + $RUNSERIAL $H5WATCH_BIN "$@" + ) > $actual 2>$actual_err + exitcode=$? + cat $actual_err >> $actual + if [ $exitcode -ne $retvalexpect ]; 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 $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 $actual_err + fi +} + +# +# TEST_WATCH(): TEST_WATCH $1 $2 $3 $4 $5 ... +# +# Arguments: +# $1 -- number of objects to watch and to extend +# $2 -- the specified file to watch and to extend +# (filename varies with $1 suffix) +# $3 -- the specified dataset to watch and to extend +# $4 -- the options to h5watch (can be NULL) +# $5 -- expected output from watching the object +# ($3, $4, $5) can be repeated for $1 times +# +# This is done to reduce the sleeping time for testing +# +TEST_WATCH() { + plist="" # plist: the list of h5watch process IDs + dlist="" # dlist: the list of dataset names to watch/extend + outlist="" # outlist: the list of expected output files with suffix ".ddl" stripped + xlist="" # xlist: the list of exit codes from extending the dataset + NUM=$1 # number of objects to watch/extend + shift + NFNAME="`basename $1 .h5`" #the file to watch and to extend stripped of suffix ".h5" + shift + ctr=1 #counter for tracking the # of objects to test + while [ $ctr -le $NUM ] ; #loop till end of all objects to test + do + actual="../testfiles/`basename $3 .ddl`.out" #the actual output + outlist="$outlist`basename $3 .ddl` " #store to the list of output names + dlist="$dlist$1 " #store to the list of datasets + # + $CP "$NFNAME.h5" "$NFNAME$ctr.h5" #copy the file to a temporary file + # + if test -z "$2"; then #compile options & object to h5watch + OBJ="$NFNAME$ctr.h5/$1" #no options, just object + else + OBJ="$2 $NFNAME$ctr.h5/$1" #option and object + fi + # + # Run h5watch and put in background, output to a file + # + TESTING $H5WATCH $OBJ + $ECHO "" + $ECHO "#############################" > $actual + $ECHO " output for '$H5WATCH $OBJ'" >>$actual + $ECHO "#############################" >>$actual + $RUNSERIAL $H5WATCH_BIN $2 "$NFNAME$ctr.h5/$1" >> $actual & + WATCH_PID=$! #get h5watch process ID + plist="$plist$! " #store to the list of process IDs + shift; shift; shift + ctr=`expr $ctr + 1` + done; + # + # Extend the list of datasets corresponding to the list of files + n=1; + for d in $dlist; do + $EXTEND_BIN "$NFNAME$n.h5" $d + xlist="$xlist$? " #store to the list of exit codes from extending the dataset + n=`expr $n + 1` + done; + # + # Sleep to make sure output is flushed out before stopping h5watch + $ECHO "Sleeping for 4 seconds..." + $SLEEP 4 + # + # Kill the list of h5watch processes + $ECHO "Killing h5watch processes..." + for p in $plist; do #kill the list of h5watch processes + $KILL $p + done + # + # Check the list of return codes from extending the dataset + # Compare the list of actual output from h5watch with the corresponding expected output + n=1 + for x in $xlist; do + outname=`$ECHO $outlist|cut -d' ' -f$n` + actual="../testfiles/$outname.out" + expect="$srcdir/../testfiles/$outname.ddl" + if [ $x -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 $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 + # + # Cleaning + rm -f "$NFNAME$n.h5" + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual + fi + n="`expr $n + 1`" + done; +} + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## +# +# +################################################################################################# +# # +# WATCH.h5: file with various types of datasets for testing-- # +# The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: # +# DSET_ONE: one-dimensional dataset # +# DSET_TWO: two-dimensional dataset # +# DSET_CMPD: one-dimensional dataset with compound type # +# DSET_CMPD_ESC: one-dimensional dataset with compound type & escape/separator characters # +# DSET_CMPD_TWO: two-dimensional dataset with compound type # +# # +# The following datasets are one-dimensional, chunked, max. dimension setting: # +# DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY # +# DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE # +# # +# The following datasets are one-dimensional: # +# DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE # +# DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR # +# # +################################################################################################# +# +# +################################################################################################# +# # +# Tests on expected failures: # +# Invalid file name # +# Unable to find dataset, invalid dataset # +# DSET_NONE and DSET_NOMAX # +# Invalid input to options --width and --polling # +# Invalid field names for -f option # +# # +################################################################################################# +# +# Generate file with various types of datasets +$GEN_TEST_BIN +# Test on --help options +TOOLTEST w-help1.ddl 0 --help +# +# Tests on expected failures +TOOLTEST w-err-dset1.ddl 1 WATCH.h5 +TOOLTEST w-err-dset2.ddl 1 WATCH.h5/group/DSET_CMPD +TOOLTEST w-err-dset-none.ddl 1 WATCH.h5/DSET_NONE +TOOLTEST w-err-dset-nomax.ddl 1 WATCH.h5/DSET_NOMAX +TOOLTEST w-err-file.ddl 1 ../WATCH.h5/DSET_CMPD +TOOLTEST w-err-width.ddl 1 --width=-8 WATCH.h5/DSET_ONE +TOOLTEST w-err-poll.ddl 1 --polling=-8 WATCH.h5/DSET_ONE +TOOLTEST w-err-poll0.ddl 1 --polling=0 WATCH.h5/DSET_ONE +# +# Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD +TOOLTEST w-err-cmpd1.ddl 1 --fields=fieldx WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd2.ddl 1 --fields=field1,field2. WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd3.ddl 1 --fields=field1,field2, WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd4.ddl 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd5.ddl 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD +# +# +################################################################################################# +# # +# Tests on extending datasets-- # +# DSET_ONE, DSET_CMPD, DSET_CMPD_ESC # +# DSET_ALLOC_EARLY, DSET_ALLOC_LATE # +# DSET_TWO, DSET_CMPD_TWO # +# # +################################################################################################# +# +# Generate file with various types of datasets +$GEN_TEST_BIN +# +# Watching and extending: WATCH1.h5/DSET_ONE, WATCH2.h5/DSET_ALLOC_EARLY, WATCH3.h5/DSET_ALLOC_LATE WATCH4.h5/DSET_CMPD +# : WATCH5.h5/DSET_TWO, WATCH6.h5/DSET_CMPD_TWO, WATCH7.h5/DDSET_CMPD_ESC +TEST_WATCH 7 WATCH.h5 DSET_ONE '' w-ext-one.ddl DSET_ALLOC_EARLY '' w-ext-early.ddl DSET_ALLOC_LATE '' w-ext-late.ddl DSET_CMPD '' w-ext-cmpd.ddl DSET_TWO '' w-ext-two.ddl DSET_CMPD_TWO '' w-ext-cmpd-two.ddl DSET_CMPD_ESC '' w-ext-cmpd-esc.ddl +# +############################ +# Tests on --fields option # +############################ +# +# Watching and extending: +# WATCH1.h5/DSET_CMPD with --fields=field1,field2 +# WATCH2.h5/DSET_CMP_TWO with --fields=field1,field2 +# WATCH3.h5/DSET_CMPD_ESC with --fields=field\,1,field2\. +# WATCH4.h5/DSET_CMPD with --fields=field1 --fields=field2 +# WATCH5.h5/DSET_CMPD_ESC with --fields=field\,1 --fields=field2\. +# WATCH6.h5/DSET_CMPD_TWO with --fields=field1 --fields=field2 +# +TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field1,field2 w-ext-cmpd-f1.ddl DSET_CMPD_TWO --fields=field1,field2 w-ext-cmpd-two-f1.ddl DSET_CMPD_ESC '--fields=field\,1,field2\.' w-ext-cmpd-esc-f1.ddl DSET_CMPD '--fields=field1 --fields=field2' w-ext-cmpd-ff1.ddl DSET_CMPD_ESC '--fields=field\,1 --fields=field2\.' w-ext-cmpd-esc-ff1.ddl DSET_CMPD_TWO '--fields=field1 --fields=field2' w-ext-cmpd-two-ff1.ddl +# +# +# +# Watching and extending: +# WATCH1.h5/DSET_CMPD with --fields=field2.b,field4 +# WATCH2.h5/DSET_CMPD_ESC with --fields=field2\..\,b,field4\ +# WATCH3.h5/DSET_CMPD_TWO with --fields=field2.b,field4 +# WATCH4.h5/DSET_CMPD with --fields=field2.b --fields=field4 +# WATCH5.h5/DSET_CMPD_ESC with --fields=field2\..\,b --fields=field4\, +# WATCH6.h5/DSET_CMPD_TWO with --fields=field2.b --fields=field4 +TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field2.b,field4 w-ext-cmpd-f2.ddl DSET_CMPD_ESC '--fields=field2\..\,b,field4\,' w-ext-cmpd-esc-f2.ddl DSET_CMPD_TWO --fields=field2.b,field4 w-ext-cmpd-two-f2.ddl DSET_CMPD '--fields=field2.b --fields=field4' w-ext-cmpd-ff2.ddl DSET_CMPD_ESC '--fields=field2\..\,b --fields=field4\,' w-ext-cmpd-esc-ff2.ddl DSET_CMPD_TWO '--fields=field2.b --fields=field4' w-ext-cmpd-two-ff2.ddl +# +# +# +# Watching and extending: +# WATCH1.h5/DSET_CMPD with --fields=field2.b.a,field2.c +# WATCH2.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a,field2\..\\K +# WATCH3.h5/DSET_CMPD_TWO with --fields=field2.b.a,field2.c +# WATCH4.h5/DSET_CMPD with --fields=field2.b.a --fields=field2.c +# WATCH5.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a --fields=field2\..\\K +# WATCH6.h5/DSET_CMPD_TWO with --fields=field2.b.a --fields=field2.c +TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field2.b.a,field2.c w-ext-cmpd-f3.ddl DSET_CMPD_ESC '--fields=field2\..\,b.a,field2\..\\K' w-ext-cmpd-esc-f3.ddl DSET_CMPD_TWO --fields=field2.b.a,field2.c w-ext-cmpd-two-f3.ddl DSET_CMPD '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-ff3.ddl DSET_CMPD_ESC '--fields=field2\..\,b.a --fields=field2\..\\K' w-ext-cmpd-esc-ff3.ddl DSET_CMPD_TWO '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-two-ff3.ddl +# +# +# +######################################################### +# # +# Tests on options: # +# --dim # +# --width, --label, --simple, --help # +# # +######################################################### +# +# Watching and extending: +# WATCH1.h5/DSET_ONE with -d option +# WATCH2.h5/DSET_TWO with --dim option +# WATCH3.h5/DSET_TWO with --width=60 option +# WATCH4.h5/DSET_CMPD with --label option +# WATCH5.h5/DSET_ONE with --simple option +TEST_WATCH 5 WATCH.h5 DSET_ONE --dim w-ext-one-d.ddl DSET_TWO --dim w-ext-two-d.ddl DSET_TWO --width=30 w-ext-two-width.ddl DSET_CMPD --label w-ext-cmpd-label.ddl DSET_ONE --simple w-ext-one-simple.ddl +# +# +# +if test $nerrors -eq 0 ; then + $ECHO "All h5watch tests passed." + exit $EXIT_SUCCESS +else + $ECHO "h5watch tests failed with $nerrors errors." + exit $EXIT_FAILURE +fi |