Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /tests/rtest/scripts/run_sh.in
ViewVC logotype

View of /tests/rtest/scripts/run_sh.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5223 - (download) (annotate)
Thu Jul 27 21:42:48 2017 UTC (21 months, 3 weeks ago) by jhr
File size: 5384 byte(s)
  Add support for "--double" option in regression tests
#!/bin/ksh
#
# A script for running the Diderot regression tests.
#
# usage:
#	scripts/run.sh [diderotc] [diderotc-flags] [-- runtime-flags]
#
# Tests live in the "tests" subdirectory. For a test named "foo", we should have
#
#	tests/foo			-- the test directory
#	tests/foo/foo.diderot		-- the test source code
#	tests/foo/assess.sh		-- an assessment script that should either return a
#					   numeric result representing the difference, or one
#					   of "ok" or "fail".  This script is given the
#					   '--double' flag if it was specified as one of the
#					   diderotc flags.
#	tests/foo/correct.{nrrd,txt}	-- the correct output.  Usually a nrrd file, but
#					   some tests produce textual output
#       tests/Makefile                  -- optional makefile for building the application
#	tests/foo/run.sh		-- optional script for running the application
#
# @configure_input@
#

# set up the path so that we can find unu
#
PATH=/bin:/usr/bin:@TEEM_DIR@/bin

function usage {
  echo "usage:"
  echo "  scripts/run.sh [diderotc] [diderotc-flags] [-- runtime-flags]"
  exit $1
}

# function to cleanup
# function to report success
#
# usage: success <test> <result>
function success {
  t=$1
  result=$2
  echo "result is good ($result)" >> $REPORT
  echo "ok" >> $LOG
  echo "$t is okay"
  if [ -f Makefile ] ; then
    make -s clean
  else
    rm -f $t $t.o $t.cxx $t.cl $t.log out.nrrd out.txt
  fi
}

# function to report test failure
function failure {
  t=$1
  result=$2
  echo "result is bad ($result)" >> $REPORT
  echo "fail ($result)" >> $LOG
  echo "$t failed"
  rm -f $t.cxx $t.o $t
}

# this script should be run from the rtest directory
#
HERE=$(pwd)
if [ ! -d $HERE/tests ] ; then
  echo "run script from rtest directory"
  exit 1
fi

# process command-line arguments
#
DIDEROTC="@DIDEROTC@"
DIDEROTC_FLAGS=""
RUNTIME_FLAGS=""
PARALLEL="no"
DOUBLE=""
if [ $# -ne 0 ] ; then
  # first we check for the diderotc command
  case $1 in
    -*) ;; # no diderot command
    /*) DIDEROTC=$1; shift ;; # absolute path
    *) DIDEROTC=$HERE/$1; shift ;; #relative path
  esac
  # get diderotc flags; we check for the "--target=parallel" and
  # "--double" options, since they affect how we build and assess
  # tests (resp.)
  while [ $# -ne 0 ] ; do
    case $1 in
      --) shift; break ;; # switch modes
      --target=pthread|--target=parallel)
        PARALLEL=yes
        DIDEROTC_FLAGS="$DIDEROTC_FLAGS $1"
      ;;
      --double) DOUBLE=$1 ;;
      -*) DIDEROTC_FLAGS="$DIDEROTC_FLAGS $1" ;;
      *) echo "unrecognized argument"
        usage 1
      ;;
    esac
    shift
  done
  # get runtime flags
  while [ $# -ne 0 ] ; do
    case $1 in
      -*) RUNTIME_FLAGS="$RUNTIME_FLAGS $1" ;;
      *) echo "unrecognized argument"
        usage 1
      ;;
    esac
    shift
  done
fi

#
# check that the diderotc path is valid
#
if [ ! -x $DIDEROTC ] ; then
  echo "$DIDEROTC is not executable or does not exist"
  exit 1
fi

# get a list of all of the tests (one per directory)
#
TESTS=$(cd tests; ls)

DATE=$( date +"%F-%H-%M-%S" )
LOG=$HERE/log.$DATE
REPORT=$HERE/report.$DATE

NUMTESTS=0
NUMFAILS=0
BUILD_FAILURES=""
RUN_FAILURES=""
RESULT_FAILURES=""
echo "testing $DIDEROTC $DIDEROTC_FLAGS" > $REPORT
for t in $TESTS ; do
  cd $HERE/tests/$t;
  NUMTESTS=$(($NUMTESTS+1))
  echo "********** $t **********" >> $LOG
  echo -n "checking $t ... " >> $REPORT
  if [ -f Makefile ] ; then
    echo "make DIDEROTC_FLAGS=$DIDEROTC_FLAGS PARALLEL=$PARALLEL" >> $LOG
    make -s clean
    make DIDEROTC_FLAGS="$DIDEROTC_FLAGS" PARALLEL="$PARALLEL" 2>> $LOG 1>> $LOG
  else
    echo "$DIDEROTC --exec $DIDEROTC_FLAGS $t.diderot" >> $LOG
    $DIDEROTC --exec $DIDEROTC_FLAGS $t.diderot 2>> $LOG 1>> $LOG
  fi
  if [ "$?" -eq "0" ] ; then
    echo -n "compile succeeded ... " >> $REPORT
    if [ -x ./run.sh ] ; then
      # test has run.sh script
      STS=$?
      echo "./run.sh $RUNTIME_FLAGS" >> $LOG
      ./run.sh $RUNTIME_FLAGS 2>> $LOG 1>> $LOG
      STS=$?
    else
      echo "./$t $RUNTIME_FLAGS" >> $LOG
      ./$t $RUNTIME_FLAGS 2>> $LOG 1>> $LOG
      STS=$?
    fi
    if [ "$STS" -eq "0" ] ; then
      echo -n "execution succeeded ... " >> $REPORT
      result=$(./assess.sh $DOUBLE)
      case $result in
	ok) success $t $result ;;
	fail)
	  NUMFAILS=$(($NUMFAILS+1))
          RESULT_FAILURES="$RESULT_FAILURES $t"
	  failure $t $result
	;;
	*)
	  if (($result < 1.0)) ; then
	    success $t $result
	  else
	    NUMFAILS=$(($NUMFAILS+1))
            RESULT_FAILURES="$RESULT_FAILURES $t"
	    failure $t $result
	  fi
	;;
      esac
    else
      let NUMFAILS=$(($NUMFAILS+1))
      echo "execution failed" >> $REPORT
      echo "$t failed"
      RUN_FAILURES="$RUN_FAILURES $t"
    fi
  else
    let NUMFAILS=$(($NUMFAILS+1))
    echo "compile failed" >> $REPORT
    echo "$t failed"
    BUILD_FAILURES="$BUILD_FAILURES $t"
  fi
  echo "**********" >> $LOG
done
cd $HERE

if (($NUMFAILS == 0)) ; then
  echo "**** all $NUMTESTS tests passed; complete report at $REPORT"
else
  echo "!!!! $NUMFAILS out of $NUMTESTS tests failed"
  if [ x"$BUILD_FAILURES" != x ] ; then
    echo "  !! build failures: $BUILD_FAILURES"
  fi
  if [ x"$RUN_FAILURES" != x ] ; then
    echo "  !! run failures:   $RUN_FAILURES"
  fi
  if [ x"$RESULT_FAILURES" != x ] ; then
    echo "  !! bad results:    $RESULT_FAILURES"
  fi
  echo "  !! complete report at $REPORT"
fi

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0