#! /bin/sh # # 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have # access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. # # run the hdf5/bin/snapshot # Usage: # runtest run the test for the local host # runtest run the test for # runtest -all run the test for all predefined hosts # # Assumptions in knowing where to find the right scripts to execute. # 1. assume we are at the top level of the hdf5 source. So, bin/* are # where the script files are. # 2. after the cvs update is completed, we can go to the snapshot area # hdf5 source tree and use the bin/* there. # 3. Cannot use the snapshot area scripts from the beginning because # for one, the current directory is renamed as previous right after # a snapshot release; and for another, some scripts may be changed # by the cvs update while it is being used. # local setup DEBUGMODE="" test -n "$DEBUGMODE" && echo "******** DEBUGMODE is $DEBUGMODE ************" WHEREAMI='pwd' CMD= # the name of this program PROGNAME="bin/runtest $DEBUGMODE" # Setup HOSTNAME=`hostname | cut -f1 -d.` # no domain part TODAY=`date +%y%m%d` WEEKDAY=`date +%a` H5VER= # default to current CVS version H5VERSION= # default to current CVS version # Default to do checkout (only once) and test, no release. # Will run test only if there is significant differences from previous version. # If srcdir is not used, don't launched multiple tests SNAPSHOT="${DEBUGMODE:+echo }bin/snapshot" SRCDIR="srcdir" # Default standard Snaptest commands SNAPCMD="$SRCDIR test clean" # Default Standard snaptest command options STANDARD_OPT="" ENABLE_PARALLEL="--enable-parallel" CONFIGNAME=$HOSTNAME # Name used in the SNAPTESTCFG file # test host default as local host. TESTHOST="" ################################# # Function definitions ################################# # Print messages to stdout # Use this to show output heading to stdout PRINT() { echo "$*" } # Show seconds since midnight. # This is used to calculate seconds elapsed SecOfDay() { set `date '+%H %M %S'` t_sec=`expr $1 \* 3600 + $2 \* 60 + $3` echo $t_sec } # Calculated the elapsed time (in seconds) between the first # and second time. If second time is smaller than the first, # we assume the clock has passed midnight and calculate appropriately. ElapsedTime() { if [ $2 -lt $1 ]; then t_sec=`expr 3600 \* 24 - $1 + $2` else t_sec=`expr $2 - $1` fi echo `expr $t_sec / 60`m `expr $t_sec % 60`s } # Report errors # $1--an error message to be printed REPORT_ERR() { ERRMSG=$1 # print it with a banner shifted right a bit PRINT " *************************************" PRINT " `date`" PRINT " $ERRMSG" PRINT " *************************************" # report it in the FAILED-LOG file too PRINT "$ERRMSG" >> $FAILEDLOG } # # Report results of the last test done REPORT_RESULT() { if [ $retcode -eq 0 ]; then if [ $skiptest = yes ]; then PRINT "SKIPPED ${HOSTNAME}: $TEST_TYPE" | tee -a $SKIPPEDLOG else PRINT "PASSED ${HOSTNAME}: $TEST_TYPE" | tee -a $PASSEDLOG fi else # test failed. REPORT_ERR "****FAILED ${HOSTNAME}: $TEST_TYPE****" fi } # Print a blank line PRINT_BLANK() { PRINT } # Print test trailer PRINT_TEST_TRAILER() { PRINT "*** finished $TEST_TYPE tests for $HOSTNAME ***" date; EndTime=`SecOfDay` PRINT Total time = `ElapsedTime $StartTime $EndTime` PRINT_BLANK } # Print trailer summary PRINT_TRAILER() { PRINT "*** finished tests in $HOSTNAME ***" date; TotalEndTime=`SecOfDay` PRINT "${HOSTNAME}: Ran $n_test $runtest_type, Grand total test time = " \ "`ElapsedTime $TotalStartTime $TotalEndTime`" | tee -a $TIMELOG PRINT_BLANK } # Figure out which remote command to use to reach a host. # Try rsh first, then ssh. # $1--hostname to reach. CHECK_RSH() { # Figure out how to use ping command in this host. # Some hosts use "ping host count", some use "ping -c count host". # Test "ping -c 3 -w 5" since it has timeout feature. # Test "ping -c ..." style before "ping host 3" because some machines # that recognize -c treat 'ping localhost 3' as to ping host '3'. if [ -z "$PING" ]; then if ping -c 3 -w 5 localhost >/dev/null 2>&1; then PING='ping -c 3 -w 5' PINGCOUNT= elif ping -c 3 localhost >/dev/null 2>&1; then PING='ping -c 3' PINGCOUNT= elif ping localhost 3 >/dev/null 2>&1; then PING=ping PINGCOUNT=3 else # don't know how to use ping. PING=no_ping PINGCOUNT= fi fi # host=$1 # Try remote command with host if it responds to ping. # Still try it if we don't know how to do ping. if [ no_ping = "$PING" ] || $PING $host $PINGCOUNT >/dev/null 2>&1; then if rsh $host -n hostname >/dev/null 2>&1; then RSH=rsh elif ssh $host -n hostname >/dev/null 2>&1; then RSH=ssh else PRINT cannot remote command with $host RSH="NoRemoteCommand" fi else RSH="NotReachable" fi } # Wait for a file for at most number of minutes # $1--the file # $2--number of minutes # WAIT_STATUS set to: # -1 if errors encountered # 0 if file found within time limit # 1 if file not found within time limit WAITFOR() { wait_file=$1 nminutes=$2 if [ -z "$wait_file" -o ! "$nminutes" -ge 0 ] then PRINT "errors in argument of WAITFOR(): wait_file($1) or nminutes($2)" WAIT_STATUS=-1 return fi while [ ! -f $wait_file ]; do if [ $nminutes -gt 0 ]; then PRINT "Wait For $wait_file to appear" sleep 60 #sleep 1 minute else WAIT_STATUS=1 return fi nminutes=`expr $nminutes - 1` done WAIT_STATUS=0 return } # Wait till a file disappears for at most number of minutes. # Useful to wait till a lock is removed by another process. # $1--the file # $2--number of minutes # WAIT_STATUS set to: # -1 if errors encountered # 0 if file disappears within time limit # 1 if file has not disappeared within time limit WAITTILL() { wait_file=$1 nminutes=$2 if [ -z "$wait_file" -o ! "$nminutes" -ge 0 ] then PRINT "errors in argument of WAITTILL(): wait_file($1) or nminutes($2)" WAIT_STATUS=-1 return fi while [ -f $wait_file ]; do if [ $nminutes -gt 0 ]; then PRINT "Wait till $wait_file has disappeared" sleep 60 #sleep 1 minute else WAIT_STATUS=1 return fi nminutes=`expr $nminutes - 1` done WAIT_STATUS=0 return } # Run one snapshot test # $*--Types of test being run RUNSNAPTEST() { SNAPCMD_OPT="$STANDARD_OPT" # snapshot test option SRCDIRNAME=${HOSTNAME} # restore CC, PATH in case they were changed in the last test. CC="$CC_SAVED" PATH=$PATH_SAVED export PATH # DEC OSF1 needs to export PATH explicitly TEST_TYPE=$* retcode=0 skiptest=no date PRINT "*** starting $TEST_TYPE tests in $HOSTNAME ***" PRINT "Uname -a: `uname -a`" # Parse the test type and set options accordingly. # See comments of SNAPTEST_CONFIG_PARSE(). while [ $# -gt 0 ]; do case $1 in -n32) # want -n32 option SRCDIRNAME=${SRCDIRNAME}-n32 CC="cc -n32" export CC ;; parallel) # want parallel test SNAPCMD_OPT="$SNAPCMD_OPT $ENABLE_PARALLEL" SRCDIRNAME=${SRCDIRNAME}-pp ;; standard) # standard test ;; --*) # option for configure SNAPCMD_OPT="$SNAPCMD_OPT $1" ;; op-configure) # option for configure SNAPCMD_OPT="$SNAPCMD_OPT $1 $2" shift ;; op-snapshot) # option for snapshot shift SNAPCMD_OPT="$SNAPCMD_OPT $1" ;; setenv) # pass them along to snapshot set environment variable shift SNAPCMD_OPT="$SNAPCMD_OPT setenv $1 $2" shift ;; setenvN) # set environment variable with $1 values # e.g., setenvN 3 x a b c is same as setenv x="a b c". # pass them along to snapshot set environment variable shift envN=$1 shift envname=$1 SNAPCMD_OPT="$SNAPCMD_OPT setenvN $envN $envname" envalue= while test $envN -gt 0; do shift envalue="$envalue $1" envN=`expr $envN - 1` done SNAPCMD_OPT="$SNAPCMD_OPT $envalue" ;; skip) # skip this test skiptest=yes ;; srcdirname) # Use this before using parallel and -n32 since this overrides # the others. shift SRCDIRNAME=$1 ;; deploy) # deploy the built binary. shift SNAPCMD_OPT="$SNAPCMD_OPT deploy $1" ;; deploydir) # default directory for deployment. shift SNAPCMD_OPT="$SNAPCMD_OPT deploydir $1" ;; *) # unknown test PRINT "$0: unknown type of test ($1)" retcode=1 ;; esac shift done if [ $retcode -ne 0 -o $skiptest = yes ]; then errcode=$retcode return $retcode fi # Track down the zlib software ans=`$SNAPYARD/current/bin/locate_sw zlib` if [ $? = 0 ]; then Z_INC=`echo $ans | cut -f1 -d,` Z_LIB=`echo $ans | cut -f2 -d,` SNAPCMD_OPT="$SNAPCMD_OPT zlib $Z_INC,$Z_LIB" else # cannot locate zlib software. # continue the test, maybe configure can find it. : fi if [ -n "${SRCDIRNAME}" ]; then SNAPCMD_OPT="$SNAPCMD_OPT srcdirname ${SRCDIRNAME}" fi # Setup log file name to save test output THIS_MINUTE=`date +%H%M` LOGFILE=${LOGBASENAME}/${SRCDIRNAME}_${TODAY}_${THIS_MINUTE} PRINT "Running snapshot with output saved in" PRINT " $LOGFILE" (date; PRINT Hostname=$HOSTNAME) >> $LOGFILE ( cd $SNAPYARD/current $SNAPSHOT $SNAPCMD $SNAPCMD_OPT ) >> $LOGFILE 2>&1 retcode=$? [ $retcode -ne 0 ] && errcode=$retcode date >> $LOGFILE if [ $retcode -ne 0 ]; then # Dump the first 10 lines and the last 30 lines of the LOGFILE. ( nhead=10; ntail=30; echo ===Dumping first $nhead and last $ntail lines of $LOGFILE head -$nhead $LOGFILE echo "[last $ntail lines]..." tail -$ntail $LOGFILE echo ===Dumping done=== ) >> $FAILEDDETAIL fi } # configuration parsing. # Taking configuration from input. # This should be invoke with configure file as stdin. # Syntax of the configure file: # All lines started with the # are comment lines and are ignored. # Blank lines are ignored too. # Each config line starts with a "Scope" followed by test types. # # Scope can be: # standard ... # what the standard test types are. # : Do for # all: Do for all hosts. # /... Use this scope if the matches. # can be {Mon,Tue,Wed,Thu,Fri,Sat,Sun} # If no : input for a , the standard test is used. # # Test types: # standard tests defined in standard scope. # -n32 -n32 mode. Apply to 64/32 bit OS such as IRIX64. # parallel parallel mode. # op-configure