OLD | NEW |
(Empty) | |
| 1 #!/bin/sh |
| 2 # Scape errors from the valgrind bots, reproduce them locally, |
| 3 # save logs as regrind-TESTNAME.log, and display any errors found. |
| 4 # Also save files regrind-failed.txt listing failed tests, |
| 5 # and regrind-failed-map.txt showing which bot URLs have which failed tests |
| 6 # (handy when filing bugs). |
| 7 # |
| 8 # Only scrapes linux layout bot at the moment. |
| 9 # TODO: handle layout tests that don't have obvious path to test file |
| 10 # TODO: extend script to handle more kinds of errors and more tests |
| 11 |
| 12 # where the valgrind layout bot results live |
| 13 LAYOUT_URL="http://build.chromium.org/buildbot/waterfall/builders/Webkit%20Linux
%20(valgrind%20layout)" |
| 14 # how many builds back to check |
| 15 LAYOUT_COUNT=250 |
| 16 |
| 17 # regexp to match valgrind errors |
| 18 PATTERN="are definitely|uninitialised|Unhandled exception|\ |
| 19 Invalid read|Invalid write|Invalid free|Source and desti|Mismatched free|\ |
| 20 unaddressable byte|vex x86|the 'impossible' happened|\ |
| 21 valgrind:.*: Assertion.*failed|VALGRIND INTERNAL ERROR" |
| 22 |
| 23 usage() { |
| 24 echo "Usage: regrind.sh [--noscrape][--norepro][--keep]" |
| 25 echo "--noscrape: don't scrape bots, just use old regrind-failed.txt" |
| 26 echo "--norepro: don't reproduce locally" |
| 27 echo "--keep: keep temp files" |
| 28 exit 1 |
| 29 } |
| 30 |
| 31 # Given a log on stdin, list all the tests that failed in that log. |
| 32 layout_list_failed_tests() { |
| 33 grep "Command:.*LayoutTests" | |
| 34 sed 's/<.*>//' | |
| 35 sed 's/.*LayoutTests/LayoutTests/' | |
| 36 sort -u | |
| 37 tr -d '\015' |
| 38 } |
| 39 |
| 40 # Generate a list of failed tests in regrind-failed.txt by scraping bot. |
| 41 # Scrape most recent first, so if user interrupts, he is left with fresh-ish dat
a. |
| 42 scrape_layout() { |
| 43 rm -f regrind-*.tmp* regrind-failed.txt regrind-failed-map.txt |
| 44 touch regrind-failed.txt |
| 45 |
| 46 # First, grab the number of the latest complete build. |
| 47 wget -q -O regrind-builds.html "$LAYOUT_URL" |
| 48 latest=`grep "<li><font .*" < regrind-builds.html | head -1 | sed 's/.*#//;s/<
.*//'` |
| 49 |
| 50 echo "Fetching $LAYOUT_COUNT logs from bot" |
| 51 # Scrape the desired number of runs (150 is about one cycle) |
| 52 first=`expr $latest - $LAYOUT_COUNT` |
| 53 i=$latest |
| 54 while test $i -ge $first |
| 55 do |
| 56 url="$LAYOUT_URL/builds/$i/steps/valgrind%20test:%20layout/logs/stdio" |
| 57 wget -q -O regrind-$i.tmp "$url" |
| 58 # Did any tests fail in this file? |
| 59 layout_list_failed_tests < regrind-$i.tmp > regrind-$i.tmp.failed |
| 60 if test -s regrind-$i.tmp.failed |
| 61 then |
| 62 # Yes. Log them to stdout, |
| 63 echo "$url" |
| 64 cat regrind-$i.tmp.failed |
| 65 # to the table regrind-failed-map.txt, |
| 66 cat regrind-$i.tmp.failed | sed "s,^,$url ," >> regrind-failed-map.txt |
| 67 # and, if not already there, to regrind-failed.txt. |
| 68 for test in `cat regrind-$i.tmp.failed` |
| 69 do |
| 70 fgrep "$test" regrind-failed.txt > /dev/null 2>&1 || echo "$test" >> reg
rind-failed.txt |
| 71 done |
| 72 else |
| 73 rm regrind-$i.tmp.failed |
| 74 fi |
| 75 # Sleep 1/3 sec per fetch |
| 76 case $i in |
| 77 *[036]) sleep 1;; |
| 78 esac |
| 79 i=`expr $i - 1` |
| 80 done |
| 81 |
| 82 # Finally, munge the logs to identify tests that probably failed. |
| 83 sh c.sh -l regrind-*.tmp > regrind-errfiles.txt |
| 84 cat `cat regrind-errfiles.txt` | layout_list_failed_tests > regrind-failed.txt |
| 85 } |
| 86 |
| 87 # Run the tests identified in regrind-failed.txt locally under valgrind. |
| 88 # Save logs in regrind-$TESTNAME.log. |
| 89 repro_layout() { |
| 90 echo Running `wc -l < regrind-failed.txt` layout tests. |
| 91 for test in `cat regrind-failed.txt` |
| 92 do |
| 93 logname="`echo $test | tr / _`" |
| 94 echo "sh tools/valgrind/valgrind_webkit_tests.sh $test" |
| 95 sh tools/valgrind/valgrind_webkit_tests.sh "$test" > regrind-"$logname".log
2>&1 |
| 96 egrep "$PATTERN" < regrind-"$logname".log | sed 's/==.*==//' |
| 97 done |
| 98 } |
| 99 |
| 100 do_repro=1 |
| 101 do_scrape=1 |
| 102 do_cleanup=1 |
| 103 while test ! -z "$1" |
| 104 do |
| 105 case "$1" in |
| 106 --noscrape) do_scrape=0;; |
| 107 --norepro) do_repro=0;; |
| 108 --keep) do_cleanup=0;; |
| 109 *) usage;; |
| 110 esac |
| 111 shift |
| 112 done |
| 113 |
| 114 if test $do_scrape = 0 && test $do_repro = 0 |
| 115 then |
| 116 usage |
| 117 fi |
| 118 |
| 119 if test $do_scrape = 1 |
| 120 then |
| 121 scrape_layout |
| 122 fi |
| 123 |
| 124 if test $do_repro = 1 |
| 125 then |
| 126 repro_layout |
| 127 fi |
| 128 |
| 129 if test $do_cleanup = 1 |
| 130 then |
| 131 rm -f regrind-errfiles.txt regrind-*.tmp* |
| 132 fi |
OLD | NEW |