Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: tools/ipc_fuzzer/mutate/ipc_fuzzer_gen.py

Issue 1000373004: Combine traits for IPC mutation and generation fuzzing plus other refactoring. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define frequency as a constant and reorder arguments in ipc_fuzzer_gen.py Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/ipc_fuzzer/mutate/generator.cc ('k') | tools/ipc_fuzzer/mutate/ipc_fuzzer_mut.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Generational ClusterFuzz fuzzer. It generates IPC messages using 6 """Generational ClusterFuzz fuzzer. It generates IPC messages using
7 GenerateTraits. Support of GenerateTraits for different types will be gradually 7 GenerateTraits. Support of GenerateTraits for different types will be gradually
8 added. 8 added.
9 """ 9 """
10 10
11 import os 11 import os
12 import random 12 import random
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 import utils 15 import utils
16 16
17 IPC_GENERATE_APPLICATION = 'ipc_fuzzer_generate' 17 FUZZER_NAME_OPTION = '--fuzzer-name=generate'
18 IPC_REPLAY_APPLICATION = 'ipc_fuzzer_replay'
19 MAX_IPC_MESSAGES_PER_TESTCASE = 1500 18 MAX_IPC_MESSAGES_PER_TESTCASE = 1500
20 19
21 20
22 class GenerationalFuzzer: 21 class GenerationalFuzzer:
23 def parse_arguments(self): 22 def parse_arguments(self):
24 self.args = utils.parse_arguments() 23 self.args = utils.parse_arguments()
25 24
26 def set_application_paths(self): 25 def set_application_paths(self):
27 chrome_application_path = utils.get_application_path() 26 chrome_application_path = utils.get_application_path()
28 chrome_application_directory = os.path.dirname(chrome_application_path) 27 chrome_application_directory = os.path.dirname(chrome_application_path)
29 self.ipc_generate_binary = utils.application_name_for_platform( 28 self.ipc_fuzzer_binary = utils.get_fuzzer_application_name()
30 IPC_GENERATE_APPLICATION) 29 self.ipc_replay_binary = utils.get_replay_application_name()
31 self.ipc_replay_binary = utils.application_name_for_platform( 30 self.ipc_fuzzer_binary_path = os.path.join(
32 IPC_REPLAY_APPLICATION) 31 chrome_application_directory, self.ipc_fuzzer_binary)
33 self.ipc_generate_binary_path = os.path.join(
34 chrome_application_directory, self.ipc_generate_binary)
35 self.ipc_replay_binary_path = os.path.join( 32 self.ipc_replay_binary_path = os.path.join(
36 chrome_application_directory, self.ipc_replay_binary) 33 chrome_application_directory, self.ipc_replay_binary)
37 34
38 def generate_ipcdump_testcase(self): 35 def generate_ipcdump_testcase(self):
39 ipcdump_testcase_path = ( 36 ipcdump_testcase_path = (
40 utils.random_ipcdump_testcase_path(self.args.output_dir)) 37 utils.random_ipcdump_testcase_path(self.args.output_dir))
41 num_ipc_messages = random.randint(1, MAX_IPC_MESSAGES_PER_TESTCASE) 38 num_ipc_messages = random.randint(1, MAX_IPC_MESSAGES_PER_TESTCASE)
42 count_option = '--count=%d' % num_ipc_messages 39 count_option = '--count=%d' % num_ipc_messages
43 40
44 cmd = [self.ipc_generate_binary_path, count_option, ipcdump_testcase_path] 41 cmd = [
42 self.ipc_fuzzer_binary_path,
43 FUZZER_NAME_OPTION,
44 count_option,
45 ipcdump_testcase_path,
46 ]
45 47
46 if subprocess.call(cmd): 48 if subprocess.call(cmd):
47 sys.exit('%s failed.' % self.ipc_generate_binary) 49 sys.exit('%s failed.' % self.ipc_fuzzer_binary)
48 50
49 utils.create_flags_file(ipcdump_testcase_path, self.ipc_replay_binary_path) 51 utils.create_flags_file(ipcdump_testcase_path, self.ipc_replay_binary_path)
50 52
51 def main(self): 53 def main(self):
52 self.parse_arguments() 54 self.parse_arguments()
53 self.set_application_paths() 55 self.set_application_paths()
54 for _ in xrange(self.args.no_of_files): 56 for _ in xrange(self.args.no_of_files):
55 self.generate_ipcdump_testcase() 57 self.generate_ipcdump_testcase()
56 58
57 return 0 59 return 0
58 60
59 if __name__ == "__main__": 61 if __name__ == "__main__":
60 fuzzer = GenerationalFuzzer() 62 fuzzer = GenerationalFuzzer()
61 sys.exit(fuzzer.main()) 63 sys.exit(fuzzer.main())
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/mutate/generator.cc ('k') | tools/ipc_fuzzer/mutate/ipc_fuzzer_mut.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698