-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrtems-run-coverity
executable file
·224 lines (183 loc) · 6.55 KB
/
rtems-run-coverity
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#! /bin/sh
#
# This script automates running Coverity on RTEMS and submitting
# the results.
#
# + Instructions: http://scan.coverity.com/self-build/
# + Results: http://scan2.coverity.com:9104/
#
# You have to have an account to view the results
#
# NOTE:
# + build.raw is very important if something goes wrong
#
#
# TODO:
# + parse arguments for some of the hard-coded items.
# + better instructions on setup. Where to download, etc.
#
COVERITY_BASE=${HOME}/coverity
# Be careful -- the tar and the directory do not always match
COVERITY_VERSION=cov-analysis-linux64-2024.6.1
COVERITY=${COVERITY_BASE}/cov-analysis-linux64-2024.6.1
do_native=no
RTEMS_CPU=sparc
RTEMS_TARGET=${RTEMS_CPU}-rtems7
RTEMS_BSP=leon3
RTEMS_TOOLS=/home/joel/rtems-work/tools/6/
PROJECT_NAME=RTEMS
COVERITY_SCAN_TOKEN=ce5hazuV
RESULTS_DIR=cov-int
RESULTS_ARCHIVE=${RESULTS_DIR}.tar.bz2
OWNER_EMAIL=joel.sherrill@gmail.com
UPLOAD_URL=https://scan.coverity.com/builds?project=RTEMS
# Prepend Coverity to our PATH
export PATH=${COVERITY}/bin:$PATH
#
# Checks the status returned by executables and exits if it is non-zero.
#
check_fatal()
{
if [ $1 -ne 0 ] ; then
shift
echo "ERROR: $*" >&2
exit 1
fi
}
test -r ${COVERITY_BASE}/${COVERITY_VERSION}.tar.gz
check_fatal $? "${COVERITY} tarball does not exist"
if [ ${do_native} != "yes" ] ; then
type ${RTEMS_TARGET}-gcc
check_fatal $? "target gcc not in path"
GCC=`type ${RTEMS_TARGET}-gcc 2>/dev/null`
check_fatal $? "Unable to find ${RTEMS_TARGET}-gcc"
GXX=`type ${RTEMS_TARGET}-g++ 2>/dev/null`
check_fatal $? "Unable to find ${RTEMS_TARGET}-g++"
fi
test -d rtems
check_fatal $? "rtems should be in the current directory"
test ${LOGNAME} = "joel"
check_fatal $? "For now, Coverity must be run by joel"
# Remove Coverity and reinstall to get fresh compiler configuration
cd ${COVERITY_BASE}
check_fatal $? "Could not cd ${COVERITY_BASE}"
rm -rf ${COVERITY}
check_fatal $? "Could not remove ${COVERITY}"
tar xf ${COVERITY_VERSION}.tar.gz
check_fatal $? "Could not untar ${COVERITY_VERSION} tarball"
test -d ${COVERITY}
check_fatal $? "Coverity path not right after untar"
test -d ${COVERITY}/bin
cd -
check_fatal $? "Could not cd to starting point"
# Configure Coverity for this target compiler
#rm -rf ${COVERITY}/config/coverity_config.xml
#rm -rf ${COVERITY}/config/gcc-config-? ${COVERITY}/config/g++-config-?
# Not configure Coverity for the compiler
if [ ${do_native} = "yes" ] ; then
cov-configure -co gcc
check_fatal $? "could not coverity configure native gcc"
cov-configure -co g++
check_fatal $? "could not coverity configure native g++"
else
#cov-configure --gcc ${RTEMS_TARGET}-gcc
#check_fatal $? "could not coverity configure target GCC"
#cov-configure --gcc ${RTEMS_TARGET}-g++
#check_fatal $? "could not coverity configure target g++"
cov-configure --comptype gcc -co ${RTEMS_TARGET}-gcc -- -mcpu=leon3
check_fatal $? "could not coverity configure target gcc"
cov-configure --comptype gcc -co ${RTEMS_TARGET}-g++ -- -mcpu=leon3
check_fatal $? "could not coverity configure target g++"
echo $PATH
type ${RTEMS_TARGET}-gcc
${RTEMS_TARGET}-gcc --version
check_fatal $? "could not print ${RTEMS_TARGET}-gcc versin"
fi
cd rtems
SHA=`git rev-parse --short HEAD`
cd -
if [ -r rtems/waf ] ; then
echo "Waf Build"
cd rtems
check_fatal $? "Could not cd to rtems directory for waf build"
# remove results of last analysis
rm -rf ${RESULTS_DIR} ${RESULTS_ARCHIVE}
# clean up the RTEMS build
./waf distclean
check_fatal $? "Could not run waf distclean"
./waf bspdefaults --rtems-bsps=${RTEMS_CPU}/${RTEMS_BSP} | \
sed -e 's/^RTEMS_NETWORKING =.*$/RTEMS_NETWORKING = False/' \
-e 's/^RTEMS_POSIX_API =.*$/RTEMS_POSIX_API = True/' \
-e 's/^RTEMS_DEBUG =.*$/RTEMS_DEBUG = False/' \
-e 's/^RTEMS_PROFILING =.*$/RTEMS_PROFILING = False/' \
-e 's/^RTEMS_SMP =.*$/RTEMS_SMP = False/' \
-e 's/^RTEMS_MP =.*$/RTEMS_MP = False/' \
-e 's/^RTEMS_CXX =.*$/RTEMS_CXX = True/' \
-e 's/^RTEMS_NETWORKING =.*$/RTEMS_NETWORKING = False/' \
-e 's/^RTEMS_POSIX_API =.*$/RTEMS_POSIX_API = True/' \
-e 's/^BUILD_TESTS =.*$/BUILD_TESTS = False/' \
-e 's/^BUILD_SAMPLES =.*$/BUILD_SAMPLES = False/' \
>config.ini
check_fatal $? "Could not run waf bspdefaults"
#--rtems-tools=${HOME}/test-gcc/install-gcc9
./waf configure \
--rtems-tools=${RTEMS_TOOLS} \
--rtems-bsps=${RTEMS_CPU}/${RTEMS_BSP} \
--prefix=${RTEMS_TOOLS}/bsp-install
check_fatal $? "Could not run waf configure"
cov-build --dir ${RESULTS_DIR} ./waf >b.log 2>&1
check_fatal $? "Could not run waf"
else
echo "Autoconf Build"
# Clean build directory and start over
rm -rf b-coverity-${RTEMS_TARGET}
check_fatal $? "Could not remove build directory"
mkdir -p b-coverity-${RTEMS_TARGET}
check_fatal $? "Could not make build directory"
cd b-coverity-${RTEMS_TARGET}
check_fatal $? "Could not cd to build directory"
# Configure RTEMS
../rtems/configure --target=${RTEMS_TARGET} \
--disable-networking --disable-itron --disable-tests \
--enable-rtemsbsp=${RTEMS_BSP} >c.log 2>&1
check_fatal $? "could not configure RTEMS"
# Build RTEMS
cov-build --dir ${RESULTS_DIR} make -j 8 >b.log 2>&1
check_fatal $? "could not make RTEMS"
fi
# Did we have problems loading the Coverity dynamic library?
grep -i "ERROR: ld.so:.*" b.log >/dev/null
if [ $? -ne 1 ] ; then
check_fatal 1 "Looks like you have dynamic library issues with Coverity."
fi
# Did Coverity report something bad?
grep -i catastrophic ${RESULTS_DIR}/build-log.txt >/dev/null
if [ $? -ne 1 ] ; then
check_fatal 1 "Catastrophic failures reported by coverity."
fi
cfound=`grep "compilation units.* are ready" \
${RESULTS_DIR}/build-log.txt | cut -d' ' -f2`
echo "Files processed: ${cfound}"
#if [ ${do_native} = "yes" ] ; then
# echo no check for minimum files on native
#elif [ ${cfound} -lt 1000 ] ; then
# echo "check_fatal 1 \"Not enough files analsed for an RTEMS run\""
#fi
# Did Coverity report that it had no results?
grep -i "No files were emitted" ${RESULTS_DIR}/build-log.txt >/dev/null
if [ $? -ne 1 ] ; then
echo check_fatal 1 "No output from Coverity. Something went wrong."
fi
tar cjf ${RESULTS_ARCHIVE} ${RESULTS_DIR}
check_fatal $? "tar of results did not work"
# --form project=$PROJECT_NAME
curl \
--progress-bar \
--form token=$COVERITY_SCAN_TOKEN \
--form email=$OWNER_EMAIL \
--form file=@${RESULTS_ARCHIVE} \
--form version=$SHA \
--form description="Master" \
$UPLOAD_URL
check_fatal $? "upload of results failed"
exit 0