| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Utility functions used by Generational and Mutational ClusterFuzz | 6 """Utility functions used by Generational and Mutational ClusterFuzz |
| 7 fuzzers.""" | 7 fuzzers.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import os | 10 import os |
| 11 import random | 11 import random |
| 12 import string | 12 import string |
| 13 import sys | 13 import sys |
| 14 import tempfile | 14 import tempfile |
| 15 | 15 |
| 16 APP_PATH_KEY = 'APP_PATH' | 16 APP_PATH_KEY = 'APP_PATH' |
| 17 FLAGS_PREFIX = 'flags-' | 17 FLAGS_PREFIX = 'flags-' |
| 18 FUZZ_PREFIX = 'fuzz-' | 18 FUZZ_PREFIX = 'fuzz-' |
| 19 IPC_FUZZER_APPLICATION = 'ipc_fuzzer' |
| 19 IPC_REPLAY_APPLICATION = 'ipc_fuzzer_replay' | 20 IPC_REPLAY_APPLICATION = 'ipc_fuzzer_replay' |
| 20 IPCDUMP_EXTENSION = '.ipcdump' | 21 IPCDUMP_EXTENSION = '.ipcdump' |
| 21 LAUNCH_PREFIXES = [ | 22 LAUNCH_PREFIXES = [ |
| 22 '--gpu-launcher', | 23 '--gpu-launcher', |
| 23 '--plugin-launcher', | 24 '--plugin-launcher', |
| 24 '--ppapi-plugin-launcher', | 25 '--ppapi-plugin-launcher', |
| 25 '--renderer-cmd-prefix', | 26 '--renderer-cmd-prefix', |
| 26 '--utility-cmd-prefix', | 27 '--utility-cmd-prefix', |
| 27 ] | 28 ] |
| 28 | 29 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 file_handle = open(flags_file_path, 'w') | 42 file_handle = open(flags_file_path, 'w') |
| 42 file_handle.write(file_content) | 43 file_handle.write(file_content) |
| 43 file_handle.close() | 44 file_handle.close() |
| 44 | 45 |
| 45 def create_temp_file(): | 46 def create_temp_file(): |
| 46 """Create a temporary file.""" | 47 """Create a temporary file.""" |
| 47 temp_file = tempfile.NamedTemporaryFile(delete=False) | 48 temp_file = tempfile.NamedTemporaryFile(delete=False) |
| 48 temp_file.close() | 49 temp_file.close() |
| 49 return temp_file.name | 50 return temp_file.name |
| 50 | 51 |
| 52 def get_fuzzer_application_name(): |
| 53 """Get the application name for the fuzzer binary.""" |
| 54 return application_name_for_platform(IPC_FUZZER_APPLICATION) |
| 55 |
| 56 def get_replay_application_name(): |
| 57 """Get the application name for the replay binary.""" |
| 58 return application_name_for_platform(IPC_REPLAY_APPLICATION) |
| 59 |
| 51 def parse_arguments(): | 60 def parse_arguments(): |
| 52 """Parse fuzzer arguments.""" | 61 """Parse fuzzer arguments.""" |
| 53 parser = argparse.ArgumentParser() | 62 parser = argparse.ArgumentParser() |
| 54 parser.add_argument('--input_dir') | 63 parser.add_argument('--input_dir') |
| 55 parser.add_argument('--output_dir') | 64 parser.add_argument('--output_dir') |
| 56 parser.add_argument('--no_of_files', type=int) | 65 parser.add_argument('--no_of_files', type=int) |
| 57 args = parser.parse_args(); | 66 args = parser.parse_args(); |
| 58 if (not args.input_dir or | 67 if (not args.input_dir or |
| 59 not args.output_dir or | 68 not args.output_dir or |
| 60 not args.no_of_files): | 69 not args.no_of_files): |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 return 'MAC' | 92 return 'MAC' |
| 84 | 93 |
| 85 assert False, 'Unknown platform' | 94 assert False, 'Unknown platform' |
| 86 | 95 |
| 87 def get_application_path(): | 96 def get_application_path(): |
| 88 """Return chrome application path.""" | 97 """Return chrome application path.""" |
| 89 if APP_PATH_KEY not in os.environ: | 98 if APP_PATH_KEY not in os.environ: |
| 90 sys.exit( | 99 sys.exit( |
| 91 'Environment variable %s should be set to chrome path.' % APP_PATH_KEY) | 100 'Environment variable %s should be set to chrome path.' % APP_PATH_KEY) |
| 92 | 101 |
| 93 return os.environ[APP_PATH_KEY] | 102 return os.environ[APP_PATH_KEY] |
| OLD | NEW |