Add onFontNameChanged event to Font Settings API
[chromium-blink-merge.git] / tools / valgrind / regrind.sh
blob78e6f7336c1014c2b30e22ccfd7a5a2d7caff6ec
1 #!/bin/sh
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
20 LAYOUT_COUNT=250
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"
28 usage() {
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"
33 exit 1
36 # Given a log on stdin, list all the tests that failed in that log.
37 layout_list_failed_tests() {
38 grep "Command:.*LayoutTests" |
39 sed 's/<.*>//' |
40 sed 's/.*LayoutTests/LayoutTests/' |
41 sort -u |
42 tr -d '\015'
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.
47 scrape_layout() {
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`
58 i=$latest
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
66 then
67 # Yes. Log them to stdout,
68 echo "$url"
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
76 done
77 else
78 rm regrind-$i.tmp.failed
80 # Sleep 1/3 sec per fetch
81 case $i in
82 *[036]) sleep 1;;
83 esac
84 i=`expr $i - 1`
85 done
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.
94 repro_layout() {
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/==.*==//'
102 done
105 do_repro=1
106 do_scrape=1
107 do_cleanup=1
108 while test ! -z "$1"
110 case "$1" in
111 --noscrape) do_scrape=0;;
112 --norepro) do_repro=0;;
113 --keep) do_cleanup=0;;
114 *) usage;;
115 esac
116 shift
117 done
119 echo "WARNING: This script is not supported and may be out of date"
121 if test $do_scrape = 0 && test $do_repro = 0
122 then
123 usage
126 if test $do_scrape = 1
127 then
128 scrape_layout
131 if test $do_repro = 1
132 then
133 repro_layout
136 if test $do_cleanup = 1
137 then
138 rm -f regrind-errfiles.txt regrind-*.tmp*