source: rtems-testing/rtems-coverage/do_coverage @ dc795fa

4.11
Last change on this file since dc795fa was dc795fa, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 29, 2009 at 7:05:48 PM

2009-09-29 Joel Sherrill <joel.sherrill@…>

  • ObjdumpProcessor?.cc, do_coverage, run_coverage: Add initial powerpc/qemuppc support.
  • Property mode set to 100755
File size: 13.4 KB
Line 
1#! /bin/sh
2#
3#  Script to perform a single coverage test run on a single BSP
4#  in a specific configuration.  This script automates all steps
5#  of building RTEMS, running the tests, and generating the reports.
6#
7#  $Id$
8#
9
10vfile=`dirname $0`/VERSIONS-COVERAGE
11if [ ! -r ${vfile} ] ; then
12  echo VERSIONS-COVERAGE file not found
13  exit 1
14fi
15
16source ${vfile}
17
18if [ ! -d ${BASEDIR} ] ; then
19  echo Have you set the BASEDIR in VERSIONS correctly?
20  exit 1
21fi
22
23progname=${0##*/}        # fast basename hack for ksh, bash
24
25USAGE=\
26"usage: $progname [ -opts ]
27        -v        -- verbose (default=no)
28        -A        -- Execute all steps (default=no)
29        -B BSP    -- Specify BSP to test
30        -P        -- Enable POSIX API (default=yes)
31        -D        -- Enable Developmental Coverage (default=no)
32        -S        -- Optimize for size (default=no)
33        -m        -- Update and build covMerge (default=no)
34        -u        -- Do CVS update on RTEMS (default=no)
35        -c        -- Configure RTEMS (default=no)
36        -b        -- Build RTEMS (default=no)
37        -C        -- copy tests from build to test execution point (default=no)
38        -r        -- run the tests (default=no)
39        -f        -- publish the results to ftp site (default=no)
40        -R        -- generate a report (default=no)
41
42Notes:  + There are currently NO checks at each step to determine if
43          the previous steps were performed!!!
44        + Use of each option toggles the setting.  For example, \"-v -v -A -u\"
45          results in verbose=no and all steps done except CVS update on RTEMS.
46
47"
48
49#   log an error to stderr
50prerr()
51{
52    echo "$*" >&2
53}
54
55fatal() {
56    prerr "$USAGE"
57    [ "$1" ] && (prerr ; prerr $*);
58    exit 1
59}
60
61warn() {
62    [ "$1" ] && prerr $*
63}
64
65check_status()
66{
67  if [ $1 -ne 0 ] ; then
68    shift
69    echo "FAILED: " "$*" >&2
70    exit 1
71  fi
72}
73
74toggle()
75{
76  case $1 in
77    no)  echo "yes" ;;
78    yes) echo "no" ;;
79    *)   fatal "Unknown value to toggle ($1)" ;;
80  esac
81}
82
83# parse arguments for these
84verbose="no"
85do_all="no"
86do_posix="yes"
87do_developmental="no"
88do_optimize_size="no"
89do_covmerge="no"
90do_rtems_update="no"
91do_rtems_configure="no"
92do_rtems_build="no"
93do_copy_tests="no"
94do_run_tests="no"
95do_report="no"
96do_publish="yes"
97BSP="not_set"
98
99while getopts vB:PDSmAucbCrRf OPT
100do
101    case "$OPT" in
102        A)
103          do_all="yes"
104          do_covmerge="yes"
105          do_posix="yes"
106          do_rtems_update="yes"
107          do_rtems_configure="yes"
108          do_rtems_build="yes"
109          do_copy_tests="yes"
110          do_run_tests="yes"
111          do_report="yes"
112          do_publish="yes"
113          ;;
114        B) BSP="${OPTARG}";;
115        v) verbose=`toggle ${verbose}` ;;
116        m) do_covmerge=`toggle ${do_covmerge}` ;;
117        P) do_posix=`toggle ${do_posix}` ;;
118        D) do_developmental=`toggle ${do_developmental}` ;;
119        S) do_optimize_size=`toggle ${do_optimize_size}` ;;
120        u) do_rtems_update=`toggle ${do_rtems_update}` ;;
121        c) do_rtems_configure=`toggle ${do_rtems_configure}` ;;
122        b) do_rtems_build=`toggle ${do_rtems_build}` ;;
123        C) do_copy_tests=`toggle ${do_copy_tests}` ;;
124        r) do_run_tests=`toggle ${do_run_tests}` ;;
125        R) do_report=`toggle ${do_report}` ;;
126        f) do_publish=`toggle ${do_publish}` ;;
127        *) fatal;;
128    esac
129done
130
131#  If we are to update or configure RTEMS, then we need to clean the
132#  RTEMS build tree up.
133do_clean="no"
134if [ ${do_rtems_update} = "yes" -o \
135     ${do_rtems_configure} = "yes" ] ; then
136  do_clean="yes"
137fi
138
139# allow bsp override
140if [ ${BSP} == "not_set" ] ; then
141  fatal "No BSP selected"
142fi
143
144# you can't publish unless ftp directory is accessible
145if [ ${do_publish} = "yes" ] ; then
146  if [ ! -d ${FTPDIR} ] ; then
147    fatal "Publishing results requested and ${FTPDIR} does not exist"
148  fi
149fi
150
151# For most BSPs, there is a script with the same name as the BSP.
152RUNNER=${BSP}
153
154case ${BSP} in
155  pc386)
156    CPU=i386
157    COVERAGE_FORMAT=RTEMS
158    RTEMS_EXTRA_ARGS="USE_COM1_AS_CONSOLE=1"
159    RTEMS_EXTRA_ARGS="${RTEMS_EXTRA_ARGS} BSP_PRESS_KEY_FOR_RESET=0"
160    ;;
161  uC5282)
162    CPU=m68k
163    COVERAGE_FORMAT=RTEMS
164    ;;
165  qemuppc)
166    CPU=powerpc
167    COVERAGE_FORMAT=RTEMS
168    ;;
169  erc32|leon2|leon3)
170    CPU=sparc
171    COVERAGE_FORMAT=TSIM
172    ;;
173  edb7312|rtl22xx|gumstix|smdk2410)
174    CPU=arm
175    COVERAGE_FORMAT=Skyeye
176    RTEMS_EXTRA_ARGS="ON_SKYEYE=1"
177    ;;
178  *)
179    fatal "Unsupported BSP (${BSP}) for coverage analysis."
180    ;;
181esac
182
183if [ ${RTEMS_VERSION} = 4.6 ] ; then
184  TARGET=${CPU}-rtems
185else
186  TARGET=${CPU}-rtems${RTEMS_VERSION}
187fi
188
189##### VERBOSE
190print_verbose()
191{
192  echo "BSP:                " ${BSP}
193  echo "Target:             " ${TARGET}
194  echo "do_all:             " ${do_all}
195  echo "do_covmerge         " ${do_covmerge}
196  echo "do_posix:           " ${do_posix}
197  echo "do_developmental:   " ${do_developmental}
198  echo "do_optimize_size:   " ${do_optimize_size}
199  echo "do_rtems_update:    " ${do_rtems_update}
200  echo "do_rtems_configure: " ${do_rtems_configure}
201  echo "do_rtems_build:     " ${do_rtems_build}
202  echo "do_copy_tests:      " ${do_copy_tests}
203  echo "do_run_tests:       " ${do_run_tests}
204  echo "do_report:          " ${do_report}
205  echo "Clean Before:       " ${do_clean}
206}
207
208if [ ${verbose} = "yes" ] ; then
209  print_verbose
210fi
211
212# Basic error checking and sanity checking on the directory structure
213# and PATH
214if [ ! -d ${COVBASE} ] ; then
215  echo You do not have ${COVBASE}
216  exit 1
217fi
218
219if [ ! -d ${RTEMSDIR} ] ; then
220  echo "Check out RTEMS!!!"
221  exit 1
222fi
223
224grep _COVERAGE ${RTEMSDIR}/c/src/make/leaf.cfg >/dev/null
225if [ $? -ne 0 ] ; then
226  echo "It doesn't look like you patched the RTEMS source for coverage."
227  exit 1
228fi
229
230type ${TARGET}-gcc
231check_status $? "Path appears to be broken"
232
233# Start real action
234NM=${TARGET}-nm
235type ${NM}
236check_status $? "Cannot find ${NM} on PATH"
237
238if [ ${do_optimize_size} = yes ] ; then
239 c_opt=-Os
240else
241 c_opt=-O2
242fi
243
244EXTENSION=${c_opt}
245if [ ${do_posix} = yes ] ; then
246  EXTENSION=${EXTENSION}P
247else
248  EXTENSION=${EXTENSION}p
249fi
250
251if [ ${do_developmental} = yes ] ; then
252  EXTENSION=${EXTENSION}D
253else
254  EXTENSION=${EXTENSION}d
255fi
256
257day=`date +%Y%m%d`
258hour=`date +%H`
259minute=`date +%M`
260results_dir=${BSP}${EXTENSION}-${day}-${hour}${minute}
261
262echo "Testing ${TARGET}/${BSP} at optimization (${c_opt})"
263
264# print a data element in table
265print_element()
266{
267  echo "  <TD>"${*}"</TD>"
268}
269
270# generate table row of results in html
271generate_html()
272{
273  echo "<TR>"
274    print_element ${day}
275    print_element ${hour}:${minute}
276    print_element ${c_opt}
277    print_element ${do_posix}
278    print_element ${do_developmental}
279    print_element `grep "uncovered range" summary.txt | cut -d ' ' -f1`
280    print_element `grep "age Not Exec" summary.txt | cut -d ':' -f2`
281    print_element `grep "age Exec" summary.txt | cut -d ':' -f2`
282    print_element `grep "Bytes Not Exec" summary.txt | cut -d ':' -f2`
283    print_element `grep "Bytes Analyzed" summary.txt | cut -d ':' -f2`
284    print_element "<A HREF=\"${results_dir}\">untarred</A> " \
285                  "<A HREF=\"${results_dir}.tar.bz2\">tarball</A> "
286  echo "</TR>"
287}
288
289# generate the coverage report set
290generate_report()
291{
292  if [ $# -ne 3 ] ; then
293    echo Usage: ${0} TARGET BSP COVERAGE_FORMAT
294    exit 1
295  fi
296
297  TARGET=${1}
298  BSP=${2}
299  COVERAGE_FORMAT=${3}
300
301  cd ${BASEDIR}/${BSP}-tests/
302  check_status $? "cd ${BSP}-tests"
303
304  ${NM} -g -n hello.exe >hello.num
305
306  # Basic validity checking
307  tlow=`grep "T ${lowsym}$" hello.num | cut -d' ' -f1`
308  if [ X${tlow} = X ] ; then
309    echo "low symbol (${lowsym}) not found"
310  fi
311  thigh=`grep "T ${highsym}$" hello.num | cut -d' ' -f1`
312  if [ X${thigh} = X ] ; then
313    echo "high symbol (${highsym}) not found"
314  fi
315
316  if [ X${tlow} = X -o X${thigh} = X ] ; then
317    echo "Did you patch RTEMS for coverage testing?"
318    exit 1
319  fi
320
321  rm -f merged.cov report.txt
322
323  ( check_endof ; \
324    echo "Optimization Level : " ${c_opt} ; \
325    echo "POSIX Enabled      : " ${do_posix} ; \
326    echo "Developmental Code : " ${do_developmental} ; \
327  ) >summary.txt
328  ${COVBASE}/covmerge \
329    -l 0x${tlow} -h 0x${thigh} \
330    -r report.txt -s sizes.txt \
331    -E ${COVBASE}/Explanations.txt \
332    -f ${COVERAGE_FORMAT} \
333    -T ${TARGET} -e hello.exe -m merged.cov *.cov        >>summary.txt
334  check_status $? "covmerge failed"
335
336  (echo "====== Largest Range Sizes (Size and Count)======" ; \
337    grep ^Size report.txt | cut -d':' -f2 | sort -n | uniq -c | \
338       tail -15 | sed -e 's/ *\([0-9]*\) *\([0-9]*\)/\2 \1/' | sort -n -r | \
339       while read l; do printf "%6d %6d\n" $l; done ; \
340    echo "=====================================" ) >>summary.txt
341
342  generate_html >row.html
343
344  cat summary.txt
345
346  # Now create the archive of information
347  rm -rf ${results_dir}
348  mkdir ${results_dir}
349  cp summary.txt report.txt sizes.txt configuration.txt \
350     annotated.dmp hello.num row.html ${results_dir}
351  cp ${COVBASE}/Explanations.txt.NotFound ${results_dir}
352  cp hello.exe ${results_dir}
353  bzip2 -9 ${results_dir}/hello.exe
354  echo "Results saved in ${results_dir}.tar.bz2"
355  tar cjf ${results_dir}.tar.bz2 ${results_dir}
356  rm -rf ${results_dir}
357}
358
359# Now we are ready to start doing real work
360start=`date`
361
362# If necessary, clean up the RTEMS build and test run directories
363if [ ${do_clean} = "yes" ] ; then
364  echo "Cleaning before building"
365  rm -rf ${BASEDIR}/b-${BSP}
366  rm -rf ${BASEDIR}/${BSP}-tests
367else
368  echo "Skipping clean before building"
369fi
370
371# If they don't exist, create the RTEMS build and test run directories
372test -d ${BASEDIR}/b-${BSP}     || mkdir ${BASEDIR}/b-${BSP}
373test -d ${BASEDIR}/${BSP}-tests || mkdir ${BASEDIR}/${BSP}-tests
374
375# If requested, update and build the coverage support tools
376if [ ${do_covmerge} = "yes" ] ; then
377  echo "Updating and building covmerge..."
378
379  cd ${COVBASE}
380  check_status $? "cd covmerge"
381
382  cvs up -Pd 2>&1 | grep -v ^cvs
383  make clean all
384  check_status $? "build covmerge"
385
386  make
387  check_status $? "make covmerge"
388else
389  echo "Skipping Updating and building covmerge..."
390fi
391
392# If requested, update the RTEMS tree
393if [ ${do_rtems_update} = "yes" ] ; then
394  echo "Updating RTEMS ..."
395  cd ${RTEMSDIR}
396  check_status $? "cd rtems"
397
398  cvs up -Pd 2>&1 | grep -v ^cvs
399  ./bootstrap -c
400  ./bootstrap
401else
402  echo "Skipping Updating RTEMS ..."
403fi
404
405# Now let's patch the make/custom file
406custom=${RTEMSDIR}/make/custom/${BSP}.cfg
407if [ ! -r ${custom} ] ; then
408  echo "Unable to read ${custom}"
409  exit 1
410fi
411
412grep "^CFLAGS_OPTIMIZE_V.*=.*-O[2s]" ${custom} >/dev/null
413if [ $? -ne 0 ] ; then
414  echo "Unable to file CFLAGS_OPTIMIZE_V in ${custom}"
415  exit 1
416fi
417
418sed -e "s/-O[2s]/${c_opt}/" <${custom} >/tmp/XXX
419mv /tmp/XXX ${custom}
420
421# If requested, configure RTEMS
422if [ ${do_rtems_configure} = "yes" ] ; then
423  echo "Configuring RTEMS..."
424  rm -rf ${BASEDIR}/b-${BSP}/
425  mkdir ${BASEDIR}/b-${BSP}/
426  cd ${BASEDIR}/b-${BSP}/
427  check_status $? "cd b-${BSP}"
428
429  ##################
430  ################## WARNING!!!!!!
431  ##################
432  ################## BE CAREFUL ABOUT THIS CONFIGURE COMMAND.  IT IS
433  ################## VERY SPECIFIC TO COVERAGE TESTING
434  ##################
435  if [ ${do_posix} = "yes" ] ; then
436    posix_en=en
437  else
438    posix_en=dis
439  fi
440
441  if [ ${do_developmental} = "yes" ] ; then
442    EXPERIMENTAL_ARG="experimental"
443  else
444    EXPERIMENTAL_ARG="yes"
445  fi
446
447  ${RTEMSDIR}/configure NDEBUG=1 \
448    RTEMS_DO_NOT_INLINE_THREAD_ENABLE_DISPATCH=1 \
449    RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE=1 \
450    RTEMS_DO_NOT_UNROLL_THREADQ_ENQUEUE_PRIORITY=1 \
451    ${RTEMS_EXTRA_ARGS} \
452    --target=${TARGET} --enable-rtemsbsp=${BSP} \
453    --enable-maintainer-mode \
454    --enable-coverage=${EXPERIMENTAL_ARG} \
455    --disable-itron --${posix_en}able-posix --enable-tests \
456    --disable-tcpip --disable-ada --disable-cxx \
457    --prefix=${BASEDIR}/coverage/install >c.log 2>&1
458  check_status $? "configuring RTEMS for ${BSP}"
459else
460  echo "Skipping Configuring RTEMS ..."
461fi
462
463# If requested, build RTEMS
464if [ ${do_rtems_build} = "yes" ] ; then
465  echo "Building RTEMS..."
466
467  cd ${BASEDIR}/b-${BSP}/
468  check_status $? "cd b-${BSP}"
469
470  make -j4 >b.log 2>&1
471  check_status $? "Building RTEMS for ${BSP}"
472else
473  echo "Skipping Building RTEMS ..."
474fi
475
476# If requested, copy the tests from the build tree to the run tree
477if [ ${do_copy_tests} = "yes" ] ; then
478  echo "Copying tests..."
479
480  # clean destination
481  rm -rf ${BASEDIR}/${BSP}-tests/*
482  check_status $? "clean test directory"
483
484  cd ${BASEDIR}/b-${BSP}/
485  check_status $? "cd b-${BSP}"
486
487  cp `find . -name *.exe` ../${BSP}-tests
488else
489  echo "Skipping copying tests..."
490fi
491
492# If requested, run the tests with coverage reporting enabled
493if [ ${do_run_tests} = "yes" ] ; then
494  echo "Running tests..."
495  cd ${BASEDIR}/${BSP}-tests/
496  check_status $? "cd ${BSP}-tests"
497
498  time ${RUNNER} -c *.exe
499else
500  echo "Skipping Running tests..."
501fi
502
503# If requested, generate the coverage report
504if [ ${do_report} = "yes" ] ; then
505  echo "Generating report..."
506
507  # Generate the configuration settings file
508  ( \
509    echo "#"
510    echo "#  Settings for this coverage test run"
511    echo "#"
512    echo
513    echo "Compiler version:   " `${TARGET}-gcc --version  | grep gcc`
514    echo "Optimization flag   " ${c_opt}
515    print_verbose
516  ) > ${BASEDIR}/${BSP}-tests/configuration.txt
517
518  cd ${BASEDIR}/${BSP}-tests/
519  check_status $? "cd ${BSP}-tests"
520
521  generate_report ${TARGET} ${BSP} ${COVERAGE_FORMAT}
522else
523  echo "Skipping Generating report..."
524fi
525
526# If requested, publish the coverage report
527if [ ${do_publish} = "yes" ] ; then
528  cp ${BASEDIR}/${BSP}-tests/${results_dir}.tar.bz2 ${FTPDIR}
529  check_status $? "cp ${BSP} results to ftp site failed"
530
531  ${COVBASE}/generate_coverage_html ${FTPDIR}
532else
533  echo "Skipping Publishing report..."
534fi
535stop=`date`
536
537echo "Started: " ${start}
538echo "Stopped: " ${stop}
539
540exit 0
541
Note: See TracBrowser for help on using the repository browser.