forked from joelsherrill/rtems-cron-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtems-tools-cron-run-coverity
executable file
·175 lines (142 loc) · 3.24 KB
/
rtems-tools-cron-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
#! /bin/sh
#
# Automated build and test script which performs the following.
#
# - Updates RTEMS Tools
# - If RTEMS Tools changed, build and do Coverity Scan
# uncomment this to watch the commands and do nothing
# TECHO=echo
progname=${0##*/} # fast basename hack for ksh, bash
USAGE=\
"usage: $progname [ -opts ]
-v verbose (default=no)
-f force build (default=no)
-g do git update (default=yes)
-D Top directory (default=${HOME}/rtems-cron-coverity)
-V RTEMS Version (default=5)
"
# log an error to stderr
prerr()
{
echo "$*" >&2
}
fatal() {
[ "$1" ] && prerr $*
prerr "$USAGE"
exit 1
}
warn() {
[ "$1" ] && prerr $*
}
check_status()
{
if [ $1 -ne 0 ] ; then
shift
echo "FAILED: " "$*" >&2
exit 1
fi
}
INFO()
{
echo "${*}" >>${LOGFILE}
}
LOG()
{
status=$1
if [ ${status} -eq 0 ] ; then
S="PASSED"
else
S="FAILED (${status})"
fi
shift
echo "${S} " $* >>${LOGFILE}
}
# directory where run from
exedir=`dirname "$0"`
exedir=`( cd "${exedir}" && pwd )`
coverity_runner=${exedir}/rtems-tools-run-coverity
test -x ${coverity_runner}
check_status $? "${coverity_runner} is not present"
# Default Behavioral variables to set
verbose="no"
version="6"
force_build="no"
do_git_update="yes"
TOP=${HOME}/rtems-cron-coverity
while getopts "fgtvD:V:" OPT
do
case "$OPT" in
f) force_build="yes";;
g) do_git_update="no" ;;
v) verbose="yes";;
D) TOP="$OPTARG";;
V) version="$OPTARG";;
*) fatal;;
esac
done
shiftcount=`expr $OPTIND - 1`
shift $shiftcount
if [ ! -d ${TOP} ] ; then
echo "echo Bad TOP directory (${TOP}!"
exit 1
fi
# Empty it out and maybe set one standard contents
LOGFILE=${TOP}/all-log.txt
echo >${LOGFILE}
### Check directories
rtems_tools_dir=${TOP}/rtems-tools
for d in ${rtems_tools_dir}
do
test -d ${d}
check_status $? "${d} is not present"
done
update()
{
# This is OK except for rtems-libbsd
case ${version} in
6|7) branch=master ;;
*) branch=${version} ;;
esac
git checkout ${branch} >/dev/null
git fetch >/dev/null
c=`git rev-list HEAD...origin/${branch} --count 2>/dev/null`
echo ${c}
}
start=`date`
if [ ${do_git_update} = "yes" ] ; then
cd ${TOP}/rtems-tools
rtems_tools_updated="no"
c=`update`
if [ ${c} -ne 0 ] ; then
git pull
check_status $? "git pull of rtems-tools failed"
rtems_tools_updated="yes"
fi
test ${verbose} = "yes" && echo "rtems-tools: ${c} updates"
INFO "rtems-tools had ${c} revisions to update"
fi
# Force -- make it look like everything updated
if [ ${force_build} = "yes" ] ; then
rtems_tools_updated="yes"
test ${verbose} = "yes" && echo "Forcing builds whether updates or not"
fi
if [ ${verbose} = "yes" ] ; then
echo Git Update: ${do_git_update}
echo Forced Update: ${force_build}
echo RTEMS Tools Updated: ${rtems_tools_updated}
fi
if [ ${force_build} = "no" -a \
${rtems_tools_updated} = "no" ] ; then
echo "No updates and forced build not requested -- NO ACTION!"
exit 0
fi
if [ ${rtems_tools_updated} = "yes" ] ; then
cd ${rtems_tools_dir}/..
${coverity_runner}
fi
stop=`date`
INFO "${0} START: " ${start}
INFO "${0} STOP: " ${stop}
echo "START: " ${start}
echo "STOP: " ${stop}
exit 0