@@ -83,6 +83,21 @@ if [ 'x' == "x$GENHTML_TOOL" ] ; then
83
83
PERL2LCOV_TOOL=${LCOV_HOME} /bin/perl2lcov
84
84
fi
85
85
86
+ if [ -f $LCOV_HOME /scripts/getp4version ] ; then
87
+ SCRIPT_DIR=$LCOV_HOME /scripts
88
+ else
89
+ # running test from lcov install
90
+ SCRIPT_DIR=$LCOV_HOME /share/lcov/support-scripts
91
+ fi
92
+ # is this git or P4?
93
+ git -C . rev-parse > /dev/null 2>&1
94
+ if [ 0 == $? ] ; then
95
+ # this is git
96
+ GET_VERSION=${SCRIPT_DIR} /gitversion.pm
97
+ else
98
+ GET_VERSION=${SCRIPT_DIR} /P4version.pm,--local-edit,--md5
99
+ fi
100
+
86
101
ROOT=` pwd`
87
102
PARENT=` (cd .. ; pwd)`
88
103
@@ -112,7 +127,7 @@ STATUS=0
112
127
function runClang()
113
128
(
114
129
# runClang exeName srcFile flags
115
- clang++ -fprofile-instr-generate -fcoverage-mapping -fcoverage-mcdc -o $1 $2 $3
130
+ clang++ -fprofile-instr-generate -fcoverage-mapping -fcoverage-mcdc -o $1 main.cpp test.cpp $2
116
131
if [ $? != 0 ] ; then
117
132
echo " ERROR from clang++ $1 "
118
133
return 1
@@ -128,23 +143,34 @@ function runClang()
128
143
echo " ERROR from llvm-cov $1 "
129
144
return 1
130
145
fi
131
- $COVER $LLVM2LCOV_TOOL --branch --mcdc -o $1 .info $1 .jsn
146
+ $COVER $LLVM2LCOV_TOOL --branch --mcdc -o $1 .info $1 .jsn --version-script $GET_VERSION
132
147
if [ $? != 0 ] ; then
133
148
echo " ERROR from llvm2lcov $1 "
134
149
return 1
135
150
fi
136
- $COVER $GENHTML_TOOL --flat --branch --mcdc -o $1 _rpt $1 .info
151
+ $COVER $GENHTML_TOOL --flat --branch --mcdc -o $1 _rpt $1 .info --version-script $GET_VERSION
137
152
if [ $? != 0 ] ; then
138
153
echo " ERROR from genhtml $1 "
139
154
return 1
140
155
fi
156
+ # run again, excluding 'main.cpp'
157
+ $COVER $LLVM2LCOV_TOOL --branch --mcdc -o $1 .excl.info $1 .jsn --version-script $GET_VERSION --exclude ' */main.cpp'
158
+ if [ $? != 0 ] ; then
159
+ echo " ERROR from llvm2lcov --exclude $1 "
160
+ return 1
161
+ fi
162
+ COUNT=` grep -c SF: $1 .excl.info`
163
+ if [ 1 != " $COUNT " ] ; then
164
+ echo " ERROR llvm2lcov --exclude $1 didn't work"
165
+ return 1
166
+ fi
141
167
rm -f * .profraw * .profdata
142
168
)
143
169
144
170
function runGcc()
145
171
{
146
172
# runGcc exeName srcFile flags
147
- g++ --coverage -fcondition-coverage -o $1 $2 $3
173
+ g++ --coverage -fcondition-coverage -o $1 main.cpp test.cpp $2
148
174
if [ $? != 0 ] ; then
149
175
echo " ERROR from g++ $1 "
150
176
return 1
184
210
185
211
186
212
if [ " $ENABLE_MCDC " == 1 ] ; then
187
- runGcc gccTest1 test.cpp
213
+ runGcc gccTest1
188
214
if [ $? != 0 ] ; then
189
215
STATUS=1
190
216
if [ $KEEP_GOING == 0 ] ; then
191
217
exit 1
192
218
fi
193
219
fi
194
- runGcc gccTest2 test.cpp -DSENS1
220
+ runGcc gccTest2 -DSENS1
195
221
if [ $? != 0 ] ; then
196
222
STATUS=1
197
223
if [ $KEEP_GOING == 0 ] ; then
198
224
exit 1
199
225
fi
200
226
fi
201
- runGcc gccTest3 test.cpp -DSENS2
227
+ runGcc gccTest3 -DSENS2
202
228
if [ $? != 0 ] ; then
203
229
STATUS=1
204
230
if [ $KEEP_GOING == 0 ] ; then
@@ -210,21 +236,21 @@ else
210
236
fi
211
237
212
238
if [ " $ENABLE_LLVM " == 1 ] ; then
213
- runClang clangTest1 test.cpp
239
+ runClang clangTest1
214
240
if [ $? != 0 ] ; then
215
241
STATUS=1
216
242
if [ $KEEP_GOING == 0 ] ; then
217
243
exit 1
218
244
fi
219
245
fi
220
- runClang clangTest2 test.cpp -DSENS1
246
+ runClang clangTest2 -DSENS1
221
247
if [ $? != 0 ] ; then
222
248
STATUS=1
223
249
if [ $KEEP_GOING == 0 ] ; then
224
250
exit 1
225
251
fi
226
252
fi
227
- runClang clangTest3 test.cpp -DSENS2
253
+ runClang clangTest3 -DSENS2
228
254
if [ $? != 0 ] ; then
229
255
STATUS=1
230
256
if [ $KEEP_GOING == 0 ] ; then
0 commit comments