summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-01-20 17:30:39 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-01-20 17:30:39 +0000
commit4398f42c8805fb05df28136344268849bed179a8 (patch)
treecef59d23f1dd6691b2c5b893eacd3fc3eb85a00e /c
parent2006-01-20 Ralf Corsepius <ralf.corsepius@rtems.org> (diff)
downloadrtems-4398f42c8805fb05df28136344268849bed179a8.tar.bz2
2006-01-20 Joel Sherrill <joel@OARcorp.com>
* 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.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/powerpc/psim/tools/ChangeLog6
-rwxr-xr-xc/src/lib/libbsp/powerpc/psim/tools/psim90
2 files changed, 94 insertions, 2 deletions
diff --git a/c/src/lib/libbsp/powerpc/psim/tools/ChangeLog b/c/src/lib/libbsp/powerpc/psim/tools/ChangeLog
index e4f0f1badb..f836e900fe 100644
--- a/c/src/lib/libbsp/powerpc/psim/tools/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/psim/tools/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-20 Joel Sherrill <joel@OARcorp.com>
+
+ * 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.
+
2006-01-08 Joel Sherrill <joel@OARcorp.com>
* psim, psim-gdb: Add setting of PVR to 0xfffe0000 since psim needs a
diff --git a/c/src/lib/libbsp/powerpc/psim/tools/psim b/c/src/lib/libbsp/powerpc/psim/tools/psim
index 7e4f77d2b2..5ac8b3cb3c 100755
--- a/c/src/lib/libbsp/powerpc/psim/tools/psim
+++ b/c/src/lib/libbsp/powerpc/psim/tools/psim
@@ -13,6 +13,57 @@
#
TREE_FILE=psim_tree.${LOGNAME}
+RUN=powerpc-rtems4.7-run
+
+
+progname=${0##*/} # fast basename hack for ksh, bash
+
+USAGE=\
+"usage: $progname [ -opts ] test [ test ... ]
+ -v -- verbose
+ -l limit -- specify time limit (default is 'no limit')
+"
+
+# log an error to stderr
+prerr()
+{
+ echo "$*" >&2
+}
+
+fatal() {
+ [ "$1" ] && prerr $*
+ prerr "$USAGE"
+ exit 1
+}
+
+warn() {
+ [ "$1" ] && prerr $*
+}
+
+#
+# process the options
+#
+# defaults for getopt vars
+#
+
+verbose=""
+limit="0"
+
+while getopts vl: OPT
+do
+ case "$OPT" in
+ v)
+ verbose="yes";;
+ l)
+ limit="$OPTARG";;
+ *)
+ fatal;;
+ esac
+done
+shiftcount=`expr $OPTIND - 1`
+shift $shiftcount
+
+args=$*
# RUN_DEBUG="-t sem_device"
@@ -28,8 +79,43 @@ echo "/openprom/options/oea-memory-size 8388608" >> ${TREE_FILE}
# echo "/sem@0xc0010000/key ${RTEMS_SHM_SEMAPHORE_KEY}" >> ${TREE_FILE}
# echo "/sem@0xc0010000/value -1" >> ${TREE_FILE}
-RUN=powerpc-rtems4.7-run
-${RUN} -f ${TREE_FILE} ${RUN_DEBUG} $*
+runtest()
+{
+ testname=${1}
+ max_run_time=${2}
+ if [ ${max_run_time} -eq 0 ] ; then
+ #echo run ${testname} forever
+ ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname}
+ else
+ #echo run ${testname} for maximum ${max_run_time} seconds
+ ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname} &
+ pid=$!
+
+ # Make sure it won't run forever...
+ time_run=0
+ while [ $time_run -lt $max_run_time ]
+ do
+ # sleep 5s at a time waiting for job to finish or timer to expire
+ # if job has exited, then we exit, too.
+ sleep 1
+ kill -0 $pid 2> /dev/null
+ running=$?
+ if [ $running -eq 0 ] ; then
+ time_run=$((time_run + 5))
+ if [ $time_run -ge $max_run_time ]; then
+ kill -9 $pid 2> /dev/null
+ ran_too_long="yes"
+ echo "${testname} killed after running ${max_run_time} seconds"
+ fi
+ else
+ ran_too_long="no"
+ break
+ fi
+ done
+ fi
+}
+runtest ${1} ${limit}
+rm -f ${TREE_FILE}
exit $?