Skip to content

Commit

Permalink
Manually merging #1493 to this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
DonggeLiu committed Oct 19, 2022
1 parent 7908284 commit 72c16df
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
8 changes: 4 additions & 4 deletions common/gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import enum
import posixpath
import subprocess
from typing import List
from typing import List, Optional

from common import experiment_utils
from common import logs
Expand Down Expand Up @@ -47,7 +47,7 @@ class InstanceType(enum.Enum):
def create_instance(instance_name: str,
instance_type: InstanceType,
config: dict,
startup_script: str = None,
startup_script: Optional[str] = None,
preemptible: bool = False,
**kwargs) -> bool:
"""Creates a GCE instance with name, |instance_name|, type, |instance_type|
Expand Down Expand Up @@ -126,12 +126,12 @@ def set_default_project(cloud_project: str):
['gcloud', 'config', 'set', 'project', cloud_project])


def run_local_instance(startup_script: str = None) -> bool:
def run_local_instance(startup_script: Optional[str] = None) -> bool:
"""Does the equivalent of "create_instance" for local experiments, runs
|startup_script| in the background."""
command = ['/bin/bash', startup_script]
subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return new_process.ProcessResult(0, '', False)
return new_process.ProcessResult(0, '', False).retcode == 0


def create_instance_template(template_name, docker_image, env, project, zone):
Expand Down
6 changes: 3 additions & 3 deletions common/new_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import signal
import subprocess
import threading
from typing import List
from typing import List, Optional

from common import logs

Expand Down Expand Up @@ -72,10 +72,10 @@ def execute( # pylint: disable=too-many-locals,too-many-branches
command: List[str],
*args,
expect_zero: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
write_to_stdout=False,
# If not set, will default to PIPE.
output_file=None,
output_file: Optional[int] = None,
# Not True by default because we can't always set group on processes.
kill_children: bool = False,
**kwargs) -> ProcessResult:
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

from common import benchmark_utils
from common import filesystem
from common import fuzzer_config
from common import fuzzer_utils as common_fuzzer_utils
from common import oss_fuzz
from common import utils
from fuzzers import utils as fuzzer_utils

Expand Down Expand Up @@ -68,10 +68,10 @@ def get_real_benchmark_name(benchmark):
if not os.path.isdir(os.path.join(benchmarks_dir, real_benchmark)):
continue

if not benchmark_utils.is_oss_fuzz(real_benchmark):
if not benchmark_utils.is_oss_fuzz_benchmark(real_benchmark):
continue

config = oss_fuzz.get_config(real_benchmark)
config = fuzzer_config.get_config(real_benchmark)
if config['project'] == benchmark:
return real_benchmark

Expand Down Expand Up @@ -126,8 +126,8 @@ def get_binary_size_mb(fuzz_target_path):

def get_fuzz_target(benchmark, benchmark_path):
"""Returns the fuzz target and its path for |benchmark|."""
if benchmark_utils.is_oss_fuzz(benchmark):
fuzz_target = oss_fuzz.get_config(benchmark)['fuzz_target']
if benchmark_utils.is_oss_fuzz_benchmark(benchmark):
fuzz_target = fuzzer_config.get_config(benchmark)['fuzz_target']
else:
fuzz_target = common_fuzzer_utils.DEFAULT_FUZZ_TARGET_NAME

Expand Down
22 changes: 11 additions & 11 deletions experiment/run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sys
import tarfile
import tempfile
from typing import Dict, List
from typing import Dict, List, Optional

import jinja2
import yaml
Expand Down Expand Up @@ -232,16 +232,16 @@ def start_experiment( # pylint: disable=too-many-arguments
config_filename: str,
benchmarks: List[str],
fuzzers: List[str],
description: str = None,
no_seeds=False,
no_dictionaries=False,
oss_fuzz_corpus=False,
allow_uncommitted_changes=False,
concurrent_builds=None,
measurers_cpus=None,
runners_cpus=None,
region_coverage=False,
custom_seed_corpus_dir=None):
description: Optional[str] = None,
no_seeds: bool = False,
no_dictionaries: bool = False,
oss_fuzz_corpus: bool = False,
allow_uncommitted_changes: bool = False,
concurrent_builds: Optional[int] = None,
measurers_cpus: Optional[int] = None,
runners_cpus: Optional[int] = None,
region_coverage: bool = False,
custom_seed_corpus_dir: Optional[str] = None):
"""Start a fuzzer benchmarking experiment."""
if not allow_uncommitted_changes:
check_no_uncommitted_changes()
Expand Down
3 changes: 0 additions & 3 deletions presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ def pytype(paths: List[Path]) -> bool:
"""Run pytype on |path| if it is a python file. Return False if it fails
type checking."""
paths = [path for path in paths if is_python(path)]
if not paths:
return True

base_command = ['python3', '-m', 'pytype']
success = True

Expand Down

0 comments on commit 72c16df

Please sign in to comment.