source: rtems-testing/rtems-coverage/run_coverage @ 85c521d

4.11
Last change on this file since 85c521d was 85c521d, checked in by Joel Sherrill <joel.sherrill@…>, on May 2, 2014 at 2:14:18 PM

rtems-testing: Use eval bash instead of full path

  • Property mode set to 100755
File size: 4.1 KB
Line 
1#! /bin/sh
2#
3#  Script to help running coverage profiles
4#
5
6vfile=`dirname $0`/VERSIONS-COVERAGE
7if [ ! -r ${vfile} ] ; then
8  echo VERSIONS-COVERAGE file not found
9  exit 1
10fi
11
12source ${vfile}
13
14if [ ! -d ${BASEDIR} ] ; then
15  echo Have you set the BASEDIR in VERSIONS correctly?
16  exit 1
17fi
18
19progname=${0##*/}        # fast basename hack for ksh, bash
20
21USAGE=\
22"usage: $progname [ -opts ] cmd [ more cmds]
23        -t        -- publish the results to ftp site (default=yes)
24        -f        -- save the results locally (default=yes)
25        -v         -- verbose
26
27where cmds are:
28  update          - to update the RTEMS and Test Support source
29  BSP_TESTSET     - to perform TESTSET on BSP
30                    TESTSET may be baseline, O2, or Os
31"
32
33#   log an error to stderr
34prerr()
35{
36    echo "$*" >&2
37}
38
39fatal() {
40    prerr "$USAGE"
41    [ "$1" ] && (prerr ; prerr $*);
42    exit 1
43}
44
45warn() {
46    [ "$1" ] && prerr $*
47}
48
49check_status()
50{
51  if [ $1 -ne 0 ] ; then
52    shift
53    echo "FAILED: " "$*" >&2
54    exit 1
55  fi
56}
57
58toggle()
59{
60  case $1 in
61    no)  echo "yes" ;;
62    yes) echo "no" ;;
63    *)   fatal "Unknown value to toggle ($1)" ;;
64  esac
65}
66
67do_one()
68{
69  bsp=${1}
70  shift
71  echo "time ${COVBASE}/do_coverage -A -v -u -m ${SAVE} ${PUBLISH} ${*} -B ${bsp}"
72  time ${COVBASE}/do_coverage -A -v -u -m ${SAVE} ${PUBLISH} ${*} -B ${bsp}
73  check_status $? "FAILED ${bsp}"
74  rm -rf b-${bsp} ${bsp}-tests
75}
76
77validate_bsp()
78{
79  case ${1} in
80    edb7312|gumstix|smdk2410)    ;; # ARM
81    pc386|qemu)                  ;; # i386
82    lm32_evr)                    ;; # lm32
83    uC5282)                      ;; # m68k/Coldfire
84    qemuppc)                     ;; # PowerPC
85    erc32|leon2|leon3)           ;; # SPARC
86    *)
87      echo "ERROR - does BSP (${bsp}) really exist and support coverage?"
88      exit 1
89  esac
90}
91
92verbose="no"
93do_publish="yes"
94do_save_tarballs="yes"
95
96while getopts ftv OPT
97do
98
99    case "$OPT" in
100      f) do_publish=`toggle ${do_publish}` ;;
101      t) do_save_tarballs=`toggle ${do_save_tarballs}` ;;
102      v) verbose=`toggle ${verbose}` ;;
103      *) fatal;;
104    esac
105done
106
107# Set the publish and save options
108if [ ${do_publish} = "yes" ] ; then
109  PUBLISH="-f"
110fi
111if [ ${do_save_tarballs} = "yes" ] ; then
112  SAVE="-t"
113fi
114
115shiftcount=`expr $OPTIND - 1`
116shift $shiftcount
117
118args=$*
119
120if [ $# -eq 0 ] ; then
121  echo "No actions requested"
122  exit 0
123fi
124
125for cmd in $*
126do
127  case ${cmd} in
128    update) ;;                       # general command
129    *_O[sS2][pP][dD]|*_baseline)            # one BSP at specific -Ox level
130      case ${cmd} in
131        lm32_evr*) bsp=lm32_evr ;;
132        *)         bsp=`echo $cmd | sed -e 's/_.*$//'` ;;
133      esac
134      validate_bsp ${bsp}
135      ;;
136    *)
137      echo "Unknown command (${cmd})"
138      exit 1
139      ;;
140  esac
141done
142
143START=`date`
144
145cd ${BASEDIR}
146
147RESULTSDIR=${BASEDIR}/covrun-results
148test -d ${RESULTSDIR} || mkdir -p ${RESULTSDIR}
149for cmd in $*
150do
151echo $cmd
152  case ${cmd} in
153    update)
154      time ${COVBASE}/do_coverage -u -m -B erc32
155      ;;
156    *_O[sS2][pP][dD])
157      bsp=`echo $cmd | sed -e 's/_O.*$//'`
158      args=`echo $cmd | sed -e 's/^.*_//'`
159      Olevel=`echo $cmd | sed -e 's/.*_O\(.\).*$/\1/'`
160      posix=`echo $cmd | sed -e 's/.*_O.\(.\).*$/\1/'`
161      devel=`echo $cmd | sed -e 's/.*_O..\(.\)$/\1/'`
162
163      echo $bsp $args $Olevel $posix $devel
164      optArg="-S"
165      if [ ${Olevel} = "2" ] ; then
166        optArg=""
167      fi
168      posixArg=""
169      if [ ${posix} = "p" ] ; then
170        posixArg="-P"
171      fi
172      develArg=""
173      if [ ${devel} = "d" ] ; then
174        develArg="-D"
175      fi
176
177      # echo do_one ${bsp} ${optArg} ${posixArg} ${develArg}
178      do_one ${bsp} ${optArg} ${posixArg} ${develArg}
179      ;;
180    *_baseline)
181      bsp=`echo $cmd | sed -e 's/_baseline$//'`
182      # Each run does both developmental and core.  So this is 8 configurations
183      do_one ${bsp} -S          # -Os / POSIX enabled
184      do_one ${bsp} -S -P       # -Os / POSIX disabled
185      do_one ${bsp}             # -O2 / POSIX enabled
186      do_one ${bsp}    -P       # -O2 / POSIX disabled
187      ;;
188    *)
189      echo "Unknown command (${cmd})"
190      exit 1
191      ;;
192  esac
193done
194
195STOP=`date`
196echo "STARTED AT: " ${START}
197echo "STOPPED AT: " ${STOP}
198
199exit 0
Note: See TracBrowser for help on using the repository browser.