source: rtems-testing/merge-helpers/check_submission @ edf7492

4.11
Last change on this file since edf7492 was edf7492, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 1, 2011 at 2:23:15 PM

2011-08-01 Joel Sherrill <joel.sherrill@…>

  • Makefile: Enhance to check more than a BSP.
  • check_submission: New file.
  • check_bsp: Removed.
  • Property mode set to 100755
File size: 4.7 KB
Line 
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#  $Id$
9#
10
11usage()
12{
13cat <<EOF
14check_submission [options] directory
15  -v - verbose
16EOF
17}
18
19fatal()
20{
21  usage
22  exit 1
23}
24
25toggle()
26{
27  case $1 in
28    no)  echo "yes" ;;
29    yes) echo "no" ;;
30    *)   fatal "Unknown value to toggle ($1)" ;;
31  esac
32}
33
34verbose="no"
35do_bsp="no"
36do_test="no"
37
38while getopts vbt OPT
39do
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
46done
47
48########################### Grab Directory ###########################
49
50shiftcount=`expr $OPTIND - 1`
51shift $shiftcount
52
53basedir=${1}
54
55if [ ${do_bsp} = "no" -a ${do_test} = "no" ] ; then
56  fatal must select test or bsp check mode
57fi
58
59if [ ! -d ${basedir} ] ; then
60  fatal ${basedir} is not a directory
61fi
62
63
64cd ${basedir}
65if [ $? -ne 0 ] ; then
66  echo Unable to cd to ${basedir}
67  exit 1
68fi
69
70
71test_its_there()
72{
73  if [ $# -ne 2 ] ; then
74    echo Usage: $0 FILE pattern
75  fi
76  grep ${2} ${1} >/dev/null
77  if [ $? -ne 0 ] ; then
78    echo "${2} is NOT in ${basedir}/${1}"
79  fi
80
81}
82
83test_its_there_all_case()
84{
85  if [ $# -ne 2 ] ; then
86    echo Usage: $0 FILE pattern
87  fi
88  grep -i ${2} ${1} >/dev/null
89  if [ $? -ne 0 ] ; then
90    echo "${2} is NOT in ${basedir}/${1} - case independent check"
91  fi
92
93}
94
95test_its_NOT_there_all_case()
96{
97  if [ $# -lt 2 ] ; then
98    echo Usage: $0 FILE pattern
99  fi
100  FILE=$1
101  shift
102  grep -i "${*}" ${FILE} >/dev/null
103  if [ $? -eq 0 ] ; then
104    echo "(${*}) SHOULD NOT BE IN ${basedir}/${FILE} - case independent check"
105  fi
106}
107
108test_its_NOT_there()
109{
110  if [ $# -lt 2 ] ; then
111    echo Usage: $0 FILE pattern
112  fi
113  FILE=$1
114  shift
115  grep "${*}" ${FILE} >/dev/null
116  if [ $? -eq 0 ] ; then
117    echo "(${*}) SHOULD NOT BE IN ${basedir}/${FILE}"
118  fi
119}
120
121find_source()
122{
123  findArgs=
124  while getopts "cCm" OPT
125  do
126   case "$OPT" in
127     c) findArgs="${findArgs} -o -name configure.ac" ;;
128     C) findArgs="${findArgs} -o -name *.cfg" ;;
129     m) findArgs="${findArgs} -o -name Makefile.am" ;;
130     *) echo "bad arg to find_source ($OPT)" ; exit 1 ;;
131   esac
132  done
133
134  shiftcount=`expr $OPTIND - 1`
135  shift $shiftcount
136
137  args=$*
138
139  find . -name "*.[chS]" ${findArgs}
140}
141
142# Verify no lines longer than 80 columns
143echo "=== Checking for lines greater than 79 columns"
144find_source -m -c -C | while read f
145do
146  grep  ".\{80,\}" ${f} >/dev/null
147  if [ $? -eq 0 ] ; then
148    echo "*** ${basedir}/${f} has the following lines that are too long"
149    grep -n '.\{80,\}' ${f}
150  fi
151done
152
153# really need to make the copyright strings consistent in BSPs
154echo "=== Checking for copyright notices"
155find_source | while read f
156do
157  test_its_there_all_case ${f} COPYRIGHT
158done
159
160# We want CVS Id strings everywhere possible
161echo "=== Checking for CVS Id strings"
162find_source | while read f
163do
164  test_its_there ${f} "\$Id"
165done
166
167# We do not want the reformatted license notice
168echo "=== Checking for reformatted RTEMS license notices"
169find_source -m -c -C | while read f
170do
171  test_its_NOT_there ${f} "this file may be found in the file"
172done
173
174# We do not want GPL code
175echo "=== Checking for hints of GPL code"
176find_source -m -c -C | while read f
177do
178  test_its_NOT_there ${f} "Free Software Foundation"
179  test_its_NOT_there ${f} "program is free software"
180  test_its_NOT_there ${f} "General Public License"
181done
182
183# We do not want hints that there are things left to do
184echo "=== Checking for TODO hints"
185find_source -m -c -C | while read f
186do
187  test_its_NOT_there ${f} XXX
188  test_its_NOT_there ${f} TODO
189  test_its_NOT_there ${f} TBD
190done
191
192# If not using -O2, then we really want to know
193if [ ${do_bsp} = "yes" ] ; then
194  # We do not want stdio in a BSP
195  echo "=== Checking for stdio"
196  find_source -m -c -C | while read f
197  do
198    test_its_NOT_there ${f} printf
199    test_its_NOT_there ${f} puts
200  done
201
202  # BSPs should include RTEMS_BSP_CLEANUP_OPTIONS and maybe
203  #   RTEMS_BSP_BOOTCARD_OPTIONS
204  if [ -r configure.ac ] ; then
205    echo "=== Checking for RTEMS_BSP_BOOTCARD_OPTIONS in BSP configure.ac"
206    test_its_there configure.ac RTEMS_BSP_BOOTCARD_OPTIONS
207    echo "=== Checking for RTEMS_BSP_CLEANUP_OPTIONS in BSP configure.ac"
208    test_its_there configure.ac RTEMS_BSP_CLEANUP_OPTIONS
209  fi
210
211  # BSPs should normally use -O2
212  echo "=== Checking for not using -O2"
213  grep -H "\-O[013456789]" make/custom/*.cfg
214
215  # BSPs should not turn on extra warnings
216  echo "=== Checking for turning on extra GCC warning checks"
217  grep -H "\-W" make/custom/*.cfg
218
219  # Hopefully have some output from the tmtests
220  echo "=== Checking for timing information"
221  c=`ls -1 times* 2>/dev/null | wc -l`
222  if [ ${c} -eq 0 ] ; then
223    echo "Please run the timing tests and include the results."
224  fi
225fi  ## END OF IF BSP
226
227exit 0
Note: See TracBrowser for help on using the repository browser.