Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2016 the V8 project 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. |
| 5 | |
| 6 | # A simple harness that downloads and runs 'jsfunfuzz' against d8. This |
| 7 | # takes a long time because it runs many iterations and is intended for |
| 8 | # automated usage. The package containing 'jsfunfuzz' can be found as an |
| 9 | # attachment to this bug: |
| 10 | # https://bugzilla.mozilla.org/show_bug.cgi?id=jsfunfuzz |
| 11 | |
| 12 | JSFUNFUZZ_URL="https://bugzilla.mozilla.org/attachment.cgi?id=310631" |
| 13 | JSFUNFUZZ_MD5="d0e497201c5cd7bffbb1cdc1574f4e32" |
| 14 | |
| 15 | v8_root=$(readlink -f $(dirname $BASH_SOURCE)/../../) |
| 16 | jsfunfuzz_dir="$v8_root/tools/jsfunfuzz" |
| 17 | cd "$jsfunfuzz_dir" |
| 18 | |
| 19 | if [ -n "$1" ]; then |
| 20 | d8="${v8_root}/$1" |
| 21 | else |
| 22 | d8="${v8_root}/d8" |
| 23 | fi |
| 24 | |
| 25 | if [ ! -f "$d8" ]; then |
| 26 | echo "Failed to find d8 binary: $d8" |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | # Deprecated download method. A prepatched archive is downloaded as a hook |
| 31 | # if jsfunfuzz=1 is specified as a gyp flag. Requires google.com authentication |
| 32 | # for google storage. |
| 33 | if [ "$3" == "--download" ]; then |
| 34 | |
| 35 | jsfunfuzz_file="$v8_root/tools/jsfunfuzz.zip" |
| 36 | if [ ! -f "$jsfunfuzz_file" ]; then |
| 37 | echo "Downloading $jsfunfuzz_file ..." |
| 38 | wget -q -O "$jsfunfuzz_file" $JSFUNFUZZ_URL || exit 1 |
| 39 | fi |
| 40 | |
| 41 | jsfunfuzz_sum=$(md5sum "$jsfunfuzz_file" | awk '{ print $1 }') |
| 42 | if [ $jsfunfuzz_sum != $JSFUNFUZZ_MD5 ]; then |
| 43 | echo "Failed to verify checksum!" |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | if [ ! -d "$jsfunfuzz_dir" ]; then |
| 48 | echo "Unpacking into $jsfunfuzz_dir ..." |
| 49 | unzip "$jsfunfuzz_file" -d "$jsfunfuzz_dir" || exit 1 |
| 50 | echo "Patching runner ..." |
| 51 | cat << EOF | patch -s -p0 -d "$v8_root" |
| 52 | --- tools/jsfunfuzz/jsfunfuzz/multi_timed_run.py~ |
| 53 | +++ tools/jsfunfuzz/jsfunfuzz/multi_timed_run.py |
| 54 | @@ -125,7 +125,7 @@ |
| 55 | |
| 56 | def many_timed_runs(): |
| 57 | iteration = 0 |
| 58 | - while True: |
| 59 | + while iteration < 100: |
| 60 | iteration += 1 |
| 61 | logfilename = "w%d" % iteration |
| 62 | one_timed_run(logfilename) |
| 63 | EOF |
| 64 | fi |
| 65 | |
| 66 | fi |
| 67 | |
| 68 | flags='--debug-code --expose-gc --verify-gc' |
| 69 | python -u "$jsfunfuzz_dir/jsfunfuzz/multi_timed_run.py" 300 \ |
| 70 | "$d8" $flags "$jsfunfuzz_dir/jsfunfuzz/jsfunfuzz.js" |
| 71 | exit_code=$(cat w* | grep " looking good" -c) |
| 72 | exit_code=$((100-exit_code)) |
| 73 | |
| 74 | if [ -n "$2" ]; then |
| 75 | archive="$2" |
| 76 | else |
| 77 | archive=fuzz-results-$(date +%Y%m%d%H%M%S).tar.bz2 |
| 78 | fi |
| 79 | echo "Creating archive $archive" |
| 80 | tar -cjf $archive err-* w* |
| 81 | rm -f err-* w* |
| 82 | |
| 83 | echo "Total failures: $exit_code" |
| 84 | exit $exit_code |