My favorites | Sign in
Project Logo
             
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
#!/bin/sh
# Simple continuous build for Wine
# Copyright 2008 Google (Dan Kegel)
# License: LGPL
#
# Watches the wine-patches mailing list, builds incoming patches against
# current git, runs conformance tests.
# Results sent out via email and uploaded to a web site.

# Warning:
# This script executes source code sent in by anonymous users,
# and is therefore very dangerous. Run this in as isolated
# and low-privilege environment as possible.
# The ftp account you upload results to should also have as
# few permissions as possible, and should not be able to write
# anything interesting.
# TODO: merge chroot code, e.g. Ambroz's, see
# http://www.winehq.org/pipermail/wine-devel/2008-August/068037.html

# Prerequisites:
# Must do
# sudo apt-get install libmail-pop3client-perl
# sudo apt-get install libmime-perl
# sudo apt-get install mailx
# and make sure mailx can send mail before running first time.
# (You may need to do sudo dpkg-reconfigure exim4-config.)
#
# Must set environment vars to point to a mailbox subscribed to wine-patches
# PATCHWATCHER_USER=user@host.com
# PATCHWATCHER_HOST=mail.host.com
# PATCHWATCHER_PASSWORD=userpass
# before running.
# All messages will slowly be deleted from the mailbox as this script runs.

# Must set envionment vars to point to an ftp account:
# PATCHWATCHER_FTP=ftp.host.com
# This script assumes that you have configured ftp (perhaps via ~/.netrc)
# with the username and password to allow the script to upload to the
# results directory at $PATCHWATCHER_FTP via ftp.

# Must set env vars to point to the web page results will appear:
# PATCHWATCHER_URL=http://www.host.com/patchwatcher/results
# This should refer to the same directory as $PATCHWATCHER_FTP/results.

# This script configures and builds wine in a directory called 'active'.
# Then whenever it wants to try a new patch, it moves that directory
# aside and replaces it with a copy.
# When it's done trying out the patch, it deletes the copy and moves
# the real directory back where it was.
# All this fancy dancing is just to avoid irritating anything
# that depends on absolute paths being the same as when 'configure' was run.
# The copies sound slow but they only take a few seconds on a
# modern machine.

set -e
set -x

# This script is not yet internationalized properly, so set locale to
# one that it can handle
LANG=C

# Work around xcb locking bug on recent xorg. See also
# https://bugs.launchpad.net/ubuntu/+source/libxcb/+bug/185311
# http://lists.opensuse.org/opensuse-commit/2007-03/msg00176.html
export LIBXCB_ALLOW_SLOPPY_LOCK=1

# Set this to true on first run and after debugging
initialize=false
# Set this to true for continuous build
loop=true

TOP=`pwd`
PATCHES=$TOP/patches
WORK=$TOP/wine-continuous-workdir

WINE=$WORK/active/wine
WINESERVER=$WORK/active/server/wineserver
WINEPREFIX=$HOME/.wine
# export so we can invoke winetricks
export WINE WINEPREFIX

baseline_tests()
{
# Gather list of tests that fail at least once in N runs
# Once this script is debugged, crank up the number of runs a bit here
cd $WORK/active
echo Running baseline test, output to $PWD/baseline.testlog
for try in 1 2 3 4 5
do
make testclean
$WINESERVER -k || true
rm -rf $WINEPREFIX || true
sh $TOP/../winetricks gecko
WINETEST_WRAPPER="$TOP/alarm 150" make -k test || true
done > baseline.testlog 2>&1

perl $TOP/get-dll.pl < baseline.testlog | egrep ": Test failed: |: Test succeeded inside todo block: |^make\[.*\]: \*\*\* \[|wineserver crashed|Timeout! Killing child" | sort -u > baseline.testdat || true
# Record for posterity
cp baseline.testlog $PATCHES/baseline.testlog
cp baseline.testdat $PATCHES/baseline.testdat
}

initialize_tree()
{
cd $WORK
git clone git://source.winehq.org/git/wine.git active
cd active
# Regenerate configure now to track what we do when patches are applied
tools/make_makefiles
autoconf
./configure
make depend
make -j3

baseline_tests
}

refresh_tree()
{
cd $WORK/active
# Recover from any accidental damage
git diff | grep -v '^diff --git' > git.diff && patch -R -p1 < git.diff
# Grab latest source
git pull > git.log 2>&1
cat git.log
if ! grep -q "Already up-to-date." < git.log
then
# Regenerate everything in case patch adds a new dll or changes configure.ac
tools/make_makefiles
autoconf
./configure
make depend
time make -j3
baseline_tests
fi
}

retrieve_patches()
{
cd $PATCHES
LAST=`ls *.txt | sort -n | tail -1 | sed 's/\.txt$//'`
NEXT=`expr $LAST + 1`
perl $TOP/get-patches.pl $NEXT || true
# Handle immediate results
while test -f $NEXT.log
do
report_results patch $NEXT.txt $NEXT.log
NEXT=`expr $NEXT + 1`
done
}

# Usage: report_results build|make|test|success patch log
report_results()
{
status=$1
patch=$2
log=$3

cd $PATCHES

# Retrieve sender and subject from patch file
# Patch file is written by get-patches.pl in a specific format,
# always starts with an email header.
patch_sender="`cat $patch | grep '^From:' | head -n 1 | sed 's/^From: //;s/.*<//;s/>.*//'`"
patch_subject="`cat $patch | grep '^Subject:' | head -n 1 | sed 's/^Subject: //'`"
case $status in
patch)
if egrep -q "can't find file to patch|hunk FAILED" $log
then
status_long="failed to apply"
elif egrep -q "Reversed \(or previously applied\) patch" $log
then
status_long="already applied"
# inhibit email
status=success;
fi
;;
build) status_long="failed to build" ;;
test) status_long="failed regression tests" ;;
success) status_long="applied, built, and passed tests" ;;
esac

cat - > msg.dat <<_EOF_
Hi! This is the experimental automated wine patchwatcher thingy.
The latest git sources were built and tested with your patch
"$patch_subject"
Result: the patch $status_long.

You can retrieve the full build results at
$PATCHWATCHER_URL/$log
and see the patch as parsed at
$PATCHWATCHER_URL/$patch
See
$PATCHWATCHER_URL
for more info.

_EOF_

case $status in
success)
# Send munged version of patch; it will show up as from the patchwatcher user, so
# put original sender in subject line, like wine-cvs does
mailx -s "${patch_sender}: $patch_subject" wine-patches-filtered@googlegroups.com < $patch
;;
*)
mailx -s "Patchwatcher: ${status_long}: $patch_subject" "$patch_sender" dank@kegel.com < msg.dat
;;
esac
rm msg.dat

perl $TOP/dashboard.pl > index.html
ftp $PATCHWATCHER_FTP <<_EOF_
cd results
put $patch
put $log
put index.html
quit
_EOF_
}

# Return true if a patch was tried, false if no patches left to try
try_one_patch()
{
cd $PATCHES

# Find first patch that doesn't have a .log
NEXT=""
for p in `ls *.txt *.log | sort -n | sed 's/\..*//' | sort -n | uniq -c | awk '$1 == 1 {print $2}'`
do
if test -f $p.txt
then
NEXT=$p
break
fi
done

if test -z "$NEXT"
then
echo No patch to apply
return 1
fi

cd $WORK
rm -rf golden
mv active golden
cp -a golden active

# Do one patch (or patch series).
# This loop assumes that get-patches.pl never outputs incomplete patch series
while true
do
echo Processing patch $NEXT.txt:
cat $PATCHES/$NEXT.txt

cd $WORK/active
# Should we use -p1 or -p0?
# CVS patches need -p0, git patches need -p1
# For now, always use -p0 unless it's obvious patch was
# generated with cvs or svn
if egrep -q 'RCS file|^+++.*working copy' < $PATCHES/$NEXT.txt
then
p=0
else
p=1
fi

if ! patch -p$p < $PATCHES/$NEXT.txt > $PATCHES/$NEXT.log 2>&1
then
report_results patch $NEXT.txt $NEXT.log
else
# Note: don't use parallel build, we want to email a nice clean log
# Regenerate everything in case patch adds a new dll or changes configure.ac
if tools/make_makefiles &&
autoconf &&
./configure &&
make depend &&
make 2>&1 | perl $TOP/trim-build-log.pl >> $PATCHES/$NEXT.log &&
grep "^Wine build complete" $PATCHES/$NEXT.log
then
make testclean
$WINESERVER -k || true
rm -rf $WINEPREFIX || true
sh $TOP/../winetricks gecko
WINETEST_WRAPPER="$TOP/alarm 150" make -k test > $PATCHES/$NEXT.testlog 2>&1 || true
perl $TOP/get-dll.pl < $PATCHES/$NEXT.testlog | egrep ": Test failed: |: Test succeeded inside todo block: |^make\[.*\]: \*\*\* \[|wineserver crashed|Timeout! Killing child" | sort -u > $PATCHES/$NEXT.testdat || true
# Regular expression matching known flaky tests
# This list is built up by simply running patchwatcher for a while,
# then doing "blacklist.sh > blacklist.txt"
# Annoyingly, no matter how many times I run the baseline tests,
# these buggers still manage to fail in new ways when testing patches.
egrep -v `cat $TOP/blacklist.txt` < $PATCHES/$NEXT.testdat > $PATCHES/$NEXT.testfilt
cat $PATCHES/$NEXT.testlog >> $PATCHES/$NEXT.log
echo "Regression test changes vs. baseline test runs:" >> $PATCHES/$NEXT.log
diff baseline.testdat $PATCHES/$NEXT.testdat >> $PATCHES/$NEXT.log || true
# Report failure if any new nonblacklisted errors
diff baseline.testdat $PATCHES/$NEXT.testfilt > $PATCHES/$NEXT.testdiff || true
if grep -q '^> ' < $PATCHES/$NEXT.testdiff
then
echo "Ditto, but just the new errors:" >> $PATCHES/$NEXT.log
grep '^> ' < $PATCHES/$NEXT.testdiff | sed 's/^>//' >> $PATCHES/$NEXT.log || true
report_results test $NEXT.txt $NEXT.log
else
echo "Conformance tests ok" >> $PATCHES/$NEXT.log
report_results success $NEXT.txt $NEXT.log
fi
else
# make failed
report_results build $NEXT.txt $NEXT.log
fi
cat $PATCHES/$NEXT.log
fi
# Use a regexp with a back reference to detect last patch in a series and break out
if egrep -q 'Subject:.*[0-9]+/[0-9]+' $PATCHES/$NEXT.txt && ! egrep -q 'Subject:.*([0-9]+)/\1[^0-9]' $PATCHES/$NEXT.txt
then
echo In middle of patch series, not wiping tree
NEXT=`expr $NEXT + 1`
else
break
fi
done

cd $WORK
rm -rf active
mv golden active
return 0
}

continuous_build()
{
while true
do
date
refresh_tree
retrieve_patches
while try_one_patch
do
sleep 1
$loop || break
done
sleep 60
$loop || break
done
}

mkdir -p $PATCHES/mimemail

if $initialize
then
rm -rf $WORK
mkdir -p $WORK
initialize_tree
else
# Recover from run aborted with ^C
if test -d $WORK/golden
then
rm -rf $WORK/active
mv $WORK/golden $WORK/active
fi
fi

continuous_build
Show details Hide details

Change log

r183 by austinenglish on Sep 16, 2008   Diff
revert last change...wasn't intended,
silly svn
Go to: 
Project members, sign in to write a code review

Older revisions

r182 by austinenglish on Sep 16, 2008   Diff
nuke the static analysis output
r177 by daniel.r.kegel on Sep 05, 2008   Diff
Update blacklist to match failures
seen on new machine
Move blacklist to external file
Rename flaky.* to baseline.*
Add script to help generate blacklist
...
r169 by daniel.r.kegel on Aug 24, 2008   Diff
Avoid duplicating From and Subject
lines in reports.

When patches pass all tests, forward
them to wine-patches-
...
All revisions of this file

File info

Size: 11520 bytes, 361 lines
Hosted by Google Code