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 [20, 'ignition', 'ignition_turbo', 'd8'], 17 [20, 'ignition', 'ignition_turbo_opt', 'd8'], 18 [4, 'ignition_turbo_opt', 'ignition_turbo_opt', 'clang_x86/d8'], 19 [4, 'ignition_turbo', 'ignition_turbo', 'clang_x86/d8'], 20 [4, 'ignition', 'ignition', 'clang_x86/d8'], 21 [5, 'ignition', 'ignition', 'clang_x64_v8_arm64/d8'], 22 [5, 'ignition', 'ignition', 'clang_x86_v8_arm/d8'], 23 [5, 'ignition', 'liftoff', 'd8'], 24 [3, 'liftoff', 'liftoff', 'clang_x86/d8'], 25] 26 27class Config(object): 28 def __init__(self, name, rng=None): 29 self.name = name 30 self.rng = rng or random.Random() 31 32 def choose_foozzie_flags(self): 33 """Randomly chooses a configuration from FOOZZIE_EXPERIMENTS. 34 35 Returns: List of flags to pass to v8_foozzie.py fuzz harness. 36 """ 37 acc = 0 38 threshold = self.rng.random() * 100 39 for prob, first_config, second_config, second_d8 in FOOZZIE_EXPERIMENTS: 40 acc += prob 41 if acc > threshold: 42 return [ 43 '--first-config=' + first_config, 44 '--second-config=' + second_config, 45 '--second-d8=' + second_d8, 46 ] 47 assert False 48