Ignore:
Timestamp:
Jan 20, 2006, 5:30:39 PM (15 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
0f1590b
Parents:
f52fed0
Message:

2006-01-20 Joel Sherrill <joel@…>

  • psim: Enhance to add limit on how long a single test is allowed to execute. This can be used to significantly enhance the reliability of long batch test runs.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/psim/tools/psim

    rf52fed0 r4398f42  
    1414
    1515TREE_FILE=psim_tree.${LOGNAME}
     16RUN=powerpc-rtems4.7-run
     17
     18
     19progname=${0##*/}        # fast basename hack for ksh, bash
     20
     21USAGE=\
     22"usage: $progname [ -opts ] test [ test ... ]
     23        -v         -- verbose
     24        -l limit   -- specify time limit (default is 'no limit')
     25"
     26
     27#   log an error to stderr
     28prerr()
     29{
     30    echo "$*" >&2
     31}
     32
     33fatal() {
     34    [ "$1" ] && prerr $*
     35    prerr "$USAGE"
     36    exit 1
     37}
     38
     39warn() {
     40    [ "$1" ] && prerr $*
     41}
     42
     43#
     44# process the options
     45#
     46# defaults for getopt vars
     47#
     48
     49verbose=""
     50limit="0"
     51
     52while getopts vl: OPT
     53do
     54    case "$OPT" in
     55        v)
     56            verbose="yes";;
     57        l)
     58            limit="$OPTARG";;
     59        *)
     60            fatal;;
     61    esac
     62done
     63shiftcount=`expr $OPTIND - 1`
     64shift $shiftcount
     65
     66args=$*
    1667
    1768# RUN_DEBUG="-t sem_device"
     
    2980# echo "/sem@0xc0010000/value -1"                       >> ${TREE_FILE}
    3081
    31 RUN=powerpc-rtems4.7-run
    32 ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} $*
     82runtest()
     83{
     84  testname=${1}
     85  max_run_time=${2}
     86  if [ ${max_run_time} -eq 0 ] ; then
     87    #echo run ${testname} forever
     88    ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname}
     89  else
     90    #echo run ${testname} for maximum ${max_run_time} seconds
     91    ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname} &
     92    pid=$!
    3393
     94    # Make sure it won't run forever...
     95    time_run=0
     96    while [ $time_run -lt $max_run_time ]
     97    do
     98      # sleep 5s at a time waiting for job to finish or timer to expire
     99      # if job has exited, then we exit, too.
     100      sleep 1
     101      kill -0 $pid 2> /dev/null
     102      running=$?
     103      if [ $running -eq 0 ] ; then
     104        time_run=$((time_run + 5))
     105        if [ $time_run -ge $max_run_time ]; then
     106          kill -9 $pid 2> /dev/null
     107          ran_too_long="yes"
     108          echo "${testname} killed after running ${max_run_time} seconds"
     109        fi
     110      else
     111        ran_too_long="no"
     112        break
     113      fi
     114    done
     115  fi
     116}
     117
     118runtest ${1} ${limit}
     119rm -f ${TREE_FILE}
    34120exit $?
    35121
Note: See TracChangeset for help on using the changeset viewer.