fuchsia_fuzzctl_test/
options.rs

1// Copyright 2022 The Fuchsia 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
5use fidl_fuchsia_fuzzer as fuzz;
6use fuchsia_fuzzctl::constants::*;
7
8/// Add defaults values to an `Options` struct.
9pub fn add_defaults(options: &mut fuzz::Options) {
10    options.runs = options.runs.or(Some(0));
11    options.max_total_time = options.max_total_time.or(Some(0));
12    options.seed = options.seed.or(Some(0));
13    options.max_input_size = options.max_input_size.or(Some(1 * BYTES_PER_MB));
14    options.mutation_depth = options.mutation_depth.or(Some(5));
15    options.dictionary_level = options.dictionary_level.or(Some(0));
16    options.detect_exits = options.detect_exits.or(Some(false));
17    options.detect_leaks = options.detect_leaks.or(Some(false));
18    options.run_limit = options.run_limit.or(Some(20 * NANOS_PER_MINUTE));
19    options.malloc_limit = options.malloc_limit.or(Some(2 * BYTES_PER_GB));
20    options.oom_limit = options.oom_limit.or(Some(2 * BYTES_PER_GB));
21    options.purge_interval = options.purge_interval.or(Some(1 * NANOS_PER_SECOND));
22    options.malloc_exitcode = options.malloc_exitcode.or(Some(2000));
23    options.death_exitcode = options.death_exitcode.or(Some(2001));
24    options.leak_exitcode = options.leak_exitcode.or(Some(2002));
25    options.oom_exitcode = options.oom_exitcode.or(Some(2003));
26    options.pulse_interval = options.pulse_interval.or(Some(20 * NANOS_PER_SECOND));
27    options.debug = options.debug.or(Some(false));
28    options.print_final_stats = options.print_final_stats.or(Some(false));
29    options.use_value_profile = options.use_value_profile.or(Some(false));
30    if options.sanitizer_options.is_none() {
31        options.sanitizer_options =
32            Some(fuzz::SanitizerOptions { name: String::default(), value: String::default() });
33    }
34}