• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 the V8 project authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import random
6
7# List of configuration experiments for correctness fuzzing.
8# List of <probability>, <1st config name>, <2nd config name>, <2nd d8>.
9# Probabilities must add up to 100.
10FOOZZIE_EXPERIMENTS = [
11  [5, 'ignition', 'ignition_asm', 'd8'],
12  [5, 'ignition', 'trusted', 'd8'],
13  [5, 'ignition', 'trusted_opt', 'd8'],
14  [10, 'ignition', 'slow_path', 'd8'],
15  [5, 'ignition', 'slow_path_opt', 'd8'],
16  [25, 'ignition', 'ignition_turbo', 'd8'],
17  [20, 'ignition', 'ignition_turbo_opt', 'd8'],
18  [5, 'ignition_turbo_opt', 'ignition_turbo_opt', 'clang_x86/d8'],
19  [5, 'ignition_turbo', 'ignition_turbo', 'clang_x86/d8'],
20  [5, 'ignition', 'ignition', 'clang_x86/d8'],
21  [5, 'ignition', 'ignition', 'clang_x64_v8_arm64/d8'],
22  [5, 'ignition', 'ignition', 'clang_x86_v8_arm/d8'],
23]
24
25class Config(object):
26  def __init__(self, name, rng=None):
27    self.name = name
28    self.rng = rng or random.Random()
29
30  def choose_foozzie_flags(self):
31    """Randomly chooses a configuration from FOOZZIE_EXPERIMENTS.
32
33    Returns: List of flags to pass to v8_foozzie.py fuzz harness.
34    """
35    acc = 0
36    threshold = self.rng.random() * 100
37    for prob, first_config, second_config, second_d8 in FOOZZIE_EXPERIMENTS:
38      acc += prob
39      if acc > threshold:
40        return [
41          '--first-config=' + first_config,
42          '--second-config=' + second_config,
43          '--second-d8=' + second_d8,
44        ]
45    assert False
46