#!/bin/sh # # run through all example directories and run commands in the # local config file (either .runAll or .validate) # # make sure that Xplor-NIH exits without error and that the expected output # files are created. # # the .runAll file specifies one command per line with the following format: # command and input arguments are specified first and separated by two && # symbols from expected output files. If an output file is missing after # execution of the script, an error is reported. # # lines beginning with a # symbol are skipped. # # delete the files after the test # [ "$ARCH" = "" ] && ARCH=`uname` name=`echo $0 | sed 's/.*\///'` rcFile=.$name runDir=$name.$ARCH usage () { echo "$0: [option] [subdir]" echo " run scripts specified in subdir/$rcFile. If subdir is omitted," echo " tests are run in all subdirectories." echo " options:" echo " -help print this message" echo " -keep don't delete results - they will remain in subdirectory" echo " $runDir" } keep=0 while [ -n "$1" ]; do opt="$1" shift case "$opt" in -help|-h|--help) usage exit 0 ;; -keep) keep=1 ;; *) dirs="$dirs $opt" ;; esac done topDirs=. [ "$dirs" ] && topDirs=$dirs dirs=`find $topDirs -type d|grep -v CVS|grep -v '\.$'|grep -v '/run\.'` echo=/bin/echo home=`pwd` #get the right version of the xplor run scripts PATH=$home/../bin:$PATH export PATH logFilePref=xplorTest totErrs=0 for dir in $dirs; do cd $home cd $dir [ -s $rcFile ] || continue $echo "running scripts in $dir." [ -d $runDir ] && rm -rf $runDir mkdir $runDir cd $runDir lines=`grep -v "^#" ../$rcFile` IFS=' ' for file in `ls -1 ..`; do ln -s ../$file . done dirErrs=0 for line in $lines; do IFS=' ' # everything before && runCmd=`echo $line | sed 's/\(.*\)&&.*/\1/'` # everything after && outFiles=`echo $line | sed 's/.*&&\(.*\)/\1/'` # the last word in $runCmd # - or blank if no spaces present script=`echo $runCmd |\ sed 's/.*[ ]\([^ ]*\)/\1/'| sed 's/[ ]//g'` #strip out script from runCmd runCmd=`echo $runCmd | sed 's/[ ][^ ][^ ]*[ ]*$//'` printed="$runCmd $script ........................................" printed=`echo $printed|\ sed 's/^\(........................................\).*/\1../'` $echo -n " $printed" err=0 logFile="$logFilePref.$script.out" errFile="$logFilePref.$script.err" eval "$runCmd $XARGS $script 2>$errFile > $logFile" if [ $? -eq 0 ]; then cpuTime=`grep ' total CPU time=' $logFile |\ sed 's/[^0-9.]*\([0-9.]*\).*/\1/'` else err=1 echo "ERROR " fi $echo " $cpuTime" if `grep -i '[a-zA-Z]' $errFile > /dev/null`; then echo "one or more errors reported in $errFile" err=1 fi for file in $outFiles; do if [ ! -s $file ]; then echo "ERROR: file $file is missing" err=1 fi done [ $err -eq 1 ] && dirErrs=`expr $dirErrs + 1` [ $err -eq 1 ] && totErrs=`expr $totErrs + 1` done cd .. [ $keep -eq 0 ] && [ $dirErrs -eq 0 ] && rm -rf $runDir done cd $home echo "$totErrs scripts produced errors"