forked from joelsherrill/rtems-cron-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtems-newlib-run-coverity
executable file
·184 lines (151 loc) · 5.06 KB
/
rtems-newlib-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
#! /bin/sh
#
# This script automates running Coverity on newlib as built for RTEMS
# and submits 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:
# + TBD
#
COVERITY_VERSION=cov-analysis-linux64-2020.09
COVERITY_BASE=${HOME}/coverity
COVERITY=${COVERITY_BASE}/${COVERITY_VERSION}
do_native=no
RTEMS_CPU=sparc
RTEMS_TARGET=${RTEMS_CPU}-rtems6
RTEMS_BSP=leon3
RTEMS_TOOLS=/home/joel/rtems-work/tools/6/
# RTEMS_TOOLS=/home/joel/test-gcc/install-gcc9
PROJECT_NAME=RTEMS-Newlib
COVERITY_SCAN_TOKEN=BtR7PhfmMTP6Z3BnAU8tNw
RESULTS_DIR=cov-int
RESULTS_ARCHIVE=${RESULTS_DIR}.tar.bz2
#UPLOAD_URL=http://scan5.coverity.com/cgi-bin/upload.py
UPLOAD_URL=https://scan.coverity.com/builds?project=RTEMS-Newlib
# Prepend Coverity to our PATH
export PATH=${COVERITY}/bin:$PATH
# Prepend RTEMS TOOLS to our PATH
export PATH=${RTEMS_TOOLS}/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
NEWLIB=sourceware-mirror-newlib-cygwin
test -d ${NEWLIB}
check_fatal $? "RTEMS newlib git mirror 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_VERSION}
check_fatal $? "Could not remove ${COVERITY_VERSION}"
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
# Now 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 -- -B`pwd`/b-newlib/sparc-rtems6/newlib/
check_fatal $? "could not coverity configure target gcc"
cov-configure --comptype gcc -co ${RTEMS_TARGET}-g++ -- -B`pwd`/b-newlib/sparc-rtems6/newlib/
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 ${NEWLIB}
SHA=`git rev-parse --short HEAD`
cd -
rm -rf b-newlib
mkdir b-newlib
check_fatal $? "Unable to create b-newlib"
cd b-newlib
check_fatal $? "Unable to cd b-newlib"
# Similar to normal build EXCEPT no multilib
../${NEWLIB}/configure \
--disable-multilib \
${enable_iconv} \
--enable-newlib-io-c99-formats \
--enable-threads \
--target=${RTEMS_TARGET} \
--prefix=/tmp/newlib-junk-install >c.log 2>&1
check_fatal $? "Unable to configure newlib"
cov-build --dir ${RESULTS_DIR} make -j8 >b.log 2>&1
check_fatal $? "Unable to build newlib"
# 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