-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunPerProj.sh
232 lines (222 loc) · 7.67 KB
/
RunPerProj.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
# Param1: N. Roll back N commits.
rollBackN() {
# clean untracked files like .ekstazi/*
git clean -fd
# Force to checkout, since we may modify pom.xml
git checkout -f HEAD~$1
}
# Param1: n, current head location
# Safe Method - Unit ready.
rollBackLastValid() {
n=$1
output=''
while ((${#output} == 0))
do
((n=$n + 1))
output=$(git diff --name-only HEAD HEAD~$n -- *.java)
done
rollBackN $n
return $n
}
# Param1: projectName
# Param2: logFileName
# Param3: timeFileName
# Param4: phaseTimeFileName
# Param5: ifExecuteWithoutEkstazi true/false
# Param6: ifExecuteOriginalEkstazi true/false
# Param7: ifExecuteOurEkstazi true/false
run() {
projectName=$1
logFileName=$2
timeFileName=$3
phaseTimeFileName=$4
ifExecuteWithoutEkstazi=$5
ifExecuteOriginalEkstazi=$6
ifExecuteOurEkstazi=$7
cp pom.xml ../Res/$1/pom.xml
printf "$(git rev-parse HEAD)," >> $timeFileName
# Run without Ekstazi
if [[ $ifExecuteWithoutEkstazi == true ]]
then
start_time=$(python -c "import time; print(int(time.time()*1000))")
mvn -Drat.ignoreErrors=true -Dcheckstyle.skip clean install >> $logFileName
mvnExitCode=$?
end_time=$(python -c "import time; print(int(time.time()*1000))")
printf `expr $end_time - $start_time` >> $timeFileName
printf "," >> $timeFileName
# Remove color information from logfiles (for maven ouput)
rm -f "${logFileName}s"
sed 's/\x1B[@A-Z\\\]^_]\|\x1B\[[0-9:;<=>?]*[-!"#$%&'"'"'()*+,.\/]*[][\\@A-Z^_`a-z{|}~]//g' $logFileName > "${logFileName}s"
rm $logFileName
mv "${logFileName}s" $logFileName
rm "${logFileName}s"
# Check if maven build successfully
if [[ "$mvnExitCode" -ne 0 ]]
then
# Print out exe time if the following 2 steps are not exed at all.
printf "0,0," >> $timeFileName
printf "0,0,0,0,\n" >> $phaseTimeFileName
return 1
fi
else
printf "0," >> $timeFileName
fi
# Run with original Ekstazi
if [[ $ifExecuteOriginalEkstazi == true ]]
then
# Modifiy pom.xml to load ekstazi
python ../Res/ekstaziInsertionOriEkstazi.py pom.xml
rm -rf .ekstazi
prevEkstaziFolder="../Res/${projectName}/.ekstazi"
if [[ -d $prevEkstaziFolder ]]
then
cp -r $prevEkstaziFolder .ekstazi
fi
start_time=$(python -c "import time; print(int(time.time()*1000))")
mvn -Drat.ignoreErrors=true -Dcheckstyle.skip clean install >> $logFileName
mvnExitCode=$?
end_time=$(python -c "import time; print(int(time.time()*1000))")
printf `expr $end_time - $start_time` >> $timeFileName
printf "," >> $timeFileName
# Remove color information from logfiles (for maven ouput)
rm -f "${logFileName}s"
sed 's/\x1B[@A-Z\\\]^_]\|\x1B\[[0-9:;<=>?]*[-!"#$%&'"'"'()*+,.\/]*[][\\@A-Z^_`a-z{|}~]//g' $logFileName > "${logFileName}s"
rm $logFileName
mv "${logFileName}s" $logFileName
rm "${logFileName}s"
if [[ "$mvnExitCode" -ne 0 ]]
then
# Print out exe time if the following 1 step are not exed at all.
printf "0," >> $timeFileName
# If build fail, and tmptimeA.csv exist, record the phase time as 0.
printf "0,0,0,0," >> $phaseTimeFileName
return 1
fi
# If build success, and tmptimeA.csv exist, record the phase time.
timeParseOutput=$(python ../Res/EkstaziTimeParser.py)
printf "$timeParseOutput" >> $phaseTimeFileName
# if build success, rm the original .ekstazi folder, copy-past the new .ekstazi folder
rm -rf $prevEkstaziFolder
cp -r .ekstazi $prevEkstaziFolder
else
printf "0," >> $timeFileName
printf "0,0,0,0," >> $phaseTimeFileName
fi
# Run with our Ekstazi
if [[ $ifExecuteOurEkstazi == true ]]
then
cp ../Res/$1/pom.xml pom.xml
python ../Res/ekstaziInsertion.py pom.xml
# prevEkstaziFolder="../Res/${projectName}/.ekstazi"
# rm -r -f .ekstazi
# if [[ -d $prevEkstaziFolder ]]
# then
# cp -r $prevEkstaziFolder .ekstazi
# fi
rm -f tmptimeA.csv
rm -f tmptimeEC.csv
start_time=$(python -c "import time; print(int(time.time()*1000))")
mvn -Drat.ignoreErrors=true -Dcheckstyle.skip clean install >> $logFileName
mvnExitCode=$?
end_time=$(python -c "import time; print(int(time.time()*1000))")
printf `expr $end_time - $start_time` >> $timeFileName
printf "," >> $timeFileName
# Remove color information from logfiles (for maven ouput)
rm -f "${logFileName}s"
sed 's/\x1B[@A-Z\\\]^_]\|\x1B\[[0-9:;<=>?]*[-!"#$%&'"'"'()*+,.\/]*[][\\@A-Z^_`a-z{|}~]//g' $logFileName > "${logFileName}s"
rm $logFileName
mv "${logFileName}s" $logFileName
rm "${logFileName}s"
if [[ "$mvnExitCode" -ne 0 ]]
then
# If build fail, and tmptimeA.csv exist, record the phase time as 0.
printf "0,0,0,0,\n" >> $phaseTimeFileName
return 1
fi
# If build success, and tmptimeA.csv exist, record the phase time.
timeParseOutput=$(python ../Res/EkstaziTimeParser.py)
printf "$timeParseOutput\n" >> $phaseTimeFileName
else
printf "0," >> $timeFileName
printf "0,0,0,0,\n" >> $phaseTimeFileName
fi
return 0
}
# Param1: projectName
# Param2: if No Ekstazi
# Param3: if with the original Ekstazi
# Param4: if with the modified Ekstazi
main() {
projectName=$1
ifWithout=$2
ifOri=$3
ifModif=$4
cd $projectName
git clean -fd
git checkout -f origin/master
# Make sure that previous ekstazi is removed.
rm -rf .ekstazi
rm -rf ../Res/$projectName/.ekstazi
time=$(date "+%Y%m%d-%H%M%S")
# Mainly record maven output
logFileName="../Res/$projectName/$time.log"
# a csv file: commitSHA,RunWithoutEkstaziInSec,RunWithMilosEkstaziInSec,RunWithOurEkstaziInSec,ExitCode,
timeFileName="../Res/$projectName/$time.time.log"
# Add a title for timeFileName
printf "commitSHA,RunWithoutEkstaziInSec,RunWithMilosEkstaziInSec,RunWithOurEkstaziInSec,ExitCode,\n" >> $timeFileName
# Record time per phase.
# With Csv format - ATime, ETime, CTime, TestClassNum,
phaseTimeFileName="../Res/$projectName/$time.phase.time.log"
# Add a title for phaseTimeFileName
printf "ATime_ori,ETime_ori,CTime_ori,TestClassNum_ori,ATime_ours,ETime_ours,CTime_ours,TestClassNum_ours,\n" >> $phaseTimeFileName
# If folder exists, -p will skip this mkdir.
mkdir -p ../Res/$projectName
# Remove the initial .ekstazi folder, if exist.
rm -rf ../Res/$projectName/.esktazi
lastValidSha=$(git rev-parse HEAD)
round=20
run $projectName $logFileName $timeFileName $phaseTimeFileName $ifWithout $ifOri $ifModif
# If the above line fails, -1 will be added as the exitcode. Otherwise, 0.
if [[ "$?" -ne 0 ]]
then
printf "1,\n" >> $timeFileName
round=1+$round
else
printf "0,\n" >> $timeFileName
fi
# for the residual 19 reversions -
rollbackNum=0
while (($round>=2))
do
((round=$round-1))
rollBackLastValid $rollbackNum
rollbackNum=$?
run $projectName $logFileName $timeFileName $phaseTimeFileName $ifWithout $ifOri $ifModif
if [[ "$?" -ne 0 ]]
then
printf "1,\n" >> $timeFileName
((round=$round+1))
git clean -fd
git checkout -f $lastValidSha
else
printf "0,\n" >> $timeFileName
lastValidSha=$(git rev-parse HEAD)
rollbackNum=0
fi
done
cd ..
}
# Which version of Ekstazi to run
# No Ekstazi - default false
ifWithout=${$1:-false}
# The original Ekstazi - default false
ifOri=${$2:-false}
# The modified Ekstazi - default true
ifModif=${$3:-true}
# main javapoet $ifWithout $ifOri $ifModif
# main commons-cli $ifWithout $ifOri $ifModif
# main commons-math $ifWithout $ifOri $ifModif
# main commons-email $ifWithout $ifOri $ifModif
# main commons-jexl $ifWithout $ifOri $ifModif
# main commons-validator $ifWithout $ifOri $ifModif
# main commons-net $ifWithout $ifOri $ifModif