summaryrefslogtreecommitdiff
path: root/merge-helpers/check_bsp
blob: bcc0bfabc65d7e732145eccb6fd4d37f076378bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#
#  Script to test for various things we want in a BSP when it is
#  submitted.
#
#  Test for:
#    - presense of BSP_BOOTCARD_OPTIONS
#    - XXX
#    - XXX
#
#  $Id$
#

if [ $# -ne 1 ] ; then
  echo Usage: $0 BSPDIR
  exit 1
fi

bspdir=${1}

if [ ! -d ${bspdir} ] ; then
  echo ${bspdir} is not a directory
  exit 1
fi

cd ${bspdir}
if [ $? -ne 0 ] ; then
  echo Unable to cd to ${bspdir}
  exit 1
fi


test_its_there()
{
  if [ $# -ne 2 ] ; then
    echo Usage: $0 FILE pattern
  fi
  grep ${2} ${1} >/dev/null
  if [ $? -ne 0 ] ; then
    echo "${2} is NOT in ${bspdir}/${1}"
  fi

}

test_its_NOT_there_all_case()
{
  if [ $# -lt 2 ] ; then
    echo Usage: $0 FILE pattern
  fi
  FILE=$1
  shift
  grep -i "${*}" ${FILE} >/dev/null
  if [ $? -eq 0 ] ; then
    echo "(${*}) SHOULD NOT BE IN ${bspdir}/${FILE} - case independent check"
  fi
}

test_its_NOT_there()
{
  if [ $# -lt 2 ] ; then
    echo Usage: $0 FILE pattern
  fi
  FILE=$1
  shift
  grep "${*}" ${FILE} >/dev/null
  if [ $? -eq 0 ] ; then
    echo "(${*}) SHOULD NOT BE IN ${bspdir}/${FILE}"
  fi
}

find_source()
{
  findArgs=
  while getopts "cCm" OPT
  do
   case "$OPT" in
     c) findArgs="${findArgs} -o -name configure.ac" ;;
     C) findArgs="${findArgs} -o -name *.cfg" ;;
     m) findArgs="${findArgs} -o -name Makefile.am" ;;
     *) echo "bad arg to find_source ($OPT)" ; exit 1 ;;
   esac
  done

  shiftcount=`expr $OPTIND - 1`
  shift $shiftcount

  args=$*

  find . -name "*.[chS]" ${findArgs}
}

if [ -r configure.ac ] ; then
  echo "=== Checking for RTEMS_BSP_BOOTCARD_OPTIONS in BSP configure.ac"
  test_its_there configure.ac RTEMS_BSP_BOOTCARD_OPTIONS
  echo "=== Checking for RTEMS_BSP_CLEANUP_OPTIONS in BSP configure.ac"
  test_its_there configure.ac RTEMS_BSP_CLEANUP_OPTIONS
fi

# Verify no lines longer than 80 columns
echo "=== Checking for lines greater than 79 columns"
find_source -m -c -C | while read f
do
  grep  ".\{80,\}" ${f} >/dev/null
  if [ $? -eq 0 ] ; then
    echo "${bspdir}/${FILE} has the following lines that are too long"
    grep -n '.\{80,\}' ${f}
  fi
done

# We want CVS Id strings everywhere possible
# really need to make the copyright strings consistent in BSPs
echo "=== Checking for copyright notices"
find_source | while read f
do
  test_its_there ${f} COPYRIGHT
done

# We want CVS Id strings everywhere possible
echo "=== Checking for CVS Id strings"
find_source | while read f
do
  test_its_there ${f} "\$Id"
done

# We do not want stdio in a BSP
echo "=== Checking for stdio"
find_source -m -c -C | while read f
do
  test_its_NOT_there ${f} printf
  test_its_NOT_there ${f} puts
done

# We do not want the reformatted license notice
echo "=== Checking for reformatted RTEMS license notices"
find_source -m -c -C | while read f
do
  test_its_NOT_there ${f} "this file may be found in the file"
done

# We do not want GPL code
echo "=== Checking for hints of GPL code"
find_source -m -c -C | while read f
do
  test_its_NOT_there ${f} "Free Software Foundation"
  test_its_NOT_there ${f} "program is free software"
  test_its_NOT_there ${f} "General Public License"
done

# We do not want hints that there are things left to do
echo "=== Checking for TODO hints"
find_source -m -c -C | while read f
do
  test_its_NOT_there ${f} XXX
  test_its_NOT_there ${f} TODO
  test_its_NOT_there ${f} TBD
done

# If not using -O2, then we really want to know
echo "=== Checking for not using -O2"
grep -H "\-O[013456789]" make/custom/*.cfg

# BSPs should not turn on extra warnings
echo "=== Checking for turning on extra GCC warning checks"
grep -H "\-W" make/custom/*.cfg

# Hopefully have some output from the tmtests
echo "=== Checking for timing information"
c=`ls -1 times* 2>/dev/null | wc -l`
if [ ${c} -eq 0 ] ; then
  echo "Please run the timing tests and include the results."
fi
exit 0