diff options
author | Nico Weber <thakis@chromium.org> | 2021-05-17 20:14:17 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-07-25 21:15:09 -0700 |
commit | 2cc583cc7e9d675e4b6d2cd3953389f8c219091d (patch) | |
tree | fee036fb6fd9e29d4875bdc3dd039288e0170fd3 /fuzzers | |
parent | 1a96551a279242efef41468357e38d3091e884bc (diff) | |
download | zucchini-2cc583cc7e9d675e4b6d2cd3953389f8c219091d.tar.gz |
build: Convert components/zucchini/fuzzers/BUILD.gn to py3
Bug: 1205597
Change-Id: I19c9513db7587d843a4cc8edc9b7267992f65a2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897540
Auto-Submit: Nico Weber <thakis@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883586}
NOKEYCHECK=True
GitOrigin-RevId: 27cc62076c62d78f6d67edaa93453aebd667d130
Diffstat (limited to 'fuzzers')
-rw-r--r-- | fuzzers/BUILD.gn | 7 | ||||
-rwxr-xr-x | fuzzers/create_seed_file_pair.py | 15 | ||||
-rwxr-xr-x | fuzzers/generate_fuzzer_data.py | 4 |
3 files changed, 11 insertions, 15 deletions
diff --git a/fuzzers/BUILD.gn b/fuzzers/BUILD.gn index 613ac99..90c436e 100644 --- a/fuzzers/BUILD.gn +++ b/fuzzers/BUILD.gn @@ -2,7 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//build/config/python.gni") import("//testing/libfuzzer/fuzzer_test.gni") import("//third_party/protobuf/proto_library.gni") @@ -72,8 +71,7 @@ proto_library("zucchini_file_pair_proto") { # Disabled on Windows due to crbug/844826. if (current_toolchain == host_toolchain && !is_win) { # Raw Apply Fuzzer Seed: - # TODO(crbug.com/1112471): Get this to run cleanly under Python 3. - python2_action("zucchini_raw_apply_seed") { + action("zucchini_raw_apply_seed") { script = "generate_fuzzer_data.py" args = [ @@ -109,8 +107,7 @@ if (current_toolchain == host_toolchain && !is_win) { } # ZTF Apply Fuzzer Seed: - # TODO(crbug.com/1112471): Get this to run cleanly under Python 3. - python2_action("zucchini_ztf_apply_seed") { + action("zucchini_ztf_apply_seed") { script = "generate_fuzzer_data.py" # *.ztf files are expected to be valid ZTF format. diff --git a/fuzzers/create_seed_file_pair.py b/fuzzers/create_seed_file_pair.py index 4394801..db3843f 100755 --- a/fuzzers/create_seed_file_pair.py +++ b/fuzzers/create_seed_file_pair.py @@ -40,21 +40,22 @@ def parse_args(): def read_to_proto_escaped_string(filename): """Reads a file and converts it to hex escape sequences.""" with open(filename, 'rb') as f: - # Note that string_escape escapes all non-ASCII printable characters + # Note that unicode-escape escapes all non-ASCII printable characters # excluding ", which needs to be manually escaped. - return f.read().encode('string_escape').replace('"', '\\"') + return f.read().decode('latin1').encode('unicode-escape').replace( + b'"', b'\\"') def main(): args = parse_args() # Create an ASCII string representing a protobuf. - content = [b'old_file: "{}"'.format(read_to_proto_escaped_string( - args.old_file)), - b'new_or_patch_file: "{}"'.format(read_to_proto_escaped_string( - args.new_or_patch_file))] + content = [b'old_file: "%s"' % read_to_proto_escaped_string(args.old_file), + b'new_or_patch_file: "%s"' % read_to_proto_escaped_string( + args.new_or_patch_file)] if args.imposed_matches: - content.append('imposed_matches: "{}"'.format(args.imposed_matches)) + content.append(b'imposed_matches: "%s"' % + args.imposed_matches.encode('unicode-escape')) # Encode the ASCII protobuf as a binary protobuf. ps = subprocess.Popen([args.protoc_path, '--proto_path=%s' % ABS_PATH, diff --git a/fuzzers/generate_fuzzer_data.py b/fuzzers/generate_fuzzer_data.py index 5f5867b..c76cfbc 100755 --- a/fuzzers/generate_fuzzer_data.py +++ b/fuzzers/generate_fuzzer_data.py @@ -61,9 +61,7 @@ def gen(old_file, new_file, patch_file, output_file, is_raw, is_win): ret = subprocess.call([sys.executable, os.path.join(ABS_PATH, 'create_seed_file_pair.py'), os.path.abspath(protoc), old_file, patch_file, - output_file], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + output_file]) os.remove(patch_file) return ret |