blob: 205a61b33516a46f953d931f64a65bdddf6c7bc1 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/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
12JSFUNFUZZ_URL="https://bugzilla.mozilla.org/attachment.cgi?id=310631"
13JSFUNFUZZ_MD5="d0e497201c5cd7bffbb1cdc1574f4e32"
14
15v8_root=$(readlink -f $(dirname $BASH_SOURCE)/../../)
16jsfunfuzz_dir="$v8_root/tools/jsfunfuzz"
17cd "$jsfunfuzz_dir"
18
19if [ -n "$1" ]; then
20 d8="${v8_root}/$1"
21else
22 d8="${v8_root}/d8"
23fi
24
25if [ ! -f "$d8" ]; then
26 echo "Failed to find d8 binary: $d8"
27 exit 1
28fi
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.
33if [ "$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)
63EOF
64 fi
65
66fi
67
68flags='--debug-code --expose-gc --verify-gc'
69python -u "$jsfunfuzz_dir/jsfunfuzz/multi_timed_run.py" 300 \
70 "$d8" $flags "$jsfunfuzz_dir/jsfunfuzz/jsfunfuzz.js"
71exit_code=$(cat w* | grep " looking good" -c)
72exit_code=$((100-exit_code))
73
74if [ -n "$2" ]; then
75 archive="$2"
76else
77 archive=fuzz-results-$(date +%Y%m%d%H%M%S).tar.bz2
78fi
79echo "Creating archive $archive"
80tar -cjf $archive err-* w*
81rm -f err-* w*
82
83echo "Total failures: $exit_code"
84exit $exit_code