diff options
author | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-09-28 16:29:02 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-09-28 16:29:02 (GMT) |
commit | 5c7ca8afff0e635f12652c35dbe9818235ac34c4 (patch) | |
tree | 1245d78ca4b0aaeb40ecab6b2615ddad886042c3 /test/testvfdswmr.sh.in | |
parent | 06fa8a94558939400dc43e99c08a784e26dfa01d (diff) | |
download | hdf5-5c7ca8afff0e635f12652c35dbe9818235ac34c4.zip hdf5-5c7ca8afff0e635f12652c35dbe9818235ac34c4.tar.gz hdf5-5c7ca8afff0e635f12652c35dbe9818235ac34c4.tar.bz2 |
Third batch of checkin:
1) Free space manager for the metadata file
2) Delayed free space release linked list
3) H5F_update_vfd_swmr_metadata_file()
3) VFD SWMR driver: read callback
4) Flushing for VFD SWMR
5) Port one concurrent test from swmr test set
6) Bug fixes and refactoring
Diffstat (limited to 'test/testvfdswmr.sh.in')
-rw-r--r-- | test/testvfdswmr.sh.in | 292 |
1 files changed, 292 insertions, 0 deletions
diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in new file mode 100644 index 0000000..a0b5aee --- /dev/null +++ b/test/testvfdswmr.sh.in @@ -0,0 +1,292 @@ +#! /bin/bash +# +# 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 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. +# +# Tests for the vfd swmr feature. +# +############################################################################### +# Copied current SWMR concurrent tests and renamed to: +# testswmr.sh.in-->test_vfd_swmr.sh.in +# swmr_generator.c-->vfd_swmr_generator.c +# swmr_reader.c-->vfd_swmr_reader.c +# swmr_writer.c-->vfd_swmr_writer.c +# +# FOR NOW: only one test is copied +############################################################################### + +srcdir=@srcdir@ + +############################################################################### +## test parameters +############################################################################### + +Nreaders=1 # number of readers to launch +Nrdrs_spa=3 # number of sparse readers to launch +Nrecords=200000 # number of records to write +Nrecs_rem=40000 # number of times to shrink +Nrecs_spa=20000 # number of records to write in the sparse test +Nsecs_add=5 # number of seconds per read interval +Nsecs_rem=3 # number of seconds per read interval +Nsecs_addrem=8 # number of seconds per read interval +nerrors=0 + +############################################################################### +## definitions for message file to coordinate test runs +############################################################################### +WRITER_MESSAGE=SWMR_WRITER_MESSAGE # The message file created by writer that the open is complete + # This should be the same as the define in "./swmr_common.h" +MESSAGE_TIMEOUT=300 # Message timeout length in secs + # This should be the same as the define in "./h5test.h" + +############################################################################### +## short hands and function definitions +############################################################################### +##DPRINT=: # Set to "echo Debug:" for debugging printing, +DPRINT="echo Debug:" # Set to "echo Debug:" for debugging printing, + # else ":" for noop. +##IFDEBUG=: # Set to null to turn on debugging, else ":" for noop. +IFDEBUG= # Set to null to turn on debugging, else ":" for noop. + +# 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' +} + +# To wait for the writer message file or till the maximum # of seconds is reached +# $1 is the message file to wait for +# This performs similar function as the routine h5_wait_message() in test/h5test.c +WAIT_MESSAGE() { + message=$1 # Get the name of the message file to wait for + t0=`date +%s` # Get current time in seconds + difft=0 # Initialize the time difference + mexist=0 # Indicate whether the message file is found + while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out + do + t1=`date +%s` # Get current time in seconds + difft=`expr $t1 - $t0` # Calculate the time difference + if [ -e $message ]; then # If message file is found: + mexist=1 # indicate the message file is found + rm $message # remove the message file + break # get out of the while loop + fi + done; + if test $mexist -eq 0; then + # Issue warning that the writer message file is not found, continue with launching the reader(s) + echo warning: $WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds + else + echo $WRITER_MESSAGE is found + fi +} + +############################################################################### +## Main +## +## Modifications: +## Vailin Choi; July 2013 +## Add waiting of message file before launching the reader(s). +## Due to the implementation of file locking, coordination +## is needed in file opening for the writer/reader tests +## to proceed as expected. +## +############################################################################### +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +./swmr_check_compat_vfd +rc=$? +if [ $rc -ne 0 ] ; then + echo + echo "The VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR." + echo + echo "SWMR acceptance tests skipped" + echo + exit 0 +fi + +# Parse options (none accepted at this time) +while [ $# -gt 0 ]; do + case "$1" in + *) # unknown option + echo "$0: Unknown option ($1)" + exit 1 + ;; + esac +done + +# HDF5 has several tests that create and delete signal files to communicate +# between processes, and it seems that even though the names of the files are +# different, occasionally the wrong file is deleted, interrupting the flow of +# the test. Running each of these tests in its own directory should eliminate +# the problem. +mkdir vfd_swmr_test +for FILE in vfd_swmr*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + cp $FILE vfd_swmr_test +done +cp vfd_swmr* vfd_swmr_test + +# With the --disable-shared option, swmr program files are built in the test +# directory, otherwise they are in test/.libs with a corresponding wrapper +# script in the test directory. The programs or wrapper scripts in test should +# always be copied, swmr files in .libs should be copied only if they exists. +if [ -f .libs/swmr ]; then + mkdir vfd_swmr_test/.libs + for FILE in .libs/vfd_swmr*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + cp $FILE vfd_swmr_test/.libs + done +fi + +cd vfd_swmr_test + +# Loop over index types +for index_type in "-i ea" "-i b2" +do + # Try with and without compression + for compress in "" "-c 5" + do + echo + echo "*******************************************************************************" + echo "** Loop testing parameters: $index_type $compress" + echo "*******************************************************************************" + echo + echo + echo "###############################################################################" + echo "## Generator test" + echo "###############################################################################" + # Launch the Generator without SWMR_WRITE + echo launch the vfd_swmr_generator + ./vfd_swmr_generator $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Launch the Generator with SWMR_WRITE + echo launch the vfd_swmr_generator with SWMR_WRITE + ./vfd_swmr_generator -s $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occured + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + exit 1 + fi + + echo + echo "###############################################################################" + echo "## Writer test - test expanding the dataset" + echo "###############################################################################" + + # Launch the Generator + echo launch the vfd_swmr_generator + ./vfd_swmr_generator -s $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Remove any possible writer message file before launching writer + rm -f $WRITER_MESSAGE + # + # Launch the Writer + echo launch the vfd_swmr_writer + seed="" # Put -r <random seed> command here + ./vfd_swmr_writer -o $Nrecords $seed 2>&1 |tee vfd_swmr_writer.out & + pid_writer=$! + $DPRINT pid_writer=$pid_writer + + # Wait for message from writer process before starting reader(s) + WAIT_MESSAGE $WRITER_MESSAGE + # + # Launch the Readers + #declare -a seeds=(<seed1> <seed2> <seed3> ... ) + echo launch $Nreaders vfd_swmr_readers + pid_readers="" + n=0 + while [ $n -lt $Nreaders ]; do + #seed="-r ${seeds[$n]}" + seed="" + ./vfd_swmr_reader $Nsecs_add $seed 2>&1 |tee vfd_swmr_reader.out.$n & + pid_readers="$pid_readers $!" + n=`expr $n + 1` + done + $DPRINT pid_readers=$pid_readers + $IFDEBUG ps + + # Collect exit code of the readers first because they usually finish + # before the writer. + for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi + done + + # Collect exit code of the writer + $DPRINT checked writer $pid_writer + wait $pid_writer + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occured + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "VFD SWMR tests failed with $nerrors errors." + echo "(Writer and reader output preserved)" + exit 1 + fi + + # Clean up output files + ##rm -f vfd_swmr_writer.out + ##rm -f vfd_swmr_reader.out.* + + done +done + +############################################################################### +## Report and exit +############################################################################### +cd .. +$DPRINT nerrors=$nerrors +if test $nerrors -eq 0 ; then + echo "VFD SWMR tests passed." + if test -z "$HDF5_NOCLEANUP"; then + # delete the test directory + rm -rf vfd_swmr_test + fi + exit 0 +else + echo "VFD SWMR tests failed with $nerrors errors." + exit 1 +fi + |