-
Notifications
You must be signed in to change notification settings - Fork 3
/
individualCoverage.sh
executable file
·309 lines (240 loc) · 6.88 KB
/
individualCoverage.sh
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#!/bin/bash
clear
#
#------------------------------
#
# Imports (settings, functions)
#
# Git branch settings
. ./settings.sh
# WriteLog() function
. ./timestampLogger.sh
#
#------------------------------
#
# Constants
#
ROOT=~
BIN_DIR=${ROOT}/build/bin
TEST_ROOT=${ROOT}/build/CE/platform
TEST_HOME=${TEST_ROOT}/HPCC-Platform/testing/regress
ECL_FILE_DIR=${TEST_HOME}/ecl/
BUILD_DIR=${TEST_ROOT}/build
COVERAGE_ROOT=${ROOT}/HPCC-Platform-coverage
LONG_DATE=$(date "+%Y-%m-%d_%H-%M-%S")
COVERAGE_LOG_FILE=${COVERAGE_ROOT}/individualCoverage-${LONG_DATE}.log
FILE_MASK='*.ecl'
DEBUG=0
DRY_RUN=0
ONLY_STARTUP=0
START_UP=1
FIRST_OINLY=0
#TARGET=hthor
TARGET=thor
declare -A testCases
#
#-----------------------------------------
#
# Functions
ReadTestCases()
{
#IFS=:$'\n'
echo "ECl dir: $1"
echo "Target: $2"
#local testCases
_pwd=$( pwd )
cd $1
target=$2
testCs=( $(find . -maxdepth 1 -name "${FILE_MASK}" -type f | sort) )
testCases=()
for test in ${testCs[@]}
do
#echo "Test case:"$test
versions=$( grep '^//version' $test | awk '{print $2}' )
if [ -n "$versions" ]
then
for version in ${versions[@]}
do
#echo "version:$version"
#ut=${version#=}
ls=(${version//,/ })
local versionId=""
for item in ${ls[@]}
do
#echo " item:'$item'"
case $item in
no*)
plat=$( echo $item | grep 's/no//' )
#echo "excluded on "$plat
;;
*) #echo " versionId:$versionId"
versionId=$versionId"-D\"${item}\" "
#echo " updated versionId:$versionId"
;;
esac
done
#echo " versionID:$versionId"
newItem=($(echo ${test} | sed 's/^\.\///' )" ${versionId}"$'\n')
#echo " New item:${newItem}"
testCases+="${newItem}"
done
else
newItem=($(echo ${test} | sed 's/^\.\///')$'\n')
testCases+="${newItem}"
fi
done
#echo ${testCases[@]}
#declare -pa testCases;
cd ${_pwd}
}
ListTestCases()
{
IFS=:$'\n'
lineNo=1
for line in ${testCases[*]}
do
echo $lineNo": $line"
lineNo=$(( ${lineNo} + 1 ))
done
echo ""
}
CleanUpCoverageData()
{
WriteLog "Clean-up coverage data" "${COVERAGE_LOG_FILE}"
echo "Clean-up coverage data"
sudo find ${BUILD_DIR} -name "*.dir" -type d -exec chmod -R 777 {} \;
res=$( sudo lcov --zerocounters --directory ${BUILD_DIR} 2>&1 )
retCode=$( echo $? )
if [ ${retCode} -ne 0 ]
then
WriteLog "Error in cleanup! retCode:"$retCode" res:"$res "${COVERAGE_LOG_FILE}"
echo "Error in cleanup! retCode:"$retCode" res:"$res
exit
fi
}
GenerateCoverageReport()
{
# WriteLog "Zip coverage data file for $1" "${COVERAGE_LOG_FILE}"
# WriteLog "CMD: zip -r ${COVERAGE_ROOT}/coverage_$1_gcxx.zip /home/ati/HPCC-Platform-build/ -i *.gc*" "${COVERAGE_LOG_FILE}"
# zip -r ${COVERAGE_ROOT}/coverage_$1_gcxx.zip /home/ati/HPCC-Platform-build/ -i *.gc*
WriteLog "Generate coverage data for $1" "${COVERAGE_LOG_FILE}"
echo "Generate coverage data for $1"
res=$( sudo lcov --quiet --capture --directory ${BUILD_DIR} --output-file ${COVERAGE_ROOT}/hpcc_$1_coverage.lcov 2>&1 )
if [ ${retCode} -ne 0 ]
then
WriteLog "Error in processsing! retCode:"$retCode" res:"$res "${COVERAGE_LOG_FILE}"
echo "Error in processing! retCode:"$retCode" res:"$res
exit
else
if [ -n "$res" ]
then
echo $res > ${COVERAGE_ROOT}/hpcc_$1_coverage.log
fi
fi
}
GenerateCoverageFor()
{
if [[ $DRY_RUN -eq 0 ]]
then
CleanUpCoverageData
WriteLog "Start HPCC-System" "${COVERAGE_LOG_FILE}"
sudo ${BIN_DIR}/start.sh
fi
if [ "$1" != "" ]
then
#cmd="./ecl-test query -t $2 $1"
cmd="ecl run -t $2 ecl/$1"
echo "CMD:${cmd}"
WriteLog "CMD: ${cmd}" "${COVERAGE_LOG_FILE}"
if [[ $DRY_RUN -eq 0 ]]
then
res=$( $cmd 2>&1 )
#echo $res
echo ""
fi
fi;
if [[ $DRY_RUN -eq 0 ]]
then
WriteLog "Stop HPCC-System" "${COVERAGE_LOG_FILE}"
sudo ${BIN_DIR}/stop.sh
GenerateCoverageReport $3
fi
}
#
#-----------------------------------------
#
# Main start
[ ! -e $COVERAGE_ROOT ] && mkdir -p $COVERAGE_ROOT
rm -rf ${COVERAGE_ROOT}/*
WriteLog "Individual Coverage generation started" "${COVERAGE_LOG_FILE}"
echo "Start..."
WriteLog "Target is ${TARGET}" "${COVERAGE_LOG_FILE}"
WriteLog "Read testcases" "${COVERAGE_LOG_FILE}"
ReadTestCases ${TEST_HOME}/ecl $TARGET
IFS=:$'\n'
maxTestCase=${#testCases[@]}
WriteLog "Number of testcases is ${maxTestCase}" "${COVERAGE_LOG_FILE}"
echo "Number of Testcases: ${maxTestCase}"
if [[ $DEBUG -eq 1 ]]
then
ListTestCases "$testCases"
fi
#
#-----------------------------------------
#
# Stop HPCC system
WriteLog "Stop HPCC Systems" "${COVERAGE_LOG_FILE}"
echo "Stop HPCC system"
sudo ${BIN_DIR}/stop.sh
#
#-----------------------------------------
#
# Collect coverage for start-stop only
#
if [[ $START_UP -eq 1 ]]
then
WriteLog "Collect coverage for start-stop only" "${COVERAGE_LOG_FILE}"
echo "Collect coverage for start-stop only"
GenerateCoverageFor "" "" "Start-Stop"
else
WriteLog "Skip coverage for start-stop" "${COVERAGE_LOG_FILE}"
echo "Skip coverage for start-stop"
fi
#
#-----------------------------------------
#
# Generate coverage for individual test cases
if [[ $ONLY_STARTUP -eq 0 ]]
then
WriteLog "Start generate coverage for individual test cases" "${COVERAGE_LOG_FILE}"
echo "Start generate coverage for individual test cases"
index=1
pwd=$( pwd )
cd ${TEST_HOME}
for test in ${testCases[@]}
do
msg=$( printf "%3d/%3d. %s\n" ${index} ${maxTestCase} ${test} )
echo $msg
WriteLog "${msg}" "${COVERAGE_LOG_FILE}"
if true
then
GenerateCoverageFor ${test} ${TARGET} "${test}-${TARGET}"
else
cmd="ecl run -t ${TARGET} ecl/${test}"
echo "CMD:${cmd}"
#res=$( $cmd 2>&1 )
echo $res
echo ""
fi
index=$(($index+1))
if [[ $FIRST_OINLY -eq 1 ]]
then
WriteLog "It was a first only call. Stop testing more test cases." "${COVERAGE_LOG_FILE}"
echo "It was a first only call. Stop testing more test cases."
break
fi
done
cd ${pwd}
fi
echo "End."
WriteLog "End." "${COVERAGE_LOG_FILE}"