3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Scape errors from the valgrind bots, reproduce them locally,
8 # save logs as regrind-TESTNAME.log, and display any errors found.
9 # Also save files regrind-failed.txt listing failed tests,
10 # and regrind-failed-map.txt showing which bot URLs have which failed tests
11 # (handy when filing bugs).
13 # Only scrapes linux layout bot at the moment.
14 # TODO: handle layout tests that don't have obvious path to test file
15 # TODO: extend script to handle more kinds of errors and more tests
17 # where the valgrind layout bot results live
18 LAYOUT_URL
="http://build.chromium.org/p/chromium.memory.fyi/builders/Webkit%20Linux%20(valgrind%20layout)"
19 # how many builds back to check
22 # regexp to match valgrind errors
23 PATTERN
="are definitely|uninitialised|Unhandled exception|\
24 Invalid read|Invalid write|Invalid free|Source and desti|Mismatched free|\
25 unaddressable byte|vex x86|the 'impossible' happened|\
26 valgrind:.*: Assertion.*failed|VALGRIND INTERNAL ERROR"
29 echo "Usage: regrind.sh [--noscrape][--norepro][--keep]"
30 echo "--noscrape: don't scrape bots, just use old regrind-failed.txt"
31 echo "--norepro: don't reproduce locally"
32 echo "--keep: keep temp files"
36 # Given a log on stdin, list all the tests that failed in that log.
37 layout_list_failed_tests
() {
38 grep "Command:.*LayoutTests" |
40 sed 's/.*LayoutTests/LayoutTests/' |
45 # Generate a list of failed tests in regrind-failed.txt by scraping bot.
46 # Scrape most recent first, so if user interrupts, he is left with fresh-ish data.
48 rm -f regrind-
*.tmp
* regrind-failed.txt regrind-failed-map.txt
49 touch regrind-failed.txt
51 # First, grab the number of the latest complete build.
52 wget
-q -O regrind-builds.html
"$LAYOUT_URL"
53 latest
=`grep "<li><font .*" < regrind-builds.html | head -1 | sed 's/.*#//;s/<.*//'`
55 echo "Fetching $LAYOUT_COUNT logs from bot"
56 # Scrape the desired number of runs (150 is about one cycle)
57 first
=`expr $latest - $LAYOUT_COUNT`
59 while test $i -ge $first
61 url
="$LAYOUT_URL/builds/$i/steps/valgrind%20test:%20layout/logs/stdio"
62 wget
-q -O regrind-
$i.tmp
"$url"
63 # Did any tests fail in this file?
64 layout_list_failed_tests
< regrind-
$i.tmp
> regrind-
$i.tmp.failed
65 if test -s regrind-
$i.tmp.failed
67 # Yes. Log them to stdout,
69 cat regrind-
$i.tmp.failed
70 # to the table regrind-failed-map.txt,
71 cat regrind-
$i.tmp.failed |
sed "s,^,$url ," >> regrind-failed-map.txt
72 # and, if not already there, to regrind-failed.txt.
73 for test in `cat regrind-$i.tmp.failed`
75 fgrep
"$test" regrind-failed.txt
> /dev
/null
2>&1 ||
echo "$test" >> regrind-failed.txt
78 rm regrind-
$i.tmp.failed
80 # Sleep 1/3 sec per fetch
87 # Finally, munge the logs to identify tests that probably failed.
88 sh c.sh
-l regrind-
*.tmp
> regrind-errfiles.txt
89 cat `cat regrind-errfiles.txt` | layout_list_failed_tests
> regrind-failed.txt
92 # Run the tests identified in regrind-failed.txt locally under valgrind.
93 # Save logs in regrind-$TESTNAME.log.
95 echo Running
`wc -l < regrind-failed.txt` layout tests.
96 for test in `cat regrind-failed.txt`
98 logname
="`echo $test | tr / _`"
99 echo "sh tools/valgrind/valgrind_webkit_tests.sh $test"
100 sh tools
/valgrind
/valgrind_webkit_tests.sh
"$test" > regrind-
"$logname".log
2>&1
101 egrep "$PATTERN" < regrind-
"$logname".log |
sed 's/==.*==//'
111 --noscrape) do_scrape
=0;;
112 --norepro) do_repro
=0;;
113 --keep) do_cleanup
=0;;
119 echo "WARNING: This script is not supported and may be out of date"
121 if test $do_scrape = 0 && test $do_repro = 0
126 if test $do_scrape = 1
131 if test $do_repro = 1
136 if test $do_cleanup = 1
138 rm -f regrind-errfiles.txt regrind-
*.tmp
*