2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # Script to run tests under tools/valgrind/chrome_tests.sh
7 # in a loop looking for rare/flaky valgrind warnings, and
8 # generate suppressions for them, to be later filed as bugs
9 # and added to our suppressions file.
11 # FIXME: Layout tests are a bit funny - they have their own
12 # sharding control, and should probably be tweaked to obey
13 # GTEST_SHARD_INDEX/GTEST_TOTAL_SHARDS like the rest,
14 # but they take days and days to run, so they are left
19 echo "Please run from parent directory of chrome and build directories"
25 echo "Usage: shard-all-tests.sh [BUILDTYPE=Release] target [target ...]"
26 echo "Example: shard-all-tests.sh ui_tests"
33 # Regexp to match any valgrind error
34 PATTERN
="ERROR SUMMARY: [^0]|are definitely|uninitialised|Unhandled exception|\
35 Invalid read|Invalid write|Invalid free|Source and desti|Mismatched free|\
36 unaddressable byte|vex x86|impossible|Assertion|INTERNAL ERROR|finish writing|OUCH"
40 BUILDTYPE
=Debug
) BUILDTYPE
=Debug
; shift ;;
41 BUILDTYPE
=Release
) BUILDTYPE
=Release
; shift ;;
42 BUILDTYPE
=*) echo "unknown build type $1"; exit 1;;
48 echo $TESTS |
tr ' ' '\012' |
grep -v layout_tests || true
49 echo $TESTS |
grep -q layout_tests
&& echo test_shell || true
50 echo $TESTS |
grep -q ui_tests
&& echo chrome || true
53 # Wrap xcodebuild to take same arguments as our make, more or less
58 chrome
) xcodebuild
-configuration $BUILDTYPE -project chrome
/chrome.xcodeproj
-target chrome
;;
59 ui_tests
) xcodebuild
-configuration $BUILDTYPE -project chrome
/chrome.xcodeproj
-target ui_tests
;;
60 base_unittests
) xcodebuild
-configuration $BUILDTYPE -project base
/base.xcodeproj
-target base_unittests
;;
61 net_unittests
) xcodebuild
-configuration $BUILDTYPE -project net
/net.xcodeproj
-target net_unittests
;;
62 *) echo "dunno how to build $target yet"; exit 1 ;;
74 # Lame way to autodetect whether 'make' or 'hammer' is in use
77 make -j4 BUILDTYPE
=$1 $@
79 # fixme: obey buildtype
86 *) echo "don't know how to build on os $OS"
91 TESTS_BUILDABLE
=`what_to_build`
92 echo building
$TESTS_BUILDABLE
93 build_tests
$BUILDTYPE $TESTS_BUILDABLE
95 # Divide each test suite up into 100 shards, as first step
96 # in tracking down exact source of errors.
97 export GTEST_TOTAL_SHARDS
=100
99 rm -rf *.vlog
*.vtmp || true
102 while test $iter -lt 1000
104 for testname
in $TESTS
106 export GTEST_SHARD_INDEX
=0
107 while test $GTEST_SHARD_INDEX -lt $GTEST_TOTAL_SHARDS
110 sh tools
/valgrind
/chrome_tests.sh
-b xcodebuild
/$BUILDTYPE -t ${testname} --tool_flags="--nocleanup_on_exit" > ${testname}_
$i.vlog
2>&1 || true
111 mv valgrind.tmp
${testname}_
$i.vtmp
112 GTEST_SHARD_INDEX
=`expr $GTEST_SHARD_INDEX + 1`
116 # Save any interesting log files from this iteration
117 # Also show interesting lines on stdout, to make tail -f more interesting
118 if egrep "$PATTERN" *.vlog
120 mkdir
-p shard-results
/$iter
121 mv `egrep -l "$PATTERN" *.vlog` shard-results
/$iter
122 # ideally we'd only save the .vtmp's corresponding to the .vlogs we saved
123 mv *.vtmp shard-results
/$iter
126 rm -rf *.vlog
*.vtmp || true
127 iter
=`expr $iter + 1`