source: rtems/c/src/lib/libbsp/powerpc/psim/tools/psim @ 4398f42

4.104.114.84.95
Last change on this file since 4398f42 was 4398f42, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 20, 2006 at 5:30:39 PM

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.
  • Property mode set to 100755
File size: 2.7 KB
Line 
1#! /bin/sh
2#
3#  Shell script to ease invocation of the powerpc simulator
4#
5#  COPYRIGHT (c) 1989-2006.
6#  On-Line Applications Research Corporation (OAR).
7#
8#  The license and distribution terms for this file may be
9#  found in found in the file LICENSE in this distribution or at
10#  http://www.rtems.com/license/LICENSE.
11#
12#  $Id$
13#
14
15TREE_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=$*
67
68# RUN_DEBUG="-t sem_device"
69
70#  Build this user's device tree file
71echo "/#address-cells 2"                              >  ${TREE_FILE}
72echo "/openprom/init/register/pvr 0xfffe0000"         >> ${TREE_FILE}
73echo "/openprom/options/oea-memory-size 8388608"      >> ${TREE_FILE}
74
75# These require the semaphore and shared memory device models.
76# echo "/shm@0xc0000000/reg 0xc0000000 0x10000"         >> ${TREE_FILE}
77# echo "/shm@0xc0000000/key ${RTEMS_SHM_KEY}"           >> ${TREE_FILE}
78# echo "/sem@0xc0010000/reg 0xc0010000 12"              >> ${TREE_FILE}
79# echo "/sem@0xc0010000/key ${RTEMS_SHM_SEMAPHORE_KEY}" >> ${TREE_FILE}
80# echo "/sem@0xc0010000/value -1"                       >> ${TREE_FILE}
81
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=$!
93
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}
120exit $?
121
Note: See TracBrowser for help on using the repository browser.