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 # This script can be used by waterfall sheriffs to fetch the status
8 # of Valgrind bots on the memory waterfall and test if their local
9 # suppressions match the reports on the waterfall.
13 THISDIR
=$
(dirname "${0}")
14 LOGS_DIR
=$THISDIR/waterfall.tmp
15 WATERFALL_PAGE
="http://build.chromium.org/p/chromium.memory/builders"
16 WATERFALL_FYI_PAGE
="http://build.chromium.org/p/chromium.memory.fyi/builders"
20 # $1 = URL to download
21 # $2 = Path to the output file
23 if [ "$(which curl)" != "" ]
25 if ! curl
-s -o "$2" "$1"
28 echo "Failed to download '$1'... aborting"
31 elif [ "$(which wget)" != "" ]
33 if ! wget
"$1" -O "$2" -q
36 echo "Failed to download '$1'... aborting"
40 echo "Need either curl or wget to download stuff... aborting"
47 # Fetch Valgrind logs from the waterfall {{{1
49 # TODO(timurrrr,maruel): use JSON, see
50 # http://build.chromium.org/p/chromium.memory/json/help
52 rm -rf "$LOGS_DIR" # Delete old logs
55 echo "Fetching the list of builders..."
56 download
$1 "$LOGS_DIR/builders"
57 SLAVES
=$
(grep "<a href=\"builders\/" "$LOGS_DIR/builders" | \
58 grep 'td class="box"' | \
59 sed "s/.*<a href=\"builders\///" |
sed "s/\".*//" | \
65 SLAVE_NAME
=$
(echo $S |
sed -e "s/%20/ /g" -e "s/%28/(/g" -e "s/%29/)/g")
66 echo -n "Fetching builds by slave '${SLAVE_NAME}'"
67 download
$SLAVE_URL "$LOGS_DIR/slave_${S}"
69 # We speed up the 'fetch' step by skipping the builds/tests which succeeded.
70 # TODO(timurrrr): OTOH, we won't be able to check
71 # if some suppression is not used anymore.
73 # The awk script here joins the lines ending with </td> to make it possible
74 # to find the failed builds.
75 LIST_OF_BUILDS
=$
(cat "$LOGS_DIR/slave_$S" | \
76 awk 'BEGIN { buf = "" }
78 if ($0 ~ /<\/td>/) { buf = (buf $0); }
80 if (buf) { print buf; buf="" }
84 END {if (buf) print buf}' | \
85 grep "success\|failure" | \
88 grep -v "failed compile" | \
89 sed "s/.*\/builds\///" |
sed "s/\".*//")
91 for BUILD
in $LIST_OF_BUILDS
93 # We'll fetch a few tiny URLs now, let's use a temp file.
94 TMPFILE
=$
(mktemp
-t memory_waterfall.XXXXXX
)
95 download
$SLAVE_URL/builds
/$BUILD "$TMPFILE"
97 REPORT_FILE
="$LOGS_DIR/report_${S}_${BUILD}"
98 rm -f $REPORT_FILE 2>/dev
/null || true
# make sure it doesn't exist
100 REPORT_URLS
=$
(grep -o "[0-9]\+/steps/\(memory\|heapcheck\).*/logs/[0-9A-F]\{16\}" \
102 || true
) # `true` is to succeed on empty output
103 FAILED_TESTS
=$
(grep -o "[0-9]\+/steps/\(memory\|heapcheck\).*/logs/[A-Za-z0-9_.]\+" \
104 "$TMPFILE" |
grep -v "[0-9A-F]\{16\}" \
105 |
grep -v "stdio" || true
)
107 for REPORT
in $REPORT_URLS
109 download
"$SLAVE_URL/builds/$REPORT/text" "$TMPFILE"
110 echo "" >> "$TMPFILE" # Add a newline at the end
111 cat "$TMPFILE" |
tr -d '\r' >> "$REPORT_FILE"
114 for FAILURE
in $FAILED_TESTS
116 echo -n "FAILED:" >> "$REPORT_FILE"
117 echo "$FAILURE" |
sed -e "s/.*\/logs\///" -e "s/\/.*//" \
122 echo $SLAVE_URL/builds
/$BUILD >> "$REPORT_FILE"
129 match_suppressions
() {
130 PYTHONPATH
=$THISDIR/..
/python
/google \
131 python
"$THISDIR/test_suppressions.py" "$LOGS_DIR/report_"*
134 match_gtest_excludes
() {
135 for PLATFORM
in "Linux" "Chromium%20Mac" "Chromium%20OS"
138 echo "Test failures on ${PLATFORM}:" |
sed "s/%20/ /"
139 grep -h -o "^FAILED:.*" -R "$LOGS_DIR"/*${PLATFORM}* | \
140 grep -v "FAILS\|FLAKY" |
sort |
uniq | \
141 sed -e "s/^FAILED://" -e "s/^/ /"
142 # Don't put any operators between "grep | sed" and "RESULT=$PIPESTATUS"
145 if [ "$RESULT" == 1 ]
150 echo " Note: we don't check for failures already excluded locally yet"
151 echo " TODO(timurrrr): don't list tests we've already excluded locally"
155 echo "Note: we don't print FAILS/FLAKY tests and 1200s-timeout failures"
158 if [ "$1" = "fetch" ]
160 fetch_logs
$WATERFALL_PAGE
161 fetch_logs
$WATERFALL_FYI_PAGE
162 elif [ "$1" = "match" ]
166 elif [ "$1" = "blame" ]
168 echo The blame
command died of bitrot. If you need it
, please reimplement it.
169 echo Reimplementation is blocked on http
://crbug.com
/82688
171 THISNAME
=$
(basename "${0}")
172 echo "Usage: $THISNAME fetch|match"
173 echo " fetch - Fetch Valgrind logs from the memory waterfall"
174 echo " match - Test the local suppression files against the downloaded logs"