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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
#!/bin/bash -e
# -*- Mode: Shell-script; tab-width: 4; indent-tabs-mode: nil; -*-
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla JavaScript Testing Utilities
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s): Bob Clary <bclary@bclary.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
if [[ -z "$TEST_DIR" ]]; then
cat <<EOF
`basename $0`: error
TEST_DIR, the location of the Sisyphus framework,
is required to be set prior to calling this script.
EOF
exit 2
fi
if [[ ! -e $TEST_DIR/bin/library.sh ]]; then
cat <<EOF
TEST_DIR=$TEST_DIR"
This script requires the Sisyphus testing framework. Please
cvs check out the Sisyphys framework from mozilla/testing/sisyphus
and set the environment variable TEST_DIR to the directory where it
located.
EOF
exit 2
fi
source $TEST_DIR/bin/library.sh
usage()
{
cat <<EOF
usage: bisect.sh -p product -b branch -e extra\\
-T buildtype \\
-t test \\
-S string \\
-G good -B bad \\
[-J javascriptoptions]
variable description
=============== ============================================================
-p bisect_product one of js, firefox
-b bisect_branches one of supported branches. see library.sh
-e bisect_extra optional. extra qualifier to pick build tree and mozconfig.
-T bisect_buildtype one of build types opt debug
-t bisect_test Test to be bisected.
-S bisect_string optional. String containing a regular expression which
can be used to distinguish different failures for the given
test. The script will search the failure log for the pattern
"\$bisect_test.*\$string" to determine if a test failure
matches the expected failure.
bisect_string can contain any extended regular expressions
supported by egrep.
-G bisect_good For branches 1.8.0, 1.8.1, 1.9.0, date test passed
For branch 1.9.1 and later, revision test passed
-B bisect_bad For branches, 1.8.0, 1.8.1, 1.9.0 date test failed
For branch 1.9.1 and later, revision test failed.
If the good revision (test passed) occurred prior to the bad revision
(test failed), the script will search for the first bad revision which
caused the test to regress.
If the bad revision (test failed) occurred prior to the good revision
(test passed), the script will search for the first good revision which
fixed the failing test.
-D By default, clobber builds will be used. For mercurial based builds
on branch 1.9.1 and later, you may specify -D to use depends builds.
This may achieve significant speed advantages by eliminating the need
to perform clobber builds for each bisection.
-J javascriptoptions optional. Set JavaScript options:
-Z n Set gczeal to n. Currently, only valid for
debug builds of Gecko 1.8.1.15, 1.9.0 and later.
-z optional. use split objects in the shell.
-j optional. use JIT in the shell. Only available on 1.9.1 and later
EOF
exit 2
}
verbose=0
while getopts "p:b:T:e:t:S:G:B:J:D" optname;
do
case $optname in
p) bisect_product=$OPTARG;;
b) bisect_branch=$OPTARG;;
T) bisect_buildtype=$OPTARG;;
e) bisect_extra="$OPTARG"
bisect_extraflag="-e $OPTARG";;
t) bisect_test="$OPTARG";;
S) bisect_string="$OPTARG";;
G) bisect_good="$OPTARG";;
B) bisect_bad="$OPTARG";;
J) javascriptoptions=$OPTARG;;
D) bisect_depends=1;;
esac
done
# javascriptoptions will be passed by environment to runtests.sh
if [[ -z "$bisect_product" || -z "$bisect_branch" || -z "$bisect_buildtype" || -z "$bisect_test" || -z "$bisect_good" || -z "$bisect_bad" ]]; then
echo "bisect_product: $bisect_product, bisect_branch: $bisect_branch, bisect_buildtype: $bisect_buildtype, bisect_test: $bisect_test, bisect_good: $bisect_good, bisect_bad: $bisect_bad"
usage
fi
OPTIND=1
# evaluate set-build-env.sh in this process to pick up the necessary environment
# variables, but restore the PATH and PYTHON to prevent their interfering with
# Sisyphus.
savepath="$PATH"
savepython="$PYTHON"
eval source $TEST_DIR/bin/set-build-env.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype > /dev/null
PATH=$savepath
PYTHON=$savepython
# TEST_JSDIR must be set after set-build-env.sh is called
# on Windows since TEST_DIR can be modified in set-build-env.sh
# from the pure cygwin path /work/... to the cygwin windows path
# /c/work/...
TEST_JSDIR=${TEST_JSDIR:-$TEST_DIR/tests/mozilla.org/js}
if [[ "$bisect_branch" == "1.8.0" || "$bisect_branch" == "1.8.1" || \
"$bisect_branch" == "1.9.0" ]]; then
#
# binary search using CVS
#
# convert dates to seconds for ordering
localgood=`dateparse.pl $bisect_good`
localbad=`dateparse.pl $bisect_bad`
# if good < bad, then we are searching for a regression,
# i.e. the first bad changeset
# if bad < good, then we are searching for a fix.
# i.e. the first good changeset. so we reverse the nature
# of good and bad.
if (( $localgood < $localbad )); then
cat <<EOF
searching for a regression between $bisect_good and $bisect_bad
the bisection is searching for the transition from test failure not found, to test failure found.
EOF
searchtype="regression"
bisect_start=$bisect_good
bisect_stop=$bisect_bad
else
cat <<EOF
searching for a fix between $bisect_bad and $bisect_good
the bisection is searching for the transition from test failure found to test failure not found.
EOF
searchtype="fix"
bisect_start=$bisect_bad
bisect_stop=$bisect_good
fi
let seconds_start="`dateparse.pl $bisect_start`"
let seconds_stop="`dateparse.pl $bisect_stop`"
echo "checking that the test fails in the bad revision $bisect_bad"
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "clobber" > /dev/null
export MOZ_CO_DATE="$bisect_bad"
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "checkout" > /dev/null
bisect_log=`eval $TEST_JSDIR/runtests.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -I $bisect_test -B "build" -c -t -X /dev/null 2>&1 | grep '_js.log $' | sed 's|log: \([^ ]*\) |\1|'`
if [[ -z "$bisect_log" ]]; then
echo "test $bisect_test not run."
else
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found, bad revision $bisect_bad confirmed"
bad_confirmed=1
else
echo "test failure $bisect_test.*$bisect_string not found, bad revision $bisect_bad *not* confirmed"
fi
fi
if [[ "$bad_confirmed" != "1" ]]; then
error "bad revision not confirmed";
fi
echo "checking that the test passes in the good revision $bisect_good"
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "clobber" > /dev/null
export MOZ_CO_DATE="$bisect_good"
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "checkout" > /dev/null
bisect_log=`eval $TEST_JSDIR/runtests.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -I $bisect_test -B "build" -c -t -X /dev/null 2>&1 | grep '_js.log $' | sed 's|log: \([^ ]*\) |\1|'`
if [[ -z "$bisect_log" ]]; then
echo "test $bisect_test not run."
else
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found, good revision $bisect_good *not* confirmed"
else
echo "test failure $bisect_test.*$bisect_string not found, good revision $bisect_good confirmed"
good_confirmed=1
fi
fi
if [[ "$good_confirmed" != "1" ]]; then
error "good revision not confirmed";
fi
echo "bisecting $bisect_start to $bisect_stop"
#
# place an array of dates of checkins into an array and
# perform a binary search on those dates.
#
declare -a seconds_array date_array
# load the cvs checkin dates into an array. the array will look like
# date_array[i] date value
# date_array[i+1] time value
pushd $BUILDTREE/mozilla
date_array=(`cvs -q -z3 log -N -d "$bisect_start<$bisect_stop" | grep "^date: " | sed 's|^date: \([^;]*\).*|\1|' | sort -u`)
popd
let seconds_index=0 1
let date_index=0 1
while (( $date_index < ${#date_array[@]} )); do
seconds_array[$seconds_index]=`dateparse.pl "${date_array[$date_index]} ${date_array[$date_index+1]} UTC"`
let seconds_index=$seconds_index+1
let date_index=$date_index+2
done
let seconds_index_start=0 1
let seconds_index_stop=${#seconds_array[@]}
while true; do
if (( $seconds_index_start+1 >= $seconds_index_stop )); then
echo "*** date `perl -e 'print scalar localtime $ARGV[0];' ${seconds_array[$seconds_index_stop]}` found ***"
break;
fi
unset result
# clobber before setting new changeset.
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "clobber" > /dev/null
let seconds_index_middle="($seconds_index_start + $seconds_index_stop)/2"
let seconds_middle="${seconds_array[$seconds_index_middle]}"
bisect_middle="`perl -e 'print scalar localtime $ARGV[0];' $seconds_middle`"
export MOZ_CO_DATE="$bisect_middle"
echo "testing $MOZ_CO_DATE"
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "checkout" > /dev/null
bisect_log=`eval $TEST_JSDIR/runtests.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -I $bisect_test -B "build" -c -t -X /dev/null 2>&1 | grep '_js.log $' | sed 's|log: \([^ ]*\) |\1|'`
if [[ -z "$bisect_log" ]]; then
echo "test $bisect_test not run. Skipping changeset"
let seconds_index_start=$seconds_index_start+1
else
if [[ "$searchtype" == "regression" ]]; then
# searching for a regression, pass -> fail
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found"
let seconds_index_stop=$seconds_index_middle;
else
echo "test failure $bisect_test.*$bisect_string not found"
let seconds_index_start=$seconds_index_middle
fi
else
# searching for a fix, fail -> pass
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found"
let seconds_index_start=$seconds_index_middle
else
echo "test failure $bisect_test.*$bisect_string not found"
let seconds_index_stop=$seconds_index_middle
fi
fi
fi
done
else
#
# binary search using mercurial
#
TEST_MOZILLA_HG_LOCAL=${TEST_MOZILLA_HG_LOCAL:-$BUILDDIR/hg.mozilla.org/`basename $TEST_MOZILLA_HG`}
hg -R $TEST_MOZILLA_HG_LOCAL pull -r tip
REPO=$BUILDTREE/mozilla
hg -R $REPO pull -r tip
# convert revision numbers to local revision numbers for ordering
localgood=`hg -R $REPO id -n -r $bisect_good`
localbad=`hg -R $REPO id -n -r $bisect_bad`
# if good < bad, then we are searching for a regression,
# i.e. the first bad changeset
# if bad < good, then we are searching for a fix.
# i.e. the first good changeset. so we reverse the nature
# of good and bad.
if (( $localgood < $localbad )); then
cat <<EOF
searching for a regression between $localgood:$bisect_good and $localbad:$bisect_bad
the result is considered good when the test result does not appear in the failure log, bad otherwise.
the bisection is searching for the transition from test failure not found, to test failure found.
EOF
searchtype="regression"
bisect_start=$bisect_good
bisect_stop=$bisect_bad
else
cat <<EOF
searching for a fix between $localbad:$bisect_bad and $localgood:$bisect_good
the result is considered good when the test result does appear in the failure log, bad otherwise.
the bisection is searching for the transition from test failure found to test failure not found.
EOF
searchtype="fix"
bisect_start=$bisect_bad
bisect_stop=$bisect_good
fi
echo "checking that the test fails in the bad revision $localbad:$bisect_bad"
if [[ -z "$bisect_depends" ]]; then
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "clobber" > /dev/null
fi
hg -R $REPO update -C -r $bisect_bad
bisect_log=`eval $TEST_JSDIR/runtests.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -I $bisect_test -B "build" -c -t -X /dev/null 2>&1 | grep '_js.log $' | sed 's|log: \([^ ]*\) |\1|'`
if [[ -z "$bisect_log" ]]; then
echo "test $bisect_test not run."
else
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found, bad revision $localbad:$bisect_bad confirmed"
bad_confirmed=1
else
echo "test failure $bisect_test.*$bisect_string not found, bad revision $localbad:$bisect_bad *not* confirmed"
fi
fi
if [[ "$bad_confirmed" != "1" ]]; then
error "bad revision not confirmed";
fi
echo "checking that the test passes in the good revision $localgood:$bisect_good"
if [[ -z "$bisect_depends" ]]; then
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "clobber" > /dev/null
fi
hg -R $REPO update -C -r $bisect_good
bisect_log=`eval $TEST_JSDIR/runtests.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -I $bisect_test -B "build" -c -t -X /dev/null 2>&1 | grep '_js.log $' | sed 's|log: \([^ ]*\) |\1|'`
if [[ -z "$bisect_log" ]]; then
echo "test $bisect_test not run."
else
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found, good revision $localgood:$bisect_good *not* confirmed"
else
echo "test failure $bisect_test.*$bisect_string not found, good revision $localgood:$bisect_good confirmed"
good_confirmed=1
fi
fi
if [[ "$good_confirmed" != "1" ]]; then
error "good revision not confirmed";
fi
echo "bisecting $REPO $bisect_start to $bisect_stop"
hg -q -R $REPO bisect --reset
hg -q -R $REPO bisect --good $bisect_start
hg -q -R $REPO bisect --bad $bisect_stop
while true; do
unset result
# clobber before setting new changeset.
if [[ -z "$bisect_depends" ]]; then
eval $TEST_DIR/bin/builder.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -B "clobber" > /dev/null
fi
# remove extraneous in-tree changes
# See https://bugzilla.mozilla.org/show_bug.cgi?id=480680 for details
# of why this is necessary.
hg -R $REPO update -C
hg -R $REPO bisect
# save the revision id so we can update to it discarding local
# changes in the working directory.
rev=`hg -R $REPO id -i`
bisect_log=`eval $TEST_JSDIR/runtests.sh -p $bisect_product -b $bisect_branch $bisect_extraflag -T $bisect_buildtype -I $bisect_test -B "build" -c -t -X /dev/null 2>&1 | grep '_js.log $' | sed 's|log: \([^ ]*\) |\1|'`
# remove extraneous in-tree changes
# See https://bugzilla.mozilla.org/show_bug.cgi?id=480680 for details
# of why this is necessary.
hg -R $REPO update -C -r $rev
if [[ -z "$bisect_log" ]]; then
echo "test $bisect_test not run. Skipping changeset"
hg -R $REPO bisect --skip
else
if [[ "$searchtype" == "regression" ]]; then
# searching for a regression
# the result is considered good when the test does not appear in the failure log
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found, marking revision bad"
if ! result=`hg -R $REPO bisect --bad 2>&1`; then
echo "bisect bad failed"
error "$result"
fi
else
echo "test failure $bisect_test.*$bisect_string not found, marking revision good"
if ! result=`hg -R $REPO bisect --good 2>&1`; then
echo "bisect good failed"
error "$result"
fi
fi
else
# searching for a fix
# the result is considered good when the test does appear in the failure log
if egrep -q "$bisect_test.*$bisect_string" ${bisect_log}-results-failures.log; then
echo "test failure $bisect_test.*$bisect_string found, marking revision good"
if ! result=`hg -R $REPO bisect --good 2>&1`; then
echo "bisect good failed"
error "$result"
fi
else
echo "test failure $bisect_test.*$bisect_string not found, marking revision bad"
if ! result=`hg -R $REPO bisect --bad 2>&1`; then
echo "bisect bad failed"
error "$result"
fi
fi
fi
fi
if echo $result | egrep -q "The first (good|bad) revision is:"; then
result_revision=`echo $result | sed "s|The first .* revision is:.*changeset: [0-9]*:\([^ ]*\).*|\1|"`
echo $result | sed "s|The first .* revision is:|$searchtype|"
echo "*** revision $result_revision found ***"
break
fi
done
fi
|