Changeset 3486c86 in rtems-testing


Ignore:
Timestamp:
Sep 17, 2013, 5:24:32 PM (6 years ago)
Author:
Vipul Nayyar <nayyar_vipul@…>
Branches:
4.11, 8895273c193787f84c4585a10f6d6aceb3b25dc4
Children:
eb1fcfb
Parents:
79af774
git-author:
Vipul Nayyar <nayyar_vipul@…> (09/17/13 17:24:32)
git-committer:
Gedare Bloom <gedare@…> (09/17/13 18:08:25)
Message:

Bash script to review BSP File Organization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • merge-helpers/check_submission

    r79af774 r3486c86  
    1 #
    2 #  Script to test for various things we want in a BSP when it is
    3 #  submitted.
    4 #
    5 #  Test for:
    6 #    - XXX
    7 #
    8 
    9 usage()
    10 {
    11 cat <<EOF
    12 check_submission [options] directory
    13   -b - check assuming directory is a BSP
    14   -t - check assuming directory is a test
    15   -v - verbose
    16 EOF
    17 }
    18 
    19 fatal()
    20 {
    21   usage
    22   exit 1
    23 }
    24 
    25 toggle()
    26 {
    27   case $1 in
    28     no)  echo "yes" ;;
    29     yes) echo "no" ;;
    30     *)   fatal "Unknown value to toggle ($1)" ;;
    31   esac
    32 }
    33 
    34 verbose="no"
    35 do_bsp="no"
    36 do_test="no"
    37 
    38 while getopts vbt OPT
    39 do
    40     case "$OPT" in
    41         b) do_bsp="yes" ; do_test="no"  ;;
    42         t) do_bsp="no"  ; do_test="yes" ;;
    43         v) verbose=`toggle ${verbose}` ;;
    44         *) fatal ;;
    45     esac
    46 done
    47 
    48 ########################### Grab Directory ###########################
    49 
    50 shiftcount=`expr $OPTIND - 1`
    51 shift $shiftcount
    52 
    53 basedir=${1}
    54 
    55 if [ "${basedir}X" = "X" ] ; then
    56   basedir=.
    57 fi
    58 
    59 if [ ${do_bsp} = "no" -a ${do_test} = "no" ] ; then
    60   fatal must select test or bsp check mode
    61 fi
    62 
    63 if [ ! -d ${basedir} ] ; then
    64   fatal ${basedir} is not a directory
    65 fi
    66 
    67 
    68 cd ${basedir}
    69 if [ $? -ne 0 ] ; then
    70   echo Unable to cd to ${basedir}
    71   exit 1
    72 fi
    73 
     1#! /bin/bash
     2
     3# Bash Script to find discrepancies in BSP file organization.
     4# Author : Vipul Nayyar <nayyar_vipul@yahoo.com>
     5
     6
     7filename="0"
     8# Passing --verbose turns verbose to 1 & gives the whole story, otherwise '0' to give only important stuff.
     9verbose="0"
     10faults="0"
     11# Passing --warnings turns warnings to 1 & gives all the critical & non-critical bsp file org. problems.
     12warnings="0"
     13flag="0"
     14
     15calling_path=`pwd`
     16path=""
     17
     18important="1"
     19rtems_internal=""
     20internal_done="0"
     21do_test="0"
     22format="1"
     23
     24
     25# Finds all rtems internal functions ( name starting with '_' & type specifier)
     26# that are defined in cpukit & libcpu
     27function find_rtems_internal(){
     28  if [[ $internal_done == "1" ]]; then
     29    return
     30  fi
     31  echo "Compiling list of RTEMS Internal functions ..."
     32  internal_files=""
     33
     34  for k in `find -name *.c`
     35  do
     36    for j in `grep -oE "[a-z|A-Z|0-9|_]+[\ |^][_]+[a-z|A-Z|0-9|_]*[\ ]*\(" $k`
     37    do
     38      if [[ $j == "_"* ]]; then
     39        j=${j%%\(}
     40        internal_files="$j $internal_files"
     41      fi
     42
     43    done
     44  done
     45
     46  for k in `find ../c/src/lib/libcpu/ -name *.c`
     47  do
     48    for j in `grep -oE "[a-z|A-Z|0-9|_]+[\ |^][_]+[a-z|A-Z|0-9|_]*[\ ]*\(" $k`
     49    do
     50      if [[ $j == "_"* ]]; then
     51        j=${j%%\(}
     52        internal_files="$j $internal_files"
     53      fi
     54
     55    done
     56  done
     57
     58  for k in $internal_files
     59  do
     60    if echo $rtems_internal |grep -q $k ; then
     61      echo > /dev/null
     62    else
     63      rtems_internal="$k $rtems_internal"
     64    fi
     65  done
     66
     67  internal_done="1"
     68}
     69
     70# Finds all internal functions common in bsp and (cpukit + libcpu)
     71function find_bsp_internal(){
     72  bsp_methods=""
     73  common_internal_methods=""
     74
     75# Searching for internal functions starting with '_' called(i.e ending with a ';')
     76  for i in `find -name *.c`
     77  do
     78    file_contents=`tr -d '\n' < $i | grep -oE "[ |^][_]+[a-z|A-Z|0-9|_]*[ ]*[\n]*\([^;]*\)[ ]*;" | tr -d '\n' `
     79
     80    for j in `echo "$file_contents" | grep -oE "[_]+[a-z|A-Z|0-9|_]*[ ]*\("`
     81    do
     82      if `echo "$bsp_methods" |grep -q "${j%%\(}"` ; then
     83        echo > /dev/null
     84      else
     85        bsp_methods="${j%%\(} $bsp_methods"
     86      fi
     87    done
     88  done
     89
     90# Identifying common fucntions between $rtems_interval & $bsp_methods
     91  for i in $rtems_internal
     92  do
     93    if [[ $i == "__asm__" || $i == "__attribute__" || $i == "__volatile__" || $i == "__"* ]];then
     94      continue
     95    fi
     96    for j in $bsp_methods
     97    do
     98      if [[ $i == $j ]]; then
     99        common_internal_methods="$j $common_internal_methods"
     100      fi
     101    done
     102  done
     103
     104  if [[ $common_internal_methods != "" ]]; then
     105    echo -e "$bsp : RTEMS Internal functions used : \c"
     106    for i in $common_internal_methods
     107    do
     108      echo -e "${i}() \c"
     109    done
     110    flag="1"
     111  fi
     112}
     113
     114
     115# Passing 1 initially to any check function states that the file/method/header
     116# being checked is of critical nature
     117function check_file(){
     118  filename="0"
     119  if [[ $1 == 1 ]]; then
     120    important="1"
     121    shift
     122  else
     123    important="0"
     124  fi
     125
     126#Grabbing the path of file being evaluated from Makefile.am
     127  if grep -wqE "[ ]*[^\ ]*/($1)" Makefile.am ; then
     128    file_path=`grep -woE "[ ]*[^\ ]*/($1)" Makefile.am | head --lines=1`
     129    cd `dirname $file_path`
     130    filename=$1
     131    file_path=`pwd`
     132
     133    cd - > /dev/null
     134    shift
     135
     136# Checking if file lies in correct directory path
     137    for i in $*
     138    do
     139      if [[ -d $i ]]; then
     140        cd $i
     141      else
     142        continue
     143      fi
     144
     145
     146      if [[ "$file_path" == `pwd` ]]; then
     147        filename="$file_path/$filename"
     148        cd - >/dev/null
     149        return
     150      fi
     151      cd - > /dev/null
     152    done
     153    echo "$bsp : $filename not present in correct path"
     154    filename="$file_path/$filename"
     155    return
     156  else
     157    if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]]; then
     158      flag="1"
     159      echo "$bsp : $1 not compiled"
     160    fi
     161  fi
     162
     163  filename="0"
     164  faults="1"
     165  return
     166}
     167
     168# Checking presence of functions in specific files
     169function check_methods(){
     170  if [[ $1 == 1 ]]; then
     171    important="1"
     172    shift
     173  else
     174    important="0"
     175  fi
     176
     177  for i in $*
     178  do
     179
     180# When correct file for this function does not exist
     181    if [[ $filename == "0" ]];then
     182      if grep -rqlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" * ;then
     183         if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]];then
     184          echo $bsp : ${i%(*}"()" present in file `grep -rlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" *`
     185         fi
     186      fi
     187    else
     188
     189# When correct file for this function exists
     190      if grep -Eq "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" $filename ; then
     191        if [[ $verbose -eq "1" ]] ;then
     192          echo "$bsp : `basename $filename` : ${i%(*}() present in file"
     193        fi
     194      else
     195        if grep -rqlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" * ;then
     196           if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]];then
     197            echo $bsp : ${i%(*}"()" present in file `grep -rlE "[a-z|A-Z|0-9|_]+[ ]*$i[ ]*\(" *`
     198           fi
     199        else
     200          if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]]; then
     201            echo "$bsp : `basename $filename` : ${i%(*}() function does not exist in $filename "
     202            flag="1"
     203          fi
     204            faults="1"
     205        fi
     206      fi
     207
     208    fi
     209  done
     210}
     211
     212# Checking presence of headers installed by bsp
     213function check_header(){
     214  if [[ $1 == 1 ]]; then
     215    important="1"
     216    shift
     217  else
     218    important="0"
     219  fi
     220
     221  for i in $*
     222  do
     223    if  grep -wq "$i" Makefile.am ;then
     224      if [[ ! -f "$i" && ! -f "${i}.in" ]] ;then
     225        continue
     226      fi
     227      if [[ $verbose -eq "1" ]] ;then
     228        cd `dirname $i`
     229        echo "$bsp : `basename $i` installed from directory" ${PWD##*/c/src/lib/}
     230        cd - > /dev/null
     231      fi
     232      return
     233    fi
     234  done
     235
     236  if [[ $warnings -eq "1" || $important -eq "1" || $verbose -eq "1" ]]; then
     237    echo "${bsp%%[\ ]*} : `basename $1` not installed "
     238    flag="1"
     239  fi
     240  filename="0"
     241  faults="1"
     242  return
     243
     244}
    74245
    75246test_its_there()
     
    80251  grep ${2} ${1} >/dev/null
    81252  if [ $? -ne 0 ] ; then
    82     echo "${2} is NOT in ${basedir}/${1}"
     253    echo "$bsp : ${2} is NOT in ${1##./}"
    83254  fi
    84255
     
    92263  grep -i ${2} ${1} >/dev/null
    93264  if [ $? -ne 0 ] ; then
    94     echo "${2} is NOT in ${basedir}/${1} - case independent check"
     265    echo "$bsp : ${2} is NOT in ${1##./} - case independent check"
    95266  fi
    96267
     
    106277  grep -i "${*}" ${FILE} >/dev/null
    107278  if [ $? -eq 0 ] ; then
    108     echo "(${*}) SHOULD NOT BE IN ${basedir}/${FILE} - case independent check"
     279    echo "$bsp : (${*}) SHOULD NOT BE IN ${FILE##./} - case independent check"
    109280  fi
    110281}
     
    119290  grep "${*}" ${FILE} >/dev/null
    120291  if [ $? -eq 0 ] ; then
    121     echo "(${*}) SHOULD NOT BE IN ${basedir}/${FILE}"
     292    echo "$bsp : (${*}) SHOULD NOT BE IN ${FILE##./}"
    122293  fi
    123294}
     
    126297{
    127298  findArgs=
    128   while getopts "cCm" OPT
     299  while getopts "cCdm" OPT
    129300  do
    130301   case "$OPT" in
     
    145316}
    146317
    147 # Verify no lines longer than 80 columns
    148 echo "=== Checking for lines greater than 79 columns"
    149 find_source -m -c -C | while read f
    150 do
    151   grep  ".\{80,\}" ${f} >/dev/null
    152   if [ $? -eq 0 ] ; then
    153     echo "*** ${basedir}/${f} has the following lines that are too long"
    154     grep -n '.\{80,\}' ${f}
    155   fi
    156 done
    157 
    158 # really need to make the copyright strings consistent in BSPs
    159 echo "=== Checking for copyright notices"
    160 find_source | while read f
    161 do
    162   test_its_there_all_case ${f} COPYRIGHT
    163 done
    164 
    165 # We want CVS Id strings everywhere possible
    166 echo "=== Checking for CVS Id strings"
    167 find_source -d | while read f
    168 do
    169   test_its_NOT_there ${f} "\$Id"
    170 done
    171 
    172 # We do not want the reformatted license notice
    173 echo "=== Checking for reformatted RTEMS license notices"
    174 find_source -m -c -C | while read f
    175 do
    176   test_its_NOT_there ${f} "this file may be found in the file"
    177 done
    178 
    179 # We do not want spaces at the end of lines
    180 echo "=== Checking for spaces at the end of lines"
    181 find_source -m -c -C | while read f
    182 do
    183   egrep " +$" $f >/dev/null
    184   test $? -eq 0 && echo "$f has spaces at the end of one or more lines."
    185 done
    186 
    187 # We do not want tabs in source files
    188 echo "=== Checking for tabs in source files"
    189 find_source | while read f
    190 do
    191   grep -P '\t' $f >/dev/null
    192   if [ $? -eq 0 ]; then
    193     echo "*** ${basedir}/${f} has the following lines with tabs"
    194     grep -P '\t' $f
    195   fi
    196 done
    197 
    198 # We do not want GPL code
    199 echo "=== Checking for hints of GPL code"
    200 find_source -m -c -C | while read f
    201 do
    202   test_its_NOT_there ${f} "Free Software Foundation"
    203   test_its_NOT_there ${f} "program is free software"
    204   test_its_NOT_there ${f} "General Public License"
    205 done
    206 
    207 # We do not want hints that there are things left to do
    208 echo "=== Checking for TODO hints"
    209 find_source -m -c -C | while read f
    210 do
    211   test_its_NOT_there ${f} XXX
    212   test_its_NOT_there ${f} TODO
    213   test_its_NOT_there ${f} TBD
    214 done
    215 
    216 #
    217 # BSP specific checks
    218 #
    219 if [ ${do_bsp} = "yes" ] ; then
     318function check_format(){
     319
     320  # Verify no lines longer than 80 columns
     321  echo "=== Checking for lines greater than 80 columns"
     322  find_source -m -c -C | while read f
     323  do
     324    grep  ".\{81,\}" ${f} >/dev/null
     325    if [ $? -eq 0 ] ; then
     326      echo -e "\n$bsp : ${f#./} has more than 80 character lines"
     327      for i in `grep -n '.\{80,\}' ${f} | cut -f1 -d:`
     328      do
     329        echo -e "$i \c"
     330    done
     331    fi
     332  done
     333
     334  # really need to make the copyright strings consistent in BSPs
     335  echo -e "\n=== Checking for copyright notices"
     336  find_source | while read f
     337  do
     338    test_its_there_all_case ${f} COPYRIGHT
     339  done
     340
     341  # We want CVS Id strings everywhere possible
     342  echo "=== Checking for CVS Id strings"
     343  find_source -d | while read f
     344  do
     345    test_its_NOT_there ${f} "\$Id"
     346  done
     347
     348  # We do not want the reformatted license notice
     349  echo "=== Checking for reformatted RTEMS license notices"
     350  find_source -m -c -C | while read f
     351  do
     352    test_its_NOT_there ${f} "this file may be found in the file"
     353  done
     354
     355  # We do not want spaces at the end of lines
     356  echo "=== Checking for spaces at the end of lines"
     357  find_source -m -c -C | while read f
     358  do
     359    egrep " +$" $f >/dev/null
     360    test $? -eq 0 && echo -e "${f##./} \c"
     361  done
     362
     363  # We do not want tabs in source files
     364  echo -e "\n=== Checking for tabs in source files"
     365  find_source | while read f
     366  do
     367    grep -P '\t' $f >/dev/null
     368    test $? -eq 0 && echo -e "${f##./} \c"
     369  done
     370
     371  # We do not want GPL code
     372  echo -e "\n=== Checking for hints of GPL code"
     373  find_source -m -c -C | while read f
     374  do
     375    test_its_NOT_there ${f} "Free Software Foundation"
     376    test_its_NOT_there ${f} "program is free software"
     377    test_its_NOT_there ${f} "General Public License"
     378  done
     379
     380  # We do not want hints that there are things left to do
     381  echo "=== Checking for TODO hints"
     382  find_source -m -c -C | while read f
     383  do
     384    test_its_NOT_there ${f} XXX
     385    test_its_NOT_there ${f} TODO
     386    test_its_NOT_there ${f} TBD
     387  done
     388}
     389
     390# Reviewing for a BSP Starts
     391function main(){
     392
     393  if [[ $format -eq "1" ]]; then
     394    check_format
     395  fi
     396
    220397  # We do not want stdio in a BSP
    221   echo "=== Checking for stdio"
    222   find_source -m -c -C | while read f
    223   do
    224     test_its_NOT_there ${f} printf
    225     test_its_NOT_there ${f} "puts("
    226   done
    227 
    228   # BSPs should include RTEMS_BSP_CLEANUP_OPTIONS and maybe
    229   #   RTEMS_BSP_BOOTCARD_OPTIONS
    230   if [ -r configure.ac ] ; then
    231     echo "=== Checking for RTEMS_BSP_BOOTCARD_OPTIONS in BSP configure.ac"
    232     test_its_not_there configure.ac RTEMS_BSP_BOOTCARD_OPTIONS
    233     echo "=== Checking for RTEMS_BSP_CLEANUP_OPTIONS in BSP configure.ac"
    234     test_its_there configure.ac RTEMS_BSP_CLEANUP_OPTIONS
    235   fi
    236 
    237   # If not using -O2, then we really want to know
    238   # BSPs should normally use -O2
    239   echo "=== Checking for not using -O2"
    240   grep -H "\-O[013456789]" make/custom/*.cfg
    241 
    242   # BSPs should not turn on extra warnings
    243   echo "=== Checking for turning on extra GCC warning checks"
    244   grep -H "\-W" make/custom/*.cfg
    245 
    246   # Hopefully have some output from the tmtests
    247   echo "=== Checking for timing information"
    248   c=`ls -1 times* 2>/dev/null | wc -l`
    249   if [ ${c} -eq 0 ] ; then
    250     echo "Please run the timing tests and include the results."
    251   fi
    252 fi  ## END OF IF BSP
    253 
    254 #
     398    echo "=== Checking for stdio"
     399    find_source -m -c -C | while read f
     400    do
     401      test_its_NOT_there ${f} printf
     402      test_its_NOT_there ${f} "puts("
     403    done
     404
     405    # BSPs should include RTEMS_BSP_CLEANUP_OPTIONS and maybe
     406    #   RTEMS_BSP_BOOTCARD_OPTIONS
     407    if [ -r configure.ac ] ; then
     408      echo "=== Checking for RTEMS_BSP_BOOTCARD_OPTIONS in BSP configure.ac"
     409      test_its_NOT_there configure.ac RTEMS_BSP_BOOTCARD_OPTIONS
     410      echo "=== Checking for RTEMS_BSP_CLEANUP_OPTIONS in BSP configure.ac"
     411      test_its_there configure.ac RTEMS_BSP_CLEANUP_OPTIONS
     412    fi
     413
     414    # If not using -O2, then we really want to know
     415    # BSPs should normally use -O2
     416    echo "=== Checking for not using -O2"
     417    grep -H "\-O[013456789]" make/custom/*.cfg
     418
     419    # BSPs should not turn on extra warnings
     420    echo "=== Checking for turning on extra GCC warning checks"
     421    grep -H "\-W" make/custom/*.cfg
     422
     423    # Hopefully have some output from the tmtests
     424    echo "=== Checking for timing information"
     425    c=`ls -1 times* 2>/dev/null | wc -l`
     426    if [ ${c} -eq 0 ] ; then
     427      echo "Please run the timing tests and include the results."
     428  fi
     429
     430  echo -e "\n=== Starting BSP Unified way checks"
     431
     432  flag="0"
     433
     434  check_file 1 start.S ../shared/start/ start/
     435  if [[ $filename != "0" ]];then
     436    if grep -wq "start" "$filename" || grep -wq "_start" "$filename"; then
     437      if [[ $verbose -eq "1" ]] ;then
     438        echo "$bsp : `basename $filename` start() present in $filename"
     439      fi
     440    else
     441      echo "$bsp : `basename $filename` start() does not exist in start.S"
     442    fi
     443  fi
     444
     445  check_file 1 bspstart.c ../../shared/ ../shared/ startup/
     446  check_methods "bsp_start"
     447
     448  check_file 1 bspreset.c ../../shared/ ../shared/ startup/
     449  check_methods 1 "bsp_reset"
     450
     451
     452  check_file 1 bootcard.c ../../shared/
     453  check_header ../../shared/include/bootcard.h
     454
     455  check_file 1 bspclean.c ../../shared/ startup/
     456  check_methods "bsp_fatal_extension"
     457
     458  check_file 1 bspgetworkarea.c ../../shared/ ../../shared/startup ../shared/ ../shared/startup/ startup/
     459  check_methods 1 "bsp_work_area_initialize"
     460
     461
     462  check_file 1 bsplibc.c ../../shared/
     463  check_methods "bsp_libc_init"
     464
     465  check_file 1 bsppost.c ../../shared/
     466  check_methods "bsp_postdriver_hook"
     467
     468  check_file 1 bsppredriverhook.c ../../shared/ ../shared/startup/ startup/
     469  check_methods "bsp_predriver_hook"
     470
     471
     472  check_file gnatinstallhandler.c ../../shared/
     473
     474  check_file sbrk.c ../../shared/ ../../shared/ startup/
     475  check_methods "sbrk"
     476
     477
     478  check_file stackalloc.c ../../shared/src/
     479  check_methods "bsp_stack_allocate_init" "bsp_stack_allocate" "bsp_stack_free"
     480
     481  check_header ../../shared/include/stackalloc.h
     482
     483  # Interrupt Files
     484  check_file 1 irq.c irq/
     485  check_methods "bsp_interrupt_vector_enable" "bsp_interrupt_vector_disable" "bsp_interrupt_facility_initialize" "bsp_interrupt_dispatch"
     486  check_header 1 include/irq.h
     487
     488  # PIC Support
     489
     490  check_file irq-default-handler.c ../../shared/src/
     491
     492  check_file 1 irq-generic.c ../../shared/src/
     493  check_header 1 ../../shared/include/irq-generic.h
     494
     495  check_file irq-info.c ../../shared/src/
     496  check_header ../../shared/include/irq-info.h
     497
     498  check_file irq-legacy.c ../../shared/src/
     499  check_file irq-server.c ../../shared/src/
     500  check_file irq-shell.c ../../shared/src/
     501
     502  # Real Time Clock
     503  check_file rtc-config.c rtc/
     504  check_methods "bsp_rtc_initialize" "bsp_rtc_get_time" "bsp_rtc_set_time" "bsp_rtc_probe"
     505
     506
     507  check_file 1 tod.c ../../shared/ tod/
     508
     509  # Benchmark Timers
     510  check_file benchmark_timer.c benchmark_timer/
     511  check_methods "benchmark_timer_initialize" "benchmark_timer_read" "benchmark_timer_disable_subtracting_average_overhead"
     512
     513
     514  # Standard Headers
     515
     516  check_header 1 include/bsp.h
     517  check_header include/bspopts.h
     518  check_header 1 ../../shared/include/coverhd.h include/coverhd.h
     519  check_header ../../shared/include/utility.h
     520  check_header 1 ../../shared/include/tm27.h include/tm27.h
     521
     522  cd ../../../../../../cpukit
     523  find_rtems_internal
     524  cd - > /dev/null
     525
     526  # Finding all internal functions being used in a bsp
     527  find_bsp_internal
     528
     529  if [[ $flag == "1" ]]; then
     530    echo -e "\n"
     531  fi
     532
     533  #
    255534# Test specific checks
    256535#
    257 if [ ${do_test} = "yes" ] ; then
    258   # find all the Makefile.am's with rtems_tests_PROGRAMS in them
    259   Makefiles=`find . -name Makefile.am | xargs -e grep -l ^rtems_tests`
    260   if [ "X${Makefiles}" = "X" ] ; then
    261     fatal "Unable to locate any test Makefile.am files."
    262   fi
    263   echo "=== Checking for missing test support files"
    264   for m in ${Makefiles}
    265   do
    266     directory=`dirname ${m}`
    267     if [ ${directory} = "." ] ; then
    268       directory=`pwd`
    269     fi
    270     testName=`basename ${directory}`
    271     # Does this test have a .doc file?
    272     if [ ! -r ${directory}/${testName}.doc ] ; then
    273       echo ${testName}.doc is not present
    274     fi
    275     case ${directory} in
    276       */*tmtests*) ;;
    277       *)
    278         # Does this test have a .scn file?
    279         if [ ! -r ${directory}/${testName}.scn ] ; then
    280           echo ${testName}.scn is not present
     536  if [ ${do_test} == "1" ] ; then
     537
     538    echo -e "\n=== Starting Test specific checks"
     539    # find all the Makefile.am's with rtems_tests_PROGRAMS in them
     540    Makefiles=`find . -name Makefile.am | xargs -e grep -l ^rtems_tests`
     541    if [ "X${Makefiles}" = "X" ] ; then
     542      echo -e "Unable to locate any test Makefile.am files.\n"
     543      return
     544    fi
     545    echo "=== Checking for missing test support files"
     546    for m in ${Makefiles}
     547    do
     548      directory=`dirname ${m}`
     549      if [ ${directory} = "." ] ; then
     550        directory=`pwd`
     551      fi
     552      testName=`basename ${directory}`
     553      # Does this test have a .doc file?
     554      if [ ! -r ${directory}/${testName}.doc ] ; then
     555        echo ${testName}.doc is not present
     556      fi
     557      case ${directory} in
     558        */*tmtests*) ;;
     559        *)
     560          # Does this test have a .scn file?
     561          if [ ! -r ${directory}/${testName}.scn ] ; then
     562            echo ${testName}.scn is not present
     563          fi
     564          ;;
     565      esac
     566    done
     567
     568  fi
     569}
     570
     571# Verifying if the directory given or pwd is a valid bsp, shared architecture, or libbsp directory
     572function check_given_dir(){
     573  if echo $cur_dir | grep -Eq "c/src/lib/libbsp/([^/]+)/([^/]+)/([^/]+)*" ; then
     574    return 0
     575
     576  elif echo $cur_dir | grep -Eq "c/src/lib/libbsp/([^/]+)/([^/]+)" ; then
     577# BSP given
     578    bsp=${cur_dir##*/}
     579
     580    if [[ $bsp == "shared" || $bsp == "autom4te.cache" || $bsp == "no_bsp" ]]; then
     581      return 0
     582    else
     583      main
     584    fi
     585  elif echo $cur_dir | grep -Eq "c/src/lib/libbsp/([^/]+)" ; then
     586# Shared architecture given
     587    for i in *
     588    do
     589      if [[ -d $i ]]; then
     590        if [[ $i == "shared" || $i == "autom4te.cache" || $i == "no_bsp" ]]; then
     591          echo -n
     592        else
     593          bsp=$i
     594
     595          cd $bsp
     596          main
     597          cd .. > /dev/null
    281598        fi
    282         ;;
     599      fi
     600    done
     601  elif echo $cur_dir | grep -Eq "c/src/lib/libbsp" ; then
     602# libbsp given
     603    for i in */*/Makefile.am
     604    do
     605      i=`dirname $i`
     606      if [[ -d $i ]]; then
     607        if [[ $i == "shared" || $i == "autom4te.cache" || $i == "no_cpu/no_bsp" ]]; then
     608          echo -n
     609        else
     610          bsp=$i
     611
     612          cd $bsp
     613          main
     614          cd ../../ > /dev/null
     615        fi
     616      fi
     617    done
     618
     619  else
     620    return 0
     621  fi
     622}
     623
     624# Evaluating Command Line Arguments
     625function start(){
     626
     627  for i in $*
     628  do
     629    case $i in
     630      "--verbose") verbose="1" # The whole story
     631      ;;
     632
     633      "--warnings") warnings="1" # All warnings
     634              verbose="0"
     635      ;;
     636
     637      "--no_format") format="0" # Disabling format checks
     638              verbose="0"
     639      ;;
     640
     641      "--tests") do_test="1"    # Enabling check of tests
     642             verbose="0"
     643      ;;
     644
     645      "--help") echo "Help to be provided"
     646      ;;
     647
     648      "--"* | "-"* ) echo "Invalid options provided"
     649      ;;
     650
     651      *) path="$path $i"  ;; # If not above options, then assumed to be a path for bsp
    283652    esac
    284653  done
    285      
     654
     655# No path given, search for bsp from pwd
     656  if [[ -z $path ]];then
     657    path=$PWD
     658    cur_dir=`pwd`
     659    check_given_dir
     660    if [[ $? -eq 1 ]];then
     661      echo "Current directory does not seem a valid RTEMS directory"
     662    fi
     663
     664  else
     665    for i in $path
     666    do
     667      if [[ -d $i ]]; then
     668        echo > /dev/null
     669      else
     670        echo "$i is an invalid directory."
     671        continue
     672      fi
     673
     674      cd $i
     675      cur_dir=`pwd`
     676      check_given_dir
     677      if [[ $? -eq 1 ]];then
     678        echo "$i does not seem a valid RTEMS directory"
     679      fi
     680      cd $calling_path
     681
     682    done
     683  fi
     684}
     685
     686# Let the Game begin !!
     687start $*
     688
     689# End of Checks
     690if [[ $faults -eq "0" ]] ; then
     691  echo -e "\nNo faults found in BSP organization"
    286692fi
    287 
    288 exit 0
Note: See TracChangeset for help on using the changeset viewer.